Fossil SCM

Merge updates from trunk.

zakero 2015-05-16 02:18 skin-xekri merge
Commit 777db01e1d8de0aa0841e2e8f3cc413add9c38d8
109 files changed -4 +1 -1 +10 -2 +4 -4 +10 -8 +3 +3 +24 -2 +3 +24 -2 +3 +3 +48 -4 +4 +1 +3 +3 +3 +3 +3 +3 +227 -18 +65 -53 +8 -6 +22 +4 -1 +18 +2 -1 +9 -4 +73 -53 +1 -1 +1 -3 +5 -1 +66 -24 +49 -4 +18 -2 +3 -1 +10 -3 +4 +7 -11 +8 -15 +2 -2 +3 +19 -24 +1 +1 -1 +87 +2 -2 +29 -9 +26 -1 +20 +3 -3 +76 -17 +1 -1 +28 -10 +24 +3 -3 +6 -6 +26 -20 +32 -15 +14 -13 +11 -2 +42 -170 +178 -70 +10 -1 +102 -62 +195 -24 +9 -2 +2640 -1268 +319 -246 +92 +29 -6 +131 -18 +5 +99 -24 +6 +52 -2 +10 -2 +61 -16 +334 -269 +1 -1 +24 -1 +4 -5 +6 -4 +9 -4 +1 -1 +9 -7 +9 +12 +4 -4 +8 -1 +1 -1 +43 +1 -1 +82 -2 +1 -1 +11 -5 +35 +35 +32 -1 +5 +33 -14 +36 -5 +144 +15 -6 +9 -9 +1 +5 -1 +414 -11
- .fossil-settings/keep-glob ~ VERSION ~ auto.def ~ setup/fossil.iss ~ skins/README.md ~ skins/aht/details.txt ~ skins/black_and_white/details.txt ~ skins/blitz/css.txt ~ skins/blitz/details.txt ~ skins/blitz_no_logo/css.txt ~ skins/blitz_no_logo/details.txt ~ skins/default/details.txt ~ skins/eagle/css.txt ~ skins/eagle/details.txt ~ skins/eagle/header.txt ~ skins/enhanced1/details.txt ~ skins/khaki/details.txt ~ skins/original/details.txt ~ skins/plain_gray/details.txt ~ skins/rounded1/details.txt ~ skins/xekri/details.txt ~ src/add.c ~ src/allrepo.c ~ src/attach.c ~ src/blob.c ~ src/branch.c ~ src/browse.c ~ src/cache.c ~ src/captcha.c ~ src/checkin.c ~ src/clone.c ~ src/comformat.c ~ src/configure.c ~ src/db.c ~ src/descendants.c ~ src/diff.c ~ src/diffcmd.c ~ src/doc.c ~ src/encode.c ~ src/finfo.c ~ src/graph.c ~ src/http.c ~ src/http_socket.c ~ src/info.c ~ src/json.c ~ src/json_config.c ~ src/leaf.c ~ src/login.c ~ src/main.c ~ src/main.mk ~ src/makemake.tcl ~ src/manifest.c ~ src/merge.c ~ src/merge3.c ~ src/name.c ~ src/piechart.c ~ src/pivot.c ~ src/popen.c ~ src/rebuild.c ~ src/report.c ~ src/schema.c ~ src/search.c ~ src/setup.c ~ src/shell.c ~ src/shun.c ~ src/sitemap.c ~ src/skins.c ~ src/sqlcmd.c ~ src/sqlite3.c ~ src/sqlite3.h ~ src/stat.c ~ src/statrep.c ~ src/style.c ~ src/tag.c ~ src/th.c ~ src/th.h ~ src/th_lang.c ~ src/th_main.c ~ src/th_tcl.c ~ src/timeline.c ~ src/tkt.c ~ src/tktsetup.c ~ src/update.c ~ src/url.c ~ src/user.c ~ src/utf8.c ~ src/vfile.c ~ src/wiki.c ~ src/wikiformat.c ~ src/xfer.c ~ src/xfersetup.c ~ src/zip.c ~ test/contains-selector.test ~ test/release-checklist.wiki ~ test/th1.test ~ win/Makefile.PellesCGMake ~ win/Makefile.dmc ~ win/Makefile.mingw ~ win/Makefile.mingw.mistachkin ~ win/Makefile.msc ~ win/fossil.rc ~ www/build.wiki ~ www/changes.wiki ~ www/customgraph.md ~ www/customskin.md ~ www/event.wiki ~ www/mkindex.tcl ~ www/permutedindex.html ~ www/th1.md
D .fossil-settings/keep-glob
-4
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -1,4 +0,0 @@
1
-compat/openssl*
2
-compat/tcl*
3
-ts
4
-aut
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -1,4 +0,0 @@
1 compat/openssl*
2 compat/tcl*
3 ts
4 aut
--- a/.fossil-settings/keep-glob
+++ b/.fossil-settings/keep-glob
@@ -1,4 +0,0 @@
 
 
 
 
+1 -1
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1
-1.32
1
+1.33
22
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.32
2
--- VERSION
+++ VERSION
@@ -1,1 +1,1 @@
1 1.33
2
+10 -2
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
55
options {
66
with-openssl:path|auto|none
77
=> {Look for OpenSSL in the given path, or auto or none}
88
with-miniz=0 => {Use miniz from the source tree}
99
with-zlib:path => {Look for zlib in the given path}
10
+ with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)}
1011
with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
1112
with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
1213
with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
1314
with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
1415
with-tcl-private-stubs=0
@@ -50,12 +51,12 @@
5051
# if sqlite3_strglob() can be found as well. If we can find open() but
5152
# not strglob(), then the system SQLite is too old to link against
5253
# fossil.
5354
#
5455
if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
55
- if {![cc-check-function-in-lib sqlite3_strglob sqlite3 $extralibs]} {
56
- user-error "system sqlite3 too old (require >= 3.7.17)"
56
+ if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
57
+ user-error "system sqlite3 too old (require >= 3.8.7)"
5758
}
5859
5960
# Success. Update symbols and return.
6061
#
6162
define USE_SYSTEM_SQLITE 1
@@ -85,10 +86,16 @@
8586
# reading config.h first.
8687
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
8788
define FOSSIL_ENABLE_JSON
8889
msg-result "JSON support enabled"
8990
}
91
+
92
+if {[opt-bool with-legacy-mv-rm]} {
93
+ define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM
94
+ define FOSSIL_ENABLE_LEGACY_MV_RM
95
+ msg-result "Legacy mv/rm support enabled"
96
+}
9097
9198
if {[opt-bool with-th1-docs]} {
9299
define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS
93100
define FOSSIL_ENABLE_TH1_DOCS
94101
msg-result "TH1 embedded documentation support enabled"
@@ -292,10 +299,11 @@
292299
if {![cc-check-functions getpassphrase]} {
293300
# Haiku needs this
294301
cc-check-function-in-lib getpass bsd
295302
}
296303
cc-check-function-in-lib dlopen dl
304
+cc-check-function-in-lib sin m
297305
298306
# Check for the FuseFS library
299307
if {[opt-bool fusefs]} {
300308
if {[cc-check-function-in-lib fuse_mount fuse]} {
301309
define FOSSIL_HAVE_FUSEFS 1
302310
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
5 options {
6 with-openssl:path|auto|none
7 => {Look for OpenSSL in the given path, or auto or none}
8 with-miniz=0 => {Use miniz from the source tree}
9 with-zlib:path => {Look for zlib in the given path}
 
10 with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
11 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
12 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
13 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
14 with-tcl-private-stubs=0
@@ -50,12 +51,12 @@
50 # if sqlite3_strglob() can be found as well. If we can find open() but
51 # not strglob(), then the system SQLite is too old to link against
52 # fossil.
53 #
54 if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
55 if {![cc-check-function-in-lib sqlite3_strglob sqlite3 $extralibs]} {
56 user-error "system sqlite3 too old (require >= 3.7.17)"
57 }
58
59 # Success. Update symbols and return.
60 #
61 define USE_SYSTEM_SQLITE 1
@@ -85,10 +86,16 @@
85 # reading config.h first.
86 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
87 define FOSSIL_ENABLE_JSON
88 msg-result "JSON support enabled"
89 }
 
 
 
 
 
 
90
91 if {[opt-bool with-th1-docs]} {
92 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS
93 define FOSSIL_ENABLE_TH1_DOCS
94 msg-result "TH1 embedded documentation support enabled"
@@ -292,10 +299,11 @@
292 if {![cc-check-functions getpassphrase]} {
293 # Haiku needs this
294 cc-check-function-in-lib getpass bsd
295 }
296 cc-check-function-in-lib dlopen dl
 
297
298 # Check for the FuseFS library
299 if {[opt-bool fusefs]} {
300 if {[cc-check-function-in-lib fuse_mount fuse]} {
301 define FOSSIL_HAVE_FUSEFS 1
302
--- auto.def
+++ auto.def
@@ -5,10 +5,11 @@
5 options {
6 with-openssl:path|auto|none
7 => {Look for OpenSSL in the given path, or auto or none}
8 with-miniz=0 => {Use miniz from the source tree}
9 with-zlib:path => {Look for zlib in the given path}
10 with-legacy-mv-rm=0 => {Enable legacy behavior for mv/rm (skip checkout files)}
11 with-th1-docs=0 => {Enable TH1 for embedded documentation pages}
12 with-th1-hooks=0 => {Enable TH1 hooks for commands and web pages}
13 with-tcl:path => {Enable Tcl integration, with Tcl in the specified path}
14 with-tcl-stubs=0 => {Enable Tcl integration via stubs library mechanism}
15 with-tcl-private-stubs=0
@@ -50,12 +51,12 @@
51 # if sqlite3_strglob() can be found as well. If we can find open() but
52 # not strglob(), then the system SQLite is too old to link against
53 # fossil.
54 #
55 if {[cc-check-function-in-lib sqlite3_open sqlite3 $extralibs]} {
56 if {![cc-check-function-in-lib sqlite3_malloc64 sqlite3 $extralibs]} {
57 user-error "system sqlite3 too old (require >= 3.8.7)"
58 }
59
60 # Success. Update symbols and return.
61 #
62 define USE_SYSTEM_SQLITE 1
@@ -85,10 +86,16 @@
86 # reading config.h first.
87 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_JSON
88 define FOSSIL_ENABLE_JSON
89 msg-result "JSON support enabled"
90 }
91
92 if {[opt-bool with-legacy-mv-rm]} {
93 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_LEGACY_MV_RM
94 define FOSSIL_ENABLE_LEGACY_MV_RM
95 msg-result "Legacy mv/rm support enabled"
96 }
97
98 if {[opt-bool with-th1-docs]} {
99 define-append EXTRA_CFLAGS -DFOSSIL_ENABLE_TH1_DOCS
100 define FOSSIL_ENABLE_TH1_DOCS
101 msg-result "TH1 embedded documentation support enabled"
@@ -292,10 +299,11 @@
299 if {![cc-check-functions getpassphrase]} {
300 # Haiku needs this
301 cc-check-function-in-lib getpass bsd
302 }
303 cc-check-function-in-lib dlopen dl
304 cc-check-function-in-lib sin m
305
306 # Check for the FuseFS library
307 if {[opt-bool fusefs]} {
308 if {[cc-check-function-in-lib fuse_mount fuse]} {
309 define FOSSIL_HAVE_FUSEFS 1
310
--- 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
--- 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
--- 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
--- 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
--- skins/blitz/css.txt
+++ skins/blitz/css.txt
@@ -1054,26 +1054,48 @@
10541054
* Displays chronologically-ordered check-ins with a branch graph.
10551055
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
10561056
tr.timelineCurrent {
10571057
border-left: 2px solid orange;
10581058
background-color: #ffc;
1059
+ border-bottom: 1px solid #ddd;
1060
+ border-right: 1px solid #ddd;
10591061
}
10601062
10611063
tr.timelineSelected {
10621064
border-left: 2px solid orange;
10631065
background-color: #ffffe8;
1066
+ border-bottom: 1px solid #ddd;
1067
+ border-right: 1px solid #ddd;
10641068
}
10651069
10661070
tr.timelineCurrent td.timelineTableCell {
10671071
}
10681072
10691073
tr.timelineSpacer {
10701074
}
1075
+
1076
+tr.timelineBottom td {
1077
+ border-bottom: 0;
1078
+}
10711079
10721080
div.timelineDate {
1073
- font-weight: bold;
1074
- white-space: nowrap;
1081
+ font-weight: bold;
1082
+ white-space: nowrap;
1083
+}
1084
+
1085
+td.timelineTime {
1086
+ vertical-align: top;
1087
+ text-align: right;
1088
+ white-space: nowrap;
1089
+ border-bottom: 0;
1090
+}
1091
+
1092
+td.timelineGraph {
1093
+ width: 20px;
1094
+ text-align: left;
1095
+ vertical-align: top;
1096
+ border-bottom: 0;
10751097
}
10761098
10771099
a.timelineHistLink {
10781100
text-transform: lowercase;
10791101
}
10801102
10811103
ADDED skins/blitz/details.txt
--- skins/blitz/css.txt
+++ skins/blitz/css.txt
@@ -1054,26 +1054,48 @@
1054 * Displays chronologically-ordered check-ins with a branch graph.
1055 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
1056 tr.timelineCurrent {
1057 border-left: 2px solid orange;
1058 background-color: #ffc;
 
 
1059 }
1060
1061 tr.timelineSelected {
1062 border-left: 2px solid orange;
1063 background-color: #ffffe8;
 
 
1064 }
1065
1066 tr.timelineCurrent td.timelineTableCell {
1067 }
1068
1069 tr.timelineSpacer {
1070 }
 
 
 
 
1071
1072 div.timelineDate {
1073 font-weight: bold;
1074 white-space: nowrap;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1075 }
1076
1077 a.timelineHistLink {
1078 text-transform: lowercase;
1079 }
1080
1081 DDED skins/blitz/details.txt
--- skins/blitz/css.txt
+++ skins/blitz/css.txt
@@ -1054,26 +1054,48 @@
1054 * Displays chronologically-ordered check-ins with a branch graph.
1055 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
1056 tr.timelineCurrent {
1057 border-left: 2px solid orange;
1058 background-color: #ffc;
1059 border-bottom: 1px solid #ddd;
1060 border-right: 1px solid #ddd;
1061 }
1062
1063 tr.timelineSelected {
1064 border-left: 2px solid orange;
1065 background-color: #ffffe8;
1066 border-bottom: 1px solid #ddd;
1067 border-right: 1px solid #ddd;
1068 }
1069
1070 tr.timelineCurrent td.timelineTableCell {
1071 }
1072
1073 tr.timelineSpacer {
1074 }
1075
1076 tr.timelineBottom td {
1077 border-bottom: 0;
1078 }
1079
1080 div.timelineDate {
1081 font-weight: bold;
1082 white-space: nowrap;
1083 }
1084
1085 td.timelineTime {
1086 vertical-align: top;
1087 text-align: right;
1088 white-space: nowrap;
1089 border-bottom: 0;
1090 }
1091
1092 td.timelineGraph {
1093 width: 20px;
1094 text-align: left;
1095 vertical-align: top;
1096 border-bottom: 0;
1097 }
1098
1099 a.timelineHistLink {
1100 text-transform: lowercase;
1101 }
1102
1103 DDED skins/blitz/details.txt
--- 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;
--- skins/blitz_no_logo/css.txt
+++ skins/blitz_no_logo/css.txt
@@ -1054,26 +1054,48 @@
10541054
* Displays chronologically-ordered check-ins with a branch graph.
10551055
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
10561056
tr.timelineCurrent {
10571057
border-left: 2px solid orange;
10581058
background-color: #ffc;
1059
+ border-bottom: 1px solid #ddd;
1060
+ border-right: 1px solid #ddd;
10591061
}
10601062
10611063
tr.timelineSelected {
10621064
border-left: 2px solid orange;
10631065
background-color: #ffffe8;
1066
+ border-bottom: 1px solid #ddd;
1067
+ border-right: 1px solid #ddd;
10641068
}
10651069
10661070
tr.timelineCurrent td.timelineTableCell {
10671071
}
10681072
10691073
tr.timelineSpacer {
10701074
}
1075
+
1076
+tr.timelineBottom td {
1077
+ border-bottom: 0;
1078
+}
10711079
10721080
div.timelineDate {
1073
- font-weight: bold;
1074
- white-space: nowrap;
1081
+ font-weight: bold;
1082
+ white-space: nowrap;
1083
+}
1084
+
1085
+td.timelineTime {
1086
+ vertical-align: top;
1087
+ text-align: right;
1088
+ white-space: nowrap;
1089
+ border-bottom: 0;
1090
+}
1091
+
1092
+td.timelineGraph {
1093
+ width: 20px;
1094
+ text-align: left;
1095
+ vertical-align: top;
1096
+ border-bottom: 0;
10751097
}
10761098
10771099
a.timelineHistLink {
10781100
text-transform: lowercase;
10791101
}
10801102
10811103
ADDED skins/blitz_no_logo/details.txt
10821104
ADDED skins/default/details.txt
--- skins/blitz_no_logo/css.txt
+++ skins/blitz_no_logo/css.txt
@@ -1054,26 +1054,48 @@
1054 * Displays chronologically-ordered check-ins with a branch graph.
1055 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
1056 tr.timelineCurrent {
1057 border-left: 2px solid orange;
1058 background-color: #ffc;
 
 
1059 }
1060
1061 tr.timelineSelected {
1062 border-left: 2px solid orange;
1063 background-color: #ffffe8;
 
 
1064 }
1065
1066 tr.timelineCurrent td.timelineTableCell {
1067 }
1068
1069 tr.timelineSpacer {
1070 }
 
 
 
 
1071
1072 div.timelineDate {
1073 font-weight: bold;
1074 white-space: nowrap;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1075 }
1076
1077 a.timelineHistLink {
1078 text-transform: lowercase;
1079 }
1080
1081 DDED skins/blitz_no_logo/details.txt
1082 DDED skins/default/details.txt
--- skins/blitz_no_logo/css.txt
+++ skins/blitz_no_logo/css.txt
@@ -1054,26 +1054,48 @@
1054 * Displays chronologically-ordered check-ins with a branch graph.
1055 ––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––– */
1056 tr.timelineCurrent {
1057 border-left: 2px solid orange;
1058 background-color: #ffc;
1059 border-bottom: 1px solid #ddd;
1060 border-right: 1px solid #ddd;
1061 }
1062
1063 tr.timelineSelected {
1064 border-left: 2px solid orange;
1065 background-color: #ffffe8;
1066 border-bottom: 1px solid #ddd;
1067 border-right: 1px solid #ddd;
1068 }
1069
1070 tr.timelineCurrent td.timelineTableCell {
1071 }
1072
1073 tr.timelineSpacer {
1074 }
1075
1076 tr.timelineBottom td {
1077 border-bottom: 0;
1078 }
1079
1080 div.timelineDate {
1081 font-weight: bold;
1082 white-space: nowrap;
1083 }
1084
1085 td.timelineTime {
1086 vertical-align: top;
1087 text-align: right;
1088 white-space: nowrap;
1089 border-bottom: 0;
1090 }
1091
1092 td.timelineGraph {
1093 width: 20px;
1094 text-align: left;
1095 vertical-align: top;
1096 border-bottom: 0;
1097 }
1098
1099 a.timelineHistLink {
1100 text-transform: lowercase;
1101 }
1102
1103 DDED skins/blitz_no_logo/details.txt
1104 DDED skins/default/details.txt
--- 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
+t1
3
+timeline-color-graph-lines: 1
--- 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 t1
3 timeline-color-graph-lines: 1
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -168,10 +168,58 @@
168168
}
169169
170170
tr.timelineSelected {
171171
background-color: #7EA2D9;
172172
}
173
+
174
+/* commit node */
175
+.tl-node {
176
+ width: 10px;
177
+ height: 10px;
178
+ border: 1px solid #fff;
179
+ background: #485D7B;
180
+ cursor: pointer;
181
+}
182
+
183
+/* leaf commit marker */
184
+.tl-node.leaf:after {
185
+ content: '';
186
+ position: absolute;
187
+ top: 3px;
188
+ left: 3px;
189
+ width: 4px;
190
+ height: 4px;
191
+ background: #fff;
192
+}
193
+
194
+/* up arrow */
195
+.tl-arrow.u {
196
+ margin-top: -1px;
197
+ border-width: 0 3px;
198
+ border-bottom: 7px solid #fff;
199
+}
200
+
201
+/* small up arrow */
202
+.tl-arrow.u.sm {
203
+ border-bottom: 5px solid #fff;
204
+}
205
+
206
+/* line */
207
+.tl-line {
208
+ background: #fff;
209
+ width: 2px;
210
+}
211
+
212
+/* left merge arrow */
213
+.tl-arrow.merge.l {
214
+ border-right: 3px solid #fff;
215
+}
216
+
217
+/* right merge arrow */
218
+.tl-arrow.merge.r {
219
+ border-left: 3px solid #fff;
220
+}
173221
174222
/* Side-by-side diff */
175223
table.sbsdiff {
176224
background-color: #485D7B;
177225
font-family: fixed, Dejavu Sans Mono, Monaco, Lucida Console, monospace;
@@ -264,14 +312,10 @@
264312
/* line numbers in a diff */
265313
span.diffln {
266314
color: white;
267315
}
268316
269
-#canvas {
270
- background-color: #485D7B;
271
-}
272
-
273317
.fileage tr:hover {
274318
background-color: #7EA2D9;
275319
}
276320
277321
.fileage td {
278322
279323
ADDED skins/eagle/details.txt
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -168,10 +168,58 @@
168 }
169
170 tr.timelineSelected {
171 background-color: #7EA2D9;
172 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
173
174 /* Side-by-side diff */
175 table.sbsdiff {
176 background-color: #485D7B;
177 font-family: fixed, Dejavu Sans Mono, Monaco, Lucida Console, monospace;
@@ -264,14 +312,10 @@
264 /* line numbers in a diff */
265 span.diffln {
266 color: white;
267 }
268
269 #canvas {
270 background-color: #485D7B;
271 }
272
273 .fileage tr:hover {
274 background-color: #7EA2D9;
275 }
276
277 .fileage td {
278
279 DDED skins/eagle/details.txt
--- skins/eagle/css.txt
+++ skins/eagle/css.txt
@@ -168,10 +168,58 @@
168 }
169
170 tr.timelineSelected {
171 background-color: #7EA2D9;
172 }
173
174 /* commit node */
175 .tl-node {
176 width: 10px;
177 height: 10px;
178 border: 1px solid #fff;
179 background: #485D7B;
180 cursor: pointer;
181 }
182
183 /* leaf commit marker */
184 .tl-node.leaf:after {
185 content: '';
186 position: absolute;
187 top: 3px;
188 left: 3px;
189 width: 4px;
190 height: 4px;
191 background: #fff;
192 }
193
194 /* up arrow */
195 .tl-arrow.u {
196 margin-top: -1px;
197 border-width: 0 3px;
198 border-bottom: 7px solid #fff;
199 }
200
201 /* small up arrow */
202 .tl-arrow.u.sm {
203 border-bottom: 5px solid #fff;
204 }
205
206 /* line */
207 .tl-line {
208 background: #fff;
209 width: 2px;
210 }
211
212 /* left merge arrow */
213 .tl-arrow.merge.l {
214 border-right: 3px solid #fff;
215 }
216
217 /* right merge arrow */
218 .tl-arrow.merge.r {
219 border-left: 3px solid #fff;
220 }
221
222 /* Side-by-side diff */
223 table.sbsdiff {
224 background-color: #485D7B;
225 font-family: fixed, Dejavu Sans Mono, Monaco, Lucida Console, monospace;
@@ -264,14 +312,10 @@
312 /* line numbers in a diff */
313 span.diffln {
314 color: white;
315 }
316
 
 
 
 
317 .fileage tr:hover {
318 background-color: #7EA2D9;
319 }
320
321 .fileage td {
322
323 DDED skins/eagle/details.txt
--- 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
--- skins/eagle/header.txt
+++ skins/eagle/header.txt
@@ -123,10 +123,11 @@
123123
menulink /ticket Tickets
124124
}
125125
if {[anoncap j]} {
126126
menulink /wiki Wiki
127127
}
128
+menulink /sitemap More...
128129
if {[hascap s]} {
129130
menulink /setup Admin
130131
} elseif {[hascap a]} {
131132
menulink /setup_ulist Users
132133
}
133134
134135
ADDED skins/enhanced1/details.txt
135136
ADDED skins/khaki/details.txt
136137
ADDED skins/original/details.txt
137138
ADDED skins/plain_gray/details.txt
138139
ADDED skins/rounded1/details.txt
139140
ADDED skins/xekri/details.txt
--- skins/eagle/header.txt
+++ skins/eagle/header.txt
@@ -123,10 +123,11 @@
123 menulink /ticket Tickets
124 }
125 if {[anoncap j]} {
126 menulink /wiki Wiki
127 }
 
128 if {[hascap s]} {
129 menulink /setup Admin
130 } elseif {[hascap a]} {
131 menulink /setup_ulist Users
132 }
133
134 DDED skins/enhanced1/details.txt
135 DDED skins/khaki/details.txt
136 DDED skins/original/details.txt
137 DDED skins/plain_gray/details.txt
138 DDED skins/rounded1/details.txt
139 DDED skins/xekri/details.txt
--- skins/eagle/header.txt
+++ skins/eagle/header.txt
@@ -123,10 +123,11 @@
123 menulink /ticket Tickets
124 }
125 if {[anoncap j]} {
126 menulink /wiki Wiki
127 }
128 menulink /sitemap More...
129 if {[hascap s]} {
130 menulink /setup Admin
131 } elseif {[hascap a]} {
132 menulink /setup_ulist Users
133 }
134
135 DDED skins/enhanced1/details.txt
136 DDED skins/khaki/details.txt
137 DDED skins/original/details.txt
138 DDED skins/plain_gray/details.txt
139 DDED skins/rounded1/details.txt
140 DDED skins/xekri/details.txt
--- 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
--- 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
+227 -18
--- src/add.c
+++ src/add.c
@@ -22,10 +22,28 @@
2222
#include "add.h"
2323
#include <assert.h>
2424
#include <dirent.h>
2525
#include "cygsup.h"
2626
27
+/*
28
+** WARNING: For Fossil version 1.x this value was always zero. For Fossil
29
+** 2.x, it will probably always be one. When this value is zero,
30
+** files in the checkout will not be moved by the "mv" command and
31
+** files in the checkout will not be removed by the "rm" command.
32
+**
33
+** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used,
34
+** the "mv-rm-files" setting will be consulted instead of using
35
+** this value.
36
+**
37
+** To retain the Fossil version 1.x behavior when using Fossil 2.x,
38
+** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used
39
+** -AND- the "mv-rm-files" setting must be set to zero.
40
+*/
41
+#ifndef FOSSIL_MV_RM_FILE
42
+#define FOSSIL_MV_RM_FILE (0)
43
+#endif
44
+
2745
/*
2846
** This routine returns the names of files in a working checkout that
2947
** are created by Fossil itself, and hence should not be added, deleted,
3048
** or merge, and should be omitted from "clean" and "extras" lists.
3149
**
@@ -299,12 +317,10 @@
299317
isDir = file_wd_isdir(zName);
300318
if( isDir==1 ){
301319
vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
302320
}else if( isDir==0 ){
303321
fossil_warning("not found: %s", zName);
304
- }else if( file_access(zName, R_OK) ){
305
- fossil_fatal("cannot open %s", zName);
306322
}else{
307323
char *zTreeName = &zName[nRoot];
308324
if( !forceFlag && glob_match(pIgnore, zTreeName) ){
309325
Blob ans;
310326
char cReply;
@@ -331,10 +347,58 @@
331347
glob_free(pClean);
332348
333349
add_files_in_sfile(vid);
334350
db_end_transaction(0);
335351
}
352
+
353
+/*
354
+** This function adds a file to list of files to delete from disk after
355
+** the other actions required for the parent operation have completed
356
+** successfully. The first time it is called for the current process,
357
+** it creates a temporary table named "fremove", to keep track of these
358
+** files.
359
+*/
360
+static void add_file_to_remove(
361
+ const char *zOldName /* The old name of the file on disk. */
362
+){
363
+ static int tableCreated = 0;
364
+ Blob fullOldName;
365
+ if( !tableCreated ){
366
+ db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)",
367
+ filename_collation());
368
+ tableCreated = 1;
369
+ }
370
+ file_canonical_name(zOldName, &fullOldName, 0);
371
+ db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName));
372
+ blob_reset(&fullOldName);
373
+}
374
+
375
+/*
376
+** This function deletes files from the checkout, using the file names
377
+** contained in the temporary table "fremove". The temporary table is
378
+** created on demand by the add_file_to_remove() function.
379
+**
380
+** If dryRunFlag is non-zero, no files will be removed; however, their
381
+** names will still be output.
382
+**
383
+** The temporary table "fremove" is dropped after being processed.
384
+*/
385
+static void process_files_to_remove(
386
+ int dryRunFlag /* Zero to actually operate on the file-system. */
387
+){
388
+ Stmt remove;
389
+ db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;");
390
+ while( db_step(&remove)==SQLITE_ROW ){
391
+ const char *zOldName = db_column_text(&remove, 0);
392
+ if( !dryRunFlag ){
393
+ file_delete(zOldName);
394
+ }
395
+ fossil_print("DELETED_FILE %s\n", zOldName);
396
+ }
397
+ db_finalize(&remove);
398
+ db_multi_exec("DROP TABLE fremove;");
399
+}
336400
337401
/*
338402
** COMMAND: rm
339403
** COMMAND: delete
340404
** COMMAND: forget*
@@ -341,28 +405,63 @@
341405
**
342406
** Usage: %fossil rm|delete|forget FILE1 ?FILE2 ...?
343407
**
344408
** Remove one or more files or directories from the repository.
345409
**
346
-** This command does NOT remove the files from disk. It just marks the
347
-** files as no longer being part of the project. In other words, future
348
-** changes to the named files will not be versioned.
410
+** The 'rm' and 'delete' commands do NOT normally remove the files from
411
+** disk. They just mark the files as no longer being part of the project.
412
+** In other words, future changes to the named files will not be versioned.
413
+** However, the default behavior of this command may be overridden via the
414
+** command line options listed below and/or the 'mv-rm-files' setting.
415
+**
416
+** The 'forget' command never removes files from disk, even when the command
417
+** line options and/or the 'mv-rm-files' setting would otherwise require it
418
+** to do so.
419
+**
420
+** WARNING: If the "--hard" option is specified -OR- the "mv-rm-files"
421
+** setting is non-zero, files WILL BE removed from disk as well.
422
+** This does NOT apply to the 'forget' command.
349423
**
350424
** Options:
425
+** --soft Skip removing files from the checkout.
426
+** This supersedes the --hard option.
427
+** --hard Remove files from the checkout.
351428
** --case-sensitive <BOOL> Override the case-sensitive setting.
429
+** -n|--dry-run If given, display instead of run actions.
352430
**
353431
** See also: addremove, add
354432
*/
355433
void delete_cmd(void){
356434
int i;
435
+ int removeFiles;
436
+ int dryRunFlag;
437
+ int softFlag;
438
+ int hardFlag;
357439
Stmt loop;
440
+
441
+ dryRunFlag = find_option("dry-run","n",0)!=0;
442
+ softFlag = find_option("soft",0,0)!=0;
443
+ hardFlag = find_option("hard",0,0)!=0;
358444
359445
/* We should be done with options.. */
360446
verify_all_options();
361447
362448
db_must_be_within_tree();
363449
db_begin_transaction();
450
+ if( g.argv[1][0]=='f' ){ /* i.e. "forget" */
451
+ removeFiles = 0;
452
+ }else if( softFlag ){
453
+ removeFiles = 0;
454
+ }else if( hardFlag ){
455
+ removeFiles = 1;
456
+ }else{
457
+#if FOSSIL_ENABLE_LEGACY_MV_RM
458
+ removeFiles = db_get_boolean("mv-rm-files",0);
459
+#else
460
+ removeFiles = FOSSIL_MV_RM_FILE;
461
+#endif
462
+ }
364463
db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
365464
filename_collation());
366465
for(i=2; i<g.argc; i++){
367466
Blob treeName;
368467
char *zTreeName;
@@ -382,17 +481,21 @@
382481
}
383482
384483
db_prepare(&loop, "SELECT x FROM sfile");
385484
while( db_step(&loop)==SQLITE_ROW ){
386485
fossil_print("DELETED %s\n", db_column_text(&loop, 0));
486
+ if( removeFiles ) add_file_to_remove(db_column_text(&loop, 0));
387487
}
388488
db_finalize(&loop);
389
- db_multi_exec(
390
- "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
391
- "DELETE FROM vfile WHERE rid=0 AND deleted;"
392
- );
489
+ if( !dryRunFlag ){
490
+ db_multi_exec(
491
+ "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
492
+ "DELETE FROM vfile WHERE rid=0 AND deleted;"
493
+ );
494
+ }
393495
db_end_transaction(0);
496
+ if( removeFiles ) process_files_to_remove(dryRunFlag);
394497
}
395498
396499
/*
397500
** Capture the command-line --case-sensitive option.
398501
*/
@@ -527,10 +630,18 @@
527630
}
528631
529632
/* We should be done with options.. */
530633
verify_all_options();
531634
635
+ /* Fail if unprocessed arguments are present, in case user expect the
636
+ ** addremove command to accept a list of file or directory.
637
+ */
638
+ if( g.argc>2 ){
639
+ fossil_fatal(
640
+ "%s: Can only work on the entire checkout, no arguments supported.",
641
+ g.argv[1]);
642
+ }
532643
db_must_be_within_tree();
533644
if( zCleanFlag==0 ){
534645
zCleanFlag = db_get("clean-glob", 0);
535646
}
536647
if( zIgnoreFlag==0 ){
@@ -593,11 +704,12 @@
593704
** The original name of the file is zOrig. The new filename is zNew.
594705
*/
595706
static void mv_one_file(
596707
int vid,
597708
const char *zOrig,
598
- const char *zNew
709
+ const char *zNew,
710
+ int dryRunFlag
599711
){
600712
int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
601713
zNew, filename_collation());
602714
if( x>=0 ){
603715
if( x==0 ){
@@ -607,14 +719,75 @@
607719
fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has "
608720
"not yet been committed", zOrig, zNew, zNew);
609721
}
610722
}
611723
fossil_print("RENAME %s %s\n", zOrig, zNew);
612
- db_multi_exec(
613
- "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
614
- zNew, zOrig, filename_collation(), vid
615
- );
724
+ if( !dryRunFlag ){
725
+ db_multi_exec(
726
+ "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
727
+ zNew, zOrig, filename_collation(), vid
728
+ );
729
+ }
730
+}
731
+
732
+/*
733
+** This function adds a file to list of files to move on disk after the
734
+** other actions required for the parent operation have completed
735
+** successfully. The first time it is called for the current process,
736
+** it creates a temporary table named "fmove", to keep track of these
737
+** files.
738
+*/
739
+static void add_file_to_move(
740
+ const char *zOldName, /* The old name of the file on disk. */
741
+ const char *zNewName /* The new name of the file on disk. */
742
+){
743
+ static int tableCreated = 0;
744
+ Blob fullOldName;
745
+ Blob fullNewName;
746
+ if( !tableCreated ){
747
+ db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)",
748
+ filename_collation(), filename_collation());
749
+ tableCreated = 1;
750
+ }
751
+ file_canonical_name(zOldName, &fullOldName, 0);
752
+ file_canonical_name(zNewName, &fullNewName, 0);
753
+ db_multi_exec("INSERT INTO fmove VALUES('%q','%q');",
754
+ blob_str(&fullOldName), blob_str(&fullNewName));
755
+ blob_reset(&fullNewName);
756
+ blob_reset(&fullOldName);
757
+}
758
+
759
+/*
760
+** This function moves files within the checkout, using the file names
761
+** contained in the temporary table "fmove". The temporary table is
762
+** created on demand by the add_file_to_move() function.
763
+**
764
+** If dryRunFlag is non-zero, no files will be moved; however, their
765
+** names will still be output.
766
+**
767
+** The temporary table "fmove" is dropped after being processed.
768
+*/
769
+static void process_files_to_move(
770
+ int dryRunFlag /* Zero to actually operate on the file-system. */
771
+){
772
+ Stmt move;
773
+ db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;");
774
+ while( db_step(&move)==SQLITE_ROW ){
775
+ const char *zOldName = db_column_text(&move, 0);
776
+ const char *zNewName = db_column_text(&move, 1);
777
+ if( !dryRunFlag ){
778
+ if( file_wd_islink(zOldName) ){
779
+ symlink_copy(zOldName, zNewName);
780
+ }else{
781
+ file_copy(zOldName, zNewName);
782
+ }
783
+ file_delete(zOldName);
784
+ }
785
+ fossil_print("MOVED_FILE %s\n", zOldName);
786
+ }
787
+ db_finalize(&move);
788
+ db_multi_exec("DROP TABLE fmove;");
616789
}
617790
618791
/*
619792
** COMMAND: mv
620793
** COMMAND: rename*
@@ -623,27 +796,48 @@
623796
** or: %fossil mv|rename OLDNAME... DIR
624797
**
625798
** Move or rename one or more files or directories within the repository tree.
626799
** You can either rename a file or directory or move it to another subdirectory.
627800
**
628
-** This command does NOT rename or move the files on disk. This command merely
629
-** records the fact that filenames have changed so that appropriate notations
630
-** can be made at the next commit/check-in.
801
+** The 'mv' command does NOT normally rename or move the files on disk.
802
+** This command merely records the fact that file names have changed so
803
+** that appropriate notations can be made at the next commit/check-in.
804
+** However, the default behavior of this command may be overridden via
805
+** command line options listed below and/or the 'mv-rm-files' setting.
806
+**
807
+** The 'rename' command never renames or moves files on disk, even when the
808
+** command line options and/or the 'mv-rm-files' setting would otherwise
809
+** require it to do so.
810
+**
811
+** WARNING: If the "--hard" option is specified -OR- the "mv-rm-files"
812
+** setting is non-zero, files WILL BE renamed or moved on disk
813
+** as well. This does NOT apply to the 'rename' command.
631814
**
632815
** Options:
816
+** --soft Skip moving files within the checkout.
817
+** This supersedes the --hard option.
818
+** --hard Move files within the checkout.
633819
** --case-sensitive <BOOL> Override the case-sensitive setting.
820
+** -n|--dry-run If given, display instead of run actions.
634821
**
635822
** See also: changes, status
636823
*/
637824
void mv_cmd(void){
638825
int i;
639826
int vid;
827
+ int moveFiles;
828
+ int dryRunFlag;
829
+ int softFlag;
830
+ int hardFlag;
640831
char *zDest;
641832
Blob dest;
642833
Stmt q;
643834
644835
db_must_be_within_tree();
836
+ dryRunFlag = find_option("dry-run","n",0)!=0;
837
+ softFlag = find_option("soft",0,0)!=0;
838
+ hardFlag = find_option("hard",0,0)!=0;
645839
646840
/* We should be done with options.. */
647841
verify_all_options();
648842
649843
vid = db_lget_int("checkout", 0);
@@ -653,10 +847,23 @@
653847
if( g.argc<4 ){
654848
usage("OLDNAME NEWNAME");
655849
}
656850
zDest = g.argv[g.argc-1];
657851
db_begin_transaction();
852
+ if( g.argv[1][0]=='r' ){ /* i.e. "rename" */
853
+ moveFiles = 0;
854
+ }else if( softFlag ){
855
+ moveFiles = 0;
856
+ }else if( hardFlag ){
857
+ moveFiles = 1;
858
+ }else{
859
+#if FOSSIL_ENABLE_LEGACY_MV_RM
860
+ moveFiles = db_get_boolean("mv-rm-files",0);
861
+#else
862
+ moveFiles = FOSSIL_MV_RM_FILE;
863
+#endif
864
+ }
658865
file_tree_name(zDest, &dest, 1);
659866
db_multi_exec(
660867
"UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
661868
);
662869
db_multi_exec(
@@ -711,18 +918,20 @@
711918
}
712919
db_prepare(&q, "SELECT f, t FROM mv ORDER BY f");
713920
while( db_step(&q)==SQLITE_ROW ){
714921
const char *zFrom = db_column_text(&q, 0);
715922
const char *zTo = db_column_text(&q, 1);
716
- mv_one_file(vid, zFrom, zTo);
923
+ mv_one_file(vid, zFrom, zTo, dryRunFlag);
924
+ if( moveFiles ) add_file_to_move(zFrom, zTo);
717925
}
718926
db_finalize(&q);
719927
db_end_transaction(0);
928
+ if( moveFiles ) process_files_to_move(dryRunFlag);
720929
}
721930
722931
/*
723932
** Function for stash_apply to be able to restore a file and indicate
724933
** newly ADDED state.
725934
*/
726935
int stash_add_files_in_sfile(int vid){
727936
return add_files_in_sfile(vid);
728937
}
729938
--- src/add.c
+++ src/add.c
@@ -22,10 +22,28 @@
22 #include "add.h"
23 #include <assert.h>
24 #include <dirent.h>
25 #include "cygsup.h"
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27 /*
28 ** This routine returns the names of files in a working checkout that
29 ** are created by Fossil itself, and hence should not be added, deleted,
30 ** or merge, and should be omitted from "clean" and "extras" lists.
31 **
@@ -299,12 +317,10 @@
299 isDir = file_wd_isdir(zName);
300 if( isDir==1 ){
301 vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
302 }else if( isDir==0 ){
303 fossil_warning("not found: %s", zName);
304 }else if( file_access(zName, R_OK) ){
305 fossil_fatal("cannot open %s", zName);
306 }else{
307 char *zTreeName = &zName[nRoot];
308 if( !forceFlag && glob_match(pIgnore, zTreeName) ){
309 Blob ans;
310 char cReply;
@@ -331,10 +347,58 @@
331 glob_free(pClean);
332
333 add_files_in_sfile(vid);
334 db_end_transaction(0);
335 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
337 /*
338 ** COMMAND: rm
339 ** COMMAND: delete
340 ** COMMAND: forget*
@@ -341,28 +405,63 @@
341 **
342 ** Usage: %fossil rm|delete|forget FILE1 ?FILE2 ...?
343 **
344 ** Remove one or more files or directories from the repository.
345 **
346 ** This command does NOT remove the files from disk. It just marks the
347 ** files as no longer being part of the project. In other words, future
348 ** changes to the named files will not be versioned.
 
 
 
 
 
 
 
 
 
 
349 **
350 ** Options:
 
 
 
351 ** --case-sensitive <BOOL> Override the case-sensitive setting.
 
352 **
353 ** See also: addremove, add
354 */
355 void delete_cmd(void){
356 int i;
 
 
 
 
357 Stmt loop;
 
 
 
 
358
359 /* We should be done with options.. */
360 verify_all_options();
361
362 db_must_be_within_tree();
363 db_begin_transaction();
 
 
 
 
 
 
 
 
 
 
 
 
 
364 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
365 filename_collation());
366 for(i=2; i<g.argc; i++){
367 Blob treeName;
368 char *zTreeName;
@@ -382,17 +481,21 @@
382 }
383
384 db_prepare(&loop, "SELECT x FROM sfile");
385 while( db_step(&loop)==SQLITE_ROW ){
386 fossil_print("DELETED %s\n", db_column_text(&loop, 0));
 
387 }
388 db_finalize(&loop);
389 db_multi_exec(
390 "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
391 "DELETE FROM vfile WHERE rid=0 AND deleted;"
392 );
 
 
393 db_end_transaction(0);
 
394 }
395
396 /*
397 ** Capture the command-line --case-sensitive option.
398 */
@@ -527,10 +630,18 @@
527 }
528
529 /* We should be done with options.. */
530 verify_all_options();
531
 
 
 
 
 
 
 
 
532 db_must_be_within_tree();
533 if( zCleanFlag==0 ){
534 zCleanFlag = db_get("clean-glob", 0);
535 }
536 if( zIgnoreFlag==0 ){
@@ -593,11 +704,12 @@
593 ** The original name of the file is zOrig. The new filename is zNew.
594 */
595 static void mv_one_file(
596 int vid,
597 const char *zOrig,
598 const char *zNew
 
599 ){
600 int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
601 zNew, filename_collation());
602 if( x>=0 ){
603 if( x==0 ){
@@ -607,14 +719,75 @@
607 fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has "
608 "not yet been committed", zOrig, zNew, zNew);
609 }
610 }
611 fossil_print("RENAME %s %s\n", zOrig, zNew);
612 db_multi_exec(
613 "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
614 zNew, zOrig, filename_collation(), vid
615 );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
616 }
617
618 /*
619 ** COMMAND: mv
620 ** COMMAND: rename*
@@ -623,27 +796,48 @@
623 ** or: %fossil mv|rename OLDNAME... DIR
624 **
625 ** Move or rename one or more files or directories within the repository tree.
626 ** You can either rename a file or directory or move it to another subdirectory.
627 **
628 ** This command does NOT rename or move the files on disk. This command merely
629 ** records the fact that filenames have changed so that appropriate notations
630 ** can be made at the next commit/check-in.
 
 
 
 
 
 
 
 
 
 
631 **
632 ** Options:
 
 
 
633 ** --case-sensitive <BOOL> Override the case-sensitive setting.
 
634 **
635 ** See also: changes, status
636 */
637 void mv_cmd(void){
638 int i;
639 int vid;
 
 
 
 
640 char *zDest;
641 Blob dest;
642 Stmt q;
643
644 db_must_be_within_tree();
 
 
 
645
646 /* We should be done with options.. */
647 verify_all_options();
648
649 vid = db_lget_int("checkout", 0);
@@ -653,10 +847,23 @@
653 if( g.argc<4 ){
654 usage("OLDNAME NEWNAME");
655 }
656 zDest = g.argv[g.argc-1];
657 db_begin_transaction();
 
 
 
 
 
 
 
 
 
 
 
 
 
658 file_tree_name(zDest, &dest, 1);
659 db_multi_exec(
660 "UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
661 );
662 db_multi_exec(
@@ -711,18 +918,20 @@
711 }
712 db_prepare(&q, "SELECT f, t FROM mv ORDER BY f");
713 while( db_step(&q)==SQLITE_ROW ){
714 const char *zFrom = db_column_text(&q, 0);
715 const char *zTo = db_column_text(&q, 1);
716 mv_one_file(vid, zFrom, zTo);
 
717 }
718 db_finalize(&q);
719 db_end_transaction(0);
 
720 }
721
722 /*
723 ** Function for stash_apply to be able to restore a file and indicate
724 ** newly ADDED state.
725 */
726 int stash_add_files_in_sfile(int vid){
727 return add_files_in_sfile(vid);
728 }
729
--- src/add.c
+++ src/add.c
@@ -22,10 +22,28 @@
22 #include "add.h"
23 #include <assert.h>
24 #include <dirent.h>
25 #include "cygsup.h"
26
27 /*
28 ** WARNING: For Fossil version 1.x this value was always zero. For Fossil
29 ** 2.x, it will probably always be one. When this value is zero,
30 ** files in the checkout will not be moved by the "mv" command and
31 ** files in the checkout will not be removed by the "rm" command.
32 **
33 ** If the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option is used,
34 ** the "mv-rm-files" setting will be consulted instead of using
35 ** this value.
36 **
37 ** To retain the Fossil version 1.x behavior when using Fossil 2.x,
38 ** the FOSSIL_ENABLE_LEGACY_MV_RM compile-time option must be used
39 ** -AND- the "mv-rm-files" setting must be set to zero.
40 */
41 #ifndef FOSSIL_MV_RM_FILE
42 #define FOSSIL_MV_RM_FILE (0)
43 #endif
44
45 /*
46 ** This routine returns the names of files in a working checkout that
47 ** are created by Fossil itself, and hence should not be added, deleted,
48 ** or merge, and should be omitted from "clean" and "extras" lists.
49 **
@@ -299,12 +317,10 @@
317 isDir = file_wd_isdir(zName);
318 if( isDir==1 ){
319 vfile_scan(&fullName, nRoot-1, scanFlags, pClean, pIgnore);
320 }else if( isDir==0 ){
321 fossil_warning("not found: %s", zName);
 
 
322 }else{
323 char *zTreeName = &zName[nRoot];
324 if( !forceFlag && glob_match(pIgnore, zTreeName) ){
325 Blob ans;
326 char cReply;
@@ -331,10 +347,58 @@
347 glob_free(pClean);
348
349 add_files_in_sfile(vid);
350 db_end_transaction(0);
351 }
352
353 /*
354 ** This function adds a file to list of files to delete from disk after
355 ** the other actions required for the parent operation have completed
356 ** successfully. The first time it is called for the current process,
357 ** it creates a temporary table named "fremove", to keep track of these
358 ** files.
359 */
360 static void add_file_to_remove(
361 const char *zOldName /* The old name of the file on disk. */
362 ){
363 static int tableCreated = 0;
364 Blob fullOldName;
365 if( !tableCreated ){
366 db_multi_exec("CREATE TEMP TABLE fremove(x TEXT PRIMARY KEY %s)",
367 filename_collation());
368 tableCreated = 1;
369 }
370 file_canonical_name(zOldName, &fullOldName, 0);
371 db_multi_exec("INSERT INTO fremove VALUES('%q');", blob_str(&fullOldName));
372 blob_reset(&fullOldName);
373 }
374
375 /*
376 ** This function deletes files from the checkout, using the file names
377 ** contained in the temporary table "fremove". The temporary table is
378 ** created on demand by the add_file_to_remove() function.
379 **
380 ** If dryRunFlag is non-zero, no files will be removed; however, their
381 ** names will still be output.
382 **
383 ** The temporary table "fremove" is dropped after being processed.
384 */
385 static void process_files_to_remove(
386 int dryRunFlag /* Zero to actually operate on the file-system. */
387 ){
388 Stmt remove;
389 db_prepare(&remove, "SELECT x FROM fremove ORDER BY x;");
390 while( db_step(&remove)==SQLITE_ROW ){
391 const char *zOldName = db_column_text(&remove, 0);
392 if( !dryRunFlag ){
393 file_delete(zOldName);
394 }
395 fossil_print("DELETED_FILE %s\n", zOldName);
396 }
397 db_finalize(&remove);
398 db_multi_exec("DROP TABLE fremove;");
399 }
400
401 /*
402 ** COMMAND: rm
403 ** COMMAND: delete
404 ** COMMAND: forget*
@@ -341,28 +405,63 @@
405 **
406 ** Usage: %fossil rm|delete|forget FILE1 ?FILE2 ...?
407 **
408 ** Remove one or more files or directories from the repository.
409 **
410 ** The 'rm' and 'delete' commands do NOT normally remove the files from
411 ** disk. They just mark the files as no longer being part of the project.
412 ** In other words, future changes to the named files will not be versioned.
413 ** However, the default behavior of this command may be overridden via the
414 ** command line options listed below and/or the 'mv-rm-files' setting.
415 **
416 ** The 'forget' command never removes files from disk, even when the command
417 ** line options and/or the 'mv-rm-files' setting would otherwise require it
418 ** to do so.
419 **
420 ** WARNING: If the "--hard" option is specified -OR- the "mv-rm-files"
421 ** setting is non-zero, files WILL BE removed from disk as well.
422 ** This does NOT apply to the 'forget' command.
423 **
424 ** Options:
425 ** --soft Skip removing files from the checkout.
426 ** This supersedes the --hard option.
427 ** --hard Remove files from the checkout.
428 ** --case-sensitive <BOOL> Override the case-sensitive setting.
429 ** -n|--dry-run If given, display instead of run actions.
430 **
431 ** See also: addremove, add
432 */
433 void delete_cmd(void){
434 int i;
435 int removeFiles;
436 int dryRunFlag;
437 int softFlag;
438 int hardFlag;
439 Stmt loop;
440
441 dryRunFlag = find_option("dry-run","n",0)!=0;
442 softFlag = find_option("soft",0,0)!=0;
443 hardFlag = find_option("hard",0,0)!=0;
444
445 /* We should be done with options.. */
446 verify_all_options();
447
448 db_must_be_within_tree();
449 db_begin_transaction();
450 if( g.argv[1][0]=='f' ){ /* i.e. "forget" */
451 removeFiles = 0;
452 }else if( softFlag ){
453 removeFiles = 0;
454 }else if( hardFlag ){
455 removeFiles = 1;
456 }else{
457 #if FOSSIL_ENABLE_LEGACY_MV_RM
458 removeFiles = db_get_boolean("mv-rm-files",0);
459 #else
460 removeFiles = FOSSIL_MV_RM_FILE;
461 #endif
462 }
463 db_multi_exec("CREATE TEMP TABLE sfile(x TEXT PRIMARY KEY %s)",
464 filename_collation());
465 for(i=2; i<g.argc; i++){
466 Blob treeName;
467 char *zTreeName;
@@ -382,17 +481,21 @@
481 }
482
483 db_prepare(&loop, "SELECT x FROM sfile");
484 while( db_step(&loop)==SQLITE_ROW ){
485 fossil_print("DELETED %s\n", db_column_text(&loop, 0));
486 if( removeFiles ) add_file_to_remove(db_column_text(&loop, 0));
487 }
488 db_finalize(&loop);
489 if( !dryRunFlag ){
490 db_multi_exec(
491 "UPDATE vfile SET deleted=1 WHERE pathname IN sfile;"
492 "DELETE FROM vfile WHERE rid=0 AND deleted;"
493 );
494 }
495 db_end_transaction(0);
496 if( removeFiles ) process_files_to_remove(dryRunFlag);
497 }
498
499 /*
500 ** Capture the command-line --case-sensitive option.
501 */
@@ -527,10 +630,18 @@
630 }
631
632 /* We should be done with options.. */
633 verify_all_options();
634
635 /* Fail if unprocessed arguments are present, in case user expect the
636 ** addremove command to accept a list of file or directory.
637 */
638 if( g.argc>2 ){
639 fossil_fatal(
640 "%s: Can only work on the entire checkout, no arguments supported.",
641 g.argv[1]);
642 }
643 db_must_be_within_tree();
644 if( zCleanFlag==0 ){
645 zCleanFlag = db_get("clean-glob", 0);
646 }
647 if( zIgnoreFlag==0 ){
@@ -593,11 +704,12 @@
704 ** The original name of the file is zOrig. The new filename is zNew.
705 */
706 static void mv_one_file(
707 int vid,
708 const char *zOrig,
709 const char *zNew,
710 int dryRunFlag
711 ){
712 int x = db_int(-1, "SELECT deleted FROM vfile WHERE pathname=%Q %s",
713 zNew, filename_collation());
714 if( x>=0 ){
715 if( x==0 ){
@@ -607,14 +719,75 @@
719 fossil_fatal("cannot rename '%s' to '%s' since the delete of '%s' has "
720 "not yet been committed", zOrig, zNew, zNew);
721 }
722 }
723 fossil_print("RENAME %s %s\n", zOrig, zNew);
724 if( !dryRunFlag ){
725 db_multi_exec(
726 "UPDATE vfile SET pathname='%q' WHERE pathname='%q' %s AND vid=%d",
727 zNew, zOrig, filename_collation(), vid
728 );
729 }
730 }
731
732 /*
733 ** This function adds a file to list of files to move on disk after the
734 ** other actions required for the parent operation have completed
735 ** successfully. The first time it is called for the current process,
736 ** it creates a temporary table named "fmove", to keep track of these
737 ** files.
738 */
739 static void add_file_to_move(
740 const char *zOldName, /* The old name of the file on disk. */
741 const char *zNewName /* The new name of the file on disk. */
742 ){
743 static int tableCreated = 0;
744 Blob fullOldName;
745 Blob fullNewName;
746 if( !tableCreated ){
747 db_multi_exec("CREATE TEMP TABLE fmove(x TEXT PRIMARY KEY %s, y TEXT %s)",
748 filename_collation(), filename_collation());
749 tableCreated = 1;
750 }
751 file_canonical_name(zOldName, &fullOldName, 0);
752 file_canonical_name(zNewName, &fullNewName, 0);
753 db_multi_exec("INSERT INTO fmove VALUES('%q','%q');",
754 blob_str(&fullOldName), blob_str(&fullNewName));
755 blob_reset(&fullNewName);
756 blob_reset(&fullOldName);
757 }
758
759 /*
760 ** This function moves files within the checkout, using the file names
761 ** contained in the temporary table "fmove". The temporary table is
762 ** created on demand by the add_file_to_move() function.
763 **
764 ** If dryRunFlag is non-zero, no files will be moved; however, their
765 ** names will still be output.
766 **
767 ** The temporary table "fmove" is dropped after being processed.
768 */
769 static void process_files_to_move(
770 int dryRunFlag /* Zero to actually operate on the file-system. */
771 ){
772 Stmt move;
773 db_prepare(&move, "SELECT x, y FROM fmove ORDER BY x;");
774 while( db_step(&move)==SQLITE_ROW ){
775 const char *zOldName = db_column_text(&move, 0);
776 const char *zNewName = db_column_text(&move, 1);
777 if( !dryRunFlag ){
778 if( file_wd_islink(zOldName) ){
779 symlink_copy(zOldName, zNewName);
780 }else{
781 file_copy(zOldName, zNewName);
782 }
783 file_delete(zOldName);
784 }
785 fossil_print("MOVED_FILE %s\n", zOldName);
786 }
787 db_finalize(&move);
788 db_multi_exec("DROP TABLE fmove;");
789 }
790
791 /*
792 ** COMMAND: mv
793 ** COMMAND: rename*
@@ -623,27 +796,48 @@
796 ** or: %fossil mv|rename OLDNAME... DIR
797 **
798 ** Move or rename one or more files or directories within the repository tree.
799 ** You can either rename a file or directory or move it to another subdirectory.
800 **
801 ** The 'mv' command does NOT normally rename or move the files on disk.
802 ** This command merely records the fact that file names have changed so
803 ** that appropriate notations can be made at the next commit/check-in.
804 ** However, the default behavior of this command may be overridden via
805 ** command line options listed below and/or the 'mv-rm-files' setting.
806 **
807 ** The 'rename' command never renames or moves files on disk, even when the
808 ** command line options and/or the 'mv-rm-files' setting would otherwise
809 ** require it to do so.
810 **
811 ** WARNING: If the "--hard" option is specified -OR- the "mv-rm-files"
812 ** setting is non-zero, files WILL BE renamed or moved on disk
813 ** as well. This does NOT apply to the 'rename' command.
814 **
815 ** Options:
816 ** --soft Skip moving files within the checkout.
817 ** This supersedes the --hard option.
818 ** --hard Move files within the checkout.
819 ** --case-sensitive <BOOL> Override the case-sensitive setting.
820 ** -n|--dry-run If given, display instead of run actions.
821 **
822 ** See also: changes, status
823 */
824 void mv_cmd(void){
825 int i;
826 int vid;
827 int moveFiles;
828 int dryRunFlag;
829 int softFlag;
830 int hardFlag;
831 char *zDest;
832 Blob dest;
833 Stmt q;
834
835 db_must_be_within_tree();
836 dryRunFlag = find_option("dry-run","n",0)!=0;
837 softFlag = find_option("soft",0,0)!=0;
838 hardFlag = find_option("hard",0,0)!=0;
839
840 /* We should be done with options.. */
841 verify_all_options();
842
843 vid = db_lget_int("checkout", 0);
@@ -653,10 +847,23 @@
847 if( g.argc<4 ){
848 usage("OLDNAME NEWNAME");
849 }
850 zDest = g.argv[g.argc-1];
851 db_begin_transaction();
852 if( g.argv[1][0]=='r' ){ /* i.e. "rename" */
853 moveFiles = 0;
854 }else if( softFlag ){
855 moveFiles = 0;
856 }else if( hardFlag ){
857 moveFiles = 1;
858 }else{
859 #if FOSSIL_ENABLE_LEGACY_MV_RM
860 moveFiles = db_get_boolean("mv-rm-files",0);
861 #else
862 moveFiles = FOSSIL_MV_RM_FILE;
863 #endif
864 }
865 file_tree_name(zDest, &dest, 1);
866 db_multi_exec(
867 "UPDATE vfile SET origname=pathname WHERE origname IS NULL;"
868 );
869 db_multi_exec(
@@ -711,18 +918,20 @@
918 }
919 db_prepare(&q, "SELECT f, t FROM mv ORDER BY f");
920 while( db_step(&q)==SQLITE_ROW ){
921 const char *zFrom = db_column_text(&q, 0);
922 const char *zTo = db_column_text(&q, 1);
923 mv_one_file(vid, zFrom, zTo, dryRunFlag);
924 if( moveFiles ) add_file_to_move(zFrom, zTo);
925 }
926 db_finalize(&q);
927 db_end_transaction(0);
928 if( moveFiles ) process_files_to_move(dryRunFlag);
929 }
930
931 /*
932 ** Function for stash_apply to be able to restore a file and indicate
933 ** newly ADDED state.
934 */
935 int stash_add_files_in_sfile(int vid){
936 return add_files_in_sfile(vid);
937 }
938
+65 -53
--- src/allrepo.c
+++ src/allrepo.c
@@ -87,63 +87,65 @@
8787
** On Win32 systems, the file is named "_fossil" and is located in
8888
** %LOCALAPPDATA%, %APPDATA% or %HOMEPATH%.
8989
**
9090
** Available operations are:
9191
**
92
-** changes Shows all local checkouts that have uncommitted changes.
93
-** This operation has no additional options.
94
-**
95
-** clean Delete all "extra" files in all local checkouts. Extreme
96
-** caution should be exercised with this command because its
97
-** effects cannot be undone. Use of the --dry-run option to
98
-** carefully review the local checkouts to be operated upon
99
-** and the --whatif option to carefully review the files to
100
-** be deleted beforehand is highly recommended. The command
101
-** line options supported by the clean command itself, if any
102
-** are present, are passed along verbatim.
103
-**
104
-** dbstat Run the "dbstat" command on all repositories.
105
-**
106
-** extras Shows "extra" files from all local checkouts. The command
107
-** line options supported by the extra command itself, if any
108
-** are present, are passed along verbatim.
109
-**
110
-** info Run the "info" command on all repositories.
111
-**
112
-** pull Run a "pull" operation on all repositories. Only the
113
-** --verbose option is supported.
114
-**
115
-** push Run a "push" on all repositories. Only the --verbose
116
-** option is supported.
117
-**
118
-** rebuild Rebuild on all repositories. The command line options
119
-** supported by the rebuild command itself, if any are
120
-** present, are passed along verbatim. The --force and
121
-** --randomize options are not supported.
122
-**
123
-** sync Run a "sync" on all repositories. Only the --verbose
124
-** option is supported.
125
-**
126
-** setting Run the "setting", "set", or "unset" commands on all
127
-** set repositories. These command are particularly useful in
128
-** unset conjunction with the "max-loadavg" setting which cannot
129
-** otherwise be set globally.
92
+** changes Shows all local checkouts that have uncommitted changes.
93
+** This operation has no additional options.
94
+**
95
+** clean Delete all "extra" files in all local checkouts. Extreme
96
+** caution should be exercised with this command because its
97
+** effects cannot be undone. Use of the --dry-run option to
98
+** carefully review the local checkouts to be operated upon
99
+** and the --whatif option to carefully review the files to
100
+** be deleted beforehand is highly recommended. The command
101
+** line options supported by the clean command itself, if any
102
+** are present, are passed along verbatim.
103
+**
104
+** dbstat Run the "dbstat" command on all repositories.
105
+**
106
+** extras Shows "extra" files from all local checkouts. The command
107
+** line options supported by the extra command itself, if any
108
+** are present, are passed along verbatim.
109
+**
110
+** fts-config Run the "fts-config" command on all repositories.
111
+**
112
+** info Run the "info" command on all repositories.
113
+**
114
+** pull Run a "pull" operation on all repositories. Only the
115
+** --verbose option is supported.
116
+**
117
+** push Run a "push" on all repositories. Only the --verbose
118
+** option is supported.
119
+**
120
+** rebuild Rebuild on all repositories. The command line options
121
+** supported by the rebuild command itself, if any are
122
+** present, are passed along verbatim. The --force and
123
+** --randomize options are not supported.
124
+**
125
+** sync Run a "sync" on all repositories. Only the --verbose
126
+** option is supported.
127
+**
128
+** setting Run the "setting", "set", or "unset" commands on all
129
+** set repositories. These command are particularly useful in
130
+** unset conjunction with the "max-loadavg" setting which cannot
131
+** otherwise be set globally.
130132
**
131133
** In addition, the following maintenance operations are supported:
132134
**
133
-** add Add all the repositories named to the set of repositories
134
-** tracked by Fossil. Normally Fossil is able to keep up with
135
-** this list by itself, but sometime it can benefit from this
136
-** hint if you rename repositories.
137
-**
138
-** ignore Arguments are repositories that should be ignored by
139
-** subsequent clean, extras, list, pull, push, rebuild, and
140
-** sync operations. The -c|--ckout option causes the listed
141
-** local checkouts to be ignored instead.
142
-**
143
-** list | ls Display the location of all repositories. The -c|--ckout
144
-** option causes all local checkouts to be listed instead.
135
+** add Add all the repositories named to the set of repositories
136
+** tracked by Fossil. Normally Fossil is able to keep up with
137
+** this list by itself, but sometime it can benefit from this
138
+** hint if you rename repositories.
139
+**
140
+** ignore Arguments are repositories that should be ignored by
141
+** subsequent clean, extras, list, pull, push, rebuild, and
142
+** sync operations. The -c|--ckout option causes the listed
143
+** local checkouts to be ignored instead.
144
+**
145
+** list | ls Display the location of all repositories. The -c|--ckout
146
+** option causes all local checkouts to be listed instead.
145147
**
146148
** Repositories are automatically added to the set of known repositories
147149
** when one of the following commands are run against the repository:
148150
** clone, info, pull, push, or sync. Even previously ignored repositories
149151
** are added back to the list of repositories by these commands.
@@ -174,11 +176,11 @@
174176
if( !dryRunFlag ){
175177
dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
176178
}
177179
178180
if( g.argc<3 ){
179
- usage("changes|clean|extras|ignore|list|ls|pull|push|rebuild|sync");
181
+ usage("SUBCOMMAND ...");
180182
}
181183
n = strlen(g.argv[2]);
182184
db_open_config(1);
183185
blob_zero(&extra);
184186
zCmd = g.argv[2];
@@ -229,10 +231,11 @@
229231
collect_argument(&extra, "verbose","v");
230232
}else if( strncmp(zCmd, "rebuild", n)==0 ){
231233
zCmd = "rebuild";
232234
collect_argument(&extra, "cluster",0);
233235
collect_argument(&extra, "compress",0);
236
+ collect_argument(&extra, "compress-only",0);
234237
collect_argument(&extra, "noverify",0);
235238
collect_argument_value(&extra, "pagesize");
236239
collect_argument(&extra, "vacuum",0);
237240
collect_argument(&extra, "deanalyze",0);
238241
collect_argument(&extra, "analyze",0);
@@ -273,11 +276,11 @@
273276
useCheckouts = find_option("ckout","c",0)!=0;
274277
verify_all_options();
275278
db_begin_transaction();
276279
for(j=3; j<g.argc; j++, blob_reset(&sql), blob_reset(&fn)){
277280
file_canonical_name(g.argv[j], &fn, 0);
278
- blob_append_sql(&sql,
281
+ blob_append_sql(&sql,
279282
"DELETE FROM global_config WHERE name GLOB '%s:%q'",
280283
useCheckouts?"ckout":"repo", blob_str(&fn)
281284
);
282285
if( dryRunFlag ){
283286
fossil_print("%s\n", blob_sql_text(&sql));
@@ -284,10 +287,13 @@
284287
}else{
285288
db_multi_exec("%s", blob_sql_text(&sql));
286289
}
287290
}
288291
db_end_transaction(0);
292
+ blob_reset(&sql);
293
+ blob_reset(&fn);
294
+ blob_reset(&extra);
289295
return;
290296
}else if( strncmp(zCmd, "add", n)==0 ){
291297
int j;
292298
Blob fn = BLOB_INITIALIZER;
293299
Blob sql = BLOB_INITIALIZER;
@@ -313,18 +319,22 @@
313319
}else{
314320
db_multi_exec("%s", blob_sql_text(&sql));
315321
}
316322
}
317323
db_end_transaction(0);
324
+ blob_reset(&sql);
325
+ blob_reset(&fn);
326
+ blob_reset(&extra);
318327
return;
319328
}else if( strncmp(zCmd, "info", n)==0 ){
320329
zCmd = "info";
321330
showLabel = 1;
322331
quiet = 1;
323332
}else{
324333
fossil_fatal("\"all\" subcommand should be one of: "
325
- "changes clean extras ignore list ls push pull rebuild sync");
334
+ "add changes clean dbstat extras fts-config ignore "
335
+ "info list ls pull push rebuild setting sync unset");
326336
}
327337
verify_all_options();
328338
zFossil = quoteFilename(g.nameOfExe);
329339
db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
330340
if( useCheckouts ){
@@ -382,10 +392,12 @@
382392
if( stopOnError && rc ){
383393
break;
384394
}
385395
}
386396
db_finalize(&q);
397
+
398
+ blob_reset(&extra);
387399
388400
/* If any repositories whose names appear in the ~/.fossil file could not
389401
** be found, remove those names from the ~/.fossil file.
390402
*/
391403
if( nToDel>0 ){
392404
--- src/allrepo.c
+++ src/allrepo.c
@@ -87,63 +87,65 @@
87 ** On Win32 systems, the file is named "_fossil" and is located in
88 ** %LOCALAPPDATA%, %APPDATA% or %HOMEPATH%.
89 **
90 ** Available operations are:
91 **
92 ** changes Shows all local checkouts that have uncommitted changes.
93 ** This operation has no additional options.
94 **
95 ** clean Delete all "extra" files in all local checkouts. Extreme
96 ** caution should be exercised with this command because its
97 ** effects cannot be undone. Use of the --dry-run option to
98 ** carefully review the local checkouts to be operated upon
99 ** and the --whatif option to carefully review the files to
100 ** be deleted beforehand is highly recommended. The command
101 ** line options supported by the clean command itself, if any
102 ** are present, are passed along verbatim.
103 **
104 ** dbstat Run the "dbstat" command on all repositories.
105 **
106 ** extras Shows "extra" files from all local checkouts. The command
107 ** line options supported by the extra command itself, if any
108 ** are present, are passed along verbatim.
109 **
110 ** info Run the "info" command on all repositories.
111 **
112 ** pull Run a "pull" operation on all repositories. Only the
113 ** --verbose option is supported.
114 **
115 ** push Run a "push" on all repositories. Only the --verbose
116 ** option is supported.
117 **
118 ** rebuild Rebuild on all repositories. The command line options
119 ** supported by the rebuild command itself, if any are
120 ** present, are passed along verbatim. The --force and
121 ** --randomize options are not supported.
122 **
123 ** sync Run a "sync" on all repositories. Only the --verbose
124 ** option is supported.
125 **
126 ** setting Run the "setting", "set", or "unset" commands on all
127 ** set repositories. These command are particularly useful in
128 ** unset conjunction with the "max-loadavg" setting which cannot
129 ** otherwise be set globally.
 
 
130 **
131 ** In addition, the following maintenance operations are supported:
132 **
133 ** add Add all the repositories named to the set of repositories
134 ** tracked by Fossil. Normally Fossil is able to keep up with
135 ** this list by itself, but sometime it can benefit from this
136 ** hint if you rename repositories.
137 **
138 ** ignore Arguments are repositories that should be ignored by
139 ** subsequent clean, extras, list, pull, push, rebuild, and
140 ** sync operations. The -c|--ckout option causes the listed
141 ** local checkouts to be ignored instead.
142 **
143 ** list | ls Display the location of all repositories. The -c|--ckout
144 ** option causes all local checkouts to be listed instead.
145 **
146 ** Repositories are automatically added to the set of known repositories
147 ** when one of the following commands are run against the repository:
148 ** clone, info, pull, push, or sync. Even previously ignored repositories
149 ** are added back to the list of repositories by these commands.
@@ -174,11 +176,11 @@
174 if( !dryRunFlag ){
175 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
176 }
177
178 if( g.argc<3 ){
179 usage("changes|clean|extras|ignore|list|ls|pull|push|rebuild|sync");
180 }
181 n = strlen(g.argv[2]);
182 db_open_config(1);
183 blob_zero(&extra);
184 zCmd = g.argv[2];
@@ -229,10 +231,11 @@
229 collect_argument(&extra, "verbose","v");
230 }else if( strncmp(zCmd, "rebuild", n)==0 ){
231 zCmd = "rebuild";
232 collect_argument(&extra, "cluster",0);
233 collect_argument(&extra, "compress",0);
 
234 collect_argument(&extra, "noverify",0);
235 collect_argument_value(&extra, "pagesize");
236 collect_argument(&extra, "vacuum",0);
237 collect_argument(&extra, "deanalyze",0);
238 collect_argument(&extra, "analyze",0);
@@ -273,11 +276,11 @@
273 useCheckouts = find_option("ckout","c",0)!=0;
274 verify_all_options();
275 db_begin_transaction();
276 for(j=3; j<g.argc; j++, blob_reset(&sql), blob_reset(&fn)){
277 file_canonical_name(g.argv[j], &fn, 0);
278 blob_append_sql(&sql,
279 "DELETE FROM global_config WHERE name GLOB '%s:%q'",
280 useCheckouts?"ckout":"repo", blob_str(&fn)
281 );
282 if( dryRunFlag ){
283 fossil_print("%s\n", blob_sql_text(&sql));
@@ -284,10 +287,13 @@
284 }else{
285 db_multi_exec("%s", blob_sql_text(&sql));
286 }
287 }
288 db_end_transaction(0);
 
 
 
289 return;
290 }else if( strncmp(zCmd, "add", n)==0 ){
291 int j;
292 Blob fn = BLOB_INITIALIZER;
293 Blob sql = BLOB_INITIALIZER;
@@ -313,18 +319,22 @@
313 }else{
314 db_multi_exec("%s", blob_sql_text(&sql));
315 }
316 }
317 db_end_transaction(0);
 
 
 
318 return;
319 }else if( strncmp(zCmd, "info", n)==0 ){
320 zCmd = "info";
321 showLabel = 1;
322 quiet = 1;
323 }else{
324 fossil_fatal("\"all\" subcommand should be one of: "
325 "changes clean extras ignore list ls push pull rebuild sync");
 
326 }
327 verify_all_options();
328 zFossil = quoteFilename(g.nameOfExe);
329 db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
330 if( useCheckouts ){
@@ -382,10 +392,12 @@
382 if( stopOnError && rc ){
383 break;
384 }
385 }
386 db_finalize(&q);
 
 
387
388 /* If any repositories whose names appear in the ~/.fossil file could not
389 ** be found, remove those names from the ~/.fossil file.
390 */
391 if( nToDel>0 ){
392
--- src/allrepo.c
+++ src/allrepo.c
@@ -87,63 +87,65 @@
87 ** On Win32 systems, the file is named "_fossil" and is located in
88 ** %LOCALAPPDATA%, %APPDATA% or %HOMEPATH%.
89 **
90 ** Available operations are:
91 **
92 ** changes Shows all local checkouts that have uncommitted changes.
93 ** This operation has no additional options.
94 **
95 ** clean Delete all "extra" files in all local checkouts. Extreme
96 ** caution should be exercised with this command because its
97 ** effects cannot be undone. Use of the --dry-run option to
98 ** carefully review the local checkouts to be operated upon
99 ** and the --whatif option to carefully review the files to
100 ** be deleted beforehand is highly recommended. The command
101 ** line options supported by the clean command itself, if any
102 ** are present, are passed along verbatim.
103 **
104 ** dbstat Run the "dbstat" command on all repositories.
105 **
106 ** extras Shows "extra" files from all local checkouts. The command
107 ** line options supported by the extra command itself, if any
108 ** are present, are passed along verbatim.
109 **
110 ** fts-config Run the "fts-config" command on all repositories.
111 **
112 ** info Run the "info" command on all repositories.
113 **
114 ** pull Run a "pull" operation on all repositories. Only the
115 ** --verbose option is supported.
116 **
117 ** push Run a "push" on all repositories. Only the --verbose
118 ** option is supported.
119 **
120 ** rebuild Rebuild on all repositories. The command line options
121 ** supported by the rebuild command itself, if any are
122 ** present, are passed along verbatim. The --force and
123 ** --randomize options are not supported.
124 **
125 ** sync Run a "sync" on all repositories. Only the --verbose
126 ** option is supported.
127 **
128 ** setting Run the "setting", "set", or "unset" commands on all
129 ** set repositories. These command are particularly useful in
130 ** unset conjunction with the "max-loadavg" setting which cannot
131 ** otherwise be set globally.
132 **
133 ** In addition, the following maintenance operations are supported:
134 **
135 ** add Add all the repositories named to the set of repositories
136 ** tracked by Fossil. Normally Fossil is able to keep up with
137 ** this list by itself, but sometime it can benefit from this
138 ** hint if you rename repositories.
139 **
140 ** ignore Arguments are repositories that should be ignored by
141 ** subsequent clean, extras, list, pull, push, rebuild, and
142 ** sync operations. The -c|--ckout option causes the listed
143 ** local checkouts to be ignored instead.
144 **
145 ** list | ls Display the location of all repositories. The -c|--ckout
146 ** option causes all local checkouts to be listed instead.
147 **
148 ** Repositories are automatically added to the set of known repositories
149 ** when one of the following commands are run against the repository:
150 ** clone, info, pull, push, or sync. Even previously ignored repositories
151 ** are added back to the list of repositories by these commands.
@@ -174,11 +176,11 @@
176 if( !dryRunFlag ){
177 dryRunFlag = find_option("test",0,0)!=0; /* deprecated */
178 }
179
180 if( g.argc<3 ){
181 usage("SUBCOMMAND ...");
182 }
183 n = strlen(g.argv[2]);
184 db_open_config(1);
185 blob_zero(&extra);
186 zCmd = g.argv[2];
@@ -229,10 +231,11 @@
231 collect_argument(&extra, "verbose","v");
232 }else if( strncmp(zCmd, "rebuild", n)==0 ){
233 zCmd = "rebuild";
234 collect_argument(&extra, "cluster",0);
235 collect_argument(&extra, "compress",0);
236 collect_argument(&extra, "compress-only",0);
237 collect_argument(&extra, "noverify",0);
238 collect_argument_value(&extra, "pagesize");
239 collect_argument(&extra, "vacuum",0);
240 collect_argument(&extra, "deanalyze",0);
241 collect_argument(&extra, "analyze",0);
@@ -273,11 +276,11 @@
276 useCheckouts = find_option("ckout","c",0)!=0;
277 verify_all_options();
278 db_begin_transaction();
279 for(j=3; j<g.argc; j++, blob_reset(&sql), blob_reset(&fn)){
280 file_canonical_name(g.argv[j], &fn, 0);
281 blob_append_sql(&sql,
282 "DELETE FROM global_config WHERE name GLOB '%s:%q'",
283 useCheckouts?"ckout":"repo", blob_str(&fn)
284 );
285 if( dryRunFlag ){
286 fossil_print("%s\n", blob_sql_text(&sql));
@@ -284,10 +287,13 @@
287 }else{
288 db_multi_exec("%s", blob_sql_text(&sql));
289 }
290 }
291 db_end_transaction(0);
292 blob_reset(&sql);
293 blob_reset(&fn);
294 blob_reset(&extra);
295 return;
296 }else if( strncmp(zCmd, "add", n)==0 ){
297 int j;
298 Blob fn = BLOB_INITIALIZER;
299 Blob sql = BLOB_INITIALIZER;
@@ -313,18 +319,22 @@
319 }else{
320 db_multi_exec("%s", blob_sql_text(&sql));
321 }
322 }
323 db_end_transaction(0);
324 blob_reset(&sql);
325 blob_reset(&fn);
326 blob_reset(&extra);
327 return;
328 }else if( strncmp(zCmd, "info", n)==0 ){
329 zCmd = "info";
330 showLabel = 1;
331 quiet = 1;
332 }else{
333 fossil_fatal("\"all\" subcommand should be one of: "
334 "add changes clean dbstat extras fts-config ignore "
335 "info list ls pull push rebuild setting sync unset");
336 }
337 verify_all_options();
338 zFossil = quoteFilename(g.nameOfExe);
339 db_multi_exec("CREATE TEMP TABLE repolist(name,tag);");
340 if( useCheckouts ){
@@ -382,10 +392,12 @@
392 if( stopOnError && rc ){
393 break;
394 }
395 }
396 db_finalize(&q);
397
398 blob_reset(&extra);
399
400 /* If any repositories whose names appear in the ~/.fossil file could not
401 ** be found, remove those names from the ~/.fossil file.
402 */
403 if( nToDel>0 ){
404
+8 -6
--- src/attach.c
+++ src/attach.c
@@ -21,18 +21,18 @@
2121
#include "attach.h"
2222
#include <assert.h>
2323
2424
/*
2525
** WEBPAGE: attachlist
26
+** List attachments.
2627
**
2728
** tkt=TICKETUUID
2829
** page=WIKIPAGE
2930
**
30
-** List attachments.
31
-** Either one of tkt= or page= are supplied or neither. If neither
32
-** are given, all attachments are listed. If one is given, only
33
-** attachments for the designated ticket or wiki page are shown.
31
+** Either one of tkt= or page= are supplied or neither but not both.
32
+** If neither are given, all attachments are listed. If one is given,
33
+** only attachments for the designated ticket or wiki page are shown.
3434
** TICKETUUID must be complete
3535
*/
3636
void attachlist_page(void){
3737
const char *zPage = P("page");
3838
const char *zTkt = P("tkt");
@@ -134,16 +134,18 @@
134134
/*
135135
** WEBPAGE: attachdownload
136136
** WEBPAGE: attachimage
137137
** WEBPAGE: attachview
138138
**
139
+** Download or display an attachment.
140
+** Query parameters:
141
+**
139142
** tkt=TICKETUUID
140143
** page=WIKIPAGE
141144
** file=FILENAME
142145
** attachid=ID
143146
**
144
-** List attachments.
145147
*/
146148
void attachview_page(void){
147149
const char *zPage = P("page");
148150
const char *zTkt = P("tkt");
149151
const char *zFile = P("file");
@@ -223,16 +225,16 @@
223225
}
224226
225227
226228
/*
227229
** WEBPAGE: attachadd
230
+** Add a new attachment.
228231
**
229232
** tkt=TICKETUUID
230233
** page=WIKIPAGE
231234
** from=URL
232235
**
233
-** Add a new attachment.
234236
*/
235237
void attachadd_page(void){
236238
const char *zPage = P("page");
237239
const char *zTkt = P("tkt");
238240
const char *zFrom = P("from");
239241
--- src/attach.c
+++ src/attach.c
@@ -21,18 +21,18 @@
21 #include "attach.h"
22 #include <assert.h>
23
24 /*
25 ** WEBPAGE: attachlist
 
26 **
27 ** tkt=TICKETUUID
28 ** page=WIKIPAGE
29 **
30 ** List attachments.
31 ** Either one of tkt= or page= are supplied or neither. If neither
32 ** are given, all attachments are listed. If one is given, only
33 ** attachments for the designated ticket or wiki page are shown.
34 ** TICKETUUID must be complete
35 */
36 void attachlist_page(void){
37 const char *zPage = P("page");
38 const char *zTkt = P("tkt");
@@ -134,16 +134,18 @@
134 /*
135 ** WEBPAGE: attachdownload
136 ** WEBPAGE: attachimage
137 ** WEBPAGE: attachview
138 **
 
 
 
139 ** tkt=TICKETUUID
140 ** page=WIKIPAGE
141 ** file=FILENAME
142 ** attachid=ID
143 **
144 ** List attachments.
145 */
146 void attachview_page(void){
147 const char *zPage = P("page");
148 const char *zTkt = P("tkt");
149 const char *zFile = P("file");
@@ -223,16 +225,16 @@
223 }
224
225
226 /*
227 ** WEBPAGE: attachadd
 
228 **
229 ** tkt=TICKETUUID
230 ** page=WIKIPAGE
231 ** from=URL
232 **
233 ** Add a new attachment.
234 */
235 void attachadd_page(void){
236 const char *zPage = P("page");
237 const char *zTkt = P("tkt");
238 const char *zFrom = P("from");
239
--- src/attach.c
+++ src/attach.c
@@ -21,18 +21,18 @@
21 #include "attach.h"
22 #include <assert.h>
23
24 /*
25 ** WEBPAGE: attachlist
26 ** List attachments.
27 **
28 ** tkt=TICKETUUID
29 ** page=WIKIPAGE
30 **
31 ** Either one of tkt= or page= are supplied or neither but not both.
32 ** If neither are given, all attachments are listed. If one is given,
33 ** only attachments for the designated ticket or wiki page are shown.
 
34 ** TICKETUUID must be complete
35 */
36 void attachlist_page(void){
37 const char *zPage = P("page");
38 const char *zTkt = P("tkt");
@@ -134,16 +134,18 @@
134 /*
135 ** WEBPAGE: attachdownload
136 ** WEBPAGE: attachimage
137 ** WEBPAGE: attachview
138 **
139 ** Download or display an attachment.
140 ** Query parameters:
141 **
142 ** tkt=TICKETUUID
143 ** page=WIKIPAGE
144 ** file=FILENAME
145 ** attachid=ID
146 **
 
147 */
148 void attachview_page(void){
149 const char *zPage = P("page");
150 const char *zTkt = P("tkt");
151 const char *zFile = P("file");
@@ -223,16 +225,16 @@
225 }
226
227
228 /*
229 ** WEBPAGE: attachadd
230 ** Add a new attachment.
231 **
232 ** tkt=TICKETUUID
233 ** page=WIKIPAGE
234 ** from=URL
235 **
 
236 */
237 void attachadd_page(void){
238 const char *zPage = P("page");
239 const char *zTkt = P("tkt");
240 const char *zFrom = P("from");
241
+22
--- src/blob.c
+++ src/blob.c
@@ -118,10 +118,13 @@
118118
}
119119
120120
121121
/*
122122
** COMMAND: test-isspace
123
+**
124
+** Verify that the fossil_isspace() routine is working correctly but
125
+** testing it on all possible inputs.
123126
*/
124127
void isspace_cmd(void){
125128
int i;
126129
for(i=0; i<=255; i++){
127130
if( i==' ' || i=='\n' || i=='\t' || i=='\v'
@@ -884,10 +887,16 @@
884887
blob_resize(pOut, nOut2+4);
885888
}
886889
887890
/*
888891
** COMMAND: test-compress
892
+**
893
+** Usage: %fossil test-compress INPUTFILE OUTPUTFILE
894
+**
895
+** Run compression on INPUTFILE and write the result into OUTPUTFILE.
896
+**
897
+** This is used to test and debug the blob_compress() routine.
889898
*/
890899
void compress_cmd(void){
891900
Blob f;
892901
if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
893902
blob_read_from_file(&f, g.argv[2]);
@@ -936,10 +945,17 @@
936945
*pOut = temp;
937946
}
938947
939948
/*
940949
** COMMAND: test-compress-2
950
+**
951
+** Usage: %fossil test-compress-2 IN1 IN2 OUT
952
+**
953
+** Read files IN1 and IN2, concatenate the content, compress the
954
+** content, then write results into OUT.
955
+**
956
+** This is used to test and debug the blob_compress2() routine.
941957
*/
942958
void compress2_cmd(void){
943959
Blob f1, f2;
944960
if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE");
945961
blob_read_from_file(&f1, g.argv[2]);
@@ -982,10 +998,16 @@
982998
return 0;
983999
}
9841000
9851001
/*
9861002
** COMMAND: test-uncompress
1003
+**
1004
+** Usage: %fossil test-uncompress IN OUT
1005
+**
1006
+** Read the content of file IN, uncompress that content, and write the
1007
+** result into OUT. This command is intended for testing of the the
1008
+** blob_compress() function.
9871009
*/
9881010
void uncompress_cmd(void){
9891011
Blob f;
9901012
if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
9911013
blob_read_from_file(&f, g.argv[2]);
9921014
--- src/blob.c
+++ src/blob.c
@@ -118,10 +118,13 @@
118 }
119
120
121 /*
122 ** COMMAND: test-isspace
 
 
 
123 */
124 void isspace_cmd(void){
125 int i;
126 for(i=0; i<=255; i++){
127 if( i==' ' || i=='\n' || i=='\t' || i=='\v'
@@ -884,10 +887,16 @@
884 blob_resize(pOut, nOut2+4);
885 }
886
887 /*
888 ** COMMAND: test-compress
 
 
 
 
 
 
889 */
890 void compress_cmd(void){
891 Blob f;
892 if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
893 blob_read_from_file(&f, g.argv[2]);
@@ -936,10 +945,17 @@
936 *pOut = temp;
937 }
938
939 /*
940 ** COMMAND: test-compress-2
 
 
 
 
 
 
 
941 */
942 void compress2_cmd(void){
943 Blob f1, f2;
944 if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE");
945 blob_read_from_file(&f1, g.argv[2]);
@@ -982,10 +998,16 @@
982 return 0;
983 }
984
985 /*
986 ** COMMAND: test-uncompress
 
 
 
 
 
 
987 */
988 void uncompress_cmd(void){
989 Blob f;
990 if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
991 blob_read_from_file(&f, g.argv[2]);
992
--- src/blob.c
+++ src/blob.c
@@ -118,10 +118,13 @@
118 }
119
120
121 /*
122 ** COMMAND: test-isspace
123 **
124 ** Verify that the fossil_isspace() routine is working correctly but
125 ** testing it on all possible inputs.
126 */
127 void isspace_cmd(void){
128 int i;
129 for(i=0; i<=255; i++){
130 if( i==' ' || i=='\n' || i=='\t' || i=='\v'
@@ -884,10 +887,16 @@
887 blob_resize(pOut, nOut2+4);
888 }
889
890 /*
891 ** COMMAND: test-compress
892 **
893 ** Usage: %fossil test-compress INPUTFILE OUTPUTFILE
894 **
895 ** Run compression on INPUTFILE and write the result into OUTPUTFILE.
896 **
897 ** This is used to test and debug the blob_compress() routine.
898 */
899 void compress_cmd(void){
900 Blob f;
901 if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
902 blob_read_from_file(&f, g.argv[2]);
@@ -936,10 +945,17 @@
945 *pOut = temp;
946 }
947
948 /*
949 ** COMMAND: test-compress-2
950 **
951 ** Usage: %fossil test-compress-2 IN1 IN2 OUT
952 **
953 ** Read files IN1 and IN2, concatenate the content, compress the
954 ** content, then write results into OUT.
955 **
956 ** This is used to test and debug the blob_compress2() routine.
957 */
958 void compress2_cmd(void){
959 Blob f1, f2;
960 if( g.argc!=5 ) usage("INPUTFILE1 INPUTFILE2 OUTPUTFILE");
961 blob_read_from_file(&f1, g.argv[2]);
@@ -982,10 +998,16 @@
998 return 0;
999 }
1000
1001 /*
1002 ** COMMAND: test-uncompress
1003 **
1004 ** Usage: %fossil test-uncompress IN OUT
1005 **
1006 ** Read the content of file IN, uncompress that content, and write the
1007 ** result into OUT. This command is intended for testing of the the
1008 ** blob_compress() function.
1009 */
1010 void uncompress_cmd(void){
1011 Blob f;
1012 if( g.argc!=4 ) usage("INPUTFILE OUTPUTFILE");
1013 blob_read_from_file(&f, g.argv[2]);
1014
+4 -1
--- src/branch.c
+++ src/branch.c
@@ -386,11 +386,14 @@
386386
style_footer();
387387
}
388388
389389
/*
390390
** WEBPAGE: brlist
391
-** Show a list of branches
391
+** Show a list of branches. With no query parameters, a sortable table
392
+** is used to show all branches. If query parameters are present a
393
+** fixed bullet list is shown.
394
+**
392395
** Query parameters:
393396
**
394397
** all Show all branches
395398
** closed Show only closed branches
396399
** open Show only open branches (default behavior)
397400
--- src/branch.c
+++ src/branch.c
@@ -386,11 +386,14 @@
386 style_footer();
387 }
388
389 /*
390 ** WEBPAGE: brlist
391 ** Show a list of branches
 
 
 
392 ** Query parameters:
393 **
394 ** all Show all branches
395 ** closed Show only closed branches
396 ** open Show only open branches (default behavior)
397
--- src/branch.c
+++ src/branch.c
@@ -386,11 +386,14 @@
386 style_footer();
387 }
388
389 /*
390 ** WEBPAGE: brlist
391 ** Show a list of branches. With no query parameters, a sortable table
392 ** is used to show all branches. If query parameters are present a
393 ** fixed bullet list is shown.
394 **
395 ** Query parameters:
396 **
397 ** all Show all branches
398 ** closed Show only closed branches
399 ** open Show only open branches (default behavior)
400
+18
--- src/browse.c
+++ src/browse.c
@@ -105,14 +105,21 @@
105105
106106
107107
/*
108108
** WEBPAGE: dir
109109
**
110
+** Show the files and subdirectories within a single directory of the
111
+** source tree. Only files for a single check-in are shown if the ci=
112
+** query parameter is present. If ci= is missing, the union of files
113
+** across all check-ins is shown.
114
+**
110115
** Query parameters:
111116
**
112117
** name=PATH Directory to display. Optional. Top-level if missing
113118
** ci=LABEL Show only files in this check-in. Optional.
119
+** type=TYPE TYPE=flat: use this display
120
+** TYPE=tree: use the /tree display instead
114121
*/
115122
void page_dir(void){
116123
char *zD = fossil_strdup(P("name"));
117124
int nD = zD ? strlen(zD)+1 : 0;
118125
int mxLen;
@@ -503,13 +510,21 @@
503510
}
504511
505512
506513
/*
507514
** WEBPAGE: tree
515
+**
516
+** Show the files using a tree-view. If the ci= query parameter is present
517
+** then show only the files for the check-in identified. If ci= is omitted,
518
+** then show the union of files over all check-ins.
519
+**
520
+** The type=tree query parameter is required or else the /dir format is
521
+** used.
508522
**
509523
** Query parameters:
510524
**
525
+** type=tree Required to prevent use of /dir format
511526
** name=PATH Directory to display. Optional
512527
** ci=LABEL Show only files in this check-in. Optional.
513528
** re=REGEXP Show only files matching REGEXP. Optional.
514529
** expand Begin with the tree fully expanded.
515530
** nofiles Show directories (folders) only. Omit files.
@@ -985,10 +1000,13 @@
9851000
db_finalize(&q);
9861001
}
9871002
9881003
/*
9891004
** WEBPAGE: fileage
1005
+**
1006
+** Show all files in a single check-in (identified by the name= query
1007
+** parameter) in order of increasing age.
9901008
**
9911009
** Parameters:
9921010
** name=VERSION Selects the check-in version (default=tip).
9931011
** glob=STRING Only shows files matching this glob pattern
9941012
** (e.g. *.c or *.txt).
9951013
--- src/browse.c
+++ src/browse.c
@@ -105,14 +105,21 @@
105
106
107 /*
108 ** WEBPAGE: dir
109 **
 
 
 
 
 
110 ** Query parameters:
111 **
112 ** name=PATH Directory to display. Optional. Top-level if missing
113 ** ci=LABEL Show only files in this check-in. Optional.
 
 
114 */
115 void page_dir(void){
116 char *zD = fossil_strdup(P("name"));
117 int nD = zD ? strlen(zD)+1 : 0;
118 int mxLen;
@@ -503,13 +510,21 @@
503 }
504
505
506 /*
507 ** WEBPAGE: tree
 
 
 
 
 
 
 
508 **
509 ** Query parameters:
510 **
 
511 ** name=PATH Directory to display. Optional
512 ** ci=LABEL Show only files in this check-in. Optional.
513 ** re=REGEXP Show only files matching REGEXP. Optional.
514 ** expand Begin with the tree fully expanded.
515 ** nofiles Show directories (folders) only. Omit files.
@@ -985,10 +1000,13 @@
985 db_finalize(&q);
986 }
987
988 /*
989 ** WEBPAGE: fileage
 
 
 
990 **
991 ** Parameters:
992 ** name=VERSION Selects the check-in version (default=tip).
993 ** glob=STRING Only shows files matching this glob pattern
994 ** (e.g. *.c or *.txt).
995
--- src/browse.c
+++ src/browse.c
@@ -105,14 +105,21 @@
105
106
107 /*
108 ** WEBPAGE: dir
109 **
110 ** Show the files and subdirectories within a single directory of the
111 ** source tree. Only files for a single check-in are shown if the ci=
112 ** query parameter is present. If ci= is missing, the union of files
113 ** across all check-ins is shown.
114 **
115 ** Query parameters:
116 **
117 ** name=PATH Directory to display. Optional. Top-level if missing
118 ** ci=LABEL Show only files in this check-in. Optional.
119 ** type=TYPE TYPE=flat: use this display
120 ** TYPE=tree: use the /tree display instead
121 */
122 void page_dir(void){
123 char *zD = fossil_strdup(P("name"));
124 int nD = zD ? strlen(zD)+1 : 0;
125 int mxLen;
@@ -503,13 +510,21 @@
510 }
511
512
513 /*
514 ** WEBPAGE: tree
515 **
516 ** Show the files using a tree-view. If the ci= query parameter is present
517 ** then show only the files for the check-in identified. If ci= is omitted,
518 ** then show the union of files over all check-ins.
519 **
520 ** The type=tree query parameter is required or else the /dir format is
521 ** used.
522 **
523 ** Query parameters:
524 **
525 ** type=tree Required to prevent use of /dir format
526 ** name=PATH Directory to display. Optional
527 ** ci=LABEL Show only files in this check-in. Optional.
528 ** re=REGEXP Show only files matching REGEXP. Optional.
529 ** expand Begin with the tree fully expanded.
530 ** nofiles Show directories (folders) only. Omit files.
@@ -985,10 +1000,13 @@
1000 db_finalize(&q);
1001 }
1002
1003 /*
1004 ** WEBPAGE: fileage
1005 **
1006 ** Show all files in a single check-in (identified by the name= query
1007 ** parameter) in order of increasing age.
1008 **
1009 ** Parameters:
1010 ** name=VERSION Selects the check-in version (default=tip).
1011 ** glob=STRING Only shows files matching this glob pattern
1012 ** (e.g. *.c or *.txt).
1013
+2 -1
--- src/cache.c
+++ src/cache.c
@@ -330,11 +330,11 @@
330330
}
331331
332332
/*
333333
** WEBPAGE: cachestat
334334
**
335
-** Show information about the webpage cache
335
+** Show information about the webpage cache. Requires Admin privilege.
336336
*/
337337
void cache_page(void){
338338
sqlite3 *db;
339339
sqlite3_stmt *pStmt;
340340
char zBuf[100];
@@ -380,10 +380,11 @@
380380
**
381381
** Usage: /cacheget?key=KEY
382382
**
383383
** Download a single entry for the cache, identified by KEY.
384384
** This page is normally a hyperlink from the /cachestat page.
385
+** Requires Admin privilege.
385386
*/
386387
void cache_getpage(void){
387388
const char *zKey;
388389
Blob content;
389390
390391
--- src/cache.c
+++ src/cache.c
@@ -330,11 +330,11 @@
330 }
331
332 /*
333 ** WEBPAGE: cachestat
334 **
335 ** Show information about the webpage cache
336 */
337 void cache_page(void){
338 sqlite3 *db;
339 sqlite3_stmt *pStmt;
340 char zBuf[100];
@@ -380,10 +380,11 @@
380 **
381 ** Usage: /cacheget?key=KEY
382 **
383 ** Download a single entry for the cache, identified by KEY.
384 ** This page is normally a hyperlink from the /cachestat page.
 
385 */
386 void cache_getpage(void){
387 const char *zKey;
388 Blob content;
389
390
--- src/cache.c
+++ src/cache.c
@@ -330,11 +330,11 @@
330 }
331
332 /*
333 ** WEBPAGE: cachestat
334 **
335 ** Show information about the webpage cache. Requires Admin privilege.
336 */
337 void cache_page(void){
338 sqlite3 *db;
339 sqlite3_stmt *pStmt;
340 char zBuf[100];
@@ -380,10 +380,11 @@
380 **
381 ** Usage: /cacheget?key=KEY
382 **
383 ** Download a single entry for the cache, identified by KEY.
384 ** This page is normally a hyperlink from the /cachestat page.
385 ** Requires Admin privilege.
386 */
387 void cache_getpage(void){
388 const char *zKey;
389 Blob content;
390
391
+9 -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;
@@ -414,10 +414,12 @@
414414
}
415415
#endif /* CAPTCHA==3 */
416416
417417
/*
418418
** COMMAND: test-captcha
419
+**
420
+** Render an ASCII-art captcha for numbers given on the command line.
419421
*/
420422
void test_captcha(void){
421423
int i;
422424
unsigned int v;
423425
char *z;
@@ -551,10 +553,13 @@
551553
@ </td></tr></table></div>
552554
}
553555
554556
/*
555557
** WEBPAGE: test-captcha
558
+** Test the captcha-generator by rendering the value of the name= query
559
+** parameter using ascii-art. If name= is omitted, show a random 16-digit
560
+** hexadecimal number.
556561
*/
557562
void captcha_test(void){
558563
const char *zPw = P("name");
559564
if( zPw==0 || zPw[0]==0 ){
560565
u64 x;
561566
--- 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;
@@ -414,10 +414,12 @@
414 }
415 #endif /* CAPTCHA==3 */
416
417 /*
418 ** COMMAND: test-captcha
 
 
419 */
420 void test_captcha(void){
421 int i;
422 unsigned int v;
423 char *z;
@@ -551,10 +553,13 @@
551 @ </td></tr></table></div>
552 }
553
554 /*
555 ** WEBPAGE: test-captcha
 
 
 
556 */
557 void captcha_test(void){
558 const char *zPw = P("name");
559 if( zPw==0 || zPw[0]==0 ){
560 u64 x;
561
--- 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;
@@ -414,10 +414,12 @@
414 }
415 #endif /* CAPTCHA==3 */
416
417 /*
418 ** COMMAND: test-captcha
419 **
420 ** Render an ASCII-art captcha for numbers given on the command line.
421 */
422 void test_captcha(void){
423 int i;
424 unsigned int v;
425 char *z;
@@ -551,10 +553,13 @@
553 @ </td></tr></table></div>
554 }
555
556 /*
557 ** WEBPAGE: test-captcha
558 ** Test the captcha-generator by rendering the value of the name= query
559 ** parameter using ascii-art. If name= is omitted, show a random 16-digit
560 ** hexadecimal number.
561 */
562 void captcha_test(void){
563 const char *zPw = P("name");
564 if( zPw==0 || zPw[0]==0 ){
565 u64 x;
566
+73 -53
--- src/checkin.c
+++ src/checkin.c
@@ -44,15 +44,15 @@
4444
Blob where;
4545
const char *zName;
4646
int i;
4747
4848
blob_zero(&where);
49
- for(i=2; i<g.argc; i++) {
49
+ for(i=2; i<g.argc; i++){
5050
Blob fname;
5151
file_tree_name(g.argv[i], &fname, 1);
5252
zName = blob_str(&fname);
53
- if( fossil_strcmp(zName, ".")==0 ) {
53
+ if( fossil_strcmp(zName, ".")==0 ){
5454
blob_reset(&where);
5555
break;
5656
}
5757
blob_append_sql(&where,
5858
" %s (pathname=%Q %s) "
@@ -65,11 +65,12 @@
6565
6666
db_prepare(&q,
6767
"SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
6868
" FROM vfile "
6969
" WHERE is_selected(id) %s"
70
- " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1 /*scan*/",
70
+ " AND (chnged OR deleted OR rid=0 OR pathname!=origname)"
71
+ " ORDER BY 1 /*scan*/",
7172
blob_sql_text(&where)
7273
);
7374
blob_zero(&rewrittenPathname);
7475
while( db_step(&q)==SQLITE_ROW ){
7576
const char *zPathname = db_column_text(&q,0);
@@ -264,19 +265,20 @@
264265
if( vid ){
265266
show_common_info(vid, "checkout:", 1, 1);
266267
}
267268
db_record_repository_filename(0);
268269
print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);
270
+ leaf_ambiguity_warning(vid, vid);
269271
}
270272
271273
/*
272274
** Take care of -r version of ls command
273275
*/
274276
static void ls_cmd_rev(
275277
const char *zRev, /* Revision string given */
276278
int verboseFlag, /* Verbose flag given */
277
- int showAge, /* Age flag given */
279
+ int showAge, /* Age flag given */
278280
int timeOrder /* Order by time flag given */
279281
){
280282
Stmt q;
281283
char *zOrderBy = "pathname COLLATE nocase";
282284
char *zName;
@@ -288,11 +290,11 @@
288290
blob_zero(&where);
289291
for(i=2; i<g.argc; i++){
290292
Blob fname;
291293
file_tree_name(g.argv[i], &fname, 1);
292294
zName = blob_str(&fname);
293
- if( fossil_strcmp(zName, ".")==0 ) {
295
+ if( fossil_strcmp(zName, ".")==0 ){
294296
blob_reset(&where);
295297
break;
296298
}
297299
blob_append_sql(&where,
298300
" %s (pathname=%Q %s) "
@@ -308,11 +310,11 @@
308310
309311
rid = symbolic_name_to_rid(zRev, "ci");
310312
if( rid==0 ){
311313
fossil_fatal("not a valid check-in: %s", zRev);
312314
}
313
-
315
+
314316
if( timeOrder ){
315317
zOrderBy = "mtime DESC";
316318
}
317319
318320
compute_fileage(rid,0);
@@ -333,11 +335,11 @@
333335
fossil_print("%s %7d %s\n", zTime, size, zFile);
334336
}else if( showAge ){
335337
fossil_print("%s %s\n", zTime, zFile);
336338
}else{
337339
fossil_print("%s\n", zFile);
338
- }
340
+ }
339341
}
340342
db_finalize(&q);
341343
}
342344
343345
/*
@@ -401,11 +403,11 @@
401403
blob_zero(&where);
402404
for(i=2; i<g.argc; i++){
403405
Blob fname;
404406
file_tree_name(g.argv[i], &fname, 1);
405407
zName = blob_str(&fname);
406
- if( fossil_strcmp(zName, ".")==0 ) {
408
+ if( fossil_strcmp(zName, ".")==0 ){
407409
blob_reset(&where);
408410
break;
409411
}
410412
blob_append_sql(&where,
411413
" %s (pathname=%Q %s) "
@@ -593,11 +595,11 @@
593595
db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
594596
blob_zero(&rewrittenPathname);
595597
g.allowSymlinks = 1; /* Report on symbolic links */
596598
while( db_step(&q)==SQLITE_ROW ){
597599
zDisplayName = zPathname = db_column_text(&q, 0);
598
- if( cwdRelative ) {
600
+ if( cwdRelative ){
599601
char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
600602
file_relative_name(zFullName, &rewrittenPathname, 0);
601603
free(zFullName);
602604
zDisplayName = blob_str(&rewrittenPathname);
603605
if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
@@ -615,30 +617,30 @@
615617
db_finalize(&q);
616618
}
617619
618620
/*
619621
** COMMAND: clean
620
-** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
622
+** Usage: %fossil clean ?OPTIONS? ?PATH ...?
621623
**
622624
** Delete all "extra" files in the source tree. "Extra" files are
623625
** files that are not officially part of the checkout. This operation
624
-** cannot be undone. If paths are specified, only the directories or
625
-** files specified will be considered for cleaning.
626
-**
627
-** You will be prompted before removing each eligible file unless the
628
-** --force flag is in use or it matches the --clean option. The
629
-** GLOBPATTERN specified by the "ignore-glob" setting is used if the
630
-** --ignore option is omitted, the same with "clean-glob" and --clean
631
-** as well as "keep-glob" and --keep. If you are sure you wish to
632
-** remove all "extra" files except the ones specified with --ignore
633
-** and --keep, you can specify the optional -f|--force flag and no
634
-** prompts will be issued. If a file matches both --keep and --clean,
635
-** --keep takes precedence.
636
-**
637
-** Files and subdirectories whose names begin with "." are
638
-** normally kept. They are handled if the "--dotfiles" option
639
-** is used.
626
+** cannot be undone. If one or more PATH arguments appear, then only
627
+** the files named, or files contained with directories named, will be
628
+** removed.
629
+**
630
+** Prompted are issued to confirm the removal of each file, unless
631
+** the --force flag is used or unless the file matches glob pattern
632
+** specified by the --clean option. No file that matches glob patterns
633
+** specified by --ignore or --keep will ever be deleted. The default
634
+** values for --clean, --ignore, and --keep are determined by the
635
+** (versionable) clean-glob, ignore-glob, and keep-glob settings.
636
+** Files and subdirectories whose names begin with "." are automatically
637
+** ignored unless the --dotfiles option is used.
638
+**
639
+** The --verily option ignores the keep-glob and ignore-glob settings
640
+** and turns on --force, --dotfiles, and --emptydirs. Use the --verily
641
+** option when you really want to clean up everything.
640642
**
641643
** Options:
642644
** --allckouts Check for empty directories within any checkouts
643645
** that may be nested within the current one. This
644646
** option should be used with great care because the
@@ -656,27 +658,31 @@
656658
** argument. Matching files, if any, are removed
657659
** prior to checking for any empty directories;
658660
** therefore, directories that contain only files
659661
** that were removed will be removed as well.
660662
** -f|--force Remove files without prompting.
661
-** --verily Shorthand for: -f --emptydirs --dotfiles
663
+** -x|--verily Remove everything that is not a managed file or
664
+** the repository itself. Implies -f --emptydirs
665
+** --dotfiles. Disregard keep-glob and ignore-glob.
662666
** --clean <CSG> Never prompt for files matching this
663667
** comma separated list of glob patterns.
664668
** --ignore <CSG> Ignore files matching patterns from the
665669
** comma separated list of glob patterns.
666670
** --keep <CSG> Keep files matching this comma separated
667671
** list of glob patterns.
668
-** -n|--dry-run If given, display instead of run actions.
672
+** -n|--dry-run Delete nothing, but display what would have been
673
+** deleted.
669674
** --temp Remove only Fossil-generated temporary files.
670675
** -v|--verbose Show all files as they are removed.
671676
**
672677
** See also: addremove, extras, status
673678
*/
674679
void clean_cmd(void){
675680
int allFileFlag, allDirFlag, dryRunFlag, verboseFlag;
676681
int emptyDirsFlag, dirsOnlyFlag;
677682
unsigned scanFlags = 0;
683
+ int verilyFlag = 0;
678684
const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
679685
Glob *pIgnore, *pKeep, *pClean;
680686
int nRoot;
681687
682688
dryRunFlag = find_option("dry-run","n",0)!=0;
@@ -695,22 +701,23 @@
695701
zIgnoreFlag = find_option("ignore",0,1);
696702
verboseFlag = find_option("verbose","v",0)!=0;
697703
zKeepFlag = find_option("keep",0,1);
698704
zCleanFlag = find_option("clean",0,1);
699705
db_must_be_within_tree();
700
- if( find_option("verily",0,0)!=0 ){
701
- allFileFlag = allDirFlag = 1;
706
+ if( find_option("verily","x",0)!=0 ){
707
+ verilyFlag = allFileFlag = allDirFlag = 1;
702708
emptyDirsFlag = 1;
703709
scanFlags |= SCAN_ALL;
710
+ zCleanFlag = 0;
704711
}
705
- if( zIgnoreFlag==0 ){
712
+ if( zIgnoreFlag==0 && !verilyFlag ){
706713
zIgnoreFlag = db_get("ignore-glob", 0);
707714
}
708
- if( zKeepFlag==0 ){
715
+ if( zKeepFlag==0 && !verilyFlag ){
709716
zKeepFlag = db_get("keep-glob", 0);
710717
}
711
- if( zCleanFlag==0 ){
718
+ if( zCleanFlag==0 && !verilyFlag ){
712719
zCleanFlag = db_get("clean-glob", 0);
713720
}
714721
if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
715722
verify_all_options();
716723
pIgnore = glob_create(zIgnoreFlag);
@@ -754,11 +761,11 @@
754761
blob_reset(&ans);
755762
continue;
756763
}
757764
blob_reset(&ans);
758765
}
759
- if ( dryRunFlag || file_delete(zName)==0 ){
766
+ if( dryRunFlag || file_delete(zName)==0 ){
760767
if( verboseFlag || dryRunFlag ){
761768
fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
762769
}
763770
}else if( verboseFlag ){
764771
fossil_print("Could not remove file: %s\n", zName+nRoot);
@@ -770,11 +777,11 @@
770777
Glob *pEmptyDirs = glob_create(db_get("empty-dirs", 0));
771778
Stmt q;
772779
Blob root;
773780
blob_init(&root, g.zLocalRoot, nRoot - 1);
774781
vfile_dir_scan(&root, blob_size(&root), scanFlags, pIgnore,
775
- pEmptyDirs, 0);
782
+ pEmptyDirs);
776783
blob_reset(&root);
777784
db_prepare(&q,
778785
"SELECT %Q || x FROM dscan_temp"
779786
" WHERE x NOT IN (%s) AND y = 0"
780787
" ORDER BY 1 DESC",
@@ -802,11 +809,11 @@
802809
blob_reset(&ans);
803810
continue;
804811
}
805812
blob_reset(&ans);
806813
}
807
- if ( dryRunFlag || file_rmdir(zName)==0 ){
814
+ if( dryRunFlag || file_rmdir(zName)==0 ){
808815
if( verboseFlag || dryRunFlag ){
809816
fossil_print("Removed unmanaged directory: %s\n", zName+nRoot);
810817
}
811818
}else if( verboseFlag ){
812819
fossil_print("Could not remove directory: %s\n", zName+nRoot);
@@ -941,22 +948,24 @@
941948
Blob prompt;
942949
#if defined(_WIN32) || defined(__CYGWIN__)
943950
int bomSize;
944951
const unsigned char *bom = get_utf8_bom(&bomSize);
945952
blob_init(&prompt, (const char *) bom, bomSize);
946
- if( zInit && zInit[0]) {
953
+ if( zInit && zInit[0]){
947954
blob_append(&prompt, zInit, -1);
948955
}
949956
#else
950957
blob_init(&prompt, zInit, -1);
951958
#endif
952959
blob_append(&prompt,
953960
"\n"
954
- "# Enter a commit message for this check-in. Lines beginning with # are ignored.\n"
961
+ "# Enter a commit message for this check-in."
962
+ " Lines beginning with # are ignored.\n"
955963
"#\n", -1
956964
);
957
- blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : login_name());
965
+ blob_appendf(&prompt, "# user: %s\n",
966
+ p->zUserOvrd ? p->zUserOvrd : login_name());
958967
if( p->zBranch && p->zBranch[0] ){
959968
blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
960969
}else{
961970
char *zTags = info_tags_of_checkin(parent_rid, 1);
962971
if( zTags || p->azTag ){
@@ -1041,11 +1050,12 @@
10411050
fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
10421051
result = 1;
10431052
}
10441053
blob_reset(&fname);
10451054
}
1046
- g.aCommitFile = fossil_malloc( (bag_count(&toCommit)+1) * sizeof(g.aCommitFile[0]) );
1055
+ g.aCommitFile = fossil_malloc( (bag_count(&toCommit)+1) *
1056
+ sizeof(g.aCommitFile[0]) );
10471057
for(ii=bag_first(&toCommit); ii>0; ii=bag_next(&toCommit, ii)){
10481058
g.aCommitFile[jj++] = ii;
10491059
}
10501060
g.aCommitFile[jj] = 0;
10511061
bag_clear(&toCommit);
@@ -1269,11 +1279,13 @@
12691279
free(zParentUuid);
12701280
db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
12711281
while( db_step(&q)==SQLITE_ROW ){
12721282
char *zMergeUuid;
12731283
int mid = db_column_int(&q, 0);
1274
- if( (!g.markPrivate && content_is_private(mid)) || (mid == vid) ) continue;
1284
+ if( (!g.markPrivate && content_is_private(mid)) || (mid == vid) ){
1285
+ continue;
1286
+ }
12751287
zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
12761288
if( zMergeUuid ){
12771289
blob_appendf(pOut, " %s", zMergeUuid);
12781290
if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
12791291
free(zMergeUuid);
@@ -1380,11 +1392,11 @@
13801392
int fBinary; /* does the blob content appear to be binary? */
13811393
int lookFlags; /* output flags from looks_like_utf8/utf16() */
13821394
int fHasAnyCr; /* the blob contains one or more CR chars */
13831395
int fHasLoneCrOnly; /* all detected line endings are CR only */
13841396
int fHasCrLfOnly; /* all detected line endings are CR/LF pairs */
1385
- int fHasInvalidUtf8 = 0;/* contains byte-sequence which is invalid for UTF-8 */
1397
+ int fHasInvalidUtf8 = 0;/* contains invalid UTF-8 */
13861398
char *zMsg; /* Warning message */
13871399
Blob fname; /* Relative pathname of the file */
13881400
static int allOk = 0; /* Set to true to disable this routine */
13891401
13901402
if( allOk ) return 0;
@@ -1459,11 +1471,12 @@
14591471
zWarning = "Unicode";
14601472
zDisable = "\"encoding-glob\" setting";
14611473
}
14621474
file_relative_name(zFilename, &fname, 0);
14631475
zMsg = mprintf(
1464
- "%s contains %s. Use --no-warnings or the %s to disable this warning.\n"
1476
+ "%s contains %s. Use --no-warnings or the %s to"
1477
+ " disable this warning.\n"
14651478
"Commit anyhow (a=all/%sy/N)? ",
14661479
blob_str(&fname), zWarning, zDisable, zConvert);
14671480
prompt_user(zMsg, &ans);
14681481
fossil_free(zMsg);
14691482
cReply = blob_str(&ans)[0];
@@ -1476,11 +1489,11 @@
14761489
fossil_free(zOrig);
14771490
f = fossil_fopen(zFilename, "wb");
14781491
if( f==0 ){
14791492
fossil_warning("cannot open %s for writing", zFilename);
14801493
}else{
1481
- if( fUnicode ) {
1494
+ if( fUnicode ){
14821495
int bomSize;
14831496
const unsigned char *bom = get_utf8_bom(&bomSize);
14841497
fwrite(bom, 1, bomSize, f);
14851498
blob_to_utf8_no_bom(p, 0);
14861499
}else if( fHasInvalidUtf8 ){
@@ -1659,11 +1672,12 @@
16591672
sCiInfo.closeFlag = find_option("close",0,0)!=0;
16601673
sCiInfo.integrateFlag = find_option("integrate",0,0)!=0;
16611674
sCiInfo.zMimetype = find_option("mimetype",0,1);
16621675
while( (zTag = find_option("tag",0,1))!=0 ){
16631676
if( zTag[0]==0 ) continue;
1664
- sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
1677
+ sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag,
1678
+ sizeof(char*)*(nTag+2));
16651679
sCiInfo.azTag[nTag++] = zTag;
16661680
sCiInfo.azTag[nTag] = 0;
16671681
}
16681682
zComFile = find_option("message-file", "M", 1);
16691683
if( find_option("private",0,0) ){
@@ -1840,11 +1854,10 @@
18401854
" AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch))
18411855
){
18421856
fossil_fatal("cannot commit against a closed leaf");
18431857
}
18441858
1845
- if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
18461859
if( zComment ){
18471860
blob_zero(&comment);
18481861
blob_append(&comment, zComment, -1);
18491862
}else if( zComFile ){
18501863
blob_zero(&comment);
@@ -1874,16 +1887,24 @@
18741887
db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
18751888
db_end_transaction(0);
18761889
db_begin_transaction();
18771890
}
18781891
1879
- /* Step 1: Insert records for all modified files into the blob
1892
+ /*
1893
+ ** Step 1: Compute an aggregate MD5 checksum over the disk image
1894
+ ** of every file in vid. The file names are part of the checksum.
1895
+ ** The resulting checksum is the same as is expected on the R-card
1896
+ ** of a manifest.
1897
+ */
1898
+ if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
1899
+
1900
+ /* Step 2: Insert records for all modified files into the blob
18801901
** table. If there were arguments passed to this command, only
18811902
** the identified files are inserted (if they have been modified).
18821903
*/
18831904
db_prepare(&q,
1884
- "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile "
1905
+ "SELECT id, %Q || pathname, mrid, %s, %s, %s FROM vfile "
18851906
"WHERE chnged==1 AND NOT deleted AND is_selected(id)",
18861907
g.zLocalRoot,
18871908
glob_expr("pathname", db_get("crnl-glob","")),
18881909
glob_expr("pathname", db_get("binary-glob","")),
18891910
glob_expr("pathname", db_get("encoding-glob",""))
@@ -1890,19 +1911,18 @@
18901911
);
18911912
while( db_step(&q)==SQLITE_ROW ){
18921913
int id, rid;
18931914
const char *zFullname;
18941915
Blob content;
1895
- int crnlOk, binOk, encodingOk, chnged;
1916
+ int crnlOk, binOk, encodingOk;
18961917
18971918
id = db_column_int(&q, 0);
18981919
zFullname = db_column_text(&q, 1);
18991920
rid = db_column_int(&q, 2);
19001921
crnlOk = db_column_int(&q, 3);
1901
- chnged = db_column_int(&q, 4);
1902
- binOk = db_column_int(&q, 5);
1903
- encodingOk = db_column_int(&q, 6);
1922
+ binOk = db_column_int(&q, 4);
1923
+ encodingOk = db_column_int(&q, 5);
19041924
19051925
blob_zero(&content);
19061926
if( file_wd_islink(zFullname) ){
19071927
/* Instead of file content, put link destination path */
19081928
blob_read_link(&content, zFullname);
@@ -1912,11 +1932,11 @@
19121932
/* Do not emit any warnings when they are disabled. */
19131933
if( !noWarningFlag ){
19141934
abortCommit |= commit_warning(&content, crnlOk, binOk,
19151935
encodingOk, zFullname);
19161936
}
1917
- if( chnged==1 && contains_merge_marker(&content) ){
1937
+ if( contains_merge_marker(&content) ){
19181938
Blob fname; /* Relative pathname of the file */
19191939
19201940
nConflict++;
19211941
file_relative_name(zFullname, &fname, 0);
19221942
fossil_print("possible unresolved merge conflict in %s\n",
19231943
--- src/checkin.c
+++ src/checkin.c
@@ -44,15 +44,15 @@
44 Blob where;
45 const char *zName;
46 int i;
47
48 blob_zero(&where);
49 for(i=2; i<g.argc; i++) {
50 Blob fname;
51 file_tree_name(g.argv[i], &fname, 1);
52 zName = blob_str(&fname);
53 if( fossil_strcmp(zName, ".")==0 ) {
54 blob_reset(&where);
55 break;
56 }
57 blob_append_sql(&where,
58 " %s (pathname=%Q %s) "
@@ -65,11 +65,12 @@
65
66 db_prepare(&q,
67 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
68 " FROM vfile "
69 " WHERE is_selected(id) %s"
70 " AND (chnged OR deleted OR rid=0 OR pathname!=origname) ORDER BY 1 /*scan*/",
 
71 blob_sql_text(&where)
72 );
73 blob_zero(&rewrittenPathname);
74 while( db_step(&q)==SQLITE_ROW ){
75 const char *zPathname = db_column_text(&q,0);
@@ -264,19 +265,20 @@
264 if( vid ){
265 show_common_info(vid, "checkout:", 1, 1);
266 }
267 db_record_repository_filename(0);
268 print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);
 
269 }
270
271 /*
272 ** Take care of -r version of ls command
273 */
274 static void ls_cmd_rev(
275 const char *zRev, /* Revision string given */
276 int verboseFlag, /* Verbose flag given */
277 int showAge, /* Age flag given */
278 int timeOrder /* Order by time flag given */
279 ){
280 Stmt q;
281 char *zOrderBy = "pathname COLLATE nocase";
282 char *zName;
@@ -288,11 +290,11 @@
288 blob_zero(&where);
289 for(i=2; i<g.argc; i++){
290 Blob fname;
291 file_tree_name(g.argv[i], &fname, 1);
292 zName = blob_str(&fname);
293 if( fossil_strcmp(zName, ".")==0 ) {
294 blob_reset(&where);
295 break;
296 }
297 blob_append_sql(&where,
298 " %s (pathname=%Q %s) "
@@ -308,11 +310,11 @@
308
309 rid = symbolic_name_to_rid(zRev, "ci");
310 if( rid==0 ){
311 fossil_fatal("not a valid check-in: %s", zRev);
312 }
313
314 if( timeOrder ){
315 zOrderBy = "mtime DESC";
316 }
317
318 compute_fileage(rid,0);
@@ -333,11 +335,11 @@
333 fossil_print("%s %7d %s\n", zTime, size, zFile);
334 }else if( showAge ){
335 fossil_print("%s %s\n", zTime, zFile);
336 }else{
337 fossil_print("%s\n", zFile);
338 }
339 }
340 db_finalize(&q);
341 }
342
343 /*
@@ -401,11 +403,11 @@
401 blob_zero(&where);
402 for(i=2; i<g.argc; i++){
403 Blob fname;
404 file_tree_name(g.argv[i], &fname, 1);
405 zName = blob_str(&fname);
406 if( fossil_strcmp(zName, ".")==0 ) {
407 blob_reset(&where);
408 break;
409 }
410 blob_append_sql(&where,
411 " %s (pathname=%Q %s) "
@@ -593,11 +595,11 @@
593 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
594 blob_zero(&rewrittenPathname);
595 g.allowSymlinks = 1; /* Report on symbolic links */
596 while( db_step(&q)==SQLITE_ROW ){
597 zDisplayName = zPathname = db_column_text(&q, 0);
598 if( cwdRelative ) {
599 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
600 file_relative_name(zFullName, &rewrittenPathname, 0);
601 free(zFullName);
602 zDisplayName = blob_str(&rewrittenPathname);
603 if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
@@ -615,30 +617,30 @@
615 db_finalize(&q);
616 }
617
618 /*
619 ** COMMAND: clean
620 ** Usage: %fossil clean ?OPTIONS? ?PATH1 ...?
621 **
622 ** Delete all "extra" files in the source tree. "Extra" files are
623 ** files that are not officially part of the checkout. This operation
624 ** cannot be undone. If paths are specified, only the directories or
625 ** files specified will be considered for cleaning.
626 **
627 ** You will be prompted before removing each eligible file unless the
628 ** --force flag is in use or it matches the --clean option. The
629 ** GLOBPATTERN specified by the "ignore-glob" setting is used if the
630 ** --ignore option is omitted, the same with "clean-glob" and --clean
631 ** as well as "keep-glob" and --keep. If you are sure you wish to
632 ** remove all "extra" files except the ones specified with --ignore
633 ** and --keep, you can specify the optional -f|--force flag and no
634 ** prompts will be issued. If a file matches both --keep and --clean,
635 ** --keep takes precedence.
636 **
637 ** Files and subdirectories whose names begin with "." are
638 ** normally kept. They are handled if the "--dotfiles" option
639 ** is used.
640 **
641 ** Options:
642 ** --allckouts Check for empty directories within any checkouts
643 ** that may be nested within the current one. This
644 ** option should be used with great care because the
@@ -656,27 +658,31 @@
656 ** argument. Matching files, if any, are removed
657 ** prior to checking for any empty directories;
658 ** therefore, directories that contain only files
659 ** that were removed will be removed as well.
660 ** -f|--force Remove files without prompting.
661 ** --verily Shorthand for: -f --emptydirs --dotfiles
 
 
662 ** --clean <CSG> Never prompt for files matching this
663 ** comma separated list of glob patterns.
664 ** --ignore <CSG> Ignore files matching patterns from the
665 ** comma separated list of glob patterns.
666 ** --keep <CSG> Keep files matching this comma separated
667 ** list of glob patterns.
668 ** -n|--dry-run If given, display instead of run actions.
 
669 ** --temp Remove only Fossil-generated temporary files.
670 ** -v|--verbose Show all files as they are removed.
671 **
672 ** See also: addremove, extras, status
673 */
674 void clean_cmd(void){
675 int allFileFlag, allDirFlag, dryRunFlag, verboseFlag;
676 int emptyDirsFlag, dirsOnlyFlag;
677 unsigned scanFlags = 0;
 
678 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
679 Glob *pIgnore, *pKeep, *pClean;
680 int nRoot;
681
682 dryRunFlag = find_option("dry-run","n",0)!=0;
@@ -695,22 +701,23 @@
695 zIgnoreFlag = find_option("ignore",0,1);
696 verboseFlag = find_option("verbose","v",0)!=0;
697 zKeepFlag = find_option("keep",0,1);
698 zCleanFlag = find_option("clean",0,1);
699 db_must_be_within_tree();
700 if( find_option("verily",0,0)!=0 ){
701 allFileFlag = allDirFlag = 1;
702 emptyDirsFlag = 1;
703 scanFlags |= SCAN_ALL;
 
704 }
705 if( zIgnoreFlag==0 ){
706 zIgnoreFlag = db_get("ignore-glob", 0);
707 }
708 if( zKeepFlag==0 ){
709 zKeepFlag = db_get("keep-glob", 0);
710 }
711 if( zCleanFlag==0 ){
712 zCleanFlag = db_get("clean-glob", 0);
713 }
714 if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
715 verify_all_options();
716 pIgnore = glob_create(zIgnoreFlag);
@@ -754,11 +761,11 @@
754 blob_reset(&ans);
755 continue;
756 }
757 blob_reset(&ans);
758 }
759 if ( dryRunFlag || file_delete(zName)==0 ){
760 if( verboseFlag || dryRunFlag ){
761 fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
762 }
763 }else if( verboseFlag ){
764 fossil_print("Could not remove file: %s\n", zName+nRoot);
@@ -770,11 +777,11 @@
770 Glob *pEmptyDirs = glob_create(db_get("empty-dirs", 0));
771 Stmt q;
772 Blob root;
773 blob_init(&root, g.zLocalRoot, nRoot - 1);
774 vfile_dir_scan(&root, blob_size(&root), scanFlags, pIgnore,
775 pEmptyDirs, 0);
776 blob_reset(&root);
777 db_prepare(&q,
778 "SELECT %Q || x FROM dscan_temp"
779 " WHERE x NOT IN (%s) AND y = 0"
780 " ORDER BY 1 DESC",
@@ -802,11 +809,11 @@
802 blob_reset(&ans);
803 continue;
804 }
805 blob_reset(&ans);
806 }
807 if ( dryRunFlag || file_rmdir(zName)==0 ){
808 if( verboseFlag || dryRunFlag ){
809 fossil_print("Removed unmanaged directory: %s\n", zName+nRoot);
810 }
811 }else if( verboseFlag ){
812 fossil_print("Could not remove directory: %s\n", zName+nRoot);
@@ -941,22 +948,24 @@
941 Blob prompt;
942 #if defined(_WIN32) || defined(__CYGWIN__)
943 int bomSize;
944 const unsigned char *bom = get_utf8_bom(&bomSize);
945 blob_init(&prompt, (const char *) bom, bomSize);
946 if( zInit && zInit[0]) {
947 blob_append(&prompt, zInit, -1);
948 }
949 #else
950 blob_init(&prompt, zInit, -1);
951 #endif
952 blob_append(&prompt,
953 "\n"
954 "# Enter a commit message for this check-in. Lines beginning with # are ignored.\n"
 
955 "#\n", -1
956 );
957 blob_appendf(&prompt, "# user: %s\n", p->zUserOvrd ? p->zUserOvrd : login_name());
 
958 if( p->zBranch && p->zBranch[0] ){
959 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
960 }else{
961 char *zTags = info_tags_of_checkin(parent_rid, 1);
962 if( zTags || p->azTag ){
@@ -1041,11 +1050,12 @@
1041 fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
1042 result = 1;
1043 }
1044 blob_reset(&fname);
1045 }
1046 g.aCommitFile = fossil_malloc( (bag_count(&toCommit)+1) * sizeof(g.aCommitFile[0]) );
 
1047 for(ii=bag_first(&toCommit); ii>0; ii=bag_next(&toCommit, ii)){
1048 g.aCommitFile[jj++] = ii;
1049 }
1050 g.aCommitFile[jj] = 0;
1051 bag_clear(&toCommit);
@@ -1269,11 +1279,13 @@
1269 free(zParentUuid);
1270 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
1271 while( db_step(&q)==SQLITE_ROW ){
1272 char *zMergeUuid;
1273 int mid = db_column_int(&q, 0);
1274 if( (!g.markPrivate && content_is_private(mid)) || (mid == vid) ) continue;
 
 
1275 zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
1276 if( zMergeUuid ){
1277 blob_appendf(pOut, " %s", zMergeUuid);
1278 if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
1279 free(zMergeUuid);
@@ -1380,11 +1392,11 @@
1380 int fBinary; /* does the blob content appear to be binary? */
1381 int lookFlags; /* output flags from looks_like_utf8/utf16() */
1382 int fHasAnyCr; /* the blob contains one or more CR chars */
1383 int fHasLoneCrOnly; /* all detected line endings are CR only */
1384 int fHasCrLfOnly; /* all detected line endings are CR/LF pairs */
1385 int fHasInvalidUtf8 = 0;/* contains byte-sequence which is invalid for UTF-8 */
1386 char *zMsg; /* Warning message */
1387 Blob fname; /* Relative pathname of the file */
1388 static int allOk = 0; /* Set to true to disable this routine */
1389
1390 if( allOk ) return 0;
@@ -1459,11 +1471,12 @@
1459 zWarning = "Unicode";
1460 zDisable = "\"encoding-glob\" setting";
1461 }
1462 file_relative_name(zFilename, &fname, 0);
1463 zMsg = mprintf(
1464 "%s contains %s. Use --no-warnings or the %s to disable this warning.\n"
 
1465 "Commit anyhow (a=all/%sy/N)? ",
1466 blob_str(&fname), zWarning, zDisable, zConvert);
1467 prompt_user(zMsg, &ans);
1468 fossil_free(zMsg);
1469 cReply = blob_str(&ans)[0];
@@ -1476,11 +1489,11 @@
1476 fossil_free(zOrig);
1477 f = fossil_fopen(zFilename, "wb");
1478 if( f==0 ){
1479 fossil_warning("cannot open %s for writing", zFilename);
1480 }else{
1481 if( fUnicode ) {
1482 int bomSize;
1483 const unsigned char *bom = get_utf8_bom(&bomSize);
1484 fwrite(bom, 1, bomSize, f);
1485 blob_to_utf8_no_bom(p, 0);
1486 }else if( fHasInvalidUtf8 ){
@@ -1659,11 +1672,12 @@
1659 sCiInfo.closeFlag = find_option("close",0,0)!=0;
1660 sCiInfo.integrateFlag = find_option("integrate",0,0)!=0;
1661 sCiInfo.zMimetype = find_option("mimetype",0,1);
1662 while( (zTag = find_option("tag",0,1))!=0 ){
1663 if( zTag[0]==0 ) continue;
1664 sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag, sizeof(char*)*(nTag+2));
 
1665 sCiInfo.azTag[nTag++] = zTag;
1666 sCiInfo.azTag[nTag] = 0;
1667 }
1668 zComFile = find_option("message-file", "M", 1);
1669 if( find_option("private",0,0) ){
@@ -1840,11 +1854,10 @@
1840 " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch))
1841 ){
1842 fossil_fatal("cannot commit against a closed leaf");
1843 }
1844
1845 if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
1846 if( zComment ){
1847 blob_zero(&comment);
1848 blob_append(&comment, zComment, -1);
1849 }else if( zComFile ){
1850 blob_zero(&comment);
@@ -1874,16 +1887,24 @@
1874 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1875 db_end_transaction(0);
1876 db_begin_transaction();
1877 }
1878
1879 /* Step 1: Insert records for all modified files into the blob
 
 
 
 
 
 
 
 
1880 ** table. If there were arguments passed to this command, only
1881 ** the identified files are inserted (if they have been modified).
1882 */
1883 db_prepare(&q,
1884 "SELECT id, %Q || pathname, mrid, %s, chnged, %s, %s FROM vfile "
1885 "WHERE chnged==1 AND NOT deleted AND is_selected(id)",
1886 g.zLocalRoot,
1887 glob_expr("pathname", db_get("crnl-glob","")),
1888 glob_expr("pathname", db_get("binary-glob","")),
1889 glob_expr("pathname", db_get("encoding-glob",""))
@@ -1890,19 +1911,18 @@
1890 );
1891 while( db_step(&q)==SQLITE_ROW ){
1892 int id, rid;
1893 const char *zFullname;
1894 Blob content;
1895 int crnlOk, binOk, encodingOk, chnged;
1896
1897 id = db_column_int(&q, 0);
1898 zFullname = db_column_text(&q, 1);
1899 rid = db_column_int(&q, 2);
1900 crnlOk = db_column_int(&q, 3);
1901 chnged = db_column_int(&q, 4);
1902 binOk = db_column_int(&q, 5);
1903 encodingOk = db_column_int(&q, 6);
1904
1905 blob_zero(&content);
1906 if( file_wd_islink(zFullname) ){
1907 /* Instead of file content, put link destination path */
1908 blob_read_link(&content, zFullname);
@@ -1912,11 +1932,11 @@
1912 /* Do not emit any warnings when they are disabled. */
1913 if( !noWarningFlag ){
1914 abortCommit |= commit_warning(&content, crnlOk, binOk,
1915 encodingOk, zFullname);
1916 }
1917 if( chnged==1 && contains_merge_marker(&content) ){
1918 Blob fname; /* Relative pathname of the file */
1919
1920 nConflict++;
1921 file_relative_name(zFullname, &fname, 0);
1922 fossil_print("possible unresolved merge conflict in %s\n",
1923
--- src/checkin.c
+++ src/checkin.c
@@ -44,15 +44,15 @@
44 Blob where;
45 const char *zName;
46 int i;
47
48 blob_zero(&where);
49 for(i=2; i<g.argc; i++){
50 Blob fname;
51 file_tree_name(g.argv[i], &fname, 1);
52 zName = blob_str(&fname);
53 if( fossil_strcmp(zName, ".")==0 ){
54 blob_reset(&where);
55 break;
56 }
57 blob_append_sql(&where,
58 " %s (pathname=%Q %s) "
@@ -65,11 +65,12 @@
65
66 db_prepare(&q,
67 "SELECT pathname, deleted, chnged, rid, coalesce(origname!=pathname,0)"
68 " FROM vfile "
69 " WHERE is_selected(id) %s"
70 " AND (chnged OR deleted OR rid=0 OR pathname!=origname)"
71 " ORDER BY 1 /*scan*/",
72 blob_sql_text(&where)
73 );
74 blob_zero(&rewrittenPathname);
75 while( db_step(&q)==SQLITE_ROW ){
76 const char *zPathname = db_column_text(&q,0);
@@ -264,19 +265,20 @@
265 if( vid ){
266 show_common_info(vid, "checkout:", 1, 1);
267 }
268 db_record_repository_filename(0);
269 print_changes(useSha1sum, showHdr, verboseFlag, cwdRelative);
270 leaf_ambiguity_warning(vid, vid);
271 }
272
273 /*
274 ** Take care of -r version of ls command
275 */
276 static void ls_cmd_rev(
277 const char *zRev, /* Revision string given */
278 int verboseFlag, /* Verbose flag given */
279 int showAge, /* Age flag given */
280 int timeOrder /* Order by time flag given */
281 ){
282 Stmt q;
283 char *zOrderBy = "pathname COLLATE nocase";
284 char *zName;
@@ -288,11 +290,11 @@
290 blob_zero(&where);
291 for(i=2; i<g.argc; i++){
292 Blob fname;
293 file_tree_name(g.argv[i], &fname, 1);
294 zName = blob_str(&fname);
295 if( fossil_strcmp(zName, ".")==0 ){
296 blob_reset(&where);
297 break;
298 }
299 blob_append_sql(&where,
300 " %s (pathname=%Q %s) "
@@ -308,11 +310,11 @@
310
311 rid = symbolic_name_to_rid(zRev, "ci");
312 if( rid==0 ){
313 fossil_fatal("not a valid check-in: %s", zRev);
314 }
315
316 if( timeOrder ){
317 zOrderBy = "mtime DESC";
318 }
319
320 compute_fileage(rid,0);
@@ -333,11 +335,11 @@
335 fossil_print("%s %7d %s\n", zTime, size, zFile);
336 }else if( showAge ){
337 fossil_print("%s %s\n", zTime, zFile);
338 }else{
339 fossil_print("%s\n", zFile);
340 }
341 }
342 db_finalize(&q);
343 }
344
345 /*
@@ -401,11 +403,11 @@
403 blob_zero(&where);
404 for(i=2; i<g.argc; i++){
405 Blob fname;
406 file_tree_name(g.argv[i], &fname, 1);
407 zName = blob_str(&fname);
408 if( fossil_strcmp(zName, ".")==0 ){
409 blob_reset(&where);
410 break;
411 }
412 blob_append_sql(&where,
413 " %s (pathname=%Q %s) "
@@ -593,11 +595,11 @@
595 db_multi_exec("DELETE FROM sfile WHERE x IN (SELECT pathname FROM vfile)");
596 blob_zero(&rewrittenPathname);
597 g.allowSymlinks = 1; /* Report on symbolic links */
598 while( db_step(&q)==SQLITE_ROW ){
599 zDisplayName = zPathname = db_column_text(&q, 0);
600 if( cwdRelative ){
601 char *zFullName = mprintf("%s%s", g.zLocalRoot, zPathname);
602 file_relative_name(zFullName, &rewrittenPathname, 0);
603 free(zFullName);
604 zDisplayName = blob_str(&rewrittenPathname);
605 if( zDisplayName[0]=='.' && zDisplayName[1]=='/' ){
@@ -615,30 +617,30 @@
617 db_finalize(&q);
618 }
619
620 /*
621 ** COMMAND: clean
622 ** Usage: %fossil clean ?OPTIONS? ?PATH ...?
623 **
624 ** Delete all "extra" files in the source tree. "Extra" files are
625 ** files that are not officially part of the checkout. This operation
626 ** cannot be undone. If one or more PATH arguments appear, then only
627 ** the files named, or files contained with directories named, will be
628 ** removed.
629 **
630 ** Prompted are issued to confirm the removal of each file, unless
631 ** the --force flag is used or unless the file matches glob pattern
632 ** specified by the --clean option. No file that matches glob patterns
633 ** specified by --ignore or --keep will ever be deleted. The default
634 ** values for --clean, --ignore, and --keep are determined by the
635 ** (versionable) clean-glob, ignore-glob, and keep-glob settings.
636 ** Files and subdirectories whose names begin with "." are automatically
637 ** ignored unless the --dotfiles option is used.
638 **
639 ** The --verily option ignores the keep-glob and ignore-glob settings
640 ** and turns on --force, --dotfiles, and --emptydirs. Use the --verily
641 ** option when you really want to clean up everything.
642 **
643 ** Options:
644 ** --allckouts Check for empty directories within any checkouts
645 ** that may be nested within the current one. This
646 ** option should be used with great care because the
@@ -656,27 +658,31 @@
658 ** argument. Matching files, if any, are removed
659 ** prior to checking for any empty directories;
660 ** therefore, directories that contain only files
661 ** that were removed will be removed as well.
662 ** -f|--force Remove files without prompting.
663 ** -x|--verily Remove everything that is not a managed file or
664 ** the repository itself. Implies -f --emptydirs
665 ** --dotfiles. Disregard keep-glob and ignore-glob.
666 ** --clean <CSG> Never prompt for files matching this
667 ** comma separated list of glob patterns.
668 ** --ignore <CSG> Ignore files matching patterns from the
669 ** comma separated list of glob patterns.
670 ** --keep <CSG> Keep files matching this comma separated
671 ** list of glob patterns.
672 ** -n|--dry-run Delete nothing, but display what would have been
673 ** deleted.
674 ** --temp Remove only Fossil-generated temporary files.
675 ** -v|--verbose Show all files as they are removed.
676 **
677 ** See also: addremove, extras, status
678 */
679 void clean_cmd(void){
680 int allFileFlag, allDirFlag, dryRunFlag, verboseFlag;
681 int emptyDirsFlag, dirsOnlyFlag;
682 unsigned scanFlags = 0;
683 int verilyFlag = 0;
684 const char *zIgnoreFlag, *zKeepFlag, *zCleanFlag;
685 Glob *pIgnore, *pKeep, *pClean;
686 int nRoot;
687
688 dryRunFlag = find_option("dry-run","n",0)!=0;
@@ -695,22 +701,23 @@
701 zIgnoreFlag = find_option("ignore",0,1);
702 verboseFlag = find_option("verbose","v",0)!=0;
703 zKeepFlag = find_option("keep",0,1);
704 zCleanFlag = find_option("clean",0,1);
705 db_must_be_within_tree();
706 if( find_option("verily","x",0)!=0 ){
707 verilyFlag = allFileFlag = allDirFlag = 1;
708 emptyDirsFlag = 1;
709 scanFlags |= SCAN_ALL;
710 zCleanFlag = 0;
711 }
712 if( zIgnoreFlag==0 && !verilyFlag ){
713 zIgnoreFlag = db_get("ignore-glob", 0);
714 }
715 if( zKeepFlag==0 && !verilyFlag ){
716 zKeepFlag = db_get("keep-glob", 0);
717 }
718 if( zCleanFlag==0 && !verilyFlag ){
719 zCleanFlag = db_get("clean-glob", 0);
720 }
721 if( db_get_boolean("dotfiles", 0) ) scanFlags |= SCAN_ALL;
722 verify_all_options();
723 pIgnore = glob_create(zIgnoreFlag);
@@ -754,11 +761,11 @@
761 blob_reset(&ans);
762 continue;
763 }
764 blob_reset(&ans);
765 }
766 if( dryRunFlag || file_delete(zName)==0 ){
767 if( verboseFlag || dryRunFlag ){
768 fossil_print("Removed unmanaged file: %s\n", zName+nRoot);
769 }
770 }else if( verboseFlag ){
771 fossil_print("Could not remove file: %s\n", zName+nRoot);
@@ -770,11 +777,11 @@
777 Glob *pEmptyDirs = glob_create(db_get("empty-dirs", 0));
778 Stmt q;
779 Blob root;
780 blob_init(&root, g.zLocalRoot, nRoot - 1);
781 vfile_dir_scan(&root, blob_size(&root), scanFlags, pIgnore,
782 pEmptyDirs);
783 blob_reset(&root);
784 db_prepare(&q,
785 "SELECT %Q || x FROM dscan_temp"
786 " WHERE x NOT IN (%s) AND y = 0"
787 " ORDER BY 1 DESC",
@@ -802,11 +809,11 @@
809 blob_reset(&ans);
810 continue;
811 }
812 blob_reset(&ans);
813 }
814 if( dryRunFlag || file_rmdir(zName)==0 ){
815 if( verboseFlag || dryRunFlag ){
816 fossil_print("Removed unmanaged directory: %s\n", zName+nRoot);
817 }
818 }else if( verboseFlag ){
819 fossil_print("Could not remove directory: %s\n", zName+nRoot);
@@ -941,22 +948,24 @@
948 Blob prompt;
949 #if defined(_WIN32) || defined(__CYGWIN__)
950 int bomSize;
951 const unsigned char *bom = get_utf8_bom(&bomSize);
952 blob_init(&prompt, (const char *) bom, bomSize);
953 if( zInit && zInit[0]){
954 blob_append(&prompt, zInit, -1);
955 }
956 #else
957 blob_init(&prompt, zInit, -1);
958 #endif
959 blob_append(&prompt,
960 "\n"
961 "# Enter a commit message for this check-in."
962 " Lines beginning with # are ignored.\n"
963 "#\n", -1
964 );
965 blob_appendf(&prompt, "# user: %s\n",
966 p->zUserOvrd ? p->zUserOvrd : login_name());
967 if( p->zBranch && p->zBranch[0] ){
968 blob_appendf(&prompt, "# tags: %s\n#\n", p->zBranch);
969 }else{
970 char *zTags = info_tags_of_checkin(parent_rid, 1);
971 if( zTags || p->azTag ){
@@ -1041,11 +1050,12 @@
1050 fossil_warning("fossil knows nothing about: %s", g.argv[ii]);
1051 result = 1;
1052 }
1053 blob_reset(&fname);
1054 }
1055 g.aCommitFile = fossil_malloc( (bag_count(&toCommit)+1) *
1056 sizeof(g.aCommitFile[0]) );
1057 for(ii=bag_first(&toCommit); ii>0; ii=bag_next(&toCommit, ii)){
1058 g.aCommitFile[jj++] = ii;
1059 }
1060 g.aCommitFile[jj] = 0;
1061 bag_clear(&toCommit);
@@ -1269,11 +1279,13 @@
1279 free(zParentUuid);
1280 db_prepare(&q, "SELECT merge FROM vmerge WHERE id=0 OR id<-2");
1281 while( db_step(&q)==SQLITE_ROW ){
1282 char *zMergeUuid;
1283 int mid = db_column_int(&q, 0);
1284 if( (!g.markPrivate && content_is_private(mid)) || (mid == vid) ){
1285 continue;
1286 }
1287 zMergeUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", mid);
1288 if( zMergeUuid ){
1289 blob_appendf(pOut, " %s", zMergeUuid);
1290 if( p->verifyDate ) checkin_verify_younger(mid, zMergeUuid, zDate);
1291 free(zMergeUuid);
@@ -1380,11 +1392,11 @@
1392 int fBinary; /* does the blob content appear to be binary? */
1393 int lookFlags; /* output flags from looks_like_utf8/utf16() */
1394 int fHasAnyCr; /* the blob contains one or more CR chars */
1395 int fHasLoneCrOnly; /* all detected line endings are CR only */
1396 int fHasCrLfOnly; /* all detected line endings are CR/LF pairs */
1397 int fHasInvalidUtf8 = 0;/* contains invalid UTF-8 */
1398 char *zMsg; /* Warning message */
1399 Blob fname; /* Relative pathname of the file */
1400 static int allOk = 0; /* Set to true to disable this routine */
1401
1402 if( allOk ) return 0;
@@ -1459,11 +1471,12 @@
1471 zWarning = "Unicode";
1472 zDisable = "\"encoding-glob\" setting";
1473 }
1474 file_relative_name(zFilename, &fname, 0);
1475 zMsg = mprintf(
1476 "%s contains %s. Use --no-warnings or the %s to"
1477 " disable this warning.\n"
1478 "Commit anyhow (a=all/%sy/N)? ",
1479 blob_str(&fname), zWarning, zDisable, zConvert);
1480 prompt_user(zMsg, &ans);
1481 fossil_free(zMsg);
1482 cReply = blob_str(&ans)[0];
@@ -1476,11 +1489,11 @@
1489 fossil_free(zOrig);
1490 f = fossil_fopen(zFilename, "wb");
1491 if( f==0 ){
1492 fossil_warning("cannot open %s for writing", zFilename);
1493 }else{
1494 if( fUnicode ){
1495 int bomSize;
1496 const unsigned char *bom = get_utf8_bom(&bomSize);
1497 fwrite(bom, 1, bomSize, f);
1498 blob_to_utf8_no_bom(p, 0);
1499 }else if( fHasInvalidUtf8 ){
@@ -1659,11 +1672,12 @@
1672 sCiInfo.closeFlag = find_option("close",0,0)!=0;
1673 sCiInfo.integrateFlag = find_option("integrate",0,0)!=0;
1674 sCiInfo.zMimetype = find_option("mimetype",0,1);
1675 while( (zTag = find_option("tag",0,1))!=0 ){
1676 if( zTag[0]==0 ) continue;
1677 sCiInfo.azTag = fossil_realloc((void*)sCiInfo.azTag,
1678 sizeof(char*)*(nTag+2));
1679 sCiInfo.azTag[nTag++] = zTag;
1680 sCiInfo.azTag[nTag] = 0;
1681 }
1682 zComFile = find_option("message-file", "M", 1);
1683 if( find_option("private",0,0) ){
@@ -1840,11 +1854,10 @@
1854 " AND value=%Q", TAG_BRANCH, vid, sCiInfo.zBranch))
1855 ){
1856 fossil_fatal("cannot commit against a closed leaf");
1857 }
1858
 
1859 if( zComment ){
1860 blob_zero(&comment);
1861 blob_append(&comment, zComment, -1);
1862 }else if( zComFile ){
1863 blob_zero(&comment);
@@ -1874,16 +1887,24 @@
1887 db_multi_exec("REPLACE INTO vvar VALUES('ci-comment',%B)", &comment);
1888 db_end_transaction(0);
1889 db_begin_transaction();
1890 }
1891
1892 /*
1893 ** Step 1: Compute an aggregate MD5 checksum over the disk image
1894 ** of every file in vid. The file names are part of the checksum.
1895 ** The resulting checksum is the same as is expected on the R-card
1896 ** of a manifest.
1897 */
1898 if( useCksum ) vfile_aggregate_checksum_disk(vid, &cksum1);
1899
1900 /* Step 2: Insert records for all modified files into the blob
1901 ** table. If there were arguments passed to this command, only
1902 ** the identified files are inserted (if they have been modified).
1903 */
1904 db_prepare(&q,
1905 "SELECT id, %Q || pathname, mrid, %s, %s, %s FROM vfile "
1906 "WHERE chnged==1 AND NOT deleted AND is_selected(id)",
1907 g.zLocalRoot,
1908 glob_expr("pathname", db_get("crnl-glob","")),
1909 glob_expr("pathname", db_get("binary-glob","")),
1910 glob_expr("pathname", db_get("encoding-glob",""))
@@ -1890,19 +1911,18 @@
1911 );
1912 while( db_step(&q)==SQLITE_ROW ){
1913 int id, rid;
1914 const char *zFullname;
1915 Blob content;
1916 int crnlOk, binOk, encodingOk;
1917
1918 id = db_column_int(&q, 0);
1919 zFullname = db_column_text(&q, 1);
1920 rid = db_column_int(&q, 2);
1921 crnlOk = db_column_int(&q, 3);
1922 binOk = db_column_int(&q, 4);
1923 encodingOk = db_column_int(&q, 5);
 
1924
1925 blob_zero(&content);
1926 if( file_wd_islink(zFullname) ){
1927 /* Instead of file content, put link destination path */
1928 blob_read_link(&content, zFullname);
@@ -1912,11 +1932,11 @@
1932 /* Do not emit any warnings when they are disabled. */
1933 if( !noWarningFlag ){
1934 abortCommit |= commit_warning(&content, crnlOk, binOk,
1935 encodingOk, zFullname);
1936 }
1937 if( contains_merge_marker(&content) ){
1938 Blob fname; /* Relative pathname of the file */
1939
1940 nConflict++;
1941 file_relative_name(zFullname, &fname, 0);
1942 fossil_print("possible unresolved merge conflict in %s\n",
1943
+1 -1
--- src/clone.c
+++ src/clone.c
@@ -206,11 +206,11 @@
206206
rebuild_db(0, 1, 0);
207207
fossil_print("Extra delta compression... "); fflush(stdout);
208208
extra_deltification();
209209
db_end_transaction(0);
210210
fossil_print("\nVacuuming the database... "); fflush(stdout);
211
- if( db_int(0, "PRAGMA page_count")>1000
211
+ if( db_int(0, "PRAGMA page_count")>1000
212212
&& db_int(0, "PRAGMA page_size")<8192 ){
213213
db_multi_exec("PRAGMA page_size=8192;");
214214
}
215215
db_multi_exec("VACUUM");
216216
fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
217217
--- src/clone.c
+++ src/clone.c
@@ -206,11 +206,11 @@
206 rebuild_db(0, 1, 0);
207 fossil_print("Extra delta compression... "); fflush(stdout);
208 extra_deltification();
209 db_end_transaction(0);
210 fossil_print("\nVacuuming the database... "); fflush(stdout);
211 if( db_int(0, "PRAGMA page_count")>1000
212 && db_int(0, "PRAGMA page_size")<8192 ){
213 db_multi_exec("PRAGMA page_size=8192;");
214 }
215 db_multi_exec("VACUUM");
216 fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
217
--- src/clone.c
+++ src/clone.c
@@ -206,11 +206,11 @@
206 rebuild_db(0, 1, 0);
207 fossil_print("Extra delta compression... "); fflush(stdout);
208 extra_deltification();
209 db_end_transaction(0);
210 fossil_print("\nVacuuming the database... "); fflush(stdout);
211 if( db_int(0, "PRAGMA page_count")>1000
212 && db_int(0, "PRAGMA page_size")<8192 ){
213 db_multi_exec("PRAGMA page_size=8192;");
214 }
215 db_multi_exec("VACUUM");
216 fossil_print("\nproject-id: %s\n", db_get("project-code", 0));
217
+1 -3
--- src/comformat.c
+++ src/comformat.c
@@ -23,13 +23,11 @@
2323
#include <assert.h>
2424
#ifdef _WIN32
2525
# include <windows.h>
2626
#else
2727
# include <termios.h>
28
-# if defined(TIOCGWINSZ)
29
-# include <sys/ioctl.h>
30
-# endif
28
+# include <sys/ioctl.h>
3129
#endif
3230
3331
#if INTERFACE
3432
#define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
3533
#define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */
3634
--- src/comformat.c
+++ src/comformat.c
@@ -23,13 +23,11 @@
23 #include <assert.h>
24 #ifdef _WIN32
25 # include <windows.h>
26 #else
27 # include <termios.h>
28 # if defined(TIOCGWINSZ)
29 # include <sys/ioctl.h>
30 # endif
31 #endif
32
33 #if INTERFACE
34 #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
35 #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */
36
--- src/comformat.c
+++ src/comformat.c
@@ -23,13 +23,11 @@
23 #include <assert.h>
24 #ifdef _WIN32
25 # include <windows.h>
26 #else
27 # include <termios.h>
28 # include <sys/ioctl.h>
 
 
29 #endif
30
31 #if INTERFACE
32 #define COMMENT_PRINT_NONE ((u32)0x00000000) /* No flags. */
33 #define COMMENT_PRINT_LEGACY ((u32)0x00000001) /* Use legacy algorithm. */
34
+5 -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
@@ -126,10 +126,14 @@
126126
{ "crnl-glob", CONFIGSET_PROJ },
127127
{ "encoding-glob", CONFIGSET_PROJ },
128128
{ "empty-dirs", CONFIGSET_PROJ },
129129
{ "allow-symlinks", CONFIGSET_PROJ },
130130
{ "dotfiles", CONFIGSET_PROJ },
131
+
132
+#ifdef FOSSIL_ENABLE_LEGACY_MV_RM
133
+ { "mv-rm-files", CONFIGSET_PROJ },
134
+#endif
131135
132136
{ "ticket-table", CONFIGSET_TKT },
133137
{ "ticket-common", CONFIGSET_TKT },
134138
{ "ticket-change", CONFIGSET_TKT },
135139
{ "ticket-newpage", CONFIGSET_TKT },
136140
--- 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
@@ -126,10 +126,14 @@
126 { "crnl-glob", CONFIGSET_PROJ },
127 { "encoding-glob", CONFIGSET_PROJ },
128 { "empty-dirs", CONFIGSET_PROJ },
129 { "allow-symlinks", CONFIGSET_PROJ },
130 { "dotfiles", CONFIGSET_PROJ },
 
 
 
 
131
132 { "ticket-table", CONFIGSET_TKT },
133 { "ticket-common", CONFIGSET_TKT },
134 { "ticket-change", CONFIGSET_TKT },
135 { "ticket-newpage", CONFIGSET_TKT },
136
--- 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
@@ -126,10 +126,14 @@
126 { "crnl-glob", CONFIGSET_PROJ },
127 { "encoding-glob", CONFIGSET_PROJ },
128 { "empty-dirs", CONFIGSET_PROJ },
129 { "allow-symlinks", CONFIGSET_PROJ },
130 { "dotfiles", CONFIGSET_PROJ },
131
132 #ifdef FOSSIL_ENABLE_LEGACY_MV_RM
133 { "mv-rm-files", CONFIGSET_PROJ },
134 #endif
135
136 { "ticket-table", CONFIGSET_TKT },
137 { "ticket-common", CONFIGSET_TKT },
138 { "ticket-change", CONFIGSET_TKT },
139 { "ticket-newpage", CONFIGSET_TKT },
140
+66 -24
--- src/db.c
+++ src/db.c
@@ -1646,11 +1646,11 @@
16461646
verify_all_options();
16471647
16481648
if( g.argc!=3 ){
16491649
usage("REPOSITORY-NAME");
16501650
}
1651
-
1651
+
16521652
if( -1 != file_size(g.argv[2]) ){
16531653
fossil_fatal("file already exists: %s", g.argv[2]);
16541654
}
16551655
16561656
db_create_repository(g.argv[2]);
@@ -1887,60 +1887,79 @@
18871887
**
18881888
** Return the text of the string if it is found. Return NULL if not
18891889
** found.
18901890
**
18911891
** If the zNonVersionedSetting parameter is not NULL then it holds the
1892
-** non-versioned value for this setting. If both a versioned and ad
1892
+** non-versioned value for this setting. If both a versioned and a
18931893
** non-versioned value exist and are not equal, then a warning message
18941894
** might be generated.
18951895
*/
18961896
char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
18971897
char *zVersionedSetting = 0;
18981898
int noWarn = 0;
1899
+ int found = 0;
18991900
struct _cacheEntry {
19001901
struct _cacheEntry *next;
19011902
const char *zName, *zValue;
19021903
} *cacheEntry = 0;
19031904
static struct _cacheEntry *cache = 0;
19041905
1905
- if( !g.localOpen) return zNonVersionedSetting;
1906
+ if( !g.localOpen && g.zOpenRevision==0 ) return zNonVersionedSetting;
19061907
/* Look up name in cache */
19071908
cacheEntry = cache;
19081909
while( cacheEntry!=0 ){
19091910
if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
19101911
zVersionedSetting = fossil_strdup(cacheEntry->zValue);
19111912
break;
19121913
}
19131914
cacheEntry = cacheEntry->next;
19141915
}
1915
- /* Attempt to read value from file in checkout if there wasn't a cache hit
1916
- ** and a checkout is open. */
1916
+ /* Attempt to read value from file in checkout if there wasn't a cache hit. */
19171917
if( cacheEntry==0 ){
19181918
Blob versionedPathname;
1919
- char *zVersionedPathname;
1919
+ Blob setting;
19201920
blob_zero(&versionedPathname);
1921
+ blob_zero(&setting);
19211922
blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
19221923
g.zLocalRoot, zName);
1923
- zVersionedPathname = blob_str(&versionedPathname);
1924
- if( file_size(zVersionedPathname)>=0 ){
1924
+ if( !g.localOpen ){
1925
+ /* Repository is in the process of being opened, but files have not been
1926
+ * written to disk. Load from the database. */
1927
+ Blob noWarnFile;
1928
+ if( historical_version_of_file(g.zOpenRevision,
1929
+ blob_str(&versionedPathname),
1930
+ &setting, 0, 0, 0, 2)!=2 ){
1931
+ found = 1;
1932
+ }
1933
+ /* See if there's a no-warn flag */
1934
+ blob_append(&versionedPathname, ".no-warn", -1);
1935
+ blob_zero(&noWarnFile);
1936
+ if( historical_version_of_file(g.zOpenRevision,
1937
+ blob_str(&versionedPathname),
1938
+ &noWarnFile, 0, 0, 0, 2)!=2 ){
1939
+ noWarn = 1;
1940
+ }
1941
+ blob_reset(&noWarnFile);
1942
+ }else if( file_size(blob_str(&versionedPathname))>=0 ){
19251943
/* File exists, and contains the value for this setting. Load from
19261944
** the file. */
1927
- Blob setting;
1928
- blob_zero(&setting);
1929
- if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1930
- blob_trim(&setting); /* Avoid non-obvious problems with line endings
1931
- ** on boolean properties */
1932
- zVersionedSetting = strdup(blob_str(&setting));
1933
- }
1934
- blob_reset(&setting);
1945
+ if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){
1946
+ found = 1;
1947
+ }
19351948
/* See if there's a no-warn flag */
19361949
blob_append(&versionedPathname, ".no-warn", -1);
19371950
if( file_size(blob_str(&versionedPathname))>=0 ){
19381951
noWarn = 1;
19391952
}
19401953
}
19411954
blob_reset(&versionedPathname);
1955
+ if( found ){
1956
+ blob_trim(&setting); /* Avoid non-obvious problems with line endings
1957
+ ** on boolean properties */
1958
+ zVersionedSetting = fossil_strdup(blob_str(&setting));
1959
+ }
1960
+ blob_reset(&setting);
19421961
/* Store result in cache, which can be the value or 0 if not found */
19431962
cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
19441963
cacheEntry->next = cache;
19451964
cacheEntry->zName = zName;
19461965
cacheEntry->zValue = fossil_strdup(zVersionedSetting);
@@ -2218,10 +2237,26 @@
22182237
}
22192238
if( !allowNested && db_open_local(0) ){
22202239
fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
22212240
}
22222241
db_open_repository(g.argv[2]);
2242
+
2243
+ /* Figure out which revision to open. */
2244
+ if( !emptyFlag ){
2245
+ if( g.argc==4 ){
2246
+ g.zOpenRevision = g.argv[3];
2247
+ }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2248
+ g.zOpenRevision = db_get("main-branch", "trunk");
2249
+ }
2250
+ }
2251
+
2252
+ if( g.zOpenRevision ){
2253
+ /* Since the repository is open and we know the revision now,
2254
+ ** refresh the allow-symlinks flag. */
2255
+ g.allowSymlinks = db_get_boolean("allow-symlinks", 0);
2256
+ }
2257
+
22232258
#if defined(_WIN32) || defined(__CYGWIN__)
22242259
# define LOCALDB_NAME "./_FOSSIL_"
22252260
#else
22262261
# define LOCALDB_NAME "./.fslckout"
22272262
#endif
@@ -2239,16 +2274,14 @@
22392274
oldArgc = g.argc;
22402275
azNewArgv[0] = g.argv[0];
22412276
g.argv = azNewArgv;
22422277
if( !emptyFlag ){
22432278
g.argc = 3;
2244
- if( oldArgc==4 ){
2245
- azNewArgv[g.argc-1] = oldArgv[3];
2246
- }else if( !db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2247
- azNewArgv[g.argc-1] = "--latest";
2279
+ if( g.zOpenRevision ){
2280
+ azNewArgv[g.argc-1] = g.zOpenRevision;
22482281
}else{
2249
- azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2282
+ azNewArgv[g.argc-1] = "--latest";
22502283
}
22512284
if( keepFlag ){
22522285
azNewArgv[g.argc++] = "--keep";
22532286
}
22542287
if( forceMissingFlag ){
@@ -2287,11 +2320,11 @@
22872320
}
22882321
if( pSetting->versionable && g.localOpen ){
22892322
/* Check to see if this is overridden by a versionable settings file */
22902323
Blob versionedPathname;
22912324
blob_zero(&versionedPathname);
2292
- blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
2325
+ blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
22932326
g.zLocalRoot, pSetting->name);
22942327
if( file_size(blob_str(&versionedPathname))>=0 ){
22952328
fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
22962329
pSetting->name);
22972330
}
@@ -2345,11 +2378,11 @@
23452378
{ "crnl-glob", 0, 40, 1, 0, "" },
23462379
{ "default-perms", 0, 16, 0, 0, "u" },
23472380
{ "diff-binary", 0, 0, 0, 0, "on" },
23482381
{ "diff-command", 0, 40, 0, 0, "" },
23492382
{ "dont-push", 0, 0, 0, 0, "off" },
2350
- { "dotfiles", 0, 0, 0, 0, "off" },
2383
+ { "dotfiles", 0, 0, 1, 0, "off" },
23512384
{ "editor", 0, 32, 0, 0, "" },
23522385
{ "empty-dirs", 0, 40, 1, 0, "" },
23532386
{ "encoding-glob", 0, 40, 1, 0, "" },
23542387
{ "gdiff-command", 0, 40, 0, 0, "gdiff" },
23552388
{ "gmerge-command", 0, 40, 0, 0, "" },
@@ -2362,10 +2395,13 @@
23622395
{ "main-branch", 0, 40, 0, 0, "trunk" },
23632396
{ "manifest", 0, 0, 1, 0, "off" },
23642397
{ "max-loadavg", 0, 25, 0, 0, "0.0" },
23652398
{ "max-upload", 0, 25, 0, 0, "250000" },
23662399
{ "mtime-changes", 0, 0, 0, 0, "on" },
2400
+#if FOSSIL_ENABLE_LEGACY_MV_RM
2401
+ { "mv-rm-files", 0, 0, 0, 0, "off" },
2402
+#endif
23672403
{ "pgp-command", 0, 40, 0, 0, "gpg --clearsign -o " },
23682404
{ "proxy", 0, 32, 0, 0, "off" },
23692405
{ "relative-paths", 0, 0, 0, 0, "on" },
23702406
{ "repo-cksum", 0, 0, 0, 0, "on" },
23712407
{ "self-register", 0, 0, 0, 0, "off" },
@@ -2383,11 +2419,10 @@
23832419
{ "th1-hooks", 0, 0, 0, 0, "off" },
23842420
#endif
23852421
{ "th1-setup", 0, 40, 1, 1, "" },
23862422
{ "th1-uri-regexp", 0, 40, 1, 0, "" },
23872423
{ "web-browser", 0, 32, 0, 0, "" },
2388
- { "white-foreground", 0, 0, 0, 0, "off" },
23892424
{ 0,0,0,0,0,0 }
23902425
};
23912426
23922427
/*
23932428
** Look up a control setting by its name. Return a pointer to the Setting
@@ -2508,10 +2543,11 @@
25082543
**
25092544
** dont-push Prevent this repository from pushing from client to
25102545
** server. Useful when setting up a private branch.
25112546
**
25122547
** dotfiles Include --dotfiles option for all compatible commands.
2548
+** (versionable)
25132549
**
25142550
** editor Text editor command used for check-in comments.
25152551
**
25162552
** empty-dirs A comma or newline-separated list of pathnames. On
25172553
** (versionable) update and checkout commands, if no file or directory
@@ -2572,10 +2608,16 @@
25722608
** max-upload A limit on the size of uplink HTTP requests. The
25732609
** default is 250000 bytes.
25742610
**
25752611
** mtime-changes Use file modification times (mtimes) to detect when
25762612
** files have been modified. (Default "on".)
2613
+**
2614
+** mv-rm-files If enabled (and Fossil was compiled with legacy "mv/rm"
2615
+** support), the "mv" and "rename" commands will also move
2616
+** the associated files within the checkout -AND- the "rm"
2617
+** and "delete" commands will also remove the associated
2618
+** files from within the checkout. Default: off.
25772619
**
25782620
** pgp-command Command used to clear-sign manifests at check-in.
25792621
** The default is "gpg --clearsign -o ".
25802622
**
25812623
** proxy URL of the HTTP proxy. If undefined or "off" then
25822624
--- src/db.c
+++ src/db.c
@@ -1646,11 +1646,11 @@
1646 verify_all_options();
1647
1648 if( g.argc!=3 ){
1649 usage("REPOSITORY-NAME");
1650 }
1651
1652 if( -1 != file_size(g.argv[2]) ){
1653 fossil_fatal("file already exists: %s", g.argv[2]);
1654 }
1655
1656 db_create_repository(g.argv[2]);
@@ -1887,60 +1887,79 @@
1887 **
1888 ** Return the text of the string if it is found. Return NULL if not
1889 ** found.
1890 **
1891 ** If the zNonVersionedSetting parameter is not NULL then it holds the
1892 ** non-versioned value for this setting. If both a versioned and ad
1893 ** non-versioned value exist and are not equal, then a warning message
1894 ** might be generated.
1895 */
1896 char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
1897 char *zVersionedSetting = 0;
1898 int noWarn = 0;
 
1899 struct _cacheEntry {
1900 struct _cacheEntry *next;
1901 const char *zName, *zValue;
1902 } *cacheEntry = 0;
1903 static struct _cacheEntry *cache = 0;
1904
1905 if( !g.localOpen) return zNonVersionedSetting;
1906 /* Look up name in cache */
1907 cacheEntry = cache;
1908 while( cacheEntry!=0 ){
1909 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1910 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1911 break;
1912 }
1913 cacheEntry = cacheEntry->next;
1914 }
1915 /* Attempt to read value from file in checkout if there wasn't a cache hit
1916 ** and a checkout is open. */
1917 if( cacheEntry==0 ){
1918 Blob versionedPathname;
1919 char *zVersionedPathname;
1920 blob_zero(&versionedPathname);
 
1921 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
1922 g.zLocalRoot, zName);
1923 zVersionedPathname = blob_str(&versionedPathname);
1924 if( file_size(zVersionedPathname)>=0 ){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1925 /* File exists, and contains the value for this setting. Load from
1926 ** the file. */
1927 Blob setting;
1928 blob_zero(&setting);
1929 if( blob_read_from_file(&setting, zVersionedPathname) >= 0 ){
1930 blob_trim(&setting); /* Avoid non-obvious problems with line endings
1931 ** on boolean properties */
1932 zVersionedSetting = strdup(blob_str(&setting));
1933 }
1934 blob_reset(&setting);
1935 /* See if there's a no-warn flag */
1936 blob_append(&versionedPathname, ".no-warn", -1);
1937 if( file_size(blob_str(&versionedPathname))>=0 ){
1938 noWarn = 1;
1939 }
1940 }
1941 blob_reset(&versionedPathname);
 
 
 
 
 
 
1942 /* Store result in cache, which can be the value or 0 if not found */
1943 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1944 cacheEntry->next = cache;
1945 cacheEntry->zName = zName;
1946 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
@@ -2218,10 +2237,26 @@
2218 }
2219 if( !allowNested && db_open_local(0) ){
2220 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
2221 }
2222 db_open_repository(g.argv[2]);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2223 #if defined(_WIN32) || defined(__CYGWIN__)
2224 # define LOCALDB_NAME "./_FOSSIL_"
2225 #else
2226 # define LOCALDB_NAME "./.fslckout"
2227 #endif
@@ -2239,16 +2274,14 @@
2239 oldArgc = g.argc;
2240 azNewArgv[0] = g.argv[0];
2241 g.argv = azNewArgv;
2242 if( !emptyFlag ){
2243 g.argc = 3;
2244 if( oldArgc==4 ){
2245 azNewArgv[g.argc-1] = oldArgv[3];
2246 }else if( !db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2247 azNewArgv[g.argc-1] = "--latest";
2248 }else{
2249 azNewArgv[g.argc-1] = db_get("main-branch", "trunk");
2250 }
2251 if( keepFlag ){
2252 azNewArgv[g.argc++] = "--keep";
2253 }
2254 if( forceMissingFlag ){
@@ -2287,11 +2320,11 @@
2287 }
2288 if( pSetting->versionable && g.localOpen ){
2289 /* Check to see if this is overridden by a versionable settings file */
2290 Blob versionedPathname;
2291 blob_zero(&versionedPathname);
2292 blob_appendf(&versionedPathname, "%s/.fossil-settings/%s",
2293 g.zLocalRoot, pSetting->name);
2294 if( file_size(blob_str(&versionedPathname))>=0 ){
2295 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
2296 pSetting->name);
2297 }
@@ -2345,11 +2378,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, "" },
@@ -2362,10 +2395,13 @@
2362 { "main-branch", 0, 40, 0, 0, "trunk" },
2363 { "manifest", 0, 0, 1, 0, "off" },
2364 { "max-loadavg", 0, 25, 0, 0, "0.0" },
2365 { "max-upload", 0, 25, 0, 0, "250000" },
2366 { "mtime-changes", 0, 0, 0, 0, "on" },
 
 
 
2367 { "pgp-command", 0, 40, 0, 0, "gpg --clearsign -o " },
2368 { "proxy", 0, 32, 0, 0, "off" },
2369 { "relative-paths", 0, 0, 0, 0, "on" },
2370 { "repo-cksum", 0, 0, 0, 0, "on" },
2371 { "self-register", 0, 0, 0, 0, "off" },
@@ -2383,11 +2419,10 @@
2383 { "th1-hooks", 0, 0, 0, 0, "off" },
2384 #endif
2385 { "th1-setup", 0, 40, 1, 1, "" },
2386 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2387 { "web-browser", 0, 32, 0, 0, "" },
2388 { "white-foreground", 0, 0, 0, 0, "off" },
2389 { 0,0,0,0,0,0 }
2390 };
2391
2392 /*
2393 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2508,10 +2543,11 @@
2508 **
2509 ** dont-push Prevent this repository from pushing from client to
2510 ** server. Useful when setting up a private branch.
2511 **
2512 ** dotfiles Include --dotfiles option for all compatible commands.
 
2513 **
2514 ** editor Text editor command used for check-in comments.
2515 **
2516 ** empty-dirs A comma or newline-separated list of pathnames. On
2517 ** (versionable) update and checkout commands, if no file or directory
@@ -2572,10 +2608,16 @@
2572 ** max-upload A limit on the size of uplink HTTP requests. The
2573 ** default is 250000 bytes.
2574 **
2575 ** mtime-changes Use file modification times (mtimes) to detect when
2576 ** files have been modified. (Default "on".)
 
 
 
 
 
 
2577 **
2578 ** pgp-command Command used to clear-sign manifests at check-in.
2579 ** The default is "gpg --clearsign -o ".
2580 **
2581 ** proxy URL of the HTTP proxy. If undefined or "off" then
2582
--- src/db.c
+++ src/db.c
@@ -1646,11 +1646,11 @@
1646 verify_all_options();
1647
1648 if( g.argc!=3 ){
1649 usage("REPOSITORY-NAME");
1650 }
1651
1652 if( -1 != file_size(g.argv[2]) ){
1653 fossil_fatal("file already exists: %s", g.argv[2]);
1654 }
1655
1656 db_create_repository(g.argv[2]);
@@ -1887,60 +1887,79 @@
1887 **
1888 ** Return the text of the string if it is found. Return NULL if not
1889 ** found.
1890 **
1891 ** If the zNonVersionedSetting parameter is not NULL then it holds the
1892 ** non-versioned value for this setting. If both a versioned and a
1893 ** non-versioned value exist and are not equal, then a warning message
1894 ** might be generated.
1895 */
1896 char *db_get_versioned(const char *zName, char *zNonVersionedSetting){
1897 char *zVersionedSetting = 0;
1898 int noWarn = 0;
1899 int found = 0;
1900 struct _cacheEntry {
1901 struct _cacheEntry *next;
1902 const char *zName, *zValue;
1903 } *cacheEntry = 0;
1904 static struct _cacheEntry *cache = 0;
1905
1906 if( !g.localOpen && g.zOpenRevision==0 ) return zNonVersionedSetting;
1907 /* Look up name in cache */
1908 cacheEntry = cache;
1909 while( cacheEntry!=0 ){
1910 if( fossil_strcmp(cacheEntry->zName, zName)==0 ){
1911 zVersionedSetting = fossil_strdup(cacheEntry->zValue);
1912 break;
1913 }
1914 cacheEntry = cacheEntry->next;
1915 }
1916 /* Attempt to read value from file in checkout if there wasn't a cache hit. */
 
1917 if( cacheEntry==0 ){
1918 Blob versionedPathname;
1919 Blob setting;
1920 blob_zero(&versionedPathname);
1921 blob_zero(&setting);
1922 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
1923 g.zLocalRoot, zName);
1924 if( !g.localOpen ){
1925 /* Repository is in the process of being opened, but files have not been
1926 * written to disk. Load from the database. */
1927 Blob noWarnFile;
1928 if( historical_version_of_file(g.zOpenRevision,
1929 blob_str(&versionedPathname),
1930 &setting, 0, 0, 0, 2)!=2 ){
1931 found = 1;
1932 }
1933 /* See if there's a no-warn flag */
1934 blob_append(&versionedPathname, ".no-warn", -1);
1935 blob_zero(&noWarnFile);
1936 if( historical_version_of_file(g.zOpenRevision,
1937 blob_str(&versionedPathname),
1938 &noWarnFile, 0, 0, 0, 2)!=2 ){
1939 noWarn = 1;
1940 }
1941 blob_reset(&noWarnFile);
1942 }else if( file_size(blob_str(&versionedPathname))>=0 ){
1943 /* File exists, and contains the value for this setting. Load from
1944 ** the file. */
1945 if( blob_read_from_file(&setting, blob_str(&versionedPathname))>=0 ){
1946 found = 1;
1947 }
 
 
 
 
 
1948 /* See if there's a no-warn flag */
1949 blob_append(&versionedPathname, ".no-warn", -1);
1950 if( file_size(blob_str(&versionedPathname))>=0 ){
1951 noWarn = 1;
1952 }
1953 }
1954 blob_reset(&versionedPathname);
1955 if( found ){
1956 blob_trim(&setting); /* Avoid non-obvious problems with line endings
1957 ** on boolean properties */
1958 zVersionedSetting = fossil_strdup(blob_str(&setting));
1959 }
1960 blob_reset(&setting);
1961 /* Store result in cache, which can be the value or 0 if not found */
1962 cacheEntry = (struct _cacheEntry*)fossil_malloc(sizeof(struct _cacheEntry));
1963 cacheEntry->next = cache;
1964 cacheEntry->zName = zName;
1965 cacheEntry->zValue = fossil_strdup(zVersionedSetting);
@@ -2218,10 +2237,26 @@
2237 }
2238 if( !allowNested && db_open_local(0) ){
2239 fossil_fatal("already within an open tree rooted at %s", g.zLocalRoot);
2240 }
2241 db_open_repository(g.argv[2]);
2242
2243 /* Figure out which revision to open. */
2244 if( !emptyFlag ){
2245 if( g.argc==4 ){
2246 g.zOpenRevision = g.argv[3];
2247 }else if( db_exists("SELECT 1 FROM event WHERE type='ci'") ){
2248 g.zOpenRevision = db_get("main-branch", "trunk");
2249 }
2250 }
2251
2252 if( g.zOpenRevision ){
2253 /* Since the repository is open and we know the revision now,
2254 ** refresh the allow-symlinks flag. */
2255 g.allowSymlinks = db_get_boolean("allow-symlinks", 0);
2256 }
2257
2258 #if defined(_WIN32) || defined(__CYGWIN__)
2259 # define LOCALDB_NAME "./_FOSSIL_"
2260 #else
2261 # define LOCALDB_NAME "./.fslckout"
2262 #endif
@@ -2239,16 +2274,14 @@
2274 oldArgc = g.argc;
2275 azNewArgv[0] = g.argv[0];
2276 g.argv = azNewArgv;
2277 if( !emptyFlag ){
2278 g.argc = 3;
2279 if( g.zOpenRevision ){
2280 azNewArgv[g.argc-1] = g.zOpenRevision;
 
 
2281 }else{
2282 azNewArgv[g.argc-1] = "--latest";
2283 }
2284 if( keepFlag ){
2285 azNewArgv[g.argc++] = "--keep";
2286 }
2287 if( forceMissingFlag ){
@@ -2287,11 +2320,11 @@
2320 }
2321 if( pSetting->versionable && g.localOpen ){
2322 /* Check to see if this is overridden by a versionable settings file */
2323 Blob versionedPathname;
2324 blob_zero(&versionedPathname);
2325 blob_appendf(&versionedPathname, "%s.fossil-settings/%s",
2326 g.zLocalRoot, pSetting->name);
2327 if( file_size(blob_str(&versionedPathname))>=0 ){
2328 fossil_print(" (overridden by contents of file .fossil-settings/%s)\n",
2329 pSetting->name);
2330 }
@@ -2345,11 +2378,11 @@
2378 { "crnl-glob", 0, 40, 1, 0, "" },
2379 { "default-perms", 0, 16, 0, 0, "u" },
2380 { "diff-binary", 0, 0, 0, 0, "on" },
2381 { "diff-command", 0, 40, 0, 0, "" },
2382 { "dont-push", 0, 0, 0, 0, "off" },
2383 { "dotfiles", 0, 0, 1, 0, "off" },
2384 { "editor", 0, 32, 0, 0, "" },
2385 { "empty-dirs", 0, 40, 1, 0, "" },
2386 { "encoding-glob", 0, 40, 1, 0, "" },
2387 { "gdiff-command", 0, 40, 0, 0, "gdiff" },
2388 { "gmerge-command", 0, 40, 0, 0, "" },
@@ -2362,10 +2395,13 @@
2395 { "main-branch", 0, 40, 0, 0, "trunk" },
2396 { "manifest", 0, 0, 1, 0, "off" },
2397 { "max-loadavg", 0, 25, 0, 0, "0.0" },
2398 { "max-upload", 0, 25, 0, 0, "250000" },
2399 { "mtime-changes", 0, 0, 0, 0, "on" },
2400 #if FOSSIL_ENABLE_LEGACY_MV_RM
2401 { "mv-rm-files", 0, 0, 0, 0, "off" },
2402 #endif
2403 { "pgp-command", 0, 40, 0, 0, "gpg --clearsign -o " },
2404 { "proxy", 0, 32, 0, 0, "off" },
2405 { "relative-paths", 0, 0, 0, 0, "on" },
2406 { "repo-cksum", 0, 0, 0, 0, "on" },
2407 { "self-register", 0, 0, 0, 0, "off" },
@@ -2383,11 +2419,10 @@
2419 { "th1-hooks", 0, 0, 0, 0, "off" },
2420 #endif
2421 { "th1-setup", 0, 40, 1, 1, "" },
2422 { "th1-uri-regexp", 0, 40, 1, 0, "" },
2423 { "web-browser", 0, 32, 0, 0, "" },
 
2424 { 0,0,0,0,0,0 }
2425 };
2426
2427 /*
2428 ** Look up a control setting by its name. Return a pointer to the Setting
@@ -2508,10 +2543,11 @@
2543 **
2544 ** dont-push Prevent this repository from pushing from client to
2545 ** server. Useful when setting up a private branch.
2546 **
2547 ** dotfiles Include --dotfiles option for all compatible commands.
2548 ** (versionable)
2549 **
2550 ** editor Text editor command used for check-in comments.
2551 **
2552 ** empty-dirs A comma or newline-separated list of pathnames. On
2553 ** (versionable) update and checkout commands, if no file or directory
@@ -2572,10 +2608,16 @@
2608 ** max-upload A limit on the size of uplink HTTP requests. The
2609 ** default is 250000 bytes.
2610 **
2611 ** mtime-changes Use file modification times (mtimes) to detect when
2612 ** files have been modified. (Default "on".)
2613 **
2614 ** mv-rm-files If enabled (and Fossil was compiled with legacy "mv/rm"
2615 ** support), the "mv" and "rename" commands will also move
2616 ** the associated files within the checkout -AND- the "rm"
2617 ** and "delete" commands will also remove the associated
2618 ** files from within the checkout. Default: off.
2619 **
2620 ** pgp-command Command used to clear-sign manifests at check-in.
2621 ** The default is "gpg --clearsign -o ".
2622 **
2623 ** proxy URL of the HTTP proxy. If undefined or "off" then
2624
--- src/descendants.c
+++ src/descendants.c
@@ -352,12 +352,13 @@
352352
** The --recompute flag causes the content of the "leaf" table in the
353353
** repository database to be recomputed.
354354
**
355355
** Options:
356356
** -a|--all show ALL leaves
357
-** -c|--closed show only closed leaves
358357
** --bybranch order output by branch name
358
+** -c|--closed show only closed leaves
359
+** -m|--multiple show only cases with multiple leaves on a single branch
359360
** --recompute recompute the "leaf" table in the repository DB
360361
** -W|--width <num> Width of lines (default is to auto-detect). Must be
361362
** >39 or 0 (= no limit, resulting in a single line per
362363
** entry).
363364
**
@@ -368,32 +369,65 @@
368369
Blob sql;
369370
int showAll = find_option("all", "a", 0)!=0;
370371
int showClosed = find_option("closed", "c", 0)!=0;
371372
int recomputeFlag = find_option("recompute",0,0)!=0;
372373
int byBranch = find_option("bybranch",0,0)!=0;
374
+ int multipleFlag = find_option("multiple","m",0)!=0;
373375
const char *zWidth = find_option("width","W",1);
374376
char *zLastBr = 0;
375377
int n, width;
376378
char zLineNo[10];
377379
380
+ if( multipleFlag ) byBranch = 1;
378381
if( zWidth ){
379382
width = atoi(zWidth);
380383
if( (width!=0) && (width<=39) ){
381384
fossil_fatal("-W|--width value must be >39 or 0");
382385
}
383386
}else{
384387
width = -1;
385388
}
386389
db_find_and_open_repository(0,0);
387
-
390
+
388391
/* We should be done with options.. */
389392
verify_all_options();
390393
391394
if( recomputeFlag ) leaf_rebuild();
392395
blob_zero(&sql);
393396
blob_append(&sql, timeline_query_for_tty(), -1);
394
- blob_append_sql(&sql, " AND blob.rid IN leaf");
397
+ if( !multipleFlag ){
398
+ /* The usual case - show all leaves */
399
+ blob_append_sql(&sql, " AND blob.rid IN leaf");
400
+ }else{
401
+ /* Show only leaves where two are more occur in the same branch */
402
+ db_multi_exec(
403
+ "CREATE TEMP TABLE openLeaf(rid INTEGER PRIMARY KEY);"
404
+ "INSERT INTO openLeaf(rid)"
405
+ " SELECT rid FROM leaf"
406
+ " WHERE NOT EXISTS("
407
+ " SELECT 1 FROM tagxref"
408
+ " WHERE tagid=%d AND tagtype>0 AND rid=leaf.rid);",
409
+ TAG_CLOSED
410
+ );
411
+ db_multi_exec(
412
+ "CREATE TEMP TABLE ambiguousBranch(brname TEXT);"
413
+ "INSERT INTO ambiguousBranch(brname)"
414
+ " SELECT (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
415
+ " FROM openLeaf"
416
+ " GROUP BY 1 HAVING count(*)>1;",
417
+ TAG_BRANCH
418
+ );
419
+ db_multi_exec(
420
+ "CREATE TEMP TABLE ambiguousLeaf(rid INTEGER PRIMARY KEY);\n"
421
+ "INSERT INTO ambiguousLeaf(rid)\n"
422
+ " SELECT rid FROM openLeaf\n"
423
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
424
+ " IN (SELECT brname FROM ambiguousBranch);",
425
+ TAG_BRANCH
426
+ );
427
+ blob_append_sql(&sql, " AND blob.rid IN ambiguousLeaf");
428
+ }
395429
if( showClosed ){
396430
blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
397431
}else if( !showAll ){
398432
blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
399433
}
@@ -415,10 +449,11 @@
415449
416450
if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
417451
fossil_print("*** %s ***\n", zBr);
418452
fossil_free(zLastBr);
419453
zLastBr = fossil_strdup(zBr);
454
+ if( multipleFlag ) n = 0;
420455
}
421456
n++;
422457
sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
423458
fossil_print("%6s ", zLineNo);
424459
z = mprintf("%s [%S] %s", zDate, zId, zCom);
@@ -430,11 +465,21 @@
430465
}
431466
432467
/*
433468
** WEBPAGE: leaves
434469
**
435
-** Find leaves of all branches.
470
+** Show leaf check-ins in a timeline. By default only open leaves
471
+** are listed.
472
+**
473
+** A "leaf" is a check-in with no children in the same branch. A
474
+** "closed leaf" is a leaf that has a "closed" tag. An "open leaf"
475
+** is a leaf without a "closed" tag.
476
+**
477
+** Query parameters:
478
+**
479
+** all Show all leaves
480
+** closed Show only closed leaves
436481
*/
437482
void leaves_page(void){
438483
Blob sql;
439484
Stmt q;
440485
int showAll = P("all")!=0;
441486
--- src/descendants.c
+++ src/descendants.c
@@ -352,12 +352,13 @@
352 ** The --recompute flag causes the content of the "leaf" table in the
353 ** repository database to be recomputed.
354 **
355 ** Options:
356 ** -a|--all show ALL leaves
357 ** -c|--closed show only closed leaves
358 ** --bybranch order output by branch name
 
 
359 ** --recompute recompute the "leaf" table in the repository DB
360 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
361 ** >39 or 0 (= no limit, resulting in a single line per
362 ** entry).
363 **
@@ -368,32 +369,65 @@
368 Blob sql;
369 int showAll = find_option("all", "a", 0)!=0;
370 int showClosed = find_option("closed", "c", 0)!=0;
371 int recomputeFlag = find_option("recompute",0,0)!=0;
372 int byBranch = find_option("bybranch",0,0)!=0;
 
373 const char *zWidth = find_option("width","W",1);
374 char *zLastBr = 0;
375 int n, width;
376 char zLineNo[10];
377
 
378 if( zWidth ){
379 width = atoi(zWidth);
380 if( (width!=0) && (width<=39) ){
381 fossil_fatal("-W|--width value must be >39 or 0");
382 }
383 }else{
384 width = -1;
385 }
386 db_find_and_open_repository(0,0);
387
388 /* We should be done with options.. */
389 verify_all_options();
390
391 if( recomputeFlag ) leaf_rebuild();
392 blob_zero(&sql);
393 blob_append(&sql, timeline_query_for_tty(), -1);
394 blob_append_sql(&sql, " AND blob.rid IN leaf");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
395 if( showClosed ){
396 blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
397 }else if( !showAll ){
398 blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
399 }
@@ -415,10 +449,11 @@
415
416 if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
417 fossil_print("*** %s ***\n", zBr);
418 fossil_free(zLastBr);
419 zLastBr = fossil_strdup(zBr);
 
420 }
421 n++;
422 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
423 fossil_print("%6s ", zLineNo);
424 z = mprintf("%s [%S] %s", zDate, zId, zCom);
@@ -430,11 +465,21 @@
430 }
431
432 /*
433 ** WEBPAGE: leaves
434 **
435 ** Find leaves of all branches.
 
 
 
 
 
 
 
 
 
 
436 */
437 void leaves_page(void){
438 Blob sql;
439 Stmt q;
440 int showAll = P("all")!=0;
441
--- src/descendants.c
+++ src/descendants.c
@@ -352,12 +352,13 @@
352 ** The --recompute flag causes the content of the "leaf" table in the
353 ** repository database to be recomputed.
354 **
355 ** Options:
356 ** -a|--all show ALL leaves
 
357 ** --bybranch order output by branch name
358 ** -c|--closed show only closed leaves
359 ** -m|--multiple show only cases with multiple leaves on a single branch
360 ** --recompute recompute the "leaf" table in the repository DB
361 ** -W|--width <num> Width of lines (default is to auto-detect). Must be
362 ** >39 or 0 (= no limit, resulting in a single line per
363 ** entry).
364 **
@@ -368,32 +369,65 @@
369 Blob sql;
370 int showAll = find_option("all", "a", 0)!=0;
371 int showClosed = find_option("closed", "c", 0)!=0;
372 int recomputeFlag = find_option("recompute",0,0)!=0;
373 int byBranch = find_option("bybranch",0,0)!=0;
374 int multipleFlag = find_option("multiple","m",0)!=0;
375 const char *zWidth = find_option("width","W",1);
376 char *zLastBr = 0;
377 int n, width;
378 char zLineNo[10];
379
380 if( multipleFlag ) byBranch = 1;
381 if( zWidth ){
382 width = atoi(zWidth);
383 if( (width!=0) && (width<=39) ){
384 fossil_fatal("-W|--width value must be >39 or 0");
385 }
386 }else{
387 width = -1;
388 }
389 db_find_and_open_repository(0,0);
390
391 /* We should be done with options.. */
392 verify_all_options();
393
394 if( recomputeFlag ) leaf_rebuild();
395 blob_zero(&sql);
396 blob_append(&sql, timeline_query_for_tty(), -1);
397 if( !multipleFlag ){
398 /* The usual case - show all leaves */
399 blob_append_sql(&sql, " AND blob.rid IN leaf");
400 }else{
401 /* Show only leaves where two are more occur in the same branch */
402 db_multi_exec(
403 "CREATE TEMP TABLE openLeaf(rid INTEGER PRIMARY KEY);"
404 "INSERT INTO openLeaf(rid)"
405 " SELECT rid FROM leaf"
406 " WHERE NOT EXISTS("
407 " SELECT 1 FROM tagxref"
408 " WHERE tagid=%d AND tagtype>0 AND rid=leaf.rid);",
409 TAG_CLOSED
410 );
411 db_multi_exec(
412 "CREATE TEMP TABLE ambiguousBranch(brname TEXT);"
413 "INSERT INTO ambiguousBranch(brname)"
414 " SELECT (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
415 " FROM openLeaf"
416 " GROUP BY 1 HAVING count(*)>1;",
417 TAG_BRANCH
418 );
419 db_multi_exec(
420 "CREATE TEMP TABLE ambiguousLeaf(rid INTEGER PRIMARY KEY);\n"
421 "INSERT INTO ambiguousLeaf(rid)\n"
422 " SELECT rid FROM openLeaf\n"
423 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=openLeaf.rid)"
424 " IN (SELECT brname FROM ambiguousBranch);",
425 TAG_BRANCH
426 );
427 blob_append_sql(&sql, " AND blob.rid IN ambiguousLeaf");
428 }
429 if( showClosed ){
430 blob_append_sql(&sql," AND %z", leaf_is_closed_sql("blob.rid"));
431 }else if( !showAll ){
432 blob_append_sql(&sql," AND NOT %z", leaf_is_closed_sql("blob.rid"));
433 }
@@ -415,10 +449,11 @@
449
450 if( byBranch && fossil_strcmp(zBr, zLastBr)!=0 ){
451 fossil_print("*** %s ***\n", zBr);
452 fossil_free(zLastBr);
453 zLastBr = fossil_strdup(zBr);
454 if( multipleFlag ) n = 0;
455 }
456 n++;
457 sqlite3_snprintf(sizeof(zLineNo), zLineNo, "(%d)", n);
458 fossil_print("%6s ", zLineNo);
459 z = mprintf("%s [%S] %s", zDate, zId, zCom);
@@ -430,11 +465,21 @@
465 }
466
467 /*
468 ** WEBPAGE: leaves
469 **
470 ** Show leaf check-ins in a timeline. By default only open leaves
471 ** are listed.
472 **
473 ** A "leaf" is a check-in with no children in the same branch. A
474 ** "closed leaf" is a leaf that has a "closed" tag. An "open leaf"
475 ** is a leaf without a "closed" tag.
476 **
477 ** Query parameters:
478 **
479 ** all Show all leaves
480 ** closed Show only closed leaves
481 */
482 void leaves_page(void){
483 Blob sql;
484 Stmt q;
485 int showAll = P("all")!=0;
486
+18 -2
--- src/diff.c
+++ src/diff.c
@@ -1929,10 +1929,16 @@
19291929
return diffFlags;
19301930
}
19311931
19321932
/*
19331933
** COMMAND: test-rawdiff
1934
+**
1935
+** Usage: %fossil test-rawdiff FILE1 FILE2
1936
+**
1937
+** Show a minimal sequence of Copy/Delete/Insert operations needed to convert
1938
+** FILE1 into FILE2. This command is intended for use in testing and debugging
1939
+** the built-in difference engine of Fossil.
19341940
*/
19351941
void test_rawdiff_cmd(void){
19361942
Blob a, b;
19371943
int r;
19381944
int i;
@@ -2207,17 +2213,27 @@
22072213
/*
22082214
** WEBPAGE: annotate
22092215
** WEBPAGE: blame
22102216
** WEBPAGE: praise
22112217
**
2218
+** URL: /annotate?checkin=ID&filename=FILENAME
2219
+** URL: /blame?checkin=ID&filename=FILENAME
2220
+** URL: /praise?checkin=ID&filename=FILENAME
2221
+**
2222
+** Show the most recent change to each line of a text file. /annotate shows
2223
+** the date of the changes and the check-in SHA1 hash (with a link to the
2224
+** check-in). /blame and /praise also show the user who made the check-in.
2225
+**
22122226
** Query parameters:
22132227
**
22142228
** checkin=ID The manifest ID at which to start the annotation
22152229
** filename=FILENAME The filename.
22162230
** filevers Show file versions rather than check-in versions
2217
-** log=BOOLEAN Show a log of versions analyzed
22182231
** limit=N Limit the search depth to N ancestors
2232
+** log=BOOLEAN Show a log of versions analyzed
2233
+** w Ignore whitespace
2234
+**
22192235
*/
22202236
void annotation_page(void){
22212237
int mid;
22222238
int fnid;
22232239
int i;
@@ -2294,11 +2310,11 @@
22942310
}
22952311
if( iLimit>20 ){
22962312
style_submenu_element("20 Ancestors", "20 Ancestors",
22972313
"%s", url_render(&url, "limit", "20", 0, 0));
22982314
}
2299
- if( skin_white_foreground() ){
2315
+ if( skin_detail_boolean("white-foreground") ){
23002316
clr1 = 0xa04040;
23012317
clr2 = 0x4059a0;
23022318
}else{
23032319
clr1 = 0xffb5b5; /* Recent changes: red (hot) */
23042320
clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
23052321
--- src/diff.c
+++ src/diff.c
@@ -1929,10 +1929,16 @@
1929 return diffFlags;
1930 }
1931
1932 /*
1933 ** COMMAND: test-rawdiff
 
 
 
 
 
 
1934 */
1935 void test_rawdiff_cmd(void){
1936 Blob a, b;
1937 int r;
1938 int i;
@@ -2207,17 +2213,27 @@
2207 /*
2208 ** WEBPAGE: annotate
2209 ** WEBPAGE: blame
2210 ** WEBPAGE: praise
2211 **
 
 
 
 
 
 
 
 
2212 ** Query parameters:
2213 **
2214 ** checkin=ID The manifest ID at which to start the annotation
2215 ** filename=FILENAME The filename.
2216 ** filevers Show file versions rather than check-in versions
2217 ** log=BOOLEAN Show a log of versions analyzed
2218 ** limit=N Limit the search depth to N ancestors
 
 
 
2219 */
2220 void annotation_page(void){
2221 int mid;
2222 int fnid;
2223 int i;
@@ -2294,11 +2310,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
@@ -1929,10 +1929,16 @@
1929 return diffFlags;
1930 }
1931
1932 /*
1933 ** COMMAND: test-rawdiff
1934 **
1935 ** Usage: %fossil test-rawdiff FILE1 FILE2
1936 **
1937 ** Show a minimal sequence of Copy/Delete/Insert operations needed to convert
1938 ** FILE1 into FILE2. This command is intended for use in testing and debugging
1939 ** the built-in difference engine of Fossil.
1940 */
1941 void test_rawdiff_cmd(void){
1942 Blob a, b;
1943 int r;
1944 int i;
@@ -2207,17 +2213,27 @@
2213 /*
2214 ** WEBPAGE: annotate
2215 ** WEBPAGE: blame
2216 ** WEBPAGE: praise
2217 **
2218 ** URL: /annotate?checkin=ID&filename=FILENAME
2219 ** URL: /blame?checkin=ID&filename=FILENAME
2220 ** URL: /praise?checkin=ID&filename=FILENAME
2221 **
2222 ** Show the most recent change to each line of a text file. /annotate shows
2223 ** the date of the changes and the check-in SHA1 hash (with a link to the
2224 ** check-in). /blame and /praise also show the user who made the check-in.
2225 **
2226 ** Query parameters:
2227 **
2228 ** checkin=ID The manifest ID at which to start the annotation
2229 ** filename=FILENAME The filename.
2230 ** filevers Show file versions rather than check-in versions
 
2231 ** limit=N Limit the search depth to N ancestors
2232 ** log=BOOLEAN Show a log of versions analyzed
2233 ** w Ignore whitespace
2234 **
2235 */
2236 void annotation_page(void){
2237 int mid;
2238 int fnid;
2239 int i;
@@ -2294,11 +2310,11 @@
2310 }
2311 if( iLimit>20 ){
2312 style_submenu_element("20 Ancestors", "20 Ancestors",
2313 "%s", url_render(&url, "limit", "20", 0, 0));
2314 }
2315 if( skin_detail_boolean("white-foreground") ){
2316 clr1 = 0xa04040;
2317 clr2 = 0x4059a0;
2318 }else{
2319 clr1 = 0xffb5b5; /* Recent changes: red (hot) */
2320 clr2 = 0xb5e0ff; /* Older changes: blue (cold) */
2321
+3 -1
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -835,11 +835,13 @@
835835
}
836836
}
837837
838838
/*
839839
** WEBPAGE: vpatch
840
-** URL vpatch?from=UUID&to=UUID
840
+** URL: /vpatch?from=FROM&to=TO
841
+**
842
+** Show a patch that goes from check-in FROM to check-in TO.
841843
*/
842844
void vpatch_page(void){
843845
const char *zFrom = P("from");
844846
const char *zTo = P("to");
845847
login_check_credentials();
846848
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -835,11 +835,13 @@
835 }
836 }
837
838 /*
839 ** WEBPAGE: vpatch
840 ** URL vpatch?from=UUID&to=UUID
 
 
841 */
842 void vpatch_page(void){
843 const char *zFrom = P("from");
844 const char *zTo = P("to");
845 login_check_credentials();
846
--- src/diffcmd.c
+++ src/diffcmd.c
@@ -835,11 +835,13 @@
835 }
836 }
837
838 /*
839 ** WEBPAGE: vpatch
840 ** URL: /vpatch?from=FROM&to=TO
841 **
842 ** Show a patch that goes from check-in FROM to check-in TO.
843 */
844 void vpatch_page(void){
845 const char *zFrom = P("from");
846 const char *zTo = P("to");
847 login_check_credentials();
848
+10 -3
--- src/doc.c
+++ src/doc.c
@@ -774,11 +774,12 @@
774774
775775
776776
/*
777777
** WEBPAGE: background
778778
**
779
-** Return the background image.
779
+** Return the background image. If no background image is defined, a
780
+** built-in 16x16 pixel white GIF is returned.
780781
*/
781782
void background_page(void){
782783
Blob bgimg;
783784
char *zMime;
784785
@@ -793,15 +794,21 @@
793794
g.isConst = 1;
794795
}
795796
796797
797798
/*
798
-** WEBPAGE: /docsrch
799
+** WEBPAGE: docsrch
800
+**
801
+** Search for documents that match a user-supplied full-text search pattern.
802
+** If no pattern is specified (by the s= query parameter) then the user
803
+** is prompted to enter a search string.
804
+**
805
+** Query parameters:
799806
**
800
-** Search for documents that match a user-supplied pattern.
807
+** s=PATTERN Search for PATTERN
801808
*/
802809
void doc_search_page(void){
803810
login_check_credentials();
804811
style_header("Document Search");
805812
search_screen(SRCH_DOC, 0);
806813
style_footer();
807814
}
808815
--- src/doc.c
+++ src/doc.c
@@ -774,11 +774,12 @@
774
775
776 /*
777 ** WEBPAGE: background
778 **
779 ** Return the background image.
 
780 */
781 void background_page(void){
782 Blob bgimg;
783 char *zMime;
784
@@ -793,15 +794,21 @@
793 g.isConst = 1;
794 }
795
796
797 /*
798 ** WEBPAGE: /docsrch
 
 
 
 
 
 
799 **
800 ** Search for documents that match a user-supplied pattern.
801 */
802 void doc_search_page(void){
803 login_check_credentials();
804 style_header("Document Search");
805 search_screen(SRCH_DOC, 0);
806 style_footer();
807 }
808
--- src/doc.c
+++ src/doc.c
@@ -774,11 +774,12 @@
774
775
776 /*
777 ** WEBPAGE: background
778 **
779 ** Return the background image. If no background image is defined, a
780 ** built-in 16x16 pixel white GIF is returned.
781 */
782 void background_page(void){
783 Blob bgimg;
784 char *zMime;
785
@@ -793,15 +794,21 @@
794 g.isConst = 1;
795 }
796
797
798 /*
799 ** WEBPAGE: docsrch
800 **
801 ** Search for documents that match a user-supplied full-text search pattern.
802 ** If no pattern is specified (by the s= query parameter) then the user
803 ** is prompted to enter a search string.
804 **
805 ** Query parameters:
806 **
807 ** s=PATTERN Search for PATTERN
808 */
809 void doc_search_page(void){
810 login_check_credentials();
811 style_header("Document Search");
812 search_screen(SRCH_DOC, 0);
813 style_footer();
814 }
815
--- src/encode.c
+++ src/encode.c
@@ -606,10 +606,14 @@
606606
/*
607607
** Command to test obscure() and unobscure(). These commands are also useful
608608
** utilities for decoding passwords found in the database.
609609
**
610610
** COMMAND: test-obscure
611
+**
612
+** For each command-line argument X, run both obscure(X) and
613
+** unobscure(obscure(X)) and print the results. This is used for testing
614
+** and debugging of the obscure() and unobscure() functions.
611615
*/
612616
void test_obscure_cmd(void){
613617
int i;
614618
char *z, *z2;
615619
for(i=2; i<g.argc; i++){
616620
--- src/encode.c
+++ src/encode.c
@@ -606,10 +606,14 @@
606 /*
607 ** Command to test obscure() and unobscure(). These commands are also useful
608 ** utilities for decoding passwords found in the database.
609 **
610 ** COMMAND: test-obscure
 
 
 
 
611 */
612 void test_obscure_cmd(void){
613 int i;
614 char *z, *z2;
615 for(i=2; i<g.argc; i++){
616
--- src/encode.c
+++ src/encode.c
@@ -606,10 +606,14 @@
606 /*
607 ** Command to test obscure() and unobscure(). These commands are also useful
608 ** utilities for decoding passwords found in the database.
609 **
610 ** COMMAND: test-obscure
611 **
612 ** For each command-line argument X, run both obscure(X) and
613 ** unobscure(obscure(X)) and print the results. This is used for testing
614 ** and debugging of the obscure() and unobscure() functions.
615 */
616 void test_obscure_cmd(void){
617 int i;
618 char *z, *z2;
619 for(i=2; i<g.argc; i++){
620
+7 -11
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182182
if( rid==0 ){
183183
fossil_fatal("no history for file: %b", &fname);
184184
}
185185
zFilename = blob_str(&fname);
186186
db_prepare(&q,
187
- "SELECT b.uuid, ci.uuid, date(event.mtime%s),"
187
+ "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime%s),"
188188
" coalesce(event.ecomment, event.comment),"
189189
" coalesce(event.euser, event.user),"
190190
" (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191191
" AND tagxref.rid=mlink.mid)" /* Tags */
192192
" FROM mlink, blob b, event, blob ci, filename"
@@ -261,12 +261,12 @@
261261
verify_all_options();
262262
263263
for(i=2; i<g.argc; i++){
264264
file_tree_name(g.argv[i], &fname, 1);
265265
blob_zero(&content);
266
- rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0);
267
- if( rc==0 ){
266
+ rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2);
267
+ if( rc==2 ){
268268
fossil_fatal("no such file: %s", g.argv[i]);
269269
}
270270
blob_write_to_file(&content, "-");
271271
blob_reset(&fname);
272272
blob_reset(&content);
@@ -288,10 +288,11 @@
288288
** b=DATE Only show changes before DATE
289289
** n=NUM Show the first NUM changes only
290290
** brbg Background color by branch name
291291
** ubg Background color by user name
292292
** ci=UUID Ancestors of a particular check-in
293
+** showid Show RID values for debugging
293294
*/
294295
void finfo_page(void){
295296
Stmt q;
296297
const char *zFilename;
297298
char zPrevDate[20];
@@ -402,12 +403,10 @@
402403
if( fShowId ) blob_appendf(&title, " (%d)", fnid);
403404
}
404405
@ <h2>%b(&title)</h2>
405406
blob_reset(&title);
406407
pGraph = graph_init();
407
- @ <div id="canvas" style="position:relative;width:1px;height:1px;"
408
- @ onclick="clickOnGraph(event)"></div>
409408
@ <table id="timelineTable" class="timelineTable">
410409
while( db_step(&q)==SQLITE_ROW ){
411410
const char *zDate = db_column_text(&q, 0);
412411
const char *zCom = db_column_text(&q, 1);
413412
const char *zUser = db_column_text(&q, 2);
@@ -458,11 +457,11 @@
458457
}
459458
memcpy(zTime, &zDate[11], 5);
460459
zTime[5] = 0;
461460
@ <tr><td class="timelineTime">
462461
@ %z(href("%R/timeline?c=%t",zDate))%s(zTime)</a></td>
463
- @ <td class="timelineGraph"><div id="m%d(gidx)"></div></td>
462
+ @ <td class="timelineGraph"><div id="m%d(gidx)" class="tl-nodemark"></div></td>
464463
if( zBgClr && zBgClr[0] ){
465464
@ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
466465
}else{
467466
@ <td class="timelineTableCell">
468467
}
@@ -508,11 +507,11 @@
508507
@ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
509508
@ [annotate]</a>
510509
@ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
511510
@ [blame]</a>
512511
@ %z(href("%R/timeline?n=200&uf=%!S",zUuid))[check-ins&nbsp;using]</a>
513
- if( fpid ){
512
+ if( fpid>0 ){
514513
@ %z(href("%R/fdiff?sbs=1&v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a>
515514
}
516515
}
517516
if( fDebug & FINFO_DEBUG_MLINK ){
518517
int ii;
@@ -535,15 +534,12 @@
535534
graph_finish(pGraph, 1);
536535
if( pGraph->nErr ){
537536
graph_free(pGraph);
538537
pGraph = 0;
539538
}else{
540
- int w = pGraph->mxRail*pGraph->iRailPitch + 28;
541
- @ <tr><td></td><td>
542
- @ <div id="grbtm" style="width:%d(w)px;"></div>
543
- @ </td><td></td></tr>
539
+ @ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
544540
}
545541
}
546542
@ </table>
547543
timeline_output_graph_javascript(pGraph, 0, 1);
548544
style_footer();
549545
}
550546
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182 if( rid==0 ){
183 fossil_fatal("no history for file: %b", &fname);
184 }
185 zFilename = blob_str(&fname);
186 db_prepare(&q,
187 "SELECT b.uuid, ci.uuid, date(event.mtime%s),"
188 " coalesce(event.ecomment, event.comment),"
189 " coalesce(event.euser, event.user),"
190 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191 " AND tagxref.rid=mlink.mid)" /* Tags */
192 " FROM mlink, blob b, event, blob ci, filename"
@@ -261,12 +261,12 @@
261 verify_all_options();
262
263 for(i=2; i<g.argc; i++){
264 file_tree_name(g.argv[i], &fname, 1);
265 blob_zero(&content);
266 rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,0);
267 if( rc==0 ){
268 fossil_fatal("no such file: %s", g.argv[i]);
269 }
270 blob_write_to_file(&content, "-");
271 blob_reset(&fname);
272 blob_reset(&content);
@@ -288,10 +288,11 @@
288 ** b=DATE Only show changes before DATE
289 ** n=NUM Show the first NUM changes only
290 ** brbg Background color by branch name
291 ** ubg Background color by user name
292 ** ci=UUID Ancestors of a particular check-in
 
293 */
294 void finfo_page(void){
295 Stmt q;
296 const char *zFilename;
297 char zPrevDate[20];
@@ -402,12 +403,10 @@
402 if( fShowId ) blob_appendf(&title, " (%d)", fnid);
403 }
404 @ <h2>%b(&title)</h2>
405 blob_reset(&title);
406 pGraph = graph_init();
407 @ <div id="canvas" style="position:relative;width:1px;height:1px;"
408 @ onclick="clickOnGraph(event)"></div>
409 @ <table id="timelineTable" class="timelineTable">
410 while( db_step(&q)==SQLITE_ROW ){
411 const char *zDate = db_column_text(&q, 0);
412 const char *zCom = db_column_text(&q, 1);
413 const char *zUser = db_column_text(&q, 2);
@@ -458,11 +457,11 @@
458 }
459 memcpy(zTime, &zDate[11], 5);
460 zTime[5] = 0;
461 @ <tr><td class="timelineTime">
462 @ %z(href("%R/timeline?c=%t",zDate))%s(zTime)</a></td>
463 @ <td class="timelineGraph"><div id="m%d(gidx)"></div></td>
464 if( zBgClr && zBgClr[0] ){
465 @ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
466 }else{
467 @ <td class="timelineTableCell">
468 }
@@ -508,11 +507,11 @@
508 @ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
509 @ [annotate]</a>
510 @ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
511 @ [blame]</a>
512 @ %z(href("%R/timeline?n=200&uf=%!S",zUuid))[check-ins&nbsp;using]</a>
513 if( fpid ){
514 @ %z(href("%R/fdiff?sbs=1&v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a>
515 }
516 }
517 if( fDebug & FINFO_DEBUG_MLINK ){
518 int ii;
@@ -535,15 +534,12 @@
535 graph_finish(pGraph, 1);
536 if( pGraph->nErr ){
537 graph_free(pGraph);
538 pGraph = 0;
539 }else{
540 int w = pGraph->mxRail*pGraph->iRailPitch + 28;
541 @ <tr><td></td><td>
542 @ <div id="grbtm" style="width:%d(w)px;"></div>
543 @ </td><td></td></tr>
544 }
545 }
546 @ </table>
547 timeline_output_graph_javascript(pGraph, 0, 1);
548 style_footer();
549 }
550
--- src/finfo.c
+++ src/finfo.c
@@ -182,11 +182,11 @@
182 if( rid==0 ){
183 fossil_fatal("no history for file: %b", &fname);
184 }
185 zFilename = blob_str(&fname);
186 db_prepare(&q,
187 "SELECT DISTINCT b.uuid, ci.uuid, date(event.mtime%s),"
188 " coalesce(event.ecomment, event.comment),"
189 " coalesce(event.euser, event.user),"
190 " (SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0"
191 " AND tagxref.rid=mlink.mid)" /* Tags */
192 " FROM mlink, blob b, event, blob ci, filename"
@@ -261,12 +261,12 @@
261 verify_all_options();
262
263 for(i=2; i<g.argc; i++){
264 file_tree_name(g.argv[i], &fname, 1);
265 blob_zero(&content);
266 rc = historical_version_of_file(zRev, blob_str(&fname), &content, 0,0,0,2);
267 if( rc==2 ){
268 fossil_fatal("no such file: %s", g.argv[i]);
269 }
270 blob_write_to_file(&content, "-");
271 blob_reset(&fname);
272 blob_reset(&content);
@@ -288,10 +288,11 @@
288 ** b=DATE Only show changes before DATE
289 ** n=NUM Show the first NUM changes only
290 ** brbg Background color by branch name
291 ** ubg Background color by user name
292 ** ci=UUID Ancestors of a particular check-in
293 ** showid Show RID values for debugging
294 */
295 void finfo_page(void){
296 Stmt q;
297 const char *zFilename;
298 char zPrevDate[20];
@@ -402,12 +403,10 @@
403 if( fShowId ) blob_appendf(&title, " (%d)", fnid);
404 }
405 @ <h2>%b(&title)</h2>
406 blob_reset(&title);
407 pGraph = graph_init();
 
 
408 @ <table id="timelineTable" class="timelineTable">
409 while( db_step(&q)==SQLITE_ROW ){
410 const char *zDate = db_column_text(&q, 0);
411 const char *zCom = db_column_text(&q, 1);
412 const char *zUser = db_column_text(&q, 2);
@@ -458,11 +457,11 @@
457 }
458 memcpy(zTime, &zDate[11], 5);
459 zTime[5] = 0;
460 @ <tr><td class="timelineTime">
461 @ %z(href("%R/timeline?c=%t",zDate))%s(zTime)</a></td>
462 @ <td class="timelineGraph"><div id="m%d(gidx)" class="tl-nodemark"></div></td>
463 if( zBgClr && zBgClr[0] ){
464 @ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
465 }else{
466 @ <td class="timelineTableCell">
467 }
@@ -508,11 +507,11 @@
507 @ %z(href("%R/annotate?filename=%h&checkin=%s",z,zCkin))
508 @ [annotate]</a>
509 @ %z(href("%R/blame?filename=%h&checkin=%s",z,zCkin))
510 @ [blame]</a>
511 @ %z(href("%R/timeline?n=200&uf=%!S",zUuid))[check-ins&nbsp;using]</a>
512 if( fpid>0 ){
513 @ %z(href("%R/fdiff?sbs=1&v1=%!S&v2=%!S",zPUuid,zUuid))[diff]</a>
514 }
515 }
516 if( fDebug & FINFO_DEBUG_MLINK ){
517 int ii;
@@ -535,15 +534,12 @@
534 graph_finish(pGraph, 1);
535 if( pGraph->nErr ){
536 graph_free(pGraph);
537 pGraph = 0;
538 }else{
539 @ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
 
 
 
540 }
541 }
542 @ </table>
543 timeline_output_graph_javascript(pGraph, 0, 1);
544 style_footer();
545 }
546
+8 -15
--- src/graph.c
+++ src/graph.c
@@ -47,11 +47,11 @@
4747
u8 isDup; /* True if this is duplicate of a prior entry */
4848
u8 isLeaf; /* True if this is a leaf node */
4949
u8 timeWarp; /* Child is earlier in time */
5050
u8 bDescender; /* True if riser from bottom of graph to here. */
5151
i8 iRail; /* Which rail this check-in appears on. 0-based.*/
52
- i8 mergeOut; /* Merge out on rail mergeOut/4. -1 for none */
52
+ i8 mergeOut; /* Merge out to this rail. -1 if no merge-out */
5353
u8 mergeIn[GR_MAX_RAIL]; /* Merge in from non-zero rails */
5454
int aiRiser[GR_MAX_RAIL]; /* Risers from this node to a higher row. */
5555
int mergeUpto; /* Draw the mergeOut rail up to this level */
5656
u64 mergeDown; /* Draw merge lines up from bottom of graph */
5757
@@ -61,11 +61,10 @@
6161
/* Context while building a graph
6262
*/
6363
struct GraphContext {
6464
int nErr; /* Number of errors encountered */
6565
int mxRail; /* Number of rails required to render the graph */
66
- int iRailPitch; /* Pixels between rail centers */
6766
GraphRow *pFirst; /* First row in the list */
6867
GraphRow *pLast; /* Last row in the list */
6968
int nBranch; /* Number of distinct branches */
7069
char **azBranch; /* Names of the branches */
7170
int nRow; /* Number of rows */
@@ -294,28 +293,27 @@
294293
u = pParent->aiRiser[pParent->iRail];
295294
if( u>=0 && u<pChild->idx ){
296295
/* The thick arrow up to the next primary child of pDesc goes
297296
** further up than the thin merge arrow riser, so draw them both
298297
** on the same rail. */
299
- pParent->mergeOut = pParent->iRail*4;
300
- if( pParent->iRail<pChild->iRail ) pParent->mergeOut += 2;
298
+ pParent->mergeOut = pParent->iRail;
301299
pParent->mergeUpto = pChild->idx;
302300
}else{
303301
/* The thin merge arrow riser is taller than the thick primary
304302
** child riser, so use separate rails. */
305303
int iTarget = pParent->iRail;
306304
pParent->mergeOut = findFreeRail(p, pChild->idx, pParent->idx-1,
307
- 0, iTarget)*4 + 1;
305
+ 0, iTarget);
308306
pParent->mergeUpto = pChild->idx;
309
- mask = BIT(pParent->mergeOut/4);
307
+ mask = BIT(pParent->mergeOut);
310308
for(pLoop=pChild->pNext; pLoop && pLoop->rid!=pParent->rid;
311309
pLoop=pLoop->pNext){
312310
pLoop->railInUse |= mask;
313311
}
314312
}
315313
}
316
- pChild->mergeIn[pParent->mergeOut/4] = (pParent->mergeOut&3)+1;
314
+ pChild->mergeIn[pParent->mergeOut] = 1;
317315
}
318316
319317
/*
320318
** Compute the maximum rail number.
321319
*/
@@ -322,11 +320,11 @@
322320
static void find_max_rail(GraphContext *p){
323321
GraphRow *pRow;
324322
p->mxRail = 0;
325323
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
326324
if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
327
- if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4;
325
+ if( pRow->mergeOut>p->mxRail ) p->mxRail = pRow->mergeOut;
328326
while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>(BIT(p->mxRail+1)-1) ){
329327
p->mxRail++;
330328
}
331329
}
332330
}
@@ -540,11 +538,11 @@
540538
if( pDesc==0 ){
541539
/* Merge from a node that is off-screen */
542540
int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0);
543541
if( p->mxRail>=GR_MAX_RAIL ) return;
544542
mask = BIT(iMrail);
545
- pRow->mergeIn[iMrail] = 2;
543
+ pRow->mergeIn[iMrail] = 1;
546544
pRow->mergeDown |= mask;
547545
for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
548546
pLoop->railInUse |= mask;
549547
}
550548
}else{
@@ -569,11 +567,11 @@
569567
if( !pRow->isDup ) continue;
570568
pRow->iRail = dupRail;
571569
pDesc = hashFind(p, pRow->rid);
572570
assert( pDesc!=0 && pDesc!=pRow );
573571
createMergeRiser(p, pDesc, pRow);
574
- if( pDesc->mergeOut/4>mxRail ) mxRail = pDesc->mergeOut/4;
572
+ if( pDesc->mergeOut>mxRail ) mxRail = pDesc->mergeOut;
575573
}
576574
if( dupRail<=mxRail ){
577575
dupRail = mxRail+1;
578576
for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
579577
if( pRow->isDup ) pRow->iRail = dupRail;
@@ -584,12 +582,7 @@
584582
585583
/*
586584
** Find the maximum rail number.
587585
*/
588586
find_max_rail(p);
589
- p->iRailPitch = atoi(PD("railpitch","0"));
590
- if( p->iRailPitch<=0 ){
591
- p->iRailPitch = 18 - (p->mxRail/3);
592
- if( p->iRailPitch<11 ) p->iRailPitch = 11;
593
- }
594587
p->nErr = 0;
595588
}
596589
--- src/graph.c
+++ src/graph.c
@@ -47,11 +47,11 @@
47 u8 isDup; /* True if this is duplicate of a prior entry */
48 u8 isLeaf; /* True if this is a leaf node */
49 u8 timeWarp; /* Child is earlier in time */
50 u8 bDescender; /* True if riser from bottom of graph to here. */
51 i8 iRail; /* Which rail this check-in appears on. 0-based.*/
52 i8 mergeOut; /* Merge out on rail mergeOut/4. -1 for none */
53 u8 mergeIn[GR_MAX_RAIL]; /* Merge in from non-zero rails */
54 int aiRiser[GR_MAX_RAIL]; /* Risers from this node to a higher row. */
55 int mergeUpto; /* Draw the mergeOut rail up to this level */
56 u64 mergeDown; /* Draw merge lines up from bottom of graph */
57
@@ -61,11 +61,10 @@
61 /* Context while building a graph
62 */
63 struct GraphContext {
64 int nErr; /* Number of errors encountered */
65 int mxRail; /* Number of rails required to render the graph */
66 int iRailPitch; /* Pixels between rail centers */
67 GraphRow *pFirst; /* First row in the list */
68 GraphRow *pLast; /* Last row in the list */
69 int nBranch; /* Number of distinct branches */
70 char **azBranch; /* Names of the branches */
71 int nRow; /* Number of rows */
@@ -294,28 +293,27 @@
294 u = pParent->aiRiser[pParent->iRail];
295 if( u>=0 && u<pChild->idx ){
296 /* The thick arrow up to the next primary child of pDesc goes
297 ** further up than the thin merge arrow riser, so draw them both
298 ** on the same rail. */
299 pParent->mergeOut = pParent->iRail*4;
300 if( pParent->iRail<pChild->iRail ) pParent->mergeOut += 2;
301 pParent->mergeUpto = pChild->idx;
302 }else{
303 /* The thin merge arrow riser is taller than the thick primary
304 ** child riser, so use separate rails. */
305 int iTarget = pParent->iRail;
306 pParent->mergeOut = findFreeRail(p, pChild->idx, pParent->idx-1,
307 0, iTarget)*4 + 1;
308 pParent->mergeUpto = pChild->idx;
309 mask = BIT(pParent->mergeOut/4);
310 for(pLoop=pChild->pNext; pLoop && pLoop->rid!=pParent->rid;
311 pLoop=pLoop->pNext){
312 pLoop->railInUse |= mask;
313 }
314 }
315 }
316 pChild->mergeIn[pParent->mergeOut/4] = (pParent->mergeOut&3)+1;
317 }
318
319 /*
320 ** Compute the maximum rail number.
321 */
@@ -322,11 +320,11 @@
322 static void find_max_rail(GraphContext *p){
323 GraphRow *pRow;
324 p->mxRail = 0;
325 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
326 if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
327 if( pRow->mergeOut/4>p->mxRail ) p->mxRail = pRow->mergeOut/4;
328 while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>(BIT(p->mxRail+1)-1) ){
329 p->mxRail++;
330 }
331 }
332 }
@@ -540,11 +538,11 @@
540 if( pDesc==0 ){
541 /* Merge from a node that is off-screen */
542 int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0);
543 if( p->mxRail>=GR_MAX_RAIL ) return;
544 mask = BIT(iMrail);
545 pRow->mergeIn[iMrail] = 2;
546 pRow->mergeDown |= mask;
547 for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
548 pLoop->railInUse |= mask;
549 }
550 }else{
@@ -569,11 +567,11 @@
569 if( !pRow->isDup ) continue;
570 pRow->iRail = dupRail;
571 pDesc = hashFind(p, pRow->rid);
572 assert( pDesc!=0 && pDesc!=pRow );
573 createMergeRiser(p, pDesc, pRow);
574 if( pDesc->mergeOut/4>mxRail ) mxRail = pDesc->mergeOut/4;
575 }
576 if( dupRail<=mxRail ){
577 dupRail = mxRail+1;
578 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
579 if( pRow->isDup ) pRow->iRail = dupRail;
@@ -584,12 +582,7 @@
584
585 /*
586 ** Find the maximum rail number.
587 */
588 find_max_rail(p);
589 p->iRailPitch = atoi(PD("railpitch","0"));
590 if( p->iRailPitch<=0 ){
591 p->iRailPitch = 18 - (p->mxRail/3);
592 if( p->iRailPitch<11 ) p->iRailPitch = 11;
593 }
594 p->nErr = 0;
595 }
596
--- src/graph.c
+++ src/graph.c
@@ -47,11 +47,11 @@
47 u8 isDup; /* True if this is duplicate of a prior entry */
48 u8 isLeaf; /* True if this is a leaf node */
49 u8 timeWarp; /* Child is earlier in time */
50 u8 bDescender; /* True if riser from bottom of graph to here. */
51 i8 iRail; /* Which rail this check-in appears on. 0-based.*/
52 i8 mergeOut; /* Merge out to this rail. -1 if no merge-out */
53 u8 mergeIn[GR_MAX_RAIL]; /* Merge in from non-zero rails */
54 int aiRiser[GR_MAX_RAIL]; /* Risers from this node to a higher row. */
55 int mergeUpto; /* Draw the mergeOut rail up to this level */
56 u64 mergeDown; /* Draw merge lines up from bottom of graph */
57
@@ -61,11 +61,10 @@
61 /* Context while building a graph
62 */
63 struct GraphContext {
64 int nErr; /* Number of errors encountered */
65 int mxRail; /* Number of rails required to render the graph */
 
66 GraphRow *pFirst; /* First row in the list */
67 GraphRow *pLast; /* Last row in the list */
68 int nBranch; /* Number of distinct branches */
69 char **azBranch; /* Names of the branches */
70 int nRow; /* Number of rows */
@@ -294,28 +293,27 @@
293 u = pParent->aiRiser[pParent->iRail];
294 if( u>=0 && u<pChild->idx ){
295 /* The thick arrow up to the next primary child of pDesc goes
296 ** further up than the thin merge arrow riser, so draw them both
297 ** on the same rail. */
298 pParent->mergeOut = pParent->iRail;
 
299 pParent->mergeUpto = pChild->idx;
300 }else{
301 /* The thin merge arrow riser is taller than the thick primary
302 ** child riser, so use separate rails. */
303 int iTarget = pParent->iRail;
304 pParent->mergeOut = findFreeRail(p, pChild->idx, pParent->idx-1,
305 0, iTarget);
306 pParent->mergeUpto = pChild->idx;
307 mask = BIT(pParent->mergeOut);
308 for(pLoop=pChild->pNext; pLoop && pLoop->rid!=pParent->rid;
309 pLoop=pLoop->pNext){
310 pLoop->railInUse |= mask;
311 }
312 }
313 }
314 pChild->mergeIn[pParent->mergeOut] = 1;
315 }
316
317 /*
318 ** Compute the maximum rail number.
319 */
@@ -322,11 +320,11 @@
320 static void find_max_rail(GraphContext *p){
321 GraphRow *pRow;
322 p->mxRail = 0;
323 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
324 if( pRow->iRail>p->mxRail ) p->mxRail = pRow->iRail;
325 if( pRow->mergeOut>p->mxRail ) p->mxRail = pRow->mergeOut;
326 while( p->mxRail<GR_MAX_RAIL && pRow->mergeDown>(BIT(p->mxRail+1)-1) ){
327 p->mxRail++;
328 }
329 }
330 }
@@ -540,11 +538,11 @@
538 if( pDesc==0 ){
539 /* Merge from a node that is off-screen */
540 int iMrail = findFreeRail(p, pRow->idx, p->nRow, 0, 0);
541 if( p->mxRail>=GR_MAX_RAIL ) return;
542 mask = BIT(iMrail);
543 pRow->mergeIn[iMrail] = 1;
544 pRow->mergeDown |= mask;
545 for(pLoop=pRow->pNext; pLoop; pLoop=pLoop->pNext){
546 pLoop->railInUse |= mask;
547 }
548 }else{
@@ -569,11 +567,11 @@
567 if( !pRow->isDup ) continue;
568 pRow->iRail = dupRail;
569 pDesc = hashFind(p, pRow->rid);
570 assert( pDesc!=0 && pDesc!=pRow );
571 createMergeRiser(p, pDesc, pRow);
572 if( pDesc->mergeOut>mxRail ) mxRail = pDesc->mergeOut;
573 }
574 if( dupRail<=mxRail ){
575 dupRail = mxRail+1;
576 for(pRow=p->pFirst; pRow; pRow=pRow->pNext){
577 if( pRow->isDup ) pRow->iRail = dupRail;
@@ -584,12 +582,7 @@
582
583 /*
584 ** Find the maximum rail number.
585 */
586 find_max_rail(p);
 
 
 
 
 
587 p->nErr = 0;
588 }
589
+2 -2
--- src/http.c
+++ src/http.c
@@ -338,14 +338,14 @@
338338
j = strlen(zLine) - 1;
339339
while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
340340
j -= 4;
341341
zLine[j] = 0;
342342
}
343
+ fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
344
+ url_parse(&zLine[i], 0);
343345
transport_close(&g.url);
344346
transport_global_shutdown(&g.url);
345
- fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
346
- url_parse(&zLine[i], 0);
347347
fSeenHttpAuth = 0;
348348
if( g.zHttpAuth ) free(g.zHttpAuth);
349349
g.zHttpAuth = get_httpauth();
350350
return http_exchange(pSend, pReply, useLogin, maxRedirect);
351351
}else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
352352
--- src/http.c
+++ src/http.c
@@ -338,14 +338,14 @@
338 j = strlen(zLine) - 1;
339 while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
340 j -= 4;
341 zLine[j] = 0;
342 }
 
 
343 transport_close(&g.url);
344 transport_global_shutdown(&g.url);
345 fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
346 url_parse(&zLine[i], 0);
347 fSeenHttpAuth = 0;
348 if( g.zHttpAuth ) free(g.zHttpAuth);
349 g.zHttpAuth = get_httpauth();
350 return http_exchange(pSend, pReply, useLogin, maxRedirect);
351 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
352
--- src/http.c
+++ src/http.c
@@ -338,14 +338,14 @@
338 j = strlen(zLine) - 1;
339 while( j>4 && fossil_strcmp(&zLine[j-4],"/xfer")==0 ){
340 j -= 4;
341 zLine[j] = 0;
342 }
343 fossil_print("redirect with status %d to %s\n", rc, &zLine[i]);
344 url_parse(&zLine[i], 0);
345 transport_close(&g.url);
346 transport_global_shutdown(&g.url);
 
 
347 fSeenHttpAuth = 0;
348 if( g.zHttpAuth ) free(g.zHttpAuth);
349 g.zHttpAuth = get_httpauth();
350 return http_exchange(pSend, pReply, useLogin, maxRedirect);
351 }else if( fossil_strnicmp(zLine, "content-type: ", 14)==0 ){
352
--- 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
+19 -24
--- src/info.c
+++ src/info.c
@@ -48,10 +48,11 @@
4848
**
4949
** * The UUID
5050
** * The record ID
5151
** * mtime and ctime
5252
** * who signed it
53
+**
5354
*/
5455
void show_common_info(
5556
int rid, /* The rid for the check-in to display info for */
5657
const char *zUuidName, /* Name of the UUID */
5758
int showComment, /* True to show the check-in comment */
@@ -109,26 +110,10 @@
109110
fossil_print("%-13s %s %s\n", zType, zUuid, zDate);
110111
free(zDate);
111112
}
112113
db_finalize(&q);
113114
}
114
- if( zUuid ){
115
- fossil_print("%-13s ", "leaf:");
116
- if(is_a_leaf(rid)){
117
- if(db_int(0, "SELECT 1 FROM tagxref AS tx"
118
- " WHERE tx.rid=%d"
119
- " AND tx.tagid=%d"
120
- " AND tx.tagtype>0",
121
- rid, TAG_CLOSED)){
122
- fossil_print("%s\n", "closed");
123
- }else{
124
- fossil_print("%s\n", "open");
125
- }
126
- }else{
127
- fossil_print("no\n");
128
- }
129
- }
130115
zTags = info_tags_of_checkin(rid, 0);
131116
if( zTags && zTags[0] ){
132117
fossil_print("tags: %s\n", zTags);
133118
}
134119
free(zTags);
@@ -498,15 +483,16 @@
498483
}
499484
500485
/*
501486
** WEBPAGE: vinfo
502487
** WEBPAGE: ci
503
-** URL: /ci?name=RID|ARTIFACTID
488
+** URL: /ci?name=ARTIFACTID
489
+** URL: /vinfo?name=ARTIFACTID
504490
**
505491
** Display information about a particular check-in.
506492
**
507
-** We also jump here from /info if the name is a version.
493
+** We also jump here from /info if the name is a check-in
508494
**
509495
** If the /ci page is used (instead of /vinfo or /info) then the
510496
** default behavior is to show unified diffs of all file changes.
511497
** With /vinfo and /info, only a list of the changed files are
512498
** shown, without diffs. This behavior is inverted if the
@@ -761,11 +747,11 @@
761747
762748
/*
763749
** WEBPAGE: winfo
764750
** URL: /winfo?name=UUID
765751
**
766
-** Return information about a wiki page.
752
+** Display information about a wiki page.
767753
*/
768754
void winfo_page(void){
769755
int rid;
770756
Manifest *pWiki;
771757
char *zUuid;
@@ -964,20 +950,25 @@
964950
}
965951
966952
967953
/*
968954
** WEBPAGE: vdiff
969
-** URL: /vdiff
955
+** URL: /vdiff?from=TAG&to=TAG
956
+**
957
+** Show the difference between two check-ins identified by the from= and
958
+** to= query parameters.
970959
**
971960
** Query parameters:
972961
**
973962
** from=TAG Left side of the comparison
974963
** to=TAG Right side of the comparison
975964
** branch=TAG Show all changes on a particular branch
976965
** v=BOOLEAN Default true. If false, only list files that have changed
977966
** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
978967
** glob=STRING only diff files matching this glob
968
+** dc=N show N lines of context around each diff
969
+** w ignore whitespace when computing diffs
979970
**
980971
**
981972
** Show all differences between two check-ins.
982973
*/
983974
void vdiff_page(void){
@@ -1410,10 +1401,12 @@
14101401
** is 0. Generate plaintext if "patch" is present.
14111402
**
14121403
** Additional parameters:
14131404
**
14141405
** verbose Show more detail when describing artifacts
1406
+** dc=N Show N lines of context around each diff
1407
+** w Ignore whitespace
14151408
*/
14161409
void diff_page(void){
14171410
int v1, v2;
14181411
int isPatch;
14191412
int sideBySide;
@@ -2037,14 +2030,14 @@
20372030
20382031
/*
20392032
** WEBPAGE: info
20402033
** URL: info/ARTIFACTID
20412034
**
2042
-** The argument is a artifact ID which might be a baseline or a file or
2035
+** The argument is a artifact ID which might be a check-in or a file or
20432036
** a ticket changes or a wiki edit or something else.
20442037
**
2045
-** Figure out what the artifact ID is and jump to it.
2038
+** Figure out what the artifact ID is and display it appropriately.
20462039
*/
20472040
void info_page(void){
20482041
const char *zName;
20492042
Blob uuid;
20502043
int rid;
@@ -2272,17 +2265,19 @@
22722265
return zA[0]==0 && zB[0]==0;
22732266
}
22742267
22752268
/*
22762269
** WEBPAGE: ci_edit
2277
-** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
2270
+** URL: /ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
22782271
**
2279
-** Present a dialog for updating properties of a baseline:
2272
+** Present a dialog for updating properties of a check-in.
22802273
**
22812274
** * The check-in user
22822275
** * The check-in comment
2276
+** * The check-in time and date
22832277
** * The background color.
2278
+** * Add and remove tags
22842279
*/
22852280
void ci_edit_page(void){
22862281
int rid;
22872282
const char *zComment; /* Current comment on the check-in */
22882283
const char *zNewComment; /* Revised check-in comment */
22892284
--- src/info.c
+++ src/info.c
@@ -48,10 +48,11 @@
48 **
49 ** * The UUID
50 ** * The record ID
51 ** * mtime and ctime
52 ** * who signed it
 
53 */
54 void show_common_info(
55 int rid, /* The rid for the check-in to display info for */
56 const char *zUuidName, /* Name of the UUID */
57 int showComment, /* True to show the check-in comment */
@@ -109,26 +110,10 @@
109 fossil_print("%-13s %s %s\n", zType, zUuid, zDate);
110 free(zDate);
111 }
112 db_finalize(&q);
113 }
114 if( zUuid ){
115 fossil_print("%-13s ", "leaf:");
116 if(is_a_leaf(rid)){
117 if(db_int(0, "SELECT 1 FROM tagxref AS tx"
118 " WHERE tx.rid=%d"
119 " AND tx.tagid=%d"
120 " AND tx.tagtype>0",
121 rid, TAG_CLOSED)){
122 fossil_print("%s\n", "closed");
123 }else{
124 fossil_print("%s\n", "open");
125 }
126 }else{
127 fossil_print("no\n");
128 }
129 }
130 zTags = info_tags_of_checkin(rid, 0);
131 if( zTags && zTags[0] ){
132 fossil_print("tags: %s\n", zTags);
133 }
134 free(zTags);
@@ -498,15 +483,16 @@
498 }
499
500 /*
501 ** WEBPAGE: vinfo
502 ** WEBPAGE: ci
503 ** URL: /ci?name=RID|ARTIFACTID
 
504 **
505 ** Display information about a particular check-in.
506 **
507 ** We also jump here from /info if the name is a version.
508 **
509 ** If the /ci page is used (instead of /vinfo or /info) then the
510 ** default behavior is to show unified diffs of all file changes.
511 ** With /vinfo and /info, only a list of the changed files are
512 ** shown, without diffs. This behavior is inverted if the
@@ -761,11 +747,11 @@
761
762 /*
763 ** WEBPAGE: winfo
764 ** URL: /winfo?name=UUID
765 **
766 ** Return information about a wiki page.
767 */
768 void winfo_page(void){
769 int rid;
770 Manifest *pWiki;
771 char *zUuid;
@@ -964,20 +950,25 @@
964 }
965
966
967 /*
968 ** WEBPAGE: vdiff
969 ** URL: /vdiff
 
 
 
970 **
971 ** Query parameters:
972 **
973 ** from=TAG Left side of the comparison
974 ** to=TAG Right side of the comparison
975 ** branch=TAG Show all changes on a particular branch
976 ** v=BOOLEAN Default true. If false, only list files that have changed
977 ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
978 ** glob=STRING only diff files matching this glob
 
 
979 **
980 **
981 ** Show all differences between two check-ins.
982 */
983 void vdiff_page(void){
@@ -1410,10 +1401,12 @@
1410 ** is 0. Generate plaintext if "patch" is present.
1411 **
1412 ** Additional parameters:
1413 **
1414 ** verbose Show more detail when describing artifacts
 
 
1415 */
1416 void diff_page(void){
1417 int v1, v2;
1418 int isPatch;
1419 int sideBySide;
@@ -2037,14 +2030,14 @@
2037
2038 /*
2039 ** WEBPAGE: info
2040 ** URL: info/ARTIFACTID
2041 **
2042 ** The argument is a artifact ID which might be a baseline or a file or
2043 ** a ticket changes or a wiki edit or something else.
2044 **
2045 ** Figure out what the artifact ID is and jump to it.
2046 */
2047 void info_page(void){
2048 const char *zName;
2049 Blob uuid;
2050 int rid;
@@ -2272,17 +2265,19 @@
2272 return zA[0]==0 && zB[0]==0;
2273 }
2274
2275 /*
2276 ** WEBPAGE: ci_edit
2277 ** URL: ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
2278 **
2279 ** Present a dialog for updating properties of a baseline:
2280 **
2281 ** * The check-in user
2282 ** * The check-in comment
 
2283 ** * The background color.
 
2284 */
2285 void ci_edit_page(void){
2286 int rid;
2287 const char *zComment; /* Current comment on the check-in */
2288 const char *zNewComment; /* Revised check-in comment */
2289
--- src/info.c
+++ src/info.c
@@ -48,10 +48,11 @@
48 **
49 ** * The UUID
50 ** * The record ID
51 ** * mtime and ctime
52 ** * who signed it
53 **
54 */
55 void show_common_info(
56 int rid, /* The rid for the check-in to display info for */
57 const char *zUuidName, /* Name of the UUID */
58 int showComment, /* True to show the check-in comment */
@@ -109,26 +110,10 @@
110 fossil_print("%-13s %s %s\n", zType, zUuid, zDate);
111 free(zDate);
112 }
113 db_finalize(&q);
114 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115 zTags = info_tags_of_checkin(rid, 0);
116 if( zTags && zTags[0] ){
117 fossil_print("tags: %s\n", zTags);
118 }
119 free(zTags);
@@ -498,15 +483,16 @@
483 }
484
485 /*
486 ** WEBPAGE: vinfo
487 ** WEBPAGE: ci
488 ** URL: /ci?name=ARTIFACTID
489 ** URL: /vinfo?name=ARTIFACTID
490 **
491 ** Display information about a particular check-in.
492 **
493 ** We also jump here from /info if the name is a check-in
494 **
495 ** If the /ci page is used (instead of /vinfo or /info) then the
496 ** default behavior is to show unified diffs of all file changes.
497 ** With /vinfo and /info, only a list of the changed files are
498 ** shown, without diffs. This behavior is inverted if the
@@ -761,11 +747,11 @@
747
748 /*
749 ** WEBPAGE: winfo
750 ** URL: /winfo?name=UUID
751 **
752 ** Display information about a wiki page.
753 */
754 void winfo_page(void){
755 int rid;
756 Manifest *pWiki;
757 char *zUuid;
@@ -964,20 +950,25 @@
950 }
951
952
953 /*
954 ** WEBPAGE: vdiff
955 ** URL: /vdiff?from=TAG&to=TAG
956 **
957 ** Show the difference between two check-ins identified by the from= and
958 ** to= query parameters.
959 **
960 ** Query parameters:
961 **
962 ** from=TAG Left side of the comparison
963 ** to=TAG Right side of the comparison
964 ** branch=TAG Show all changes on a particular branch
965 ** v=BOOLEAN Default true. If false, only list files that have changed
966 ** sbs=BOOLEAN Side-by-side diff if true. Unified diff if false
967 ** glob=STRING only diff files matching this glob
968 ** dc=N show N lines of context around each diff
969 ** w ignore whitespace when computing diffs
970 **
971 **
972 ** Show all differences between two check-ins.
973 */
974 void vdiff_page(void){
@@ -1410,10 +1401,12 @@
1401 ** is 0. Generate plaintext if "patch" is present.
1402 **
1403 ** Additional parameters:
1404 **
1405 ** verbose Show more detail when describing artifacts
1406 ** dc=N Show N lines of context around each diff
1407 ** w Ignore whitespace
1408 */
1409 void diff_page(void){
1410 int v1, v2;
1411 int isPatch;
1412 int sideBySide;
@@ -2037,14 +2030,14 @@
2030
2031 /*
2032 ** WEBPAGE: info
2033 ** URL: info/ARTIFACTID
2034 **
2035 ** The argument is a artifact ID which might be a check-in or a file or
2036 ** a ticket changes or a wiki edit or something else.
2037 **
2038 ** Figure out what the artifact ID is and display it appropriately.
2039 */
2040 void info_page(void){
2041 const char *zName;
2042 Blob uuid;
2043 int rid;
@@ -2272,17 +2265,19 @@
2265 return zA[0]==0 && zB[0]==0;
2266 }
2267
2268 /*
2269 ** WEBPAGE: ci_edit
2270 ** URL: /ci_edit?r=RID&c=NEWCOMMENT&u=NEWUSER
2271 **
2272 ** Present a dialog for updating properties of a check-in.
2273 **
2274 ** * The check-in user
2275 ** * The check-in comment
2276 ** * The check-in time and date
2277 ** * The background color.
2278 ** * Add and remove tags
2279 */
2280 void ci_edit_page(void){
2281 int rid;
2282 const char *zComment; /* Current comment on the check-in */
2283 const char *zNewComment; /* Revised check-in comment */
2284
+1
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
12921292
INT(g, nAux);
12931293
INT(g, allowSymlinks);
12941294
12951295
CSTR(g, zMainDbType);
12961296
CSTR(g, zConfigDbType);
1297
+ CSTR(g, zOpenRevision);
12971298
CSTR(g, zLocalRoot);
12981299
CSTR(g, zPath);
12991300
CSTR(g, zExtra);
13001301
CSTR(g, zBaseURL);
13011302
CSTR(g, zTop);
13021303
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
1292 INT(g, nAux);
1293 INT(g, allowSymlinks);
1294
1295 CSTR(g, zMainDbType);
1296 CSTR(g, zConfigDbType);
 
1297 CSTR(g, zLocalRoot);
1298 CSTR(g, zPath);
1299 CSTR(g, zExtra);
1300 CSTR(g, zBaseURL);
1301 CSTR(g, zTop);
1302
--- src/json.c
+++ src/json.c
@@ -1292,10 +1292,11 @@
1292 INT(g, nAux);
1293 INT(g, allowSymlinks);
1294
1295 CSTR(g, zMainDbType);
1296 CSTR(g, zConfigDbType);
1297 CSTR(g, zOpenRevision);
1298 CSTR(g, zLocalRoot);
1299 CSTR(g, zPath);
1300 CSTR(g, zExtra);
1301 CSTR(g, zBaseURL);
1302 CSTR(g, zTop);
1303
--- 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
+87
--- src/leaf.c
+++ src/leaf.c
@@ -180,5 +180,92 @@
180180
for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
181181
leaf_check(rid);
182182
}
183183
bag_clear(&needToCheck);
184184
}
185
+
186
+/*
187
+** If check-in rid is an open-leaf and there exists another
188
+** open leaf on the same branch, then return 1.
189
+**
190
+** If check-in rid is not an open leaf, or if it is the only open leaf
191
+** on its branch, then return 0.
192
+*/
193
+int leaf_ambiguity(int rid){
194
+ int rc; /* Result */
195
+ char zVal[30];
196
+ if( !is_a_leaf(rid) ) return 0;
197
+ sqlite3_snprintf(sizeof(zVal), zVal, "%d", rid);
198
+ rc = db_exists(
199
+ "SELECT 1 FROM leaf"
200
+ " WHERE NOT %z"
201
+ " AND rid<>%d"
202
+ " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)="
203
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)"
204
+ " AND NOT %z",
205
+ leaf_is_closed_sql(zVal), rid, TAG_BRANCH, TAG_BRANCH, rid,
206
+ leaf_is_closed_sql("leaf.rid"));
207
+ return rc;
208
+}
209
+
210
+/*
211
+** If check-in rid is an open-leaf and there exists another open leaf
212
+** on the same branch, then print a detailed warning showing all open
213
+** leaves on that branch.
214
+*/
215
+int leaf_ambiguity_warning(int rid, int currentCkout){
216
+ char *zBr;
217
+ Stmt q;
218
+ int n = 0;
219
+ Blob msg;
220
+ if( leaf_ambiguity(rid)==0 ) return 0;
221
+ zBr = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
222
+ TAG_BRANCH, rid);
223
+ if( zBr==0 ) zBr = fossil_strdup("trunk");
224
+ blob_init(&msg, 0, 0);
225
+ blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
226
+ db_prepare(&q,
227
+ "SELECT"
228
+ " (SELECT uuid FROM blob WHERE rid=leaf.rid),"
229
+ " (SELECT datetime(mtime%s) FROM event WHERE objid=leaf.rid),"
230
+ " leaf.rid"
231
+ " FROM leaf"
232
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)=%Q"
233
+ " AND NOT %z"
234
+ " ORDER BY 2 DESC",
235
+ timeline_utc(), TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
236
+ );
237
+ while( db_step(&q)==SQLITE_ROW ){
238
+ blob_appendf(&msg, "\n (%d) %s [%S]%s",
239
+ ++n, db_column_text(&q,1), db_column_text(&q,0),
240
+ db_column_int(&q,2)==currentCkout ? " (current)" : "");
241
+ }
242
+ db_finalize(&q);
243
+ fossil_warning("%s",blob_str(&msg));
244
+ blob_reset(&msg);
245
+ return 1;
246
+}
247
+
248
+/*
249
+** COMMAND: test-leaf-ambiguity
250
+**
251
+** Usage: %fossil NAME ...
252
+**
253
+** Resolve each name on the command line and call leaf_ambiguity_warning()
254
+** for each resulting RID.
255
+*/
256
+void leaf_ambiguity_warning_test(void){
257
+ int i;
258
+ int rid;
259
+ int rc;
260
+ db_find_and_open_repository(0,0);
261
+ verify_all_options();
262
+ for(i=2; i<g.argc; i++){
263
+ char *zUuid;
264
+ rid = name_to_typed_rid(g.argv[i], "ci");
265
+ zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
266
+ fossil_print("%s (rid=%d) %S ", g.argv[i], rid, zUuid ? zUuid : "(none)");
267
+ fossil_free(zUuid);
268
+ rc = leaf_ambiguity_warning(rid, rid);
269
+ if( rc==0 ) fossil_print(" ok\n");
270
+ }
271
+}
185272
--- src/leaf.c
+++ src/leaf.c
@@ -180,5 +180,92 @@
180 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
181 leaf_check(rid);
182 }
183 bag_clear(&needToCheck);
184 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
--- src/leaf.c
+++ src/leaf.c
@@ -180,5 +180,92 @@
180 for(rid=bag_first(&needToCheck); rid; rid=bag_next(&needToCheck,rid)){
181 leaf_check(rid);
182 }
183 bag_clear(&needToCheck);
184 }
185
186 /*
187 ** If check-in rid is an open-leaf and there exists another
188 ** open leaf on the same branch, then return 1.
189 **
190 ** If check-in rid is not an open leaf, or if it is the only open leaf
191 ** on its branch, then return 0.
192 */
193 int leaf_ambiguity(int rid){
194 int rc; /* Result */
195 char zVal[30];
196 if( !is_a_leaf(rid) ) return 0;
197 sqlite3_snprintf(sizeof(zVal), zVal, "%d", rid);
198 rc = db_exists(
199 "SELECT 1 FROM leaf"
200 " WHERE NOT %z"
201 " AND rid<>%d"
202 " AND (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)="
203 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=%d)"
204 " AND NOT %z",
205 leaf_is_closed_sql(zVal), rid, TAG_BRANCH, TAG_BRANCH, rid,
206 leaf_is_closed_sql("leaf.rid"));
207 return rc;
208 }
209
210 /*
211 ** If check-in rid is an open-leaf and there exists another open leaf
212 ** on the same branch, then print a detailed warning showing all open
213 ** leaves on that branch.
214 */
215 int leaf_ambiguity_warning(int rid, int currentCkout){
216 char *zBr;
217 Stmt q;
218 int n = 0;
219 Blob msg;
220 if( leaf_ambiguity(rid)==0 ) return 0;
221 zBr = db_text(0, "SELECT value FROM tagxref WHERE tagid=%d AND rid=%d",
222 TAG_BRANCH, rid);
223 if( zBr==0 ) zBr = fossil_strdup("trunk");
224 blob_init(&msg, 0, 0);
225 blob_appendf(&msg, "WARNING: multiple open leaf check-ins on %s:", zBr);
226 db_prepare(&q,
227 "SELECT"
228 " (SELECT uuid FROM blob WHERE rid=leaf.rid),"
229 " (SELECT datetime(mtime%s) FROM event WHERE objid=leaf.rid),"
230 " leaf.rid"
231 " FROM leaf"
232 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=leaf.rid)=%Q"
233 " AND NOT %z"
234 " ORDER BY 2 DESC",
235 timeline_utc(), TAG_BRANCH, zBr, leaf_is_closed_sql("leaf.rid")
236 );
237 while( db_step(&q)==SQLITE_ROW ){
238 blob_appendf(&msg, "\n (%d) %s [%S]%s",
239 ++n, db_column_text(&q,1), db_column_text(&q,0),
240 db_column_int(&q,2)==currentCkout ? " (current)" : "");
241 }
242 db_finalize(&q);
243 fossil_warning("%s",blob_str(&msg));
244 blob_reset(&msg);
245 return 1;
246 }
247
248 /*
249 ** COMMAND: test-leaf-ambiguity
250 **
251 ** Usage: %fossil NAME ...
252 **
253 ** Resolve each name on the command line and call leaf_ambiguity_warning()
254 ** for each resulting RID.
255 */
256 void leaf_ambiguity_warning_test(void){
257 int i;
258 int rid;
259 int rc;
260 db_find_and_open_repository(0,0);
261 verify_all_options();
262 for(i=2; i<g.argc; i++){
263 char *zUuid;
264 rid = name_to_typed_rid(g.argv[i], "ci");
265 zUuid = db_text(0, "SELECT uuid FROM blob WHERE rid=%d", rid);
266 fossil_print("%s (rid=%d) %S ", g.argv[i], rid, zUuid ? zUuid : "(none)");
267 fossil_free(zUuid);
268 rc = leaf_ambiguity_warning(rid, rid);
269 if( rc==0 ) fossil_print(" ok\n");
270 }
271 }
272
+2 -2
--- src/login.c
+++ src/login.c
@@ -1302,12 +1302,12 @@
13021302
}
13031303
13041304
/*
13051305
** WEBPAGE: register
13061306
**
1307
-** Generate the register page.
1308
-**
1307
+** Page to allow users to self-register. The "self-register" setting
1308
+** must be enabled for this page to operate.
13091309
*/
13101310
void register_page(void){
13111311
const char *zUsername, *zPasswd, *zConfirm, *zContact, *zCS, *zPw, *zCap;
13121312
unsigned int uSeed;
13131313
const char *zDecoded;
13141314
--- src/login.c
+++ src/login.c
@@ -1302,12 +1302,12 @@
1302 }
1303
1304 /*
1305 ** WEBPAGE: register
1306 **
1307 ** Generate the register page.
1308 **
1309 */
1310 void register_page(void){
1311 const char *zUsername, *zPasswd, *zConfirm, *zContact, *zCS, *zPw, *zCap;
1312 unsigned int uSeed;
1313 const char *zDecoded;
1314
--- src/login.c
+++ src/login.c
@@ -1302,12 +1302,12 @@
1302 }
1303
1304 /*
1305 ** WEBPAGE: register
1306 **
1307 ** Page to allow users to self-register. The "self-register" setting
1308 ** must be enabled for this page to operate.
1309 */
1310 void register_page(void){
1311 const char *zUsername, *zPasswd, *zConfirm, *zContact, *zCS, *zPw, *zCap;
1312 unsigned int uSeed;
1313 const char *zDecoded;
1314
+29 -9
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135135
char *zRepositoryOption; /* Most recent cached repository option value */
136136
char *zRepositoryName; /* Name of the repository database */
137137
char *zLocalDbName; /* Name of the local database */
138138
const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139139
const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
140
+ char *zOpenRevision; /* Check-in version to use during database open */
140141
int localOpen; /* True if the local database is open */
141142
char *zLocalRoot; /* The directory holding the local database */
142143
int minPrefix; /* Number of digits needed for a distinct UUID */
143144
int fSqlTrace; /* True if --sqltrace flag is present */
144145
int fSqlStats; /* True if --sqltrace or --sqlstats are present */
@@ -590,12 +591,12 @@
590591
#endif
591592
{
592593
const char *zCmdName = "unknown";
593594
int idx;
594595
int rc;
595
- if( sqlite3_libversion_number()<3008003 ){
596
- fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.3",
596
+ if( sqlite3_libversion_number()<3008007 ){
597
+ fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.7",
597598
sqlite3_libversion());
598599
}
599600
sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
600601
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
601602
memset(&g, 0, sizeof(g));
@@ -656,10 +657,11 @@
656657
"in conjunction with any other flags.\n");
657658
fossil_exit(1);
658659
}else{
659660
const char *zChdir = find_option("chdir",0,1);
660661
g.isHTTP = 0;
662
+ g.rcvid = 0;
661663
g.fQuiet = find_option("quiet", 0, 0)!=0;
662664
g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
663665
g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
664666
g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
665667
g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
@@ -1008,10 +1010,13 @@
10081010
fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
10091011
#endif
10101012
#if defined(FOSSIL_ENABLE_SSL)
10111013
fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
10121014
#endif
1015
+#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1016
+ fossil_print("LEGACY_MV_RM\n");
1017
+#endif
10131018
#if defined(FOSSIL_ENABLE_TH1_DOCS)
10141019
fossil_print("TH1_DOCS\n");
10151020
#endif
10161021
#if defined(FOSSIL_ENABLE_TH1_HOOKS)
10171022
fossil_print("TH1_HOOKS\n");
@@ -1128,11 +1133,14 @@
11281133
putchar('\n');
11291134
}
11301135
11311136
/*
11321137
** WEBPAGE: help
1133
-** URL: /help/CMD
1138
+** URL: /help?name=CMD
1139
+**
1140
+** Show the built-in help text for CMD. CMD can be a command-line interface
1141
+** command or a page name from the web interface.
11341142
*/
11351143
void help_page(void){
11361144
const char *zCmd = P("cmd");
11371145
11381146
if( zCmd==0 ) zCmd = P("name");
@@ -1196,11 +1204,10 @@
11961204
@ </ul></td>
11971205
}
11981206
@ </tr></table>
11991207
12001208
@ <h1>Available web UI pages:</h1>
1201
- @ (Only pages with help text are linked.)
12021209
@ <table border="0"><tr>
12031210
for(i=j=0; i<count(aCommand); i++){
12041211
const char *z = aCommand[i].zName;
12051212
if( '/'!=*z ) continue;
12061213
j++;
@@ -1435,20 +1442,27 @@
14351442
vfile_scan(&base, blob_size(&base), 0, 0, 0);
14361443
db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*.fossil'");
14371444
n = db_int(0, "SELECT count(*) FROM sfile");
14381445
if( n>0 ){
14391446
Stmt q;
1447
+ @ <html>
1448
+ @ <head>
1449
+ @ <title>Repository List</title>
1450
+ @ </head>
1451
+ @ <body>
14401452
@ <h1>Available Repositories:</h1>
14411453
@ <ol>
14421454
db_prepare(&q, "SELECT x, substr(x,-7,-100000)||'/home'"
14431455
" FROM sfile ORDER BY x COLLATE nocase;");
14441456
while( db_step(&q)==SQLITE_ROW ){
14451457
const char *zName = db_column_text(&q, 0);
14461458
const char *zUrl = db_column_text(&q, 1);
1447
- @ <li><a href="%h(zUrl)">%h(zName)</a></li>
1459
+ @ <li><a href="%h(zUrl)" target="_blank">%h(zName)</a></li>
14481460
}
14491461
@ </ol>
1462
+ @ </body>
1463
+ @ </html>
14501464
cgi_reply();
14511465
}
14521466
sqlite3_close(g.db);
14531467
g.db = 0;
14541468
return n;
@@ -1522,10 +1536,16 @@
15221536
break;
15231537
}
15241538
if( szFile==0 ){
15251539
if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
15261540
szFile = file_size(zRepo);
1541
+ /* this should only be set from the --baseurl option, not CGI */
1542
+ if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1543
+ file_isdir(g.zRepositoryName)==1 ){
1544
+ g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1545
+ g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1546
+ }
15271547
}
15281548
if( szFile<0 && i>0 ){
15291549
const char *zMimetype;
15301550
assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
15311551
zRepo[j] = 0;
@@ -1551,16 +1571,16 @@
15511571
zRepo[j] = '.';
15521572
}
15531573
15541574
if( szFile<1024 ){
15551575
set_base_url(0);
1556
- if( zNotFound ){
1557
- cgi_redirect(zNotFound);
1558
- }else if( strcmp(zPathInfo,"/")==0
1576
+ if( strcmp(zPathInfo,"/")==0
15591577
&& allowRepoList
15601578
&& repo_list_page() ){
15611579
/* Will return a list of repositories */
1580
+ }else if( zNotFound ){
1581
+ cgi_redirect(zNotFound);
15621582
}else{
15631583
#ifdef FOSSIL_ENABLE_JSON
15641584
if(g.json.isJsonMode){
15651585
json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
15661586
return;
@@ -2157,18 +2177,18 @@
21572177
zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
21582178
cgi_replace_parameter("HTTPS","on");
21592179
}
21602180
zHost = find_option("host", 0, 1);
21612181
if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2162
- g.cgiOutput = 1;
21632182
21642183
/* We should be done with options.. */
21652184
verify_all_options();
21662185
21672186
if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
21682187
fossil_fatal("no repository specified");
21692188
}
2189
+ g.cgiOutput = 1;
21702190
g.fullHttpReply = 1;
21712191
if( g.argc>=5 ){
21722192
g.httpIn = fossil_fopen(g.argv[2], "rb");
21732193
g.httpOut = fossil_fopen(g.argv[3], "wb");
21742194
zIpAddr = g.argv[4];
21752195
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
137 char *zLocalDbName; /* Name of the local database */
138 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
 
140 int localOpen; /* True if the local database is open */
141 char *zLocalRoot; /* The directory holding the local database */
142 int minPrefix; /* Number of digits needed for a distinct UUID */
143 int fSqlTrace; /* True if --sqltrace flag is present */
144 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
@@ -590,12 +591,12 @@
590 #endif
591 {
592 const char *zCmdName = "unknown";
593 int idx;
594 int rc;
595 if( sqlite3_libversion_number()<3008003 ){
596 fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.3",
597 sqlite3_libversion());
598 }
599 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
600 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
601 memset(&g, 0, sizeof(g));
@@ -656,10 +657,11 @@
656 "in conjunction with any other flags.\n");
657 fossil_exit(1);
658 }else{
659 const char *zChdir = find_option("chdir",0,1);
660 g.isHTTP = 0;
 
661 g.fQuiet = find_option("quiet", 0, 0)!=0;
662 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
663 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
664 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
665 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
@@ -1008,10 +1010,13 @@
1008 fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1009 #endif
1010 #if defined(FOSSIL_ENABLE_SSL)
1011 fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1012 #endif
 
 
 
1013 #if defined(FOSSIL_ENABLE_TH1_DOCS)
1014 fossil_print("TH1_DOCS\n");
1015 #endif
1016 #if defined(FOSSIL_ENABLE_TH1_HOOKS)
1017 fossil_print("TH1_HOOKS\n");
@@ -1128,11 +1133,14 @@
1128 putchar('\n');
1129 }
1130
1131 /*
1132 ** WEBPAGE: help
1133 ** URL: /help/CMD
 
 
 
1134 */
1135 void help_page(void){
1136 const char *zCmd = P("cmd");
1137
1138 if( zCmd==0 ) zCmd = P("name");
@@ -1196,11 +1204,10 @@
1196 @ </ul></td>
1197 }
1198 @ </tr></table>
1199
1200 @ <h1>Available web UI pages:</h1>
1201 @ (Only pages with help text are linked.)
1202 @ <table border="0"><tr>
1203 for(i=j=0; i<count(aCommand); i++){
1204 const char *z = aCommand[i].zName;
1205 if( '/'!=*z ) continue;
1206 j++;
@@ -1435,20 +1442,27 @@
1435 vfile_scan(&base, blob_size(&base), 0, 0, 0);
1436 db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*.fossil'");
1437 n = db_int(0, "SELECT count(*) FROM sfile");
1438 if( n>0 ){
1439 Stmt q;
 
 
 
 
 
1440 @ <h1>Available Repositories:</h1>
1441 @ <ol>
1442 db_prepare(&q, "SELECT x, substr(x,-7,-100000)||'/home'"
1443 " FROM sfile ORDER BY x COLLATE nocase;");
1444 while( db_step(&q)==SQLITE_ROW ){
1445 const char *zName = db_column_text(&q, 0);
1446 const char *zUrl = db_column_text(&q, 1);
1447 @ <li><a href="%h(zUrl)">%h(zName)</a></li>
1448 }
1449 @ </ol>
 
 
1450 cgi_reply();
1451 }
1452 sqlite3_close(g.db);
1453 g.db = 0;
1454 return n;
@@ -1522,10 +1536,16 @@
1522 break;
1523 }
1524 if( szFile==0 ){
1525 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1526 szFile = file_size(zRepo);
 
 
 
 
 
 
1527 }
1528 if( szFile<0 && i>0 ){
1529 const char *zMimetype;
1530 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1531 zRepo[j] = 0;
@@ -1551,16 +1571,16 @@
1551 zRepo[j] = '.';
1552 }
1553
1554 if( szFile<1024 ){
1555 set_base_url(0);
1556 if( zNotFound ){
1557 cgi_redirect(zNotFound);
1558 }else if( strcmp(zPathInfo,"/")==0
1559 && allowRepoList
1560 && repo_list_page() ){
1561 /* Will return a list of repositories */
 
 
1562 }else{
1563 #ifdef FOSSIL_ENABLE_JSON
1564 if(g.json.isJsonMode){
1565 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1566 return;
@@ -2157,18 +2177,18 @@
2157 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2158 cgi_replace_parameter("HTTPS","on");
2159 }
2160 zHost = find_option("host", 0, 1);
2161 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
2162 g.cgiOutput = 1;
2163
2164 /* We should be done with options.. */
2165 verify_all_options();
2166
2167 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
2168 fossil_fatal("no repository specified");
2169 }
 
2170 g.fullHttpReply = 1;
2171 if( g.argc>=5 ){
2172 g.httpIn = fossil_fopen(g.argv[2], "rb");
2173 g.httpOut = fossil_fopen(g.argv[3], "wb");
2174 zIpAddr = g.argv[4];
2175
--- src/main.c
+++ src/main.c
@@ -135,10 +135,11 @@
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database */
137 char *zLocalDbName; /* Name of the local database */
138 const char *zMainDbType;/* "configdb", "localdb", or "repository" */
139 const char *zConfigDbType; /* "configdb", "localdb", or "repository" */
140 char *zOpenRevision; /* Check-in version to use during database open */
141 int localOpen; /* True if the local database is open */
142 char *zLocalRoot; /* The directory holding the local database */
143 int minPrefix; /* Number of digits needed for a distinct UUID */
144 int fSqlTrace; /* True if --sqltrace flag is present */
145 int fSqlStats; /* True if --sqltrace or --sqlstats are present */
@@ -590,12 +591,12 @@
591 #endif
592 {
593 const char *zCmdName = "unknown";
594 int idx;
595 int rc;
596 if( sqlite3_libversion_number()<3008007 ){
597 fossil_fatal("Unsuitable SQLite version %s, must be at least 3.8.7",
598 sqlite3_libversion());
599 }
600 sqlite3_config(SQLITE_CONFIG_MULTITHREAD);
601 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
602 memset(&g, 0, sizeof(g));
@@ -656,10 +657,11 @@
657 "in conjunction with any other flags.\n");
658 fossil_exit(1);
659 }else{
660 const char *zChdir = find_option("chdir",0,1);
661 g.isHTTP = 0;
662 g.rcvid = 0;
663 g.fQuiet = find_option("quiet", 0, 0)!=0;
664 g.fSqlTrace = find_option("sqltrace", 0, 0)!=0;
665 g.fSqlStats = find_option("sqlstats", 0, 0)!=0;
666 g.fSystemTrace = find_option("systemtrace", 0, 0)!=0;
667 g.fSshTrace = find_option("sshtrace", 0, 0)!=0;
@@ -1008,10 +1010,13 @@
1010 fossil_print("zlib %s, loaded %s\n", ZLIB_VERSION, zlibVersion());
1011 #endif
1012 #if defined(FOSSIL_ENABLE_SSL)
1013 fossil_print("SSL (%s)\n", SSLeay_version(SSLEAY_VERSION));
1014 #endif
1015 #if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
1016 fossil_print("LEGACY_MV_RM\n");
1017 #endif
1018 #if defined(FOSSIL_ENABLE_TH1_DOCS)
1019 fossil_print("TH1_DOCS\n");
1020 #endif
1021 #if defined(FOSSIL_ENABLE_TH1_HOOKS)
1022 fossil_print("TH1_HOOKS\n");
@@ -1128,11 +1133,14 @@
1133 putchar('\n');
1134 }
1135
1136 /*
1137 ** WEBPAGE: help
1138 ** URL: /help?name=CMD
1139 **
1140 ** Show the built-in help text for CMD. CMD can be a command-line interface
1141 ** command or a page name from the web interface.
1142 */
1143 void help_page(void){
1144 const char *zCmd = P("cmd");
1145
1146 if( zCmd==0 ) zCmd = P("name");
@@ -1196,11 +1204,10 @@
1204 @ </ul></td>
1205 }
1206 @ </tr></table>
1207
1208 @ <h1>Available web UI pages:</h1>
 
1209 @ <table border="0"><tr>
1210 for(i=j=0; i<count(aCommand); i++){
1211 const char *z = aCommand[i].zName;
1212 if( '/'!=*z ) continue;
1213 j++;
@@ -1435,20 +1442,27 @@
1442 vfile_scan(&base, blob_size(&base), 0, 0, 0);
1443 db_multi_exec("DELETE FROM sfile WHERE x NOT GLOB '*.fossil'");
1444 n = db_int(0, "SELECT count(*) FROM sfile");
1445 if( n>0 ){
1446 Stmt q;
1447 @ <html>
1448 @ <head>
1449 @ <title>Repository List</title>
1450 @ </head>
1451 @ <body>
1452 @ <h1>Available Repositories:</h1>
1453 @ <ol>
1454 db_prepare(&q, "SELECT x, substr(x,-7,-100000)||'/home'"
1455 " FROM sfile ORDER BY x COLLATE nocase;");
1456 while( db_step(&q)==SQLITE_ROW ){
1457 const char *zName = db_column_text(&q, 0);
1458 const char *zUrl = db_column_text(&q, 1);
1459 @ <li><a href="%h(zUrl)" target="_blank">%h(zName)</a></li>
1460 }
1461 @ </ol>
1462 @ </body>
1463 @ </html>
1464 cgi_reply();
1465 }
1466 sqlite3_close(g.db);
1467 g.db = 0;
1468 return n;
@@ -1522,10 +1536,16 @@
1536 break;
1537 }
1538 if( szFile==0 ){
1539 if( zRepo[0]=='/' && zRepo[1]=='/' ){ zRepo++; j--; }
1540 szFile = file_size(zRepo);
1541 /* this should only be set from the --baseurl option, not CGI */
1542 if( g.zBaseURL && g.zBaseURL[0]!=0 && g.zTop && g.zTop[0]!=0 &&
1543 file_isdir(g.zRepositoryName)==1 ){
1544 g.zBaseURL = mprintf("%s%.*s", g.zBaseURL, i, zPathInfo);
1545 g.zTop = mprintf("%s%.*s", g.zTop, i, zPathInfo);
1546 }
1547 }
1548 if( szFile<0 && i>0 ){
1549 const char *zMimetype;
1550 assert( fossil_strcmp(&zRepo[j], ".fossil")==0 );
1551 zRepo[j] = 0;
@@ -1551,16 +1571,16 @@
1571 zRepo[j] = '.';
1572 }
1573
1574 if( szFile<1024 ){
1575 set_base_url(0);
1576 if( strcmp(zPathInfo,"/")==0
 
 
1577 && allowRepoList
1578 && repo_list_page() ){
1579 /* Will return a list of repositories */
1580 }else if( zNotFound ){
1581 cgi_redirect(zNotFound);
1582 }else{
1583 #ifdef FOSSIL_ENABLE_JSON
1584 if(g.json.isJsonMode){
1585 json_err(FSL_JSON_E_RESOURCE_NOT_FOUND,NULL,1);
1586 return;
@@ -2157,18 +2177,18 @@
2177 zIpAddr = fossil_getenv("REMOTE_HOST"); /* From stunnel */
2178 cgi_replace_parameter("HTTPS","on");
2179 }
2180 zHost = find_option("host", 0, 1);
2181 if( zHost ) cgi_replace_parameter("HTTP_HOST",zHost);
 
2182
2183 /* We should be done with options.. */
2184 verify_all_options();
2185
2186 if( g.argc!=2 && g.argc!=3 && g.argc!=5 && g.argc!=6 ){
2187 fossil_fatal("no repository specified");
2188 }
2189 g.cgiOutput = 1;
2190 g.fullHttpReply = 1;
2191 if( g.argc>=5 ){
2192 g.httpIn = fossil_fopen(g.argv[2], "rb");
2193 g.httpOut = fossil_fopen(g.argv[3], "wb");
2194 zIpAddr = g.argv[4];
2195
+26 -1
--- src/main.mk
+++ src/main.mk
@@ -84,10 +84,11 @@
8484
$(SRCDIR)/merge.c \
8585
$(SRCDIR)/merge3.c \
8686
$(SRCDIR)/moderate.c \
8787
$(SRCDIR)/name.c \
8888
$(SRCDIR)/path.c \
89
+ $(SRCDIR)/piechart.c \
8990
$(SRCDIR)/pivot.c \
9091
$(SRCDIR)/popen.c \
9192
$(SRCDIR)/pqueue.c \
9293
$(SRCDIR)/printf.c \
9394
$(SRCDIR)/publish.c \
@@ -132,43 +133,55 @@
132133
$(SRCDIR)/xfer.c \
133134
$(SRCDIR)/xfersetup.c \
134135
$(SRCDIR)/zip.c
135136
136137
EXTRA_FILES = \
138
+ $(SRCDIR)/../skins/aht/details.txt \
137139
$(SRCDIR)/../skins/black_and_white/css.txt \
140
+ $(SRCDIR)/../skins/black_and_white/details.txt \
138141
$(SRCDIR)/../skins/black_and_white/footer.txt \
139142
$(SRCDIR)/../skins/black_and_white/header.txt \
140143
$(SRCDIR)/../skins/blitz/css.txt \
144
+ $(SRCDIR)/../skins/blitz/details.txt \
141145
$(SRCDIR)/../skins/blitz/footer.txt \
142146
$(SRCDIR)/../skins/blitz/header.txt \
143147
$(SRCDIR)/../skins/blitz/ticket.txt \
144148
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
149
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
145150
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
146151
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
147152
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
148153
$(SRCDIR)/../skins/default/css.txt \
154
+ $(SRCDIR)/../skins/default/details.txt \
149155
$(SRCDIR)/../skins/default/footer.txt \
150156
$(SRCDIR)/../skins/default/header.txt \
151157
$(SRCDIR)/../skins/eagle/css.txt \
158
+ $(SRCDIR)/../skins/eagle/details.txt \
152159
$(SRCDIR)/../skins/eagle/footer.txt \
153160
$(SRCDIR)/../skins/eagle/header.txt \
154161
$(SRCDIR)/../skins/enhanced1/css.txt \
162
+ $(SRCDIR)/../skins/enhanced1/details.txt \
155163
$(SRCDIR)/../skins/enhanced1/footer.txt \
156164
$(SRCDIR)/../skins/enhanced1/header.txt \
157165
$(SRCDIR)/../skins/khaki/css.txt \
166
+ $(SRCDIR)/../skins/khaki/details.txt \
158167
$(SRCDIR)/../skins/khaki/footer.txt \
159168
$(SRCDIR)/../skins/khaki/header.txt \
160169
$(SRCDIR)/../skins/original/css.txt \
170
+ $(SRCDIR)/../skins/original/details.txt \
161171
$(SRCDIR)/../skins/original/footer.txt \
162172
$(SRCDIR)/../skins/original/header.txt \
163173
$(SRCDIR)/../skins/plain_gray/css.txt \
174
+ $(SRCDIR)/../skins/plain_gray/details.txt \
164175
$(SRCDIR)/../skins/plain_gray/footer.txt \
165176
$(SRCDIR)/../skins/plain_gray/header.txt \
166177
$(SRCDIR)/../skins/rounded1/css.txt \
178
+ $(SRCDIR)/../skins/rounded1/details.txt \
167179
$(SRCDIR)/../skins/rounded1/footer.txt \
168180
$(SRCDIR)/../skins/rounded1/header.txt \
169181
$(SRCDIR)/../skins/xekri/css.txt \
182
+ $(SRCDIR)/../skins/xekri/details.txt \
170183
$(SRCDIR)/../skins/xekri/footer.txt \
171184
$(SRCDIR)/../skins/xekri/header.txt \
172185
$(SRCDIR)/diff.tcl \
173186
$(SRCDIR)/markdown.md
174187
@@ -243,10 +256,11 @@
243256
$(OBJDIR)/merge_.c \
244257
$(OBJDIR)/merge3_.c \
245258
$(OBJDIR)/moderate_.c \
246259
$(OBJDIR)/name_.c \
247260
$(OBJDIR)/path_.c \
261
+ $(OBJDIR)/piechart_.c \
248262
$(OBJDIR)/pivot_.c \
249263
$(OBJDIR)/popen_.c \
250264
$(OBJDIR)/pqueue_.c \
251265
$(OBJDIR)/printf_.c \
252266
$(OBJDIR)/publish_.c \
@@ -363,10 +377,11 @@
363377
$(OBJDIR)/merge.o \
364378
$(OBJDIR)/merge3.o \
365379
$(OBJDIR)/moderate.o \
366380
$(OBJDIR)/name.o \
367381
$(OBJDIR)/path.o \
382
+ $(OBJDIR)/piechart.o \
368383
$(OBJDIR)/pivot.o \
369384
$(OBJDIR)/popen.o \
370385
$(OBJDIR)/pqueue.o \
371386
$(OBJDIR)/printf.o \
372387
$(OBJDIR)/publish.o \
@@ -462,11 +477,12 @@
462477
-DSQLITE_THREADSAFE=0 \
463478
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
464479
-DSQLITE_OMIT_DEPRECATED \
465480
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
466481
-DSQLITE_ENABLE_FTS4 \
467
- -DSQLITE_ENABLE_FTS3_PARENTHESIS
482
+ -DSQLITE_ENABLE_FTS3_PARENTHESIS \
483
+ -DSQLITE_ENABLE_DBSTAT_VTAB
468484
469485
# Setup the options used to compile the included SQLite shell.
470486
SHELL_OPTIONS = -Dmain=sqlite3_shell \
471487
-DSQLITE_OMIT_LOAD_EXTENSION=1 \
472488
-DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -594,10 +610,11 @@
594610
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
595611
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
596612
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
597613
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
598614
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
615
+ $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
599616
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
600617
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
601618
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
602619
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
603620
$(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1222,10 +1239,18 @@
12221239
12231240
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
12241241
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
12251242
12261243
$(OBJDIR)/path.h: $(OBJDIR)/headers
1244
+
1245
+$(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(OBJDIR)/translate
1246
+ $(OBJDIR)/translate $(SRCDIR)/piechart.c >$@
1247
+
1248
+$(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1249
+ $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1250
+
1251
+$(OBJDIR)/piechart.h: $(OBJDIR)/headers
12271252
12281253
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(OBJDIR)/translate
12291254
$(OBJDIR)/translate $(SRCDIR)/pivot.c >$@
12301255
12311256
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
12321257
--- src/main.mk
+++ src/main.mk
@@ -84,10 +84,11 @@
84 $(SRCDIR)/merge.c \
85 $(SRCDIR)/merge3.c \
86 $(SRCDIR)/moderate.c \
87 $(SRCDIR)/name.c \
88 $(SRCDIR)/path.c \
 
89 $(SRCDIR)/pivot.c \
90 $(SRCDIR)/popen.c \
91 $(SRCDIR)/pqueue.c \
92 $(SRCDIR)/printf.c \
93 $(SRCDIR)/publish.c \
@@ -132,43 +133,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
@@ -243,10 +256,11 @@
243 $(OBJDIR)/merge_.c \
244 $(OBJDIR)/merge3_.c \
245 $(OBJDIR)/moderate_.c \
246 $(OBJDIR)/name_.c \
247 $(OBJDIR)/path_.c \
 
248 $(OBJDIR)/pivot_.c \
249 $(OBJDIR)/popen_.c \
250 $(OBJDIR)/pqueue_.c \
251 $(OBJDIR)/printf_.c \
252 $(OBJDIR)/publish_.c \
@@ -363,10 +377,11 @@
363 $(OBJDIR)/merge.o \
364 $(OBJDIR)/merge3.o \
365 $(OBJDIR)/moderate.o \
366 $(OBJDIR)/name.o \
367 $(OBJDIR)/path.o \
 
368 $(OBJDIR)/pivot.o \
369 $(OBJDIR)/popen.o \
370 $(OBJDIR)/pqueue.o \
371 $(OBJDIR)/printf.o \
372 $(OBJDIR)/publish.o \
@@ -462,11 +477,12 @@
462 -DSQLITE_THREADSAFE=0 \
463 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
464 -DSQLITE_OMIT_DEPRECATED \
465 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
466 -DSQLITE_ENABLE_FTS4 \
467 -DSQLITE_ENABLE_FTS3_PARENTHESIS
 
468
469 # Setup the options used to compile the included SQLite shell.
470 SHELL_OPTIONS = -Dmain=sqlite3_shell \
471 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
472 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -594,10 +610,11 @@
594 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
595 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
596 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
597 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
598 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
 
599 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
600 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
601 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
602 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
603 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1222,10 +1239,18 @@
1222
1223 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1224 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1225
1226 $(OBJDIR)/path.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
1227
1228 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(OBJDIR)/translate
1229 $(OBJDIR)/translate $(SRCDIR)/pivot.c >$@
1230
1231 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
1232
--- src/main.mk
+++ src/main.mk
@@ -84,10 +84,11 @@
84 $(SRCDIR)/merge.c \
85 $(SRCDIR)/merge3.c \
86 $(SRCDIR)/moderate.c \
87 $(SRCDIR)/name.c \
88 $(SRCDIR)/path.c \
89 $(SRCDIR)/piechart.c \
90 $(SRCDIR)/pivot.c \
91 $(SRCDIR)/popen.c \
92 $(SRCDIR)/pqueue.c \
93 $(SRCDIR)/printf.c \
94 $(SRCDIR)/publish.c \
@@ -132,43 +133,55 @@
133 $(SRCDIR)/xfer.c \
134 $(SRCDIR)/xfersetup.c \
135 $(SRCDIR)/zip.c
136
137 EXTRA_FILES = \
138 $(SRCDIR)/../skins/aht/details.txt \
139 $(SRCDIR)/../skins/black_and_white/css.txt \
140 $(SRCDIR)/../skins/black_and_white/details.txt \
141 $(SRCDIR)/../skins/black_and_white/footer.txt \
142 $(SRCDIR)/../skins/black_and_white/header.txt \
143 $(SRCDIR)/../skins/blitz/css.txt \
144 $(SRCDIR)/../skins/blitz/details.txt \
145 $(SRCDIR)/../skins/blitz/footer.txt \
146 $(SRCDIR)/../skins/blitz/header.txt \
147 $(SRCDIR)/../skins/blitz/ticket.txt \
148 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
149 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
150 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
151 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
152 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
153 $(SRCDIR)/../skins/default/css.txt \
154 $(SRCDIR)/../skins/default/details.txt \
155 $(SRCDIR)/../skins/default/footer.txt \
156 $(SRCDIR)/../skins/default/header.txt \
157 $(SRCDIR)/../skins/eagle/css.txt \
158 $(SRCDIR)/../skins/eagle/details.txt \
159 $(SRCDIR)/../skins/eagle/footer.txt \
160 $(SRCDIR)/../skins/eagle/header.txt \
161 $(SRCDIR)/../skins/enhanced1/css.txt \
162 $(SRCDIR)/../skins/enhanced1/details.txt \
163 $(SRCDIR)/../skins/enhanced1/footer.txt \
164 $(SRCDIR)/../skins/enhanced1/header.txt \
165 $(SRCDIR)/../skins/khaki/css.txt \
166 $(SRCDIR)/../skins/khaki/details.txt \
167 $(SRCDIR)/../skins/khaki/footer.txt \
168 $(SRCDIR)/../skins/khaki/header.txt \
169 $(SRCDIR)/../skins/original/css.txt \
170 $(SRCDIR)/../skins/original/details.txt \
171 $(SRCDIR)/../skins/original/footer.txt \
172 $(SRCDIR)/../skins/original/header.txt \
173 $(SRCDIR)/../skins/plain_gray/css.txt \
174 $(SRCDIR)/../skins/plain_gray/details.txt \
175 $(SRCDIR)/../skins/plain_gray/footer.txt \
176 $(SRCDIR)/../skins/plain_gray/header.txt \
177 $(SRCDIR)/../skins/rounded1/css.txt \
178 $(SRCDIR)/../skins/rounded1/details.txt \
179 $(SRCDIR)/../skins/rounded1/footer.txt \
180 $(SRCDIR)/../skins/rounded1/header.txt \
181 $(SRCDIR)/../skins/xekri/css.txt \
182 $(SRCDIR)/../skins/xekri/details.txt \
183 $(SRCDIR)/../skins/xekri/footer.txt \
184 $(SRCDIR)/../skins/xekri/header.txt \
185 $(SRCDIR)/diff.tcl \
186 $(SRCDIR)/markdown.md
187
@@ -243,10 +256,11 @@
256 $(OBJDIR)/merge_.c \
257 $(OBJDIR)/merge3_.c \
258 $(OBJDIR)/moderate_.c \
259 $(OBJDIR)/name_.c \
260 $(OBJDIR)/path_.c \
261 $(OBJDIR)/piechart_.c \
262 $(OBJDIR)/pivot_.c \
263 $(OBJDIR)/popen_.c \
264 $(OBJDIR)/pqueue_.c \
265 $(OBJDIR)/printf_.c \
266 $(OBJDIR)/publish_.c \
@@ -363,10 +377,11 @@
377 $(OBJDIR)/merge.o \
378 $(OBJDIR)/merge3.o \
379 $(OBJDIR)/moderate.o \
380 $(OBJDIR)/name.o \
381 $(OBJDIR)/path.o \
382 $(OBJDIR)/piechart.o \
383 $(OBJDIR)/pivot.o \
384 $(OBJDIR)/popen.o \
385 $(OBJDIR)/pqueue.o \
386 $(OBJDIR)/printf.o \
387 $(OBJDIR)/publish.o \
@@ -462,11 +477,12 @@
477 -DSQLITE_THREADSAFE=0 \
478 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
479 -DSQLITE_OMIT_DEPRECATED \
480 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
481 -DSQLITE_ENABLE_FTS4 \
482 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
483 -DSQLITE_ENABLE_DBSTAT_VTAB
484
485 # Setup the options used to compile the included SQLite shell.
486 SHELL_OPTIONS = -Dmain=sqlite3_shell \
487 -DSQLITE_OMIT_LOAD_EXTENSION=1 \
488 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -594,10 +610,11 @@
610 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
611 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
612 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
613 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
614 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
615 $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
616 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
617 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
618 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
619 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
620 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1222,10 +1239,18 @@
1239
1240 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1241 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1242
1243 $(OBJDIR)/path.h: $(OBJDIR)/headers
1244
1245 $(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(OBJDIR)/translate
1246 $(OBJDIR)/translate $(SRCDIR)/piechart.c >$@
1247
1248 $(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1249 $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1250
1251 $(OBJDIR)/piechart.h: $(OBJDIR)/headers
1252
1253 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(OBJDIR)/translate
1254 $(OBJDIR)/translate $(SRCDIR)/pivot.c >$@
1255
1256 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
1257
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -90,10 +90,11 @@
9090
merge
9191
merge3
9292
moderate
9393
name
9494
path
95
+ piechart
9596
pivot
9697
popen
9798
pqueue
9899
printf
99100
publish
@@ -159,10 +160,11 @@
159160
-DSQLITE_DEFAULT_FILE_FORMAT=4
160161
-DSQLITE_OMIT_DEPRECATED
161162
-DSQLITE_ENABLE_EXPLAIN_COMMENTS
162163
-DSQLITE_ENABLE_FTS4
163164
-DSQLITE_ENABLE_FTS3_PARENTHESIS
165
+ -DSQLITE_ENABLE_DBSTAT_VTAB
164166
}
165167
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
166168
#lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
167169
#lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
168170
#lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
@@ -493,10 +495,14 @@
493495
494496
#### Automatically build OpenSSL when building Fossil (causes rebuild
495497
# issues when building incrementally).
496498
#
497499
# FOSSIL_BUILD_SSL = 1
500
+
501
+#### Enable legacy treatment of mv/rm (skip checkout files)
502
+#
503
+# FOSSIL_ENABLE_LEGACY_MV_RM = 1
498504
499505
#### Enable TH1 scripts in embedded documentation files
500506
#
501507
# FOSSIL_ENABLE_TH1_DOCS = 1
502508
@@ -692,10 +698,16 @@
692698
# With HTTPS support
693699
ifdef FOSSIL_ENABLE_SSL
694700
TCC += -DFOSSIL_ENABLE_SSL=1
695701
RCC += -DFOSSIL_ENABLE_SSL=1
696702
endif
703
+
704
+# With legacy treatment of mv/rm
705
+ifdef FOSSIL_ENABLE_LEGACY_MV_RM
706
+TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
707
+RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
708
+endif
697709
698710
# With TH1 embedded docs support
699711
ifdef FOSSIL_ENABLE_TH1_DOCS
700712
TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
701713
RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -1309,10 +1321,13 @@
13091321
# Uncomment to enable SSL support
13101322
# FOSSIL_ENABLE_SSL = 1
13111323
13121324
# Uncomment to build SSL libraries
13131325
# FOSSIL_BUILD_SSL = 1
1326
+
1327
+# Uncomment to enable legacy treatment of mv/rm
1328
+# FOSSIL_ENABLE_LEGACY_MV_RM = 1
13141329
13151330
# Uncomment to enable TH1 scripts in embedded documentation files
13161331
# FOSSIL_ENABLE_TH1_DOCS = 1
13171332
13181333
# Uncomment to enable TH1 hooks
@@ -1425,10 +1440,15 @@
14251440
TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
14261441
RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
14271442
LIBS = $(LIBS) $(SSLLIB)
14281443
LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
14291444
!endif
1445
+
1446
+!ifdef FOSSIL_ENABLE_LEGACY_MV_RM
1447
+TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
1448
+RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
1449
+!endif
14301450
14311451
!ifdef FOSSIL_ENABLE_TH1_DOCS
14321452
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
14331453
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
14341454
!endif
14351455
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -90,10 +90,11 @@
90 merge
91 merge3
92 moderate
93 name
94 path
 
95 pivot
96 popen
97 pqueue
98 printf
99 publish
@@ -159,10 +160,11 @@
159 -DSQLITE_DEFAULT_FILE_FORMAT=4
160 -DSQLITE_OMIT_DEPRECATED
161 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
162 -DSQLITE_ENABLE_FTS4
163 -DSQLITE_ENABLE_FTS3_PARENTHESIS
 
164 }
165 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
166 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
167 #lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
168 #lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
@@ -493,10 +495,14 @@
493
494 #### Automatically build OpenSSL when building Fossil (causes rebuild
495 # issues when building incrementally).
496 #
497 # FOSSIL_BUILD_SSL = 1
 
 
 
 
498
499 #### Enable TH1 scripts in embedded documentation files
500 #
501 # FOSSIL_ENABLE_TH1_DOCS = 1
502
@@ -692,10 +698,16 @@
692 # With HTTPS support
693 ifdef FOSSIL_ENABLE_SSL
694 TCC += -DFOSSIL_ENABLE_SSL=1
695 RCC += -DFOSSIL_ENABLE_SSL=1
696 endif
 
 
 
 
 
 
697
698 # With TH1 embedded docs support
699 ifdef FOSSIL_ENABLE_TH1_DOCS
700 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
701 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -1309,10 +1321,13 @@
1309 # Uncomment to enable SSL support
1310 # FOSSIL_ENABLE_SSL = 1
1311
1312 # Uncomment to build SSL libraries
1313 # FOSSIL_BUILD_SSL = 1
 
 
 
1314
1315 # Uncomment to enable TH1 scripts in embedded documentation files
1316 # FOSSIL_ENABLE_TH1_DOCS = 1
1317
1318 # Uncomment to enable TH1 hooks
@@ -1425,10 +1440,15 @@
1425 TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
1426 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
1427 LIBS = $(LIBS) $(SSLLIB)
1428 LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
1429 !endif
 
 
 
 
 
1430
1431 !ifdef FOSSIL_ENABLE_TH1_DOCS
1432 TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
1433 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
1434 !endif
1435
--- src/makemake.tcl
+++ src/makemake.tcl
@@ -90,10 +90,11 @@
90 merge
91 merge3
92 moderate
93 name
94 path
95 piechart
96 pivot
97 popen
98 pqueue
99 printf
100 publish
@@ -159,10 +160,11 @@
160 -DSQLITE_DEFAULT_FILE_FORMAT=4
161 -DSQLITE_OMIT_DEPRECATED
162 -DSQLITE_ENABLE_EXPLAIN_COMMENTS
163 -DSQLITE_ENABLE_FTS4
164 -DSQLITE_ENABLE_FTS3_PARENTHESIS
165 -DSQLITE_ENABLE_DBSTAT_VTAB
166 }
167 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_FTS3=1
168 #lappend SQLITE_OPTIONS -DSQLITE_ENABLE_STAT4
169 #lappend SQLITE_OPTIONS -DSQLITE_WIN32_NO_ANSI
170 #lappend SQLITE_OPTIONS -DSQLITE_WINNT_MAX_PATH_CHARS=4096
@@ -493,10 +495,14 @@
495
496 #### Automatically build OpenSSL when building Fossil (causes rebuild
497 # issues when building incrementally).
498 #
499 # FOSSIL_BUILD_SSL = 1
500
501 #### Enable legacy treatment of mv/rm (skip checkout files)
502 #
503 # FOSSIL_ENABLE_LEGACY_MV_RM = 1
504
505 #### Enable TH1 scripts in embedded documentation files
506 #
507 # FOSSIL_ENABLE_TH1_DOCS = 1
508
@@ -692,10 +698,16 @@
698 # With HTTPS support
699 ifdef FOSSIL_ENABLE_SSL
700 TCC += -DFOSSIL_ENABLE_SSL=1
701 RCC += -DFOSSIL_ENABLE_SSL=1
702 endif
703
704 # With legacy treatment of mv/rm
705 ifdef FOSSIL_ENABLE_LEGACY_MV_RM
706 TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
707 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
708 endif
709
710 # With TH1 embedded docs support
711 ifdef FOSSIL_ENABLE_TH1_DOCS
712 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
713 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -1309,10 +1321,13 @@
1321 # Uncomment to enable SSL support
1322 # FOSSIL_ENABLE_SSL = 1
1323
1324 # Uncomment to build SSL libraries
1325 # FOSSIL_BUILD_SSL = 1
1326
1327 # Uncomment to enable legacy treatment of mv/rm
1328 # FOSSIL_ENABLE_LEGACY_MV_RM = 1
1329
1330 # Uncomment to enable TH1 scripts in embedded documentation files
1331 # FOSSIL_ENABLE_TH1_DOCS = 1
1332
1333 # Uncomment to enable TH1 hooks
@@ -1425,10 +1440,15 @@
1440 TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
1441 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
1442 LIBS = $(LIBS) $(SSLLIB)
1443 LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
1444 !endif
1445
1446 !ifdef FOSSIL_ENABLE_LEGACY_MV_RM
1447 TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
1448 RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
1449 !endif
1450
1451 !ifdef FOSSIL_ENABLE_TH1_DOCS
1452 TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
1453 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
1454 !endif
1455
+3 -3
--- src/manifest.c
+++ src/manifest.c
@@ -1344,10 +1344,11 @@
13441344
** A single mlink entry is added for every file that changed content,
13451345
** name, and/or permissions going from pid to cid.
13461346
**
13471347
** Deleted files have mlink.fid=0.
13481348
** Added files have mlink.pid=0.
1349
+** File added by merge have mlink.pid=-1
13491350
** Edited files have both mlink.pid!=0 and mlink.fid!=0
13501351
*/
13511352
static void add_mlink(
13521353
int pmid, Manifest *pParent, /* Parent check-in */
13531354
int mid, Manifest *pChild, /* The child check-in */
@@ -1801,14 +1802,13 @@
18011802
pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/);
18021803
add_mlink(pid, 0, rid, p, i==0);
18031804
if( i==0 ) parentid = pid;
18041805
}
18051806
if( p->nParent>1 ){
1806
- /* Remove incorrect MLINK create-file entries that arise when a
1807
- ** file is added by merge. */
1807
+ /* Change MLINK.PID from 0 to -1 for files that are added by merge. */
18081808
db_multi_exec(
1809
- "DELETE FROM mlink"
1809
+ "UPDATE mlink SET pid=-1"
18101810
" WHERE mid=%d"
18111811
" AND pid=0"
18121812
" AND fnid IN "
18131813
" (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid"
18141814
" HAVING count(*)<%d)",
18151815
--- src/manifest.c
+++ src/manifest.c
@@ -1344,10 +1344,11 @@
1344 ** A single mlink entry is added for every file that changed content,
1345 ** name, and/or permissions going from pid to cid.
1346 **
1347 ** Deleted files have mlink.fid=0.
1348 ** Added files have mlink.pid=0.
 
1349 ** Edited files have both mlink.pid!=0 and mlink.fid!=0
1350 */
1351 static void add_mlink(
1352 int pmid, Manifest *pParent, /* Parent check-in */
1353 int mid, Manifest *pChild, /* The child check-in */
@@ -1801,14 +1802,13 @@
1801 pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/);
1802 add_mlink(pid, 0, rid, p, i==0);
1803 if( i==0 ) parentid = pid;
1804 }
1805 if( p->nParent>1 ){
1806 /* Remove incorrect MLINK create-file entries that arise when a
1807 ** file is added by merge. */
1808 db_multi_exec(
1809 "DELETE FROM mlink"
1810 " WHERE mid=%d"
1811 " AND pid=0"
1812 " AND fnid IN "
1813 " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid"
1814 " HAVING count(*)<%d)",
1815
--- src/manifest.c
+++ src/manifest.c
@@ -1344,10 +1344,11 @@
1344 ** A single mlink entry is added for every file that changed content,
1345 ** name, and/or permissions going from pid to cid.
1346 **
1347 ** Deleted files have mlink.fid=0.
1348 ** Added files have mlink.pid=0.
1349 ** File added by merge have mlink.pid=-1
1350 ** Edited files have both mlink.pid!=0 and mlink.fid!=0
1351 */
1352 static void add_mlink(
1353 int pmid, Manifest *pParent, /* Parent check-in */
1354 int mid, Manifest *pChild, /* The child check-in */
@@ -1801,14 +1802,13 @@
1802 pid, rid, i==0, p->rDate, zBaseId/*safe-for-%s*/);
1803 add_mlink(pid, 0, rid, p, i==0);
1804 if( i==0 ) parentid = pid;
1805 }
1806 if( p->nParent>1 ){
1807 /* Change MLINK.PID from 0 to -1 for files that are added by merge. */
 
1808 db_multi_exec(
1809 "UPDATE mlink SET pid=-1"
1810 " WHERE mid=%d"
1811 " AND pid=0"
1812 " AND fnid IN "
1813 " (SELECT fnid FROM mlink WHERE mid=%d GROUP BY fnid"
1814 " HAVING count(*)<%d)",
1815
+76 -17
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,85 @@
5353
fossil_free(zCom);
5454
}
5555
db_finalize(&q);
5656
}
5757
58
+
59
+/* Pick the most recent leaf that is (1) not equal to vid and (2)
60
+** has not already been merged into vid and (3) the leaf is not
61
+** closed and (4) the leaf is in the same branch as vid.
62
+**
63
+** Set vmergeFlag to control whether the vmerge table is checked.
64
+*/
65
+int fossil_find_nearest_fork(int vid, int vmergeFlag){
66
+ Blob sql;
67
+ Stmt q;
68
+ int rid = 0;
69
+
70
+ blob_zero(&sql);
71
+ blob_append_sql(&sql,
72
+ "SELECT leaf.rid"
73
+ " FROM leaf, event"
74
+ " WHERE leaf.rid=event.objid"
75
+ " AND leaf.rid!=%d", /* Constraint (1) */
76
+ vid
77
+ );
78
+ if( vmergeFlag ){
79
+ blob_append_sql(&sql,
80
+ " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
81
+ );
82
+ }
83
+ blob_append_sql(&sql,
84
+ " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
85
+ " WHERE rid=leaf.rid"
86
+ " AND tagid=%d"
87
+ " AND tagtype>0)"
88
+ " AND (SELECT value FROM tagxref" /* Constraint (4) */
89
+ " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
90
+ " (SELECT value FROM tagxref"
91
+ " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
92
+ " ORDER BY event.mtime DESC LIMIT 1",
93
+ TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
94
+ );
95
+ db_prepare(&q, "%s", blob_sql_text(&sql));
96
+ blob_reset(&sql);
97
+ if( db_step(&q)==SQLITE_ROW ){
98
+ rid = db_column_int(&q, 0);
99
+ }
100
+ db_finalize(&q);
101
+ return rid;
102
+}
103
+
104
+/*
105
+** Check content that was received with rcvid and return true if any
106
+** fork was created.
107
+*/
108
+int fossil_any_has_fork(int rcvid){
109
+ static Stmt q;
110
+ int fForkSeen = 0;
111
+
112
+ if( rcvid==0 ) return 0;
113
+ db_static_prepare(&q,
114
+ " SELECT pid FROM plink WHERE pid>0 AND isprim"
115
+ " AND cid IN (SELECT blob.rid FROM blob"
116
+ " WHERE rcvid=:rcvid)");
117
+ db_bind_int(&q, ":rcvid", rcvid);
118
+ while( !fForkSeen && db_step(&q)==SQLITE_ROW ){
119
+ int pid = db_column_int(&q, 0);
120
+ if( count_nonbranch_children(pid)>1 ){
121
+ compute_leaves(pid,1);
122
+ if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
123
+ int rid = db_int(0, "SELECT rid FROM leaves, event"
124
+ " WHERE event.objid=leaves.rid"
125
+ " ORDER BY event.mtime DESC LIMIT 1");
126
+ fForkSeen = fossil_find_nearest_fork(rid, db_open_local(0))!=0;
127
+ }
128
+ }
129
+ }
130
+ db_finalize(&q);
131
+ return fForkSeen;
132
+}
58133
59134
/*
60135
** COMMAND: merge
61136
**
62137
** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +247,11 @@
172247
*/
173248
Stmt q;
174249
if( pickFlag || backoutFlag || integrateFlag){
175250
fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
176251
}
177
- mid = db_int(0,
178
- "SELECT leaf.rid"
179
- " FROM leaf, event"
180
- " WHERE leaf.rid=event.objid"
181
- " AND leaf.rid!=%d" /* Constraint (1) */
182
- " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
183
- " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
184
- " WHERE rid=leaf.rid"
185
- " AND tagid=%d"
186
- " AND tagtype>0)"
187
- " AND (SELECT value FROM tagxref" /* Constraint (4) */
188
- " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
189
- " (SELECT value FROM tagxref"
190
- " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
191
- " ORDER BY event.mtime DESC LIMIT 1",
192
- vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
193
- );
252
+ mid = fossil_find_nearest_fork(vid, db_open_local(0));
194253
if( mid==0 ){
195254
fossil_fatal("no unmerged forks of branch \"%s\"",
196255
db_text(0, "SELECT value FROM tagxref"
197256
" WHERE tagid=%d AND rid=%d AND tagtype>0",
198257
TAG_BRANCH, vid)
199258
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,85 @@
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
59 /*
60 ** COMMAND: merge
61 **
62 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +247,11 @@
172 */
173 Stmt q;
174 if( pickFlag || backoutFlag || integrateFlag){
175 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
176 }
177 mid = db_int(0,
178 "SELECT leaf.rid"
179 " FROM leaf, event"
180 " WHERE leaf.rid=event.objid"
181 " AND leaf.rid!=%d" /* Constraint (1) */
182 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
183 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
184 " WHERE rid=leaf.rid"
185 " AND tagid=%d"
186 " AND tagtype>0)"
187 " AND (SELECT value FROM tagxref" /* Constraint (4) */
188 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
189 " (SELECT value FROM tagxref"
190 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
191 " ORDER BY event.mtime DESC LIMIT 1",
192 vid, TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
193 );
194 if( mid==0 ){
195 fossil_fatal("no unmerged forks of branch \"%s\"",
196 db_text(0, "SELECT value FROM tagxref"
197 " WHERE tagid=%d AND rid=%d AND tagtype>0",
198 TAG_BRANCH, vid)
199
--- src/merge.c
+++ src/merge.c
@@ -53,10 +53,85 @@
53 fossil_free(zCom);
54 }
55 db_finalize(&q);
56 }
57
58
59 /* Pick the most recent leaf that is (1) not equal to vid and (2)
60 ** has not already been merged into vid and (3) the leaf is not
61 ** closed and (4) the leaf is in the same branch as vid.
62 **
63 ** Set vmergeFlag to control whether the vmerge table is checked.
64 */
65 int fossil_find_nearest_fork(int vid, int vmergeFlag){
66 Blob sql;
67 Stmt q;
68 int rid = 0;
69
70 blob_zero(&sql);
71 blob_append_sql(&sql,
72 "SELECT leaf.rid"
73 " FROM leaf, event"
74 " WHERE leaf.rid=event.objid"
75 " AND leaf.rid!=%d", /* Constraint (1) */
76 vid
77 );
78 if( vmergeFlag ){
79 blob_append_sql(&sql,
80 " AND leaf.rid NOT IN (SELECT merge FROM vmerge)" /* Constraint (2) */
81 );
82 }
83 blob_append_sql(&sql,
84 " AND NOT EXISTS(SELECT 1 FROM tagxref" /* Constraint (3) */
85 " WHERE rid=leaf.rid"
86 " AND tagid=%d"
87 " AND tagtype>0)"
88 " AND (SELECT value FROM tagxref" /* Constraint (4) */
89 " WHERE tagid=%d AND rid=%d AND tagtype>0) ="
90 " (SELECT value FROM tagxref"
91 " WHERE tagid=%d AND rid=leaf.rid AND tagtype>0)"
92 " ORDER BY event.mtime DESC LIMIT 1",
93 TAG_CLOSED, TAG_BRANCH, vid, TAG_BRANCH
94 );
95 db_prepare(&q, "%s", blob_sql_text(&sql));
96 blob_reset(&sql);
97 if( db_step(&q)==SQLITE_ROW ){
98 rid = db_column_int(&q, 0);
99 }
100 db_finalize(&q);
101 return rid;
102 }
103
104 /*
105 ** Check content that was received with rcvid and return true if any
106 ** fork was created.
107 */
108 int fossil_any_has_fork(int rcvid){
109 static Stmt q;
110 int fForkSeen = 0;
111
112 if( rcvid==0 ) return 0;
113 db_static_prepare(&q,
114 " SELECT pid FROM plink WHERE pid>0 AND isprim"
115 " AND cid IN (SELECT blob.rid FROM blob"
116 " WHERE rcvid=:rcvid)");
117 db_bind_int(&q, ":rcvid", rcvid);
118 while( !fForkSeen && db_step(&q)==SQLITE_ROW ){
119 int pid = db_column_int(&q, 0);
120 if( count_nonbranch_children(pid)>1 ){
121 compute_leaves(pid,1);
122 if( db_int(0, "SELECT count(*) FROM leaves")>1 ){
123 int rid = db_int(0, "SELECT rid FROM leaves, event"
124 " WHERE event.objid=leaves.rid"
125 " ORDER BY event.mtime DESC LIMIT 1");
126 fForkSeen = fossil_find_nearest_fork(rid, db_open_local(0))!=0;
127 }
128 }
129 }
130 db_finalize(&q);
131 return fForkSeen;
132 }
133
134 /*
135 ** COMMAND: merge
136 **
137 ** Usage: %fossil merge ?OPTIONS? ?VERSION?
@@ -172,27 +247,11 @@
247 */
248 Stmt q;
249 if( pickFlag || backoutFlag || integrateFlag){
250 fossil_fatal("cannot use --backout, --cherrypick or --integrate with a fork merge");
251 }
252 mid = fossil_find_nearest_fork(vid, db_open_local(0));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
253 if( mid==0 ){
254 fossil_fatal("no unmerged forks of branch \"%s\"",
255 db_text(0, "SELECT value FROM tagxref"
256 " WHERE tagid=%d AND rid=%d AND tagtype>0",
257 TAG_BRANCH, vid)
258
+1 -1
--- src/merge3.c
+++ src/merge3.c
@@ -260,11 +260,11 @@
260260
i2 += 3;
261261
}else
262262
{
263263
/* We have found a region where different edits to V1 and V2 overlap.
264264
** This is a merge conflict. Find the size of the conflict, then
265
- ** output both possible edits separate by distinctive marks.
265
+ ** output both possible edits separated by distinctive marks.
266266
*/
267267
int sz = 1; /* Size of the conflict in lines */
268268
nConflict++;
269269
while( !ends_at_CPY(&aC1[i1], sz) || !ends_at_CPY(&aC2[i2], sz) ){
270270
sz++;
271271
--- src/merge3.c
+++ src/merge3.c
@@ -260,11 +260,11 @@
260 i2 += 3;
261 }else
262 {
263 /* We have found a region where different edits to V1 and V2 overlap.
264 ** This is a merge conflict. Find the size of the conflict, then
265 ** output both possible edits separate by distinctive marks.
266 */
267 int sz = 1; /* Size of the conflict in lines */
268 nConflict++;
269 while( !ends_at_CPY(&aC1[i1], sz) || !ends_at_CPY(&aC2[i2], sz) ){
270 sz++;
271
--- src/merge3.c
+++ src/merge3.c
@@ -260,11 +260,11 @@
260 i2 += 3;
261 }else
262 {
263 /* We have found a region where different edits to V1 and V2 overlap.
264 ** This is a merge conflict. Find the size of the conflict, then
265 ** output both possible edits separated by distinctive marks.
266 */
267 int sz = 1; /* Size of the conflict in lines */
268 nConflict++;
269 while( !ends_at_CPY(&aC1[i1], sz) || !ends_at_CPY(&aC2[i2], sz) ){
270 sz++;
271
+28 -10
--- src/name.c
+++ src/name.c
@@ -1068,29 +1068,26 @@
10681068
10691069
/* Maximum number of collision examples to remember */
10701070
#define MAX_COLLIDE 25
10711071
10721072
/*
1073
-** WEBPAGE: hash-collisions
1074
-**
1075
-** Show the number of hash collisions for hash prefixes of various lengths.
1073
+** Generate a report on the number of collisions in SHA1 hashes
1074
+** generated by the SQL given in the argument.
10761075
*/
1077
-void hash_collisions_webpage(void){
1076
+static void collision_report(const char *zSql){
10781077
int i, j, kk;
10791078
int nHash = 0;
10801079
Stmt q;
10811080
char zPrev[UUID_SIZE+1];
10821081
struct {
10831082
int cnt;
10841083
char *azHit[MAX_COLLIDE];
10851084
char z[UUID_SIZE+1];
10861085
} aCollide[UUID_SIZE+1];
1087
- login_check_credentials();
1088
- if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
10891086
memset(aCollide, 0, sizeof(aCollide));
10901087
memset(zPrev, 0, sizeof(zPrev));
1091
- db_prepare(&q,"SELECT uuid FROM blob ORDER BY 1");
1088
+ db_prepare(&q,"%s",zSql/*safe-for-%s*/);
10921089
while( db_step(&q)==SQLITE_ROW ){
10931090
const char *zUuid = db_column_text(&q,0);
10941091
int n = db_column_bytes(&q,0);
10951092
int i;
10961093
nHash++;
@@ -1103,13 +1100,10 @@
11031100
if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
11041101
}
11051102
memcpy(zPrev, zUuid, n+1);
11061103
}
11071104
db_finalize(&q);
1108
- style_header("SHA1 Prefix Collisions");
1109
- style_submenu_element("Activity Reports", 0, "reports");
1110
- style_submenu_element("Stats", 0, "stat");
11111105
@ <table border=1><thead>
11121106
@ <tr><th>Length<th>Instances<th>First Instance</tr>
11131107
@ </thead><tbody>
11141108
for(i=1; i<=UUID_SIZE; i++){
11151109
if( aCollide[i].cnt==0 ) continue;
@@ -1131,7 +1125,31 @@
11311125
char *zId = aCollide[i].azHit[j];
11321126
if( zId==0 ) continue;
11331127
@ %z(href("%R/whatis/%s",zId))%h(zId)</a>
11341128
}
11351129
}
1130
+ for(i=4; i<ArraySize(aCollide); i++){
1131
+ for(j=0; j<aCollide[i].cnt && j<MAX_COLLIDE; j++){
1132
+ fossil_free(aCollide[i].azHit[j]);
1133
+ }
1134
+ }
1135
+}
1136
+
1137
+/*
1138
+** WEBPAGE: hash-collisions
1139
+**
1140
+** Show the number of hash collisions for hash prefixes of various lengths.
1141
+*/
1142
+void hash_collisions_webpage(void){
1143
+ login_check_credentials();
1144
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1145
+ style_header("SHA1 Prefix Collisions");
1146
+ style_submenu_element("Activity Reports", 0, "reports");
1147
+ style_submenu_element("Stats", 0, "stat");
1148
+ @ <h1>Hash Prefix Collisions on Check-ins</h1>
1149
+ collision_report("SELECT (SELECT uuid FROM blob WHERE rid=objid)"
1150
+ " FROM event WHERE event.type='ci'"
1151
+ " ORDER BY 1");
1152
+ @ <h1>Hash Prefix Collisions on All Artifacts</h1>
1153
+ collision_report("SELECT uuid FROM blob ORDER BY 1");
11361154
style_footer();
11371155
}
11381156
11391157
ADDED src/piechart.c
--- src/name.c
+++ src/name.c
@@ -1068,29 +1068,26 @@
1068
1069 /* Maximum number of collision examples to remember */
1070 #define MAX_COLLIDE 25
1071
1072 /*
1073 ** WEBPAGE: hash-collisions
1074 **
1075 ** Show the number of hash collisions for hash prefixes of various lengths.
1076 */
1077 void hash_collisions_webpage(void){
1078 int i, j, kk;
1079 int nHash = 0;
1080 Stmt q;
1081 char zPrev[UUID_SIZE+1];
1082 struct {
1083 int cnt;
1084 char *azHit[MAX_COLLIDE];
1085 char z[UUID_SIZE+1];
1086 } aCollide[UUID_SIZE+1];
1087 login_check_credentials();
1088 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1089 memset(aCollide, 0, sizeof(aCollide));
1090 memset(zPrev, 0, sizeof(zPrev));
1091 db_prepare(&q,"SELECT uuid FROM blob ORDER BY 1");
1092 while( db_step(&q)==SQLITE_ROW ){
1093 const char *zUuid = db_column_text(&q,0);
1094 int n = db_column_bytes(&q,0);
1095 int i;
1096 nHash++;
@@ -1103,13 +1100,10 @@
1103 if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
1104 }
1105 memcpy(zPrev, zUuid, n+1);
1106 }
1107 db_finalize(&q);
1108 style_header("SHA1 Prefix Collisions");
1109 style_submenu_element("Activity Reports", 0, "reports");
1110 style_submenu_element("Stats", 0, "stat");
1111 @ <table border=1><thead>
1112 @ <tr><th>Length<th>Instances<th>First Instance</tr>
1113 @ </thead><tbody>
1114 for(i=1; i<=UUID_SIZE; i++){
1115 if( aCollide[i].cnt==0 ) continue;
@@ -1131,7 +1125,31 @@
1131 char *zId = aCollide[i].azHit[j];
1132 if( zId==0 ) continue;
1133 @ %z(href("%R/whatis/%s",zId))%h(zId)</a>
1134 }
1135 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1136 style_footer();
1137 }
1138
1139 DDED src/piechart.c
--- src/name.c
+++ src/name.c
@@ -1068,29 +1068,26 @@
1068
1069 /* Maximum number of collision examples to remember */
1070 #define MAX_COLLIDE 25
1071
1072 /*
1073 ** Generate a report on the number of collisions in SHA1 hashes
1074 ** generated by the SQL given in the argument.
 
1075 */
1076 static void collision_report(const char *zSql){
1077 int i, j, kk;
1078 int nHash = 0;
1079 Stmt q;
1080 char zPrev[UUID_SIZE+1];
1081 struct {
1082 int cnt;
1083 char *azHit[MAX_COLLIDE];
1084 char z[UUID_SIZE+1];
1085 } aCollide[UUID_SIZE+1];
 
 
1086 memset(aCollide, 0, sizeof(aCollide));
1087 memset(zPrev, 0, sizeof(zPrev));
1088 db_prepare(&q,"%s",zSql/*safe-for-%s*/);
1089 while( db_step(&q)==SQLITE_ROW ){
1090 const char *zUuid = db_column_text(&q,0);
1091 int n = db_column_bytes(&q,0);
1092 int i;
1093 nHash++;
@@ -1103,13 +1100,10 @@
1100 if( aCollide[i].z[0]==0 ) memcpy(aCollide[i].z, zPrev, n+1);
1101 }
1102 memcpy(zPrev, zUuid, n+1);
1103 }
1104 db_finalize(&q);
 
 
 
1105 @ <table border=1><thead>
1106 @ <tr><th>Length<th>Instances<th>First Instance</tr>
1107 @ </thead><tbody>
1108 for(i=1; i<=UUID_SIZE; i++){
1109 if( aCollide[i].cnt==0 ) continue;
@@ -1131,7 +1125,31 @@
1125 char *zId = aCollide[i].azHit[j];
1126 if( zId==0 ) continue;
1127 @ %z(href("%R/whatis/%s",zId))%h(zId)</a>
1128 }
1129 }
1130 for(i=4; i<ArraySize(aCollide); i++){
1131 for(j=0; j<aCollide[i].cnt && j<MAX_COLLIDE; j++){
1132 fossil_free(aCollide[i].azHit[j]);
1133 }
1134 }
1135 }
1136
1137 /*
1138 ** WEBPAGE: hash-collisions
1139 **
1140 ** Show the number of hash collisions for hash prefixes of various lengths.
1141 */
1142 void hash_collisions_webpage(void){
1143 login_check_credentials();
1144 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
1145 style_header("SHA1 Prefix Collisions");
1146 style_submenu_element("Activity Reports", 0, "reports");
1147 style_submenu_element("Stats", 0, "stat");
1148 @ <h1>Hash Prefix Collisions on Check-ins</h1>
1149 collision_report("SELECT (SELECT uuid FROM blob WHERE rid=objid)"
1150 " FROM event WHERE event.type='ci'"
1151 " ORDER BY 1");
1152 @ <h1>Hash Prefix Collisions on All Artifacts</h1>
1153 collision_report("SELECT uuid FROM blob ORDER BY 1");
1154 style_footer();
1155 }
1156
1157 DDED src/piechart.c
--- a/src/piechart.c
+++ b/src/piechart.c
@@ -0,0 +1,24 @@
1
+/*
2
+** Copyright (c) 2015 D. Richard Hipp
3
+**
4
+** This program is free software; you can redistribute it and/or
5
+** modify it under the terms o return;test_piecharpiechart_tes, q;
6
+ Bloblob_init(&all, zData, -1);
7
+ whif( blob_token(&line, &token1)==0 ) continue;
8
+ rAmt = atof(blob_str(&token1));
9
+ if( rAmt<=0.0 ) continue;
10
+ blob_tail(&line, &token2blob_str(&token2)n++ins);
11
+ blob_reset(&all);
12
+ if( n>0postOne slice per line. Value and then Label.<p>
13
+ @ <textarea name='data' rows='20' cohidden<input type='hiddenhr /><p>Previous Data:<rowid,");
14
+ while( ){
15
+ @ <tr><td>%d(db_column_int1))</td>
16
+ @ <td>%h(db_c. @ </table>
17
+ style_footer();
18
+}
19
+= stroke="%s(zFg)='%s(zFg)' stroke-width='1*
20
+** Copyright (c) 2015 D. Richard Hipp
21
+**
22
+** This program is free software; you can redistrib (c) 2015 D. Richard Hipp
23
+**
24
+ fill='%s(zFg
--- a/src/piechart.c
+++ b/src/piechart.c
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/src/piechart.c
+++ b/src/piechart.c
@@ -0,0 +1,24 @@
1 /*
2 ** Copyright (c) 2015 D. Richard Hipp
3 **
4 ** This program is free software; you can redistribute it and/or
5 ** modify it under the terms o return;test_piecharpiechart_tes, q;
6 Bloblob_init(&all, zData, -1);
7 whif( blob_token(&line, &token1)==0 ) continue;
8 rAmt = atof(blob_str(&token1));
9 if( rAmt<=0.0 ) continue;
10 blob_tail(&line, &token2blob_str(&token2)n++ins);
11 blob_reset(&all);
12 if( n>0postOne slice per line. Value and then Label.<p>
13 @ <textarea name='data' rows='20' cohidden<input type='hiddenhr /><p>Previous Data:<rowid,");
14 while( ){
15 @ <tr><td>%d(db_column_int1))</td>
16 @ <td>%h(db_c. @ </table>
17 style_footer();
18 }
19 = stroke="%s(zFg)='%s(zFg)' stroke-width='1*
20 ** Copyright (c) 2015 D. Richard Hipp
21 **
22 ** This program is free software; you can redistrib (c) 2015 D. Richard Hipp
23 **
24 fill='%s(zFg
+3 -3
--- src/pivot.c
+++ src/pivot.c
@@ -48,11 +48,11 @@
4848
"DELETE FROM aqueue;"
4949
"CREATE INDEX IF NOT EXISTS aqueue_idx1 ON aqueue(pending, mtime);"
5050
);
5151
5252
/* Insert the primary record */
53
- db_multi_exec(
53
+ db_multi_exec(
5454
"INSERT INTO aqueue(rid, mtime, pending, src)"
5555
" SELECT %d, mtime, 1, 1 FROM event WHERE objid=%d AND type='ci' LIMIT 1",
5656
rid, rid
5757
);
5858
}
@@ -62,11 +62,11 @@
6262
** must be at least one secondary but there can be more than one if
6363
** desired.
6464
*/
6565
void pivot_set_secondary(int rid){
6666
/* Insert the primary record */
67
- db_multi_exec(
67
+ db_multi_exec(
6868
"INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
6969
" SELECT %d, mtime, 1, 0 FROM event WHERE objid=%d AND type='ci'",
7070
rid, rid
7171
);
7272
}
@@ -77,11 +77,11 @@
7777
** can be found.
7878
*/
7979
int pivot_find(void){
8080
Stmt q1, q2, u1, i1;
8181
int rid = 0;
82
-
82
+
8383
/* aqueue must contain at least one primary and one other. Otherwise
8484
** we abort early
8585
*/
8686
if( db_int(0, "SELECT count(distinct src) FROM aqueue")<2 ){
8787
fossil_fatal("lack both primary and secondary files");
8888
--- src/pivot.c
+++ src/pivot.c
@@ -48,11 +48,11 @@
48 "DELETE FROM aqueue;"
49 "CREATE INDEX IF NOT EXISTS aqueue_idx1 ON aqueue(pending, mtime);"
50 );
51
52 /* Insert the primary record */
53 db_multi_exec(
54 "INSERT INTO aqueue(rid, mtime, pending, src)"
55 " SELECT %d, mtime, 1, 1 FROM event WHERE objid=%d AND type='ci' LIMIT 1",
56 rid, rid
57 );
58 }
@@ -62,11 +62,11 @@
62 ** must be at least one secondary but there can be more than one if
63 ** desired.
64 */
65 void pivot_set_secondary(int rid){
66 /* Insert the primary record */
67 db_multi_exec(
68 "INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
69 " SELECT %d, mtime, 1, 0 FROM event WHERE objid=%d AND type='ci'",
70 rid, rid
71 );
72 }
@@ -77,11 +77,11 @@
77 ** can be found.
78 */
79 int pivot_find(void){
80 Stmt q1, q2, u1, i1;
81 int rid = 0;
82
83 /* aqueue must contain at least one primary and one other. Otherwise
84 ** we abort early
85 */
86 if( db_int(0, "SELECT count(distinct src) FROM aqueue")<2 ){
87 fossil_fatal("lack both primary and secondary files");
88
--- src/pivot.c
+++ src/pivot.c
@@ -48,11 +48,11 @@
48 "DELETE FROM aqueue;"
49 "CREATE INDEX IF NOT EXISTS aqueue_idx1 ON aqueue(pending, mtime);"
50 );
51
52 /* Insert the primary record */
53 db_multi_exec(
54 "INSERT INTO aqueue(rid, mtime, pending, src)"
55 " SELECT %d, mtime, 1, 1 FROM event WHERE objid=%d AND type='ci' LIMIT 1",
56 rid, rid
57 );
58 }
@@ -62,11 +62,11 @@
62 ** must be at least one secondary but there can be more than one if
63 ** desired.
64 */
65 void pivot_set_secondary(int rid){
66 /* Insert the primary record */
67 db_multi_exec(
68 "INSERT OR IGNORE INTO aqueue(rid, mtime, pending, src)"
69 " SELECT %d, mtime, 1, 0 FROM event WHERE objid=%d AND type='ci'",
70 rid, rid
71 );
72 }
@@ -77,11 +77,11 @@
77 ** can be found.
78 */
79 int pivot_find(void){
80 Stmt q1, q2, u1, i1;
81 int rid = 0;
82
83 /* aqueue must contain at least one primary and one other. Otherwise
84 ** we abort early
85 */
86 if( db_int(0, "SELECT count(distinct src) FROM aqueue")<2 ){
87 fossil_fatal("lack both primary and secondary files");
88
+6 -6
--- src/popen.c
+++ src/popen.c
@@ -38,11 +38,11 @@
3838
** The following macros are used to cast pointers to integers and
3939
** integers to pointers. The way you do this varies from one compiler
4040
** to the next, so we have developed the following set of #if statements
4141
** to generate appropriate macros for a wide range of compilers.
4242
**
43
-** The correct "ANSI" way to do this is to use the intptr_t type.
43
+** The correct "ANSI" way to do this is to use the intptr_t type.
4444
** Unfortunately, that typedef is not available on all compilers, or
4545
** if it is available, it requires an #include of specific headers
4646
** that vary from one machine to the next.
4747
**
4848
** This code is copied out of SQLite.
@@ -112,11 +112,11 @@
112112
}
113113
#endif
114114
115115
/*
116116
** Create a child process running shell command "zCmd". *ppOut is
117
-** a FILE that becomes the standard input of the child process.
117
+** a FILE that becomes the standard input of the child process.
118118
** (The caller writes to *ppOut in order to send text to the child.)
119119
** *ppIn is stdout from the child process. (The caller
120120
** reads from *ppIn in order to receive input from the child.)
121121
** Note that *ppIn is an unbuffered file descriptor, not a FILE.
122122
** The process ID of the child is written into *pChildPid.
@@ -124,17 +124,17 @@
124124
** Return the number of errors.
125125
*/
126126
int popen2(const char *zCmd, int *pfdIn, FILE **ppOut, int *pChildPid){
127127
#ifdef _WIN32
128128
HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr;
129
- SECURITY_ATTRIBUTES saAttr;
129
+ SECURITY_ATTRIBUTES saAttr;
130130
DWORD childPid = 0;
131131
int fd;
132132
133133
saAttr.nLength = sizeof(saAttr);
134134
saAttr.bInheritHandle = TRUE;
135
- saAttr.lpSecurityDescriptor = NULL;
135
+ saAttr.lpSecurityDescriptor = NULL;
136136
hStderr = GetStdHandle(STD_ERROR_HANDLE);
137137
if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){
138138
win32_fatal_error("cannot create pipe for stdout");
139139
}
140140
SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE);
@@ -141,18 +141,18 @@
141141
142142
if( !CreatePipe(&hStdinRd, &hStdinWr, &saAttr, 4096) ){
143143
win32_fatal_error("cannot create pipe for stdin");
144144
}
145145
SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE);
146
-
146
+
147147
win32_create_child_process(fossil_utf8_to_unicode(zCmd),
148148
hStdinRd, hStdoutWr, hStderr,&childPid);
149149
*pChildPid = childPid;
150150
*pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0);
151151
fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0);
152152
*ppOut = _fdopen(fd, "w");
153
- CloseHandle(hStdinRd);
153
+ CloseHandle(hStdinRd);
154154
CloseHandle(hStdoutWr);
155155
return 0;
156156
#else
157157
int pin[2], pout[2];
158158
*pfdIn = 0;
159159
--- src/popen.c
+++ src/popen.c
@@ -38,11 +38,11 @@
38 ** The following macros are used to cast pointers to integers and
39 ** integers to pointers. The way you do this varies from one compiler
40 ** to the next, so we have developed the following set of #if statements
41 ** to generate appropriate macros for a wide range of compilers.
42 **
43 ** The correct "ANSI" way to do this is to use the intptr_t type.
44 ** Unfortunately, that typedef is not available on all compilers, or
45 ** if it is available, it requires an #include of specific headers
46 ** that vary from one machine to the next.
47 **
48 ** This code is copied out of SQLite.
@@ -112,11 +112,11 @@
112 }
113 #endif
114
115 /*
116 ** Create a child process running shell command "zCmd". *ppOut is
117 ** a FILE that becomes the standard input of the child process.
118 ** (The caller writes to *ppOut in order to send text to the child.)
119 ** *ppIn is stdout from the child process. (The caller
120 ** reads from *ppIn in order to receive input from the child.)
121 ** Note that *ppIn is an unbuffered file descriptor, not a FILE.
122 ** The process ID of the child is written into *pChildPid.
@@ -124,17 +124,17 @@
124 ** Return the number of errors.
125 */
126 int popen2(const char *zCmd, int *pfdIn, FILE **ppOut, int *pChildPid){
127 #ifdef _WIN32
128 HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr;
129 SECURITY_ATTRIBUTES saAttr;
130 DWORD childPid = 0;
131 int fd;
132
133 saAttr.nLength = sizeof(saAttr);
134 saAttr.bInheritHandle = TRUE;
135 saAttr.lpSecurityDescriptor = NULL;
136 hStderr = GetStdHandle(STD_ERROR_HANDLE);
137 if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){
138 win32_fatal_error("cannot create pipe for stdout");
139 }
140 SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE);
@@ -141,18 +141,18 @@
141
142 if( !CreatePipe(&hStdinRd, &hStdinWr, &saAttr, 4096) ){
143 win32_fatal_error("cannot create pipe for stdin");
144 }
145 SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE);
146
147 win32_create_child_process(fossil_utf8_to_unicode(zCmd),
148 hStdinRd, hStdoutWr, hStderr,&childPid);
149 *pChildPid = childPid;
150 *pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0);
151 fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0);
152 *ppOut = _fdopen(fd, "w");
153 CloseHandle(hStdinRd);
154 CloseHandle(hStdoutWr);
155 return 0;
156 #else
157 int pin[2], pout[2];
158 *pfdIn = 0;
159
--- src/popen.c
+++ src/popen.c
@@ -38,11 +38,11 @@
38 ** The following macros are used to cast pointers to integers and
39 ** integers to pointers. The way you do this varies from one compiler
40 ** to the next, so we have developed the following set of #if statements
41 ** to generate appropriate macros for a wide range of compilers.
42 **
43 ** The correct "ANSI" way to do this is to use the intptr_t type.
44 ** Unfortunately, that typedef is not available on all compilers, or
45 ** if it is available, it requires an #include of specific headers
46 ** that vary from one machine to the next.
47 **
48 ** This code is copied out of SQLite.
@@ -112,11 +112,11 @@
112 }
113 #endif
114
115 /*
116 ** Create a child process running shell command "zCmd". *ppOut is
117 ** a FILE that becomes the standard input of the child process.
118 ** (The caller writes to *ppOut in order to send text to the child.)
119 ** *ppIn is stdout from the child process. (The caller
120 ** reads from *ppIn in order to receive input from the child.)
121 ** Note that *ppIn is an unbuffered file descriptor, not a FILE.
122 ** The process ID of the child is written into *pChildPid.
@@ -124,17 +124,17 @@
124 ** Return the number of errors.
125 */
126 int popen2(const char *zCmd, int *pfdIn, FILE **ppOut, int *pChildPid){
127 #ifdef _WIN32
128 HANDLE hStdinRd, hStdinWr, hStdoutRd, hStdoutWr, hStderr;
129 SECURITY_ATTRIBUTES saAttr;
130 DWORD childPid = 0;
131 int fd;
132
133 saAttr.nLength = sizeof(saAttr);
134 saAttr.bInheritHandle = TRUE;
135 saAttr.lpSecurityDescriptor = NULL;
136 hStderr = GetStdHandle(STD_ERROR_HANDLE);
137 if( !CreatePipe(&hStdoutRd, &hStdoutWr, &saAttr, 4096) ){
138 win32_fatal_error("cannot create pipe for stdout");
139 }
140 SetHandleInformation( hStdoutRd, HANDLE_FLAG_INHERIT, FALSE);
@@ -141,18 +141,18 @@
141
142 if( !CreatePipe(&hStdinRd, &hStdinWr, &saAttr, 4096) ){
143 win32_fatal_error("cannot create pipe for stdin");
144 }
145 SetHandleInformation( hStdinWr, HANDLE_FLAG_INHERIT, FALSE);
146
147 win32_create_child_process(fossil_utf8_to_unicode(zCmd),
148 hStdinRd, hStdoutWr, hStderr,&childPid);
149 *pChildPid = childPid;
150 *pfdIn = _open_osfhandle(PTR_TO_INT(hStdoutRd), 0);
151 fd = _open_osfhandle(PTR_TO_INT(hStdinWr), 0);
152 *ppOut = _fdopen(fd, "w");
153 CloseHandle(hStdinRd);
154 CloseHandle(hStdoutWr);
155 return 0;
156 #else
157 int pin[2], pout[2];
158 *pfdIn = 0;
159
+26 -20
--- src/rebuild.c
+++ src/rebuild.c
@@ -522,31 +522,32 @@
522522
** Reconstruct the named repository database from the core
523523
** records. Run this command after updating the fossil
524524
** executable in a way that changes the database schema.
525525
**
526526
** Options:
527
-** --analyze Run ANALYZE on the database after rebuilding
528
-** --cluster Compute clusters for unclustered artifacts
529
-** --compress Strive to make the database as small as possible
530
-** --deanalyze Remove ANALYZE tables from the database
531
-** --force Force the rebuild to complete even if errors are seen
532
-** --ifneeded Only do the rebuild if it would change the schema version
533
-** --index Always add in the full-text search index
534
-** --noverify Skip the verification of changes to the BLOB table
535
-** --noindex Always omit the full-text search index
536
-** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
537
-** --randomize Scan artifacts in a random order
538
-** --stats Show artifact statistics after rebuilding
539
-** --vacuum Run VACUUM on the database after rebuilding
540
-** --wal Set Write-Ahead-Log journalling mode on the database
527
+** --analyze Run ANALYZE on the database after rebuilding
528
+** --cluster Compute clusters for unclustered artifacts
529
+** --compress Strive to make the database as small as possible
530
+** --compress-only Skip the rebuilding step. Do --compress only
531
+** --deanalyze Remove ANALYZE tables from the database
532
+** --force Force the rebuild to complete even if errors are seen
533
+** --ifneeded Only do the rebuild if it would change the schema version
534
+** --index Always add in the full-text search index
535
+** --noverify Skip the verification of changes to the BLOB table
536
+** --noindex Always omit the full-text search index
537
+** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
538
+** --randomize Scan artifacts in a random order
539
+** --stats Show artifact statistics after rebuilding
540
+** --vacuum Run VACUUM on the database after rebuilding
541
+** --wal Set Write-Ahead-Log journalling mode on the database
541542
**
542543
** See also: deconstruct, reconstruct
543544
*/
544545
void rebuild_database(void){
545546
int forceFlag;
546547
int randomizeFlag;
547
- int errCnt;
548
+ int errCnt = 0;
548549
int omitVerify;
549550
int doClustering;
550551
const char *zPagesize;
551552
int newPagesize = 0;
552553
int activateWal;
@@ -557,10 +558,11 @@
557558
int showStats;
558559
int runReindex;
559560
int optNoIndex;
560561
int optIndex;
561562
int optIfNeeded;
563
+ int compressOnlyFlag;
562564
563565
omitVerify = find_option("noverify",0,0)!=0;
564566
forceFlag = find_option("force","f",0)!=0;
565567
randomizeFlag = find_option("randomize", 0, 0)!=0;
566568
doClustering = find_option("cluster", 0, 0)!=0;
@@ -571,10 +573,12 @@
571573
zPagesize = find_option("pagesize",0,1);
572574
showStats = find_option("stats",0,0)!=0;
573575
optIndex = find_option("index",0,0)!=0;
574576
optNoIndex = find_option("noindex",0,0)!=0;
575577
optIfNeeded = find_option("ifneeded",0,0)!=0;
578
+ compressOnlyFlag = find_option("compress-only",0,0)!=0;
579
+ if( compressOnlyFlag ) runCompress = runVacuum = 1;
576580
if( zPagesize ){
577581
newPagesize = atoi(zPagesize);
578582
if( newPagesize<512 || newPagesize>65536
579583
|| (newPagesize&(newPagesize-1))!=0
580584
){
@@ -590,11 +594,11 @@
590594
usage("?REPOSITORY-FILENAME?");
591595
}
592596
db_close(1);
593597
db_open_repository(g.zRepositoryName);
594598
}
595
- runReindex = search_index_exists();
599
+ runReindex = search_index_exists() && !compressOnlyFlag;
596600
if( optIndex ) runReindex = 1;
597601
if( optNoIndex ) runReindex = 0;
598602
if( optIfNeeded && fossil_strcmp(db_get("aux-schema",""),AUX_SCHEMA_MAX)==0 ){
599603
return;
600604
}
@@ -601,14 +605,16 @@
601605
602606
/* We should be done with options.. */
603607
verify_all_options();
604608
605609
db_begin_transaction();
606
- search_drop_index();
607
- ttyOutput = 1;
608
- errCnt = rebuild_db(randomizeFlag, 1, doClustering);
609
- reconstruct_private_table();
610
+ if( !compressOnlyFlag ){
611
+ search_drop_index();
612
+ ttyOutput = 1;
613
+ errCnt = rebuild_db(randomizeFlag, 1, doClustering);
614
+ reconstruct_private_table();
615
+ }
610616
db_multi_exec(
611617
"REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());"
612618
"REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());"
613619
"REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());",
614620
CONTENT_SCHEMA, AUX_SCHEMA_MAX, get_version()
615621
--- src/rebuild.c
+++ src/rebuild.c
@@ -522,31 +522,32 @@
522 ** Reconstruct the named repository database from the core
523 ** records. Run this command after updating the fossil
524 ** executable in a way that changes the database schema.
525 **
526 ** Options:
527 ** --analyze Run ANALYZE on the database after rebuilding
528 ** --cluster Compute clusters for unclustered artifacts
529 ** --compress Strive to make the database as small as possible
530 ** --deanalyze Remove ANALYZE tables from the database
531 ** --force Force the rebuild to complete even if errors are seen
532 ** --ifneeded Only do the rebuild if it would change the schema version
533 ** --index Always add in the full-text search index
534 ** --noverify Skip the verification of changes to the BLOB table
535 ** --noindex Always omit the full-text search index
536 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
537 ** --randomize Scan artifacts in a random order
538 ** --stats Show artifact statistics after rebuilding
539 ** --vacuum Run VACUUM on the database after rebuilding
540 ** --wal Set Write-Ahead-Log journalling mode on the database
 
541 **
542 ** See also: deconstruct, reconstruct
543 */
544 void rebuild_database(void){
545 int forceFlag;
546 int randomizeFlag;
547 int errCnt;
548 int omitVerify;
549 int doClustering;
550 const char *zPagesize;
551 int newPagesize = 0;
552 int activateWal;
@@ -557,10 +558,11 @@
557 int showStats;
558 int runReindex;
559 int optNoIndex;
560 int optIndex;
561 int optIfNeeded;
 
562
563 omitVerify = find_option("noverify",0,0)!=0;
564 forceFlag = find_option("force","f",0)!=0;
565 randomizeFlag = find_option("randomize", 0, 0)!=0;
566 doClustering = find_option("cluster", 0, 0)!=0;
@@ -571,10 +573,12 @@
571 zPagesize = find_option("pagesize",0,1);
572 showStats = find_option("stats",0,0)!=0;
573 optIndex = find_option("index",0,0)!=0;
574 optNoIndex = find_option("noindex",0,0)!=0;
575 optIfNeeded = find_option("ifneeded",0,0)!=0;
 
 
576 if( zPagesize ){
577 newPagesize = atoi(zPagesize);
578 if( newPagesize<512 || newPagesize>65536
579 || (newPagesize&(newPagesize-1))!=0
580 ){
@@ -590,11 +594,11 @@
590 usage("?REPOSITORY-FILENAME?");
591 }
592 db_close(1);
593 db_open_repository(g.zRepositoryName);
594 }
595 runReindex = search_index_exists();
596 if( optIndex ) runReindex = 1;
597 if( optNoIndex ) runReindex = 0;
598 if( optIfNeeded && fossil_strcmp(db_get("aux-schema",""),AUX_SCHEMA_MAX)==0 ){
599 return;
600 }
@@ -601,14 +605,16 @@
601
602 /* We should be done with options.. */
603 verify_all_options();
604
605 db_begin_transaction();
606 search_drop_index();
607 ttyOutput = 1;
608 errCnt = rebuild_db(randomizeFlag, 1, doClustering);
609 reconstruct_private_table();
 
 
610 db_multi_exec(
611 "REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());"
612 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());"
613 "REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());",
614 CONTENT_SCHEMA, AUX_SCHEMA_MAX, get_version()
615
--- src/rebuild.c
+++ src/rebuild.c
@@ -522,31 +522,32 @@
522 ** Reconstruct the named repository database from the core
523 ** records. Run this command after updating the fossil
524 ** executable in a way that changes the database schema.
525 **
526 ** Options:
527 ** --analyze Run ANALYZE on the database after rebuilding
528 ** --cluster Compute clusters for unclustered artifacts
529 ** --compress Strive to make the database as small as possible
530 ** --compress-only Skip the rebuilding step. Do --compress only
531 ** --deanalyze Remove ANALYZE tables from the database
532 ** --force Force the rebuild to complete even if errors are seen
533 ** --ifneeded Only do the rebuild if it would change the schema version
534 ** --index Always add in the full-text search index
535 ** --noverify Skip the verification of changes to the BLOB table
536 ** --noindex Always omit the full-text search index
537 ** --pagesize N Set the database pagesize to N. (512..65536 and power of 2)
538 ** --randomize Scan artifacts in a random order
539 ** --stats Show artifact statistics after rebuilding
540 ** --vacuum Run VACUUM on the database after rebuilding
541 ** --wal Set Write-Ahead-Log journalling mode on the database
542 **
543 ** See also: deconstruct, reconstruct
544 */
545 void rebuild_database(void){
546 int forceFlag;
547 int randomizeFlag;
548 int errCnt = 0;
549 int omitVerify;
550 int doClustering;
551 const char *zPagesize;
552 int newPagesize = 0;
553 int activateWal;
@@ -557,10 +558,11 @@
558 int showStats;
559 int runReindex;
560 int optNoIndex;
561 int optIndex;
562 int optIfNeeded;
563 int compressOnlyFlag;
564
565 omitVerify = find_option("noverify",0,0)!=0;
566 forceFlag = find_option("force","f",0)!=0;
567 randomizeFlag = find_option("randomize", 0, 0)!=0;
568 doClustering = find_option("cluster", 0, 0)!=0;
@@ -571,10 +573,12 @@
573 zPagesize = find_option("pagesize",0,1);
574 showStats = find_option("stats",0,0)!=0;
575 optIndex = find_option("index",0,0)!=0;
576 optNoIndex = find_option("noindex",0,0)!=0;
577 optIfNeeded = find_option("ifneeded",0,0)!=0;
578 compressOnlyFlag = find_option("compress-only",0,0)!=0;
579 if( compressOnlyFlag ) runCompress = runVacuum = 1;
580 if( zPagesize ){
581 newPagesize = atoi(zPagesize);
582 if( newPagesize<512 || newPagesize>65536
583 || (newPagesize&(newPagesize-1))!=0
584 ){
@@ -590,11 +594,11 @@
594 usage("?REPOSITORY-FILENAME?");
595 }
596 db_close(1);
597 db_open_repository(g.zRepositoryName);
598 }
599 runReindex = search_index_exists() && !compressOnlyFlag;
600 if( optIndex ) runReindex = 1;
601 if( optNoIndex ) runReindex = 0;
602 if( optIfNeeded && fossil_strcmp(db_get("aux-schema",""),AUX_SCHEMA_MAX)==0 ){
603 return;
604 }
@@ -601,14 +605,16 @@
605
606 /* We should be done with options.. */
607 verify_all_options();
608
609 db_begin_transaction();
610 if( !compressOnlyFlag ){
611 search_drop_index();
612 ttyOutput = 1;
613 errCnt = rebuild_db(randomizeFlag, 1, doClustering);
614 reconstruct_private_table();
615 }
616 db_multi_exec(
617 "REPLACE INTO config(name,value,mtime) VALUES('content-schema',%Q,now());"
618 "REPLACE INTO config(name,value,mtime) VALUES('aux-schema',%Q,now());"
619 "REPLACE INTO config(name,value,mtime) VALUES('rebuilt',%Q,now());",
620 CONTENT_SCHEMA, AUX_SCHEMA_MAX, get_version()
621
+32 -15
--- src/report.c
+++ src/report.c
@@ -28,11 +28,11 @@
2828
#ifndef SQLITE_RECURSIVE
2929
# define SQLITE_RECURSIVE 33
3030
#endif
3131
3232
/*
33
-** WEBPAGE: /reportlist
33
+** WEBPAGE: reportlist
3434
**
3535
** Main menu for Tickets.
3636
*/
3737
void view_list(void){
3838
const char *zScript;
@@ -284,11 +284,15 @@
284284
report_unrestrict_sql();
285285
return zErr;
286286
}
287287
288288
/*
289
-** WEBPAGE: /rptsql
289
+** WEBPAGE: rptsql
290
+** URL: /rptsql?rn=N
291
+**
292
+** Display the SQL query used to generate a ticket report. The rn=N
293
+** query parameter identifies the specific report number to be displayed.
290294
*/
291295
void view_see_sql(void){
292296
int rn;
293297
const char *zTitle;
294298
const char *zSQL;
@@ -332,12 +336,21 @@
332336
style_footer();
333337
db_finalize(&q);
334338
}
335339
336340
/*
337
-** WEBPAGE: /rptnew
338
-** WEBPAGE: /rptedit
341
+** WEBPAGE: rptnew
342
+** WEBPAGE: rptedit
343
+**
344
+** Create (/rptnew) or edit (/rptedit) a ticket report format.
345
+** Query parameters:
346
+**
347
+** rn=N Ticket report number. (required)
348
+** t=TITLE Title of the report format
349
+** w=USER Owner of the report format
350
+** s=SQL SQL text used to implement the report
351
+** k=KEY Color key
339352
*/
340353
void view_edit(void){
341354
int rn;
342355
const char *zTitle;
343356
const char *z;
@@ -1061,20 +1074,20 @@
10611074
@ </script>
10621075
}
10631076
10641077
10651078
/*
1066
-** WEBPAGE: /rptview
1079
+** WEBPAGE: rptview
10671080
**
10681081
** Generate a report. The rn query parameter is the report number
10691082
** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
10701083
** then the output consists of lines of tab-separated fields instead of
10711084
** an HTML table.
10721085
*/
10731086
void rptview_page(void){
10741087
int count = 0;
1075
- int rn;
1088
+ int rn, rc;
10761089
char *zSql;
10771090
char *zTitle;
10781091
char *zOwner;
10791092
char *zClrKey;
10801093
int tabs;
@@ -1082,28 +1095,32 @@
10821095
char *zErr1 = 0;
10831096
char *zErr2 = 0;
10841097
10851098
login_check_credentials();
10861099
if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1087
- rn = atoi(PD("rn","0"));
1088
- if( rn==0 ){
1089
- cgi_redirect("reportlist");
1090
- return;
1091
- }
10921100
tabs = P("tablist")!=0;
1093
- /* view_add_functions(tabs); */
10941101
db_prepare(&q,
1095
- "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
1096
- if( db_step(&q)!=SQLITE_ROW ){
1097
- cgi_redirect("reportlist");
1102
+ "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
1103
+ atoi(PD("rn","0")));
1104
+ rc = db_step(&q);
1105
+ if( rc!=SQLITE_ROW ){
1106
+ db_finalize(&q);
1107
+ db_prepare(&q,
1108
+ "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
1109
+ P("title"));
1110
+ rc = db_step(&q);
1111
+ }
1112
+ if( rc!=SQLITE_ROW ){
10981113
db_finalize(&q);
1114
+ cgi_redirect("reportlist");
10991115
return;
11001116
}
11011117
zTitle = db_column_malloc(&q, 0);
11021118
zSql = db_column_malloc(&q, 1);
11031119
zOwner = db_column_malloc(&q, 2);
11041120
zClrKey = db_column_malloc(&q, 3);
1121
+ rn = db_column_int(&q,4);
11051122
db_finalize(&q);
11061123
11071124
if( P("order_by") ){
11081125
/*
11091126
** If the user wants to do a column sort, wrap the query into a sub
11101127
--- src/report.c
+++ src/report.c
@@ -28,11 +28,11 @@
28 #ifndef SQLITE_RECURSIVE
29 # define SQLITE_RECURSIVE 33
30 #endif
31
32 /*
33 ** WEBPAGE: /reportlist
34 **
35 ** Main menu for Tickets.
36 */
37 void view_list(void){
38 const char *zScript;
@@ -284,11 +284,15 @@
284 report_unrestrict_sql();
285 return zErr;
286 }
287
288 /*
289 ** WEBPAGE: /rptsql
 
 
 
 
290 */
291 void view_see_sql(void){
292 int rn;
293 const char *zTitle;
294 const char *zSQL;
@@ -332,12 +336,21 @@
332 style_footer();
333 db_finalize(&q);
334 }
335
336 /*
337 ** WEBPAGE: /rptnew
338 ** WEBPAGE: /rptedit
 
 
 
 
 
 
 
 
 
339 */
340 void view_edit(void){
341 int rn;
342 const char *zTitle;
343 const char *z;
@@ -1061,20 +1074,20 @@
1061 @ </script>
1062 }
1063
1064
1065 /*
1066 ** WEBPAGE: /rptview
1067 **
1068 ** Generate a report. The rn query parameter is the report number
1069 ** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
1070 ** then the output consists of lines of tab-separated fields instead of
1071 ** an HTML table.
1072 */
1073 void rptview_page(void){
1074 int count = 0;
1075 int rn;
1076 char *zSql;
1077 char *zTitle;
1078 char *zOwner;
1079 char *zClrKey;
1080 int tabs;
@@ -1082,28 +1095,32 @@
1082 char *zErr1 = 0;
1083 char *zErr2 = 0;
1084
1085 login_check_credentials();
1086 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
1087 rn = atoi(PD("rn","0"));
1088 if( rn==0 ){
1089 cgi_redirect("reportlist");
1090 return;
1091 }
1092 tabs = P("tablist")!=0;
1093 /* view_add_functions(tabs); */
1094 db_prepare(&q,
1095 "SELECT title, sqlcode, owner, cols FROM reportfmt WHERE rn=%d", rn);
1096 if( db_step(&q)!=SQLITE_ROW ){
1097 cgi_redirect("reportlist");
 
 
 
 
 
 
 
 
1098 db_finalize(&q);
 
1099 return;
1100 }
1101 zTitle = db_column_malloc(&q, 0);
1102 zSql = db_column_malloc(&q, 1);
1103 zOwner = db_column_malloc(&q, 2);
1104 zClrKey = db_column_malloc(&q, 3);
 
1105 db_finalize(&q);
1106
1107 if( P("order_by") ){
1108 /*
1109 ** If the user wants to do a column sort, wrap the query into a sub
1110
--- src/report.c
+++ src/report.c
@@ -28,11 +28,11 @@
28 #ifndef SQLITE_RECURSIVE
29 # define SQLITE_RECURSIVE 33
30 #endif
31
32 /*
33 ** WEBPAGE: reportlist
34 **
35 ** Main menu for Tickets.
36 */
37 void view_list(void){
38 const char *zScript;
@@ -284,11 +284,15 @@
284 report_unrestrict_sql();
285 return zErr;
286 }
287
288 /*
289 ** WEBPAGE: rptsql
290 ** URL: /rptsql?rn=N
291 **
292 ** Display the SQL query used to generate a ticket report. The rn=N
293 ** query parameter identifies the specific report number to be displayed.
294 */
295 void view_see_sql(void){
296 int rn;
297 const char *zTitle;
298 const char *zSQL;
@@ -332,12 +336,21 @@
336 style_footer();
337 db_finalize(&q);
338 }
339
340 /*
341 ** WEBPAGE: rptnew
342 ** WEBPAGE: rptedit
343 **
344 ** Create (/rptnew) or edit (/rptedit) a ticket report format.
345 ** Query parameters:
346 **
347 ** rn=N Ticket report number. (required)
348 ** t=TITLE Title of the report format
349 ** w=USER Owner of the report format
350 ** s=SQL SQL text used to implement the report
351 ** k=KEY Color key
352 */
353 void view_edit(void){
354 int rn;
355 const char *zTitle;
356 const char *z;
@@ -1061,20 +1074,20 @@
1074 @ </script>
1075 }
1076
1077
1078 /*
1079 ** WEBPAGE: rptview
1080 **
1081 ** Generate a report. The rn query parameter is the report number
1082 ** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
1083 ** then the output consists of lines of tab-separated fields instead of
1084 ** an HTML table.
1085 */
1086 void rptview_page(void){
1087 int count = 0;
1088 int rn, rc;
1089 char *zSql;
1090 char *zTitle;
1091 char *zOwner;
1092 char *zClrKey;
1093 int tabs;
@@ -1082,28 +1095,32 @@
1095 char *zErr1 = 0;
1096 char *zErr2 = 0;
1097
1098 login_check_credentials();
1099 if( !g.perm.RdTkt ){ login_needed(g.anon.RdTkt); return; }
 
 
 
 
 
1100 tabs = P("tablist")!=0;
 
1101 db_prepare(&q,
1102 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE rn=%d",
1103 atoi(PD("rn","0")));
1104 rc = db_step(&q);
1105 if( rc!=SQLITE_ROW ){
1106 db_finalize(&q);
1107 db_prepare(&q,
1108 "SELECT title, sqlcode, owner, cols, rn FROM reportfmt WHERE title GLOB %Q",
1109 P("title"));
1110 rc = db_step(&q);
1111 }
1112 if( rc!=SQLITE_ROW ){
1113 db_finalize(&q);
1114 cgi_redirect("reportlist");
1115 return;
1116 }
1117 zTitle = db_column_malloc(&q, 0);
1118 zSql = db_column_malloc(&q, 1);
1119 zOwner = db_column_malloc(&q, 2);
1120 zClrKey = db_column_malloc(&q, 3);
1121 rn = db_column_int(&q,4);
1122 db_finalize(&q);
1123
1124 if( P("order_by") ){
1125 /*
1126 ** If the user wants to do a column sort, wrap the query into a sub
1127
+14 -13
--- src/schema.c
+++ src/schema.c
@@ -249,22 +249,24 @@
249249
@ -- pid = Parent file ID.
250250
@ -- fnid = File Name ID.
251251
@ -- pfnid = Parent File Name ID.
252252
@ -- isaux = pmid IS AUXiliary parent, not primary parent
253253
@ --
254
-@ -- pid==0 if the file is added by check-in mid.
255
-@ -- fid==0 if the file is removed by check-in mid.
254
+@ -- pid==0 if the file is added by check-in mid.
255
+@ -- pid==(-1) if the file exists in a merge parents but not in the primary
256
+@ -- parent. In other words, if the file file was added by merge.
257
+@ -- fid==0 if the file is removed by check-in mid.
256258
@ --
257259
@ CREATE TABLE mlink(
258
-@ mid INTEGER REFERENCES plink(cid), -- Check-in that contains fid
259
-@ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted
260
-@ pmid INTEGER REFERENCES plink(cid), -- Check-in that contains pid
261
-@ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new
262
-@ fnid INTEGER REFERENCES filename, -- Name of the file
263
-@ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged
264
-@ mperm INTEGER, -- File permissions. 1==exec
265
-@ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary
260
+@ mid INTEGER, -- Check-in that contains fid
261
+@ fid INTEGER, -- New file content. 0 if deleted
262
+@ pmid INTEGER, -- Check-in that contains pid
263
+@ pid INTEGER, -- Prev file content. 0 if new. -1 merge
264
+@ fnid INTEGER REFERENCES filename, -- Name of the file
265
+@ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged
266
+@ mperm INTEGER, -- File permissions. 1==exec
267
+@ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary
266268
@ );
267269
@ CREATE INDEX mlink_i1 ON mlink(mid);
268270
@ CREATE INDEX mlink_i2 ON mlink(fnid);
269271
@ CREATE INDEX mlink_i3 ON mlink(fid);
270272
@ CREATE INDEX mlink_i4 ON mlink(pid);
@@ -367,10 +369,11 @@
367369
@ INSERT INTO tag VALUES(6, 'private'); -- TAG_PRIVATE
368370
@ INSERT INTO tag VALUES(7, 'cluster'); -- TAG_CLUSTER
369371
@ INSERT INTO tag VALUES(8, 'branch'); -- TAG_BRANCH
370372
@ INSERT INTO tag VALUES(9, 'closed'); -- TAG_CLOSED
371373
@ INSERT INTO tag VALUES(10,'parent'); -- TAG_PARENT
374
+@ INSERT INTO tag VALUES(11,'note'); -- TAG_NOTE
372375
@
373376
@ -- Assignments of tags to baselines. Note that we allow tags to
374377
@ -- have values assigned to them. So we are not really dealing with
375378
@ -- tags here. These are really properties. But we are going to
376379
@ -- keep calling them tags because in many cases the value is ignored.
@@ -466,13 +469,11 @@
466469
# define TAG_PRIVATE 6 /* Do not sync */
467470
# define TAG_CLUSTER 7 /* A cluster */
468471
# define TAG_BRANCH 8 /* Value is name of the current branch */
469472
# define TAG_CLOSED 9 /* Do not display this check-in as a leaf */
470473
# define TAG_PARENT 10 /* Change to parentage on a check-in */
471
-#endif
472
-#if EXPORT_INTERFACE
473
-# define MAX_INT_TAG 16 /* The largest pre-assigned tag id */
474
+# define TAG_NOTE 11 /* Extra text appended to a check-in comment */
474475
#endif
475476
476477
/*
477478
** The schema for the local FOSSIL database file found at the root
478479
** of every check-out. This database contains the complete state of
479480
--- src/schema.c
+++ src/schema.c
@@ -249,22 +249,24 @@
249 @ -- pid = Parent file ID.
250 @ -- fnid = File Name ID.
251 @ -- pfnid = Parent File Name ID.
252 @ -- isaux = pmid IS AUXiliary parent, not primary parent
253 @ --
254 @ -- pid==0 if the file is added by check-in mid.
255 @ -- fid==0 if the file is removed by check-in mid.
 
 
256 @ --
257 @ CREATE TABLE mlink(
258 @ mid INTEGER REFERENCES plink(cid), -- Check-in that contains fid
259 @ fid INTEGER REFERENCES blob, -- New file content. 0 if deleted
260 @ pmid INTEGER REFERENCES plink(cid), -- Check-in that contains pid
261 @ pid INTEGER REFERENCES blob, -- Prev file content. 0 if new
262 @ fnid INTEGER REFERENCES filename, -- Name of the file
263 @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged
264 @ mperm INTEGER, -- File permissions. 1==exec
265 @ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary
266 @ );
267 @ CREATE INDEX mlink_i1 ON mlink(mid);
268 @ CREATE INDEX mlink_i2 ON mlink(fnid);
269 @ CREATE INDEX mlink_i3 ON mlink(fid);
270 @ CREATE INDEX mlink_i4 ON mlink(pid);
@@ -367,10 +369,11 @@
367 @ INSERT INTO tag VALUES(6, 'private'); -- TAG_PRIVATE
368 @ INSERT INTO tag VALUES(7, 'cluster'); -- TAG_CLUSTER
369 @ INSERT INTO tag VALUES(8, 'branch'); -- TAG_BRANCH
370 @ INSERT INTO tag VALUES(9, 'closed'); -- TAG_CLOSED
371 @ INSERT INTO tag VALUES(10,'parent'); -- TAG_PARENT
 
372 @
373 @ -- Assignments of tags to baselines. Note that we allow tags to
374 @ -- have values assigned to them. So we are not really dealing with
375 @ -- tags here. These are really properties. But we are going to
376 @ -- keep calling them tags because in many cases the value is ignored.
@@ -466,13 +469,11 @@
466 # define TAG_PRIVATE 6 /* Do not sync */
467 # define TAG_CLUSTER 7 /* A cluster */
468 # define TAG_BRANCH 8 /* Value is name of the current branch */
469 # define TAG_CLOSED 9 /* Do not display this check-in as a leaf */
470 # define TAG_PARENT 10 /* Change to parentage on a check-in */
471 #endif
472 #if EXPORT_INTERFACE
473 # define MAX_INT_TAG 16 /* The largest pre-assigned tag id */
474 #endif
475
476 /*
477 ** The schema for the local FOSSIL database file found at the root
478 ** of every check-out. This database contains the complete state of
479
--- src/schema.c
+++ src/schema.c
@@ -249,22 +249,24 @@
249 @ -- pid = Parent file ID.
250 @ -- fnid = File Name ID.
251 @ -- pfnid = Parent File Name ID.
252 @ -- isaux = pmid IS AUXiliary parent, not primary parent
253 @ --
254 @ -- pid==0 if the file is added by check-in mid.
255 @ -- pid==(-1) if the file exists in a merge parents but not in the primary
256 @ -- parent. In other words, if the file file was added by merge.
257 @ -- fid==0 if the file is removed by check-in mid.
258 @ --
259 @ CREATE TABLE mlink(
260 @ mid INTEGER, -- Check-in that contains fid
261 @ fid INTEGER, -- New file content. 0 if deleted
262 @ pmid INTEGER, -- Check-in that contains pid
263 @ pid INTEGER, -- Prev file content. 0 if new. -1 merge
264 @ fnid INTEGER REFERENCES filename, -- Name of the file
265 @ pfnid INTEGER REFERENCES filename, -- Previous name. 0 if unchanged
266 @ mperm INTEGER, -- File permissions. 1==exec
267 @ isaux BOOLEAN DEFAULT 0 -- TRUE if pmid is the primary
268 @ );
269 @ CREATE INDEX mlink_i1 ON mlink(mid);
270 @ CREATE INDEX mlink_i2 ON mlink(fnid);
271 @ CREATE INDEX mlink_i3 ON mlink(fid);
272 @ CREATE INDEX mlink_i4 ON mlink(pid);
@@ -367,10 +369,11 @@
369 @ INSERT INTO tag VALUES(6, 'private'); -- TAG_PRIVATE
370 @ INSERT INTO tag VALUES(7, 'cluster'); -- TAG_CLUSTER
371 @ INSERT INTO tag VALUES(8, 'branch'); -- TAG_BRANCH
372 @ INSERT INTO tag VALUES(9, 'closed'); -- TAG_CLOSED
373 @ INSERT INTO tag VALUES(10,'parent'); -- TAG_PARENT
374 @ INSERT INTO tag VALUES(11,'note'); -- TAG_NOTE
375 @
376 @ -- Assignments of tags to baselines. Note that we allow tags to
377 @ -- have values assigned to them. So we are not really dealing with
378 @ -- tags here. These are really properties. But we are going to
379 @ -- keep calling them tags because in many cases the value is ignored.
@@ -466,13 +469,11 @@
469 # define TAG_PRIVATE 6 /* Do not sync */
470 # define TAG_CLUSTER 7 /* A cluster */
471 # define TAG_BRANCH 8 /* Value is name of the current branch */
472 # define TAG_CLOSED 9 /* Do not display this check-in as a leaf */
473 # define TAG_PARENT 10 /* Change to parentage on a check-in */
474 # define TAG_NOTE 11 /* Extra text appended to a check-in comment */
 
 
475 #endif
476
477 /*
478 ** The schema for the local FOSSIL database file found at the root
479 ** of every check-out. This database contains the complete state of
480
+11 -2
--- src/search.c
+++ src/search.c
@@ -102,11 +102,11 @@
102102
}
103103
104104
/*
105105
** Compile a search pattern
106106
*/
107
-Search *search_init(
107
+static Search *search_init(
108108
const char *zPattern, /* The search pattern */
109109
const char *zMarkBegin, /* Start of a match */
110110
const char *zMarkEnd, /* End of a match */
111111
const char *zMarkGap, /* A gap between two matches */
112112
unsigned fSrchFlg /* Flags */
@@ -1047,14 +1047,22 @@
10471047
@ </div>
10481048
}
10491049
}
10501050
10511051
/*
1052
-** WEBPAGE: /search
1052
+** WEBPAGE: search
10531053
**
10541054
** Search for check-in comments, documents, tickets, or wiki that
10551055
** match a user-supplied pattern.
1056
+**
1057
+** s=PATTERN Specify the full-text pattern to search for
1058
+** y=TYPE What to search.
1059
+** c -> check-ins
1060
+** d -> documentation
1061
+** t -> tickets
1062
+** w -> wiki
1063
+** all -> everything
10561064
*/
10571065
void search_page(void){
10581066
login_check_credentials();
10591067
style_header("Search");
10601068
search_screen(SRCH_ALL, 1);
@@ -1103,10 +1111,11 @@
11031111
if( doc_is_embedded_html(pIn, &title) ){
11041112
blob_appendf(pOut, "%s\n", blob_str(&title));
11051113
}
11061114
html_to_plaintext(blob_str(pIn), pOut);
11071115
}else{
1116
+ blob_append(pOut, "\n", 1);
11081117
blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
11091118
}
11101119
blob_reset(&html);
11111120
blob_reset(&title);
11121121
}
11131122
--- src/search.c
+++ src/search.c
@@ -102,11 +102,11 @@
102 }
103
104 /*
105 ** Compile a search pattern
106 */
107 Search *search_init(
108 const char *zPattern, /* The search pattern */
109 const char *zMarkBegin, /* Start of a match */
110 const char *zMarkEnd, /* End of a match */
111 const char *zMarkGap, /* A gap between two matches */
112 unsigned fSrchFlg /* Flags */
@@ -1047,14 +1047,22 @@
1047 @ </div>
1048 }
1049 }
1050
1051 /*
1052 ** WEBPAGE: /search
1053 **
1054 ** Search for check-in comments, documents, tickets, or wiki that
1055 ** match a user-supplied pattern.
 
 
 
 
 
 
 
 
1056 */
1057 void search_page(void){
1058 login_check_credentials();
1059 style_header("Search");
1060 search_screen(SRCH_ALL, 1);
@@ -1103,10 +1111,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
@@ -102,11 +102,11 @@
102 }
103
104 /*
105 ** Compile a search pattern
106 */
107 static Search *search_init(
108 const char *zPattern, /* The search pattern */
109 const char *zMarkBegin, /* Start of a match */
110 const char *zMarkEnd, /* End of a match */
111 const char *zMarkGap, /* A gap between two matches */
112 unsigned fSrchFlg /* Flags */
@@ -1047,14 +1047,22 @@
1047 @ </div>
1048 }
1049 }
1050
1051 /*
1052 ** WEBPAGE: search
1053 **
1054 ** Search for check-in comments, documents, tickets, or wiki that
1055 ** match a user-supplied pattern.
1056 **
1057 ** s=PATTERN Specify the full-text pattern to search for
1058 ** y=TYPE What to search.
1059 ** c -> check-ins
1060 ** d -> documentation
1061 ** t -> tickets
1062 ** w -> wiki
1063 ** all -> everything
1064 */
1065 void search_page(void){
1066 login_check_credentials();
1067 style_header("Search");
1068 search_screen(SRCH_ALL, 1);
@@ -1103,10 +1111,11 @@
1111 if( doc_is_embedded_html(pIn, &title) ){
1112 blob_appendf(pOut, "%s\n", blob_str(&title));
1113 }
1114 html_to_plaintext(blob_str(pIn), pOut);
1115 }else{
1116 blob_append(pOut, "\n", 1);
1117 blob_append(pOut, blob_buffer(pIn), blob_size(pIn));
1118 }
1119 blob_reset(&html);
1120 blob_reset(&title);
1121 }
1122
+42 -170
--- src/setup.c
+++ src/setup.c
@@ -54,11 +54,13 @@
5454
}
5555
5656
5757
5858
/*
59
-** WEBPAGE: /setup
59
+** WEBPAGE: setup
60
+**
61
+** Main menu for the administrative pages. Requires Admin privileges.
6062
*/
6163
void setup_page(void){
6264
login_check_credentials();
6365
if( !g.perm.Setup ){
6466
login_needed(0);
@@ -69,11 +71,11 @@
6971
/* Make sure the header contains <base href="...">. Issue a warning
7072
** if it does not. */
7173
if( !cgi_header_contains("<base href=") ){
7274
@ <p class="generalError"><b>Configuration Error:</b> Please add
7375
@ <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>
76
+ @ <tt>&lt;head&gt;</tt> in the <a href="setup_skinedit?w=2">HTML header</a>!</p>
7577
}
7678
7779
#if !defined(_WIN32)
7880
/* Check for /dev/null and /dev/urandom. We want both devices to be present,
7981
** but they are sometimes omitted (by mistake) from chroot jails. */
@@ -107,17 +109,11 @@
107109
setup_menu_entry("Search","srchsetup",
108110
"Configure the built-in search engine");
109111
setup_menu_entry("Transfers", "xfersetup",
110112
"Configure the transfer system for this repository");
111113
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");
114
+ "Select and/or modify the web interface \"skins\"");
119115
setup_menu_entry("Moderation", "setup_modreq",
120116
"Enable/Disable requiring moderator approval of Wiki and/or Ticket"
121117
" changes and attachments.");
122118
setup_menu_entry("Ad-Unit", "setup_adunit",
123119
"Edit HTML text for an ad unit inserted after the menu bar");
@@ -129,12 +125,12 @@
129125
"A record of received artifacts and their sources");
130126
setup_menu_entry("User Log", "access_log",
131127
"A record of login attempts");
132128
setup_menu_entry("Administrative Log", "admin_log",
133129
"View the admin_log entries");
134
- setup_menu_entry("Stats", "stat",
135
- "Display repository statistics");
130
+ setup_menu_entry("Sitemap", "sitemap",
131
+ "Links to miscellaneous pages");
136132
setup_menu_entry("SQL", "admin_sql",
137133
"Enter raw SQL commands");
138134
setup_menu_entry("TH1", "admin_th1",
139135
"Enter raw TH1 commands");
140136
@ </table>
@@ -144,11 +140,11 @@
144140
145141
/*
146142
** WEBPAGE: setup_ulist
147143
**
148144
** Show a list of users. Clicking on any user jumps to the edit
149
-** screen for that user.
145
+** screen for that user. Requires Admin privileges.
150146
*/
151147
void setup_ulist(void){
152148
Stmt s;
153149
int prevLevel = 0;
154150
@@ -319,11 +315,14 @@
319315
while( zPw[0]=='*' ){ zPw++; }
320316
return zPw[0]!=0;
321317
}
322318
323319
/*
324
-** WEBPAGE: /setup_uedit
320
+** WEBPAGE: setup_uedit
321
+**
322
+** Edit information about a user or create a new user.
323
+** Requires Admin privileges.
325324
*/
326325
void user_edit(void){
327326
const char *zId, *zLogin, *zInfo, *zCap, *zPw;
328327
const char *zGroup;
329328
const char *zOldLogin;
@@ -930,11 +929,11 @@
930929
}
931930
932931
/*
933932
** Generate a text box for an attribute.
934933
*/
935
-static void textarea_attribute(
934
+const char *textarea_attribute(
936935
const char *zLabel, /* The text label on the textarea */
937936
int rows, /* Rows in the textarea */
938937
int cols, /* Columns in the textarea */
939938
const char *zVar, /* The corresponding row in the VAR table */
940939
const char *zQP, /* The query parameter */
@@ -959,10 +958,11 @@
959958
@ cols="%d(cols)">%h(z)</textarea>
960959
if( zLabel && *zLabel ){
961960
@ <span class="textareaLabel">%s(zLabel)</span>
962961
}
963962
}
963
+ return z;
964964
}
965965
966966
/*
967967
** Generate a text box for an attribute.
968968
*/
@@ -994,10 +994,12 @@
994994
}
995995
996996
997997
/*
998998
** WEBPAGE: setup_access
999
+**
1000
+** The access-control settings page. Requires Admin privileges.
9991001
*/
10001002
void setup_access(void){
10011003
login_check_credentials();
10021004
if( !g.perm.Setup ){
10031005
login_needed(0);
@@ -1191,10 +1193,13 @@
11911193
style_footer();
11921194
}
11931195
11941196
/*
11951197
** WEBPAGE: setup_login_group
1198
+**
1199
+** Change how the current repository participates in a login
1200
+** group.
11961201
*/
11971202
void setup_login_group(void){
11981203
const char *zGroup;
11991204
char *zErrMsg = 0;
12001205
Blob fullName;
@@ -1304,10 +1309,13 @@
13041309
style_footer();
13051310
}
13061311
13071312
/*
13081313
** WEBPAGE: setup_timeline
1314
+**
1315
+** Edit administrative settings controlling the display of
1316
+** timelines.
13091317
*/
13101318
void setup_timeline(void){
13111319
double tmDiff;
13121320
char zTmDiff[20];
13131321
static const char *const azTimeFormats[] = {
@@ -1390,10 +1398,13 @@
13901398
style_footer();
13911399
}
13921400
13931401
/*
13941402
** WEBPAGE: setup_settings
1403
+**
1404
+** Change or view miscellanous settings. Part of the
1405
+** Admin pages requiring Admin privileges.
13951406
*/
13961407
void setup_settings(void){
13971408
Setting const *pSet;
13981409
13991410
login_check_credentials();
@@ -1473,10 +1484,12 @@
14731484
style_footer();
14741485
}
14751486
14761487
/*
14771488
** WEBPAGE: setup_config
1489
+**
1490
+** The "Admin/Configuration" page. Requires Admin privilege.
14781491
*/
14791492
void setup_config(void){
14801493
login_check_credentials();
14811494
if( !g.perm.Setup ){
14821495
login_needed(0);
@@ -1550,161 +1563,14 @@
15501563
@ </div></form>
15511564
db_end_transaction(0);
15521565
style_footer();
15531566
}
15541567
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
-
17041568
/*
17051569
** WEBPAGE: setup_modreq
1570
+**
1571
+** Admin page for setting up moderation of tickets and wiki.
17061572
*/
17071573
void setup_modreq(void){
17081574
login_check_credentials();
17091575
if( !g.perm.Setup ){
17101576
login_needed(0);
@@ -1746,10 +1612,13 @@
17461612
17471613
}
17481614
17491615
/*
17501616
** WEBPAGE: setup_adunit
1617
+**
1618
+** Administrative page for configuring and controlling ad units
1619
+** and how they are displayed.
17511620
*/
17521621
void setup_adunit(void){
17531622
login_check_credentials();
17541623
if( !g.perm.Setup ){
17551624
login_needed(0);
@@ -1783,11 +1652,11 @@
17831652
@ <b>Ad-Unit Notes:</b><ul>
17841653
@ <li>Leave both Ad-Units blank to disable all advertising.
17851654
@ <li>The "Banner Ad-Unit" is used for wide pages.
17861655
@ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
17871656
@ <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:
1657
+ @ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
17891658
@ <blockquote><pre>
17901659
@ div.adunit_banner {
17911660
@ margin: auto;
17921661
@ width: 100%;
17931662
@ }
@@ -1814,10 +1683,12 @@
18141683
db_end_transaction(0);
18151684
}
18161685
18171686
/*
18181687
** WEBPAGE: setup_logo
1688
+**
1689
+** Administrative page for changing the logo image.
18191690
*/
18201691
void setup_logo(void){
18211692
const char *zLogoMtime = db_get_mtime("logo-image", 0, 0);
18221693
const char *zLogoMime = db_get("logo-mimetype","image/gif");
18231694
const char *aLogoImg = P("logoim");
@@ -1897,12 +1768,12 @@
18971768
@ <form action="%s(g.zTop)/setup_logo" method="post"
18981769
@ enctype="multipart/form-data"><div>
18991770
@ <p>The logo is accessible to all users at this URL:
19001771
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
19011772
@ 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>.
1773
+ @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1774
+ @ <a href="setup_skinedit?w=2">header setup</a>.
19041775
@ To change the logo image, use the following form:</p>
19051776
login_insert_csrf_secret();
19061777
@ Logo Image file:
19071778
@ <input type="file" name="logoim" size="60" accept="image/*" />
19081779
@ <p align="center">
@@ -1919,12 +1790,12 @@
19191790
@ <form action="%s(g.zTop)/setup_logo" method="post"
19201791
@ enctype="multipart/form-data"><div>
19211792
@ <p>The background image is accessible to all users at this URL:
19221793
@ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
19231794
@ 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>.
1795
+ @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1796
+ @ <a href="setup_skinedit?w=2">header setup</a>.
19261797
@ To change the background image, use the following form:</p>
19271798
login_insert_csrf_secret();
19281799
@ Background image file:
19291800
@ <input type="file" name="bgim" size="60" accept="image/*" />
19301801
@ <p align="center">
@@ -1966,10 +1837,11 @@
19661837
19671838
/*
19681839
** WEBPAGE: admin_sql
19691840
**
19701841
** Run raw SQL commands against the database file using the web interface.
1842
+** Requires Admin privileges.
19711843
*/
19721844
void sql_page(void){
19731845
const char *zQ = P("q");
19741846
int go = P("go")!=0;
19751847
login_check_credentials();
@@ -2087,11 +1959,11 @@
20871959
/*
20881960
** WEBPAGE: admin_th1
20891961
**
20901962
** Run raw TH1 commands using the web interface. If Tcl integration was
20911963
** enabled at compile-time and the "tcl" setting is enabled, Tcl commands
2092
-** may be run as well.
1964
+** may be run as well. Requires Admin privilege.
20931965
*/
20941966
void th1_page(void){
20951967
const char *zQ = P("q");
20961968
int go = P("go")!=0;
20971969
login_check_credentials();
@@ -2208,11 +2080,11 @@
22082080
}
22092081
22102082
/*
22112083
** WEBPAGE: srchsetup
22122084
**
2213
-** Configure the search engine.
2085
+** Configure the search engine. Requires Admin privilege.
22142086
*/
22152087
void page_srchsetup(){
22162088
login_check_credentials();
22172089
if( !g.perm.Setup && !g.perm.Admin ){
22182090
login_needed(0);
22192091
--- src/setup.c
+++ src/setup.c
@@ -54,11 +54,13 @@
54 }
55
56
57
58 /*
59 ** WEBPAGE: /setup
 
 
60 */
61 void setup_page(void){
62 login_check_credentials();
63 if( !g.perm.Setup ){
64 login_needed(0);
@@ -69,11 +71,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 +109,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");
@@ -129,12 +125,12 @@
129 "A record of received artifacts and their sources");
130 setup_menu_entry("User Log", "access_log",
131 "A record of login attempts");
132 setup_menu_entry("Administrative Log", "admin_log",
133 "View the admin_log entries");
134 setup_menu_entry("Stats", "stat",
135 "Display repository statistics");
136 setup_menu_entry("SQL", "admin_sql",
137 "Enter raw SQL commands");
138 setup_menu_entry("TH1", "admin_th1",
139 "Enter raw TH1 commands");
140 @ </table>
@@ -144,11 +140,11 @@
144
145 /*
146 ** WEBPAGE: setup_ulist
147 **
148 ** Show a list of users. Clicking on any user jumps to the edit
149 ** screen for that user.
150 */
151 void setup_ulist(void){
152 Stmt s;
153 int prevLevel = 0;
154
@@ -319,11 +315,14 @@
319 while( zPw[0]=='*' ){ zPw++; }
320 return zPw[0]!=0;
321 }
322
323 /*
324 ** WEBPAGE: /setup_uedit
 
 
 
325 */
326 void user_edit(void){
327 const char *zId, *zLogin, *zInfo, *zCap, *zPw;
328 const char *zGroup;
329 const char *zOldLogin;
@@ -930,11 +929,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 +958,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 */
@@ -994,10 +994,12 @@
994 }
995
996
997 /*
998 ** WEBPAGE: setup_access
 
 
999 */
1000 void setup_access(void){
1001 login_check_credentials();
1002 if( !g.perm.Setup ){
1003 login_needed(0);
@@ -1191,10 +1193,13 @@
1191 style_footer();
1192 }
1193
1194 /*
1195 ** WEBPAGE: setup_login_group
 
 
 
1196 */
1197 void setup_login_group(void){
1198 const char *zGroup;
1199 char *zErrMsg = 0;
1200 Blob fullName;
@@ -1304,10 +1309,13 @@
1304 style_footer();
1305 }
1306
1307 /*
1308 ** WEBPAGE: setup_timeline
 
 
 
1309 */
1310 void setup_timeline(void){
1311 double tmDiff;
1312 char zTmDiff[20];
1313 static const char *const azTimeFormats[] = {
@@ -1390,10 +1398,13 @@
1390 style_footer();
1391 }
1392
1393 /*
1394 ** WEBPAGE: setup_settings
 
 
 
1395 */
1396 void setup_settings(void){
1397 Setting const *pSet;
1398
1399 login_check_credentials();
@@ -1473,10 +1484,12 @@
1473 style_footer();
1474 }
1475
1476 /*
1477 ** WEBPAGE: setup_config
 
 
1478 */
1479 void setup_config(void){
1480 login_check_credentials();
1481 if( !g.perm.Setup ){
1482 login_needed(0);
@@ -1550,161 +1563,14 @@
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();
1709 if( !g.perm.Setup ){
1710 login_needed(0);
@@ -1746,10 +1612,13 @@
1746
1747 }
1748
1749 /*
1750 ** WEBPAGE: setup_adunit
 
 
 
1751 */
1752 void setup_adunit(void){
1753 login_check_credentials();
1754 if( !g.perm.Setup ){
1755 login_needed(0);
@@ -1783,11 +1652,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 @ }
@@ -1814,10 +1683,12 @@
1814 db_end_transaction(0);
1815 }
1816
1817 /*
1818 ** WEBPAGE: setup_logo
 
 
1819 */
1820 void setup_logo(void){
1821 const char *zLogoMtime = db_get_mtime("logo-image", 0, 0);
1822 const char *zLogoMime = db_get("logo-mimetype","image/gif");
1823 const char *aLogoImg = P("logoim");
@@ -1897,12 +1768,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 +1790,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">
@@ -1966,10 +1837,11 @@
1966
1967 /*
1968 ** WEBPAGE: admin_sql
1969 **
1970 ** Run raw SQL commands against the database file using the web interface.
 
1971 */
1972 void sql_page(void){
1973 const char *zQ = P("q");
1974 int go = P("go")!=0;
1975 login_check_credentials();
@@ -2087,11 +1959,11 @@
2087 /*
2088 ** WEBPAGE: admin_th1
2089 **
2090 ** Run raw TH1 commands using the web interface. If Tcl integration was
2091 ** enabled at compile-time and the "tcl" setting is enabled, Tcl commands
2092 ** may be run as well.
2093 */
2094 void th1_page(void){
2095 const char *zQ = P("q");
2096 int go = P("go")!=0;
2097 login_check_credentials();
@@ -2208,11 +2080,11 @@
2208 }
2209
2210 /*
2211 ** WEBPAGE: srchsetup
2212 **
2213 ** Configure the search engine.
2214 */
2215 void page_srchsetup(){
2216 login_check_credentials();
2217 if( !g.perm.Setup && !g.perm.Admin ){
2218 login_needed(0);
2219
--- src/setup.c
+++ src/setup.c
@@ -54,11 +54,13 @@
54 }
55
56
57
58 /*
59 ** WEBPAGE: setup
60 **
61 ** Main menu for the administrative pages. Requires Admin privileges.
62 */
63 void setup_page(void){
64 login_check_credentials();
65 if( !g.perm.Setup ){
66 login_needed(0);
@@ -69,11 +71,11 @@
71 /* Make sure the header contains <base href="...">. Issue a warning
72 ** if it does not. */
73 if( !cgi_header_contains("<base href=") ){
74 @ <p class="generalError"><b>Configuration Error:</b> Please add
75 @ <tt>&lt;base href="$secureurl/$current_page"&gt;</tt> after
76 @ <tt>&lt;head&gt;</tt> in the <a href="setup_skinedit?w=2">HTML header</a>!</p>
77 }
78
79 #if !defined(_WIN32)
80 /* Check for /dev/null and /dev/urandom. We want both devices to be present,
81 ** but they are sometimes omitted (by mistake) from chroot jails. */
@@ -107,17 +109,11 @@
109 setup_menu_entry("Search","srchsetup",
110 "Configure the built-in search engine");
111 setup_menu_entry("Transfers", "xfersetup",
112 "Configure the transfer system for this repository");
113 setup_menu_entry("Skins", "setup_skin",
114 "Select and/or modify the web interface \"skins\"");
 
 
 
 
 
 
115 setup_menu_entry("Moderation", "setup_modreq",
116 "Enable/Disable requiring moderator approval of Wiki and/or Ticket"
117 " changes and attachments.");
118 setup_menu_entry("Ad-Unit", "setup_adunit",
119 "Edit HTML text for an ad unit inserted after the menu bar");
@@ -129,12 +125,12 @@
125 "A record of received artifacts and their sources");
126 setup_menu_entry("User Log", "access_log",
127 "A record of login attempts");
128 setup_menu_entry("Administrative Log", "admin_log",
129 "View the admin_log entries");
130 setup_menu_entry("Sitemap", "sitemap",
131 "Links to miscellaneous pages");
132 setup_menu_entry("SQL", "admin_sql",
133 "Enter raw SQL commands");
134 setup_menu_entry("TH1", "admin_th1",
135 "Enter raw TH1 commands");
136 @ </table>
@@ -144,11 +140,11 @@
140
141 /*
142 ** WEBPAGE: setup_ulist
143 **
144 ** Show a list of users. Clicking on any user jumps to the edit
145 ** screen for that user. Requires Admin privileges.
146 */
147 void setup_ulist(void){
148 Stmt s;
149 int prevLevel = 0;
150
@@ -319,11 +315,14 @@
315 while( zPw[0]=='*' ){ zPw++; }
316 return zPw[0]!=0;
317 }
318
319 /*
320 ** WEBPAGE: setup_uedit
321 **
322 ** Edit information about a user or create a new user.
323 ** Requires Admin privileges.
324 */
325 void user_edit(void){
326 const char *zId, *zLogin, *zInfo, *zCap, *zPw;
327 const char *zGroup;
328 const char *zOldLogin;
@@ -930,11 +929,11 @@
929 }
930
931 /*
932 ** Generate a text box for an attribute.
933 */
934 const char *textarea_attribute(
935 const char *zLabel, /* The text label on the textarea */
936 int rows, /* Rows in the textarea */
937 int cols, /* Columns in the textarea */
938 const char *zVar, /* The corresponding row in the VAR table */
939 const char *zQP, /* The query parameter */
@@ -959,10 +958,11 @@
958 @ cols="%d(cols)">%h(z)</textarea>
959 if( zLabel && *zLabel ){
960 @ <span class="textareaLabel">%s(zLabel)</span>
961 }
962 }
963 return z;
964 }
965
966 /*
967 ** Generate a text box for an attribute.
968 */
@@ -994,10 +994,12 @@
994 }
995
996
997 /*
998 ** WEBPAGE: setup_access
999 **
1000 ** The access-control settings page. Requires Admin privileges.
1001 */
1002 void setup_access(void){
1003 login_check_credentials();
1004 if( !g.perm.Setup ){
1005 login_needed(0);
@@ -1191,10 +1193,13 @@
1193 style_footer();
1194 }
1195
1196 /*
1197 ** WEBPAGE: setup_login_group
1198 **
1199 ** Change how the current repository participates in a login
1200 ** group.
1201 */
1202 void setup_login_group(void){
1203 const char *zGroup;
1204 char *zErrMsg = 0;
1205 Blob fullName;
@@ -1304,10 +1309,13 @@
1309 style_footer();
1310 }
1311
1312 /*
1313 ** WEBPAGE: setup_timeline
1314 **
1315 ** Edit administrative settings controlling the display of
1316 ** timelines.
1317 */
1318 void setup_timeline(void){
1319 double tmDiff;
1320 char zTmDiff[20];
1321 static const char *const azTimeFormats[] = {
@@ -1390,10 +1398,13 @@
1398 style_footer();
1399 }
1400
1401 /*
1402 ** WEBPAGE: setup_settings
1403 **
1404 ** Change or view miscellanous settings. Part of the
1405 ** Admin pages requiring Admin privileges.
1406 */
1407 void setup_settings(void){
1408 Setting const *pSet;
1409
1410 login_check_credentials();
@@ -1473,10 +1484,12 @@
1484 style_footer();
1485 }
1486
1487 /*
1488 ** WEBPAGE: setup_config
1489 **
1490 ** The "Admin/Configuration" page. Requires Admin privilege.
1491 */
1492 void setup_config(void){
1493 login_check_credentials();
1494 if( !g.perm.Setup ){
1495 login_needed(0);
@@ -1550,161 +1563,14 @@
1563 @ </div></form>
1564 db_end_transaction(0);
1565 style_footer();
1566 }
1567
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1568 /*
1569 ** WEBPAGE: setup_modreq
1570 **
1571 ** Admin page for setting up moderation of tickets and wiki.
1572 */
1573 void setup_modreq(void){
1574 login_check_credentials();
1575 if( !g.perm.Setup ){
1576 login_needed(0);
@@ -1746,10 +1612,13 @@
1612
1613 }
1614
1615 /*
1616 ** WEBPAGE: setup_adunit
1617 **
1618 ** Administrative page for configuring and controlling ad units
1619 ** and how they are displayed.
1620 */
1621 void setup_adunit(void){
1622 login_check_credentials();
1623 if( !g.perm.Setup ){
1624 login_needed(0);
@@ -1783,11 +1652,11 @@
1652 @ <b>Ad-Unit Notes:</b><ul>
1653 @ <li>Leave both Ad-Units blank to disable all advertising.
1654 @ <li>The "Banner Ad-Unit" is used for wide pages.
1655 @ <li>The "Right-Column Ad-Unit" is used on pages with tall, narrow content.
1656 @ <li>If the "Right-Column Ad-Unit" is blank, the "Banner Ad-Unit" is used on all pages.
1657 @ <li>Suggested <a href="setup_skinedit?w=0">CSS</a> changes:
1658 @ <blockquote><pre>
1659 @ div.adunit_banner {
1660 @ margin: auto;
1661 @ width: 100%;
1662 @ }
@@ -1814,10 +1683,12 @@
1683 db_end_transaction(0);
1684 }
1685
1686 /*
1687 ** WEBPAGE: setup_logo
1688 **
1689 ** Administrative page for changing the logo image.
1690 */
1691 void setup_logo(void){
1692 const char *zLogoMtime = db_get_mtime("logo-image", 0, 0);
1693 const char *zLogoMime = db_get("logo-mimetype","image/gif");
1694 const char *aLogoImg = P("logoim");
@@ -1897,12 +1768,12 @@
1768 @ <form action="%s(g.zTop)/setup_logo" method="post"
1769 @ enctype="multipart/form-data"><div>
1770 @ <p>The logo is accessible to all users at this URL:
1771 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1772 @ The logo may or may not appear on each
1773 @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1774 @ <a href="setup_skinedit?w=2">header setup</a>.
1775 @ To change the logo image, use the following form:</p>
1776 login_insert_csrf_secret();
1777 @ Logo Image file:
1778 @ <input type="file" name="logoim" size="60" accept="image/*" />
1779 @ <p align="center">
@@ -1919,12 +1790,12 @@
1790 @ <form action="%s(g.zTop)/setup_logo" method="post"
1791 @ enctype="multipart/form-data"><div>
1792 @ <p>The background image is accessible to all users at this URL:
1793 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1794 @ The background image may or may not appear on each
1795 @ page depending on the <a href="setup_skinedit?w=0">CSS</a> and
1796 @ <a href="setup_skinedit?w=2">header setup</a>.
1797 @ To change the background image, use the following form:</p>
1798 login_insert_csrf_secret();
1799 @ Background image file:
1800 @ <input type="file" name="bgim" size="60" accept="image/*" />
1801 @ <p align="center">
@@ -1966,10 +1837,11 @@
1837
1838 /*
1839 ** WEBPAGE: admin_sql
1840 **
1841 ** Run raw SQL commands against the database file using the web interface.
1842 ** Requires Admin privileges.
1843 */
1844 void sql_page(void){
1845 const char *zQ = P("q");
1846 int go = P("go")!=0;
1847 login_check_credentials();
@@ -2087,11 +1959,11 @@
1959 /*
1960 ** WEBPAGE: admin_th1
1961 **
1962 ** Run raw TH1 commands using the web interface. If Tcl integration was
1963 ** enabled at compile-time and the "tcl" setting is enabled, Tcl commands
1964 ** may be run as well. Requires Admin privilege.
1965 */
1966 void th1_page(void){
1967 const char *zQ = P("q");
1968 int go = P("go")!=0;
1969 login_check_credentials();
@@ -2208,11 +2080,11 @@
2080 }
2081
2082 /*
2083 ** WEBPAGE: srchsetup
2084 **
2085 ** Configure the search engine. Requires Admin privilege.
2086 */
2087 void page_srchsetup(){
2088 login_check_credentials();
2089 if( !g.perm.Setup && !g.perm.Admin ){
2090 login_needed(0);
2091
+178 -70
--- src/shell.c
+++ src/shell.c
@@ -334,11 +334,11 @@
334334
/*
335335
** The following is the open SQLite database. We make a pointer
336336
** to this database a static variable so that it can be accessed
337337
** by the SIGINT handler to interrupt database processing.
338338
*/
339
-static sqlite3 *db = 0;
339
+static sqlite3 *globalDb = 0;
340340
341341
/*
342342
** True if an interrupt (Control-C) has been received.
343343
*/
344344
static volatile int seenInterrupt = 0;
@@ -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);
@@ -525,10 +525,11 @@
525525
sqlite3 *db; /* The database */
526526
int echoOn; /* True to echo input commands */
527527
int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
528528
int statsOn; /* True to display memory stats before each finalize */
529529
int scanstatsOn; /* True to display scan stats before each finalize */
530
+ int backslashOn; /* Resolve C-style \x escapes in SQL input text */
530531
int outCount; /* Revert to stdout when reaching zero */
531532
int cnt; /* Number of records displayed so far */
532533
FILE *out; /* Write results here */
533534
FILE *traceOut; /* Output for sqlite3_trace() */
534535
int nErr; /* Number of errors seen */
@@ -802,11 +803,11 @@
802803
*/
803804
static void interrupt_handler(int NotUsed){
804805
UNUSED_PARAMETER(NotUsed);
805806
seenInterrupt++;
806807
if( seenInterrupt>2 ) exit(1);
807
- if( db ) sqlite3_interrupt(db);
808
+ if( globalDb ) sqlite3_interrupt(globalDb);
808809
}
809810
#endif
810811
811812
/*
812813
** This is the callback routine that the shell
@@ -987,11 +988,20 @@
987988
break;
988989
}
989990
case MODE_Insert: {
990991
p->cnt++;
991992
if( azArg==0 ) break;
992
- fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
993
+ fprintf(p->out,"INSERT INTO %s",p->zDestTable);
994
+ if( p->showHeader ){
995
+ fprintf(p->out,"(");
996
+ for(i=0; i<nArg; i++){
997
+ char *zSep = i>0 ? ",": "";
998
+ fprintf(p->out, "%s%s", zSep, azCol[i]);
999
+ }
1000
+ fprintf(p->out,")");
1001
+ }
1002
+ fprintf(p->out," VALUES(");
9931003
for(i=0; i<nArg; i++){
9941004
char *zSep = i>0 ? ",": "";
9951005
if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
9961006
fprintf(p->out,"%sNULL",zSep);
9971007
}else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1188,11 +1198,11 @@
11881198
*/
11891199
static char *save_err_msg(
11901200
sqlite3 *db /* Database to query */
11911201
){
11921202
int nErrMsg = 1+strlen30(sqlite3_errmsg(db));
1193
- char *zErrMsg = sqlite3_malloc(nErrMsg);
1203
+ char *zErrMsg = sqlite3_malloc64(nErrMsg);
11941204
if( zErrMsg ){
11951205
memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);
11961206
}
11971207
return zErrMsg;
11981208
}
@@ -1425,12 +1435,12 @@
14251435
int p2op = (p2 + (iOp-iAddr));
14261436
14271437
/* Grow the p->aiIndent array as required */
14281438
if( iOp>=nAlloc ){
14291439
nAlloc += 100;
1430
- p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int));
1431
- abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int));
1440
+ p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
1441
+ abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
14321442
}
14331443
abYield[iOp] = str_in_array(zOp, azYield);
14341444
p->aiIndent[iOp] = 0;
14351445
p->nIndent = iOp+1;
14361446
@@ -1543,11 +1553,11 @@
15431553
if( SQLITE_ROW == rc ){
15441554
/* if we have a callback... */
15451555
if( xCallback ){
15461556
/* allocate space for col name ptr, value ptr, and type */
15471557
int nCol = sqlite3_column_count(pStmt);
1548
- void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1);
1558
+ void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);
15491559
if( !pData ){
15501560
rc = SQLITE_NOMEM;
15511561
}else{
15521562
char **azCols = (char **)pData; /* Names of result columns */
15531563
char **azVals = &azCols[nCol]; /* Results */
@@ -1769,10 +1779,11 @@
17691779
** Text of a help message
17701780
*/
17711781
static char zHelp[] =
17721782
".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
17731783
".bail on|off Stop after hitting an error. Default OFF\n"
1784
+ ".binary on|off Turn binary output on or off. Default OFF\n"
17741785
".clone NEWDB Clone data into NEWDB from the existing database\n"
17751786
".databases List names and files of attached databases\n"
17761787
".dbinfo ?DB? Show status information about the database\n"
17771788
".dump ?TABLE? ... Dump the database in an SQL text format\n"
17781789
" If TABLE specified, only dump tables matching\n"
@@ -1790,10 +1801,11 @@
17901801
" If TABLE specified, only show indexes for tables\n"
17911802
" matching LIKE pattern TABLE.\n"
17921803
#ifdef SQLITE_ENABLE_IOTRACE
17931804
".iotrace FILE Enable I/O diagnostic logging to FILE\n"
17941805
#endif
1806
+ ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n"
17951807
#ifndef SQLITE_OMIT_LOAD_EXTENSION
17961808
".load FILE ?ENTRY? Load an extension library\n"
17971809
#endif
17981810
".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
17991811
".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
@@ -1859,11 +1871,11 @@
18591871
in = fopen(zName, "rb");
18601872
if( in==0 ) return;
18611873
fseek(in, 0, SEEK_END);
18621874
nIn = ftell(in);
18631875
rewind(in);
1864
- pBuf = sqlite3_malloc( nIn );
1876
+ pBuf = sqlite3_malloc64( nIn );
18651877
if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
18661878
sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
18671879
}else{
18681880
sqlite3_free(pBuf);
18691881
}
@@ -1906,54 +1918,72 @@
19061918
*/
19071919
static void open_db(ShellState *p, int keepAlive){
19081920
if( p->db==0 ){
19091921
sqlite3_initialize();
19101922
sqlite3_open(p->zDbFilename, &p->db);
1911
- db = p->db;
1912
- if( db && sqlite3_errcode(db)==SQLITE_OK ){
1913
- sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
1923
+ globalDb = p->db;
1924
+ if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){
1925
+ sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0,
19141926
shellstaticFunc, 0, 0);
19151927
}
1916
- if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
1928
+ if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
19171929
fprintf(stderr,"Error: unable to open database \"%s\": %s\n",
1918
- p->zDbFilename, sqlite3_errmsg(db));
1930
+ p->zDbFilename, sqlite3_errmsg(p->db));
19191931
if( keepAlive ) return;
19201932
exit(1);
19211933
}
19221934
#ifndef SQLITE_OMIT_LOAD_EXTENSION
19231935
sqlite3_enable_load_extension(p->db, 1);
19241936
#endif
1925
- sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
1937
+ sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
19261938
readfileFunc, 0, 0);
1927
- sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
1939
+ sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
19281940
writefileFunc, 0, 0);
19291941
}
19301942
}
19311943
19321944
/*
19331945
** Do C-language style dequoting.
19341946
**
1947
+** \a -> alarm
1948
+** \b -> backspace
19351949
** \t -> tab
19361950
** \n -> newline
1951
+** \v -> vertical tab
1952
+** \f -> form feed
19371953
** \r -> carriage return
1954
+** \s -> space
19381955
** \" -> "
1939
-** \NNN -> ascii character NNN in octal
1956
+** \' -> '
19401957
** \\ -> backslash
1958
+** \NNN -> ascii character NNN in octal
19411959
*/
19421960
static void resolve_backslashes(char *z){
19431961
int i, j;
19441962
char c;
19451963
while( *z && *z!='\\' ) z++;
19461964
for(i=j=0; (c = z[i])!=0; i++, j++){
1947
- if( c=='\\' ){
1965
+ if( c=='\\' && z[i+1]!=0 ){
19481966
c = z[++i];
1949
- if( c=='n' ){
1950
- c = '\n';
1967
+ if( c=='a' ){
1968
+ c = '\a';
1969
+ }else if( c=='b' ){
1970
+ c = '\b';
19511971
}else if( c=='t' ){
19521972
c = '\t';
1973
+ }else if( c=='n' ){
1974
+ c = '\n';
1975
+ }else if( c=='v' ){
1976
+ c = '\v';
1977
+ }else if( c=='f' ){
1978
+ c = '\f';
19531979
}else if( c=='r' ){
19541980
c = '\r';
1981
+ }else if( c=='"' ){
1982
+ c = '"';
1983
+ }else if( c=='\'' ){
1984
+ c = '\'';
19551985
}else if( c=='\\' ){
19561986
c = '\\';
19571987
}else if( c>='0' && c<='7' ){
19581988
c -= '0';
19591989
if( z[i+1]>='0' && z[i+1]<='7' ){
@@ -2119,11 +2149,11 @@
21192149
21202150
/* Append a single byte to z[] */
21212151
static void import_append_char(ImportCtx *p, int c){
21222152
if( p->n+1>=p->nAlloc ){
21232153
p->nAlloc += p->nAlloc + 100;
2124
- p->z = sqlite3_realloc(p->z, p->nAlloc);
2154
+ p->z = sqlite3_realloc64(p->z, p->nAlloc);
21252155
if( p->z==0 ){
21262156
fprintf(stderr, "out of memory\n");
21272157
exit(1);
21282158
}
21292159
}
@@ -2133,11 +2163,11 @@
21332163
/* Read a single field of CSV text. Compatible with rfc4180 and extended
21342164
** with the option of having a separator other than ",".
21352165
**
21362166
** + Input comes from p->in.
21372167
** + Store results in p->z of length p->n. Space to hold p->z comes
2138
-** from sqlite3_malloc().
2168
+** from sqlite3_malloc64().
21392169
** + Use p->cSep as the column separator. The default is ",".
21402170
** + Use p->rSep as the row separator. The default is "\n".
21412171
** + Keep track of the line number in p->nLine.
21422172
** + Store the character that terminates the field in p->cTerm. Store
21432173
** EOF on end-of-file.
@@ -2207,11 +2237,11 @@
22072237
22082238
/* Read a single field of ASCII delimited text.
22092239
**
22102240
** + Input comes from p->in.
22112241
** + Store results in p->z of length p->n. Space to hold p->z comes
2212
-** from sqlite3_malloc().
2242
+** from sqlite3_malloc64().
22132243
** + Use p->cSep as the column separator. The default is "\x1F".
22142244
** + Use p->rSep as the row separator. The default is "\x1E".
22152245
** + Keep track of the row number in p->nLine.
22162246
** + Store the character that terminates the field in p->cTerm. Store
22172247
** EOF on end-of-file.
@@ -2267,11 +2297,11 @@
22672297
sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
22682298
zQuery);
22692299
goto end_data_xfer;
22702300
}
22712301
n = sqlite3_column_count(pQuery);
2272
- zInsert = sqlite3_malloc(200 + nTable + n*3);
2302
+ zInsert = sqlite3_malloc64(200 + nTable + n*3);
22732303
if( zInsert==0 ){
22742304
fprintf(stderr, "out of memory\n");
22752305
goto end_data_xfer;
22762306
}
22772307
sqlite3_snprintf(200+nTable,zInsert,
@@ -2583,36 +2613,36 @@
25832613
** process that line.
25842614
**
25852615
** Return 1 on error, 2 to exit, and 0 otherwise.
25862616
*/
25872617
static int do_meta_command(char *zLine, ShellState *p){
2588
- int i = 1;
2618
+ int h = 1;
25892619
int nArg = 0;
25902620
int n, c;
25912621
int rc = 0;
25922622
char *azArg[50];
25932623
25942624
/* Parse the input line into tokens.
25952625
*/
2596
- while( zLine[i] && nArg<ArraySize(azArg) ){
2597
- while( IsSpace(zLine[i]) ){ i++; }
2598
- if( zLine[i]==0 ) break;
2599
- if( zLine[i]=='\'' || zLine[i]=='"' ){
2600
- int delim = zLine[i++];
2601
- azArg[nArg++] = &zLine[i];
2602
- while( zLine[i] && zLine[i]!=delim ){
2603
- if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
2604
- i++;
2605
- }
2606
- if( zLine[i]==delim ){
2607
- zLine[i++] = 0;
2626
+ while( zLine[h] && nArg<ArraySize(azArg) ){
2627
+ while( IsSpace(zLine[h]) ){ h++; }
2628
+ if( zLine[h]==0 ) break;
2629
+ if( zLine[h]=='\'' || zLine[h]=='"' ){
2630
+ int delim = zLine[h++];
2631
+ azArg[nArg++] = &zLine[h];
2632
+ while( zLine[h] && zLine[h]!=delim ){
2633
+ if( zLine[h]=='\\' && delim=='"' && zLine[h+1]!=0 ) h++;
2634
+ h++;
2635
+ }
2636
+ if( zLine[h]==delim ){
2637
+ zLine[h++] = 0;
26082638
}
26092639
if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
26102640
}else{
2611
- azArg[nArg++] = &zLine[i];
2612
- while( zLine[i] && !IsSpace(zLine[i]) ){ i++; }
2613
- if( zLine[i] ) zLine[i++] = 0;
2641
+ azArg[nArg++] = &zLine[h];
2642
+ while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
2643
+ if( zLine[h] ) zLine[h++] = 0;
26142644
resolve_backslashes(azArg[nArg-1]);
26152645
}
26162646
}
26172647
26182648
/* Process the input line.
@@ -2682,10 +2712,23 @@
26822712
}else{
26832713
fprintf(stderr, "Usage: .bail on|off\n");
26842714
rc = 1;
26852715
}
26862716
}else
2717
+
2718
+ if( c=='b' && n>=3 && strncmp(azArg[0], "binary", n)==0 ){
2719
+ if( nArg==2 ){
2720
+ if( booleanValue(azArg[1]) ){
2721
+ setBinaryMode(p->out);
2722
+ }else{
2723
+ setTextMode(p->out);
2724
+ }
2725
+ }else{
2726
+ fprintf(stderr, "Usage: .binary on|off\n");
2727
+ rc = 1;
2728
+ }
2729
+ }else
26872730
26882731
/* The undocumented ".breakpoint" command causes a call to the no-op
26892732
** routine named test_breakpoint().
26902733
*/
26912734
if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
@@ -2984,11 +3027,11 @@
29843027
return 1;
29853028
}
29863029
nByte = strlen30(zSql);
29873030
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
29883031
import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
2989
- if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
3032
+ if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
29903033
char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
29913034
char cSep = '(';
29923035
while( xRead(&sCtx) ){
29933036
zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCtx.z);
29943037
cSep = ',';
@@ -3004,29 +3047,29 @@
30043047
zCreate = sqlite3_mprintf("%z\n)", zCreate);
30053048
rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
30063049
sqlite3_free(zCreate);
30073050
if( rc ){
30083051
fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
3009
- sqlite3_errmsg(db));
3052
+ sqlite3_errmsg(p->db));
30103053
sqlite3_free(sCtx.z);
30113054
xCloser(sCtx.in);
30123055
return 1;
30133056
}
30143057
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
30153058
}
30163059
sqlite3_free(zSql);
30173060
if( rc ){
30183061
if (pStmt) sqlite3_finalize(pStmt);
3019
- fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
3062
+ fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
30203063
xCloser(sCtx.in);
30213064
return 1;
30223065
}
30233066
nCol = sqlite3_column_count(pStmt);
30243067
sqlite3_finalize(pStmt);
30253068
pStmt = 0;
30263069
if( nCol==0 ) return 0; /* no columns, no error */
3027
- zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
3070
+ zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
30283071
if( zSql==0 ){
30293072
fprintf(stderr, "Error: out of memory\n");
30303073
xCloser(sCtx.in);
30313074
return 1;
30323075
}
@@ -3039,17 +3082,17 @@
30393082
zSql[j++] = ')';
30403083
zSql[j] = 0;
30413084
rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
30423085
sqlite3_free(zSql);
30433086
if( rc ){
3044
- fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
3087
+ fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
30453088
if (pStmt) sqlite3_finalize(pStmt);
30463089
xCloser(sCtx.in);
30473090
return 1;
30483091
}
3049
- needCommit = sqlite3_get_autocommit(db);
3050
- if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
3092
+ needCommit = sqlite3_get_autocommit(p->db);
3093
+ if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
30513094
do{
30523095
int startLine = sCtx.nLine;
30533096
for(i=0; i<nCol; i++){
30543097
char *z = xRead(&sCtx);
30553098
/*
@@ -3084,19 +3127,19 @@
30843127
if( i>=nCol ){
30853128
sqlite3_step(pStmt);
30863129
rc = sqlite3_reset(pStmt);
30873130
if( rc!=SQLITE_OK ){
30883131
fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, startLine,
3089
- sqlite3_errmsg(db));
3132
+ sqlite3_errmsg(p->db));
30903133
}
30913134
}
30923135
}while( sCtx.cTerm!=EOF );
30933136
30943137
xCloser(sCtx.in);
30953138
sqlite3_free(sCtx.z);
30963139
sqlite3_finalize(pStmt);
3097
- if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
3140
+ if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
30983141
}else
30993142
31003143
if( c=='i' && (strncmp(azArg[0], "indices", n)==0
31013144
|| strncmp(azArg[0], "indexes", n)==0) ){
31023145
ShellState data;
@@ -3142,11 +3185,11 @@
31423185
}
31433186
}else
31443187
31453188
#ifdef SQLITE_ENABLE_IOTRACE
31463189
if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
3147
- extern void (*sqlite3IoTrace)(const char*, ...);
3190
+ SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
31483191
if( iotrace && iotrace!=stdout ) fclose(iotrace);
31493192
iotrace = 0;
31503193
if( nArg<2 ){
31513194
sqlite3IoTrace = 0;
31523195
}else if( strcmp(azArg[1], "-")==0 ){
@@ -3162,10 +3205,67 @@
31623205
sqlite3IoTrace = iotracePrintf;
31633206
}
31643207
}
31653208
}else
31663209
#endif
3210
+ if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){
3211
+ static const struct {
3212
+ const char *zLimitName; /* Name of a limit */
3213
+ int limitCode; /* Integer code for that limit */
3214
+ } aLimit[] = {
3215
+ { "length", SQLITE_LIMIT_LENGTH },
3216
+ { "sql_length", SQLITE_LIMIT_SQL_LENGTH },
3217
+ { "column", SQLITE_LIMIT_COLUMN },
3218
+ { "expr_depth", SQLITE_LIMIT_EXPR_DEPTH },
3219
+ { "compound_select", SQLITE_LIMIT_COMPOUND_SELECT },
3220
+ { "vdbe_op", SQLITE_LIMIT_VDBE_OP },
3221
+ { "function_arg", SQLITE_LIMIT_FUNCTION_ARG },
3222
+ { "attached", SQLITE_LIMIT_ATTACHED },
3223
+ { "like_pattern_length", SQLITE_LIMIT_LIKE_PATTERN_LENGTH },
3224
+ { "variable_number", SQLITE_LIMIT_VARIABLE_NUMBER },
3225
+ { "trigger_depth", SQLITE_LIMIT_TRIGGER_DEPTH },
3226
+ { "worker_threads", SQLITE_LIMIT_WORKER_THREADS },
3227
+ };
3228
+ int i, n2;
3229
+ open_db(p, 0);
3230
+ if( nArg==1 ){
3231
+ for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
3232
+ printf("%20s %d\n", aLimit[i].zLimitName,
3233
+ sqlite3_limit(p->db, aLimit[i].limitCode, -1));
3234
+ }
3235
+ }else if( nArg>3 ){
3236
+ fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n");
3237
+ rc = 1;
3238
+ goto meta_command_exit;
3239
+ }else{
3240
+ int iLimit = -1;
3241
+ n2 = strlen30(azArg[1]);
3242
+ for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
3243
+ if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){
3244
+ if( iLimit<0 ){
3245
+ iLimit = i;
3246
+ }else{
3247
+ fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]);
3248
+ rc = 1;
3249
+ goto meta_command_exit;
3250
+ }
3251
+ }
3252
+ }
3253
+ if( iLimit<0 ){
3254
+ fprintf(stderr, "unknown limit: \"%s\"\n"
3255
+ "enter \".limits\" with no arguments for a list.\n",
3256
+ azArg[1]);
3257
+ rc = 1;
3258
+ goto meta_command_exit;
3259
+ }
3260
+ if( nArg==3 ){
3261
+ sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2]));
3262
+ }
3263
+ printf("%20s %d\n", aLimit[iLimit].zLimitName,
3264
+ sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));
3265
+ }
3266
+ }else
31673267
31683268
#ifndef SQLITE_OMIT_LOAD_EXTENSION
31693269
if( c=='l' && strncmp(azArg[0], "load", n)==0 ){
31703270
const char *zFile, *zProc;
31713271
char *zErrMsg = 0;
@@ -3646,17 +3746,17 @@
36463746
sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
36473747
}
36483748
while( sqlite3_step(pStmt)==SQLITE_ROW ){
36493749
if( nRow>=nAlloc ){
36503750
char **azNew;
3651
- int n = nAlloc*2 + 10;
3652
- azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n);
3751
+ int n2 = nAlloc*2 + 10;
3752
+ azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
36533753
if( azNew==0 ){
36543754
fprintf(stderr, "Error: out of memory\n");
36553755
break;
36563756
}
3657
- nAlloc = n;
3757
+ nAlloc = n2;
36583758
azResult = azNew;
36593759
}
36603760
azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
36613761
if( azResult[nRow] ) nRow++;
36623762
}
@@ -3705,19 +3805,19 @@
37053805
{ "byteorder", SQLITE_TESTCTRL_BYTEORDER },
37063806
{ "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
37073807
{ "imposter", SQLITE_TESTCTRL_IMPOSTER },
37083808
};
37093809
int testctrl = -1;
3710
- int rc = 0;
3711
- int i, n;
3810
+ int rc2 = 0;
3811
+ int i, n2;
37123812
open_db(p, 0);
37133813
37143814
/* convert testctrl text option to value. allow any unique prefix
37153815
** of the option name, or a numerical value. */
3716
- n = strlen30(azArg[1]);
3816
+ n2 = strlen30(azArg[1]);
37173817
for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){
3718
- if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){
3818
+ if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){
37193819
if( testctrl<0 ){
37203820
testctrl = aCtrl[i].ctrlCode;
37213821
}else{
37223822
fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]);
37233823
testctrl = -1;
@@ -3734,12 +3834,12 @@
37343834
/* sqlite3_test_control(int, db, int) */
37353835
case SQLITE_TESTCTRL_OPTIMIZATIONS:
37363836
case SQLITE_TESTCTRL_RESERVE:
37373837
if( nArg==3 ){
37383838
int opt = (int)strtol(azArg[2], 0, 0);
3739
- rc = sqlite3_test_control(testctrl, p->db, opt);
3740
- fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3839
+ rc2 = sqlite3_test_control(testctrl, p->db, opt);
3840
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
37413841
} else {
37423842
fprintf(stderr,"Error: testctrl %s takes a single int option\n",
37433843
azArg[1]);
37443844
}
37453845
break;
@@ -3748,23 +3848,23 @@
37483848
case SQLITE_TESTCTRL_PRNG_SAVE:
37493849
case SQLITE_TESTCTRL_PRNG_RESTORE:
37503850
case SQLITE_TESTCTRL_PRNG_RESET:
37513851
case SQLITE_TESTCTRL_BYTEORDER:
37523852
if( nArg==2 ){
3753
- rc = sqlite3_test_control(testctrl);
3754
- fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3853
+ rc2 = sqlite3_test_control(testctrl);
3854
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
37553855
} else {
37563856
fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]);
37573857
}
37583858
break;
37593859
37603860
/* sqlite3_test_control(int, uint) */
37613861
case SQLITE_TESTCTRL_PENDING_BYTE:
37623862
if( nArg==3 ){
37633863
unsigned int opt = (unsigned int)integerValue(azArg[2]);
3764
- rc = sqlite3_test_control(testctrl, opt);
3765
- fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3864
+ rc2 = sqlite3_test_control(testctrl, opt);
3865
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
37663866
} else {
37673867
fprintf(stderr,"Error: testctrl %s takes a single unsigned"
37683868
" int option\n", azArg[1]);
37693869
}
37703870
break;
@@ -3773,12 +3873,12 @@
37733873
case SQLITE_TESTCTRL_ASSERT:
37743874
case SQLITE_TESTCTRL_ALWAYS:
37753875
case SQLITE_TESTCTRL_NEVER_CORRUPT:
37763876
if( nArg==3 ){
37773877
int opt = booleanValue(azArg[2]);
3778
- rc = sqlite3_test_control(testctrl, opt);
3779
- fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3878
+ rc2 = sqlite3_test_control(testctrl, opt);
3879
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
37803880
} else {
37813881
fprintf(stderr,"Error: testctrl %s takes a single int option\n",
37823882
azArg[1]);
37833883
}
37843884
break;
@@ -3786,28 +3886,28 @@
37863886
/* sqlite3_test_control(int, char *) */
37873887
#ifdef SQLITE_N_KEYWORD
37883888
case SQLITE_TESTCTRL_ISKEYWORD:
37893889
if( nArg==3 ){
37903890
const char *opt = azArg[2];
3791
- rc = sqlite3_test_control(testctrl, opt);
3792
- fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3891
+ rc2 = sqlite3_test_control(testctrl, opt);
3892
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
37933893
} else {
37943894
fprintf(stderr,"Error: testctrl %s takes a single char * option\n",
37953895
azArg[1]);
37963896
}
37973897
break;
37983898
#endif
37993899
38003900
case SQLITE_TESTCTRL_IMPOSTER:
38013901
if( nArg==5 ){
3802
- rc = sqlite3_test_control(testctrl, p->db,
3902
+ rc2 = sqlite3_test_control(testctrl, p->db,
38033903
azArg[2],
38043904
integerValue(azArg[3]),
38053905
integerValue(azArg[4]));
3906
+ fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
38063907
}else{
3807
- fprintf(stderr,"Usage: .testctrl initmode dbName onoff tnum\n");
3808
- rc = 1;
3908
+ fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
38093909
}
38103910
break;
38113911
38123912
case SQLITE_TESTCTRL_BITVEC_TEST:
38133913
case SQLITE_TESTCTRL_FAULT_INSTALL:
@@ -4109,10 +4209,11 @@
41094209
}
41104210
if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
41114211
&& sqlite3_complete(zSql) ){
41124212
p->cnt = 0;
41134213
open_db(p, 0);
4214
+ if( p->backslashOn ) resolve_backslashes(zSql);
41144215
BEGIN_TIMER;
41154216
rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);
41164217
END_TIMER;
41174218
if( rc || zErrMsg ){
41184219
char zPrefix[100];
@@ -4575,10 +4676,17 @@
45754676
data.autoEQP = 1;
45764677
}else if( strcmp(z,"-stats")==0 ){
45774678
data.statsOn = 1;
45784679
}else if( strcmp(z,"-scanstats")==0 ){
45794680
data.scanstatsOn = 1;
4681
+ }else if( strcmp(z,"-backslash")==0 ){
4682
+ /* Undocumented command-line option: -backslash
4683
+ ** Causes C-style backslash escapes to be evaluated in SQL statements
4684
+ ** prior to sending the SQL into SQLite. Useful for injecting
4685
+ ** crazy bytes in the middle of SQL statements for testing and debugging.
4686
+ */
4687
+ data.backslashOn = 1;
45804688
}else if( strcmp(z,"-bail")==0 ){
45814689
bail_on_error = 1;
45824690
}else if( strcmp(z,"-version")==0 ){
45834691
printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid());
45844692
return 0;
45854693
--- src/shell.c
+++ src/shell.c
@@ -334,11 +334,11 @@
334 /*
335 ** The following is the open SQLite database. We make a pointer
336 ** to this database a static variable so that it can be accessed
337 ** by the SIGINT handler to interrupt database processing.
338 */
339 static sqlite3 *db = 0;
340
341 /*
342 ** True if an interrupt (Control-C) has been received.
343 */
344 static volatile int seenInterrupt = 0;
@@ -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);
@@ -525,10 +525,11 @@
525 sqlite3 *db; /* The database */
526 int echoOn; /* True to echo input commands */
527 int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
528 int statsOn; /* True to display memory stats before each finalize */
529 int scanstatsOn; /* True to display scan stats before each finalize */
 
530 int outCount; /* Revert to stdout when reaching zero */
531 int cnt; /* Number of records displayed so far */
532 FILE *out; /* Write results here */
533 FILE *traceOut; /* Output for sqlite3_trace() */
534 int nErr; /* Number of errors seen */
@@ -802,11 +803,11 @@
802 */
803 static void interrupt_handler(int NotUsed){
804 UNUSED_PARAMETER(NotUsed);
805 seenInterrupt++;
806 if( seenInterrupt>2 ) exit(1);
807 if( db ) sqlite3_interrupt(db);
808 }
809 #endif
810
811 /*
812 ** This is the callback routine that the shell
@@ -987,11 +988,20 @@
987 break;
988 }
989 case MODE_Insert: {
990 p->cnt++;
991 if( azArg==0 ) break;
992 fprintf(p->out,"INSERT INTO %s VALUES(",p->zDestTable);
 
 
 
 
 
 
 
 
 
993 for(i=0; i<nArg; i++){
994 char *zSep = i>0 ? ",": "";
995 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
996 fprintf(p->out,"%sNULL",zSep);
997 }else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1188,11 +1198,11 @@
1188 */
1189 static char *save_err_msg(
1190 sqlite3 *db /* Database to query */
1191 ){
1192 int nErrMsg = 1+strlen30(sqlite3_errmsg(db));
1193 char *zErrMsg = sqlite3_malloc(nErrMsg);
1194 if( zErrMsg ){
1195 memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);
1196 }
1197 return zErrMsg;
1198 }
@@ -1425,12 +1435,12 @@
1425 int p2op = (p2 + (iOp-iAddr));
1426
1427 /* Grow the p->aiIndent array as required */
1428 if( iOp>=nAlloc ){
1429 nAlloc += 100;
1430 p->aiIndent = (int*)sqlite3_realloc(p->aiIndent, nAlloc*sizeof(int));
1431 abYield = (int*)sqlite3_realloc(abYield, nAlloc*sizeof(int));
1432 }
1433 abYield[iOp] = str_in_array(zOp, azYield);
1434 p->aiIndent[iOp] = 0;
1435 p->nIndent = iOp+1;
1436
@@ -1543,11 +1553,11 @@
1543 if( SQLITE_ROW == rc ){
1544 /* if we have a callback... */
1545 if( xCallback ){
1546 /* allocate space for col name ptr, value ptr, and type */
1547 int nCol = sqlite3_column_count(pStmt);
1548 void *pData = sqlite3_malloc(3*nCol*sizeof(const char*) + 1);
1549 if( !pData ){
1550 rc = SQLITE_NOMEM;
1551 }else{
1552 char **azCols = (char **)pData; /* Names of result columns */
1553 char **azVals = &azCols[nCol]; /* Results */
@@ -1769,10 +1779,11 @@
1769 ** Text of a help message
1770 */
1771 static char zHelp[] =
1772 ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
1773 ".bail on|off Stop after hitting an error. Default OFF\n"
 
1774 ".clone NEWDB Clone data into NEWDB from the existing database\n"
1775 ".databases List names and files of attached databases\n"
1776 ".dbinfo ?DB? Show status information about the database\n"
1777 ".dump ?TABLE? ... Dump the database in an SQL text format\n"
1778 " If TABLE specified, only dump tables matching\n"
@@ -1790,10 +1801,11 @@
1790 " If TABLE specified, only show indexes for tables\n"
1791 " matching LIKE pattern TABLE.\n"
1792 #ifdef SQLITE_ENABLE_IOTRACE
1793 ".iotrace FILE Enable I/O diagnostic logging to FILE\n"
1794 #endif
 
1795 #ifndef SQLITE_OMIT_LOAD_EXTENSION
1796 ".load FILE ?ENTRY? Load an extension library\n"
1797 #endif
1798 ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
1799 ".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
@@ -1859,11 +1871,11 @@
1859 in = fopen(zName, "rb");
1860 if( in==0 ) return;
1861 fseek(in, 0, SEEK_END);
1862 nIn = ftell(in);
1863 rewind(in);
1864 pBuf = sqlite3_malloc( nIn );
1865 if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
1866 sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
1867 }else{
1868 sqlite3_free(pBuf);
1869 }
@@ -1906,54 +1918,72 @@
1906 */
1907 static void open_db(ShellState *p, int keepAlive){
1908 if( p->db==0 ){
1909 sqlite3_initialize();
1910 sqlite3_open(p->zDbFilename, &p->db);
1911 db = p->db;
1912 if( db && sqlite3_errcode(db)==SQLITE_OK ){
1913 sqlite3_create_function(db, "shellstatic", 0, SQLITE_UTF8, 0,
1914 shellstaticFunc, 0, 0);
1915 }
1916 if( db==0 || SQLITE_OK!=sqlite3_errcode(db) ){
1917 fprintf(stderr,"Error: unable to open database \"%s\": %s\n",
1918 p->zDbFilename, sqlite3_errmsg(db));
1919 if( keepAlive ) return;
1920 exit(1);
1921 }
1922 #ifndef SQLITE_OMIT_LOAD_EXTENSION
1923 sqlite3_enable_load_extension(p->db, 1);
1924 #endif
1925 sqlite3_create_function(db, "readfile", 1, SQLITE_UTF8, 0,
1926 readfileFunc, 0, 0);
1927 sqlite3_create_function(db, "writefile", 2, SQLITE_UTF8, 0,
1928 writefileFunc, 0, 0);
1929 }
1930 }
1931
1932 /*
1933 ** Do C-language style dequoting.
1934 **
 
 
1935 ** \t -> tab
1936 ** \n -> newline
 
 
1937 ** \r -> carriage return
 
1938 ** \" -> "
1939 ** \NNN -> ascii character NNN in octal
1940 ** \\ -> backslash
 
1941 */
1942 static void resolve_backslashes(char *z){
1943 int i, j;
1944 char c;
1945 while( *z && *z!='\\' ) z++;
1946 for(i=j=0; (c = z[i])!=0; i++, j++){
1947 if( c=='\\' ){
1948 c = z[++i];
1949 if( c=='n' ){
1950 c = '\n';
 
 
1951 }else if( c=='t' ){
1952 c = '\t';
 
 
 
 
 
 
1953 }else if( c=='r' ){
1954 c = '\r';
 
 
 
 
1955 }else if( c=='\\' ){
1956 c = '\\';
1957 }else if( c>='0' && c<='7' ){
1958 c -= '0';
1959 if( z[i+1]>='0' && z[i+1]<='7' ){
@@ -2119,11 +2149,11 @@
2119
2120 /* Append a single byte to z[] */
2121 static void import_append_char(ImportCtx *p, int c){
2122 if( p->n+1>=p->nAlloc ){
2123 p->nAlloc += p->nAlloc + 100;
2124 p->z = sqlite3_realloc(p->z, p->nAlloc);
2125 if( p->z==0 ){
2126 fprintf(stderr, "out of memory\n");
2127 exit(1);
2128 }
2129 }
@@ -2133,11 +2163,11 @@
2133 /* Read a single field of CSV text. Compatible with rfc4180 and extended
2134 ** with the option of having a separator other than ",".
2135 **
2136 ** + Input comes from p->in.
2137 ** + Store results in p->z of length p->n. Space to hold p->z comes
2138 ** from sqlite3_malloc().
2139 ** + Use p->cSep as the column separator. The default is ",".
2140 ** + Use p->rSep as the row separator. The default is "\n".
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.
@@ -2207,11 +2237,11 @@
2207
2208 /* Read a single field of ASCII delimited text.
2209 **
2210 ** + Input comes from p->in.
2211 ** + Store results in p->z of length p->n. Space to hold p->z comes
2212 ** from sqlite3_malloc().
2213 ** + Use p->cSep as the column separator. The default is "\x1F".
2214 ** + Use p->rSep as the row separator. The default is "\x1E".
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.
@@ -2267,11 +2297,11 @@
2267 sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
2268 zQuery);
2269 goto end_data_xfer;
2270 }
2271 n = sqlite3_column_count(pQuery);
2272 zInsert = sqlite3_malloc(200 + nTable + n*3);
2273 if( zInsert==0 ){
2274 fprintf(stderr, "out of memory\n");
2275 goto end_data_xfer;
2276 }
2277 sqlite3_snprintf(200+nTable,zInsert,
@@ -2583,36 +2613,36 @@
2583 ** process that line.
2584 **
2585 ** Return 1 on error, 2 to exit, and 0 otherwise.
2586 */
2587 static int do_meta_command(char *zLine, ShellState *p){
2588 int i = 1;
2589 int nArg = 0;
2590 int n, c;
2591 int rc = 0;
2592 char *azArg[50];
2593
2594 /* Parse the input line into tokens.
2595 */
2596 while( zLine[i] && nArg<ArraySize(azArg) ){
2597 while( IsSpace(zLine[i]) ){ i++; }
2598 if( zLine[i]==0 ) break;
2599 if( zLine[i]=='\'' || zLine[i]=='"' ){
2600 int delim = zLine[i++];
2601 azArg[nArg++] = &zLine[i];
2602 while( zLine[i] && zLine[i]!=delim ){
2603 if( zLine[i]=='\\' && delim=='"' && zLine[i+1]!=0 ) i++;
2604 i++;
2605 }
2606 if( zLine[i]==delim ){
2607 zLine[i++] = 0;
2608 }
2609 if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
2610 }else{
2611 azArg[nArg++] = &zLine[i];
2612 while( zLine[i] && !IsSpace(zLine[i]) ){ i++; }
2613 if( zLine[i] ) zLine[i++] = 0;
2614 resolve_backslashes(azArg[nArg-1]);
2615 }
2616 }
2617
2618 /* Process the input line.
@@ -2682,10 +2712,23 @@
2682 }else{
2683 fprintf(stderr, "Usage: .bail on|off\n");
2684 rc = 1;
2685 }
2686 }else
 
 
 
 
 
 
 
 
 
 
 
 
 
2687
2688 /* The undocumented ".breakpoint" command causes a call to the no-op
2689 ** routine named test_breakpoint().
2690 */
2691 if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
@@ -2984,11 +3027,11 @@
2984 return 1;
2985 }
2986 nByte = strlen30(zSql);
2987 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
2988 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
2989 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(db))==0 ){
2990 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
2991 char cSep = '(';
2992 while( xRead(&sCtx) ){
2993 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCtx.z);
2994 cSep = ',';
@@ -3004,29 +3047,29 @@
3004 zCreate = sqlite3_mprintf("%z\n)", zCreate);
3005 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
3006 sqlite3_free(zCreate);
3007 if( rc ){
3008 fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
3009 sqlite3_errmsg(db));
3010 sqlite3_free(sCtx.z);
3011 xCloser(sCtx.in);
3012 return 1;
3013 }
3014 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
3015 }
3016 sqlite3_free(zSql);
3017 if( rc ){
3018 if (pStmt) sqlite3_finalize(pStmt);
3019 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(db));
3020 xCloser(sCtx.in);
3021 return 1;
3022 }
3023 nCol = sqlite3_column_count(pStmt);
3024 sqlite3_finalize(pStmt);
3025 pStmt = 0;
3026 if( nCol==0 ) return 0; /* no columns, no error */
3027 zSql = sqlite3_malloc( nByte*2 + 20 + nCol*2 );
3028 if( zSql==0 ){
3029 fprintf(stderr, "Error: out of memory\n");
3030 xCloser(sCtx.in);
3031 return 1;
3032 }
@@ -3039,17 +3082,17 @@
3039 zSql[j++] = ')';
3040 zSql[j] = 0;
3041 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
3042 sqlite3_free(zSql);
3043 if( rc ){
3044 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(db));
3045 if (pStmt) sqlite3_finalize(pStmt);
3046 xCloser(sCtx.in);
3047 return 1;
3048 }
3049 needCommit = sqlite3_get_autocommit(db);
3050 if( needCommit ) sqlite3_exec(db, "BEGIN", 0, 0, 0);
3051 do{
3052 int startLine = sCtx.nLine;
3053 for(i=0; i<nCol; i++){
3054 char *z = xRead(&sCtx);
3055 /*
@@ -3084,19 +3127,19 @@
3084 if( i>=nCol ){
3085 sqlite3_step(pStmt);
3086 rc = sqlite3_reset(pStmt);
3087 if( rc!=SQLITE_OK ){
3088 fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, startLine,
3089 sqlite3_errmsg(db));
3090 }
3091 }
3092 }while( sCtx.cTerm!=EOF );
3093
3094 xCloser(sCtx.in);
3095 sqlite3_free(sCtx.z);
3096 sqlite3_finalize(pStmt);
3097 if( needCommit ) sqlite3_exec(db, "COMMIT", 0, 0, 0);
3098 }else
3099
3100 if( c=='i' && (strncmp(azArg[0], "indices", n)==0
3101 || strncmp(azArg[0], "indexes", n)==0) ){
3102 ShellState data;
@@ -3142,11 +3185,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 ){
@@ -3162,10 +3205,67 @@
3162 sqlite3IoTrace = iotracePrintf;
3163 }
3164 }
3165 }else
3166 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3167
3168 #ifndef SQLITE_OMIT_LOAD_EXTENSION
3169 if( c=='l' && strncmp(azArg[0], "load", n)==0 ){
3170 const char *zFile, *zProc;
3171 char *zErrMsg = 0;
@@ -3646,17 +3746,17 @@
3646 sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
3647 }
3648 while( sqlite3_step(pStmt)==SQLITE_ROW ){
3649 if( nRow>=nAlloc ){
3650 char **azNew;
3651 int n = nAlloc*2 + 10;
3652 azNew = sqlite3_realloc(azResult, sizeof(azResult[0])*n);
3653 if( azNew==0 ){
3654 fprintf(stderr, "Error: out of memory\n");
3655 break;
3656 }
3657 nAlloc = n;
3658 azResult = azNew;
3659 }
3660 azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
3661 if( azResult[nRow] ) nRow++;
3662 }
@@ -3705,19 +3805,19 @@
3705 { "byteorder", SQLITE_TESTCTRL_BYTEORDER },
3706 { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
3707 { "imposter", SQLITE_TESTCTRL_IMPOSTER },
3708 };
3709 int testctrl = -1;
3710 int rc = 0;
3711 int i, n;
3712 open_db(p, 0);
3713
3714 /* convert testctrl text option to value. allow any unique prefix
3715 ** of the option name, or a numerical value. */
3716 n = strlen30(azArg[1]);
3717 for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){
3718 if( strncmp(azArg[1], aCtrl[i].zCtrlName, n)==0 ){
3719 if( testctrl<0 ){
3720 testctrl = aCtrl[i].ctrlCode;
3721 }else{
3722 fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]);
3723 testctrl = -1;
@@ -3734,12 +3834,12 @@
3734 /* sqlite3_test_control(int, db, int) */
3735 case SQLITE_TESTCTRL_OPTIMIZATIONS:
3736 case SQLITE_TESTCTRL_RESERVE:
3737 if( nArg==3 ){
3738 int opt = (int)strtol(azArg[2], 0, 0);
3739 rc = sqlite3_test_control(testctrl, p->db, opt);
3740 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3741 } else {
3742 fprintf(stderr,"Error: testctrl %s takes a single int option\n",
3743 azArg[1]);
3744 }
3745 break;
@@ -3748,23 +3848,23 @@
3748 case SQLITE_TESTCTRL_PRNG_SAVE:
3749 case SQLITE_TESTCTRL_PRNG_RESTORE:
3750 case SQLITE_TESTCTRL_PRNG_RESET:
3751 case SQLITE_TESTCTRL_BYTEORDER:
3752 if( nArg==2 ){
3753 rc = sqlite3_test_control(testctrl);
3754 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3755 } else {
3756 fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]);
3757 }
3758 break;
3759
3760 /* sqlite3_test_control(int, uint) */
3761 case SQLITE_TESTCTRL_PENDING_BYTE:
3762 if( nArg==3 ){
3763 unsigned int opt = (unsigned int)integerValue(azArg[2]);
3764 rc = sqlite3_test_control(testctrl, opt);
3765 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3766 } else {
3767 fprintf(stderr,"Error: testctrl %s takes a single unsigned"
3768 " int option\n", azArg[1]);
3769 }
3770 break;
@@ -3773,12 +3873,12 @@
3773 case SQLITE_TESTCTRL_ASSERT:
3774 case SQLITE_TESTCTRL_ALWAYS:
3775 case SQLITE_TESTCTRL_NEVER_CORRUPT:
3776 if( nArg==3 ){
3777 int opt = booleanValue(azArg[2]);
3778 rc = sqlite3_test_control(testctrl, opt);
3779 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3780 } else {
3781 fprintf(stderr,"Error: testctrl %s takes a single int option\n",
3782 azArg[1]);
3783 }
3784 break;
@@ -3786,28 +3886,28 @@
3786 /* sqlite3_test_control(int, char *) */
3787 #ifdef SQLITE_N_KEYWORD
3788 case SQLITE_TESTCTRL_ISKEYWORD:
3789 if( nArg==3 ){
3790 const char *opt = azArg[2];
3791 rc = sqlite3_test_control(testctrl, opt);
3792 fprintf(p->out, "%d (0x%08x)\n", rc, rc);
3793 } else {
3794 fprintf(stderr,"Error: testctrl %s takes a single char * option\n",
3795 azArg[1]);
3796 }
3797 break;
3798 #endif
3799
3800 case SQLITE_TESTCTRL_IMPOSTER:
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:
@@ -4109,10 +4209,11 @@
4109 }
4110 if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
4111 && sqlite3_complete(zSql) ){
4112 p->cnt = 0;
4113 open_db(p, 0);
 
4114 BEGIN_TIMER;
4115 rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);
4116 END_TIMER;
4117 if( rc || zErrMsg ){
4118 char zPrefix[100];
@@ -4575,10 +4676,17 @@
4575 data.autoEQP = 1;
4576 }else if( strcmp(z,"-stats")==0 ){
4577 data.statsOn = 1;
4578 }else if( strcmp(z,"-scanstats")==0 ){
4579 data.scanstatsOn = 1;
 
 
 
 
 
 
 
4580 }else if( strcmp(z,"-bail")==0 ){
4581 bail_on_error = 1;
4582 }else if( strcmp(z,"-version")==0 ){
4583 printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid());
4584 return 0;
4585
--- src/shell.c
+++ src/shell.c
@@ -334,11 +334,11 @@
334 /*
335 ** The following is the open SQLite database. We make a pointer
336 ** to this database a static variable so that it can be accessed
337 ** by the SIGINT handler to interrupt database processing.
338 */
339 static sqlite3 *globalDb = 0;
340
341 /*
342 ** True if an interrupt (Control-C) has been received.
343 */
344 static volatile int seenInterrupt = 0;
@@ -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);
@@ -525,10 +525,11 @@
525 sqlite3 *db; /* The database */
526 int echoOn; /* True to echo input commands */
527 int autoEQP; /* Run EXPLAIN QUERY PLAN prior to seach SQL stmt */
528 int statsOn; /* True to display memory stats before each finalize */
529 int scanstatsOn; /* True to display scan stats before each finalize */
530 int backslashOn; /* Resolve C-style \x escapes in SQL input text */
531 int outCount; /* Revert to stdout when reaching zero */
532 int cnt; /* Number of records displayed so far */
533 FILE *out; /* Write results here */
534 FILE *traceOut; /* Output for sqlite3_trace() */
535 int nErr; /* Number of errors seen */
@@ -802,11 +803,11 @@
803 */
804 static void interrupt_handler(int NotUsed){
805 UNUSED_PARAMETER(NotUsed);
806 seenInterrupt++;
807 if( seenInterrupt>2 ) exit(1);
808 if( globalDb ) sqlite3_interrupt(globalDb);
809 }
810 #endif
811
812 /*
813 ** This is the callback routine that the shell
@@ -987,11 +988,20 @@
988 break;
989 }
990 case MODE_Insert: {
991 p->cnt++;
992 if( azArg==0 ) break;
993 fprintf(p->out,"INSERT INTO %s",p->zDestTable);
994 if( p->showHeader ){
995 fprintf(p->out,"(");
996 for(i=0; i<nArg; i++){
997 char *zSep = i>0 ? ",": "";
998 fprintf(p->out, "%s%s", zSep, azCol[i]);
999 }
1000 fprintf(p->out,")");
1001 }
1002 fprintf(p->out," VALUES(");
1003 for(i=0; i<nArg; i++){
1004 char *zSep = i>0 ? ",": "";
1005 if( (azArg[i]==0) || (aiType && aiType[i]==SQLITE_NULL) ){
1006 fprintf(p->out,"%sNULL",zSep);
1007 }else if( aiType && aiType[i]==SQLITE_TEXT ){
@@ -1188,11 +1198,11 @@
1198 */
1199 static char *save_err_msg(
1200 sqlite3 *db /* Database to query */
1201 ){
1202 int nErrMsg = 1+strlen30(sqlite3_errmsg(db));
1203 char *zErrMsg = sqlite3_malloc64(nErrMsg);
1204 if( zErrMsg ){
1205 memcpy(zErrMsg, sqlite3_errmsg(db), nErrMsg);
1206 }
1207 return zErrMsg;
1208 }
@@ -1425,12 +1435,12 @@
1435 int p2op = (p2 + (iOp-iAddr));
1436
1437 /* Grow the p->aiIndent array as required */
1438 if( iOp>=nAlloc ){
1439 nAlloc += 100;
1440 p->aiIndent = (int*)sqlite3_realloc64(p->aiIndent, nAlloc*sizeof(int));
1441 abYield = (int*)sqlite3_realloc64(abYield, nAlloc*sizeof(int));
1442 }
1443 abYield[iOp] = str_in_array(zOp, azYield);
1444 p->aiIndent[iOp] = 0;
1445 p->nIndent = iOp+1;
1446
@@ -1543,11 +1553,11 @@
1553 if( SQLITE_ROW == rc ){
1554 /* if we have a callback... */
1555 if( xCallback ){
1556 /* allocate space for col name ptr, value ptr, and type */
1557 int nCol = sqlite3_column_count(pStmt);
1558 void *pData = sqlite3_malloc64(3*nCol*sizeof(const char*) + 1);
1559 if( !pData ){
1560 rc = SQLITE_NOMEM;
1561 }else{
1562 char **azCols = (char **)pData; /* Names of result columns */
1563 char **azVals = &azCols[nCol]; /* Results */
@@ -1769,10 +1779,11 @@
1779 ** Text of a help message
1780 */
1781 static char zHelp[] =
1782 ".backup ?DB? FILE Backup DB (default \"main\") to FILE\n"
1783 ".bail on|off Stop after hitting an error. Default OFF\n"
1784 ".binary on|off Turn binary output on or off. Default OFF\n"
1785 ".clone NEWDB Clone data into NEWDB from the existing database\n"
1786 ".databases List names and files of attached databases\n"
1787 ".dbinfo ?DB? Show status information about the database\n"
1788 ".dump ?TABLE? ... Dump the database in an SQL text format\n"
1789 " If TABLE specified, only dump tables matching\n"
@@ -1790,10 +1801,11 @@
1801 " If TABLE specified, only show indexes for tables\n"
1802 " matching LIKE pattern TABLE.\n"
1803 #ifdef SQLITE_ENABLE_IOTRACE
1804 ".iotrace FILE Enable I/O diagnostic logging to FILE\n"
1805 #endif
1806 ".limit ?LIMIT? ?VAL? Display or change the value of an SQLITE_LIMIT\n"
1807 #ifndef SQLITE_OMIT_LOAD_EXTENSION
1808 ".load FILE ?ENTRY? Load an extension library\n"
1809 #endif
1810 ".log FILE|off Turn logging on or off. FILE can be stderr/stdout\n"
1811 ".mode MODE ?TABLE? Set output mode where MODE is one of:\n"
@@ -1859,11 +1871,11 @@
1871 in = fopen(zName, "rb");
1872 if( in==0 ) return;
1873 fseek(in, 0, SEEK_END);
1874 nIn = ftell(in);
1875 rewind(in);
1876 pBuf = sqlite3_malloc64( nIn );
1877 if( pBuf && 1==fread(pBuf, nIn, 1, in) ){
1878 sqlite3_result_blob(context, pBuf, nIn, sqlite3_free);
1879 }else{
1880 sqlite3_free(pBuf);
1881 }
@@ -1906,54 +1918,72 @@
1918 */
1919 static void open_db(ShellState *p, int keepAlive){
1920 if( p->db==0 ){
1921 sqlite3_initialize();
1922 sqlite3_open(p->zDbFilename, &p->db);
1923 globalDb = p->db;
1924 if( p->db && sqlite3_errcode(p->db)==SQLITE_OK ){
1925 sqlite3_create_function(p->db, "shellstatic", 0, SQLITE_UTF8, 0,
1926 shellstaticFunc, 0, 0);
1927 }
1928 if( p->db==0 || SQLITE_OK!=sqlite3_errcode(p->db) ){
1929 fprintf(stderr,"Error: unable to open database \"%s\": %s\n",
1930 p->zDbFilename, sqlite3_errmsg(p->db));
1931 if( keepAlive ) return;
1932 exit(1);
1933 }
1934 #ifndef SQLITE_OMIT_LOAD_EXTENSION
1935 sqlite3_enable_load_extension(p->db, 1);
1936 #endif
1937 sqlite3_create_function(p->db, "readfile", 1, SQLITE_UTF8, 0,
1938 readfileFunc, 0, 0);
1939 sqlite3_create_function(p->db, "writefile", 2, SQLITE_UTF8, 0,
1940 writefileFunc, 0, 0);
1941 }
1942 }
1943
1944 /*
1945 ** Do C-language style dequoting.
1946 **
1947 ** \a -> alarm
1948 ** \b -> backspace
1949 ** \t -> tab
1950 ** \n -> newline
1951 ** \v -> vertical tab
1952 ** \f -> form feed
1953 ** \r -> carriage return
1954 ** \s -> space
1955 ** \" -> "
1956 ** \' -> '
1957 ** \\ -> backslash
1958 ** \NNN -> ascii character NNN in octal
1959 */
1960 static void resolve_backslashes(char *z){
1961 int i, j;
1962 char c;
1963 while( *z && *z!='\\' ) z++;
1964 for(i=j=0; (c = z[i])!=0; i++, j++){
1965 if( c=='\\' && z[i+1]!=0 ){
1966 c = z[++i];
1967 if( c=='a' ){
1968 c = '\a';
1969 }else if( c=='b' ){
1970 c = '\b';
1971 }else if( c=='t' ){
1972 c = '\t';
1973 }else if( c=='n' ){
1974 c = '\n';
1975 }else if( c=='v' ){
1976 c = '\v';
1977 }else if( c=='f' ){
1978 c = '\f';
1979 }else if( c=='r' ){
1980 c = '\r';
1981 }else if( c=='"' ){
1982 c = '"';
1983 }else if( c=='\'' ){
1984 c = '\'';
1985 }else if( c=='\\' ){
1986 c = '\\';
1987 }else if( c>='0' && c<='7' ){
1988 c -= '0';
1989 if( z[i+1]>='0' && z[i+1]<='7' ){
@@ -2119,11 +2149,11 @@
2149
2150 /* Append a single byte to z[] */
2151 static void import_append_char(ImportCtx *p, int c){
2152 if( p->n+1>=p->nAlloc ){
2153 p->nAlloc += p->nAlloc + 100;
2154 p->z = sqlite3_realloc64(p->z, p->nAlloc);
2155 if( p->z==0 ){
2156 fprintf(stderr, "out of memory\n");
2157 exit(1);
2158 }
2159 }
@@ -2133,11 +2163,11 @@
2163 /* Read a single field of CSV text. Compatible with rfc4180 and extended
2164 ** with the option of having a separator other than ",".
2165 **
2166 ** + Input comes from p->in.
2167 ** + Store results in p->z of length p->n. Space to hold p->z comes
2168 ** from sqlite3_malloc64().
2169 ** + Use p->cSep as the column separator. The default is ",".
2170 ** + Use p->rSep as the row separator. The default is "\n".
2171 ** + Keep track of the line number in p->nLine.
2172 ** + Store the character that terminates the field in p->cTerm. Store
2173 ** EOF on end-of-file.
@@ -2207,11 +2237,11 @@
2237
2238 /* Read a single field of ASCII delimited text.
2239 **
2240 ** + Input comes from p->in.
2241 ** + Store results in p->z of length p->n. Space to hold p->z comes
2242 ** from sqlite3_malloc64().
2243 ** + Use p->cSep as the column separator. The default is "\x1F".
2244 ** + Use p->rSep as the row separator. The default is "\x1E".
2245 ** + Keep track of the row number in p->nLine.
2246 ** + Store the character that terminates the field in p->cTerm. Store
2247 ** EOF on end-of-file.
@@ -2267,11 +2297,11 @@
2297 sqlite3_extended_errcode(p->db), sqlite3_errmsg(p->db),
2298 zQuery);
2299 goto end_data_xfer;
2300 }
2301 n = sqlite3_column_count(pQuery);
2302 zInsert = sqlite3_malloc64(200 + nTable + n*3);
2303 if( zInsert==0 ){
2304 fprintf(stderr, "out of memory\n");
2305 goto end_data_xfer;
2306 }
2307 sqlite3_snprintf(200+nTable,zInsert,
@@ -2583,36 +2613,36 @@
2613 ** process that line.
2614 **
2615 ** Return 1 on error, 2 to exit, and 0 otherwise.
2616 */
2617 static int do_meta_command(char *zLine, ShellState *p){
2618 int h = 1;
2619 int nArg = 0;
2620 int n, c;
2621 int rc = 0;
2622 char *azArg[50];
2623
2624 /* Parse the input line into tokens.
2625 */
2626 while( zLine[h] && nArg<ArraySize(azArg) ){
2627 while( IsSpace(zLine[h]) ){ h++; }
2628 if( zLine[h]==0 ) break;
2629 if( zLine[h]=='\'' || zLine[h]=='"' ){
2630 int delim = zLine[h++];
2631 azArg[nArg++] = &zLine[h];
2632 while( zLine[h] && zLine[h]!=delim ){
2633 if( zLine[h]=='\\' && delim=='"' && zLine[h+1]!=0 ) h++;
2634 h++;
2635 }
2636 if( zLine[h]==delim ){
2637 zLine[h++] = 0;
2638 }
2639 if( delim=='"' ) resolve_backslashes(azArg[nArg-1]);
2640 }else{
2641 azArg[nArg++] = &zLine[h];
2642 while( zLine[h] && !IsSpace(zLine[h]) ){ h++; }
2643 if( zLine[h] ) zLine[h++] = 0;
2644 resolve_backslashes(azArg[nArg-1]);
2645 }
2646 }
2647
2648 /* Process the input line.
@@ -2682,10 +2712,23 @@
2712 }else{
2713 fprintf(stderr, "Usage: .bail on|off\n");
2714 rc = 1;
2715 }
2716 }else
2717
2718 if( c=='b' && n>=3 && strncmp(azArg[0], "binary", n)==0 ){
2719 if( nArg==2 ){
2720 if( booleanValue(azArg[1]) ){
2721 setBinaryMode(p->out);
2722 }else{
2723 setTextMode(p->out);
2724 }
2725 }else{
2726 fprintf(stderr, "Usage: .binary on|off\n");
2727 rc = 1;
2728 }
2729 }else
2730
2731 /* The undocumented ".breakpoint" command causes a call to the no-op
2732 ** routine named test_breakpoint().
2733 */
2734 if( c=='b' && n>=3 && strncmp(azArg[0], "breakpoint", n)==0 ){
@@ -2984,11 +3027,11 @@
3027 return 1;
3028 }
3029 nByte = strlen30(zSql);
3030 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
3031 import_append_char(&sCtx, 0); /* To ensure sCtx.z is allocated */
3032 if( rc && sqlite3_strglob("no such table: *", sqlite3_errmsg(p->db))==0 ){
3033 char *zCreate = sqlite3_mprintf("CREATE TABLE %s", zTable);
3034 char cSep = '(';
3035 while( xRead(&sCtx) ){
3036 zCreate = sqlite3_mprintf("%z%c\n \"%s\" TEXT", zCreate, cSep, sCtx.z);
3037 cSep = ',';
@@ -3004,29 +3047,29 @@
3047 zCreate = sqlite3_mprintf("%z\n)", zCreate);
3048 rc = sqlite3_exec(p->db, zCreate, 0, 0, 0);
3049 sqlite3_free(zCreate);
3050 if( rc ){
3051 fprintf(stderr, "CREATE TABLE %s(...) failed: %s\n", zTable,
3052 sqlite3_errmsg(p->db));
3053 sqlite3_free(sCtx.z);
3054 xCloser(sCtx.in);
3055 return 1;
3056 }
3057 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
3058 }
3059 sqlite3_free(zSql);
3060 if( rc ){
3061 if (pStmt) sqlite3_finalize(pStmt);
3062 fprintf(stderr,"Error: %s\n", sqlite3_errmsg(p->db));
3063 xCloser(sCtx.in);
3064 return 1;
3065 }
3066 nCol = sqlite3_column_count(pStmt);
3067 sqlite3_finalize(pStmt);
3068 pStmt = 0;
3069 if( nCol==0 ) return 0; /* no columns, no error */
3070 zSql = sqlite3_malloc64( nByte*2 + 20 + nCol*2 );
3071 if( zSql==0 ){
3072 fprintf(stderr, "Error: out of memory\n");
3073 xCloser(sCtx.in);
3074 return 1;
3075 }
@@ -3039,17 +3082,17 @@
3082 zSql[j++] = ')';
3083 zSql[j] = 0;
3084 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
3085 sqlite3_free(zSql);
3086 if( rc ){
3087 fprintf(stderr, "Error: %s\n", sqlite3_errmsg(p->db));
3088 if (pStmt) sqlite3_finalize(pStmt);
3089 xCloser(sCtx.in);
3090 return 1;
3091 }
3092 needCommit = sqlite3_get_autocommit(p->db);
3093 if( needCommit ) sqlite3_exec(p->db, "BEGIN", 0, 0, 0);
3094 do{
3095 int startLine = sCtx.nLine;
3096 for(i=0; i<nCol; i++){
3097 char *z = xRead(&sCtx);
3098 /*
@@ -3084,19 +3127,19 @@
3127 if( i>=nCol ){
3128 sqlite3_step(pStmt);
3129 rc = sqlite3_reset(pStmt);
3130 if( rc!=SQLITE_OK ){
3131 fprintf(stderr, "%s:%d: INSERT failed: %s\n", sCtx.zFile, startLine,
3132 sqlite3_errmsg(p->db));
3133 }
3134 }
3135 }while( sCtx.cTerm!=EOF );
3136
3137 xCloser(sCtx.in);
3138 sqlite3_free(sCtx.z);
3139 sqlite3_finalize(pStmt);
3140 if( needCommit ) sqlite3_exec(p->db, "COMMIT", 0, 0, 0);
3141 }else
3142
3143 if( c=='i' && (strncmp(azArg[0], "indices", n)==0
3144 || strncmp(azArg[0], "indexes", n)==0) ){
3145 ShellState data;
@@ -3142,11 +3185,11 @@
3185 }
3186 }else
3187
3188 #ifdef SQLITE_ENABLE_IOTRACE
3189 if( c=='i' && strncmp(azArg[0], "iotrace", n)==0 ){
3190 SQLITE_API extern void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...);
3191 if( iotrace && iotrace!=stdout ) fclose(iotrace);
3192 iotrace = 0;
3193 if( nArg<2 ){
3194 sqlite3IoTrace = 0;
3195 }else if( strcmp(azArg[1], "-")==0 ){
@@ -3162,10 +3205,67 @@
3205 sqlite3IoTrace = iotracePrintf;
3206 }
3207 }
3208 }else
3209 #endif
3210 if( c=='l' && n>=5 && strncmp(azArg[0], "limits", n)==0 ){
3211 static const struct {
3212 const char *zLimitName; /* Name of a limit */
3213 int limitCode; /* Integer code for that limit */
3214 } aLimit[] = {
3215 { "length", SQLITE_LIMIT_LENGTH },
3216 { "sql_length", SQLITE_LIMIT_SQL_LENGTH },
3217 { "column", SQLITE_LIMIT_COLUMN },
3218 { "expr_depth", SQLITE_LIMIT_EXPR_DEPTH },
3219 { "compound_select", SQLITE_LIMIT_COMPOUND_SELECT },
3220 { "vdbe_op", SQLITE_LIMIT_VDBE_OP },
3221 { "function_arg", SQLITE_LIMIT_FUNCTION_ARG },
3222 { "attached", SQLITE_LIMIT_ATTACHED },
3223 { "like_pattern_length", SQLITE_LIMIT_LIKE_PATTERN_LENGTH },
3224 { "variable_number", SQLITE_LIMIT_VARIABLE_NUMBER },
3225 { "trigger_depth", SQLITE_LIMIT_TRIGGER_DEPTH },
3226 { "worker_threads", SQLITE_LIMIT_WORKER_THREADS },
3227 };
3228 int i, n2;
3229 open_db(p, 0);
3230 if( nArg==1 ){
3231 for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
3232 printf("%20s %d\n", aLimit[i].zLimitName,
3233 sqlite3_limit(p->db, aLimit[i].limitCode, -1));
3234 }
3235 }else if( nArg>3 ){
3236 fprintf(stderr, "Usage: .limit NAME ?NEW-VALUE?\n");
3237 rc = 1;
3238 goto meta_command_exit;
3239 }else{
3240 int iLimit = -1;
3241 n2 = strlen30(azArg[1]);
3242 for(i=0; i<sizeof(aLimit)/sizeof(aLimit[0]); i++){
3243 if( sqlite3_strnicmp(aLimit[i].zLimitName, azArg[1], n2)==0 ){
3244 if( iLimit<0 ){
3245 iLimit = i;
3246 }else{
3247 fprintf(stderr, "ambiguous limit: \"%s\"\n", azArg[1]);
3248 rc = 1;
3249 goto meta_command_exit;
3250 }
3251 }
3252 }
3253 if( iLimit<0 ){
3254 fprintf(stderr, "unknown limit: \"%s\"\n"
3255 "enter \".limits\" with no arguments for a list.\n",
3256 azArg[1]);
3257 rc = 1;
3258 goto meta_command_exit;
3259 }
3260 if( nArg==3 ){
3261 sqlite3_limit(p->db, aLimit[iLimit].limitCode, integerValue(azArg[2]));
3262 }
3263 printf("%20s %d\n", aLimit[iLimit].zLimitName,
3264 sqlite3_limit(p->db, aLimit[iLimit].limitCode, -1));
3265 }
3266 }else
3267
3268 #ifndef SQLITE_OMIT_LOAD_EXTENSION
3269 if( c=='l' && strncmp(azArg[0], "load", n)==0 ){
3270 const char *zFile, *zProc;
3271 char *zErrMsg = 0;
@@ -3646,17 +3746,17 @@
3746 sqlite3_bind_text(pStmt, 1, "%", -1, SQLITE_STATIC);
3747 }
3748 while( sqlite3_step(pStmt)==SQLITE_ROW ){
3749 if( nRow>=nAlloc ){
3750 char **azNew;
3751 int n2 = nAlloc*2 + 10;
3752 azNew = sqlite3_realloc64(azResult, sizeof(azResult[0])*n2);
3753 if( azNew==0 ){
3754 fprintf(stderr, "Error: out of memory\n");
3755 break;
3756 }
3757 nAlloc = n2;
3758 azResult = azNew;
3759 }
3760 azResult[nRow] = sqlite3_mprintf("%s", sqlite3_column_text(pStmt, 0));
3761 if( azResult[nRow] ) nRow++;
3762 }
@@ -3705,19 +3805,19 @@
3805 { "byteorder", SQLITE_TESTCTRL_BYTEORDER },
3806 { "never_corrupt", SQLITE_TESTCTRL_NEVER_CORRUPT },
3807 { "imposter", SQLITE_TESTCTRL_IMPOSTER },
3808 };
3809 int testctrl = -1;
3810 int rc2 = 0;
3811 int i, n2;
3812 open_db(p, 0);
3813
3814 /* convert testctrl text option to value. allow any unique prefix
3815 ** of the option name, or a numerical value. */
3816 n2 = strlen30(azArg[1]);
3817 for(i=0; i<(int)(sizeof(aCtrl)/sizeof(aCtrl[0])); i++){
3818 if( strncmp(azArg[1], aCtrl[i].zCtrlName, n2)==0 ){
3819 if( testctrl<0 ){
3820 testctrl = aCtrl[i].ctrlCode;
3821 }else{
3822 fprintf(stderr, "ambiguous option name: \"%s\"\n", azArg[1]);
3823 testctrl = -1;
@@ -3734,12 +3834,12 @@
3834 /* sqlite3_test_control(int, db, int) */
3835 case SQLITE_TESTCTRL_OPTIMIZATIONS:
3836 case SQLITE_TESTCTRL_RESERVE:
3837 if( nArg==3 ){
3838 int opt = (int)strtol(azArg[2], 0, 0);
3839 rc2 = sqlite3_test_control(testctrl, p->db, opt);
3840 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3841 } else {
3842 fprintf(stderr,"Error: testctrl %s takes a single int option\n",
3843 azArg[1]);
3844 }
3845 break;
@@ -3748,23 +3848,23 @@
3848 case SQLITE_TESTCTRL_PRNG_SAVE:
3849 case SQLITE_TESTCTRL_PRNG_RESTORE:
3850 case SQLITE_TESTCTRL_PRNG_RESET:
3851 case SQLITE_TESTCTRL_BYTEORDER:
3852 if( nArg==2 ){
3853 rc2 = sqlite3_test_control(testctrl);
3854 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3855 } else {
3856 fprintf(stderr,"Error: testctrl %s takes no options\n", azArg[1]);
3857 }
3858 break;
3859
3860 /* sqlite3_test_control(int, uint) */
3861 case SQLITE_TESTCTRL_PENDING_BYTE:
3862 if( nArg==3 ){
3863 unsigned int opt = (unsigned int)integerValue(azArg[2]);
3864 rc2 = sqlite3_test_control(testctrl, opt);
3865 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3866 } else {
3867 fprintf(stderr,"Error: testctrl %s takes a single unsigned"
3868 " int option\n", azArg[1]);
3869 }
3870 break;
@@ -3773,12 +3873,12 @@
3873 case SQLITE_TESTCTRL_ASSERT:
3874 case SQLITE_TESTCTRL_ALWAYS:
3875 case SQLITE_TESTCTRL_NEVER_CORRUPT:
3876 if( nArg==3 ){
3877 int opt = booleanValue(azArg[2]);
3878 rc2 = sqlite3_test_control(testctrl, opt);
3879 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3880 } else {
3881 fprintf(stderr,"Error: testctrl %s takes a single int option\n",
3882 azArg[1]);
3883 }
3884 break;
@@ -3786,28 +3886,28 @@
3886 /* sqlite3_test_control(int, char *) */
3887 #ifdef SQLITE_N_KEYWORD
3888 case SQLITE_TESTCTRL_ISKEYWORD:
3889 if( nArg==3 ){
3890 const char *opt = azArg[2];
3891 rc2 = sqlite3_test_control(testctrl, opt);
3892 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3893 } else {
3894 fprintf(stderr,"Error: testctrl %s takes a single char * option\n",
3895 azArg[1]);
3896 }
3897 break;
3898 #endif
3899
3900 case SQLITE_TESTCTRL_IMPOSTER:
3901 if( nArg==5 ){
3902 rc2 = sqlite3_test_control(testctrl, p->db,
3903 azArg[2],
3904 integerValue(azArg[3]),
3905 integerValue(azArg[4]));
3906 fprintf(p->out, "%d (0x%08x)\n", rc2, rc2);
3907 }else{
3908 fprintf(stderr,"Usage: .testctrl imposter dbName onoff tnum\n");
 
3909 }
3910 break;
3911
3912 case SQLITE_TESTCTRL_BITVEC_TEST:
3913 case SQLITE_TESTCTRL_FAULT_INSTALL:
@@ -4109,10 +4209,11 @@
4209 }
4210 if( nSql && line_contains_semicolon(&zSql[nSqlPrior], nSql-nSqlPrior)
4211 && sqlite3_complete(zSql) ){
4212 p->cnt = 0;
4213 open_db(p, 0);
4214 if( p->backslashOn ) resolve_backslashes(zSql);
4215 BEGIN_TIMER;
4216 rc = shell_exec(p->db, zSql, shell_callback, p, &zErrMsg);
4217 END_TIMER;
4218 if( rc || zErrMsg ){
4219 char zPrefix[100];
@@ -4575,10 +4676,17 @@
4676 data.autoEQP = 1;
4677 }else if( strcmp(z,"-stats")==0 ){
4678 data.statsOn = 1;
4679 }else if( strcmp(z,"-scanstats")==0 ){
4680 data.scanstatsOn = 1;
4681 }else if( strcmp(z,"-backslash")==0 ){
4682 /* Undocumented command-line option: -backslash
4683 ** Causes C-style backslash escapes to be evaluated in SQL statements
4684 ** prior to sending the SQL into SQLite. Useful for injecting
4685 ** crazy bytes in the middle of SQL statements for testing and debugging.
4686 */
4687 data.backslashOn = 1;
4688 }else if( strcmp(z,"-bail")==0 ){
4689 bail_on_error = 1;
4690 }else if( strcmp(z,"-version")==0 ){
4691 printf("%s %s\n", sqlite3_libversion(), sqlite3_sourceid());
4692 return 0;
4693
+10 -1
--- src/shun.c
+++ src/shun.c
@@ -35,10 +35,13 @@
3535
return rc==SQLITE_ROW;
3636
}
3737
3838
/*
3939
** WEBPAGE: shun
40
+**
41
+** View the SHA1 hashes of all shunned artifacts. Add new hashes
42
+** to the shun set. Requires Admin privilege.
4043
*/
4144
void shun_page(void){
4245
Stmt q;
4346
int cnt = 0;
4447
const char *zUuid = P("uuid");
@@ -293,10 +296,15 @@
293296
294297
/*
295298
** WEBPAGE: rcvfromlist
296299
**
297300
** Show a listing of RCVFROM table entries.
301
+**
302
+** The RCVFROM table records where this repository received each
303
+** artifact, including the time of receipt, user, and IP address.
304
+**
305
+** Access requires Admin privilege.
298306
*/
299307
void rcvfromlist_page(void){
300308
int ofst = atoi(PD("ofst","0"));
301309
int showAll = P("all")!=0;
302310
int cnt;
@@ -375,11 +383,12 @@
375383
}
376384
377385
/*
378386
** WEBPAGE: rcvfrom
379387
**
380
-** Show a single RCVFROM table entry.
388
+** Show a single RCVFROM table entry identified by the rcvid= query
389
+** parameters. Requires Admin privilege.
381390
*/
382391
void rcvfrom_page(void){
383392
int rcvid = atoi(PD("rcvid","0"));
384393
Stmt q;
385394
386395
--- src/shun.c
+++ src/shun.c
@@ -35,10 +35,13 @@
35 return rc==SQLITE_ROW;
36 }
37
38 /*
39 ** WEBPAGE: shun
 
 
 
40 */
41 void shun_page(void){
42 Stmt q;
43 int cnt = 0;
44 const char *zUuid = P("uuid");
@@ -293,10 +296,15 @@
293
294 /*
295 ** WEBPAGE: rcvfromlist
296 **
297 ** Show a listing of RCVFROM table entries.
 
 
 
 
 
298 */
299 void rcvfromlist_page(void){
300 int ofst = atoi(PD("ofst","0"));
301 int showAll = P("all")!=0;
302 int cnt;
@@ -375,11 +383,12 @@
375 }
376
377 /*
378 ** WEBPAGE: rcvfrom
379 **
380 ** Show a single RCVFROM table entry.
 
381 */
382 void rcvfrom_page(void){
383 int rcvid = atoi(PD("rcvid","0"));
384 Stmt q;
385
386
--- src/shun.c
+++ src/shun.c
@@ -35,10 +35,13 @@
35 return rc==SQLITE_ROW;
36 }
37
38 /*
39 ** WEBPAGE: shun
40 **
41 ** View the SHA1 hashes of all shunned artifacts. Add new hashes
42 ** to the shun set. Requires Admin privilege.
43 */
44 void shun_page(void){
45 Stmt q;
46 int cnt = 0;
47 const char *zUuid = P("uuid");
@@ -293,10 +296,15 @@
296
297 /*
298 ** WEBPAGE: rcvfromlist
299 **
300 ** Show a listing of RCVFROM table entries.
301 **
302 ** The RCVFROM table records where this repository received each
303 ** artifact, including the time of receipt, user, and IP address.
304 **
305 ** Access requires Admin privilege.
306 */
307 void rcvfromlist_page(void){
308 int ofst = atoi(PD("ofst","0"));
309 int showAll = P("all")!=0;
310 int cnt;
@@ -375,11 +383,12 @@
383 }
384
385 /*
386 ** WEBPAGE: rcvfrom
387 **
388 ** Show a single RCVFROM table entry identified by the rcvid= query
389 ** parameters. Requires Admin privilege.
390 */
391 void rcvfrom_page(void){
392 int rcvid = atoi(PD("rcvid","0"));
393 Stmt q;
394
395
+102 -62
--- src/sitemap.c
+++ src/sitemap.c
@@ -22,93 +22,133 @@
2222
#include <assert.h>
2323
2424
/*
2525
** WEBPAGE: sitemap
2626
**
27
-** Show an incomplete list of web pages offered by the Fossil web engine.
27
+** List some of the web pages offered by the Fossil web engine. This
28
+** page is intended as a suppliment to the menu bar on the main screen.
29
+** That is, this page is designed to hold links that are omitted from
30
+** the main menu due to lack of space.
2831
*/
2932
void sitemap_page(void){
33
+ int srchFlags;
3034
login_check_credentials();
35
+ srchFlags = search_restrict(SRCH_ALL);
3136
style_header("Site Map");
3237
style_adunit_config(ADUNIT_RIGHT_OK);
38
+#if 0
3339
@ <p>
3440
@ The following links are just a few of the many web-pages available for
3541
@ this Fossil repository:
3642
@ </p>
3743
@
44
+#endif
3845
@ <ul>
3946
@ <li>%z(href("%R/home"))Home Page</a>
40
- @ <ul>
41
- @ <li>%z(href("%R/docsrc"))Search Project Documentation</a></li>
42
- @ </ul></li>
43
- @ <li>%z(href("%R/tree"))File Browser</a></li>
44
- @ <ul>
45
- @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
46
- @ Trunk Check-in</a></li>
47
- @ <li>%z(href("%R/tree?type=flat"))Flat-view</a></li>
48
- @ <li>%z(href("%R/fileage?name=trunk"))File ages for Trunk</a></li>
49
- @ </ul>
50
- @ <li>%z(href("%R/timeline?n=200"))Project Timeline</a></li>
51
- @ <ul>
52
- @ <li>%z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10
53
- @ check-ins</a></li>
54
- @ <li>%z(href("%R/timeline?n=all&namechng"))All check-ins with file name
55
- @ changes</a></li>
56
- @ <li>%z(href("%R/reports"))Activity Reports</a></li>
57
- @ </ul>
58
- @ <li>%z(href("%R/brlist"))Branches</a></li>
59
- @ <ul>
60
- @ <li>%z(href("%R/leaves"))Leaf Check-ins</a></li>
61
- @ <li>%z(href("%R/taglist"))List of Tags</a></li>
62
- @ </ul>
63
- @ </li>
64
- @ <li>%z(href("%R/wikihelp"))Wiki</a>
65
- @ <ul>
66
- @ <li>%z(href("%R/wikisrch"))Wiki Search</a></li>
67
- @ <li>%z(href("%R/wcontent"))List of Wiki Pages</a></li>
68
- @ <li>%z(href("%R/timeline?y=w"))Recent activity</a></li>
69
- @ <li>%z(href("%R/wiki_rules"))Wiki Formatting Rules</a></li>
70
- @ <li>%z(href("%R/md_rules"))Markdown Formatting Rules</a></li>
71
- @ <li>%z(href("%R/wiki?name=Sandbox"))Sandbox</a></li>
72
- @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
73
- @ </ul>
74
- @ </li>
75
- @ <li>%z(href("%R/reportlist"))Tickets</a>
76
- @ <ul>
77
- @ <li>%z(href("%R/tktsrch"))Ticket Search</a></li>
78
- @ <li>%z(href("%R/timeline?y=t"))Recent activity</a></li>
79
- @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
80
- @ </ul>
81
- @ </li>
82
- @ <li>%z(href("%R/search"))Full-Text Search</a></li>
83
- @ <li>%z(href("%R/login"))Login/Logout/Change Password</a></li>
84
- @ <li>%z(href("%R/stat"))Repository Status</a>
85
- @ <ul>
86
- @ <li>%z(href("%R/hash-collisions"))Collisions on SHA1 hash
87
- @ prefixes</a></li>
88
- @ <li>%z(href("%R/urllist"))List of URLs used to access
89
- @ this repository</a></li>
90
- @ <li>%z(href("%R/bloblist"))List of Artifacts</a></li>
91
- @ </ul></li>
47
+ if( srchFlags & SRCH_DOC ){
48
+ @ <ul>
49
+ @ <li>%z(href("%R/docsrch"))Search Project Documentation</a></li>
50
+ @ </ul>
51
+ }
52
+ @ </li>
53
+ if( g.perm.Read ){
54
+ @ <li>%z(href("%R/tree"))File Browser</a></li>
55
+ @ <ul>
56
+ @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
57
+ @ Trunk Check-in</a></li>
58
+ @ <li>%z(href("%R/tree?type=flat"))Flat-view</a></li>
59
+ @ <li>%z(href("%R/fileage?name=trunk"))File ages for Trunk</a></li>
60
+ @ </ul>
61
+ }
62
+ if( g.perm.Read ){
63
+ @ <li>%z(href("%R/timeline?n=200"))Project Timeline</a></li>
64
+ @ <ul>
65
+ @ <li>%z(href("%R/reports"))Activity Reports</a></li>
66
+ @ <li>%z(href("%R/timeline?n=all&namechng"))File name changes</a></li>
67
+ @ <li>%z(href("%R/timeline?n=all&forks"))Forks</a></li>
68
+ @ <li>%z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10
69
+ @ check-ins</a></li>
70
+ @ </ul>
71
+ }
72
+ if( g.perm.Read ){
73
+ @ <li>%z(href("%R/brlist"))Branches</a></li>
74
+ @ <ul>
75
+ @ <li>%z(href("%R/leaves"))Leaf Check-ins</a></li>
76
+ @ <li>%z(href("%R/taglist"))List of Tags</a></li>
77
+ @ </ul>
78
+ @ </li>
79
+ }
80
+ if( g.perm.RdWiki ){
81
+ @ <li>%z(href("%R/wikihelp"))Wiki</a>
82
+ @ <ul>
83
+ if( srchFlags & SRCH_WIKI ){
84
+ @ <li>%z(href("%R/wikisrch"))Wiki Search</a></li>
85
+ }
86
+ @ <li>%z(href("%R/wcontent"))List of Wiki Pages</a></li>
87
+ @ <li>%z(href("%R/timeline?y=w"))Recent activity</a></li>
88
+ @ <li>%z(href("%R/wiki_rules"))Wiki Formatting Rules</a></li>
89
+ @ <li>%z(href("%R/md_rules"))Markdown Formatting Rules</a></li>
90
+ @ <li>%z(href("%R/wiki?name=Sandbox"))Sandbox</a></li>
91
+ @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
92
+ @ </ul>
93
+ @ </li>
94
+ }
95
+ if( g.perm.RdTkt ){
96
+ @ <li>%z(href("%R/reportlist"))Tickets</a>
97
+ @ <ul>
98
+ if( srchFlags & SRCH_TKT ){
99
+ @ <li>%z(href("%R/tktsrch"))Ticket Search</a></li>
100
+ }
101
+ @ <li>%z(href("%R/timeline?y=t"))Recent activity</a></li>
102
+ @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
103
+ @ </ul>
104
+ @ </li>
105
+ }
106
+ if( srchFlags ){
107
+ @ <li>%z(href("%R/search"))Full-Text Search</a></li>
108
+ }
109
+ @ <li>%z(href("%R/login"))Login/Logout/Change Password</a></li>
110
+ if( g.perm.Read ){
111
+ @ <li>%z(href("%R/stat"))Repository Status</a>
112
+ @ <ul>
113
+ @ <li>%z(href("%R/hash-collisions"))Collisions on SHA1 hash
114
+ @ prefixes</a></li>
115
+ if( g.perm.Admin ){
116
+ @ <li>%z(href("%R/urllist"))List of URLs used to access
117
+ @ this repository</a></li>
118
+ }
119
+ @ <li>%z(href("%R/bloblist"))List of Artifacts</a></li>
120
+ @ </ul>
121
+ @ </li>
122
+ }
92123
@ <li>On-line Documentation
93124
@ <ul>
94125
@ <li>%z(href("%R/help"))List of All Commands and Web Pages</a></li>
95126
@ <li>%z(href("%R/test-all-help"))All "help" text on a single page</a></li>
96127
@ <li>%z(href("%R/mimetype_list"))Filename suffix to mimetype map</a></li>
97128
@ </ul></li>
98
- @ <li>%z(href("%R/setup"))Administration Pages</a>
99
- @ <ul>
100
- @ <li>%z(href("%R/modreq"))Pending Moderation Requests</a></li>
101
- @ <li>%z(href("%R/admin_log"))Admin log</a></li>
102
- @ <li>%z(href("%R/cachestat"))Status of the web-page cache</a></li>
103
- @ </ul></li>
129
+ if( g.perm.Admin ){
130
+ @ <li>%z(href("%R/setup"))Administration Pages</a>
131
+ @ <ul>
132
+ @ <li>%z(href("%R/modreq"))Pending Moderation Requests</a></li>
133
+ @ <li>%z(href("%R/admin_log"))Admin log</a></li>
134
+ @ <li>%z(href("%R/cachestat"))Status of the web-page cache</a></li>
135
+ @ </ul></li>
136
+ }
104137
@ <li>Test Pages
105138
@ <ul>
106
- @ <li>%z(href("%R/test_env"))CGI Environment Test</a></li>
107
- @ <li>%z(href("%R/test_timewarps"))List of "Timewarp" Check-ins</a></li>
108
- @ <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
139
+ if( g.perm.Admin || db_get_boolean("test_env_enable",0) ){
140
+ @ <li>%z(href("%R/test_env"))CGI Environment Test</a></li>
141
+ }
142
+ if( g.perm.Read && g.perm.Hyperlink ){
143
+ @ <li>%z(href("%R/test_timewarps"))List of "Timewarp" Check-ins</a></li>
144
+ }
145
+ if( g.perm.Read ){
146
+ @ <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
147
+ }
109148
@ <li>%z(href("%R/hash-color-test"))Page to experiment with the automatic
110149
@ colors assigned to branch names</a>
150
+ @ <li>%z(href("%R/test-captcha"))Random ASCII-art Captcha image</li>
111151
@ </ul></li>
112152
@ </ul></li>
113153
style_footer();
114154
}
115155
--- src/sitemap.c
+++ src/sitemap.c
@@ -22,93 +22,133 @@
22 #include <assert.h>
23
24 /*
25 ** WEBPAGE: sitemap
26 **
27 ** Show an incomplete list of web pages offered by the Fossil web engine.
 
 
 
28 */
29 void sitemap_page(void){
 
30 login_check_credentials();
 
31 style_header("Site Map");
32 style_adunit_config(ADUNIT_RIGHT_OK);
 
33 @ <p>
34 @ The following links are just a few of the many web-pages available for
35 @ this Fossil repository:
36 @ </p>
37 @
 
38 @ <ul>
39 @ <li>%z(href("%R/home"))Home Page</a>
40 @ <ul>
41 @ <li>%z(href("%R/docsrc"))Search Project Documentation</a></li>
42 @ </ul></li>
43 @ <li>%z(href("%R/tree"))File Browser</a></li>
44 @ <ul>
45 @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
46 @ Trunk Check-in</a></li>
47 @ <li>%z(href("%R/tree?type=flat"))Flat-view</a></li>
48 @ <li>%z(href("%R/fileage?name=trunk"))File ages for Trunk</a></li>
49 @ </ul>
50 @ <li>%z(href("%R/timeline?n=200"))Project Timeline</a></li>
51 @ <ul>
52 @ <li>%z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10
53 @ check-ins</a></li>
54 @ <li>%z(href("%R/timeline?n=all&namechng"))All check-ins with file name
55 @ changes</a></li>
56 @ <li>%z(href("%R/reports"))Activity Reports</a></li>
57 @ </ul>
58 @ <li>%z(href("%R/brlist"))Branches</a></li>
59 @ <ul>
60 @ <li>%z(href("%R/leaves"))Leaf Check-ins</a></li>
61 @ <li>%z(href("%R/taglist"))List of Tags</a></li>
62 @ </ul>
63 @ </li>
64 @ <li>%z(href("%R/wikihelp"))Wiki</a>
65 @ <ul>
66 @ <li>%z(href("%R/wikisrch"))Wiki Search</a></li>
67 @ <li>%z(href("%R/wcontent"))List of Wiki Pages</a></li>
68 @ <li>%z(href("%R/timeline?y=w"))Recent activity</a></li>
69 @ <li>%z(href("%R/wiki_rules"))Wiki Formatting Rules</a></li>
70 @ <li>%z(href("%R/md_rules"))Markdown Formatting Rules</a></li>
71 @ <li>%z(href("%R/wiki?name=Sandbox"))Sandbox</a></li>
72 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
73 @ </ul>
74 @ </li>
75 @ <li>%z(href("%R/reportlist"))Tickets</a>
76 @ <ul>
77 @ <li>%z(href("%R/tktsrch"))Ticket Search</a></li>
78 @ <li>%z(href("%R/timeline?y=t"))Recent activity</a></li>
79 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
80 @ </ul>
81 @ </li>
82 @ <li>%z(href("%R/search"))Full-Text Search</a></li>
83 @ <li>%z(href("%R/login"))Login/Logout/Change Password</a></li>
84 @ <li>%z(href("%R/stat"))Repository Status</a>
85 @ <ul>
86 @ <li>%z(href("%R/hash-collisions"))Collisions on SHA1 hash
87 @ prefixes</a></li>
88 @ <li>%z(href("%R/urllist"))List of URLs used to access
89 @ this repository</a></li>
90 @ <li>%z(href("%R/bloblist"))List of Artifacts</a></li>
91 @ </ul></li>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92 @ <li>On-line Documentation
93 @ <ul>
94 @ <li>%z(href("%R/help"))List of All Commands and Web Pages</a></li>
95 @ <li>%z(href("%R/test-all-help"))All "help" text on a single page</a></li>
96 @ <li>%z(href("%R/mimetype_list"))Filename suffix to mimetype map</a></li>
97 @ </ul></li>
98 @ <li>%z(href("%R/setup"))Administration Pages</a>
99 @ <ul>
100 @ <li>%z(href("%R/modreq"))Pending Moderation Requests</a></li>
101 @ <li>%z(href("%R/admin_log"))Admin log</a></li>
102 @ <li>%z(href("%R/cachestat"))Status of the web-page cache</a></li>
103 @ </ul></li>
 
 
104 @ <li>Test Pages
105 @ <ul>
106 @ <li>%z(href("%R/test_env"))CGI Environment Test</a></li>
107 @ <li>%z(href("%R/test_timewarps"))List of "Timewarp" Check-ins</a></li>
108 @ <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
 
 
 
 
 
 
109 @ <li>%z(href("%R/hash-color-test"))Page to experiment with the automatic
110 @ colors assigned to branch names</a>
 
111 @ </ul></li>
112 @ </ul></li>
113 style_footer();
114 }
115
--- src/sitemap.c
+++ src/sitemap.c
@@ -22,93 +22,133 @@
22 #include <assert.h>
23
24 /*
25 ** WEBPAGE: sitemap
26 **
27 ** List some of the web pages offered by the Fossil web engine. This
28 ** page is intended as a suppliment to the menu bar on the main screen.
29 ** That is, this page is designed to hold links that are omitted from
30 ** the main menu due to lack of space.
31 */
32 void sitemap_page(void){
33 int srchFlags;
34 login_check_credentials();
35 srchFlags = search_restrict(SRCH_ALL);
36 style_header("Site Map");
37 style_adunit_config(ADUNIT_RIGHT_OK);
38 #if 0
39 @ <p>
40 @ The following links are just a few of the many web-pages available for
41 @ this Fossil repository:
42 @ </p>
43 @
44 #endif
45 @ <ul>
46 @ <li>%z(href("%R/home"))Home Page</a>
47 if( srchFlags & SRCH_DOC ){
48 @ <ul>
49 @ <li>%z(href("%R/docsrch"))Search Project Documentation</a></li>
50 @ </ul>
51 }
52 @ </li>
53 if( g.perm.Read ){
54 @ <li>%z(href("%R/tree"))File Browser</a></li>
55 @ <ul>
56 @ <li>%z(href("%R/tree?type=tree&ci=trunk"))Tree-view,
57 @ Trunk Check-in</a></li>
58 @ <li>%z(href("%R/tree?type=flat"))Flat-view</a></li>
59 @ <li>%z(href("%R/fileage?name=trunk"))File ages for Trunk</a></li>
60 @ </ul>
61 }
62 if( g.perm.Read ){
63 @ <li>%z(href("%R/timeline?n=200"))Project Timeline</a></li>
64 @ <ul>
65 @ <li>%z(href("%R/reports"))Activity Reports</a></li>
66 @ <li>%z(href("%R/timeline?n=all&namechng"))File name changes</a></li>
67 @ <li>%z(href("%R/timeline?n=all&forks"))Forks</a></li>
68 @ <li>%z(href("%R/timeline?a=1970-01-01&y=ci&n=10"))First 10
69 @ check-ins</a></li>
70 @ </ul>
71 }
72 if( g.perm.Read ){
73 @ <li>%z(href("%R/brlist"))Branches</a></li>
74 @ <ul>
75 @ <li>%z(href("%R/leaves"))Leaf Check-ins</a></li>
76 @ <li>%z(href("%R/taglist"))List of Tags</a></li>
77 @ </ul>
78 @ </li>
79 }
80 if( g.perm.RdWiki ){
81 @ <li>%z(href("%R/wikihelp"))Wiki</a>
82 @ <ul>
83 if( srchFlags & SRCH_WIKI ){
84 @ <li>%z(href("%R/wikisrch"))Wiki Search</a></li>
85 }
86 @ <li>%z(href("%R/wcontent"))List of Wiki Pages</a></li>
87 @ <li>%z(href("%R/timeline?y=w"))Recent activity</a></li>
88 @ <li>%z(href("%R/wiki_rules"))Wiki Formatting Rules</a></li>
89 @ <li>%z(href("%R/md_rules"))Markdown Formatting Rules</a></li>
90 @ <li>%z(href("%R/wiki?name=Sandbox"))Sandbox</a></li>
91 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
92 @ </ul>
93 @ </li>
94 }
95 if( g.perm.RdTkt ){
96 @ <li>%z(href("%R/reportlist"))Tickets</a>
97 @ <ul>
98 if( srchFlags & SRCH_TKT ){
99 @ <li>%z(href("%R/tktsrch"))Ticket Search</a></li>
100 }
101 @ <li>%z(href("%R/timeline?y=t"))Recent activity</a></li>
102 @ <li>%z(href("%R/attachlist"))List of Attachments</a></li>
103 @ </ul>
104 @ </li>
105 }
106 if( srchFlags ){
107 @ <li>%z(href("%R/search"))Full-Text Search</a></li>
108 }
109 @ <li>%z(href("%R/login"))Login/Logout/Change Password</a></li>
110 if( g.perm.Read ){
111 @ <li>%z(href("%R/stat"))Repository Status</a>
112 @ <ul>
113 @ <li>%z(href("%R/hash-collisions"))Collisions on SHA1 hash
114 @ prefixes</a></li>
115 if( g.perm.Admin ){
116 @ <li>%z(href("%R/urllist"))List of URLs used to access
117 @ this repository</a></li>
118 }
119 @ <li>%z(href("%R/bloblist"))List of Artifacts</a></li>
120 @ </ul>
121 @ </li>
122 }
123 @ <li>On-line Documentation
124 @ <ul>
125 @ <li>%z(href("%R/help"))List of All Commands and Web Pages</a></li>
126 @ <li>%z(href("%R/test-all-help"))All "help" text on a single page</a></li>
127 @ <li>%z(href("%R/mimetype_list"))Filename suffix to mimetype map</a></li>
128 @ </ul></li>
129 if( g.perm.Admin ){
130 @ <li>%z(href("%R/setup"))Administration Pages</a>
131 @ <ul>
132 @ <li>%z(href("%R/modreq"))Pending Moderation Requests</a></li>
133 @ <li>%z(href("%R/admin_log"))Admin log</a></li>
134 @ <li>%z(href("%R/cachestat"))Status of the web-page cache</a></li>
135 @ </ul></li>
136 }
137 @ <li>Test Pages
138 @ <ul>
139 if( g.perm.Admin || db_get_boolean("test_env_enable",0) ){
140 @ <li>%z(href("%R/test_env"))CGI Environment Test</a></li>
141 }
142 if( g.perm.Read && g.perm.Hyperlink ){
143 @ <li>%z(href("%R/test_timewarps"))List of "Timewarp" Check-ins</a></li>
144 }
145 if( g.perm.Read ){
146 @ <li>%z(href("%R/test-rename-list"))List of file renames</a></li>
147 }
148 @ <li>%z(href("%R/hash-color-test"))Page to experiment with the automatic
149 @ colors assigned to branch names</a>
150 @ <li>%z(href("%R/test-captcha"))Random ASCII-art Captcha image</li>
151 @ </ul></li>
152 @ </ul></li>
153 style_footer();
154 }
155
+195 -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 ){
@@ -334,10 +407,13 @@
334407
return 0;
335408
}
336409
337410
/*
338411
** WEBPAGE: setup_skin
412
+**
413
+** Show a list of available skins with buttons for selecting which
414
+** skin to use. Requires Admin privilege.
339415
*/
340416
void setup_skin(void){
341417
const char *z;
342418
char *zName;
343419
char *zErr = 0;
@@ -420,13 +496,15 @@
420496
style_header("Skins");
421497
if( zErr ){
422498
@ <p><font color="red">%h(zErr)</font></p>
423499
}
424500
@ <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
501
+ @ <a href="setup_skinedit?w=0">CSS</a>,
502
+ @ <a href="setup_skinedit?w=2">Header</a>,
503
+ @ <a href="setup_skinedit?w=1">Footer</a>, and
504
+ @ <a href="setup_skinedit?w=3">Details</a>
505
+ @ that determines the look and feel
428506
@ of the web interface.</p>
429507
@
430508
if( pAltSkin ){
431509
@ <p class="generalError">
432510
@ This page is generated using an skin override named
@@ -483,8 +561,101 @@
483561
@ <form action="%s(g.zTop)/setup_skin" method="post">
484562
@ <input type="submit" name="save" value="Save">
485563
@ </form>
486564
}
487565
@ </table>
566
+ style_footer();
567
+ db_end_transaction(0);
568
+}
569
+
570
+
571
+/*
572
+** WEBPAGE: setup_skinedit
573
+**
574
+** Edit aspects of a skin determined by the w= query parameter.
575
+** Requires Admin privileges.
576
+**
577
+** w=N -- 0=CSS, 1=footer, 2=header, 3=details
578
+*/
579
+void setup_skinedit(void){
580
+ static const struct sSkinAddr {
581
+ const char *zFile;
582
+ const char *zTitle;
583
+ const char *zSubmenu;
584
+ } aSkinAttr[] = {
585
+ /* 0 */ { "css", "CSS", "CSS", },
586
+ /* 1 */ { "footer", "Page Footer", "Footer", },
587
+ /* 2 */ { "header", "Page Header", "Header", },
588
+ /* 3 */ { "details", "Display Details", "Details", },
589
+ };
590
+ const char *zBasis;
591
+ const char *zContent;
592
+ char *zDflt;
593
+ int ii;
594
+ int j;
595
+
596
+ login_check_credentials();
597
+ if( !g.perm.Setup ){
598
+ login_needed(0);
599
+ return;
600
+ }
601
+ ii = atoi(PD("w","0"));
602
+ if( ii<0 || ii>ArraySize(aSkinAttr) ) ii = 0;
603
+ zBasis = PD("basis","default");
604
+ zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile);
605
+ db_begin_transaction();
606
+ if( P("revert")!=0 ){
607
+ db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile);
608
+ cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt));
609
+ }
610
+ style_header("%s", aSkinAttr[ii].zTitle);
611
+ for(j=0; j<ArraySize(aSkinAttr); j++){
612
+ if( j==ii ) continue;
613
+ style_submenu_element(aSkinAttr[j].zSubmenu, 0,
614
+ "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
615
+ }
616
+ style_submenu_element("Skins", 0, "%R/setup_skin");
617
+ @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
618
+ login_insert_csrf_secret();
619
+ @ <input type='hidden' name='w' value='%d(ii)'>
620
+ @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
621
+ zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
622
+ aSkinAttr[ii].zFile, builtin_text(zDflt), 0);
623
+ @ <br />
624
+ @ <input type="submit" name="submit" value="Apply Changes" />
625
+ @ <hr />
626
+ @ Baseline: <select size='1' name='basis'>
627
+ for(j=0; j<ArraySize(aBuiltinSkin); j++){
628
+ cgi_printf("<option value='%h'%s>%h</option>\n",
629
+ aBuiltinSkin[j].zLabel,
630
+ fossil_strcmp(zBasis,aBuiltinSkin[j].zLabel)==0 ? " selected" : "",
631
+ aBuiltinSkin[j].zDesc
632
+ );
633
+ }
634
+ @ </select>
635
+ @ <input type="submit" name="diff" value="Diff" />
636
+ if( P("diff")!=0 ){
637
+ u64 diffFlags = construct_diff_flags(0,0) |
638
+ DIFF_STRIP_EOLCR;
639
+ Blob from, to, out;
640
+ blob_init(&to, zContent, -1);
641
+ blob_init(&from, builtin_text(zDflt), -1);
642
+ blob_zero(&out);
643
+ @ <input type="submit" name="revert" value="Revert" /><p>
644
+ if( diffFlags & DIFF_SIDEBYSIDE ){
645
+ text_diff(&from, &to, &out, 0, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
646
+ @ %s(blob_str(&out))
647
+ }else{
648
+ text_diff(&from, &to, &out, 0,
649
+ diffFlags | DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG);
650
+ @ <pre class="udiff">
651
+ @ %s(blob_str(&out))
652
+ @ </pre>
653
+ }
654
+ blob_reset(&from);
655
+ blob_reset(&to);
656
+ blob_reset(&out);
657
+ }
658
+ @ </div></form>
488659
style_footer();
489660
db_end_transaction(0);
490661
}
491662
--- 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 ){
@@ -334,10 +407,13 @@
334 return 0;
335 }
336
337 /*
338 ** WEBPAGE: setup_skin
 
 
 
339 */
340 void setup_skin(void){
341 const char *z;
342 char *zName;
343 char *zErr = 0;
@@ -420,13 +496,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 +561,101 @@
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 ){
@@ -334,10 +407,13 @@
407 return 0;
408 }
409
410 /*
411 ** WEBPAGE: setup_skin
412 **
413 ** Show a list of available skins with buttons for selecting which
414 ** skin to use. Requires Admin privilege.
415 */
416 void setup_skin(void){
417 const char *z;
418 char *zName;
419 char *zErr = 0;
@@ -420,13 +496,15 @@
496 style_header("Skins");
497 if( zErr ){
498 @ <p><font color="red">%h(zErr)</font></p>
499 }
500 @ <p>A "skin" is a combination of
501 @ <a href="setup_skinedit?w=0">CSS</a>,
502 @ <a href="setup_skinedit?w=2">Header</a>,
503 @ <a href="setup_skinedit?w=1">Footer</a>, and
504 @ <a href="setup_skinedit?w=3">Details</a>
505 @ that determines the look and feel
506 @ of the web interface.</p>
507 @
508 if( pAltSkin ){
509 @ <p class="generalError">
510 @ This page is generated using an skin override named
@@ -483,8 +561,101 @@
561 @ <form action="%s(g.zTop)/setup_skin" method="post">
562 @ <input type="submit" name="save" value="Save">
563 @ </form>
564 }
565 @ </table>
566 style_footer();
567 db_end_transaction(0);
568 }
569
570
571 /*
572 ** WEBPAGE: setup_skinedit
573 **
574 ** Edit aspects of a skin determined by the w= query parameter.
575 ** Requires Admin privileges.
576 **
577 ** w=N -- 0=CSS, 1=footer, 2=header, 3=details
578 */
579 void setup_skinedit(void){
580 static const struct sSkinAddr {
581 const char *zFile;
582 const char *zTitle;
583 const char *zSubmenu;
584 } aSkinAttr[] = {
585 /* 0 */ { "css", "CSS", "CSS", },
586 /* 1 */ { "footer", "Page Footer", "Footer", },
587 /* 2 */ { "header", "Page Header", "Header", },
588 /* 3 */ { "details", "Display Details", "Details", },
589 };
590 const char *zBasis;
591 const char *zContent;
592 char *zDflt;
593 int ii;
594 int j;
595
596 login_check_credentials();
597 if( !g.perm.Setup ){
598 login_needed(0);
599 return;
600 }
601 ii = atoi(PD("w","0"));
602 if( ii<0 || ii>ArraySize(aSkinAttr) ) ii = 0;
603 zBasis = PD("basis","default");
604 zDflt = mprintf("skins/%s/%s.txt", zBasis, aSkinAttr[ii].zFile);
605 db_begin_transaction();
606 if( P("revert")!=0 ){
607 db_multi_exec("DELETE FROM config WHERE name=%Q", aSkinAttr[ii].zFile);
608 cgi_replace_parameter(aSkinAttr[ii].zFile, builtin_text(zDflt));
609 }
610 style_header("%s", aSkinAttr[ii].zTitle);
611 for(j=0; j<ArraySize(aSkinAttr); j++){
612 if( j==ii ) continue;
613 style_submenu_element(aSkinAttr[j].zSubmenu, 0,
614 "%R/setup_skinedit?w=%d&basis=%h",j,zBasis);
615 }
616 style_submenu_element("Skins", 0, "%R/setup_skin");
617 @ <form action="%s(g.zTop)/setup_skinedit" method="post"><div>
618 login_insert_csrf_secret();
619 @ <input type='hidden' name='w' value='%d(ii)'>
620 @ <h2>Edit %s(aSkinAttr[ii].zTitle):</h2>
621 zContent = textarea_attribute("", 10, 80, aSkinAttr[ii].zFile,
622 aSkinAttr[ii].zFile, builtin_text(zDflt), 0);
623 @ <br />
624 @ <input type="submit" name="submit" value="Apply Changes" />
625 @ <hr />
626 @ Baseline: <select size='1' name='basis'>
627 for(j=0; j<ArraySize(aBuiltinSkin); j++){
628 cgi_printf("<option value='%h'%s>%h</option>\n",
629 aBuiltinSkin[j].zLabel,
630 fossil_strcmp(zBasis,aBuiltinSkin[j].zLabel)==0 ? " selected" : "",
631 aBuiltinSkin[j].zDesc
632 );
633 }
634 @ </select>
635 @ <input type="submit" name="diff" value="Diff" />
636 if( P("diff")!=0 ){
637 u64 diffFlags = construct_diff_flags(0,0) |
638 DIFF_STRIP_EOLCR;
639 Blob from, to, out;
640 blob_init(&to, zContent, -1);
641 blob_init(&from, builtin_text(zDflt), -1);
642 blob_zero(&out);
643 @ <input type="submit" name="revert" value="Revert" /><p>
644 if( diffFlags & DIFF_SIDEBYSIDE ){
645 text_diff(&from, &to, &out, 0, diffFlags | DIFF_HTML | DIFF_NOTTOOBIG);
646 @ %s(blob_str(&out))
647 }else{
648 text_diff(&from, &to, &out, 0,
649 diffFlags | DIFF_LINENO | DIFF_HTML | DIFF_NOTTOOBIG);
650 @ <pre class="udiff">
651 @ %s(blob_str(&out))
652 @ </pre>
653 }
654 blob_reset(&from);
655 blob_reset(&to);
656 blob_reset(&out);
657 }
658 @ </div></form>
659 style_footer();
660 db_end_transaction(0);
661 }
662
+9 -2
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -66,21 +66,27 @@
6666
){
6767
const unsigned char *pIn;
6868
unsigned char *pOut;
6969
unsigned int nIn;
7070
unsigned long int nOut;
71
+ int rc;
7172
7273
pIn = sqlite3_value_blob(argv[0]);
7374
nIn = sqlite3_value_bytes(argv[0]);
7475
nOut = 13 + nIn + (nIn+999)/1000;
7576
pOut = sqlite3_malloc( nOut+4 );
7677
pOut[0] = nIn>>24 & 0xff;
7778
pOut[1] = nIn>>16 & 0xff;
7879
pOut[2] = nIn>>8 & 0xff;
7980
pOut[3] = nIn & 0xff;
80
- compress(&pOut[4], &nOut, pIn, nIn);
81
- sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);
81
+ rc = compress(&pOut[4], &nOut, pIn, nIn);
82
+ if( rc==Z_OK ){
83
+ sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);
84
+ }else{
85
+ sqlite3_free(pOut);
86
+ sqlite3_result_error(context, "input cannot be zlib compressed", -1);
87
+ }
8288
}
8389
8490
/*
8591
** Implementation of the "decompress(X)" SQL function. The argument X
8692
** is a blob which was obtained from compress(Y). The output will be
@@ -103,10 +109,11 @@
103109
pOut = sqlite3_malloc( nOut+1 );
104110
rc = uncompress(pOut, &nOut, &pIn[4], nIn-4);
105111
if( rc==Z_OK ){
106112
sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
107113
}else{
114
+ sqlite3_free(pOut);
108115
sqlite3_result_error(context, "input is not zlib compressed", -1);
109116
}
110117
}
111118
112119
/*
113120
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -66,21 +66,27 @@
66 ){
67 const unsigned char *pIn;
68 unsigned char *pOut;
69 unsigned int nIn;
70 unsigned long int nOut;
 
71
72 pIn = sqlite3_value_blob(argv[0]);
73 nIn = sqlite3_value_bytes(argv[0]);
74 nOut = 13 + nIn + (nIn+999)/1000;
75 pOut = sqlite3_malloc( nOut+4 );
76 pOut[0] = nIn>>24 & 0xff;
77 pOut[1] = nIn>>16 & 0xff;
78 pOut[2] = nIn>>8 & 0xff;
79 pOut[3] = nIn & 0xff;
80 compress(&pOut[4], &nOut, pIn, nIn);
81 sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);
 
 
 
 
 
82 }
83
84 /*
85 ** Implementation of the "decompress(X)" SQL function. The argument X
86 ** is a blob which was obtained from compress(Y). The output will be
@@ -103,10 +109,11 @@
103 pOut = sqlite3_malloc( nOut+1 );
104 rc = uncompress(pOut, &nOut, &pIn[4], nIn-4);
105 if( rc==Z_OK ){
106 sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
107 }else{
 
108 sqlite3_result_error(context, "input is not zlib compressed", -1);
109 }
110 }
111
112 /*
113
--- src/sqlcmd.c
+++ src/sqlcmd.c
@@ -66,21 +66,27 @@
66 ){
67 const unsigned char *pIn;
68 unsigned char *pOut;
69 unsigned int nIn;
70 unsigned long int nOut;
71 int rc;
72
73 pIn = sqlite3_value_blob(argv[0]);
74 nIn = sqlite3_value_bytes(argv[0]);
75 nOut = 13 + nIn + (nIn+999)/1000;
76 pOut = sqlite3_malloc( nOut+4 );
77 pOut[0] = nIn>>24 & 0xff;
78 pOut[1] = nIn>>16 & 0xff;
79 pOut[2] = nIn>>8 & 0xff;
80 pOut[3] = nIn & 0xff;
81 rc = compress(&pOut[4], &nOut, pIn, nIn);
82 if( rc==Z_OK ){
83 sqlite3_result_blob(context, pOut, nOut+4, sqlite3_free);
84 }else{
85 sqlite3_free(pOut);
86 sqlite3_result_error(context, "input cannot be zlib compressed", -1);
87 }
88 }
89
90 /*
91 ** Implementation of the "decompress(X)" SQL function. The argument X
92 ** is a blob which was obtained from compress(Y). The output will be
@@ -103,10 +109,11 @@
109 pOut = sqlite3_malloc( nOut+1 );
110 rc = uncompress(pOut, &nOut, &pIn[4], nIn-4);
111 if( rc==Z_OK ){
112 sqlite3_result_blob(context, pOut, nOut, sqlite3_free);
113 }else{
114 sqlite3_free(pOut);
115 sqlite3_result_error(context, "input is not zlib compressed", -1);
116 }
117 }
118
119 /*
120
+2640 -1268
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.8.9. By combining all the individual C code files into this
3
+** version 3.8.10.1. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -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
@@ -71,10 +68,11 @@
7168
#if defined(_MSC_VER)
7269
#pragma warning(disable : 4054)
7370
#pragma warning(disable : 4055)
7471
#pragma warning(disable : 4100)
7572
#pragma warning(disable : 4127)
73
+#pragma warning(disable : 4130)
7674
#pragma warning(disable : 4152)
7775
#pragma warning(disable : 4189)
7876
#pragma warning(disable : 4206)
7977
#pragma warning(disable : 4210)
8078
#pragma warning(disable : 4232)
@@ -250,27 +248,24 @@
250248
extern "C" {
251249
#endif
252250
253251
254252
/*
255
-** Add the ability to override 'extern'
253
+** Provide the ability to override linkage features of the interface.
256254
*/
257255
#ifndef SQLITE_EXTERN
258256
# define SQLITE_EXTERN extern
259257
#endif
260
-
261258
#ifndef SQLITE_API
262259
# define SQLITE_API
263260
#endif
264
-
265
-
266
-/*
267
-** Add the ability to override 'cdecl'
268
-*/
269261
#ifndef SQLITE_CDECL
270262
# define SQLITE_CDECL
271263
#endif
264
+#ifndef SQLITE_STDCALL
265
+# define SQLITE_STDCALL
266
+#endif
272267
273268
/*
274269
** These no-op macros are used in front of interfaces to mark those
275270
** interfaces as either deprecated or experimental. New applications
276271
** should not use deprecated interfaces - they are supported for backwards
@@ -321,13 +316,13 @@
321316
**
322317
** See also: [sqlite3_libversion()],
323318
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
324319
** [sqlite_version()] and [sqlite_source_id()].
325320
*/
326
-#define SQLITE_VERSION "3.8.9"
327
-#define SQLITE_VERSION_NUMBER 3008009
328
-#define SQLITE_SOURCE_ID "2015-03-24 18:19:39 436314b5728c9413f9ac2d837e1c19364f31be72"
321
+#define SQLITE_VERSION "3.8.10.1"
322
+#define SQLITE_VERSION_NUMBER 3008010
323
+#define SQLITE_SOURCE_ID "2015-05-09 12:14:55 05b4b1f2a937c06c90db70c09890038f6c98ec40"
329324
330325
/*
331326
** CAPI3REF: Run-Time Library Version Numbers
332327
** KEYWORDS: sqlite3_version, sqlite3_sourceid
333328
**
@@ -356,13 +351,13 @@
356351
** [SQLITE_SOURCE_ID] C preprocessor macro.
357352
**
358353
** See also: [sqlite_version()] and [sqlite_source_id()].
359354
*/
360355
SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
361
-SQLITE_API const char *sqlite3_libversion(void);
362
-SQLITE_API const char *sqlite3_sourceid(void);
363
-SQLITE_API int sqlite3_libversion_number(void);
356
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
357
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
358
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
364359
365360
/*
366361
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
367362
**
368363
** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -383,12 +378,12 @@
383378
**
384379
** See also: SQL functions [sqlite_compileoption_used()] and
385380
** [sqlite_compileoption_get()] and the [compile_options pragma].
386381
*/
387382
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
388
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
389
-SQLITE_API const char *sqlite3_compileoption_get(int N);
383
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
384
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
390385
#endif
391386
392387
/*
393388
** CAPI3REF: Test To See If The Library Is Threadsafe
394389
**
@@ -423,11 +418,11 @@
423418
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
424419
** is unchanged by calls to sqlite3_config().)^
425420
**
426421
** See the [threading mode] documentation for additional information.
427422
*/
428
-SQLITE_API int sqlite3_threadsafe(void);
423
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
429424
430425
/*
431426
** CAPI3REF: Database Connection Handle
432427
** KEYWORDS: {database connection} {database connections}
433428
**
@@ -480,10 +475,11 @@
480475
# define double sqlite3_int64
481476
#endif
482477
483478
/*
484479
** CAPI3REF: Closing A Database Connection
480
+** DESTRUCTOR: sqlite3
485481
**
486482
** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
487483
** for the [sqlite3] object.
488484
** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
489485
** the [sqlite3] object is successfully destroyed and all associated
@@ -519,12 +515,12 @@
519515
** from [sqlite3_open()], [sqlite3_open16()], or
520516
** [sqlite3_open_v2()], and not previously closed.
521517
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
522518
** argument is a harmless no-op.
523519
*/
524
-SQLITE_API int sqlite3_close(sqlite3*);
525
-SQLITE_API int sqlite3_close_v2(sqlite3*);
520
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
521
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
526522
527523
/*
528524
** The type for a callback function.
529525
** This is legacy and deprecated. It is included for historical
530526
** compatibility and is not documented.
@@ -531,10 +527,11 @@
531527
*/
532528
typedef int (*sqlite3_callback)(void*,int,char**, char**);
533529
534530
/*
535531
** CAPI3REF: One-Step Query Execution Interface
532
+** METHOD: sqlite3
536533
**
537534
** The sqlite3_exec() interface is a convenience wrapper around
538535
** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
539536
** that allows an application to run multiple statements of SQL
540537
** without having to use a lot of C code.
@@ -590,11 +587,11 @@
590587
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
591588
** <li> The application must not modify the SQL statement text passed into
592589
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
593590
** </ul>
594591
*/
595
-SQLITE_API int sqlite3_exec(
592
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
596593
sqlite3*, /* An open database */
597594
const char *sql, /* SQL to be evaluated */
598595
int (*callback)(void*,int,char**,char**), /* Callback function */
599596
void *, /* 1st argument to callback */
600597
char **errmsg /* Error msg written here */
@@ -1550,14 +1547,14 @@
15501547
** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
15511548
** implementation of sqlite3_os_init() or sqlite3_os_end()
15521549
** must return [SQLITE_OK] on success and some other [error code] upon
15531550
** failure.
15541551
*/
1555
-SQLITE_API int sqlite3_initialize(void);
1556
-SQLITE_API int sqlite3_shutdown(void);
1557
-SQLITE_API int sqlite3_os_init(void);
1558
-SQLITE_API int sqlite3_os_end(void);
1552
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1553
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1554
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1555
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
15591556
15601557
/*
15611558
** CAPI3REF: Configuring The SQLite Library
15621559
**
15631560
** The sqlite3_config() interface is used to make global configuration
@@ -1584,14 +1581,15 @@
15841581
**
15851582
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
15861583
** ^If the option is unknown or SQLite is unable to set the option
15871584
** then this routine returns a non-zero [error code].
15881585
*/
1589
-SQLITE_API int sqlite3_config(int, ...);
1586
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
15901587
15911588
/*
15921589
** CAPI3REF: Configure database connections
1590
+** METHOD: sqlite3
15931591
**
15941592
** The sqlite3_db_config() interface is used to make configuration
15951593
** changes to a [database connection]. The interface is similar to
15961594
** [sqlite3_config()] except that the changes apply to a single
15971595
** [database connection] (specified in the first argument).
@@ -1602,11 +1600,11 @@
16021600
** Subsequent arguments vary depending on the configuration verb.
16031601
**
16041602
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
16051603
** the call is considered successful.
16061604
*/
1607
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1605
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
16081606
16091607
/*
16101608
** CAPI3REF: Memory Allocation Routines
16111609
**
16121610
** An instance of this object defines the interface between SQLite
@@ -2085,19 +2083,21 @@
20852083
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
20862084
20872085
20882086
/*
20892087
** CAPI3REF: Enable Or Disable Extended Result Codes
2088
+** METHOD: sqlite3
20902089
**
20912090
** ^The sqlite3_extended_result_codes() routine enables or disables the
20922091
** [extended result codes] feature of SQLite. ^The extended result
20932092
** codes are disabled by default for historical compatibility.
20942093
*/
2095
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
2094
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
20962095
20972096
/*
20982097
** CAPI3REF: Last Insert Rowid
2098
+** METHOD: sqlite3
20992099
**
21002100
** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
21012101
** has a unique 64-bit signed
21022102
** integer key called the [ROWID | "rowid"]. ^The rowid is always available
21032103
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -2141,14 +2141,15 @@
21412141
** function is running and thus changes the last insert [rowid],
21422142
** then the value returned by [sqlite3_last_insert_rowid()] is
21432143
** unpredictable and might not equal either the old or the new
21442144
** last insert [rowid].
21452145
*/
2146
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2146
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
21472147
21482148
/*
21492149
** CAPI3REF: Count The Number Of Rows Modified
2150
+** METHOD: sqlite3
21502151
**
21512152
** ^This function returns the number of rows modified, inserted or
21522153
** deleted by the most recently completed INSERT, UPDATE or DELETE
21532154
** statement on the database connection specified by the only parameter.
21542155
** ^Executing any other type of SQL statement does not modify the value
@@ -2193,14 +2194,15 @@
21932194
**
21942195
** If a separate thread makes changes on the same database connection
21952196
** while [sqlite3_changes()] is running then the value returned
21962197
** is unpredictable and not meaningful.
21972198
*/
2198
-SQLITE_API int sqlite3_changes(sqlite3*);
2199
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
21992200
22002201
/*
22012202
** CAPI3REF: Total Number Of Rows Modified
2203
+** METHOD: sqlite3
22022204
**
22032205
** ^This function returns the total number of rows inserted, modified or
22042206
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
22052207
** since the database connection was opened, including those executed as
22062208
** part of trigger programs. ^Executing any other type of SQL statement
@@ -2216,14 +2218,15 @@
22162218
**
22172219
** If a separate thread makes changes on the same database connection
22182220
** while [sqlite3_total_changes()] is running then the value
22192221
** returned is unpredictable and not meaningful.
22202222
*/
2221
-SQLITE_API int sqlite3_total_changes(sqlite3*);
2223
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
22222224
22232225
/*
22242226
** CAPI3REF: Interrupt A Long-Running Query
2227
+** METHOD: sqlite3
22252228
**
22262229
** ^This function causes any pending database operation to abort and
22272230
** return at its earliest opportunity. This routine is typically
22282231
** called in response to a user action such as pressing "Cancel"
22292232
** or Ctrl-C where the user wants a long query operation to halt
@@ -2255,11 +2258,11 @@
22552258
** that are started after the sqlite3_interrupt() call returns.
22562259
**
22572260
** If the database connection closes while [sqlite3_interrupt()]
22582261
** is running then bad things will likely happen.
22592262
*/
2260
-SQLITE_API void sqlite3_interrupt(sqlite3*);
2263
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
22612264
22622265
/*
22632266
** CAPI3REF: Determine If An SQL Statement Is Complete
22642267
**
22652268
** These routines are useful during command-line input to determine if the
@@ -2290,16 +2293,17 @@
22902293
** UTF-8 string.
22912294
**
22922295
** The input to [sqlite3_complete16()] must be a zero-terminated
22932296
** UTF-16 string in native byte order.
22942297
*/
2295
-SQLITE_API int sqlite3_complete(const char *sql);
2296
-SQLITE_API int sqlite3_complete16(const void *sql);
2298
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2299
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
22972300
22982301
/*
22992302
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
23002303
** KEYWORDS: {busy-handler callback} {busy handler}
2304
+** METHOD: sqlite3
23012305
**
23022306
** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
23032307
** that might be invoked with argument P whenever
23042308
** an attempt is made to access a database table associated with
23052309
** [database connection] D when another thread
@@ -2351,14 +2355,15 @@
23512355
** result in undefined behavior.
23522356
**
23532357
** A busy handler must not close the database connection
23542358
** or [prepared statement] that invoked the busy handler.
23552359
*/
2356
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2360
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
23572361
23582362
/*
23592363
** CAPI3REF: Set A Busy Timeout
2364
+** METHOD: sqlite3
23602365
**
23612366
** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
23622367
** for a specified amount of time when a table is locked. ^The handler
23632368
** will sleep multiple times until at least "ms" milliseconds of sleeping
23642369
** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2373,14 +2378,15 @@
23732378
** was defined (using [sqlite3_busy_handler()]) prior to calling
23742379
** this routine, that other busy handler is cleared.)^
23752380
**
23762381
** See also: [PRAGMA busy_timeout]
23772382
*/
2378
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2383
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
23792384
23802385
/*
23812386
** CAPI3REF: Convenience Routines For Running Queries
2387
+** METHOD: sqlite3
23822388
**
23832389
** This is a legacy interface that is preserved for backwards compatibility.
23842390
** Use of this interface is not recommended.
23852391
**
23862392
** Definition: A <b>result table</b> is memory data structure created by the
@@ -2447,19 +2453,19 @@
24472453
** interface defined here. As a consequence, errors that occur in the
24482454
** wrapper layer outside of the internal [sqlite3_exec()] call are not
24492455
** reflected in subsequent calls to [sqlite3_errcode()] or
24502456
** [sqlite3_errmsg()].
24512457
*/
2452
-SQLITE_API int sqlite3_get_table(
2458
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
24532459
sqlite3 *db, /* An open database */
24542460
const char *zSql, /* SQL to be evaluated */
24552461
char ***pazResult, /* Results of the query */
24562462
int *pnRow, /* Number of result rows written here */
24572463
int *pnColumn, /* Number of result columns written here */
24582464
char **pzErrmsg /* Error msg written here */
24592465
);
2460
-SQLITE_API void sqlite3_free_table(char **result);
2466
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
24612467
24622468
/*
24632469
** CAPI3REF: Formatted String Printing Functions
24642470
**
24652471
** These routines are work-alikes of the "printf()" family of functions
@@ -2561,14 +2567,14 @@
25612567
**
25622568
** ^(The "%z" formatting option works like "%s" but with the
25632569
** addition that after the string has been read and copied into
25642570
** the result, [sqlite3_free()] is called on the input string.)^
25652571
*/
2566
-SQLITE_API char *sqlite3_mprintf(const char*,...);
2567
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2568
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2569
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2572
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2573
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2574
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2575
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
25702576
25712577
/*
25722578
** CAPI3REF: Memory Allocation Subsystem
25732579
**
25742580
** The SQLite core uses these three routines for all of its own
@@ -2654,16 +2660,16 @@
26542660
**
26552661
** The application must not read or write any part of
26562662
** a block of memory after it has been released using
26572663
** [sqlite3_free()] or [sqlite3_realloc()].
26582664
*/
2659
-SQLITE_API void *sqlite3_malloc(int);
2660
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2661
-SQLITE_API void *sqlite3_realloc(void*, int);
2662
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2663
-SQLITE_API void sqlite3_free(void*);
2664
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2665
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2666
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2667
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2668
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2669
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2670
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
26652671
26662672
/*
26672673
** CAPI3REF: Memory Allocator Statistics
26682674
**
26692675
** SQLite provides these two interfaces for reporting on the status
@@ -2684,12 +2690,12 @@
26842690
** [sqlite3_memory_used()] if and only if the parameter to
26852691
** [sqlite3_memory_highwater()] is true. ^The value returned
26862692
** by [sqlite3_memory_highwater(1)] is the high-water mark
26872693
** prior to the reset.
26882694
*/
2689
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2690
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2695
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2696
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
26912697
26922698
/*
26932699
** CAPI3REF: Pseudo-Random Number Generator
26942700
**
26952701
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2708,14 +2714,15 @@
27082714
** ^If the previous call to this routine had an N of 1 or more and a
27092715
** non-NULL P then the pseudo-randomness is generated
27102716
** internally and without recourse to the [sqlite3_vfs] xRandomness
27112717
** method.
27122718
*/
2713
-SQLITE_API void sqlite3_randomness(int N, void *P);
2719
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
27142720
27152721
/*
27162722
** CAPI3REF: Compile-Time Authorization Callbacks
2723
+** METHOD: sqlite3
27172724
**
27182725
** ^This routine registers an authorizer callback with a particular
27192726
** [database connection], supplied in the first argument.
27202727
** ^The authorizer callback is invoked as SQL statements are being compiled
27212728
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2790,11 +2797,11 @@
27902797
** [sqlite3_prepare()] or its variants. Authorization is not
27912798
** performed during statement evaluation in [sqlite3_step()], unless
27922799
** as stated in the previous paragraph, sqlite3_step() invokes
27932800
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
27942801
*/
2795
-SQLITE_API int sqlite3_set_authorizer(
2802
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
27962803
sqlite3*,
27972804
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
27982805
void *pUserData
27992806
);
28002807
@@ -2868,10 +2875,11 @@
28682875
#define SQLITE_COPY 0 /* No longer used */
28692876
#define SQLITE_RECURSIVE 33 /* NULL NULL */
28702877
28712878
/*
28722879
** CAPI3REF: Tracing And Profiling Functions
2880
+** METHOD: sqlite3
28732881
**
28742882
** These routines register callback functions that can be used for
28752883
** tracing and profiling the execution of SQL statements.
28762884
**
28772885
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2894,16 +2902,17 @@
28942902
** digits in the time are meaningless. Future versions of SQLite
28952903
** might provide greater resolution on the profiler callback. The
28962904
** sqlite3_profile() function is considered experimental and is
28972905
** subject to change in future versions of SQLite.
28982906
*/
2899
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2900
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2907
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2908
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
29012909
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
29022910
29032911
/*
29042912
** CAPI3REF: Query Progress Callbacks
2913
+** METHOD: sqlite3
29052914
**
29062915
** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
29072916
** function X to be invoked periodically during long running calls to
29082917
** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
29092918
** database connection D. An example use for this
@@ -2929,14 +2938,15 @@
29292938
** the database connection that invoked the progress handler.
29302939
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
29312940
** database connections for the meaning of "modify" in this paragraph.
29322941
**
29332942
*/
2934
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2943
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
29352944
29362945
/*
29372946
** CAPI3REF: Opening A New Database Connection
2947
+** CONSTRUCTOR: sqlite3
29382948
**
29392949
** ^These routines open an SQLite database file as specified by the
29402950
** filename argument. ^The filename argument is interpreted as UTF-8 for
29412951
** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
29422952
** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -3157,19 +3167,19 @@
31573167
** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
31583168
** features that require the use of temporary files may fail.
31593169
**
31603170
** See also: [sqlite3_temp_directory]
31613171
*/
3162
-SQLITE_API int sqlite3_open(
3172
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
31633173
const char *filename, /* Database filename (UTF-8) */
31643174
sqlite3 **ppDb /* OUT: SQLite db handle */
31653175
);
3166
-SQLITE_API int sqlite3_open16(
3176
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
31673177
const void *filename, /* Database filename (UTF-16) */
31683178
sqlite3 **ppDb /* OUT: SQLite db handle */
31693179
);
3170
-SQLITE_API int sqlite3_open_v2(
3180
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
31713181
const char *filename, /* Database filename (UTF-8) */
31723182
sqlite3 **ppDb, /* OUT: SQLite db handle */
31733183
int flags, /* Flags */
31743184
const char *zVfs /* Name of VFS module to use */
31753185
);
@@ -3211,17 +3221,18 @@
32113221
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
32123222
** is not a database file pathname pointer that SQLite passed into the xOpen
32133223
** VFS method, then the behavior of this routine is undefined and probably
32143224
** undesirable.
32153225
*/
3216
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3217
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3218
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3226
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3227
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3228
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
32193229
32203230
32213231
/*
32223232
** CAPI3REF: Error Codes And Messages
3233
+** METHOD: sqlite3
32233234
**
32243235
** ^If the most recent sqlite3_* API call associated with
32253236
** [database connection] D failed, then the sqlite3_errcode(D) interface
32263237
** returns the numeric [result code] or [extended result code] for that
32273238
** API call.
@@ -3256,44 +3267,45 @@
32563267
**
32573268
** If an interface fails with SQLITE_MISUSE, that means the interface
32583269
** was invoked incorrectly by the application. In that case, the
32593270
** error code and message may or may not be set.
32603271
*/
3261
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
3262
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3263
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3264
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3265
-SQLITE_API const char *sqlite3_errstr(int);
3272
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3273
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3274
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3275
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3276
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
32663277
32673278
/*
3268
-** CAPI3REF: SQL Statement Object
3279
+** CAPI3REF: Prepared Statement Object
32693280
** KEYWORDS: {prepared statement} {prepared statements}
32703281
**
3271
-** An instance of this object represents a single SQL statement.
3272
-** This object is variously known as a "prepared statement" or a
3273
-** "compiled SQL statement" or simply as a "statement".
3282
+** An instance of this object represents a single SQL statement that
3283
+** has been compiled into binary form and is ready to be evaluated.
32743284
**
3275
-** The life of a statement object goes something like this:
3285
+** Think of each SQL statement as a separate computer program. The
3286
+** original SQL text is source code. A prepared statement object
3287
+** is the compiled object code. All SQL must be converted into a
3288
+** prepared statement before it can be run.
3289
+**
3290
+** The life-cycle of a prepared statement object usually goes like this:
32763291
**
32773292
** <ol>
3278
-** <li> Create the object using [sqlite3_prepare_v2()] or a related
3279
-** function.
3280
-** <li> Bind values to [host parameters] using the sqlite3_bind_*()
3293
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3294
+** <li> Bind values to [parameters] using the sqlite3_bind_*()
32813295
** interfaces.
32823296
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3283
-** <li> Reset the statement using [sqlite3_reset()] then go back
3297
+** <li> Reset the prepared statement using [sqlite3_reset()] then go back
32843298
** to step 2. Do this zero or more times.
32853299
** <li> Destroy the object using [sqlite3_finalize()].
32863300
** </ol>
3287
-**
3288
-** Refer to documentation on individual methods above for additional
3289
-** information.
32903301
*/
32913302
typedef struct sqlite3_stmt sqlite3_stmt;
32923303
32933304
/*
32943305
** CAPI3REF: Run-time Limits
3306
+** METHOD: sqlite3
32953307
**
32963308
** ^(This interface allows the size of various constructs to be limited
32973309
** on a connection by connection basis. The first parameter is the
32983310
** [database connection] whose limit is to be set or queried. The
32993311
** second parameter is one of the [limit categories] that define a
@@ -3327,11 +3339,11 @@
33273339
** created by an untrusted script can be contained using the
33283340
** [max_page_count] [PRAGMA].
33293341
**
33303342
** New run-time limit categories may be added in future releases.
33313343
*/
3332
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3344
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
33333345
33343346
/*
33353347
** CAPI3REF: Run-Time Limit Categories
33363348
** KEYWORDS: {limit category} {*limit categories}
33373349
**
@@ -3401,10 +3413,12 @@
34013413
#define SQLITE_LIMIT_WORKER_THREADS 11
34023414
34033415
/*
34043416
** CAPI3REF: Compiling An SQL Statement
34053417
** KEYWORDS: {SQL statement compiler}
3418
+** METHOD: sqlite3
3419
+** CONSTRUCTOR: sqlite3_stmt
34063420
**
34073421
** To execute an SQL query, it must first be compiled into a byte-code
34083422
** program using one of these routines.
34093423
**
34103424
** The first argument, "db", is a [database connection] obtained from a
@@ -3477,50 +3491,52 @@
34773491
** or [GLOB] operator or if the parameter is compared to an indexed column
34783492
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
34793493
** </li>
34803494
** </ol>
34813495
*/
3482
-SQLITE_API int sqlite3_prepare(
3496
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
34833497
sqlite3 *db, /* Database handle */
34843498
const char *zSql, /* SQL statement, UTF-8 encoded */
34853499
int nByte, /* Maximum length of zSql in bytes. */
34863500
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34873501
const char **pzTail /* OUT: Pointer to unused portion of zSql */
34883502
);
3489
-SQLITE_API int sqlite3_prepare_v2(
3503
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
34903504
sqlite3 *db, /* Database handle */
34913505
const char *zSql, /* SQL statement, UTF-8 encoded */
34923506
int nByte, /* Maximum length of zSql in bytes. */
34933507
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
34943508
const char **pzTail /* OUT: Pointer to unused portion of zSql */
34953509
);
3496
-SQLITE_API int sqlite3_prepare16(
3510
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
34973511
sqlite3 *db, /* Database handle */
34983512
const void *zSql, /* SQL statement, UTF-16 encoded */
34993513
int nByte, /* Maximum length of zSql in bytes. */
35003514
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
35013515
const void **pzTail /* OUT: Pointer to unused portion of zSql */
35023516
);
3503
-SQLITE_API int sqlite3_prepare16_v2(
3517
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
35043518
sqlite3 *db, /* Database handle */
35053519
const void *zSql, /* SQL statement, UTF-16 encoded */
35063520
int nByte, /* Maximum length of zSql in bytes. */
35073521
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
35083522
const void **pzTail /* OUT: Pointer to unused portion of zSql */
35093523
);
35103524
35113525
/*
35123526
** CAPI3REF: Retrieving Statement SQL
3527
+** METHOD: sqlite3_stmt
35133528
**
35143529
** ^This interface can be used to retrieve a saved copy of the original
35153530
** SQL text used to create a [prepared statement] if that statement was
35163531
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
35173532
*/
3518
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3533
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
35193534
35203535
/*
35213536
** CAPI3REF: Determine If An SQL Statement Writes The Database
3537
+** METHOD: sqlite3_stmt
35223538
**
35233539
** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
35243540
** and only if the [prepared statement] X makes no direct changes to
35253541
** the content of the database file.
35263542
**
@@ -3544,14 +3560,15 @@
35443560
** database. ^The [ATTACH] and [DETACH] statements also cause
35453561
** sqlite3_stmt_readonly() to return true since, while those statements
35463562
** change the configuration of a database connection, they do not make
35473563
** changes to the content of the database files on disk.
35483564
*/
3549
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3565
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
35503566
35513567
/*
35523568
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3569
+** METHOD: sqlite3_stmt
35533570
**
35543571
** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
35553572
** [prepared statement] S has been stepped at least once using
35563573
** [sqlite3_step(S)] but has not run to completion and/or has not
35573574
** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3563,11 +3580,11 @@
35633580
** to locate all prepared statements associated with a database
35643581
** connection that are in need of being reset. This can be used,
35653582
** for example, in diagnostic routines to search for prepared
35663583
** statements that are holding a transaction open.
35673584
*/
3568
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3585
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
35693586
35703587
/*
35713588
** CAPI3REF: Dynamically Typed Value Object
35723589
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
35733590
**
@@ -3622,10 +3639,11 @@
36223639
36233640
/*
36243641
** CAPI3REF: Binding Values To Prepared Statements
36253642
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
36263643
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3644
+** METHOD: sqlite3_stmt
36273645
**
36283646
** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
36293647
** literals may be replaced by a [parameter] that matches one of following
36303648
** templates:
36313649
**
@@ -3724,26 +3742,27 @@
37243742
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
37253743
**
37263744
** See also: [sqlite3_bind_parameter_count()],
37273745
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
37283746
*/
3729
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3730
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3747
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3748
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
37313749
void(*)(void*));
3732
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3733
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3734
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3735
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3736
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3737
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3738
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3750
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3751
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3752
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3753
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3754
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3755
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3756
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
37393757
void(*)(void*), unsigned char encoding);
3740
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3741
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3758
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3759
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
37423760
37433761
/*
37443762
** CAPI3REF: Number Of SQL Parameters
3763
+** METHOD: sqlite3_stmt
37453764
**
37463765
** ^This routine can be used to find the number of [SQL parameters]
37473766
** in a [prepared statement]. SQL parameters are tokens of the
37483767
** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
37493768
** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3756,14 +3775,15 @@
37563775
**
37573776
** See also: [sqlite3_bind_blob|sqlite3_bind()],
37583777
** [sqlite3_bind_parameter_name()], and
37593778
** [sqlite3_bind_parameter_index()].
37603779
*/
3761
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3780
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
37623781
37633782
/*
37643783
** CAPI3REF: Name Of A Host Parameter
3784
+** METHOD: sqlite3_stmt
37653785
**
37663786
** ^The sqlite3_bind_parameter_name(P,N) interface returns
37673787
** the name of the N-th [SQL parameter] in the [prepared statement] P.
37683788
** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
37693789
** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3783,14 +3803,15 @@
37833803
**
37843804
** See also: [sqlite3_bind_blob|sqlite3_bind()],
37853805
** [sqlite3_bind_parameter_count()], and
37863806
** [sqlite3_bind_parameter_index()].
37873807
*/
3788
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3808
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
37893809
37903810
/*
37913811
** CAPI3REF: Index Of A Parameter With A Given Name
3812
+** METHOD: sqlite3_stmt
37923813
**
37933814
** ^Return the index of an SQL parameter given its name. ^The
37943815
** index value returned is suitable for use as the second
37953816
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
37963817
** is returned if no matching parameter is found. ^The parameter
@@ -3799,34 +3820,37 @@
37993820
**
38003821
** See also: [sqlite3_bind_blob|sqlite3_bind()],
38013822
** [sqlite3_bind_parameter_count()], and
38023823
** [sqlite3_bind_parameter_index()].
38033824
*/
3804
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3825
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
38053826
38063827
/*
38073828
** CAPI3REF: Reset All Bindings On A Prepared Statement
3829
+** METHOD: sqlite3_stmt
38083830
**
38093831
** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
38103832
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
38113833
** ^Use this routine to reset all host parameters to NULL.
38123834
*/
3813
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3835
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
38143836
38153837
/*
38163838
** CAPI3REF: Number Of Columns In A Result Set
3839
+** METHOD: sqlite3_stmt
38173840
**
38183841
** ^Return the number of columns in the result set returned by the
38193842
** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
38203843
** statement that does not return data (for example an [UPDATE]).
38213844
**
38223845
** See also: [sqlite3_data_count()]
38233846
*/
3824
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3847
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
38253848
38263849
/*
38273850
** CAPI3REF: Column Names In A Result Set
3851
+** METHOD: sqlite3_stmt
38283852
**
38293853
** ^These routines return the name assigned to a particular column
38303854
** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
38313855
** interface returns a pointer to a zero-terminated UTF-8 string
38323856
** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3847,15 +3871,16 @@
38473871
** ^The name of a result column is the value of the "AS" clause for
38483872
** that column, if there is an AS clause. If there is no AS clause
38493873
** then the name of the column is unspecified and may change from
38503874
** one release of SQLite to the next.
38513875
*/
3852
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3853
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3876
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3877
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
38543878
38553879
/*
38563880
** CAPI3REF: Source Of Data In A Query Result
3881
+** METHOD: sqlite3_stmt
38573882
**
38583883
** ^These routines provide a means to determine the database, table, and
38593884
** table column that is the origin of a particular result column in
38603885
** [SELECT] statement.
38613886
** ^The name of the database or table or column can be returned as
@@ -3895,19 +3920,20 @@
38953920
** If two or more threads call one or more
38963921
** [sqlite3_column_database_name | column metadata interfaces]
38973922
** for the same [prepared statement] and result column
38983923
** at the same time then the results are undefined.
38993924
*/
3900
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3901
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3902
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3903
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3904
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3905
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3925
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3926
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3927
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3928
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3929
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3930
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
39063931
39073932
/*
39083933
** CAPI3REF: Declared Datatype Of A Query Result
3934
+** METHOD: sqlite3_stmt
39093935
**
39103936
** ^(The first parameter is a [prepared statement].
39113937
** If this statement is a [SELECT] statement and the Nth column of the
39123938
** returned result set of that [SELECT] is a table column (not an
39133939
** expression or subquery) then the declared type of the table
@@ -3931,15 +3957,16 @@
39313957
** data stored in that column is of the declared type. SQLite is
39323958
** strongly typed, but the typing is dynamic not static. ^Type
39333959
** is associated with individual values, not with the containers
39343960
** used to hold those values.
39353961
*/
3936
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3937
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3962
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3963
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
39383964
39393965
/*
39403966
** CAPI3REF: Evaluate An SQL Statement
3967
+** METHOD: sqlite3_stmt
39413968
**
39423969
** After a [prepared statement] has been prepared using either
39433970
** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
39443971
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
39453972
** must be called one or more times to evaluate the statement.
@@ -4011,14 +4038,15 @@
40114038
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
40124039
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
40134040
** then the more specific [error codes] are returned directly
40144041
** by sqlite3_step(). The use of the "v2" interface is recommended.
40154042
*/
4016
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
4043
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
40174044
40184045
/*
40194046
** CAPI3REF: Number of columns in a result set
4047
+** METHOD: sqlite3_stmt
40204048
**
40214049
** ^The sqlite3_data_count(P) interface returns the number of columns in the
40224050
** current row of the result set of [prepared statement] P.
40234051
** ^If prepared statement P does not have results ready to return
40244052
** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -4031,11 +4059,11 @@
40314059
** where it always returns zero since each step of that multi-step
40324060
** pragma returns 0 columns of data.
40334061
**
40344062
** See also: [sqlite3_column_count()]
40354063
*/
4036
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4064
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
40374065
40384066
/*
40394067
** CAPI3REF: Fundamental Datatypes
40404068
** KEYWORDS: SQLITE_TEXT
40414069
**
@@ -4068,10 +4096,11 @@
40684096
#define SQLITE3_TEXT 3
40694097
40704098
/*
40714099
** CAPI3REF: Result Values From A Query
40724100
** KEYWORDS: {column access functions}
4101
+** METHOD: sqlite3_stmt
40734102
**
40744103
** These routines form the "result set" interface.
40754104
**
40764105
** ^These routines return information about a single column of the current
40774106
** result row of a query. ^In every case the first argument is a pointer
@@ -4227,23 +4256,24 @@
42274256
** of these routines, a default value is returned. The default value
42284257
** is either the integer 0, the floating point number 0.0, or a NULL
42294258
** pointer. Subsequent calls to [sqlite3_errcode()] will return
42304259
** [SQLITE_NOMEM].)^
42314260
*/
4232
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4233
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4234
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4235
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4236
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4237
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4238
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4239
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4240
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4241
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4261
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4262
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4263
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4264
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4265
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4266
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4267
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4268
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4269
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4270
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
42424271
42434272
/*
42444273
** CAPI3REF: Destroy A Prepared Statement Object
4274
+** DESTRUCTOR: sqlite3_stmt
42454275
**
42464276
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
42474277
** ^If the most recent evaluation of the statement encountered no errors
42484278
** or if the statement is never been evaluated, then sqlite3_finalize() returns
42494279
** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4263,14 +4293,15 @@
42634293
** resource leaks. It is a grievous error for the application to try to use
42644294
** a prepared statement after it has been finalized. Any use of a prepared
42654295
** statement after it has been finalized can result in undefined and
42664296
** undesirable behavior such as segfaults and heap corruption.
42674297
*/
4268
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4298
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
42694299
42704300
/*
42714301
** CAPI3REF: Reset A Prepared Statement Object
4302
+** METHOD: sqlite3_stmt
42724303
**
42734304
** The sqlite3_reset() function is called to reset a [prepared statement]
42744305
** object back to its initial state, ready to be re-executed.
42754306
** ^Any SQL statement variables that had values bound to them using
42764307
** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4289,17 +4320,18 @@
42894320
** [sqlite3_reset(S)] returns an appropriate [error code].
42904321
**
42914322
** ^The [sqlite3_reset(S)] interface does not change the values
42924323
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
42934324
*/
4294
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4325
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
42954326
42964327
/*
42974328
** CAPI3REF: Create Or Redefine SQL Functions
42984329
** KEYWORDS: {function creation routines}
42994330
** KEYWORDS: {application-defined SQL function}
43004331
** KEYWORDS: {application-defined SQL functions}
4332
+** METHOD: sqlite3
43014333
**
43024334
** ^These functions (collectively known as "function creation routines")
43034335
** are used to add SQL functions or aggregates or to redefine the behavior
43044336
** of existing SQL functions or aggregates. The only differences between
43054337
** these routines are the text encoding expected for
@@ -4388,31 +4420,31 @@
43884420
** ^An application-defined function is permitted to call other
43894421
** SQLite interfaces. However, such calls must not
43904422
** close the database connection nor finalize or reset the prepared
43914423
** statement in which the function is running.
43924424
*/
4393
-SQLITE_API int sqlite3_create_function(
4425
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
43944426
sqlite3 *db,
43954427
const char *zFunctionName,
43964428
int nArg,
43974429
int eTextRep,
43984430
void *pApp,
43994431
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
44004432
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
44014433
void (*xFinal)(sqlite3_context*)
44024434
);
4403
-SQLITE_API int sqlite3_create_function16(
4435
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
44044436
sqlite3 *db,
44054437
const void *zFunctionName,
44064438
int nArg,
44074439
int eTextRep,
44084440
void *pApp,
44094441
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
44104442
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
44114443
void (*xFinal)(sqlite3_context*)
44124444
);
4413
-SQLITE_API int sqlite3_create_function_v2(
4445
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
44144446
sqlite3 *db,
44154447
const char *zFunctionName,
44164448
int nArg,
44174449
int eTextRep,
44184450
void *pApp,
@@ -4454,21 +4486,22 @@
44544486
** to be supported. However, new applications should avoid
44554487
** the use of these functions. To encourage programmers to avoid
44564488
** these functions, we will not explain what they do.
44574489
*/
44584490
#ifndef SQLITE_OMIT_DEPRECATED
4459
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4460
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4461
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4462
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4463
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4464
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4491
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4492
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4493
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4494
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4495
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4496
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
44654497
void*,sqlite3_int64);
44664498
#endif
44674499
44684500
/*
44694501
** CAPI3REF: Obtaining SQL Function Parameter Values
4502
+** METHOD: sqlite3_value
44704503
**
44714504
** The C-language implementation of SQL functions and aggregates uses
44724505
** this set of interface routines to access the parameter values on
44734506
** the function or aggregate.
44744507
**
@@ -4508,25 +4541,26 @@
45084541
** or [sqlite3_value_text16()].
45094542
**
45104543
** These routines must be called from the same thread as
45114544
** the SQL function that supplied the [sqlite3_value*] parameters.
45124545
*/
4513
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4514
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4515
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4516
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
4517
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
4518
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4519
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4520
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4521
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4522
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4523
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
4524
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4546
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4547
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4548
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4549
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4550
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4551
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4552
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4553
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4554
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4555
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4556
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4557
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
45254558
45264559
/*
45274560
** CAPI3REF: Obtain Aggregate Function Context
4561
+** METHOD: sqlite3_context
45284562
**
45294563
** Implementations of aggregate SQL functions use this
45304564
** routine to allocate memory for storing their state.
45314565
**
45324566
** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4563,14 +4597,15 @@
45634597
** function.
45644598
**
45654599
** This routine must be called from the same thread in which
45664600
** the aggregate SQL function is running.
45674601
*/
4568
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4602
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
45694603
45704604
/*
45714605
** CAPI3REF: User Data For Functions
4606
+** METHOD: sqlite3_context
45724607
**
45734608
** ^The sqlite3_user_data() interface returns a copy of
45744609
** the pointer that was the pUserData parameter (the 5th parameter)
45754610
** of the [sqlite3_create_function()]
45764611
** and [sqlite3_create_function16()] routines that originally
@@ -4577,25 +4612,27 @@
45774612
** registered the application defined function.
45784613
**
45794614
** This routine must be called from the same thread in which
45804615
** the application-defined function is running.
45814616
*/
4582
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4617
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
45834618
45844619
/*
45854620
** CAPI3REF: Database Connection For Functions
4621
+** METHOD: sqlite3_context
45864622
**
45874623
** ^The sqlite3_context_db_handle() interface returns a copy of
45884624
** the pointer to the [database connection] (the 1st parameter)
45894625
** of the [sqlite3_create_function()]
45904626
** and [sqlite3_create_function16()] routines that originally
45914627
** registered the application defined function.
45924628
*/
4593
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4629
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
45944630
45954631
/*
45964632
** CAPI3REF: Function Auxiliary Data
4633
+** METHOD: sqlite3_context
45974634
**
45984635
** These functions may be used by (non-aggregate) SQL functions to
45994636
** associate metadata with argument values. If the same value is passed to
46004637
** multiple invocations of the same SQL function during query execution, under
46014638
** some circumstances the associated metadata may be preserved. An example
@@ -4640,12 +4677,12 @@
46404677
** values and [parameters] and expressions composed from the same.)^
46414678
**
46424679
** These routines must be called from the same thread in which
46434680
** the SQL function is running.
46444681
*/
4645
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4646
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4682
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4683
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
46474684
46484685
46494686
/*
46504687
** CAPI3REF: Constants Defining Special Destructor Behavior
46514688
**
@@ -4664,10 +4701,11 @@
46644701
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
46654702
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
46664703
46674704
/*
46684705
** CAPI3REF: Setting The Result Of An SQL Function
4706
+** METHOD: sqlite3_context
46694707
**
46704708
** These routines are used by the xFunc or xFinal callbacks that
46714709
** implement SQL functions and aggregates. See
46724710
** [sqlite3_create_function()] and [sqlite3_create_function16()]
46734711
** for additional information.
@@ -4776,33 +4814,34 @@
47764814
**
47774815
** If these routines are called from within the different thread
47784816
** than the one containing the application-defined function that received
47794817
** the [sqlite3_context] pointer, the results are undefined.
47804818
*/
4781
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4782
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4819
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4820
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
47834821
sqlite3_uint64,void(*)(void*));
4784
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4785
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4786
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4787
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4788
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4789
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4790
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4791
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4792
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
4793
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4794
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4822
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4823
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4824
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4825
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4826
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4827
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4828
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4829
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4830
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4831
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4832
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
47954833
void(*)(void*), unsigned char encoding);
4796
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4797
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4798
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4799
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4800
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4834
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4835
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4836
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4837
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4838
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
48014839
48024840
/*
48034841
** CAPI3REF: Define New Collating Sequences
4842
+** METHOD: sqlite3
48044843
**
48054844
** ^These functions add, remove, or modify a [collation] associated
48064845
** with the [database connection] specified as the first argument.
48074846
**
48084847
** ^The name of the collation is a UTF-8 string
@@ -4876,35 +4915,36 @@
48764915
** is unfortunate but cannot be changed without breaking backwards
48774916
** compatibility.
48784917
**
48794918
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
48804919
*/
4881
-SQLITE_API int sqlite3_create_collation(
4920
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
48824921
sqlite3*,
48834922
const char *zName,
48844923
int eTextRep,
48854924
void *pArg,
48864925
int(*xCompare)(void*,int,const void*,int,const void*)
48874926
);
4888
-SQLITE_API int sqlite3_create_collation_v2(
4927
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
48894928
sqlite3*,
48904929
const char *zName,
48914930
int eTextRep,
48924931
void *pArg,
48934932
int(*xCompare)(void*,int,const void*,int,const void*),
48944933
void(*xDestroy)(void*)
48954934
);
4896
-SQLITE_API int sqlite3_create_collation16(
4935
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
48974936
sqlite3*,
48984937
const void *zName,
48994938
int eTextRep,
49004939
void *pArg,
49014940
int(*xCompare)(void*,int,const void*,int,const void*)
49024941
);
49034942
49044943
/*
49054944
** CAPI3REF: Collation Needed Callbacks
4945
+** METHOD: sqlite3
49064946
**
49074947
** ^To avoid having to register all collation sequences before a database
49084948
** can be used, a single callback function may be registered with the
49094949
** [database connection] to be invoked whenever an undefined collation
49104950
** sequence is required.
@@ -4925,16 +4965,16 @@
49254965
**
49264966
** The callback function should register the desired collation using
49274967
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
49284968
** [sqlite3_create_collation_v2()].
49294969
*/
4930
-SQLITE_API int sqlite3_collation_needed(
4970
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
49314971
sqlite3*,
49324972
void*,
49334973
void(*)(void*,sqlite3*,int eTextRep,const char*)
49344974
);
4935
-SQLITE_API int sqlite3_collation_needed16(
4975
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
49364976
sqlite3*,
49374977
void*,
49384978
void(*)(void*,sqlite3*,int eTextRep,const void*)
49394979
);
49404980
@@ -4944,15 +4984,15 @@
49444984
** called right after sqlite3_open().
49454985
**
49464986
** The code to implement this API is not available in the public release
49474987
** of SQLite.
49484988
*/
4949
-SQLITE_API int sqlite3_key(
4989
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
49504990
sqlite3 *db, /* Database to be rekeyed */
49514991
const void *pKey, int nKey /* The key */
49524992
);
4953
-SQLITE_API int sqlite3_key_v2(
4993
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
49544994
sqlite3 *db, /* Database to be rekeyed */
49554995
const char *zDbName, /* Name of the database */
49564996
const void *pKey, int nKey /* The key */
49574997
);
49584998
@@ -4962,35 +5002,35 @@
49625002
** database is decrypted.
49635003
**
49645004
** The code to implement this API is not available in the public release
49655005
** of SQLite.
49665006
*/
4967
-SQLITE_API int sqlite3_rekey(
5007
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
49685008
sqlite3 *db, /* Database to be rekeyed */
49695009
const void *pKey, int nKey /* The new key */
49705010
);
4971
-SQLITE_API int sqlite3_rekey_v2(
5011
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
49725012
sqlite3 *db, /* Database to be rekeyed */
49735013
const char *zDbName, /* Name of the database */
49745014
const void *pKey, int nKey /* The new key */
49755015
);
49765016
49775017
/*
49785018
** Specify the activation key for a SEE database. Unless
49795019
** activated, none of the SEE routines will work.
49805020
*/
4981
-SQLITE_API void sqlite3_activate_see(
5021
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
49825022
const char *zPassPhrase /* Activation phrase */
49835023
);
49845024
#endif
49855025
49865026
#ifdef SQLITE_ENABLE_CEROD
49875027
/*
49885028
** Specify the activation key for a CEROD database. Unless
49895029
** activated, none of the CEROD routines will work.
49905030
*/
4991
-SQLITE_API void sqlite3_activate_cerod(
5031
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
49925032
const char *zPassPhrase /* Activation phrase */
49935033
);
49945034
#endif
49955035
49965036
/*
@@ -5008,11 +5048,11 @@
50085048
** method of the default [sqlite3_vfs] object. If the xSleep() method
50095049
** of the default VFS is not implemented correctly, or not implemented at
50105050
** all, then the behavior of sqlite3_sleep() may deviate from the description
50115051
** in the previous paragraphs.
50125052
*/
5013
-SQLITE_API int sqlite3_sleep(int);
5053
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
50145054
50155055
/*
50165056
** CAPI3REF: Name Of The Folder Holding Temporary Files
50175057
**
50185058
** ^(If this global variable is made to point to a string which is
@@ -5108,10 +5148,11 @@
51085148
SQLITE_API char *sqlite3_data_directory;
51095149
51105150
/*
51115151
** CAPI3REF: Test For Auto-Commit Mode
51125152
** KEYWORDS: {autocommit mode}
5153
+** METHOD: sqlite3
51135154
**
51145155
** ^The sqlite3_get_autocommit() interface returns non-zero or
51155156
** zero if the given database connection is or is not in autocommit mode,
51165157
** respectively. ^Autocommit mode is on by default.
51175158
** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -5126,26 +5167,28 @@
51265167
**
51275168
** If another thread changes the autocommit status of the database
51285169
** connection while this routine is running, then the return value
51295170
** is undefined.
51305171
*/
5131
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
5172
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
51325173
51335174
/*
51345175
** CAPI3REF: Find The Database Handle Of A Prepared Statement
5176
+** METHOD: sqlite3_stmt
51355177
**
51365178
** ^The sqlite3_db_handle interface returns the [database connection] handle
51375179
** to which a [prepared statement] belongs. ^The [database connection]
51385180
** returned by sqlite3_db_handle is the same [database connection]
51395181
** that was the first argument
51405182
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
51415183
** create the statement in the first place.
51425184
*/
5143
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5185
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
51445186
51455187
/*
51465188
** CAPI3REF: Return The Filename For A Database Connection
5189
+** METHOD: sqlite3
51475190
**
51485191
** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
51495192
** associated with database N of connection D. ^The main database file
51505193
** has the name "main". If there is no attached database N on the database
51515194
** connection D, or if database N is a temporary or in-memory database, then
@@ -5154,23 +5197,25 @@
51545197
** ^The filename returned by this function is the output of the
51555198
** xFullPathname method of the [VFS]. ^In other words, the filename
51565199
** will be an absolute pathname, even if the filename used
51575200
** to open the database originally was a URI or relative pathname.
51585201
*/
5159
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5202
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
51605203
51615204
/*
51625205
** CAPI3REF: Determine if a database is read-only
5206
+** METHOD: sqlite3
51635207
**
51645208
** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
51655209
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
51665210
** the name of a database on connection D.
51675211
*/
5168
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5212
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
51695213
51705214
/*
51715215
** CAPI3REF: Find the next prepared statement
5216
+** METHOD: sqlite3
51725217
**
51735218
** ^This interface returns a pointer to the next [prepared statement] after
51745219
** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
51755220
** then this interface returns a pointer to the first prepared statement
51765221
** associated with the database connection pDb. ^If no prepared statement
@@ -5178,14 +5223,15 @@
51785223
**
51795224
** The [database connection] pointer D in a call to
51805225
** [sqlite3_next_stmt(D,S)] must refer to an open database
51815226
** connection and in particular must not be a NULL pointer.
51825227
*/
5183
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5228
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
51845229
51855230
/*
51865231
** CAPI3REF: Commit And Rollback Notification Callbacks
5232
+** METHOD: sqlite3
51875233
**
51885234
** ^The sqlite3_commit_hook() interface registers a callback
51895235
** function to be invoked whenever a transaction is [COMMIT | committed].
51905236
** ^Any callback set by a previous call to sqlite3_commit_hook()
51915237
** for the same database connection is overridden.
@@ -5226,15 +5272,16 @@
52265272
** ^The rollback callback is not invoked if a transaction is
52275273
** automatically rolled back because the database connection is closed.
52285274
**
52295275
** See also the [sqlite3_update_hook()] interface.
52305276
*/
5231
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5232
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5277
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5278
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
52335279
52345280
/*
52355281
** CAPI3REF: Data Change Notification Callbacks
5282
+** METHOD: sqlite3
52365283
**
52375284
** ^The sqlite3_update_hook() interface registers a callback function
52385285
** with the [database connection] identified by the first argument
52395286
** to be invoked whenever a row is updated, inserted or deleted in
52405287
** a rowid table.
@@ -5277,11 +5324,11 @@
52775324
** the first call on D.
52785325
**
52795326
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
52805327
** interfaces.
52815328
*/
5282
-SQLITE_API void *sqlite3_update_hook(
5329
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
52835330
sqlite3*,
52845331
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
52855332
void*
52865333
);
52875334
@@ -5317,11 +5364,11 @@
53175364
** This interface is threadsafe on processors where writing a
53185365
** 32-bit integer is atomic.
53195366
**
53205367
** See Also: [SQLite Shared-Cache Mode]
53215368
*/
5322
-SQLITE_API int sqlite3_enable_shared_cache(int);
5369
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
53235370
53245371
/*
53255372
** CAPI3REF: Attempt To Free Heap Memory
53265373
**
53275374
** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5333,24 +5380,25 @@
53335380
** ^The sqlite3_release_memory() routine is a no-op returning zero
53345381
** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
53355382
**
53365383
** See also: [sqlite3_db_release_memory()]
53375384
*/
5338
-SQLITE_API int sqlite3_release_memory(int);
5385
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
53395386
53405387
/*
53415388
** CAPI3REF: Free Memory Used By A Database Connection
5389
+** METHOD: sqlite3
53425390
**
53435391
** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
53445392
** memory as possible from database connection D. Unlike the
53455393
** [sqlite3_release_memory()] interface, this interface is in effect even
53465394
** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
53475395
** omitted.
53485396
**
53495397
** See also: [sqlite3_release_memory()]
53505398
*/
5351
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5399
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
53525400
53535401
/*
53545402
** CAPI3REF: Impose A Limit On Heap Size
53555403
**
53565404
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5398,11 +5446,11 @@
53985446
** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
53995447
**
54005448
** The circumstances under which SQLite will enforce the soft heap limit may
54015449
** changes in future releases of SQLite.
54025450
*/
5403
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5451
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
54045452
54055453
/*
54065454
** CAPI3REF: Deprecated Soft Heap Limit Interface
54075455
** DEPRECATED
54085456
**
@@ -5409,15 +5457,16 @@
54095457
** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
54105458
** interface. This routine is provided for historical compatibility
54115459
** only. All new applications should use the
54125460
** [sqlite3_soft_heap_limit64()] interface rather than this one.
54135461
*/
5414
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5462
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
54155463
54165464
54175465
/*
54185466
** CAPI3REF: Extract Metadata About A Column Of A Table
5467
+** METHOD: sqlite3
54195468
**
54205469
** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
54215470
** information about column C of table T in database D
54225471
** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
54235472
** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5478,11 +5527,11 @@
54785527
**
54795528
** ^This function causes all database schemas to be read from disk and
54805529
** parsed, if that has not already been done, and returns an error if
54815530
** any errors are encountered while loading the schema.
54825531
*/
5483
-SQLITE_API int sqlite3_table_column_metadata(
5532
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
54845533
sqlite3 *db, /* Connection handle */
54855534
const char *zDbName, /* Database name or NULL */
54865535
const char *zTableName, /* Table name */
54875536
const char *zColumnName, /* Column name */
54885537
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5492,10 +5541,11 @@
54925541
int *pAutoinc /* OUTPUT: True if column is auto-increment */
54935542
);
54945543
54955544
/*
54965545
** CAPI3REF: Load An Extension
5546
+** METHOD: sqlite3
54975547
**
54985548
** ^This interface loads an SQLite extension library from the named file.
54995549
**
55005550
** ^The sqlite3_load_extension() interface attempts to load an
55015551
** [SQLite extension] library contained in the file zFile. If
@@ -5524,19 +5574,20 @@
55245574
** [sqlite3_enable_load_extension()] prior to calling this API,
55255575
** otherwise an error will be returned.
55265576
**
55275577
** See also the [load_extension() SQL function].
55285578
*/
5529
-SQLITE_API int sqlite3_load_extension(
5579
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
55305580
sqlite3 *db, /* Load the extension into this database connection */
55315581
const char *zFile, /* Name of the shared library containing extension */
55325582
const char *zProc, /* Entry point. Derived from zFile if 0 */
55335583
char **pzErrMsg /* Put error message here if not 0 */
55345584
);
55355585
55365586
/*
55375587
** CAPI3REF: Enable Or Disable Extension Loading
5588
+** METHOD: sqlite3
55385589
**
55395590
** ^So as not to open security holes in older applications that are
55405591
** unprepared to deal with [extension loading], and as a means of disabling
55415592
** [extension loading] while evaluating user-entered SQL, the following API
55425593
** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5544,11 +5595,11 @@
55445595
** ^Extension loading is off by default.
55455596
** ^Call the sqlite3_enable_load_extension() routine with onoff==1
55465597
** to turn extension loading on and call it with onoff==0 to turn
55475598
** it back off again.
55485599
*/
5549
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5600
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
55505601
55515602
/*
55525603
** CAPI3REF: Automatically Load Statically Linked Extensions
55535604
**
55545605
** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5582,11 +5633,11 @@
55825633
** will be called more than once for each database connection that is opened.
55835634
**
55845635
** See also: [sqlite3_reset_auto_extension()]
55855636
** and [sqlite3_cancel_auto_extension()]
55865637
*/
5587
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5638
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
55885639
55895640
/*
55905641
** CAPI3REF: Cancel Automatic Extension Loading
55915642
**
55925643
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5594,19 +5645,19 @@
55945645
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
55955646
** routine returns 1 if initialization routine X was successfully
55965647
** unregistered and it returns 0 if X was not on the list of initialization
55975648
** routines.
55985649
*/
5599
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5650
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
56005651
56015652
/*
56025653
** CAPI3REF: Reset Automatic Extension Loading
56035654
**
56045655
** ^This interface disables all automatic extensions previously
56055656
** registered using [sqlite3_auto_extension()].
56065657
*/
5607
-SQLITE_API void sqlite3_reset_auto_extension(void);
5658
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
56085659
56095660
/*
56105661
** The interface to the virtual-table mechanism is currently considered
56115662
** to be experimental. The interface might change in incompatible ways.
56125663
** If this is a problem for you, do not use the interface at this time.
@@ -5782,10 +5833,11 @@
57825833
#define SQLITE_INDEX_CONSTRAINT_GE 32
57835834
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
57845835
57855836
/*
57865837
** CAPI3REF: Register A Virtual Table Implementation
5838
+** METHOD: sqlite3
57875839
**
57885840
** ^These routines are used to register a new [virtual table module] name.
57895841
** ^Module names must be registered before
57905842
** creating a new [virtual table] using the module and before using a
57915843
** preexisting [virtual table] for the module.
@@ -5805,17 +5857,17 @@
58055857
** be invoked if the call to sqlite3_create_module_v2() fails.
58065858
** ^The sqlite3_create_module()
58075859
** interface is equivalent to sqlite3_create_module_v2() with a NULL
58085860
** destructor.
58095861
*/
5810
-SQLITE_API int sqlite3_create_module(
5862
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
58115863
sqlite3 *db, /* SQLite connection to register module with */
58125864
const char *zName, /* Name of the module */
58135865
const sqlite3_module *p, /* Methods for the module */
58145866
void *pClientData /* Client data for xCreate/xConnect */
58155867
);
5816
-SQLITE_API int sqlite3_create_module_v2(
5868
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
58175869
sqlite3 *db, /* SQLite connection to register module with */
58185870
const char *zName, /* Name of the module */
58195871
const sqlite3_module *p, /* Methods for the module */
58205872
void *pClientData, /* Client data for xCreate/xConnect */
58215873
void(*xDestroy)(void*) /* Module destructor function */
@@ -5874,14 +5926,15 @@
58745926
** ^The [xCreate] and [xConnect] methods of a
58755927
** [virtual table module] call this interface
58765928
** to declare the format (the names and datatypes of the columns) of
58775929
** the virtual tables they implement.
58785930
*/
5879
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5931
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
58805932
58815933
/*
58825934
** CAPI3REF: Overload A Function For A Virtual Table
5935
+** METHOD: sqlite3
58835936
**
58845937
** ^(Virtual tables can provide alternative implementations of functions
58855938
** using the [xFindFunction] method of the [virtual table module].
58865939
** But global versions of those functions
58875940
** must exist in order to be overloaded.)^
@@ -5892,11 +5945,11 @@
58925945
** of the new function always causes an exception to be thrown. So
58935946
** the new function is not good for anything by itself. Its only
58945947
** purpose is to be a placeholder function that can be overloaded
58955948
** by a [virtual table].
58965949
*/
5897
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5950
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
58985951
58995952
/*
59005953
** The interface to the virtual-table mechanism defined above (back up
59015954
** to a comment remarkably similar to this one) is currently considered
59025955
** to be experimental. The interface might change in incompatible ways.
@@ -5920,10 +5973,12 @@
59205973
*/
59215974
typedef struct sqlite3_blob sqlite3_blob;
59225975
59235976
/*
59245977
** CAPI3REF: Open A BLOB For Incremental I/O
5978
+** METHOD: sqlite3
5979
+** CONSTRUCTOR: sqlite3_blob
59255980
**
59265981
** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
59275982
** in row iRow, column zColumn, table zTable in database zDb;
59285983
** in other words, the same BLOB that would be selected by:
59295984
**
@@ -5989,11 +6044,11 @@
59896044
** zero-filled blob to read or write using the incremental-blob interface.
59906045
**
59916046
** To avoid a resource leak, every open [BLOB handle] should eventually
59926047
** be released by a call to [sqlite3_blob_close()].
59936048
*/
5994
-SQLITE_API int sqlite3_blob_open(
6049
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
59956050
sqlite3*,
59966051
const char *zDb,
59976052
const char *zTable,
59986053
const char *zColumn,
59996054
sqlite3_int64 iRow,
@@ -6001,10 +6056,11 @@
60016056
sqlite3_blob **ppBlob
60026057
);
60036058
60046059
/*
60056060
** CAPI3REF: Move a BLOB Handle to a New Row
6061
+** METHOD: sqlite3_blob
60066062
**
60076063
** ^This function is used to move an existing blob handle so that it points
60086064
** to a different row of the same database table. ^The new row is identified
60096065
** by the rowid value passed as the second argument. Only the row can be
60106066
** changed. ^The database, table and column on which the blob handle is open
@@ -6021,14 +6077,15 @@
60216077
** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
60226078
** always returns zero.
60236079
**
60246080
** ^This function sets the database handle error code and message.
60256081
*/
6026
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6082
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
60276083
60286084
/*
60296085
** CAPI3REF: Close A BLOB Handle
6086
+** DESTRUCTOR: sqlite3_blob
60306087
**
60316088
** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
60326089
** unconditionally. Even if this routine returns an error code, the
60336090
** handle is still closed.)^
60346091
**
@@ -6043,14 +6100,15 @@
60436100
** with a null pointer (such as would be returned by a failed call to
60446101
** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
60456102
** is passed a valid open blob handle, the values returned by the
60466103
** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
60476104
*/
6048
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
6105
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
60496106
60506107
/*
60516108
** CAPI3REF: Return The Size Of An Open BLOB
6109
+** METHOD: sqlite3_blob
60526110
**
60536111
** ^Returns the size in bytes of the BLOB accessible via the
60546112
** successfully opened [BLOB handle] in its only argument. ^The
60556113
** incremental blob I/O routines can only read or overwriting existing
60566114
** blob content; they cannot change the size of a blob.
@@ -6058,14 +6116,15 @@
60586116
** This routine only works on a [BLOB handle] which has been created
60596117
** by a prior successful call to [sqlite3_blob_open()] and which has not
60606118
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
60616119
** to this routine results in undefined and probably undesirable behavior.
60626120
*/
6063
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
6121
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
60646122
60656123
/*
60666124
** CAPI3REF: Read Data From A BLOB Incrementally
6125
+** METHOD: sqlite3_blob
60676126
**
60686127
** ^(This function is used to read data from an open [BLOB handle] into a
60696128
** caller-supplied buffer. N bytes of data are copied into buffer Z
60706129
** from the open BLOB, starting at offset iOffset.)^
60716130
**
@@ -6086,14 +6145,15 @@
60866145
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
60876146
** to this routine results in undefined and probably undesirable behavior.
60886147
**
60896148
** See also: [sqlite3_blob_write()].
60906149
*/
6091
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6150
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
60926151
60936152
/*
60946153
** CAPI3REF: Write Data Into A BLOB Incrementally
6154
+** METHOD: sqlite3_blob
60956155
**
60966156
** ^(This function is used to write data into an open [BLOB handle] from a
60976157
** caller-supplied buffer. N bytes of data are copied from the buffer Z
60986158
** into the open BLOB, starting at offset iOffset.)^
60996159
**
@@ -6127,11 +6187,11 @@
61276187
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
61286188
** to this routine results in undefined and probably undesirable behavior.
61296189
**
61306190
** See also: [sqlite3_blob_read()].
61316191
*/
6132
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6192
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
61336193
61346194
/*
61356195
** CAPI3REF: Virtual File System Objects
61366196
**
61376197
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6158,13 +6218,13 @@
61586218
**
61596219
** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
61606220
** ^(If the default VFS is unregistered, another VFS is chosen as
61616221
** the default. The choice for the new VFS is arbitrary.)^
61626222
*/
6163
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
6164
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6165
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
6223
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6224
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6225
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
61666226
61676227
/*
61686228
** CAPI3REF: Mutexes
61696229
**
61706230
** The SQLite core uses these routines for thread
@@ -6273,15 +6333,15 @@
62736333
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
62746334
** behave as no-ops.
62756335
**
62766336
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
62776337
*/
6278
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6279
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6280
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6281
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6282
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6338
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6339
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6340
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6341
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6342
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
62836343
62846344
/*
62856345
** CAPI3REF: Mutex Methods Object
62866346
**
62876347
** An instance of this structure defines the low-level routines
@@ -6387,12 +6447,12 @@
63876447
** call to sqlite3_mutex_held() to fail, so a non-zero return is
63886448
** the appropriate thing to do. The sqlite3_mutex_notheld()
63896449
** interface should also return 1 when given a NULL pointer.
63906450
*/
63916451
#ifndef NDEBUG
6392
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6393
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6452
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6453
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
63946454
#endif
63956455
63966456
/*
63976457
** CAPI3REF: Mutex Types
63986458
**
@@ -6417,21 +6477,23 @@
64176477
#define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
64186478
#define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
64196479
64206480
/*
64216481
** CAPI3REF: Retrieve the mutex for a database connection
6482
+** METHOD: sqlite3
64226483
**
64236484
** ^This interface returns a pointer the [sqlite3_mutex] object that
64246485
** serializes access to the [database connection] given in the argument
64256486
** when the [threading mode] is Serialized.
64266487
** ^If the [threading mode] is Single-thread or Multi-thread then this
64276488
** routine returns a NULL pointer.
64286489
*/
6429
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6490
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
64306491
64316492
/*
64326493
** CAPI3REF: Low-Level Control Of Database Files
6494
+** METHOD: sqlite3
64336495
**
64346496
** ^The [sqlite3_file_control()] interface makes a direct call to the
64356497
** xFileControl method for the [sqlite3_io_methods] object associated
64366498
** with a particular database identified by the second argument. ^The
64376499
** name of the database is "main" for the main database or "temp" for the
@@ -6458,11 +6520,11 @@
64586520
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
64596521
** xFileControl method.
64606522
**
64616523
** See also: [SQLITE_FCNTL_LOCKSTATE]
64626524
*/
6463
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6525
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
64646526
64656527
/*
64666528
** CAPI3REF: Testing Interface
64676529
**
64686530
** ^The sqlite3_test_control() interface is used to read out internal
@@ -6477,11 +6539,11 @@
64776539
** The details of the operation codes, their meanings, the parameters
64786540
** they take, and what they do are all subject to change without notice.
64796541
** Unlike most of the SQLite API, this function is not guaranteed to
64806542
** operate consistently from one release to the next.
64816543
*/
6482
-SQLITE_API int sqlite3_test_control(int op, ...);
6544
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
64836545
64846546
/*
64856547
** CAPI3REF: Testing Interface Operation Codes
64866548
**
64876549
** These constants are the valid operation code parameters used
@@ -6540,12 +6602,12 @@
65406602
** be represented by a 32-bit integer, then the values returned by
65416603
** sqlite3_status() are undefined.
65426604
**
65436605
** See also: [sqlite3_db_status()]
65446606
*/
6545
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6546
-SQLITE_API int sqlite3_status64(
6607
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6608
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
65476609
int op,
65486610
sqlite3_int64 *pCurrent,
65496611
sqlite3_int64 *pHighwater,
65506612
int resetFlag
65516613
);
@@ -6644,10 +6706,11 @@
66446706
#define SQLITE_STATUS_SCRATCH_SIZE 8
66456707
#define SQLITE_STATUS_MALLOC_COUNT 9
66466708
66476709
/*
66486710
** CAPI3REF: Database Connection Status
6711
+** METHOD: sqlite3
66496712
**
66506713
** ^This interface is used to retrieve runtime status information
66516714
** about a single [database connection]. ^The first argument is the
66526715
** database connection object to be interrogated. ^The second argument
66536716
** is an integer constant, taken from the set of
@@ -6664,11 +6727,11 @@
66646727
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
66656728
** non-zero [error code] on failure.
66666729
**
66676730
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
66686731
*/
6669
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6732
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
66706733
66716734
/*
66726735
** CAPI3REF: Status Parameters for database connections
66736736
** KEYWORDS: {SQLITE_DBSTATUS options}
66746737
**
@@ -6772,10 +6835,11 @@
67726835
#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
67736836
67746837
67756838
/*
67766839
** CAPI3REF: Prepared Statement Status
6840
+** METHOD: sqlite3_stmt
67776841
**
67786842
** ^(Each prepared statement maintains various
67796843
** [SQLITE_STMTSTATUS counters] that measure the number
67806844
** of times it has performed specific operations.)^ These counters can
67816845
** be used to monitor the performance characteristics of the prepared
@@ -6793,11 +6857,11 @@
67936857
** ^If the resetFlg is true, then the counter is reset to zero after this
67946858
** interface call returns.
67956859
**
67966860
** See also: [sqlite3_status()] and [sqlite3_db_status()].
67976861
*/
6798
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6862
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
67996863
68006864
/*
68016865
** CAPI3REF: Status Parameters for prepared statements
68026866
** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
68036867
**
@@ -7262,23 +7326,24 @@
72627326
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
72637327
** APIs are not strictly speaking threadsafe. If they are invoked at the
72647328
** same time as another thread is invoking sqlite3_backup_step() it is
72657329
** possible that they return invalid values.
72667330
*/
7267
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
7331
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
72687332
sqlite3 *pDest, /* Destination database handle */
72697333
const char *zDestName, /* Destination database name */
72707334
sqlite3 *pSource, /* Source database handle */
72717335
const char *zSourceName /* Source database name */
72727336
);
7273
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7274
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7275
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7276
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7337
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7338
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7339
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7340
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
72777341
72787342
/*
72797343
** CAPI3REF: Unlock Notification
7344
+** METHOD: sqlite3
72807345
**
72817346
** ^When running in shared-cache mode, a database operation may fail with
72827347
** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
72837348
** individual tables within the shared-cache cannot be obtained. See
72847349
** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7387,11 +7452,11 @@
73877452
** by an sqlite3_step() call. ^(If there is a blocking connection, then the
73887453
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
73897454
** the special "DROP TABLE/INDEX" case, the extended error code is just
73907455
** SQLITE_LOCKED.)^
73917456
*/
7392
-SQLITE_API int sqlite3_unlock_notify(
7457
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
73937458
sqlite3 *pBlocked, /* Waiting connection */
73947459
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
73957460
void *pNotifyArg /* Argument to pass to xNotify */
73967461
);
73977462
@@ -7402,12 +7467,12 @@
74027467
** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
74037468
** and extensions to compare the contents of two buffers containing UTF-8
74047469
** strings in a case-independent fashion, using the same definition of "case
74057470
** independence" that SQLite uses internally when comparing identifiers.
74067471
*/
7407
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
7408
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7472
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7473
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
74097474
74107475
/*
74117476
** CAPI3REF: String Globbing
74127477
*
74137478
** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7418,11 +7483,11 @@
74187483
** sensitive.
74197484
**
74207485
** Note that this routine returns zero on a match and non-zero if the strings
74217486
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
74227487
*/
7423
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7488
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
74247489
74257490
/*
74267491
** CAPI3REF: Error Logging Interface
74277492
**
74287493
** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7441,14 +7506,15 @@
74417506
** will not use dynamically allocated memory. The log message is stored in
74427507
** a fixed-length buffer on the stack. If the log message is longer than
74437508
** a few hundred characters, it will be truncated to the length of the
74447509
** buffer.
74457510
*/
7446
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7511
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
74477512
74487513
/*
74497514
** CAPI3REF: Write-Ahead Log Commit Hook
7515
+** METHOD: sqlite3
74507516
**
74517517
** ^The [sqlite3_wal_hook()] function is used to register a callback that
74527518
** is invoked each time data is committed to a database in wal mode.
74537519
**
74547520
** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7476,18 +7542,19 @@
74767542
** previously registered write-ahead log callback. ^Note that the
74777543
** [sqlite3_wal_autocheckpoint()] interface and the
74787544
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
74797545
** those overwrite any prior [sqlite3_wal_hook()] settings.
74807546
*/
7481
-SQLITE_API void *sqlite3_wal_hook(
7547
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
74827548
sqlite3*,
74837549
int(*)(void *,sqlite3*,const char*,int),
74847550
void*
74857551
);
74867552
74877553
/*
74887554
** CAPI3REF: Configure an auto-checkpoint
7555
+** METHOD: sqlite3
74897556
**
74907557
** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
74917558
** [sqlite3_wal_hook()] that causes any database on [database connection] D
74927559
** to automatically [checkpoint]
74937560
** after committing a transaction if there are N or
@@ -7510,14 +7577,15 @@
75107577
** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
75117578
** pages. The use of this interface
75127579
** is only necessary if the default setting is found to be suboptimal
75137580
** for a particular application.
75147581
*/
7515
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7582
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
75167583
75177584
/*
75187585
** CAPI3REF: Checkpoint a database
7586
+** METHOD: sqlite3
75197587
**
75207588
** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
75217589
** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
75227590
**
75237591
** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7531,14 +7599,15 @@
75317599
** interface was added. This interface is retained for backwards
75327600
** compatibility and as a convenience for applications that need to manually
75337601
** start a callback but which do not need the full power (and corresponding
75347602
** complication) of [sqlite3_wal_checkpoint_v2()].
75357603
*/
7536
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7604
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
75377605
75387606
/*
75397607
** CAPI3REF: Checkpoint a database
7608
+** METHOD: sqlite3
75407609
**
75417610
** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
75427611
** operation on database X of [database connection] D in mode M. Status
75437612
** information is written back into integers pointed to by L and C.)^
75447613
** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7624,11 +7693,11 @@
76247693
** [sqlite3_errcode()] and [sqlite3_errmsg()].
76257694
**
76267695
** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
76277696
** from SQL.
76287697
*/
7629
-SQLITE_API int sqlite3_wal_checkpoint_v2(
7698
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
76307699
sqlite3 *db, /* Database handle */
76317700
const char *zDb, /* Name of attached database (or NULL) */
76327701
int eMode, /* SQLITE_CHECKPOINT_* value */
76337702
int *pnLog, /* OUT: Size of WAL log in frames */
76347703
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7660,11 +7729,11 @@
76607729
**
76617730
** At present, there is only one option that may be configured using
76627731
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
76637732
** may be added in the future.
76647733
*/
7665
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7734
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
76667735
76677736
/*
76687737
** CAPI3REF: Virtual Table Configuration Options
76697738
**
76707739
** These macros define the various options to the
@@ -7713,11 +7782,11 @@
77137782
** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
77147783
** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
77157784
** of the SQL statement that triggered the call to the [xUpdate] method of the
77167785
** [virtual table].
77177786
*/
7718
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7787
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
77197788
77207789
/*
77217790
** CAPI3REF: Conflict resolution modes
77227791
** KEYWORDS: {conflict resolution mode}
77237792
**
@@ -7789,10 +7858,11 @@
77897858
#define SQLITE_SCANSTAT_EXPLAIN 4
77907859
#define SQLITE_SCANSTAT_SELECTID 5
77917860
77927861
/*
77937862
** CAPI3REF: Prepared Statement Scan Status
7863
+** METHOD: sqlite3_stmt
77947864
**
77957865
** This interface returns information about the predicted and measured
77967866
** performance for pStmt. Advanced applications can use this
77977867
** interface to compare the predicted and the measured performance and
77987868
** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7817,26 +7887,27 @@
78177887
** as if the loop did not exist - it returns non-zero and leave the variable
78187888
** that pOut points to unchanged.
78197889
**
78207890
** See also: [sqlite3_stmt_scanstatus_reset()]
78217891
*/
7822
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7892
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
78237893
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
78247894
int idx, /* Index of loop to report on */
78257895
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
78267896
void *pOut /* Result written here */
78277897
);
78287898
78297899
/*
78307900
** CAPI3REF: Zero Scan-Status Counters
7901
+** METHOD: sqlite3_stmt
78317902
**
78327903
** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
78337904
**
78347905
** This API is only available if the library is built with pre-processor
78357906
** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
78367907
*/
7837
-SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7908
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
78387909
78397910
78407911
/*
78417912
** Undo the hack that converts floating point types to integer for
78427913
** builds on processors without floating point support.
@@ -7887,11 +7958,11 @@
78877958
** Register a geometry callback named zGeom that can be used as part of an
78887959
** R-Tree geometry query as follows:
78897960
**
78907961
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
78917962
*/
7892
-SQLITE_API int sqlite3_rtree_geometry_callback(
7963
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
78937964
sqlite3 *db,
78947965
const char *zGeom,
78957966
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
78967967
void *pContext
78977968
);
@@ -7913,11 +7984,11 @@
79137984
** Register a 2nd-generation geometry callback named zScore that can be
79147985
** used as part of an R-Tree geometry query as follows:
79157986
**
79167987
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
79177988
*/
7918
-SQLITE_API int sqlite3_rtree_query_callback(
7989
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
79197990
sqlite3 *db,
79207991
const char *zQueryFunc,
79217992
int (*xQueryFunc)(sqlite3_rtree_query_info*),
79227993
void *pContext,
79237994
void (*xDestructor)(void*)
@@ -8436,10 +8507,36 @@
84368507
#else
84378508
# define ALWAYS(X) (X)
84388509
# define NEVER(X) (X)
84398510
#endif
84408511
8512
+/*
8513
+** Declarations used for tracing the operating system interfaces.
8514
+*/
8515
+#if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
8516
+ (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
8517
+ extern int sqlite3OSTrace;
8518
+# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
8519
+# define SQLITE_HAVE_OS_TRACE
8520
+#else
8521
+# define OSTRACE(X)
8522
+# undef SQLITE_HAVE_OS_TRACE
8523
+#endif
8524
+
8525
+/*
8526
+** Is the sqlite3ErrName() function needed in the build? Currently,
8527
+** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
8528
+** OSTRACE is enabled), and by several "test*.c" files (which are
8529
+** compiled using SQLITE_TEST).
8530
+*/
8531
+#if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
8532
+ (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
8533
+# define SQLITE_NEED_ERR_NAME
8534
+#else
8535
+# undef SQLITE_NEED_ERR_NAME
8536
+#endif
8537
+
84418538
/*
84428539
** Return true (non-zero) if the input is an integer that is too large
84438540
** to fit in 32-bits. This macro is used inside of various testcase()
84448541
** macros to verify that we have tested SQLite for large-file support.
84458542
*/
@@ -9157,12 +9254,12 @@
91579254
*/
91589255
#ifdef SQLITE_OMIT_WSD
91599256
#define SQLITE_WSD const
91609257
#define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
91619258
#define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9162
-SQLITE_API int sqlite3_wsd_init(int N, int J);
9163
-SQLITE_API void *sqlite3_wsd_find(void *K, int L);
9259
+SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
9260
+SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
91649261
#else
91659262
#define SQLITE_WSD
91669263
#define GLOBAL(t,v) v
91679264
#define sqlite3GlobalConfig sqlite3Config
91689265
#endif
@@ -9847,37 +9944,36 @@
98479944
/* Properties such as "out2" or "jump" that are specified in
98489945
** comments following the "case" for each opcode in the vdbe.c
98499946
** are encoded into bitvectors as follows:
98509947
*/
98519948
#define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */
9852
-#define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */
9853
-#define OPFLG_IN1 0x0004 /* in1: P1 is an input */
9854
-#define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9855
-#define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9856
-#define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9857
-#define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9949
+#define OPFLG_IN1 0x0002 /* in1: P1 is an input */
9950
+#define OPFLG_IN2 0x0004 /* in2: P2 is an input */
9951
+#define OPFLG_IN3 0x0008 /* in3: P3 is an input */
9952
+#define OPFLG_OUT2 0x0010 /* out2: P2 is an output */
9953
+#define OPFLG_OUT3 0x0020 /* out3: P3 is an output */
98589954
#define OPFLG_INITIALIZER {\
98599955
/* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9860
-/* 8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\
9861
-/* 16 */ 0x01, 0x01, 0x04, 0x24, 0x01, 0x04, 0x05, 0x10,\
9862
-/* 24 */ 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02,\
9863
-/* 32 */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x05, 0x04,\
9864
-/* 40 */ 0x04, 0x00, 0x00, 0x01, 0x01, 0x05, 0x05, 0x00,\
9865
-/* 48 */ 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00,\
9866
-/* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9867
-/* 64 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x4c,\
9868
-/* 72 */ 0x4c, 0x02, 0x02, 0x00, 0x05, 0x05, 0x15, 0x15,\
9869
-/* 80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\
9870
-/* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\
9871
-/* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\
9872
-/* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\
9873
-/* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
9874
-/* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9875
-/* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
9876
-/* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\
9956
+/* 8 */ 0x01, 0x01, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,\
9957
+/* 16 */ 0x01, 0x01, 0x02, 0x12, 0x01, 0x02, 0x03, 0x08,\
9958
+/* 24 */ 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,\
9959
+/* 32 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x03, 0x02,\
9960
+/* 40 */ 0x02, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x00,\
9961
+/* 48 */ 0x00, 0x00, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00,\
9962
+/* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09,\
9963
+/* 64 */ 0x09, 0x09, 0x04, 0x09, 0x09, 0x09, 0x09, 0x26,\
9964
+/* 72 */ 0x26, 0x10, 0x10, 0x00, 0x03, 0x03, 0x0b, 0x0b,\
9965
+/* 80 */ 0x0b, 0x0b, 0x0b, 0x0b, 0x00, 0x26, 0x26, 0x26,\
9966
+/* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
9967
+/* 96 */ 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
9968
+/* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x00,\
9969
+/* 112 */ 0x10, 0x01, 0x01, 0x01, 0x01, 0x10, 0x00, 0x00,\
9970
+/* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9971
+/* 128 */ 0x06, 0x23, 0x0b, 0x01, 0x10, 0x10, 0x00, 0x01,\
9972
+/* 136 */ 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x01,\
98779973
/* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
9878
-/* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
9974
+/* 152 */ 0x00, 0x10, 0x10, 0x01, 0x00, 0x00,}
98799975
98809976
/************** End of opcodes.h *********************************************/
98819977
/************** Continuing where we left off in vdbe.h ***********************/
98829978
98839979
/*
@@ -9932,10 +10028,11 @@
993210028
#endif
993310029
SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
993410030
993510031
SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
993610032
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
10033
+SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
993710034
SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
993810035
993910036
typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
994010037
SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
994110038
@@ -11069,10 +11166,11 @@
1106911166
#define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
1107011167
#define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
1107111168
#define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
1107211169
#define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
1107311170
#define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
11171
+#define SQLITE_Vacuum 0x08000000 /* Currently in a VACUUM */
1107411172
1107511173
1107611174
/*
1107711175
** Bits of the sqlite3.dbOptFlags field that are used by the
1107811176
** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -11399,38 +11497,12 @@
1139911497
int iSavepoint; /* Depth of the SAVEPOINT stack */
1140011498
VTable *pNext; /* Next in linked list (see above) */
1140111499
};
1140211500
1140311501
/*
11404
-** Each SQL table is represented in memory by an instance of the
11405
-** following structure.
11406
-**
11407
-** Table.zName is the name of the table. The case of the original
11408
-** CREATE TABLE statement is stored, but case is not significant for
11409
-** comparisons.
11410
-**
11411
-** Table.nCol is the number of columns in this table. Table.aCol is a
11412
-** pointer to an array of Column structures, one for each column.
11413
-**
11414
-** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
11415
-** the column that is that key. Otherwise Table.iPKey is negative. Note
11416
-** that the datatype of the PRIMARY KEY must be INTEGER for this field to
11417
-** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of
11418
-** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid
11419
-** is generated for each row of the table. TF_HasPrimaryKey is set if
11420
-** the table has any PRIMARY KEY, INTEGER or otherwise.
11421
-**
11422
-** Table.tnum is the page number for the root BTree page of the table in the
11423
-** database file. If Table.iDb is the index of the database table backend
11424
-** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
11425
-** holds temporary tables and indices. If TF_Ephemeral is set
11426
-** then the table is stored in a file that is automatically deleted
11427
-** when the VDBE cursor to the table is closed. In this case Table.tnum
11428
-** refers VDBE cursor number that holds the table open, not to the root
11429
-** page number. Transient tables are used to hold the results of a
11430
-** sub-query that appears instead of a real table name in the FROM clause
11431
-** of a SELECT statement.
11502
+** The schema for each SQL table and view is represented in memory
11503
+** by an instance of the following structure.
1143211504
*/
1143311505
struct Table {
1143411506
char *zName; /* Name of the table or view */
1143511507
Column *aCol; /* Information about each column */
1143611508
Index *pIndex; /* List of SQL indexes on this table. */
@@ -11438,15 +11510,15 @@
1143811510
FKey *pFKey; /* Linked list of all foreign keys in this table */
1143911511
char *zColAff; /* String defining the affinity of each column */
1144011512
#ifndef SQLITE_OMIT_CHECK
1144111513
ExprList *pCheck; /* All CHECK constraints */
1144211514
#endif
11443
- LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
11444
- int tnum; /* Root BTree node for this table (see note above) */
11445
- i16 iPKey; /* If not negative, use aCol[iPKey] as the primary key */
11515
+ int tnum; /* Root BTree page for this table */
11516
+ i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
1144611517
i16 nCol; /* Number of columns in this table */
1144711518
u16 nRef; /* Number of pointers to this Table */
11519
+ LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
1144811520
LogEst szTabRow; /* Estimated size of each table row in bytes */
1144911521
#ifdef SQLITE_ENABLE_COSTMULT
1145011522
LogEst costMult; /* Cost multiplier for using this table */
1145111523
#endif
1145211524
u8 tabFlags; /* Mask of TF_* values */
@@ -11464,17 +11536,24 @@
1146411536
Table *pNextZombie; /* Next on the Parse.pZombieTab list */
1146511537
};
1146611538
1146711539
/*
1146811540
** Allowed values for Table.tabFlags.
11541
+**
11542
+** TF_OOOHidden applies to virtual tables that have hidden columns that are
11543
+** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
11544
+** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
11545
+** the TF_OOOHidden attribute would apply in this case. Such tables require
11546
+** special handling during INSERT processing.
1146911547
*/
1147011548
#define TF_Readonly 0x01 /* Read-only system table */
1147111549
#define TF_Ephemeral 0x02 /* An ephemeral table */
1147211550
#define TF_HasPrimaryKey 0x04 /* Table has a primary key */
1147311551
#define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
1147411552
#define TF_Virtual 0x10 /* Is a virtual table */
1147511553
#define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */
11554
+#define TF_OOOHidden 0x40 /* Out-of-Order hidden columns */
1147611555
1147711556
1147811557
/*
1147911558
** Test to see whether or not a table is a virtual table. This is
1148011559
** done as a macro so that it will be optimized out when virtual
@@ -12227,15 +12306,16 @@
1222712306
#define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
1222812307
#define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
1222912308
#define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
1223012309
#define SF_Compound 0x0040 /* Part of a compound query */
1223112310
#define SF_Values 0x0080 /* Synthesized from VALUES clause */
12232
-#define SF_AllValues 0x0100 /* All terms of compound are VALUES */
12311
+#define SF_MultiValue 0x0100 /* Single VALUES term with multiple rows */
1223312312
#define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
1223412313
#define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
1223512314
#define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
1223612315
#define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
12316
+#define SF_Converted 0x2000 /* By convertCompoundSelectToSubquery() */
1223712317
1223812318
1223912319
/*
1224012320
** The results of a SELECT can be distributed in several ways, as defined
1224112321
** by one of the following macros. The "SRT" prefix means "SELECT Result
@@ -12610,24 +12690,24 @@
1261012690
*
1261112691
* (op == TK_INSERT)
1261212692
* orconf -> stores the ON CONFLICT algorithm
1261312693
* pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
1261412694
* this stores a pointer to the SELECT statement. Otherwise NULL.
12615
- * target -> A token holding the quoted name of the table to insert into.
12695
+ * zTarget -> Dequoted name of the table to insert into.
1261612696
* pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
1261712697
* this stores values to be inserted. Otherwise NULL.
1261812698
* pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
1261912699
* statement, then this stores the column-names to be
1262012700
* inserted into.
1262112701
*
1262212702
* (op == TK_DELETE)
12623
- * target -> A token holding the quoted name of the table to delete from.
12703
+ * zTarget -> Dequoted name of the table to delete from.
1262412704
* pWhere -> The WHERE clause of the DELETE statement if one is specified.
1262512705
* Otherwise NULL.
1262612706
*
1262712707
* (op == TK_UPDATE)
12628
- * target -> A token holding the quoted name of the table to update rows of.
12708
+ * zTarget -> Dequoted name of the table to update.
1262912709
* pWhere -> The WHERE clause of the UPDATE statement if one is specified.
1263012710
* Otherwise NULL.
1263112711
* pExprList -> A list of the columns to update and the expressions to update
1263212712
* them to. See sqlite3Update() documentation of "pChanges"
1263312713
* argument.
@@ -12635,12 +12715,12 @@
1263512715
*/
1263612716
struct TriggerStep {
1263712717
u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
1263812718
u8 orconf; /* OE_Rollback etc. */
1263912719
Trigger *pTrig; /* The trigger that this step is a part of */
12640
- Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
12641
- Token target; /* Target table for DELETE, UPDATE, INSERT */
12720
+ Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */
12721
+ char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
1264212722
Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
1264312723
ExprList *pExprList; /* SET clause for UPDATE. */
1264412724
IdList *pIdList; /* Column names for INSERT */
1264512725
TriggerStep *pNext; /* Next in the link-list */
1264612726
TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
@@ -12669,12 +12749,11 @@
1266912749
sqlite3 *db; /* Optional database for lookaside. Can be NULL */
1267012750
char *zBase; /* A base allocation. Not from malloc. */
1267112751
char *zText; /* The string collected so far */
1267212752
int nChar; /* Length of the string so far */
1267312753
int nAlloc; /* Amount of space allocated in zText */
12674
- int mxAlloc; /* Maximum allowed string length */
12675
- u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */
12754
+ int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */
1267612755
u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
1267712756
};
1267812757
#define STRACCUM_NOMEM 1
1267912758
#define STRACCUM_TOOBIG 2
1268012759
@@ -12987,11 +13066,11 @@
1298713066
SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
1298813067
SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
1298913068
SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
1299013069
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
1299113070
SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
12992
-#if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
13071
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
1299313072
SQLITE_PRIVATE void sqlite3DebugPrintf(const char*, ...);
1299413073
#endif
1299513074
#if defined(SQLITE_TEST)
1299613075
SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
1299713076
#endif
@@ -13334,11 +13413,11 @@
1333413413
SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
1333513414
SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
1333613415
SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
1333713416
SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
1333813417
13339
-#if defined(SQLITE_TEST)
13418
+#if defined(SQLITE_NEED_ERR_NAME)
1334013419
SQLITE_PRIVATE const char *sqlite3ErrName(int);
1334113420
#endif
1334213421
1334313422
SQLITE_PRIVATE const char *sqlite3ErrStr(int);
1334413423
SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -13428,11 +13507,11 @@
1342813507
FuncDestructor *pDestructor
1342913508
);
1343013509
SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
1343113510
SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
1343213511
13433
-SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, char*, int, int);
13512
+SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
1343413513
SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
1343513514
SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
1343613515
SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
1343713516
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
1343813517
SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
@@ -13646,11 +13725,11 @@
1364613725
** print I/O tracing messages.
1364713726
*/
1364813727
#ifdef SQLITE_ENABLE_IOTRACE
1364913728
# define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
1365013729
SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13651
-void (*sqlite3IoTrace)(const char*,...);
13730
+SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
1365213731
#else
1365313732
# define IOTRACE(A)
1365413733
# define sqlite3VdbeIOTraceSql(X)
1365513734
#endif
1365613735
@@ -14044,10 +14123,13 @@
1404414123
#if SQLITE_ENABLE_CEROD
1404514124
"ENABLE_CEROD",
1404614125
#endif
1404714126
#if SQLITE_ENABLE_COLUMN_METADATA
1404814127
"ENABLE_COLUMN_METADATA",
14128
+#endif
14129
+#if SQLITE_ENABLE_DBSTAT_VTAB
14130
+ "ENABLE_DBSTAT_VTAB",
1404914131
#endif
1405014132
#if SQLITE_ENABLE_EXPENSIVE_ASSERT
1405114133
"ENABLE_EXPENSIVE_ASSERT",
1405214134
#endif
1405314135
#if SQLITE_ENABLE_FTS1
@@ -14359,11 +14441,11 @@
1435914441
** was used and false if not.
1436014442
**
1436114443
** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
1436214444
** is not required for a match.
1436314445
*/
14364
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
14446
+SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
1436514447
int i, n;
1436614448
1436714449
#if SQLITE_ENABLE_API_ARMOR
1436814450
if( zOptName==0 ){
1436914451
(void)SQLITE_MISUSE_BKPT;
@@ -14387,11 +14469,11 @@
1438714469
1438814470
/*
1438914471
** Return the N-th compile-time option string. If N is out of range,
1439014472
** return a NULL pointer.
1439114473
*/
14392
-SQLITE_API const char *sqlite3_compileoption_get(int N){
14474
+SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
1439314475
if( N>=0 && N<ArraySize(azCompileOpt) ){
1439414476
return azCompileOpt[N];
1439514477
}
1439614478
return 0;
1439714479
}
@@ -15024,11 +15106,11 @@
1502415106
}
1502515107
1502615108
/*
1502715109
** Query status information.
1502815110
*/
15029
-SQLITE_API int sqlite3_status64(
15111
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
1503015112
int op,
1503115113
sqlite3_int64 *pCurrent,
1503215114
sqlite3_int64 *pHighwater,
1503315115
int resetFlag
1503415116
){
@@ -15049,11 +15131,11 @@
1504915131
}
1505015132
sqlite3_mutex_leave(pMutex);
1505115133
(void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
1505215134
return SQLITE_OK;
1505315135
}
15054
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15136
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
1505515137
sqlite3_int64 iCur, iHwtr;
1505615138
int rc;
1505715139
#ifdef SQLITE_ENABLE_API_ARMOR
1505815140
if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
1505915141
#endif
@@ -15066,11 +15148,11 @@
1506615148
}
1506715149
1506815150
/*
1506915151
** Query status information for a single database connection
1507015152
*/
15071
-SQLITE_API int sqlite3_db_status(
15153
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(
1507215154
sqlite3 *db, /* The database connection whose status is desired */
1507315155
int op, /* Status verb */
1507415156
int *pCurrent, /* Write current value here */
1507515157
int *pHighwater, /* Write high-water mark here */
1507615158
int resetFlag /* Reset high-water mark if true */
@@ -16690,11 +16772,11 @@
1669016772
1669116773
/*
1669216774
** Locate a VFS by name. If no name is given, simply return the
1669316775
** first VFS on the list.
1669416776
*/
16695
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
16777
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){
1669616778
sqlite3_vfs *pVfs = 0;
1669716779
#if SQLITE_THREADSAFE
1669816780
sqlite3_mutex *mutex;
1669916781
#endif
1670016782
#ifndef SQLITE_OMIT_AUTOINIT
@@ -16736,11 +16818,11 @@
1673616818
/*
1673716819
** Register a VFS with the system. It is harmless to register the same
1673816820
** VFS multiple times. The new VFS becomes the default if makeDflt is
1673916821
** true.
1674016822
*/
16741
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16823
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
1674216824
MUTEX_LOGIC(sqlite3_mutex *mutex;)
1674316825
#ifndef SQLITE_OMIT_AUTOINIT
1674416826
int rc = sqlite3_initialize();
1674516827
if( rc ) return rc;
1674616828
#endif
@@ -16764,11 +16846,11 @@
1676416846
}
1676516847
1676616848
/*
1676716849
** Unregister a VFS so that it is no longer accessible.
1676816850
*/
16769
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16851
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
1677016852
#if SQLITE_THREADSAFE
1677116853
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
1677216854
#endif
1677316855
sqlite3_mutex_enter(mutex);
1677416856
vfsUnlink(pVfs);
@@ -19100,11 +19182,11 @@
1910019182
}
1910119183
1910219184
/*
1910319185
** Retrieve a pointer to a static mutex or allocate a new dynamic one.
1910419186
*/
19105
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){
19187
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){
1910619188
#ifndef SQLITE_OMIT_AUTOINIT
1910719189
if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
1910819190
if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
1910919191
#endif
1911019192
return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19119,31 +19201,31 @@
1911919201
}
1912019202
1912119203
/*
1912219204
** Free a dynamic mutex.
1912319205
*/
19124
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
19206
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
1912519207
if( p ){
1912619208
sqlite3GlobalConfig.mutex.xMutexFree(p);
1912719209
}
1912819210
}
1912919211
1913019212
/*
1913119213
** Obtain the mutex p. If some other thread already has the mutex, block
1913219214
** until it can be obtained.
1913319215
*/
19134
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
19216
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
1913519217
if( p ){
1913619218
sqlite3GlobalConfig.mutex.xMutexEnter(p);
1913719219
}
1913819220
}
1913919221
1914019222
/*
1914119223
** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
1914219224
** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
1914319225
*/
19144
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
19226
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
1914519227
int rc = SQLITE_OK;
1914619228
if( p ){
1914719229
return sqlite3GlobalConfig.mutex.xMutexTry(p);
1914819230
}
1914919231
return rc;
@@ -19153,11 +19235,11 @@
1915319235
** The sqlite3_mutex_leave() routine exits a mutex that was previously
1915419236
** entered by the same thread. The behavior is undefined if the mutex
1915519237
** is not currently entered. If a NULL pointer is passed as an argument
1915619238
** this function is a no-op.
1915719239
*/
19158
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
19240
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
1915919241
if( p ){
1916019242
sqlite3GlobalConfig.mutex.xMutexLeave(p);
1916119243
}
1916219244
}
1916319245
@@ -19164,14 +19246,14 @@
1916419246
#ifndef NDEBUG
1916519247
/*
1916619248
** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
1916719249
** intended for use inside assert() statements.
1916819250
*/
19169
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){
19251
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
1917019252
return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
1917119253
}
19172
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
19254
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
1917319255
return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
1917419256
}
1917519257
#endif
1917619258
1917719259
#endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -19812,20 +19894,10 @@
1981219894
*/
1981319895
#ifdef MEMORY_DEBUG
1981419896
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
1981519897
#endif
1981619898
19817
-#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
19818
-# ifndef SQLITE_DEBUG_OS_TRACE
19819
-# define SQLITE_DEBUG_OS_TRACE 0
19820
-# endif
19821
- int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
19822
-# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
19823
-#else
19824
-# define OSTRACE(X)
19825
-#endif
19826
-
1982719899
/*
1982819900
** Macros for performance tracing. Normally turned off. Only works
1982919901
** on i486 hardware.
1983019902
*/
1983119903
#ifdef SQLITE_PERFORMANCE_TRACE
@@ -20163,12 +20235,12 @@
2016320235
** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
2016420236
** "interlocked" magic used here is probably not strictly necessary.
2016520237
*/
2016620238
static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
2016720239
20168
-SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */
20169
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20240
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */
20241
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
2017020242
2017120243
static int winMutexInit(void){
2017220244
/* The first to increment to 1 does actual initialization */
2017320245
if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
2017420246
int i;
@@ -20460,11 +20532,11 @@
2046020532
/*
2046120533
** Attempt to release up to n bytes of non-essential memory currently
2046220534
** held by SQLite. An example of non-essential memory is memory used to
2046320535
** cache database pages that are not currently in use.
2046420536
*/
20465
-SQLITE_API int sqlite3_release_memory(int n){
20537
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){
2046620538
#ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
2046720539
return sqlite3PcacheReleaseMemory(n);
2046820540
#else
2046920541
/* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
2047020542
** is a no-op returning zero if SQLite is not compiled with
@@ -20560,11 +20632,11 @@
2056020632
#ifndef SQLITE_OMIT_DEPRECATED
2056120633
/*
2056220634
** Deprecated external interface. Internal/core SQLite code
2056320635
** should call sqlite3MemoryAlarm.
2056420636
*/
20565
-SQLITE_API int sqlite3_memory_alarm(
20637
+SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm(
2056620638
void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
2056720639
void *pArg,
2056820640
sqlite3_int64 iThreshold
2056920641
){
2057020642
return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20573,11 +20645,11 @@
2057320645
2057420646
/*
2057520647
** Set the soft heap-size limit for the library. Passing a zero or
2057620648
** negative value indicates no limit.
2057720649
*/
20578
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
20650
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
2057920651
sqlite3_int64 priorLimit;
2058020652
sqlite3_int64 excess;
2058120653
#ifndef SQLITE_OMIT_AUTOINIT
2058220654
int rc = sqlite3_initialize();
2058320655
if( rc ) return -1;
@@ -20593,19 +20665,20 @@
2059320665
}
2059420666
excess = sqlite3_memory_used() - n;
2059520667
if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
2059620668
return priorLimit;
2059720669
}
20598
-SQLITE_API void sqlite3_soft_heap_limit(int n){
20670
+SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
2059920671
if( n<0 ) n = 0;
2060020672
sqlite3_soft_heap_limit64(n);
2060120673
}
2060220674
2060320675
/*
2060420676
** Initialize the memory allocation subsystem.
2060520677
*/
2060620678
SQLITE_PRIVATE int sqlite3MallocInit(void){
20679
+ int rc;
2060720680
if( sqlite3GlobalConfig.m.xMalloc==0 ){
2060820681
sqlite3MemSetDefault();
2060920682
}
2061020683
memset(&mem0, 0, sizeof(mem0));
2061120684
if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20637,11 +20710,13 @@
2063720710
|| sqlite3GlobalConfig.nPage<1 ){
2063820711
sqlite3GlobalConfig.pPage = 0;
2063920712
sqlite3GlobalConfig.szPage = 0;
2064020713
sqlite3GlobalConfig.nPage = 0;
2064120714
}
20642
- return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20715
+ rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20716
+ if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
20717
+ return rc;
2064320718
}
2064420719
2064520720
/*
2064620721
** Return true if the heap is currently under memory pressure - in other
2064720722
** words if the amount of heap used is close to the limit set by
@@ -20662,11 +20737,11 @@
2066220737
}
2066320738
2066420739
/*
2066520740
** Return the amount of memory currently checked out.
2066620741
*/
20667
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
20742
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){
2066820743
int n, mx;
2066920744
sqlite3_int64 res;
2067020745
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
2067120746
res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
2067220747
return res;
@@ -20675,11 +20750,11 @@
2067520750
/*
2067620751
** Return the maximum amount of memory that has ever been
2067720752
** checked out since either the beginning of this process
2067820753
** or since the most recent reset.
2067920754
*/
20680
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
20755
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
2068120756
int n, mx;
2068220757
sqlite3_int64 res;
2068320758
sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
2068420759
res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
2068520760
return res;
@@ -20766,17 +20841,17 @@
2076620841
/*
2076720842
** This version of the memory allocation is for use by the application.
2076820843
** First make sure the memory subsystem is initialized, then do the
2076920844
** allocation.
2077020845
*/
20771
-SQLITE_API void *sqlite3_malloc(int n){
20846
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
2077220847
#ifndef SQLITE_OMIT_AUTOINIT
2077320848
if( sqlite3_initialize() ) return 0;
2077420849
#endif
2077520850
return n<=0 ? 0 : sqlite3Malloc(n);
2077620851
}
20777
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){
20852
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
2077820853
#ifndef SQLITE_OMIT_AUTOINIT
2077920854
if( sqlite3_initialize() ) return 0;
2078020855
#endif
2078120856
return sqlite3Malloc(n);
2078220857
}
@@ -20913,20 +20988,20 @@
2091320988
assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
2091420989
return sqlite3GlobalConfig.m.xSize(p);
2091520990
}
2091620991
}
2091720992
}
20918
-SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
20993
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){
2091920994
assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2092020995
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2092120996
return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
2092220997
}
2092320998
2092420999
/*
2092521000
** Free memory previously obtained from sqlite3Malloc().
2092621001
*/
20927
-SQLITE_API void sqlite3_free(void *p){
21002
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){
2092821003
if( p==0 ) return; /* IMP: R-49053-54554 */
2092921004
assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
2093021005
assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
2093121006
if( sqlite3GlobalConfig.bMemstat ){
2093221007
sqlite3_mutex_enter(mem0.mutex);
@@ -21031,18 +21106,18 @@
2103121106
2103221107
/*
2103321108
** The public interface to sqlite3Realloc. Make sure that the memory
2103421109
** subsystem is initialized prior to invoking sqliteRealloc.
2103521110
*/
21036
-SQLITE_API void *sqlite3_realloc(void *pOld, int n){
21111
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
2103721112
#ifndef SQLITE_OMIT_AUTOINIT
2103821113
if( sqlite3_initialize() ) return 0;
2103921114
#endif
2104021115
if( n<0 ) n = 0; /* IMP: R-26507-47431 */
2104121116
return sqlite3Realloc(pOld, n);
2104221117
}
21043
-SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
21118
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
2104421119
#ifndef SQLITE_OMIT_AUTOINIT
2104521120
if( sqlite3_initialize() ) return 0;
2104621121
#endif
2104721122
return sqlite3Realloc(pOld, n);
2104821123
}
@@ -21403,10 +21478,11 @@
2140321478
2140421479
/*
2140521480
** Set the StrAccum object to an error mode.
2140621481
*/
2140721482
static void setStrAccumError(StrAccum *p, u8 eError){
21483
+ assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );
2140821484
p->accError = eError;
2140921485
p->nAlloc = 0;
2141021486
}
2141121487
2141221488
/*
@@ -21517,45 +21593,52 @@
2151721593
case '0': flag_zeropad = 1; break;
2151821594
default: done = 1; break;
2151921595
}
2152021596
}while( !done && (c=(*++fmt))!=0 );
2152121597
/* Get the field width */
21522
- width = 0;
2152321598
if( c=='*' ){
2152421599
if( bArgList ){
2152521600
width = (int)getIntArg(pArgList);
2152621601
}else{
2152721602
width = va_arg(ap,int);
2152821603
}
2152921604
if( width<0 ){
2153021605
flag_leftjustify = 1;
21531
- width = -width;
21606
+ width = width >= -2147483647 ? -width : 0;
2153221607
}
2153321608
c = *++fmt;
2153421609
}else{
21610
+ unsigned wx = 0;
2153521611
while( c>='0' && c<='9' ){
21536
- width = width*10 + c - '0';
21612
+ wx = wx*10 + c - '0';
2153721613
c = *++fmt;
2153821614
}
21615
+ testcase( wx>0x7fffffff );
21616
+ width = wx & 0x7fffffff;
2153921617
}
21618
+
2154021619
/* Get the precision */
2154121620
if( c=='.' ){
21542
- precision = 0;
2154321621
c = *++fmt;
2154421622
if( c=='*' ){
2154521623
if( bArgList ){
2154621624
precision = (int)getIntArg(pArgList);
2154721625
}else{
2154821626
precision = va_arg(ap,int);
2154921627
}
21550
- if( precision<0 ) precision = -precision;
2155121628
c = *++fmt;
21629
+ if( precision<0 ){
21630
+ precision = precision >= -2147483647 ? -precision : -1;
21631
+ }
2155221632
}else{
21633
+ unsigned px = 0;
2155321634
while( c>='0' && c<='9' ){
21554
- precision = precision*10 + c - '0';
21635
+ px = px*10 + c - '0';
2155521636
c = *++fmt;
2155621637
}
21638
+ testcase( px>0x7fffffff );
21639
+ precision = px & 0x7fffffff;
2155721640
}
2155821641
}else{
2155921642
precision = -1;
2156021643
}
2156121644
/* Get the conversion type modifier */
@@ -21715,11 +21798,12 @@
2171521798
if( flag_plussign ) prefix = '+';
2171621799
else if( flag_blanksign ) prefix = ' ';
2171721800
else prefix = 0;
2171821801
}
2171921802
if( xtype==etGENERIC && precision>0 ) precision--;
21720
- for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
21803
+ testcase( precision>0xfff );
21804
+ for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
2172121805
if( xtype==etFLOAT ) realvalue += rounder;
2172221806
/* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
2172321807
exp = 0;
2172421808
if( sqlite3IsNaN((double)realvalue) ){
2172521809
bufpt = "NaN";
@@ -21770,12 +21854,13 @@
2177021854
if( xtype==etEXP ){
2177121855
e2 = 0;
2177221856
}else{
2177321857
e2 = exp;
2177421858
}
21775
- if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
21776
- bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
21859
+ if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
21860
+ bufpt = zExtra
21861
+ = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
2177721862
if( bufpt==0 ){
2177821863
setStrAccumError(pAccum, STRACCUM_NOMEM);
2177921864
return;
2178021865
}
2178121866
}
@@ -22003,17 +22088,17 @@
2200322088
** Return the number of bytes of text that StrAccum is able to accept
2200422089
** after the attempted enlargement. The value returned might be zero.
2200522090
*/
2200622091
static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
2200722092
char *zNew;
22008
- assert( p->nChar+N >= p->nAlloc ); /* Only called if really needed */
22093
+ assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
2200922094
if( p->accError ){
2201022095
testcase(p->accError==STRACCUM_TOOBIG);
2201122096
testcase(p->accError==STRACCUM_NOMEM);
2201222097
return 0;
2201322098
}
22014
- if( !p->useMalloc ){
22099
+ if( p->mxAlloc==0 ){
2201522100
N = p->nAlloc - p->nChar - 1;
2201622101
setStrAccumError(p, STRACCUM_TOOBIG);
2201722102
return N;
2201822103
}else{
2201922104
char *zOld = (p->zText==p->zBase ? 0 : p->zText);
@@ -22029,14 +22114,14 @@
2202922114
setStrAccumError(p, STRACCUM_TOOBIG);
2203022115
return 0;
2203122116
}else{
2203222117
p->nAlloc = (int)szNew;
2203322118
}
22034
- if( p->useMalloc==1 ){
22119
+ if( p->db ){
2203522120
zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
2203622121
}else{
22037
- zNew = sqlite3_realloc(zOld, p->nAlloc);
22122
+ zNew = sqlite3_realloc64(zOld, p->nAlloc);
2203822123
}
2203922124
if( zNew ){
2204022125
assert( p->zText!=0 || p->nChar==0 );
2204122126
if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
2204222127
p->zText = zNew;
@@ -22052,11 +22137,14 @@
2205222137
2205322138
/*
2205422139
** Append N copies of character c to the given string buffer.
2205522140
*/
2205622141
SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
22057
- if( p->nChar+N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ) return;
22142
+ testcase( p->nChar + (i64)N > 0x7fffffff );
22143
+ if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
22144
+ return;
22145
+ }
2205822146
while( (N--)>0 ) p->zText[p->nChar++] = c;
2205922147
}
2206022148
2206122149
/*
2206222150
** The StrAccum "p" is not large enough to accept N new bytes of z[].
@@ -22077,11 +22165,11 @@
2207722165
/*
2207822166
** Append N bytes of text from z to the StrAccum object. Increase the
2207922167
** size of the memory allocation for StrAccum if necessary.
2208022168
*/
2208122169
SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
22082
- assert( z!=0 );
22170
+ assert( z!=0 || N==0 );
2208322171
assert( p->zText!=0 || p->nChar==0 || p->accError );
2208422172
assert( N>=0 );
2208522173
assert( p->accError==0 || p->nAlloc==0 );
2208622174
if( p->nChar+N >= p->nAlloc ){
2208722175
enlargeAndAppend(p,z,N);
@@ -22106,16 +22194,12 @@
2210622194
** pointer if any kind of error was encountered.
2210722195
*/
2210822196
SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
2210922197
if( p->zText ){
2211022198
p->zText[p->nChar] = 0;
22111
- if( p->useMalloc && p->zText==p->zBase ){
22112
- if( p->useMalloc==1 ){
22113
- p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
22114
- }else{
22115
- p->zText = sqlite3_malloc(p->nChar+1);
22116
- }
22199
+ if( p->mxAlloc>0 && p->zText==p->zBase ){
22200
+ p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
2211722201
if( p->zText ){
2211822202
memcpy(p->zText, p->zBase, p->nChar+1);
2211922203
}else{
2212022204
setStrAccumError(p, STRACCUM_NOMEM);
2212122205
}
@@ -22127,29 +22211,35 @@
2212722211
/*
2212822212
** Reset an StrAccum string. Reclaim all malloced memory.
2212922213
*/
2213022214
SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
2213122215
if( p->zText!=p->zBase ){
22132
- if( p->useMalloc==1 ){
22133
- sqlite3DbFree(p->db, p->zText);
22134
- }else{
22135
- sqlite3_free(p->zText);
22136
- }
22216
+ sqlite3DbFree(p->db, p->zText);
2213722217
}
2213822218
p->zText = 0;
2213922219
}
2214022220
2214122221
/*
22142
-** Initialize a string accumulator
22222
+** Initialize a string accumulator.
22223
+**
22224
+** p: The accumulator to be initialized.
22225
+** db: Pointer to a database connection. May be NULL. Lookaside
22226
+** memory is used if not NULL. db->mallocFailed is set appropriately
22227
+** when not NULL.
22228
+** zBase: An initial buffer. May be NULL in which case the initial buffer
22229
+** is malloced.
22230
+** n: Size of zBase in bytes. If total space requirements never exceed
22231
+** n then no memory allocations ever occur.
22232
+** mx: Maximum number of bytes to accumulate. If mx==0 then no memory
22233
+** allocations will ever occur.
2214322234
*/
22144
-SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
22235
+SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){
2214522236
p->zText = p->zBase = zBase;
22146
- p->db = 0;
22237
+ p->db = db;
2214722238
p->nChar = 0;
2214822239
p->nAlloc = n;
2214922240
p->mxAlloc = mx;
22150
- p->useMalloc = 1;
2215122241
p->accError = 0;
2215222242
}
2215322243
2215422244
/*
2215522245
** Print into memory obtained from sqliteMalloc(). Use the internal
@@ -22158,13 +22248,12 @@
2215822248
SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
2215922249
char *z;
2216022250
char zBase[SQLITE_PRINT_BUF_SIZE];
2216122251
StrAccum acc;
2216222252
assert( db!=0 );
22163
- sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
22253
+ sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),
2216422254
db->aLimit[SQLITE_LIMIT_LENGTH]);
22165
- acc.db = db;
2216622255
sqlite3VXPrintf(&acc, SQLITE_PRINTF_INTERNAL, zFormat, ap);
2216722256
z = sqlite3StrAccumFinish(&acc);
2216822257
if( acc.accError==STRACCUM_NOMEM ){
2216922258
db->mallocFailed = 1;
2217022259
}
@@ -22204,11 +22293,11 @@
2220422293
2220522294
/*
2220622295
** Print into memory obtained from sqlite3_malloc(). Omit the internal
2220722296
** %-conversion extensions.
2220822297
*/
22209
-SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
22298
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){
2221022299
char *z;
2221122300
char zBase[SQLITE_PRINT_BUF_SIZE];
2221222301
StrAccum acc;
2221322302
2221422303
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -22218,22 +22307,21 @@
2221822307
}
2221922308
#endif
2222022309
#ifndef SQLITE_OMIT_AUTOINIT
2222122310
if( sqlite3_initialize() ) return 0;
2222222311
#endif
22223
- sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
22224
- acc.useMalloc = 2;
22312
+ sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
2222522313
sqlite3VXPrintf(&acc, 0, zFormat, ap);
2222622314
z = sqlite3StrAccumFinish(&acc);
2222722315
return z;
2222822316
}
2222922317
2223022318
/*
2223122319
** Print into memory obtained from sqlite3_malloc()(). Omit the internal
2223222320
** %-conversion extensions.
2223322321
*/
22234
-SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
22322
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
2223522323
va_list ap;
2223622324
char *z;
2223722325
#ifndef SQLITE_OMIT_AUTOINIT
2223822326
if( sqlite3_initialize() ) return 0;
2223922327
#endif
@@ -22254,26 +22342,25 @@
2225422342
** this without breaking compatibility, so we just have to live with the
2225522343
** mistake.
2225622344
**
2225722345
** sqlite3_vsnprintf() is the varargs version.
2225822346
*/
22259
-SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22347
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
2226022348
StrAccum acc;
2226122349
if( n<=0 ) return zBuf;
2226222350
#ifdef SQLITE_ENABLE_API_ARMOR
2226322351
if( zBuf==0 || zFormat==0 ) {
2226422352
(void)SQLITE_MISUSE_BKPT;
2226522353
if( zBuf ) zBuf[0] = 0;
2226622354
return zBuf;
2226722355
}
2226822356
#endif
22269
- sqlite3StrAccumInit(&acc, zBuf, n, 0);
22270
- acc.useMalloc = 0;
22357
+ sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);
2227122358
sqlite3VXPrintf(&acc, 0, zFormat, ap);
2227222359
return sqlite3StrAccumFinish(&acc);
2227322360
}
22274
-SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22361
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
2227522362
char *z;
2227622363
va_list ap;
2227722364
va_start(ap,zFormat);
2227822365
z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
2227922366
va_end(ap);
@@ -22291,41 +22378,39 @@
2229122378
*/
2229222379
static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
2229322380
StrAccum acc; /* String accumulator */
2229422381
char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
2229522382
22296
- sqlite3StrAccumInit(&acc, zMsg, sizeof(zMsg), 0);
22297
- acc.useMalloc = 0;
22383
+ sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);
2229822384
sqlite3VXPrintf(&acc, 0, zFormat, ap);
2229922385
sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,
2230022386
sqlite3StrAccumFinish(&acc));
2230122387
}
2230222388
2230322389
/*
2230422390
** Format and write a message to the log if logging is enabled.
2230522391
*/
22306
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){
22392
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
2230722393
va_list ap; /* Vararg list */
2230822394
if( sqlite3GlobalConfig.xLog ){
2230922395
va_start(ap, zFormat);
2231022396
renderLogMsg(iErrCode, zFormat, ap);
2231122397
va_end(ap);
2231222398
}
2231322399
}
2231422400
22315
-#if defined(SQLITE_DEBUG)
22401
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
2231622402
/*
2231722403
** A version of printf() that understands %lld. Used for debugging.
2231822404
** The printf() built into some versions of windows does not understand %lld
2231922405
** and segfaults if you give it a long long int.
2232022406
*/
2232122407
SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
2232222408
va_list ap;
2232322409
StrAccum acc;
2232422410
char zBuf[500];
22325
- sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
22326
- acc.useMalloc = 0;
22411
+ sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
2232722412
va_start(ap,zFormat);
2232822413
sqlite3VXPrintf(&acc, 0, zFormat, ap);
2232922414
va_end(ap);
2233022415
sqlite3StrAccumFinish(&acc);
2233122416
fprintf(stdout,"%s", zBuf);
@@ -22348,11 +22433,11 @@
2234822433
*/
2234922434
/* Add a new subitem to the tree. The moreToFollow flag indicates that this
2235022435
** is not the last item in the tree. */
2235122436
SQLITE_PRIVATE TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){
2235222437
if( p==0 ){
22353
- p = sqlite3_malloc( sizeof(*p) );
22438
+ p = sqlite3_malloc64( sizeof(*p) );
2235422439
if( p==0 ) return 0;
2235522440
memset(p, 0, sizeof(*p));
2235622441
}else{
2235722442
p->iLevel++;
2235822443
}
@@ -22371,12 +22456,11 @@
2237122456
SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
2237222457
va_list ap;
2237322458
int i;
2237422459
StrAccum acc;
2237522460
char zBuf[500];
22376
- sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
22377
- acc.useMalloc = 0;
22461
+ sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
2237822462
if( p ){
2237922463
for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
2238022464
sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4);
2238122465
}
2238222466
sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
@@ -22437,11 +22521,11 @@
2243722521
} sqlite3Prng;
2243822522
2243922523
/*
2244022524
** Return N random bytes.
2244122525
*/
22442
-SQLITE_API void sqlite3_randomness(int N, void *pBuf){
22526
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
2244322527
unsigned char t;
2244422528
unsigned char *zBuf = pBuf;
2244522529
2244622530
/* The "wsdPrng" macro will resolve to the pseudo-random number generator
2244722531
** state vector. If writable static data is unsupported on the target,
@@ -23589,11 +23673,11 @@
2358923673
** sqlite3_strnicmp() APIs allow applications and extensions to compare
2359023674
** the contents of two buffers containing UTF-8 strings in a
2359123675
** case-independent fashion, using the same definition of "case
2359223676
** independence" that SQLite uses internally when comparing identifiers.
2359323677
*/
23594
-SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
23678
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
2359523679
register unsigned char *a, *b;
2359623680
if( zLeft==0 ){
2359723681
return zRight ? -1 : 0;
2359823682
}else if( zRight==0 ){
2359923683
return 1;
@@ -23601,11 +23685,11 @@
2360123685
a = (unsigned char *)zLeft;
2360223686
b = (unsigned char *)zRight;
2360323687
while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
2360423688
return UpperToLower[*a] - UpperToLower[*b];
2360523689
}
23606
-SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23690
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
2360723691
register unsigned char *a, *b;
2360823692
if( zLeft==0 ){
2360923693
return zRight ? -1 : 0;
2361023694
}else if( zRight==0 ){
2361123695
return 1;
@@ -23995,10 +24079,11 @@
2399524079
}else{
2399624080
return 0;
2399724081
}
2399824082
}
2399924083
#endif
24084
+ while( zNum[0]=='0' ) zNum++;
2400024085
for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){
2400124086
v = v*10 + c;
2400224087
}
2400324088
2400424089
/* The longest decimal representation of a 32 bit integer is 10 digits:
@@ -25249,10 +25334,21 @@
2524925334
#if SQLITE_ENABLE_LOCKING_STYLE
2525025335
# include <sys/ioctl.h>
2525125336
# include <sys/file.h>
2525225337
# include <sys/param.h>
2525325338
#endif /* SQLITE_ENABLE_LOCKING_STYLE */
25339
+
25340
+#if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
25341
+ (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
25342
+# if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \
25343
+ && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))
25344
+# define HAVE_GETHOSTUUID 1
25345
+# else
25346
+# warning "gethostuuid() is disabled."
25347
+# endif
25348
+#endif
25349
+
2525425350
2525525351
#if OS_VXWORKS
2525625352
/* # include <sys/ioctl.h> */
2525725353
# include <semaphore.h>
2525825354
# include <limits.h>
@@ -25445,20 +25541,10 @@
2544525541
*/
2544625542
#ifdef MEMORY_DEBUG
2544725543
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
2544825544
#endif
2544925545
25450
-#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
25451
-# ifndef SQLITE_DEBUG_OS_TRACE
25452
-# define SQLITE_DEBUG_OS_TRACE 0
25453
-# endif
25454
- int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
25455
-# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
25456
-#else
25457
-# define OSTRACE(X)
25458
-#endif
25459
-
2546025546
/*
2546125547
** Macros for performance tracing. Normally turned off. Only works
2546225548
** on i486 hardware.
2546325549
*/
2546425550
#ifdef SQLITE_PERFORMANCE_TRACE
@@ -25997,11 +26083,11 @@
2599726083
return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
2599826084
}
2599926085
#endif
2600026086
2600126087
26002
-#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
26088
+#ifdef SQLITE_HAVE_OS_TRACE
2600326089
/*
2600426090
** Helper function for printing out trace information from debugging
2600526091
** binaries. This returns the string representation of the supplied
2600626092
** integer lock-type.
2600726093
*/
@@ -26260,11 +26346,11 @@
2626026346
struct vxworksFileId *pCandidate; /* For looping over existing file IDs */
2626126347
int n; /* Length of zAbsoluteName string */
2626226348
2626326349
assert( zAbsoluteName[0]=='/' );
2626426350
n = (int)strlen(zAbsoluteName);
26265
- pNew = sqlite3_malloc( sizeof(*pNew) + (n+1) );
26351
+ pNew = sqlite3_malloc64( sizeof(*pNew) + (n+1) );
2626626352
if( pNew==0 ) return 0;
2626726353
pNew->zCanonicalName = (char*)&pNew[1];
2626826354
memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);
2626926355
n = vxworksSimplifyName(pNew->zCanonicalName, n);
2627026356
@@ -26664,11 +26750,11 @@
2666426750
pInode = inodeList;
2666526751
while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
2666626752
pInode = pInode->pNext;
2666726753
}
2666826754
if( pInode==0 ){
26669
- pInode = sqlite3_malloc( sizeof(*pInode) );
26755
+ pInode = sqlite3_malloc64( sizeof(*pInode) );
2667026756
if( pInode==0 ){
2667126757
return SQLITE_NOMEM;
2667226758
}
2667326759
memset(pInode, 0, sizeof(*pInode));
2667426760
memcpy(&pInode->fileId, &fileId, sizeof(fileId));
@@ -29150,11 +29236,11 @@
2915029236
*/
2915129237
static int unixFileControl(sqlite3_file *id, int op, void *pArg){
2915229238
unixFile *pFile = (unixFile*)id;
2915329239
switch( op ){
2915429240
case SQLITE_FCNTL_WAL_BLOCK: {
29155
- pFile->ctrlFlags |= UNIXFILE_BLOCK;
29241
+ /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */
2915629242
return SQLITE_OK;
2915729243
}
2915829244
case SQLITE_FCNTL_LOCKSTATE: {
2915929245
*(int*)pArg = pFile->eFileLock;
2916029246
return SQLITE_OK;
@@ -29185,11 +29271,11 @@
2918529271
case SQLITE_FCNTL_VFSNAME: {
2918629272
*(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
2918729273
return SQLITE_OK;
2918829274
}
2918929275
case SQLITE_FCNTL_TEMPFILENAME: {
29190
- char *zTFile = sqlite3_malloc( pFile->pVfs->mxPathname );
29276
+ char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );
2919129277
if( zTFile ){
2919229278
unixGetTempname(pFile->pVfs->mxPathname, zTFile);
2919329279
*(char**)pArg = zTFile;
2919429280
}
2919529281
return SQLITE_OK;
@@ -29626,11 +29712,11 @@
2962629712
unixInodeInfo *pInode; /* The inode of fd */
2962729713
char *zShmFilename; /* Name of the file used for SHM */
2962829714
int nShmFilename; /* Size of the SHM filename in bytes */
2962929715
2963029716
/* Allocate space for the new unixShm object. */
29631
- p = sqlite3_malloc( sizeof(*p) );
29717
+ p = sqlite3_malloc64( sizeof(*p) );
2963229718
if( p==0 ) return SQLITE_NOMEM;
2963329719
memset(p, 0, sizeof(*p));
2963429720
assert( pDbFd->pShm==0 );
2963529721
2963629722
/* Check to see if a unixShmNode object already exists. Reuse an existing
@@ -29657,11 +29743,11 @@
2965729743
#ifdef SQLITE_SHM_DIRECTORY
2965829744
nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
2965929745
#else
2966029746
nShmFilename = 6 + (int)strlen(zBasePath);
2966129747
#endif
29662
- pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
29748
+ pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename );
2966329749
if( pShmNode==0 ){
2966429750
rc = SQLITE_NOMEM;
2966529751
goto shm_open_err;
2966629752
}
2966729753
memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);
@@ -29867,11 +29953,11 @@
2986729953
if( pMem==MAP_FAILED ){
2986829954
rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
2986929955
goto shmpage_out;
2987029956
}
2987129957
}else{
29872
- pMem = sqlite3_malloc(szRegion);
29958
+ pMem = sqlite3_malloc64(szRegion);
2987329959
if( pMem==0 ){
2987429960
rc = SQLITE_NOMEM;
2987529961
goto shmpage_out;
2987629962
}
2987729963
memset(pMem, 0, szRegion);
@@ -30704,11 +30790,11 @@
3070430790
else if( pLockingStyle == &afpIoMethods ){
3070530791
/* AFP locking uses the file path so it needs to be included in
3070630792
** the afpLockingContext.
3070730793
*/
3070830794
afpLockingContext *pCtx;
30709
- pNew->lockingContext = pCtx = sqlite3_malloc( sizeof(*pCtx) );
30795
+ pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) );
3071030796
if( pCtx==0 ){
3071130797
rc = SQLITE_NOMEM;
3071230798
}else{
3071330799
/* NB: zFilename exists and remains valid until the file is closed
3071430800
** according to requirement F11141. So we do not need to make a
@@ -30734,11 +30820,11 @@
3073430820
*/
3073530821
char *zLockFile;
3073630822
int nFilename;
3073730823
assert( zFilename!=0 );
3073830824
nFilename = (int)strlen(zFilename) + 6;
30739
- zLockFile = (char *)sqlite3_malloc(nFilename);
30825
+ zLockFile = (char *)sqlite3_malloc64(nFilename);
3074030826
if( zLockFile==0 ){
3074130827
rc = SQLITE_NOMEM;
3074230828
}else{
3074330829
sqlite3_snprintf(nFilename, zLockFile, "%s" DOTLOCK_SUFFIX, zFilename);
3074430830
}
@@ -31111,11 +31197,11 @@
3111131197
UnixUnusedFd *pUnused;
3111231198
pUnused = findReusableFd(zName, flags);
3111331199
if( pUnused ){
3111431200
fd = pUnused->fd;
3111531201
}else{
31116
- pUnused = sqlite3_malloc(sizeof(*pUnused));
31202
+ pUnused = sqlite3_malloc64(sizeof(*pUnused));
3111731203
if( !pUnused ){
3111831204
return SQLITE_NOMEM;
3111931205
}
3112031206
}
3112131207
p->pUnused = pUnused;
@@ -31491,11 +31577,11 @@
3149131577
** that we always use the same random number sequence. This makes the
3149231578
** tests repeatable.
3149331579
*/
3149431580
memset(zBuf, 0, nBuf);
3149531581
randomnessPid = osGetpid(0);
31496
-#if !defined(SQLITE_TEST)
31582
+#if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)
3149731583
{
3149831584
int fd, got;
3149931585
fd = robust_open("/dev/urandom", O_RDONLY, 0);
3150031586
if( fd<0 ){
3150131587
time_t t;
@@ -31903,11 +31989,11 @@
3190331989
*/
3190431990
pUnused = findReusableFd(path, openFlags);
3190531991
if( pUnused ){
3190631992
fd = pUnused->fd;
3190731993
}else{
31908
- pUnused = sqlite3_malloc(sizeof(*pUnused));
31994
+ pUnused = sqlite3_malloc64(sizeof(*pUnused));
3190931995
if( !pUnused ){
3191031996
return SQLITE_NOMEM;
3191131997
}
3191231998
}
3191331999
if( fd<0 ){
@@ -31936,11 +32022,11 @@
3193632022
default:
3193732023
return SQLITE_CANTOPEN_BKPT;
3193832024
}
3193932025
}
3194032026
31941
- pNew = (unixFile *)sqlite3_malloc(sizeof(*pNew));
32027
+ pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew));
3194232028
if( pNew==NULL ){
3194332029
rc = SQLITE_NOMEM;
3194432030
goto end_create_proxy;
3194532031
}
3194632032
memset(pNew, 0, sizeof(unixFile));
@@ -31969,21 +32055,22 @@
3196932055
SQLITE_API int sqlite3_hostid_num = 0;
3197032056
#endif
3197132057
3197232058
#define PROXY_HOSTIDLEN 16 /* conch file host id length */
3197332059
32060
+#ifdef HAVE_GETHOSTUUID
3197432061
/* Not always defined in the headers as it ought to be */
3197532062
extern int gethostuuid(uuid_t id, const struct timespec *wait);
32063
+#endif
3197632064
3197732065
/* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN
3197832066
** bytes of writable memory.
3197932067
*/
3198032068
static int proxyGetHostID(unsigned char *pHostID, int *pError){
3198132069
assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
3198232070
memset(pHostID, 0, PROXY_HOSTIDLEN);
31983
-# if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
31984
- (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
32071
+#ifdef HAVE_GETHOSTUUID
3198532072
{
3198632073
struct timespec timeout = {1, 0}; /* 1 sec timeout */
3198732074
if( gethostuuid(pHostID, &timeout) ){
3198832075
int err = errno;
3198932076
if( pError ){
@@ -32397,11 +32484,11 @@
3239732484
return rc;
3239832485
}
3239932486
3240032487
/*
3240132488
** Given the name of a database file, compute the name of its conch file.
32402
-** Store the conch filename in memory obtained from sqlite3_malloc().
32489
+** Store the conch filename in memory obtained from sqlite3_malloc64().
3240332490
** Make *pConchPath point to the new name. Return SQLITE_OK on success
3240432491
** or SQLITE_NOMEM if unable to obtain memory.
3240532492
**
3240632493
** The caller is responsible for ensuring that the allocated memory
3240732494
** space is eventually freed.
@@ -32413,11 +32500,11 @@
3241332500
int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
3241432501
char *conchPath; /* buffer in which to construct conch name */
3241532502
3241632503
/* Allocate space for the conch filename and initialize the name to
3241732504
** the name of the original database file. */
32418
- *pConchPath = conchPath = (char *)sqlite3_malloc(len + 8);
32505
+ *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8);
3241932506
if( conchPath==0 ){
3242032507
return SQLITE_NOMEM;
3242132508
}
3242232509
memcpy(conchPath, dbPath, len+1);
3242332510
@@ -32529,11 +32616,11 @@
3252932616
}
3253032617
3253132618
OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
3253232619
(lockPath ? lockPath : ":auto:"), osGetpid(0)));
3253332620
32534
- pCtx = sqlite3_malloc( sizeof(*pCtx) );
32621
+ pCtx = sqlite3_malloc64( sizeof(*pCtx) );
3253532622
if( pCtx==0 ){
3253632623
return SQLITE_NOMEM;
3253732624
}
3253832625
memset(pCtx, 0, sizeof(*pCtx));
3253932626
@@ -32814,11 +32901,11 @@
3281432901
** This routine is called once during SQLite initialization and by a
3281532902
** single thread. The memory allocation and mutex subsystems have not
3281632903
** necessarily been initialized when this routine is called, and so they
3281732904
** should not be used.
3281832905
*/
32819
-SQLITE_API int sqlite3_os_init(void){
32906
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
3282032907
/*
3282132908
** The following macro defines an initializer for an sqlite3_vfs object.
3282232909
** The name of the VFS is NAME. The pAppData is a pointer to a pointer
3282332910
** to the "finder" function. (pAppData is a pointer to a pointer because
3282432911
** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32913,11 +33000,11 @@
3291333000
**
3291433001
** Some operating systems might need to do some cleanup in this routine,
3291533002
** to release dynamically allocated objects. But not on unix.
3291633003
** This routine is a no-op for unix.
3291733004
*/
32918
-SQLITE_API int sqlite3_os_end(void){
33005
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
3291933006
return SQLITE_OK;
3292033007
}
3292133008
3292233009
#endif /* SQLITE_OS_UNIX */
3292333010
@@ -32973,20 +33060,10 @@
3297333060
*/
3297433061
#ifdef MEMORY_DEBUG
3297533062
# error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
3297633063
#endif
3297733064
32978
-#if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
32979
-# ifndef SQLITE_DEBUG_OS_TRACE
32980
-# define SQLITE_DEBUG_OS_TRACE 0
32981
-# endif
32982
- int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
32983
-# define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
32984
-#else
32985
-# define OSTRACE(X)
32986
-#endif
32987
-
3298833065
/*
3298933066
** Macros for performance tracing. Normally turned off. Only works
3299033067
** on i486 hardware.
3299133068
*/
3299233069
#ifdef SQLITE_PERFORMANCE_TRACE
@@ -33326,12 +33403,14 @@
3332633403
3332733404
WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
3332833405
#endif /* SQLITE_OS_WINRT */
3332933406
3333033407
/*
33331
-** This file mapping API is common to both Win32 and WinRT.
33408
+** These file mapping APIs are common to both Win32 and WinRT.
3333233409
*/
33410
+
33411
+WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);
3333333412
WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
3333433413
#endif /* SQLITE_WIN32_FILEMAPPING_API */
3333533414
3333633415
/*
3333733416
** Some Microsoft compilers lack this definition.
@@ -34212,10 +34291,19 @@
3421234291
#endif
3421334292
3421434293
#define osUuidCreateSequential \
3421534294
((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)
3421634295
34296
+#if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0
34297
+ { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 },
34298
+#else
34299
+ { "FlushViewOfFile", (SYSCALL)0, 0 },
34300
+#endif
34301
+
34302
+#define osFlushViewOfFile \
34303
+ ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)
34304
+
3421734305
}; /* End of the overrideable system calls */
3421834306
3421934307
/*
3422034308
** This is the xSetSystemCall() method of sqlite3_vfs for all of the
3422134309
** "win32" VFSes. Return SQLITE_OK opon successfully updating the
@@ -34305,11 +34393,11 @@
3430534393
** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
3430634394
** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
3430734395
** "pnLargest" argument, if non-zero, will be used to return the size of the
3430834396
** largest committed free block in the heap, in bytes.
3430934397
*/
34310
-SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
34398
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
3431134399
int rc = SQLITE_OK;
3431234400
UINT nLargest = 0;
3431334401
HANDLE hHeap;
3431434402
3431534403
winMemAssertMagic();
@@ -34345,11 +34433,11 @@
3434534433
** If a Win32 native heap has been configured, this function will attempt to
3434634434
** destroy and recreate it. If the Win32 native heap is not isolated and/or
3434734435
** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
3434834436
** be returned and no changes will be made to the Win32 native heap.
3434934437
*/
34350
-SQLITE_API int sqlite3_win32_reset_heap(){
34438
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){
3435134439
int rc;
3435234440
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
3435334441
MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
3435434442
MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
3435534443
MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34390,11 +34478,11 @@
3439034478
/*
3439134479
** This function outputs the specified (ANSI) string to the Win32 debugger
3439234480
** (if available).
3439334481
*/
3439434482
34395
-SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34483
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
3439634484
char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
3439734485
int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
3439834486
if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
3439934487
assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
3440034488
#if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34430,11 +34518,11 @@
3443034518
*/
3443134519
#if SQLITE_OS_WINRT
3443234520
static HANDLE sleepObj = NULL;
3443334521
#endif
3443434522
34435
-SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
34523
+SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
3443634524
#if SQLITE_OS_WINRT
3443734525
if ( sleepObj==NULL ){
3443834526
sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
3443934527
SYNCHRONIZE);
3444034528
}
@@ -34479,11 +34567,11 @@
3447934567
3448034568
/*
3448134569
** This function determines if the machine is running a version of Windows
3448234570
** based on the NT kernel.
3448334571
*/
34484
-SQLITE_API int sqlite3_win32_is_nt(void){
34572
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){
3448534573
#if SQLITE_OS_WINRT
3448634574
/*
3448734575
** NOTE: The WinRT sub-platform is always assumed to be based on the NT
3448834576
** kernel.
3448934577
*/
@@ -34833,11 +34921,11 @@
3483334921
3483434922
/*
3483534923
** Convert multibyte character string to UTF-8. Space to hold the
3483634924
** returned string is obtained from sqlite3_malloc().
3483734925
*/
34838
-SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34926
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){
3483934927
char *zFilenameUtf8;
3484034928
LPWSTR zTmpWide;
3484134929
3484234930
zTmpWide = winMbcsToUnicode(zFilename);
3484334931
if( zTmpWide==0 ){
@@ -34850,11 +34938,11 @@
3485034938
3485134939
/*
3485234940
** Convert UTF-8 to multibyte character string. Space to hold the
3485334941
** returned string is obtained from sqlite3_malloc().
3485434942
*/
34855
-SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34943
+SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){
3485634944
char *zFilenameMbcs;
3485734945
LPWSTR zTmpWide;
3485834946
3485934947
zTmpWide = winUtf8ToUnicode(zFilename);
3486034948
if( zTmpWide==0 ){
@@ -34870,11 +34958,11 @@
3487034958
** the provided arguments. The type argument must be 1 in order to set the
3487134959
** data directory or 2 in order to set the temporary directory. The zValue
3487234960
** argument is the name of the directory to use. The return value will be
3487334961
** SQLITE_OK if successful.
3487434962
*/
34875
-SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34963
+SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
3487634964
char **ppDirectory = 0;
3487734965
#ifndef SQLITE_OMIT_AUTOINIT
3487834966
int rc = sqlite3_initialize();
3487934967
if( rc ) return rc;
3488034968
#endif
@@ -35095,15 +35183,15 @@
3509535183
}
3509635184
3509735185
/*
3509835186
** Log a I/O error retry episode.
3509935187
*/
35100
-static void winLogIoerr(int nRetry){
35188
+static void winLogIoerr(int nRetry, int lineno){
3510135189
if( nRetry ){
35102
- sqlite3_log(SQLITE_IOERR,
35103
- "delayed %dms for lock/sharing conflict",
35104
- winIoerrRetryDelay*nRetry*(nRetry+1)/2
35190
+ sqlite3_log(SQLITE_NOTICE,
35191
+ "delayed %dms for lock/sharing conflict at line %d",
35192
+ winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
3510535193
);
3510635194
}
3510735195
}
3510835196
3510935197
#if SQLITE_OS_WINCE
@@ -35579,11 +35667,12 @@
3557935667
assert( id!=0 );
3558035668
#ifndef SQLITE_OMIT_WAL
3558135669
assert( pFile->pShm==0 );
3558235670
#endif
3558335671
assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35584
- OSTRACE(("CLOSE file=%p\n", pFile->h));
35672
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
35673
+ osGetCurrentProcessId(), pFile, pFile->h));
3558535674
3558635675
#if SQLITE_MAX_MMAP_SIZE>0
3558735676
winUnmapfile(pFile);
3558835677
#endif
3558935678
@@ -35608,11 +35697,12 @@
3560835697
#endif
3560935698
if( rc ){
3561035699
pFile->h = NULL;
3561135700
}
3561235701
OpenCounter(-1);
35613
- OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
35702
+ OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35703
+ osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
3561435704
return rc ? SQLITE_OK
3561535705
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
3561635706
"winClose", pFile->zPath);
3561735707
}
3561835708
@@ -35636,20 +35726,22 @@
3563635726
3563735727
assert( id!=0 );
3563835728
assert( amt>0 );
3563935729
assert( offset>=0 );
3564035730
SimulateIOError(return SQLITE_IOERR_READ);
35641
- OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
35731
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35732
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
3564235733
pFile->h, pBuf, amt, offset, pFile->locktype));
3564335734
3564435735
#if SQLITE_MAX_MMAP_SIZE>0
3564535736
/* Deal with as much of this read request as possible by transfering
3564635737
** data from the memory mapping using memcpy(). */
3564735738
if( offset<pFile->mmapSize ){
3564835739
if( offset+amt <= pFile->mmapSize ){
3564935740
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
35650
- OSTRACE(("READ-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
35741
+ OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35742
+ osGetCurrentProcessId(), pFile, pFile->h));
3565135743
return SQLITE_OK;
3565235744
}else{
3565335745
int nCopy = (int)(pFile->mmapSize - offset);
3565435746
memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
3565535747
pBuf = &((u8 *)pBuf)[nCopy];
@@ -35659,11 +35751,12 @@
3565935751
}
3566035752
#endif
3566135753
3566235754
#if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
3566335755
if( winSeekFile(pFile, offset) ){
35664
- OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
35756
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35757
+ osGetCurrentProcessId(), pFile, pFile->h));
3566535758
return SQLITE_FULL;
3566635759
}
3566735760
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
3566835761
#else
3566935762
memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35673,23 +35766,26 @@
3567335766
osGetLastError()!=ERROR_HANDLE_EOF ){
3567435767
#endif
3567535768
DWORD lastErrno;
3567635769
if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
3567735770
pFile->lastErrno = lastErrno;
35678
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
35771
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
35772
+ osGetCurrentProcessId(), pFile, pFile->h));
3567935773
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
3568035774
"winRead", pFile->zPath);
3568135775
}
35682
- winLogIoerr(nRetry);
35776
+ winLogIoerr(nRetry, __LINE__);
3568335777
if( nRead<(DWORD)amt ){
3568435778
/* Unread parts of the buffer must be zero-filled */
3568535779
memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35686
- OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
35780
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
35781
+ osGetCurrentProcessId(), pFile, pFile->h));
3568735782
return SQLITE_IOERR_SHORT_READ;
3568835783
}
3568935784
35690
- OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
35785
+ OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35786
+ osGetCurrentProcessId(), pFile, pFile->h));
3569135787
return SQLITE_OK;
3569235788
}
3569335789
3569435790
/*
3569535791
** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35708,20 +35804,22 @@
3570835804
assert( amt>0 );
3570935805
assert( pFile );
3571035806
SimulateIOError(return SQLITE_IOERR_WRITE);
3571135807
SimulateDiskfullError(return SQLITE_FULL);
3571235808
35713
- OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
35809
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35810
+ "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
3571435811
pFile->h, pBuf, amt, offset, pFile->locktype));
3571535812
3571635813
#if SQLITE_MAX_MMAP_SIZE>0
3571735814
/* Deal with as much of this write request as possible by transfering
3571835815
** data from the memory mapping using memcpy(). */
3571935816
if( offset<pFile->mmapSize ){
3572035817
if( offset+amt <= pFile->mmapSize ){
3572135818
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35722
- OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
35819
+ OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35820
+ osGetCurrentProcessId(), pFile, pFile->h));
3572335821
return SQLITE_OK;
3572435822
}else{
3572535823
int nCopy = (int)(pFile->mmapSize - offset);
3572635824
memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
3572735825
pBuf = &((u8 *)pBuf)[nCopy];
@@ -35780,21 +35878,24 @@
3578035878
}
3578135879
3578235880
if( rc ){
3578335881
if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
3578435882
|| ( pFile->lastErrno==ERROR_DISK_FULL )){
35785
- OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
35883
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35884
+ osGetCurrentProcessId(), pFile, pFile->h));
3578635885
return winLogError(SQLITE_FULL, pFile->lastErrno,
3578735886
"winWrite1", pFile->zPath);
3578835887
}
35789
- OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
35888
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
35889
+ osGetCurrentProcessId(), pFile, pFile->h));
3579035890
return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
3579135891
"winWrite2", pFile->zPath);
3579235892
}else{
35793
- winLogIoerr(nRetry);
35893
+ winLogIoerr(nRetry, __LINE__);
3579435894
}
35795
- OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
35895
+ OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35896
+ osGetCurrentProcessId(), pFile, pFile->h));
3579635897
return SQLITE_OK;
3579735898
}
3579835899
3579935900
/*
3580035901
** Truncate an open file to a specified size
@@ -35804,12 +35905,12 @@
3580435905
int rc = SQLITE_OK; /* Return code for this function */
3580535906
DWORD lastErrno;
3580635907
3580735908
assert( pFile );
3580835909
SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35809
- OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
35810
- pFile->h, nByte, pFile->locktype));
35910
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
35911
+ osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
3581135912
3581235913
/* If the user has configured a chunk-size for this file, truncate the
3581335914
** file so that it consists of an integer number of chunks (i.e. the
3581435915
** actual file size after the operation may be larger than the requested
3581535916
** size).
@@ -35837,11 +35938,12 @@
3583735938
if( pFile->pMapRegion && nByte<pFile->mmapSize ){
3583835939
pFile->mmapSize = nByte;
3583935940
}
3584035941
#endif
3584135942
35842
- OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
35943
+ OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35944
+ osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
3584335945
return rc;
3584435946
}
3584535947
3584635948
#ifdef SQLITE_TEST
3584735949
/*
@@ -35861,11 +35963,11 @@
3586135963
** Used only when SQLITE_NO_SYNC is not defined.
3586235964
*/
3586335965
BOOL rc;
3586435966
#endif
3586535967
#if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \
35866
- (defined(SQLITE_TEST) && defined(SQLITE_DEBUG))
35968
+ defined(SQLITE_HAVE_OS_TRACE)
3586735969
/*
3586835970
** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or
3586935971
** OSTRACE() macros.
3587035972
*/
3587135973
winFile *pFile = (winFile*)id;
@@ -35882,12 +35984,13 @@
3588235984
/* Unix cannot, but some systems may return SQLITE_FULL from here. This
3588335985
** line is to test that doing so does not cause any problems.
3588435986
*/
3588535987
SimulateDiskfullError( return SQLITE_FULL );
3588635988
35887
- OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
35888
- pFile->h, flags, pFile->locktype));
35989
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
35990
+ osGetCurrentProcessId(), pFile, pFile->h, flags,
35991
+ pFile->locktype));
3588935992
3589035993
#ifndef SQLITE_TEST
3589135994
UNUSED_PARAMETER(flags);
3589235995
#else
3589335996
if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35898,23 +36001,42 @@
3589836001
3589936002
/* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
3590036003
** no-op
3590136004
*/
3590236005
#ifdef SQLITE_NO_SYNC
35903
- OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
36006
+ OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
36007
+ osGetCurrentProcessId(), pFile, pFile->h));
3590436008
return SQLITE_OK;
3590536009
#else
36010
+#if SQLITE_MAX_MMAP_SIZE>0
36011
+ if( pFile->pMapRegion ){
36012
+ if( osFlushViewOfFile(pFile->pMapRegion, 0) ){
36013
+ OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
36014
+ "rc=SQLITE_OK\n", osGetCurrentProcessId(),
36015
+ pFile, pFile->pMapRegion));
36016
+ }else{
36017
+ pFile->lastErrno = osGetLastError();
36018
+ OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
36019
+ "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(),
36020
+ pFile, pFile->pMapRegion));
36021
+ return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
36022
+ "winSync1", pFile->zPath);
36023
+ }
36024
+ }
36025
+#endif
3590636026
rc = osFlushFileBuffers(pFile->h);
3590736027
SimulateIOError( rc=FALSE );
3590836028
if( rc ){
35909
- OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
36029
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
36030
+ osGetCurrentProcessId(), pFile, pFile->h));
3591036031
return SQLITE_OK;
3591136032
}else{
3591236033
pFile->lastErrno = osGetLastError();
35913
- OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
36034
+ OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
36035
+ osGetCurrentProcessId(), pFile, pFile->h));
3591436036
return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
35915
- "winSync", pFile->zPath);
36037
+ "winSync2", pFile->zPath);
3591636038
}
3591736039
#endif
3591836040
}
3591936041
3592036042
/*
@@ -36518,11 +36640,11 @@
3651836640
DWORD lastErrno; /* The Windows errno from the last I/O error */
3651936641
3652036642
int nRef; /* Number of winShm objects pointing to this */
3652136643
winShm *pFirst; /* All winShm objects pointing to this */
3652236644
winShmNode *pNext; /* Next in list of all winShmNode objects */
36523
-#ifdef SQLITE_DEBUG
36645
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
3652436646
u8 nextShmId; /* Next available winShm.id value */
3652536647
#endif
3652636648
};
3652736649
3652836650
/*
@@ -36549,11 +36671,11 @@
3654936671
winShmNode *pShmNode; /* The underlying winShmNode object */
3655036672
winShm *pNext; /* Next winShm with the same winShmNode */
3655136673
u8 hasMutex; /* True if holding the winShmNode mutex */
3655236674
u16 sharedMask; /* Mask of shared locks held */
3655336675
u16 exclMask; /* Mask of exclusive locks held */
36554
-#ifdef SQLITE_DEBUG
36676
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
3655536677
u8 id; /* Id of this connection with its winShmNode */
3655636678
#endif
3655736679
};
3655836680
3655936681
/*
@@ -36740,11 +36862,11 @@
3674036862
if( rc ) goto shm_open_err;
3674136863
}
3674236864
3674336865
/* Make the new connection a child of the winShmNode */
3674436866
p->pShmNode = pShmNode;
36745
-#ifdef SQLITE_DEBUG
36867
+#if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
3674636868
p->id = pShmNode->nextShmId++;
3674736869
#endif
3674836870
pShmNode->nRef++;
3674936871
pDbFd->pShm = p;
3675036872
winShmLeaveMutex();
@@ -37009,11 +37131,11 @@
3700937131
goto shmpage_out;
3701037132
}
3701137133
}
3701237134
3701337135
/* Map the requested memory region into this processes address space. */
37014
- apNew = (struct ShmRegion *)sqlite3_realloc(
37136
+ apNew = (struct ShmRegion *)sqlite3_realloc64(
3701537137
pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
3701637138
);
3701737139
if( !apNew ){
3701837140
rc = SQLITE_IOERR_NOMEM;
3701937141
goto shmpage_out;
@@ -37881,11 +38003,11 @@
3788138003
winRetryIoerr(&cnt, &lastErrno) ){
3788238004
/* Noop */
3788338005
}
3788438006
}
3788538007
#endif
37886
- winLogIoerr(cnt);
38008
+ winLogIoerr(cnt, __LINE__);
3788738009
3788838010
OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
3788938011
dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
3789038012
3789138013
if( h==INVALID_HANDLE_VALUE ){
@@ -38065,11 +38187,11 @@
3806538187
}
3806638188
#endif
3806738189
if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
3806838190
rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
3806938191
}else{
38070
- winLogIoerr(cnt);
38192
+ winLogIoerr(cnt, __LINE__);
3807138193
}
3807238194
sqlite3_free(zConverted);
3807338195
OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
3807438196
return rc;
3807538197
}
@@ -38115,11 +38237,11 @@
3811538237
attr = INVALID_FILE_ATTRIBUTES;
3811638238
}else{
3811738239
attr = sAttrData.dwFileAttributes;
3811838240
}
3811938241
}else{
38120
- winLogIoerr(cnt);
38242
+ winLogIoerr(cnt, __LINE__);
3812138243
if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
3812238244
sqlite3_free(zConverted);
3812338245
return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
3812438246
zFilename);
3812538247
}else{
@@ -38456,11 +38578,11 @@
3845638578
** Write up to nBuf bytes of randomness into zBuf.
3845738579
*/
3845838580
static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
3845938581
int n = 0;
3846038582
UNUSED_PARAMETER(pVfs);
38461
-#if defined(SQLITE_TEST)
38583
+#if defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS)
3846238584
n = nBuf;
3846338585
memset(zBuf, 0, nBuf);
3846438586
#else
3846538587
if( sizeof(SYSTEMTIME)<=nBuf-n ){
3846638588
SYSTEMTIME x;
@@ -38490,11 +38612,10 @@
3849038612
LARGE_INTEGER i;
3849138613
osQueryPerformanceCounter(&i);
3849238614
memcpy(&zBuf[n], &i, sizeof(i));
3849338615
n += sizeof(i);
3849438616
}
38495
-#endif
3849638617
#if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
3849738618
if( sizeof(UUID)<=nBuf-n ){
3849838619
UUID id;
3849938620
memset(&id, 0, sizeof(UUID));
3850038621
osUuidCreate(&id);
@@ -38507,10 +38628,11 @@
3850738628
osUuidCreateSequential(&id);
3850838629
memcpy(zBuf, &id, sizeof(UUID));
3850938630
n += sizeof(UUID);
3851038631
}
3851138632
#endif
38633
+#endif /* defined(SQLITE_TEST) || defined(SQLITE_ZERO_PRNG_SEED) */
3851238634
return n;
3851338635
}
3851438636
3851538637
3851638638
/*
@@ -38630,11 +38752,11 @@
3863038752
}
3863138753
3863238754
/*
3863338755
** Initialize and deinitialize the operating system interface.
3863438756
*/
38635
-SQLITE_API int sqlite3_os_init(void){
38757
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
3863638758
static sqlite3_vfs winVfs = {
3863738759
3, /* iVersion */
3863838760
sizeof(winFile), /* szOsFile */
3863938761
SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
3864038762
0, /* pNext */
@@ -38684,11 +38806,11 @@
3868438806
};
3868538807
#endif
3868638808
3868738809
/* Double-check that the aSyscall[] array has been constructed
3868838810
** correctly. See ticket [bb3a86e890c8e96ab] */
38689
- assert( ArraySize(aSyscall)==79 );
38811
+ assert( ArraySize(aSyscall)==80 );
3869038812
3869138813
/* get memory map allocation granularity */
3869238814
memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
3869338815
#if SQLITE_OS_WINRT
3869438816
osGetNativeSystemInfo(&winSysInfo);
@@ -38705,11 +38827,11 @@
3870538827
#endif
3870638828
3870738829
return SQLITE_OK;
3870838830
}
3870938831
38710
-SQLITE_API int sqlite3_os_end(void){
38832
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
3871138833
#if SQLITE_OS_WINRT
3871238834
if( sleepObj!=NULL ){
3871338835
osCloseHandle(sleepObj);
3871438836
sleepObj = NULL;
3871538837
}
@@ -39061,11 +39183,11 @@
3906139183
3906239184
/* Allocate the Bitvec to be tested and a linear array of
3906339185
** bits to act as the reference */
3906439186
pBitvec = sqlite3BitvecCreate( sz );
3906539187
pV = sqlite3MallocZero( (sz+7)/8 + 1 );
39066
- pTmpSpace = sqlite3_malloc(BITVEC_SZ);
39188
+ pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
3906739189
if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
3906839190
3906939191
/* NULL pBitvec tests */
3907039192
sqlite3BitvecSet(0, 1);
3907139193
sqlite3BitvecClear(0, 1, pTmpSpace);
@@ -44550,13 +44672,11 @@
4455044672
Pgno nTruncate, /* Database size after this commit */
4455144673
int isCommit /* True if this is a commit */
4455244674
){
4455344675
int rc; /* Return code */
4455444676
int nList; /* Number of pages in pList */
44555
-#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
4455644677
PgHdr *p; /* For looping over pages */
44557
-#endif
4455844678
4455944679
assert( pPager->pWal );
4456044680
assert( pList );
4456144681
#ifdef SQLITE_DEBUG
4456244682
/* Verify that the page list is in accending order */
@@ -44569,11 +44689,10 @@
4456944689
if( isCommit ){
4457044690
/* If a WAL transaction is being committed, there is no point in writing
4457144691
** any pages with page numbers greater than nTruncate into the WAL file.
4457244692
** They will never be read by any client. So remove them from the pDirty
4457344693
** list here. */
44574
- PgHdr *p;
4457544694
PgHdr **ppNext = &pList;
4457644695
nList = 0;
4457744696
for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
4457844697
if( p->pgno<=nTruncate ){
4457944698
ppNext = &p->pDirty;
@@ -44589,11 +44708,10 @@
4458944708
if( pList->pgno==1 ) pager_write_changecounter(pList);
4459044709
rc = sqlite3WalFrames(pPager->pWal,
4459144710
pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
4459244711
);
4459344712
if( rc==SQLITE_OK && pPager->pBackup ){
44594
- PgHdr *p;
4459544713
for(p=pList; p; p=p->pDirty){
4459644714
sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
4459744715
}
4459844716
}
4459944717
@@ -48520,10 +48638,12 @@
4852048638
}else if( state==PAGER_OPEN ){
4852148639
pager_unlock(pPager);
4852248640
}
4852348641
assert( state==pPager->eState );
4852448642
}
48643
+ }else if( eMode==PAGER_JOURNALMODE_OFF ){
48644
+ sqlite3OsClose(pPager->jfd);
4852548645
}
4852648646
}
4852748647
4852848648
/* Return the new journal mode */
4852948649
return (int)pPager->journalMode;
@@ -49302,11 +49422,11 @@
4930249422
4930349423
/* Enlarge the pWal->apWiData[] array if required */
4930449424
if( pWal->nWiData<=iPage ){
4930549425
int nByte = sizeof(u32*)*(iPage+1);
4930649426
volatile u32 **apNew;
49307
- apNew = (volatile u32 **)sqlite3_realloc((void *)pWal->apWiData, nByte);
49427
+ apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);
4930849428
if( !apNew ){
4930949429
*ppPage = 0;
4931049430
return SQLITE_NOMEM;
4931149431
}
4931249432
memset((void*)&apNew[pWal->nWiData], 0,
@@ -49927,11 +50047,11 @@
4992750047
goto finished;
4992850048
}
4992950049
4993050050
/* Malloc a buffer to read frames into. */
4993150051
szFrame = szPage + WAL_FRAME_HDRSIZE;
49932
- aFrame = (u8 *)sqlite3_malloc(szFrame);
50052
+ aFrame = (u8 *)sqlite3_malloc64(szFrame);
4993350053
if( !aFrame ){
4993450054
rc = SQLITE_NOMEM;
4993550055
goto recovery_error;
4993650056
}
4993750057
aData = &aFrame[WAL_FRAME_HDRSIZE];
@@ -50320,21 +50440,21 @@
5032050440
/* Allocate space for the WalIterator object. */
5032150441
nSegment = walFramePage(iLast) + 1;
5032250442
nByte = sizeof(WalIterator)
5032350443
+ (nSegment-1)*sizeof(struct WalSegment)
5032450444
+ iLast*sizeof(ht_slot);
50325
- p = (WalIterator *)sqlite3_malloc(nByte);
50445
+ p = (WalIterator *)sqlite3_malloc64(nByte);
5032650446
if( !p ){
5032750447
return SQLITE_NOMEM;
5032850448
}
5032950449
memset(p, 0, nByte);
5033050450
p->nSegment = nSegment;
5033150451
5033250452
/* Allocate temporary space used by the merge-sort routine. This block
5033350453
** of memory will be freed before this function returns.
5033450454
*/
50335
- aTmp = (ht_slot *)sqlite3_malloc(
50455
+ aTmp = (ht_slot *)sqlite3_malloc64(
5033650456
sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
5033750457
);
5033850458
if( !aTmp ){
5033950459
rc = SQLITE_NOMEM;
5034050460
}
@@ -50510,10 +50630,18 @@
5051050630
** cannot be backfilled from the WAL.
5051150631
*/
5051250632
mxSafeFrame = pWal->hdr.mxFrame;
5051350633
mxPage = pWal->hdr.nPage;
5051450634
for(i=1; i<WAL_NREADER; i++){
50635
+ /* Thread-sanitizer reports that the following is an unsafe read,
50636
+ ** as some other thread may be in the process of updating the value
50637
+ ** of the aReadMark[] slot. The assumption here is that if that is
50638
+ ** happening, the other client may only be increasing the value,
50639
+ ** not decreasing it. So assuming either that either the "old" or
50640
+ ** "new" version of the value is read, and not some arbitrary value
50641
+ ** that would never be written by a real client, things are still
50642
+ ** safe. */
5051550643
u32 y = pInfo->aReadMark[i];
5051650644
if( mxSafeFrame>y ){
5051750645
assert( y<=pWal->hdr.mxFrame );
5051850646
rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
5051950647
if( rc==SQLITE_OK ){
@@ -52231,10 +52359,11 @@
5223152359
u8 noPayload; /* True if internal intKey page (thus w/o data) */
5223252360
u8 leaf; /* True if a leaf page */
5223352361
u8 hdrOffset; /* 100 for page 1. 0 otherwise */
5223452362
u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */
5223552363
u8 max1bytePayload; /* min(maxLocal,127) */
52364
+ u8 bBusy; /* Prevent endless loops on corrupt database files */
5223652365
u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
5223752366
u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
5223852367
u16 cellOffset; /* Index in aData of first cell pointer */
5223952368
u16 nFree; /* Number of free bytes on the page */
5224052369
u16 nCell; /* Number of cells on this page, local and ovfl */
@@ -53006,11 +53135,11 @@
5300653135
**
5300753136
** This routine has no effect on existing database connections.
5300853137
** The shared cache setting effects only future calls to
5300953138
** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
5301053139
*/
53011
-SQLITE_API int sqlite3_enable_shared_cache(int enable){
53140
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
5301253141
sqlite3GlobalConfig.sharedCacheEnabled = enable;
5301353142
return SQLITE_OK;
5301453143
}
5301553144
#endif
5301653145
@@ -53520,14 +53649,19 @@
5352053649
** prior to calling this routine.
5352153650
*/
5352253651
static int saveCursorPosition(BtCursor *pCur){
5352353652
int rc;
5352453653
53525
- assert( CURSOR_VALID==pCur->eState );
53654
+ assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
5352653655
assert( 0==pCur->pKey );
5352753656
assert( cursorHoldsMutex(pCur) );
5352853657
53658
+ if( pCur->eState==CURSOR_SKIPNEXT ){
53659
+ pCur->eState = CURSOR_VALID;
53660
+ }else{
53661
+ pCur->skipNext = 0;
53662
+ }
5352953663
rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
5353053664
assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
5353153665
5353253666
/* If this is an intKey table, then the above call to BtreeKeySize()
5353353667
** stores the integer key in pCur->nKey. In this case this value is
@@ -53594,11 +53728,11 @@
5359453728
Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
5359553729
BtCursor *pExcept /* Do not save this cursor */
5359653730
){
5359753731
do{
5359853732
if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53599
- if( p->eState==CURSOR_VALID ){
53733
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
5360053734
int rc = saveCursorPosition(p);
5360153735
if( SQLITE_OK!=rc ){
5360253736
return rc;
5360353737
}
5360453738
}else{
@@ -53666,21 +53800,23 @@
5366653800
** at most one effective restoreCursorPosition() call after each
5366753801
** saveCursorPosition().
5366853802
*/
5366953803
static int btreeRestoreCursorPosition(BtCursor *pCur){
5367053804
int rc;
53805
+ int skipNext;
5367153806
assert( cursorHoldsMutex(pCur) );
5367253807
assert( pCur->eState>=CURSOR_REQUIRESEEK );
5367353808
if( pCur->eState==CURSOR_FAULT ){
5367453809
return pCur->skipNext;
5367553810
}
5367653811
pCur->eState = CURSOR_INVALID;
53677
- rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
53812
+ rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
5367853813
if( rc==SQLITE_OK ){
5367953814
sqlite3_free(pCur->pKey);
5368053815
pCur->pKey = 0;
5368153816
assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
53817
+ pCur->skipNext |= skipNext;
5368253818
if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
5368353819
pCur->eState = CURSOR_SKIPNEXT;
5368453820
}
5368553821
}
5368653822
return rc;
@@ -53728,13 +53864,14 @@
5372853864
rc = restoreCursorPosition(pCur);
5372953865
if( rc ){
5373053866
*pDifferentRow = 1;
5373153867
return rc;
5373253868
}
53733
- if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
53869
+ if( pCur->eState!=CURSOR_VALID ){
5373453870
*pDifferentRow = 1;
5373553871
}else{
53872
+ assert( pCur->skipNext==0 );
5373653873
*pDifferentRow = 0;
5373753874
}
5373853875
return SQLITE_OK;
5373953876
}
5374053877
@@ -54871,20 +55008,22 @@
5487155008
** If this Btree is a candidate for shared cache, try to find an
5487255009
** existing BtShared object that we can share with
5487355010
*/
5487455011
if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){
5487555012
if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
55013
+ int nFilename = sqlite3Strlen30(zFilename)+1;
5487655014
int nFullPathname = pVfs->mxPathname+1;
54877
- char *zFullPathname = sqlite3Malloc(nFullPathname);
55015
+ char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));
5487855016
MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
55017
+
5487955018
p->sharable = 1;
5488055019
if( !zFullPathname ){
5488155020
sqlite3_free(p);
5488255021
return SQLITE_NOMEM;
5488355022
}
5488455023
if( isMemdb ){
54885
- memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1);
55024
+ memcpy(zFullPathname, zFilename, nFilename);
5488655025
}else{
5488755026
rc = sqlite3OsFullPathname(pVfs, zFilename,
5488855027
nFullPathname, zFullPathname);
5488955028
if( rc ){
5489055029
sqlite3_free(zFullPathname);
@@ -55339,11 +55478,11 @@
5533955478
}
5534055479
assert( nReserve>=0 && nReserve<=255 );
5534155480
if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
5534255481
((pageSize-1)&pageSize)==0 ){
5534355482
assert( (pageSize & 7)==0 );
55344
- assert( !pBt->pPage1 && !pBt->pCursor );
55483
+ assert( !pBt->pCursor );
5534555484
pBt->pageSize = (u32)pageSize;
5534655485
freeTempSpace(pBt);
5534755486
}
5534855487
rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
5534955488
pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -56545,11 +56684,11 @@
5654556684
if( pBtree ){
5654656685
sqlite3BtreeEnter(pBtree);
5654756686
for(p=pBtree->pBt->pCursor; p; p=p->pNext){
5654856687
int i;
5654956688
if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56550
- if( p->eState==CURSOR_VALID ){
56689
+ if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
5655156690
rc = saveCursorPosition(p);
5655256691
if( rc!=SQLITE_OK ){
5655356692
(void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
5655456693
break;
5655556694
}
@@ -56951,10 +57090,12 @@
5695157090
** to return an integer result code for historical reasons.
5695257091
*/
5695357092
SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
5695457093
assert( cursorHoldsMutex(pCur) );
5695557094
assert( pCur->eState==CURSOR_VALID );
57095
+ assert( pCur->iPage>=0 );
57096
+ assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
5695657097
assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
5695757098
getCellInfo(pCur);
5695857099
*pSize = pCur->info.nPayload;
5695957100
return SQLITE_OK;
5696057101
}
@@ -57359,17 +57500,22 @@
5735957500
*/
5736057501
static const void *fetchPayload(
5736157502
BtCursor *pCur, /* Cursor pointing to entry to read from */
5736257503
u32 *pAmt /* Write the number of available bytes here */
5736357504
){
57505
+ u32 amt;
5736457506
assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
5736557507
assert( pCur->eState==CURSOR_VALID );
5736657508
assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
5736757509
assert( cursorHoldsMutex(pCur) );
5736857510
assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
5736957511
assert( pCur->info.nSize>0 );
57370
- *pAmt = pCur->info.nLocal;
57512
+ assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB );
57513
+ assert( pCur->info.pPayload<pCur->apPage[pCur->iPage]->aDataEnd ||CORRUPT_DB);
57514
+ amt = (int)(pCur->apPage[pCur->iPage]->aDataEnd - pCur->info.pPayload);
57515
+ if( pCur->info.nLocal<amt ) amt = pCur->info.nLocal;
57516
+ *pAmt = amt;
5737157517
return (void*)pCur->info.pPayload;
5737257518
}
5737357519
5737457520
5737557521
/*
@@ -57429,19 +57575,21 @@
5742957575
return SQLITE_CORRUPT_BKPT;
5743057576
}
5743157577
return SQLITE_OK;
5743257578
}
5743357579
57434
-#if 0
57580
+#if SQLITE_DEBUG
5743557581
/*
5743657582
** Page pParent is an internal (non-leaf) tree page. This function
5743757583
** asserts that page number iChild is the left-child if the iIdx'th
5743857584
** cell in page pParent. Or, if iIdx is equal to the total number of
5743957585
** cells in pParent, that page number iChild is the right-child of
5744057586
** the page.
5744157587
*/
5744257588
static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
57589
+ if( CORRUPT_DB ) return; /* The conditions tested below might not be true
57590
+ ** in a corrupt database */
5744357591
assert( iIdx<=pParent->nCell );
5744457592
if( iIdx==pParent->nCell ){
5744557593
assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
5744657594
}else{
5744757595
assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57462,23 +57610,15 @@
5746257610
static void moveToParent(BtCursor *pCur){
5746357611
assert( cursorHoldsMutex(pCur) );
5746457612
assert( pCur->eState==CURSOR_VALID );
5746557613
assert( pCur->iPage>0 );
5746657614
assert( pCur->apPage[pCur->iPage] );
57467
-
57468
- /* UPDATE: It is actually possible for the condition tested by the assert
57469
- ** below to be untrue if the database file is corrupt. This can occur if
57470
- ** one cursor has modified page pParent while a reference to it is held
57471
- ** by a second cursor. Which can only happen if a single page is linked
57472
- ** into more than one b-tree structure in a corrupt database. */
57473
-#if 0
5747457615
assertParentIndex(
5747557616
pCur->apPage[pCur->iPage-1],
5747657617
pCur->aiIdx[pCur->iPage-1],
5747757618
pCur->apPage[pCur->iPage]->pgno
5747857619
);
57479
-#endif
5748057620
testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
5748157621
5748257622
releasePage(pCur->apPage[pCur->iPage]);
5748357623
pCur->iPage--;
5748457624
pCur->info.nSize = 0;
@@ -59649,11 +59789,10 @@
5964959789
if( iParentIdx==0 ){
5965059790
nxDiv = 0;
5965159791
}else if( iParentIdx==i ){
5965259792
nxDiv = i-2+bBulk;
5965359793
}else{
59654
- assert( bBulk==0 );
5965559794
nxDiv = iParentIdx-1;
5965659795
}
5965759796
i = 2-bBulk;
5965859797
}
5965959798
nOld = i+1;
@@ -60422,10 +60561,11 @@
6042260561
pPage->nOverflow = 0;
6042360562
6042460563
/* The next iteration of the do-loop balances the parent page. */
6042560564
releasePage(pPage);
6042660565
pCur->iPage--;
60566
+ assert( pCur->iPage>=0 );
6042760567
}
6042860568
}while( rc==SQLITE_OK );
6042960569
6043060570
if( pFree ){
6043160571
sqlite3PageFree(pFree);
@@ -60898,13 +61038,17 @@
6089861038
6089961039
assert( sqlite3_mutex_held(pBt->mutex) );
6090061040
if( pgno>btreePagecount(pBt) ){
6090161041
return SQLITE_CORRUPT_BKPT;
6090261042
}
60903
-
6090461043
rc = getAndInitPage(pBt, pgno, &pPage, 0);
6090561044
if( rc ) return rc;
61045
+ if( pPage->bBusy ){
61046
+ rc = SQLITE_CORRUPT_BKPT;
61047
+ goto cleardatabasepage_out;
61048
+ }
61049
+ pPage->bBusy = 1;
6090661050
hdr = pPage->hdrOffset;
6090761051
for(i=0; i<pPage->nCell; i++){
6090861052
pCell = findCell(pPage, i);
6090961053
if( !pPage->leaf ){
6091061054
rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
@@ -60925,10 +61069,11 @@
6092561069
}else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
6092661070
zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);
6092761071
}
6092861072
6092961073
cleardatabasepage_out:
61074
+ pPage->bBusy = 0;
6093061075
releasePage(pPage);
6093161076
return rc;
6093261077
}
6093361078
6093461079
/*
@@ -61431,10 +61576,61 @@
6143161576
iPage = get4byte(pOvflData);
6143261577
sqlite3PagerUnref(pOvflPage);
6143361578
}
6143461579
}
6143561580
#endif /* SQLITE_OMIT_INTEGRITY_CHECK */
61581
+
61582
+/*
61583
+** An implementation of a min-heap.
61584
+**
61585
+** aHeap[0] is the number of elements on the heap. aHeap[1] is the
61586
+** root element. The daughter nodes of aHeap[N] are aHeap[N*2]
61587
+** and aHeap[N*2+1].
61588
+**
61589
+** The heap property is this: Every node is less than or equal to both
61590
+** of its daughter nodes. A consequence of the heap property is that the
61591
+** root node aHeap[1] is always the minimum value currently in the heap.
61592
+**
61593
+** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto
61594
+** the heap, preserving the heap property. The btreeHeapPull() routine
61595
+** removes the root element from the heap (the minimum value in the heap)
61596
+** and then moves other nodes around as necessary to preserve the heap
61597
+** property.
61598
+**
61599
+** This heap is used for cell overlap and coverage testing. Each u32
61600
+** entry represents the span of a cell or freeblock on a btree page.
61601
+** The upper 16 bits are the index of the first byte of a range and the
61602
+** lower 16 bits are the index of the last byte of that range.
61603
+*/
61604
+static void btreeHeapInsert(u32 *aHeap, u32 x){
61605
+ u32 j, i = ++aHeap[0];
61606
+ aHeap[i] = x;
61607
+ while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
61608
+ x = aHeap[j];
61609
+ aHeap[j] = aHeap[i];
61610
+ aHeap[i] = x;
61611
+ i = j;
61612
+ }
61613
+}
61614
+static int btreeHeapPull(u32 *aHeap, u32 *pOut){
61615
+ u32 j, i, x;
61616
+ if( (x = aHeap[0])==0 ) return 0;
61617
+ *pOut = aHeap[1];
61618
+ aHeap[1] = aHeap[x];
61619
+ aHeap[x] = 0xffffffff;
61620
+ aHeap[0]--;
61621
+ i = 1;
61622
+ while( (j = i*2)<=aHeap[0] ){
61623
+ if( aHeap[j]>aHeap[j+1] ) j++;
61624
+ if( aHeap[i]<aHeap[j] ) break;
61625
+ x = aHeap[i];
61626
+ aHeap[i] = aHeap[j];
61627
+ aHeap[j] = x;
61628
+ i = j;
61629
+ }
61630
+ return 1;
61631
+}
6143661632
6143761633
#ifndef SQLITE_OMIT_INTEGRITY_CHECK
6143861634
/*
6143961635
** Do various sanity checks on a single page of a tree. Return
6144061636
** the tree depth. Root pages return 0. Parents of root pages
@@ -61464,11 +61660,12 @@
6146461660
int hdr, cellStart;
6146561661
int nCell;
6146661662
u8 *data;
6146761663
BtShared *pBt;
6146861664
int usableSize;
61469
- char *hit = 0;
61665
+ u32 *heap = 0;
61666
+ u32 x, prev = 0;
6147061667
i64 nMinKey = 0;
6147161668
i64 nMaxKey = 0;
6147261669
const char *saved_zPfx = pCheck->zPfx;
6147361670
int saved_v1 = pCheck->v1;
6147461671
int saved_v2 = pCheck->v2;
@@ -61609,19 +61806,19 @@
6160961806
6161061807
/* Check for complete coverage of the page
6161161808
*/
6161261809
data = pPage->aData;
6161361810
hdr = pPage->hdrOffset;
61614
- hit = sqlite3PageMalloc( pBt->pageSize );
61811
+ heap = (u32*)sqlite3PageMalloc( pBt->pageSize );
6161561812
pCheck->zPfx = 0;
61616
- if( hit==0 ){
61813
+ if( heap==0 ){
6161761814
pCheck->mallocFailed = 1;
6161861815
}else{
6161961816
int contentOffset = get2byteNotZero(&data[hdr+5]);
6162061817
assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
61621
- memset(hit+contentOffset, 0, usableSize-contentOffset);
61622
- memset(hit, 1, contentOffset);
61818
+ heap[0] = 0;
61819
+ btreeHeapInsert(heap, contentOffset-1);
6162361820
/* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
6162461821
** number of cells on the page. */
6162561822
nCell = get2byte(&data[hdr+3]);
6162661823
/* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
6162761824
** immediately follows the b-tree page header. */
@@ -61629,20 +61826,19 @@
6162961826
/* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte
6163061827
** integer offsets to the cell contents. */
6163161828
for(i=0; i<nCell; i++){
6163261829
int pc = get2byte(&data[cellStart+i*2]);
6163361830
u32 size = 65536;
61634
- int j;
6163561831
if( pc<=usableSize-4 ){
6163661832
size = cellSizePtr(pPage, &data[pc]);
6163761833
}
6163861834
if( (int)(pc+size-1)>=usableSize ){
6163961835
pCheck->zPfx = 0;
6164061836
checkAppendMsg(pCheck,
6164161837
"Corruption detected in cell %d on page %d",i,iPage);
6164261838
}else{
61643
- for(j=pc+size-1; j>=pc; j--) hit[j]++;
61839
+ btreeHeapInsert(heap, (pc<<16)|(pc+size-1));
6164461840
}
6164561841
}
6164661842
/* EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
6164761843
** is the offset of the first freeblock, or zero if there are no
6164861844
** freeblocks on the page. */
@@ -61650,11 +61846,11 @@
6165061846
while( i>0 ){
6165161847
int size, j;
6165261848
assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */
6165361849
size = get2byte(&data[i+2]);
6165461850
assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */
61655
- for(j=i+size-1; j>=i; j--) hit[j]++;
61851
+ btreeHeapInsert(heap, (i<<16)|(i+size-1));
6165661852
/* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a
6165761853
** big-endian integer which is the offset in the b-tree page of the next
6165861854
** freeblock in the chain, or zero if the freeblock is the last on the
6165961855
** chain. */
6166061856
j = get2byte(&data[i]);
@@ -61662,31 +61858,37 @@
6166261858
** increasing offset. */
6166361859
assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */
6166461860
assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */
6166561861
i = j;
6166661862
}
61667
- for(i=cnt=0; i<usableSize; i++){
61668
- if( hit[i]==0 ){
61669
- cnt++;
61670
- }else if( hit[i]>1 ){
61863
+ cnt = 0;
61864
+ assert( heap[0]>0 );
61865
+ assert( (heap[1]>>16)==0 );
61866
+ btreeHeapPull(heap,&prev);
61867
+ while( btreeHeapPull(heap,&x) ){
61868
+ if( (prev&0xffff)+1>(x>>16) ){
6167161869
checkAppendMsg(pCheck,
61672
- "Multiple uses for byte %d of page %d", i, iPage);
61870
+ "Multiple uses for byte %u of page %d", x>>16, iPage);
6167361871
break;
61872
+ }else{
61873
+ cnt += (x>>16) - (prev&0xffff) - 1;
61874
+ prev = x;
6167461875
}
6167561876
}
61877
+ cnt += usableSize - (prev&0xffff) - 1;
6167661878
/* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments
6167761879
** is stored in the fifth field of the b-tree page header.
6167861880
** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the
6167961881
** number of fragmented free bytes within the cell content area.
6168061882
*/
61681
- if( cnt!=data[hdr+7] ){
61883
+ if( heap[0]==0 && cnt!=data[hdr+7] ){
6168261884
checkAppendMsg(pCheck,
6168361885
"Fragmentation of %d bytes reported as %d on page %d",
6168461886
cnt, data[hdr+7], iPage);
6168561887
}
6168661888
}
61687
- sqlite3PageFree(hit);
61889
+ sqlite3PageFree(heap);
6168861890
releasePage(pPage);
6168961891
6169061892
end_of_check:
6169161893
pCheck->zPfx = saved_zPfx;
6169261894
pCheck->v1 = saved_v1;
@@ -61746,12 +61948,11 @@
6174661948
sqlite3BtreeLeave(p);
6174761949
return 0;
6174861950
}
6174961951
i = PENDING_BYTE_PAGE(pBt);
6175061952
if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);
61751
- sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
61752
- sCheck.errMsg.useMalloc = 2;
61953
+ sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
6175361954
6175461955
/* Check the integrity of the freelist
6175561956
*/
6175661957
sCheck.zPfx = "Main freelist: ";
6175761958
checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
@@ -62239,11 +62440,11 @@
6223962440
** a pointer to the new sqlite3_backup object.
6224062441
**
6224162442
** If an error occurs, NULL is returned and an error code and error message
6224262443
** stored in database handle pDestDb.
6224362444
*/
62244
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
62445
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
6224562446
sqlite3* pDestDb, /* Database to write to */
6224662447
const char *zDestDb, /* Name of database within pDestDb */
6224762448
sqlite3* pSrcDb, /* Database connection to read from */
6224862449
const char *zSrcDb /* Name of database within pSrcDb */
6224962450
){
@@ -62447,11 +62648,11 @@
6244762648
}
6244862649
6244962650
/*
6245062651
** Copy nPage pages from the source b-tree to the destination.
6245162652
*/
62452
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
62653
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
6245362654
int rc;
6245462655
int destMode; /* Destination journal mode */
6245562656
int pgszSrc = 0; /* Source page size */
6245662657
int pgszDest = 0; /* Destination page size */
6245762658
@@ -62692,11 +62893,11 @@
6269262893
}
6269362894
6269462895
/*
6269562896
** Release all resources associated with an sqlite3_backup* handle.
6269662897
*/
62697
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
62898
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
6269862899
sqlite3_backup **pp; /* Ptr to head of pagers backup list */
6269962900
sqlite3 *pSrcDb; /* Source database connection */
6270062901
int rc; /* Value to return */
6270162902
6270262903
/* Enter the mutexes */
@@ -62744,11 +62945,11 @@
6274462945
6274562946
/*
6274662947
** Return the number of pages still to be backed up as of the most recent
6274762948
** call to sqlite3_backup_step().
6274862949
*/
62749
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
62950
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
6275062951
#ifdef SQLITE_ENABLE_API_ARMOR
6275162952
if( p==0 ){
6275262953
(void)SQLITE_MISUSE_BKPT;
6275362954
return 0;
6275462955
}
@@ -62758,11 +62959,11 @@
6275862959
6275962960
/*
6276062961
** Return the total number of pages in the source database as of the most
6276162962
** recent call to sqlite3_backup_step().
6276262963
*/
62763
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){
62964
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
6276462965
#ifdef SQLITE_ENABLE_API_ARMOR
6276562966
if( p==0 ){
6276662967
(void)SQLITE_MISUSE_BKPT;
6276762968
return 0;
6276862969
}
@@ -63083,14 +63284,15 @@
6308363284
return SQLITE_NOMEM;
6308463285
}
6308563286
pMem->z[pMem->n] = 0;
6308663287
pMem->z[pMem->n+1] = 0;
6308763288
pMem->flags |= MEM_Term;
63289
+ }
63290
+ pMem->flags &= ~MEM_Ephem;
6308863291
#ifdef SQLITE_DEBUG
63089
- pMem->pScopyFrom = 0;
63292
+ pMem->pScopyFrom = 0;
6309063293
#endif
63091
- }
6309263294
6309363295
return SQLITE_OK;
6309463296
}
6309563297
6309663298
/*
@@ -64530,11 +64732,11 @@
6453064732
int i;
6453164733
int nCol = pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField;
6453264734
Mem *aMem = pRec->aMem;
6453364735
sqlite3 *db = aMem[0].db;
6453464736
for(i=0; i<nCol; i++){
64535
- if( aMem[i].szMalloc ) sqlite3DbFree(db, aMem[i].zMalloc);
64737
+ sqlite3VdbeMemRelease(&aMem[i]);
6453664738
}
6453764739
sqlite3KeyInfoUnref(pRec->pKeyInfo);
6453864740
sqlite3DbFree(db, pRec);
6453964741
}
6454064742
}
@@ -64633,11 +64835,11 @@
6463364835
}
6463464836
6463564837
/*
6463664838
** Return the SQL associated with a prepared statement
6463764839
*/
64638
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){
64840
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
6463964841
Vdbe *p = (Vdbe *)pStmt;
6464064842
return (p && p->isPrepareV2) ? p->zSql : 0;
6464164843
}
6464264844
6464364845
/*
@@ -66366,18 +66568,35 @@
6636666568
pVtabCursor->pVtab->nRef--;
6636766569
pModule->xClose(pVtabCursor);
6636866570
}
6636966571
#endif
6637066572
}
66573
+
66574
+/*
66575
+** Close all cursors in the current frame.
66576
+*/
66577
+static void closeCursorsInFrame(Vdbe *p){
66578
+ if( p->apCsr ){
66579
+ int i;
66580
+ for(i=0; i<p->nCursor; i++){
66581
+ VdbeCursor *pC = p->apCsr[i];
66582
+ if( pC ){
66583
+ sqlite3VdbeFreeCursor(p, pC);
66584
+ p->apCsr[i] = 0;
66585
+ }
66586
+ }
66587
+ }
66588
+}
6637166589
6637266590
/*
6637366591
** Copy the values stored in the VdbeFrame structure to its Vdbe. This
6637466592
** is used, for example, when a trigger sub-program is halted to restore
6637566593
** control to the main program.
6637666594
*/
6637766595
SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
6637866596
Vdbe *v = pFrame->v;
66597
+ closeCursorsInFrame(v);
6637966598
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
6638066599
v->anExec = pFrame->anExec;
6638166600
#endif
6638266601
v->aOnceFlag = pFrame->aOnceFlag;
6638366602
v->nOnceFlag = pFrame->nOnceFlag;
@@ -66408,21 +66627,11 @@
6640866627
sqlite3VdbeFrameRestore(pFrame);
6640966628
p->pFrame = 0;
6641066629
p->nFrame = 0;
6641166630
}
6641266631
assert( p->nFrame==0 );
66413
-
66414
- if( p->apCsr ){
66415
- int i;
66416
- for(i=0; i<p->nCursor; i++){
66417
- VdbeCursor *pC = p->apCsr[i];
66418
- if( pC ){
66419
- sqlite3VdbeFreeCursor(p, pC);
66420
- p->apCsr[i] = 0;
66421
- }
66422
- }
66423
- }
66632
+ closeCursorsInFrame(p);
6642466633
if( p->aMem ){
6642566634
releaseMemArray(&p->aMem[1], p->nMem);
6642666635
}
6642766636
while( p->pDelFrame ){
6642866637
VdbeFrame *pDel = p->pDelFrame;
@@ -68163,11 +68372,11 @@
6816368372
** If database corruption is discovered, set pPKey2->errCode to
6816468373
** SQLITE_CORRUPT and return 0. If an OOM error is encountered,
6816568374
** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the
6816668375
** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).
6816768376
*/
68168
-static int vdbeRecordCompareWithSkip(
68377
+SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
6816968378
int nKey1, const void *pKey1, /* Left key */
6817068379
UnpackedRecord *pPKey2, /* Right key */
6817168380
int bSkip /* If true, skip the first field */
6817268381
){
6817368382
u32 d1; /* Offset into aKey[] of next data element */
@@ -68349,11 +68558,11 @@
6834968558
}
6835068559
SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
6835168560
int nKey1, const void *pKey1, /* Left key */
6835268561
UnpackedRecord *pPKey2 /* Right key */
6835368562
){
68354
- return vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
68563
+ return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
6835568564
}
6835668565
6835768566
6835868567
/*
6835968568
** This function is an optimized version of sqlite3VdbeRecordCompare()
@@ -68437,11 +68646,11 @@
6843768646
}else if( v<lhs ){
6843868647
res = pPKey2->r2;
6843968648
}else if( pPKey2->nField>1 ){
6844068649
/* The first fields of the two keys are equal. Compare the trailing
6844168650
** fields. */
68442
- res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68651
+ res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
6844368652
}else{
6844468653
/* The first fields of the two keys are equal and there are no trailing
6844568654
** fields. Return pPKey2->default_rc in this case. */
6844668655
res = pPKey2->default_rc;
6844768656
}
@@ -68485,11 +68694,11 @@
6848568694
6848668695
if( res==0 ){
6848768696
res = nStr - pPKey2->aMem[0].n;
6848868697
if( res==0 ){
6848968698
if( pPKey2->nField>1 ){
68490
- res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68699
+ res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
6849168700
}else{
6849268701
res = pPKey2->default_rc;
6849368702
}
6849468703
}else if( res>0 ){
6849568704
res = pPKey2->r2;
@@ -68789,11 +68998,11 @@
6878968998
** execution environment changes in a way that would alter the program
6879068999
** that sqlite3_prepare() generates. For example, if new functions or
6879169000
** collating sequences are registered or if an authorizer function is
6879269001
** added or changed.
6879369002
*/
68794
-SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){
69003
+SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
6879569004
Vdbe *p = (Vdbe*)pStmt;
6879669005
return p==0 || p->expired;
6879769006
}
6879869007
#endif
6879969008
@@ -68826,11 +69035,11 @@
6882669035
** machine.
6882769036
**
6882869037
** This routine sets the error code and string returned by
6882969038
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
6883069039
*/
68831
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
69040
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
6883269041
int rc;
6883369042
if( pStmt==0 ){
6883469043
/* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
6883569044
** pointer is a harmless no-op. */
6883669045
rc = SQLITE_OK;
@@ -68852,11 +69061,11 @@
6885269061
** the prior execution is returned.
6885369062
**
6885469063
** This routine sets the error code and string returned by
6885569064
** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
6885669065
*/
68857
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
69066
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
6885869067
int rc;
6885969068
if( pStmt==0 ){
6886069069
rc = SQLITE_OK;
6886169070
}else{
6886269071
Vdbe *v = (Vdbe*)pStmt;
@@ -68871,11 +69080,11 @@
6887169080
}
6887269081
6887369082
/*
6887469083
** Set all the parameters in the compiled SQL statement to NULL.
6887569084
*/
68876
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
69085
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
6887769086
int i;
6887869087
int rc = SQLITE_OK;
6887969088
Vdbe *p = (Vdbe*)pStmt;
6888069089
#if SQLITE_THREADSAFE
6888169090
sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68895,54 +69104,54 @@
6889569104
6889669105
/**************************** sqlite3_value_ *******************************
6889769106
** The following routines extract information from a Mem or sqlite3_value
6889869107
** structure.
6889969108
*/
68900
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
69109
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){
6890169110
Mem *p = (Mem*)pVal;
6890269111
if( p->flags & (MEM_Blob|MEM_Str) ){
6890369112
sqlite3VdbeMemExpandBlob(p);
6890469113
p->flags |= MEM_Blob;
6890569114
return p->n ? p->z : 0;
6890669115
}else{
6890769116
return sqlite3_value_text(pVal);
6890869117
}
6890969118
}
68910
-SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){
69119
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
6891169120
return sqlite3ValueBytes(pVal, SQLITE_UTF8);
6891269121
}
68913
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){
69122
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
6891469123
return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
6891569124
}
68916
-SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){
69125
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
6891769126
return sqlite3VdbeRealValue((Mem*)pVal);
6891869127
}
68919
-SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){
69128
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
6892069129
return (int)sqlite3VdbeIntValue((Mem*)pVal);
6892169130
}
68922
-SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
69131
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
6892369132
return sqlite3VdbeIntValue((Mem*)pVal);
6892469133
}
68925
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
69134
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){
6892669135
return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
6892769136
}
6892869137
#ifndef SQLITE_OMIT_UTF16
68929
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){
69138
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){
6893069139
return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
6893169140
}
68932
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){
69141
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){
6893369142
return sqlite3ValueText(pVal, SQLITE_UTF16BE);
6893469143
}
68935
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
69144
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){
6893669145
return sqlite3ValueText(pVal, SQLITE_UTF16LE);
6893769146
}
6893869147
#endif /* SQLITE_OMIT_UTF16 */
6893969148
/* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
6894069149
** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
6894169150
** point number string BLOB NULL
6894269151
*/
68943
-SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
69152
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
6894469153
static const u8 aType[] = {
6894569154
SQLITE_BLOB, /* 0x00 */
6894669155
SQLITE_NULL, /* 0x01 */
6894769156
SQLITE_TEXT, /* 0x02 */
6894869157
SQLITE_NULL, /* 0x03 */
@@ -69014,21 +69223,21 @@
6901469223
xDel((void*)p);
6901569224
}
6901669225
if( pCtx ) sqlite3_result_error_toobig(pCtx);
6901769226
return SQLITE_TOOBIG;
6901869227
}
69019
-SQLITE_API void sqlite3_result_blob(
69228
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(
6902069229
sqlite3_context *pCtx,
6902169230
const void *z,
6902269231
int n,
6902369232
void (*xDel)(void *)
6902469233
){
6902569234
assert( n>=0 );
6902669235
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6902769236
setResultStrOrError(pCtx, z, n, 0, xDel);
6902869237
}
69029
-SQLITE_API void sqlite3_result_blob64(
69238
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(
6903069239
sqlite3_context *pCtx,
6903169240
const void *z,
6903269241
sqlite3_uint64 n,
6903369242
void (*xDel)(void *)
6903469243
){
@@ -69038,50 +69247,50 @@
6903869247
(void)invokeValueDestructor(z, xDel, pCtx);
6903969248
}else{
6904069249
setResultStrOrError(pCtx, z, (int)n, 0, xDel);
6904169250
}
6904269251
}
69043
-SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
69252
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
6904469253
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6904569254
sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
6904669255
}
69047
-SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
69256
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
6904869257
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6904969258
pCtx->isError = SQLITE_ERROR;
6905069259
pCtx->fErrorOrAux = 1;
6905169260
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
6905269261
}
6905369262
#ifndef SQLITE_OMIT_UTF16
69054
-SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
69263
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
6905569264
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6905669265
pCtx->isError = SQLITE_ERROR;
6905769266
pCtx->fErrorOrAux = 1;
6905869267
sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
6905969268
}
6906069269
#endif
69061
-SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
69270
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
6906269271
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6906369272
sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
6906469273
}
69065
-SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
69274
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
6906669275
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6906769276
sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
6906869277
}
69069
-SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
69278
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
6907069279
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6907169280
sqlite3VdbeMemSetNull(pCtx->pOut);
6907269281
}
69073
-SQLITE_API void sqlite3_result_text(
69282
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(
6907469283
sqlite3_context *pCtx,
6907569284
const char *z,
6907669285
int n,
6907769286
void (*xDel)(void *)
6907869287
){
6907969288
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6908069289
setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
6908169290
}
69082
-SQLITE_API void sqlite3_result_text64(
69291
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(
6908369292
sqlite3_context *pCtx,
6908469293
const char *z,
6908569294
sqlite3_uint64 n,
6908669295
void (*xDel)(void *),
6908769296
unsigned char enc
@@ -69094,47 +69303,47 @@
6909469303
}else{
6909569304
setResultStrOrError(pCtx, z, (int)n, enc, xDel);
6909669305
}
6909769306
}
6909869307
#ifndef SQLITE_OMIT_UTF16
69099
-SQLITE_API void sqlite3_result_text16(
69308
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(
6910069309
sqlite3_context *pCtx,
6910169310
const void *z,
6910269311
int n,
6910369312
void (*xDel)(void *)
6910469313
){
6910569314
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6910669315
setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
6910769316
}
69108
-SQLITE_API void sqlite3_result_text16be(
69317
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(
6910969318
sqlite3_context *pCtx,
6911069319
const void *z,
6911169320
int n,
6911269321
void (*xDel)(void *)
6911369322
){
6911469323
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6911569324
setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
6911669325
}
69117
-SQLITE_API void sqlite3_result_text16le(
69326
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(
6911869327
sqlite3_context *pCtx,
6911969328
const void *z,
6912069329
int n,
6912169330
void (*xDel)(void *)
6912269331
){
6912369332
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6912469333
setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
6912569334
}
6912669335
#endif /* SQLITE_OMIT_UTF16 */
69127
-SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
69336
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
6912869337
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6912969338
sqlite3VdbeMemCopy(pCtx->pOut, pValue);
6913069339
}
69131
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
69340
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
6913269341
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6913369342
sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
6913469343
}
69135
-SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
69344
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
6913669345
pCtx->isError = errCode;
6913769346
pCtx->fErrorOrAux = 1;
6913869347
#ifdef SQLITE_DEBUG
6913969348
if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
6914069349
#endif
@@ -69143,20 +69352,20 @@
6914369352
SQLITE_UTF8, SQLITE_STATIC);
6914469353
}
6914569354
}
6914669355
6914769356
/* Force an SQLITE_TOOBIG error. */
69148
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
69357
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
6914969358
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6915069359
pCtx->isError = SQLITE_TOOBIG;
6915169360
pCtx->fErrorOrAux = 1;
6915269361
sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
6915369362
SQLITE_UTF8, SQLITE_STATIC);
6915469363
}
6915569364
6915669365
/* An SQLITE_NOMEM error. */
69157
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
69366
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
6915869367
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6915969368
sqlite3VdbeMemSetNull(pCtx->pOut);
6916069369
pCtx->isError = SQLITE_NOMEM;
6916169370
pCtx->fErrorOrAux = 1;
6916269371
pCtx->pOut->db->mallocFailed = 1;
@@ -69325,11 +69534,11 @@
6932569534
/*
6932669535
** This is the top-level implementation of sqlite3_step(). Call
6932769536
** sqlite3Step() to do most of the work. If a schema error occurs,
6932869537
** call sqlite3Reprepare() and try again.
6932969538
*/
69330
-SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
69539
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
6933169540
int rc = SQLITE_OK; /* Result from sqlite3Step() */
6933269541
int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
6933369542
Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
6933469543
int cnt = 0; /* Counter to prevent infinite loop of reprepares */
6933569544
sqlite3 *db; /* The database connection */
@@ -69376,11 +69585,11 @@
6937669585
6937769586
/*
6937869587
** Extract the user data from a sqlite3_context structure and return a
6937969588
** pointer to it.
6938069589
*/
69381
-SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
69590
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
6938269591
assert( p && p->pFunc );
6938369592
return p->pFunc->pUserData;
6938469593
}
6938569594
6938669595
/*
@@ -69391,11 +69600,11 @@
6939169600
** returns a copy of the pointer to the database connection (the 1st
6939269601
** parameter) of the sqlite3_create_function() and
6939369602
** sqlite3_create_function16() routines that originally registered the
6939469603
** application defined function.
6939569604
*/
69396
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
69605
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){
6939769606
assert( p && p->pFunc );
6939869607
return p->pOut->db;
6939969608
}
6940069609
6940169610
/*
@@ -69467,11 +69676,11 @@
6946769676
/*
6946869677
** Allocate or return the aggregate context for a user function. A new
6946969678
** context is allocated on the first call. Subsequent calls return the
6947069679
** same context that was returned on prior calls.
6947169680
*/
69472
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69681
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){
6947369682
assert( p && p->pFunc && p->pFunc->xStep );
6947469683
assert( sqlite3_mutex_held(p->pOut->db->mutex) );
6947569684
testcase( nByte<0 );
6947669685
if( (p->pMem->flags & MEM_Agg)==0 ){
6947769686
return createAggContext(p, nByte);
@@ -69482,11 +69691,11 @@
6948269691
6948369692
/*
6948469693
** Return the auxiliary data pointer, if any, for the iArg'th argument to
6948569694
** the user-function defined by pCtx.
6948669695
*/
69487
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69696
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
6948869697
AuxData *pAuxData;
6948969698
6949069699
assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
6949169700
#if SQLITE_ENABLE_STAT3_OR_STAT4
6949269701
if( pCtx->pVdbe==0 ) return 0;
@@ -69503,11 +69712,11 @@
6950369712
/*
6950469713
** Set the auxiliary data pointer and delete function, for the iArg'th
6950569714
** argument to the user-function defined by pCtx. Any previous value is
6950669715
** deleted by calling the delete function specified when it was set.
6950769716
*/
69508
-SQLITE_API void sqlite3_set_auxdata(
69717
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(
6950969718
sqlite3_context *pCtx,
6951069719
int iArg,
6951169720
void *pAux,
6951269721
void (*xDelete)(void*)
6951369722
){
@@ -69558,29 +69767,29 @@
6955869767
** This function is deprecated. Do not use it for new code. It is
6955969768
** provide only to avoid breaking legacy code. New aggregate function
6956069769
** implementations should keep their own counts within their aggregate
6956169770
** context.
6956269771
*/
69563
-SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
69772
+SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
6956469773
assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
6956569774
return p->pMem->n;
6956669775
}
6956769776
#endif
6956869777
6956969778
/*
6957069779
** Return the number of columns in the result set for the statement pStmt.
6957169780
*/
69572
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
69781
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
6957369782
Vdbe *pVm = (Vdbe *)pStmt;
6957469783
return pVm ? pVm->nResColumn : 0;
6957569784
}
6957669785
6957769786
/*
6957869787
** Return the number of values available from the current row of the
6957969788
** currently executing statement pStmt.
6958069789
*/
69581
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
69790
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
6958269791
Vdbe *pVm = (Vdbe *)pStmt;
6958369792
if( pVm==0 || pVm->pResultSet==0 ) return 0;
6958469793
return pVm->nResColumn;
6958569794
}
6958669795
@@ -69678,67 +69887,67 @@
6967869887
6967969888
/**************************** sqlite3_column_ *******************************
6968069889
** The following routines are used to access elements of the current row
6968169890
** in the result set.
6968269891
*/
69683
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69892
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
6968469893
const void *val;
6968569894
val = sqlite3_value_blob( columnMem(pStmt,i) );
6968669895
/* Even though there is no encoding conversion, value_blob() might
6968769896
** need to call malloc() to expand the result of a zeroblob()
6968869897
** expression.
6968969898
*/
6969069899
columnMallocFailure(pStmt);
6969169900
return val;
6969269901
}
69693
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69902
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
6969469903
int val = sqlite3_value_bytes( columnMem(pStmt,i) );
6969569904
columnMallocFailure(pStmt);
6969669905
return val;
6969769906
}
69698
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69907
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
6969969908
int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
6970069909
columnMallocFailure(pStmt);
6970169910
return val;
6970269911
}
69703
-SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69912
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
6970469913
double val = sqlite3_value_double( columnMem(pStmt,i) );
6970569914
columnMallocFailure(pStmt);
6970669915
return val;
6970769916
}
69708
-SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69917
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
6970969918
int val = sqlite3_value_int( columnMem(pStmt,i) );
6971069919
columnMallocFailure(pStmt);
6971169920
return val;
6971269921
}
69713
-SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69922
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
6971469923
sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
6971569924
columnMallocFailure(pStmt);
6971669925
return val;
6971769926
}
69718
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69927
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){
6971969928
const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
6972069929
columnMallocFailure(pStmt);
6972169930
return val;
6972269931
}
69723
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69932
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){
6972469933
Mem *pOut = columnMem(pStmt, i);
6972569934
if( pOut->flags&MEM_Static ){
6972669935
pOut->flags &= ~MEM_Static;
6972769936
pOut->flags |= MEM_Ephem;
6972869937
}
6972969938
columnMallocFailure(pStmt);
6973069939
return (sqlite3_value *)pOut;
6973169940
}
6973269941
#ifndef SQLITE_OMIT_UTF16
69733
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69942
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
6973469943
const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
6973569944
columnMallocFailure(pStmt);
6973669945
return val;
6973769946
}
6973869947
#endif /* SQLITE_OMIT_UTF16 */
69739
-SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69948
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
6974069949
int iType = sqlite3_value_type( columnMem(pStmt,i) );
6974169950
columnMallocFailure(pStmt);
6974269951
return iType;
6974369952
}
6974469953
@@ -69798,16 +70007,16 @@
6979870007
6979970008
/*
6980070009
** Return the name of the Nth column of the result set returned by SQL
6980170010
** statement pStmt.
6980270011
*/
69803
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
70012
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){
6980470013
return columnName(
6980570014
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
6980670015
}
6980770016
#ifndef SQLITE_OMIT_UTF16
69808
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
70017
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
6980970018
return columnName(
6981070019
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
6981170020
}
6981270021
#endif
6981370022
@@ -69823,16 +70032,16 @@
6982370032
#ifndef SQLITE_OMIT_DECLTYPE
6982470033
/*
6982570034
** Return the column declaration type (if applicable) of the 'i'th column
6982670035
** of the result set of SQL statement pStmt.
6982770036
*/
69828
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
70037
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
6982970038
return columnName(
6983070039
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
6983170040
}
6983270041
#ifndef SQLITE_OMIT_UTF16
69833
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
70042
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
6983470043
return columnName(
6983570044
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
6983670045
}
6983770046
#endif /* SQLITE_OMIT_UTF16 */
6983870047
#endif /* SQLITE_OMIT_DECLTYPE */
@@ -69841,16 +70050,16 @@
6984170050
/*
6984270051
** Return the name of the database from which a result column derives.
6984370052
** NULL is returned if the result column is an expression or constant or
6984470053
** anything else which is not an unambiguous reference to a database column.
6984570054
*/
69846
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
70055
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
6984770056
return columnName(
6984870057
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
6984970058
}
6985070059
#ifndef SQLITE_OMIT_UTF16
69851
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
70060
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
6985270061
return columnName(
6985370062
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
6985470063
}
6985570064
#endif /* SQLITE_OMIT_UTF16 */
6985670065
@@ -69857,16 +70066,16 @@
6985770066
/*
6985870067
** Return the name of the table from which a result column derives.
6985970068
** NULL is returned if the result column is an expression or constant or
6986070069
** anything else which is not an unambiguous reference to a database column.
6986170070
*/
69862
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
70071
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
6986370072
return columnName(
6986470073
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
6986570074
}
6986670075
#ifndef SQLITE_OMIT_UTF16
69867
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
70076
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
6986870077
return columnName(
6986970078
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
6987070079
}
6987170080
#endif /* SQLITE_OMIT_UTF16 */
6987270081
@@ -69873,16 +70082,16 @@
6987370082
/*
6987470083
** Return the name of the table column from which a result column derives.
6987570084
** NULL is returned if the result column is an expression or constant or
6987670085
** anything else which is not an unambiguous reference to a database column.
6987770086
*/
69878
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
70087
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
6987970088
return columnName(
6988070089
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
6988170090
}
6988270091
#ifndef SQLITE_OMIT_UTF16
69883
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
70092
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
6988470093
return columnName(
6988570094
pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
6988670095
}
6988770096
#endif /* SQLITE_OMIT_UTF16 */
6988870097
#endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69979,20 +70188,20 @@
6997970188
6998070189
6998170190
/*
6998270191
** Bind a blob value to an SQL statement variable.
6998370192
*/
69984
-SQLITE_API int sqlite3_bind_blob(
70193
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(
6998570194
sqlite3_stmt *pStmt,
6998670195
int i,
6998770196
const void *zData,
6998870197
int nData,
6998970198
void (*xDel)(void*)
6999070199
){
6999170200
return bindText(pStmt, i, zData, nData, xDel, 0);
6999270201
}
69993
-SQLITE_API int sqlite3_bind_blob64(
70202
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(
6999470203
sqlite3_stmt *pStmt,
6999570204
int i,
6999670205
const void *zData,
6999770206
sqlite3_uint64 nData,
6999870207
void (*xDel)(void*)
@@ -70002,52 +70211,52 @@
7000270211
return invokeValueDestructor(zData, xDel, 0);
7000370212
}else{
7000470213
return bindText(pStmt, i, zData, (int)nData, xDel, 0);
7000570214
}
7000670215
}
70007
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
70216
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
7000870217
int rc;
7000970218
Vdbe *p = (Vdbe *)pStmt;
7001070219
rc = vdbeUnbind(p, i);
7001170220
if( rc==SQLITE_OK ){
7001270221
sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
7001370222
sqlite3_mutex_leave(p->db->mutex);
7001470223
}
7001570224
return rc;
7001670225
}
70017
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
70226
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
7001870227
return sqlite3_bind_int64(p, i, (i64)iValue);
7001970228
}
70020
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
70229
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
7002170230
int rc;
7002270231
Vdbe *p = (Vdbe *)pStmt;
7002370232
rc = vdbeUnbind(p, i);
7002470233
if( rc==SQLITE_OK ){
7002570234
sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
7002670235
sqlite3_mutex_leave(p->db->mutex);
7002770236
}
7002870237
return rc;
7002970238
}
70030
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
70239
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
7003170240
int rc;
7003270241
Vdbe *p = (Vdbe*)pStmt;
7003370242
rc = vdbeUnbind(p, i);
7003470243
if( rc==SQLITE_OK ){
7003570244
sqlite3_mutex_leave(p->db->mutex);
7003670245
}
7003770246
return rc;
7003870247
}
70039
-SQLITE_API int sqlite3_bind_text(
70248
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(
7004070249
sqlite3_stmt *pStmt,
7004170250
int i,
7004270251
const char *zData,
7004370252
int nData,
7004470253
void (*xDel)(void*)
7004570254
){
7004670255
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
7004770256
}
70048
-SQLITE_API int sqlite3_bind_text64(
70257
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(
7004970258
sqlite3_stmt *pStmt,
7005070259
int i,
7005170260
const char *zData,
7005270261
sqlite3_uint64 nData,
7005370262
void (*xDel)(void*),
@@ -70060,21 +70269,21 @@
7006070269
if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
7006170270
return bindText(pStmt, i, zData, (int)nData, xDel, enc);
7006270271
}
7006370272
}
7006470273
#ifndef SQLITE_OMIT_UTF16
70065
-SQLITE_API int sqlite3_bind_text16(
70274
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(
7006670275
sqlite3_stmt *pStmt,
7006770276
int i,
7006870277
const void *zData,
7006970278
int nData,
7007070279
void (*xDel)(void*)
7007170280
){
7007270281
return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
7007370282
}
7007470283
#endif /* SQLITE_OMIT_UTF16 */
70075
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
70284
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
7007670285
int rc;
7007770286
switch( sqlite3_value_type((sqlite3_value*)pValue) ){
7007870287
case SQLITE_INTEGER: {
7007970288
rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
7008070289
break;
@@ -70101,11 +70310,11 @@
7010170310
break;
7010270311
}
7010370312
}
7010470313
return rc;
7010570314
}
70106
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
70315
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
7010770316
int rc;
7010870317
Vdbe *p = (Vdbe *)pStmt;
7010970318
rc = vdbeUnbind(p, i);
7011070319
if( rc==SQLITE_OK ){
7011170320
sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -70116,11 +70325,11 @@
7011670325
7011770326
/*
7011870327
** Return the number of wildcards that can be potentially bound to.
7011970328
** This routine is added to support DBD::SQLite.
7012070329
*/
70121
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
70330
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
7012270331
Vdbe *p = (Vdbe*)pStmt;
7012370332
return p ? p->nVar : 0;
7012470333
}
7012570334
7012670335
/*
@@ -70127,11 +70336,11 @@
7012770336
** Return the name of a wildcard parameter. Return NULL if the index
7012870337
** is out of range or if the wildcard is unnamed.
7012970338
**
7013070339
** The result is always UTF-8.
7013170340
*/
70132
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
70341
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
7013370342
Vdbe *p = (Vdbe*)pStmt;
7013470343
if( p==0 || i<1 || i>p->nzVar ){
7013570344
return 0;
7013670345
}
7013770346
return p->azVar[i-1];
@@ -70155,11 +70364,11 @@
7015570364
}
7015670365
}
7015770366
}
7015870367
return 0;
7015970368
}
70160
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
70369
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
7016170370
return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
7016270371
}
7016370372
7016470373
/*
7016570374
** Transfer all bindings from the first statement over to the second.
@@ -70189,11 +70398,11 @@
7018970398
**
7019070399
** If the two statements contain a different number of bindings, then
7019170400
** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
7019270401
** SQLITE_OK is returned.
7019370402
*/
70194
-SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
70403
+SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
7019570404
Vdbe *pFrom = (Vdbe*)pFromStmt;
7019670405
Vdbe *pTo = (Vdbe*)pToStmt;
7019770406
if( pFrom->nVar!=pTo->nVar ){
7019870407
return SQLITE_ERROR;
7019970408
}
@@ -70211,26 +70420,26 @@
7021170420
** Return the sqlite3* database handle to which the prepared statement given
7021270421
** in the argument belongs. This is the same database handle that was
7021370422
** the first argument to the sqlite3_prepare() that was used to create
7021470423
** the statement in the first place.
7021570424
*/
70216
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
70425
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
7021770426
return pStmt ? ((Vdbe*)pStmt)->db : 0;
7021870427
}
7021970428
7022070429
/*
7022170430
** Return true if the prepared statement is guaranteed to not modify the
7022270431
** database.
7022370432
*/
70224
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
70433
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
7022570434
return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
7022670435
}
7022770436
7022870437
/*
7022970438
** Return true if the prepared statement is in need of being reset.
7023070439
*/
70231
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
70440
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
7023270441
Vdbe *v = (Vdbe*)pStmt;
7023370442
return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
7023470443
}
7023570444
7023670445
/*
@@ -70237,11 +70446,11 @@
7023770446
** Return a pointer to the next prepared statement after pStmt associated
7023870447
** with database connection pDb. If pStmt is NULL, return the first
7023970448
** prepared statement for the database connection. Return NULL if there
7024070449
** are no more.
7024170450
*/
70242
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
70451
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
7024370452
sqlite3_stmt *pNext;
7024470453
#ifdef SQLITE_ENABLE_API_ARMOR
7024570454
if( !sqlite3SafetyCheckOk(pDb) ){
7024670455
(void)SQLITE_MISUSE_BKPT;
7024770456
return 0;
@@ -70258,11 +70467,11 @@
7025870467
}
7025970468
7026070469
/*
7026170470
** Return the value of a status counter for a prepared statement
7026270471
*/
70263
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
70472
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
7026470473
Vdbe *pVdbe = (Vdbe*)pStmt;
7026570474
u32 v;
7026670475
#ifdef SQLITE_ENABLE_API_ARMOR
7026770476
if( !pStmt ){
7026870477
(void)SQLITE_MISUSE_BKPT;
@@ -70276,11 +70485,11 @@
7027670485
7027770486
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
7027870487
/*
7027970488
** Return status data for a single loop within query pStmt.
7028070489
*/
70281
-SQLITE_API int sqlite3_stmt_scanstatus(
70490
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
7028270491
sqlite3_stmt *pStmt, /* Prepared statement being queried */
7028370492
int idx, /* Index of loop to report on */
7028470493
int iScanStatusOp, /* Which metric to return */
7028570494
void *pOut /* OUT: Write the answer here */
7028670495
){
@@ -70335,11 +70544,11 @@
7033570544
}
7033670545
7033770546
/*
7033870547
** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
7033970548
*/
70340
-SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70549
+SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
7034170550
Vdbe *p = (Vdbe*)pStmt;
7034270551
memset(p->anExec, 0, p->nOp * sizeof(i64));
7034370552
}
7034470553
#endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
7034570554
@@ -70427,21 +70636,22 @@
7042770636
Mem *pVar; /* Value of a host parameter */
7042870637
StrAccum out; /* Accumulate the output here */
7042970638
char zBase[100]; /* Initial working space */
7043070639
7043170640
db = p->db;
70432
- sqlite3StrAccumInit(&out, zBase, sizeof(zBase),
70641
+ sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase),
7043370642
db->aLimit[SQLITE_LIMIT_LENGTH]);
70434
- out.db = db;
7043570643
if( db->nVdbeExec>1 ){
7043670644
while( *zRawSql ){
7043770645
const char *zStart = zRawSql;
7043870646
while( *(zRawSql++)!='\n' && *zRawSql );
7043970647
sqlite3StrAccumAppend(&out, "-- ", 3);
7044070648
assert( (zRawSql - zStart) > 0 );
7044170649
sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
7044270650
}
70651
+ }else if( p->nVar==0 ){
70652
+ sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));
7044370653
}else{
7044470654
while( zRawSql[0] ){
7044570655
n = findNextHostParameter(zRawSql, &nToken);
7044670656
assert( n>0 );
7044770657
sqlite3StrAccumAppend(&out, zRawSql, n);
@@ -70454,14 +70664,16 @@
7045470664
sqlite3GetInt32(&zRawSql[1], &idx);
7045570665
}else{
7045670666
idx = nextIndex;
7045770667
}
7045870668
}else{
70459
- assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );
70669
+ assert( zRawSql[0]==':' || zRawSql[0]=='$' ||
70670
+ zRawSql[0]=='@' || zRawSql[0]=='#' );
7046070671
testcase( zRawSql[0]==':' );
7046170672
testcase( zRawSql[0]=='$' );
7046270673
testcase( zRawSql[0]=='@' );
70674
+ testcase( zRawSql[0]=='#' );
7046370675
idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);
7046470676
assert( idx>0 );
7046570677
}
7046670678
zRawSql += nToken;
7046770679
nextIndex = idx + 1;
@@ -70834,11 +71046,11 @@
7083471046
** Try to convert the type of a function argument or a result column
7083571047
** into a numeric representation. Use either INTEGER or REAL whichever
7083671048
** is appropriate. But only do the conversion if it is possible without
7083771049
** loss of information and return the revised type of the argument.
7083871050
*/
70839
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
71051
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
7084071052
int eType = sqlite3_value_type(pVal);
7084171053
if( eType==SQLITE_TEXT ){
7084271054
Mem *pMem = (Mem*)pVal;
7084371055
applyNumericAffinity(pMem, 0);
7084471056
eType = sqlite3_value_type(pVal);
@@ -71132,21 +71344,38 @@
7113271344
assert( n==(db->nSavepoint + db->isTransactionSavepoint) );
7113371345
return 1;
7113471346
}
7113571347
#endif
7113671348
71349
+/*
71350
+** Return the register of pOp->p2 after first preparing it to be
71351
+** overwritten with an integer value.
71352
+*/
71353
+static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
71354
+ Mem *pOut;
71355
+ assert( pOp->p2>0 );
71356
+ assert( pOp->p2<=(p->nMem-p->nCursor) );
71357
+ pOut = &p->aMem[pOp->p2];
71358
+ memAboutToChange(p, pOut);
71359
+ if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
71360
+ pOut->flags = MEM_Int;
71361
+ return pOut;
71362
+}
71363
+
7113771364
7113871365
/*
7113971366
** Execute as much of a VDBE program as we can.
7114071367
** This is the core of sqlite3_step().
7114171368
*/
7114271369
SQLITE_PRIVATE int sqlite3VdbeExec(
7114371370
Vdbe *p /* The VDBE */
7114471371
){
71145
- int pc=0; /* The program counter */
7114671372
Op *aOp = p->aOp; /* Copy of p->aOp */
71147
- Op *pOp; /* Current operation */
71373
+ Op *pOp = aOp; /* Current operation */
71374
+#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
71375
+ Op *pOrigOp; /* Value of pOp at the top of the loop */
71376
+#endif
7114871377
int rc = SQLITE_OK; /* Value to return */
7114971378
sqlite3 *db = p->db; /* The database */
7115071379
u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
7115171380
u8 encoding = ENC(db); /* The database encoding */
7115271381
int iCompare = 0; /* Result of last OP_Compare operation */
@@ -71218,27 +71447,26 @@
7121871447
}
7121971448
if( p->db->flags & SQLITE_VdbeTrace ) printf("VDBE Trace:\n");
7122071449
}
7122171450
sqlite3EndBenignMalloc();
7122271451
#endif
71223
- for(pc=p->pc; rc==SQLITE_OK; pc++){
71224
- assert( pc>=0 && pc<p->nOp );
71452
+ for(pOp=&aOp[p->pc]; rc==SQLITE_OK; pOp++){
71453
+ assert( pOp>=aOp && pOp<&aOp[p->nOp]);
7122571454
if( db->mallocFailed ) goto no_mem;
7122671455
#ifdef VDBE_PROFILE
7122771456
start = sqlite3Hwtime();
7122871457
#endif
7122971458
nVmStep++;
71230
- pOp = &aOp[pc];
7123171459
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
71232
- if( p->anExec ) p->anExec[pc]++;
71460
+ if( p->anExec ) p->anExec[(int)(pOp-aOp)]++;
7123371461
#endif
7123471462
7123571463
/* Only allow tracing if SQLITE_DEBUG is defined.
7123671464
*/
7123771465
#ifdef SQLITE_DEBUG
7123871466
if( db->flags & SQLITE_VdbeTrace ){
71239
- sqlite3VdbePrintOp(stdout, pc, pOp);
71467
+ sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);
7124071468
}
7124171469
#endif
7124271470
7124371471
7124471472
/* Check to see if we need to simulate an interrupt. This only happens
@@ -71251,27 +71479,13 @@
7125171479
sqlite3_interrupt(db);
7125271480
}
7125371481
}
7125471482
#endif
7125571483
71256
- /* On any opcode with the "out2-prerelease" tag, free any
71257
- ** external allocations out of mem[p2] and set mem[p2] to be
71258
- ** an undefined integer. Opcodes will either fill in the integer
71259
- ** value or convert mem[p2] to a different type.
71260
- */
71261
- assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
71262
- if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
71263
- assert( pOp->p2>0 );
71264
- assert( pOp->p2<=(p->nMem-p->nCursor) );
71265
- pOut = &aMem[pOp->p2];
71266
- memAboutToChange(p, pOut);
71267
- if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
71268
- pOut->flags = MEM_Int;
71269
- }
71270
-
7127171484
/* Sanity checking on other operands */
7127271485
#ifdef SQLITE_DEBUG
71486
+ assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
7127371487
if( (pOp->opflags & OPFLG_IN1)!=0 ){
7127471488
assert( pOp->p1>0 );
7127571489
assert( pOp->p1<=(p->nMem-p->nCursor) );
7127671490
assert( memIsValid(&aMem[pOp->p1]) );
7127771491
assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );
@@ -71300,10 +71514,13 @@
7130071514
assert( pOp->p3>0 );
7130171515
assert( pOp->p3<=(p->nMem-p->nCursor) );
7130271516
memAboutToChange(p, &aMem[pOp->p3]);
7130371517
}
7130471518
#endif
71519
+#if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
71520
+ pOrigOp = pOp;
71521
+#endif
7130571522
7130671523
switch( pOp->opcode ){
7130771524
7130871525
/*****************************************************************************
7130971526
** What follows is a massive switch statement where each case implements a
@@ -71323,11 +71540,11 @@
7132371540
** case statement is followed by a comment of the form "/# same as ... #/"
7132471541
** that comment is used to determine the particular value of the opcode.
7132571542
**
7132671543
** Other keywords in the comment that follows each case are used to
7132771544
** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].
71328
-** Keywords include: in1, in2, in3, out2_prerelease, out2, out3. See
71545
+** Keywords include: in1, in2, in3, out2, out3. See
7132971546
** the mkopcodeh.awk script for additional information.
7133071547
**
7133171548
** Documentation about VDBE opcodes is generated by scanning this file
7133271549
** for lines of that contain "Opcode:". That line and all subsequent
7133371550
** comment lines are used in the generation of the opcode.html documentation
@@ -71351,11 +71568,12 @@
7135171568
** is sometimes set to 1 instead of 0 as a hint to the command-line shell
7135271569
** that this Goto is the bottom of a loop and that the lines from P2 down
7135371570
** to the current line should be indented for EXPLAIN output.
7135471571
*/
7135571572
case OP_Goto: { /* jump */
71356
- pc = pOp->p2 - 1;
71573
+jump_to_p2_and_check_for_interrupt:
71574
+ pOp = &aOp[pOp->p2 - 1];
7135771575
7135871576
/* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,
7135971577
** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon
7136071578
** completion. Check to see if sqlite3_interrupt() has been called
7136171579
** or if the progress callback needs to be invoked.
@@ -71396,13 +71614,17 @@
7139671614
assert( pOp->p1>0 && pOp->p1<=(p->nMem-p->nCursor) );
7139771615
pIn1 = &aMem[pOp->p1];
7139871616
assert( VdbeMemDynamic(pIn1)==0 );
7139971617
memAboutToChange(p, pIn1);
7140071618
pIn1->flags = MEM_Int;
71401
- pIn1->u.i = pc;
71619
+ pIn1->u.i = (int)(pOp-aOp);
7140271620
REGISTER_TRACE(pOp->p1, pIn1);
71403
- pc = pOp->p2 - 1;
71621
+
71622
+ /* Most jump operations do a goto to this spot in order to update
71623
+ ** the pOp pointer. */
71624
+jump_to_p2:
71625
+ pOp = &aOp[pOp->p2 - 1];
7140471626
break;
7140571627
}
7140671628
7140771629
/* Opcode: Return P1 * * * *
7140871630
**
@@ -71410,11 +71632,11 @@
7141071632
** the jump, register P1 becomes undefined.
7141171633
*/
7141271634
case OP_Return: { /* in1 */
7141371635
pIn1 = &aMem[pOp->p1];
7141471636
assert( pIn1->flags==MEM_Int );
71415
- pc = (int)pIn1->u.i;
71637
+ pOp = &aOp[pIn1->u.i];
7141671638
pIn1->flags = MEM_Undefined;
7141771639
break;
7141871640
}
7141971641
7142071642
/* Opcode: InitCoroutine P1 P2 P3 * *
@@ -71434,11 +71656,11 @@
7143471656
assert( pOp->p3>=0 && pOp->p3<p->nOp );
7143571657
pOut = &aMem[pOp->p1];
7143671658
assert( !VdbeMemDynamic(pOut) );
7143771659
pOut->u.i = pOp->p3 - 1;
7143871660
pOut->flags = MEM_Int;
71439
- if( pOp->p2 ) pc = pOp->p2 - 1;
71661
+ if( pOp->p2 ) goto jump_to_p2;
7144071662
break;
7144171663
}
7144271664
7144371665
/* Opcode: EndCoroutine P1 * * * *
7144471666
**
@@ -71454,11 +71676,11 @@
7145471676
assert( pIn1->flags==MEM_Int );
7145571677
assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );
7145671678
pCaller = &aOp[pIn1->u.i];
7145771679
assert( pCaller->opcode==OP_Yield );
7145871680
assert( pCaller->p2>=0 && pCaller->p2<p->nOp );
71459
- pc = pCaller->p2 - 1;
71681
+ pOp = &aOp[pCaller->p2 - 1];
7146071682
pIn1->flags = MEM_Undefined;
7146171683
break;
7146271684
}
7146371685
7146471686
/* Opcode: Yield P1 P2 * * *
@@ -71478,13 +71700,13 @@
7147871700
int pcDest;
7147971701
pIn1 = &aMem[pOp->p1];
7148071702
assert( VdbeMemDynamic(pIn1)==0 );
7148171703
pIn1->flags = MEM_Int;
7148271704
pcDest = (int)pIn1->u.i;
71483
- pIn1->u.i = pc;
71705
+ pIn1->u.i = (int)(pOp - aOp);
7148471706
REGISTER_TRACE(pOp->p1, pIn1);
71485
- pc = pcDest;
71707
+ pOp = &aOp[pcDest];
7148671708
break;
7148771709
}
7148871710
7148971711
/* Opcode: HaltIfNull P1 P2 P3 P4 P5
7149071712
** Synopsis: if r[P3]=null halt
@@ -71531,34 +71753,38 @@
7153171753
** is the same as executing Halt.
7153271754
*/
7153371755
case OP_Halt: {
7153471756
const char *zType;
7153571757
const char *zLogFmt;
71758
+ VdbeFrame *pFrame;
71759
+ int pcx;
7153671760
71761
+ pcx = (int)(pOp - aOp);
7153771762
if( pOp->p1==SQLITE_OK && p->pFrame ){
7153871763
/* Halt the sub-program. Return control to the parent frame. */
71539
- VdbeFrame *pFrame = p->pFrame;
71764
+ pFrame = p->pFrame;
7154071765
p->pFrame = pFrame->pParent;
7154171766
p->nFrame--;
7154271767
sqlite3VdbeSetChanges(db, p->nChange);
71543
- pc = sqlite3VdbeFrameRestore(pFrame);
71768
+ pcx = sqlite3VdbeFrameRestore(pFrame);
7154471769
lastRowid = db->lastRowid;
7154571770
if( pOp->p2==OE_Ignore ){
71546
- /* Instruction pc is the OP_Program that invoked the sub-program
71771
+ /* Instruction pcx is the OP_Program that invoked the sub-program
7154771772
** currently being halted. If the p2 instruction of this OP_Halt
7154871773
** instruction is set to OE_Ignore, then the sub-program is throwing
7154971774
** an IGNORE exception. In this case jump to the address specified
7155071775
** as the p2 of the calling OP_Program. */
71551
- pc = p->aOp[pc].p2-1;
71776
+ pcx = p->aOp[pcx].p2-1;
7155271777
}
7155371778
aOp = p->aOp;
7155471779
aMem = p->aMem;
71780
+ pOp = &aOp[pcx];
7155571781
break;
7155671782
}
7155771783
p->rc = pOp->p1;
7155871784
p->errorAction = (u8)pOp->p2;
71559
- p->pc = pc;
71785
+ p->pc = pcx;
7156071786
if( p->rc ){
7156171787
if( pOp->p5 ){
7156271788
static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK",
7156371789
"FOREIGN KEY" };
7156471790
assert( pOp->p5>=1 && pOp->p5<=4 );
@@ -71578,11 +71804,11 @@
7157871804
}else if( pOp->p4.z ){
7157971805
sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
7158071806
}else{
7158171807
sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType);
7158271808
}
71583
- sqlite3_log(pOp->p1, zLogFmt, pc, p->zSql, p->zErrMsg);
71809
+ sqlite3_log(pOp->p1, zLogFmt, pcx, p->zSql, p->zErrMsg);
7158471810
}
7158571811
rc = sqlite3VdbeHalt(p);
7158671812
assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
7158771813
if( rc==SQLITE_BUSY ){
7158871814
p->rc = rc = SQLITE_BUSY;
@@ -71597,11 +71823,12 @@
7159771823
/* Opcode: Integer P1 P2 * * *
7159871824
** Synopsis: r[P2]=P1
7159971825
**
7160071826
** The 32-bit integer value P1 is written into register P2.
7160171827
*/
71602
-case OP_Integer: { /* out2-prerelease */
71828
+case OP_Integer: { /* out2 */
71829
+ pOut = out2Prerelease(p, pOp);
7160371830
pOut->u.i = pOp->p1;
7160471831
break;
7160571832
}
7160671833
7160771834
/* Opcode: Int64 * P2 * P4 *
@@ -71608,11 +71835,12 @@
7160871835
** Synopsis: r[P2]=P4
7160971836
**
7161071837
** P4 is a pointer to a 64-bit integer value.
7161171838
** Write that value into register P2.
7161271839
*/
71613
-case OP_Int64: { /* out2-prerelease */
71840
+case OP_Int64: { /* out2 */
71841
+ pOut = out2Prerelease(p, pOp);
7161471842
assert( pOp->p4.pI64!=0 );
7161571843
pOut->u.i = *pOp->p4.pI64;
7161671844
break;
7161771845
}
7161871846
@@ -71621,11 +71849,12 @@
7162171849
** Synopsis: r[P2]=P4
7162271850
**
7162371851
** P4 is a pointer to a 64-bit floating point value.
7162471852
** Write that value into register P2.
7162571853
*/
71626
-case OP_Real: { /* same as TK_FLOAT, out2-prerelease */
71854
+case OP_Real: { /* same as TK_FLOAT, out2 */
71855
+ pOut = out2Prerelease(p, pOp);
7162771856
pOut->flags = MEM_Real;
7162871857
assert( !sqlite3IsNaN(*pOp->p4.pReal) );
7162971858
pOut->u.r = *pOp->p4.pReal;
7163071859
break;
7163171860
}
@@ -71637,12 +71866,13 @@
7163771866
** P4 points to a nul terminated UTF-8 string. This opcode is transformed
7163871867
** into a String opcode before it is executed for the first time. During
7163971868
** this transformation, the length of string P4 is computed and stored
7164071869
** as the P1 parameter.
7164171870
*/
71642
-case OP_String8: { /* same as TK_STRING, out2-prerelease */
71871
+case OP_String8: { /* same as TK_STRING, out2 */
7164371872
assert( pOp->p4.z!=0 );
71873
+ pOut = out2Prerelease(p, pOp);
7164471874
pOp->opcode = OP_String;
7164571875
pOp->p1 = sqlite3Strlen30(pOp->p4.z);
7164671876
7164771877
#ifndef SQLITE_OMIT_UTF16
7164871878
if( encoding!=SQLITE_UTF8 ){
@@ -71675,12 +71905,13 @@
7167571905
** If P5!=0 and the content of register P3 is greater than zero, then
7167671906
** the datatype of the register P2 is converted to BLOB. The content is
7167771907
** the same sequence of bytes, it is merely interpreted as a BLOB instead
7167871908
** of a string, as if it had been CAST.
7167971909
*/
71680
-case OP_String: { /* out2-prerelease */
71910
+case OP_String: { /* out2 */
7168171911
assert( pOp->p4.z!=0 );
71912
+ pOut = out2Prerelease(p, pOp);
7168271913
pOut->flags = MEM_Str|MEM_Static|MEM_Term;
7168371914
pOut->z = pOp->p4.z;
7168471915
pOut->n = pOp->p1;
7168571916
pOut->enc = encoding;
7168671917
UPDATE_MAX_BLOBSIZE(pOut);
@@ -71704,13 +71935,14 @@
7170471935
**
7170571936
** If the P1 value is non-zero, then also set the MEM_Cleared flag so that
7170671937
** NULL values will not compare equal even if SQLITE_NULLEQ is set on
7170771938
** OP_Ne or OP_Eq.
7170871939
*/
71709
-case OP_Null: { /* out2-prerelease */
71940
+case OP_Null: { /* out2 */
7171071941
int cnt;
7171171942
u16 nullFlag;
71943
+ pOut = out2Prerelease(p, pOp);
7171271944
cnt = pOp->p3-pOp->p2;
7171371945
assert( pOp->p3<=(p->nMem-p->nCursor) );
7171471946
pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
7171571947
while( cnt>0 ){
7171671948
pOut++;
@@ -71741,12 +71973,13 @@
7174171973
** Synopsis: r[P2]=P4 (len=P1)
7174271974
**
7174371975
** P4 points to a blob of data P1 bytes long. Store this
7174471976
** blob in register P2.
7174571977
*/
71746
-case OP_Blob: { /* out2-prerelease */
71978
+case OP_Blob: { /* out2 */
7174771979
assert( pOp->p1 <= SQLITE_MAX_LENGTH );
71980
+ pOut = out2Prerelease(p, pOp);
7174871981
sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
7174971982
pOut->enc = encoding;
7175071983
UPDATE_MAX_BLOBSIZE(pOut);
7175171984
break;
7175271985
}
@@ -71757,19 +71990,20 @@
7175771990
** Transfer the values of bound parameter P1 into register P2
7175871991
**
7175971992
** If the parameter is named, then its name appears in P4.
7176071993
** The P4 value is used by sqlite3_bind_parameter_name().
7176171994
*/
71762
-case OP_Variable: { /* out2-prerelease */
71995
+case OP_Variable: { /* out2 */
7176371996
Mem *pVar; /* Value being transferred */
7176471997
7176571998
assert( pOp->p1>0 && pOp->p1<=p->nVar );
7176671999
assert( pOp->p4.z==0 || pOp->p4.z==p->azVar[pOp->p1-1] );
7176772000
pVar = &p->aVar[pOp->p1 - 1];
7176872001
if( sqlite3VdbeMemTooBig(pVar) ){
7176972002
goto too_big;
7177072003
}
72004
+ pOut = out2Prerelease(p, pOp);
7177172005
sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
7177272006
UPDATE_MAX_BLOBSIZE(pOut);
7177372007
break;
7177472008
}
7177572009
@@ -71800,14 +72034,15 @@
7180072034
assert( pIn1<=&aMem[(p->nMem-p->nCursor)] );
7180172035
assert( memIsValid(pIn1) );
7180272036
memAboutToChange(p, pOut);
7180372037
sqlite3VdbeMemMove(pOut, pIn1);
7180472038
#ifdef SQLITE_DEBUG
71805
- if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<&aMem[p1+pOp->p3] ){
71806
- pOut->pScopyFrom += p1 - pOp->p2;
72039
+ if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<pOut ){
72040
+ pOut->pScopyFrom += pOp->p2 - p1;
7180772041
}
7180872042
#endif
72043
+ Deephemeralize(pOut);
7180972044
REGISTER_TRACE(p2++, pOut);
7181072045
pIn1++;
7181172046
pOut++;
7181272047
}while( --n );
7181372048
break;
@@ -71942,11 +72177,11 @@
7194272177
}
7194372178
if( db->mallocFailed ) goto no_mem;
7194472179
7194572180
/* Return SQLITE_ROW
7194672181
*/
71947
- p->pc = pc + 1;
72182
+ p->pc = (int)(pOp - aOp) + 1;
7194872183
rc = SQLITE_ROW;
7194972184
goto vdbe_return;
7195072185
}
7195172186
7195272187
/* Opcode: Concat P1 P2 P3 * *
@@ -72188,11 +72423,11 @@
7218872423
REGISTER_TRACE(pOp->p2+i, pArg);
7218972424
}
7219072425
7219172426
assert( pOp->p4type==P4_FUNCDEF );
7219272427
ctx.pFunc = pOp->p4.pFunc;
72193
- ctx.iOp = pc;
72428
+ ctx.iOp = (int)(pOp - aOp);
7219472429
ctx.pVdbe = p;
7219572430
MemSetTypeFlag(ctx.pOut, MEM_Null);
7219672431
ctx.fErrorOrAux = 0;
7219772432
db->lastRowid = lastRowid;
7219872433
(*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
@@ -72202,11 +72437,11 @@
7220272437
if( ctx.fErrorOrAux ){
7220372438
if( ctx.isError ){
7220472439
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(ctx.pOut));
7220572440
rc = ctx.isError;
7220672441
}
72207
- sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
72442
+ sqlite3VdbeDeleteAuxData(p, (int)(pOp - aOp), pOp->p1);
7220872443
}
7220972444
7221072445
/* Copy the result of the function into register P3 */
7221172446
sqlite3VdbeChangeEncoding(ctx.pOut, encoding);
7221272447
if( sqlite3VdbeMemTooBig(ctx.pOut) ){
@@ -72331,12 +72566,11 @@
7233172566
if( (pIn1->flags & MEM_Int)==0 ){
7233272567
if( pOp->p2==0 ){
7233372568
rc = SQLITE_MISMATCH;
7233472569
goto abort_due_to_error;
7233572570
}else{
72336
- pc = pOp->p2 - 1;
72337
- break;
72571
+ goto jump_to_p2;
7233872572
}
7233972573
}
7234072574
}
7234172575
MemSetTypeFlag(pIn1, MEM_Int);
7234272576
break;
@@ -72518,11 +72752,11 @@
7251872752
MemSetTypeFlag(pOut, MEM_Null);
7251972753
REGISTER_TRACE(pOp->p2, pOut);
7252072754
}else{
7252172755
VdbeBranchTaken(2,3);
7252272756
if( pOp->p5 & SQLITE_JUMPIFNULL ){
72523
- pc = pOp->p2-1;
72757
+ goto jump_to_p2;
7252472758
}
7252572759
}
7252672760
break;
7252772761
}
7252872762
}else{
@@ -72538,15 +72772,19 @@
7253872772
}else if( affinity==SQLITE_AFF_TEXT ){
7253972773
if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
7254072774
testcase( pIn1->flags & MEM_Int );
7254172775
testcase( pIn1->flags & MEM_Real );
7254272776
sqlite3VdbeMemStringify(pIn1, encoding, 1);
72777
+ testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
72778
+ flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
7254372779
}
7254472780
if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
7254572781
testcase( pIn3->flags & MEM_Int );
7254672782
testcase( pIn3->flags & MEM_Real );
7254772783
sqlite3VdbeMemStringify(pIn3, encoding, 1);
72784
+ testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
72785
+ flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
7254872786
}
7254972787
}
7255072788
assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
7255172789
if( pIn1->flags & MEM_Zero ){
7255272790
sqlite3VdbeMemExpandBlob(pIn1);
@@ -72565,10 +72803,16 @@
7256572803
case OP_Lt: res = res<0; break;
7256672804
case OP_Le: res = res<=0; break;
7256772805
case OP_Gt: res = res>0; break;
7256872806
default: res = res>=0; break;
7256972807
}
72808
+
72809
+ /* Undo any changes made by applyAffinity() to the input registers. */
72810
+ assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
72811
+ pIn1->flags = flags1;
72812
+ assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
72813
+ pIn3->flags = flags3;
7257072814
7257172815
if( pOp->p5 & SQLITE_STOREP2 ){
7257272816
pOut = &aMem[pOp->p2];
7257372817
memAboutToChange(p, pOut);
7257472818
MemSetTypeFlag(pOut, MEM_Int);
@@ -72575,16 +72819,13 @@
7257572819
pOut->u.i = res;
7257672820
REGISTER_TRACE(pOp->p2, pOut);
7257772821
}else{
7257872822
VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
7257972823
if( res ){
72580
- pc = pOp->p2-1;
72824
+ goto jump_to_p2;
7258172825
}
7258272826
}
72583
- /* Undo any changes made by applyAffinity() to the input registers. */
72584
- pIn1->flags = flags1;
72585
- pIn3->flags = flags3;
7258672827
break;
7258772828
}
7258872829
7258972830
/* Opcode: Permutation * * * P4 *
7259072831
**
@@ -72675,15 +72916,15 @@
7267572916
** in the most recent OP_Compare instruction the P1 vector was less than
7267672917
** equal to, or greater than the P2 vector, respectively.
7267772918
*/
7267872919
case OP_Jump: { /* jump */
7267972920
if( iCompare<0 ){
72680
- pc = pOp->p1 - 1; VdbeBranchTaken(0,3);
72921
+ VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];
7268172922
}else if( iCompare==0 ){
72682
- pc = pOp->p2 - 1; VdbeBranchTaken(1,3);
72923
+ VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];
7268372924
}else{
72684
- pc = pOp->p3 - 1; VdbeBranchTaken(2,3);
72925
+ VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];
7268572926
}
7268672927
break;
7268772928
}
7268872929
7268972930
/* Opcode: And P1 P2 P3 * *
@@ -72789,11 +73030,11 @@
7278973030
*/
7279073031
case OP_Once: { /* jump */
7279173032
assert( pOp->p1<p->nOnceFlag );
7279273033
VdbeBranchTaken(p->aOnceFlag[pOp->p1]!=0, 2);
7279373034
if( p->aOnceFlag[pOp->p1] ){
72794
- pc = pOp->p2-1;
73035
+ goto jump_to_p2;
7279573036
}else{
7279673037
p->aOnceFlag[pOp->p1] = 1;
7279773038
}
7279873039
break;
7279973040
}
@@ -72824,11 +73065,11 @@
7282473065
#endif
7282573066
if( pOp->opcode==OP_IfNot ) c = !c;
7282673067
}
7282773068
VdbeBranchTaken(c!=0, 2);
7282873069
if( c ){
72829
- pc = pOp->p2-1;
73070
+ goto jump_to_p2;
7283073071
}
7283173072
break;
7283273073
}
7283373074
7283473075
/* Opcode: IsNull P1 P2 * * *
@@ -72838,11 +73079,11 @@
7283873079
*/
7283973080
case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
7284073081
pIn1 = &aMem[pOp->p1];
7284173082
VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);
7284273083
if( (pIn1->flags & MEM_Null)!=0 ){
72843
- pc = pOp->p2 - 1;
73084
+ goto jump_to_p2;
7284473085
}
7284573086
break;
7284673087
}
7284773088
7284873089
/* Opcode: NotNull P1 P2 * * *
@@ -72852,11 +73093,11 @@
7285273093
*/
7285373094
case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */
7285473095
pIn1 = &aMem[pOp->p1];
7285573096
VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);
7285673097
if( (pIn1->flags & MEM_Null)==0 ){
72857
- pc = pOp->p2 - 1;
73098
+ goto jump_to_p2;
7285873099
}
7285973100
break;
7286073101
}
7286173102
7286273103
/* Opcode: Column P1 P2 P3 P4 P5
@@ -73066,11 +73307,11 @@
7306673307
rc = SQLITE_CORRUPT_BKPT;
7306773308
goto op_column_error;
7306873309
}
7306973310
}
7307073311
73071
- /* If after trying to extra new entries from the header, nHdrParsed is
73312
+ /* If after trying to extract new entries from the header, nHdrParsed is
7307273313
** still not up to p2, that means that the record has fewer than p2
7307373314
** columns. So the result will be either the default value or a NULL.
7307473315
*/
7307573316
if( pC->nHdrParsed<=p2 ){
7307673317
if( pOp->p4type==P4_MEM ){
@@ -73190,11 +73431,11 @@
7319073431
u8 *zNewRecord; /* A buffer to hold the data for the new record */
7319173432
Mem *pRec; /* The new record */
7319273433
u64 nData; /* Number of bytes of data space */
7319373434
int nHdr; /* Number of bytes of header space */
7319473435
i64 nByte; /* Data space required for this record */
73195
- int nZero; /* Number of zero bytes at the end of the record */
73436
+ i64 nZero; /* Number of zero bytes at the end of the record */
7319673437
int nVarint; /* Number of bytes in a varint */
7319773438
u32 serial_type; /* Type field */
7319873439
Mem *pData0; /* First field to be combined into the record */
7319973440
Mem *pLast; /* Last field of the record */
7320073441
int nField; /* Number of fields in the record */
@@ -73282,11 +73523,11 @@
7328273523
nVarint = sqlite3VarintLen(nHdr);
7328373524
nHdr += nVarint;
7328473525
if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
7328573526
}
7328673527
nByte = nHdr+nData;
73287
- if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
73528
+ if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
7328873529
goto too_big;
7328973530
}
7329073531
7329173532
/* Make sure the output register has a buffer large enough to store
7329273533
** the new record. The output register (pOp->p3) is not allowed to
@@ -73333,18 +73574,19 @@
7333373574
**
7333473575
** Store the number of entries (an integer value) in the table or index
7333573576
** opened by cursor P1 in register P2
7333673577
*/
7333773578
#ifndef SQLITE_OMIT_BTREECOUNT
73338
-case OP_Count: { /* out2-prerelease */
73579
+case OP_Count: { /* out2 */
7333973580
i64 nEntry;
7334073581
BtCursor *pCrsr;
7334173582
7334273583
pCrsr = p->apCsr[pOp->p1]->pCursor;
7334373584
assert( pCrsr );
7334473585
nEntry = 0; /* Not needed. Only used to silence a warning. */
7334573586
rc = sqlite3BtreeCount(pCrsr, &nEntry);
73587
+ pOut = out2Prerelease(p, pOp);
7334673588
pOut->u.i = nEntry;
7334773589
break;
7334873590
}
7334973591
#endif
7335073592
@@ -73454,11 +73696,11 @@
7345473696
if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
7345573697
goto vdbe_return;
7345673698
}
7345773699
db->autoCommit = 1;
7345873700
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73459
- p->pc = pc;
73701
+ p->pc = (int)(pOp - aOp);
7346073702
db->autoCommit = 0;
7346173703
p->rc = rc = SQLITE_BUSY;
7346273704
goto vdbe_return;
7346373705
}
7346473706
db->isTransactionSavepoint = 0;
@@ -73513,11 +73755,11 @@
7351373755
}else{
7351473756
db->nDeferredCons = pSavepoint->nDeferredCons;
7351573757
db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
7351673758
}
7351773759
73518
- if( !isTransaction ){
73760
+ if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){
7351973761
rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
7352073762
if( rc!=SQLITE_OK ) goto abort_due_to_error;
7352173763
}
7352273764
}
7352373765
}
@@ -73573,11 +73815,11 @@
7357373815
}else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
7357473816
goto vdbe_return;
7357573817
}else{
7357673818
db->autoCommit = (u8)desiredAutoCommit;
7357773819
if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73578
- p->pc = pc;
73820
+ p->pc = (int)(pOp - aOp);
7357973821
db->autoCommit = (u8)(1-desiredAutoCommit);
7358073822
p->rc = rc = SQLITE_BUSY;
7358173823
goto vdbe_return;
7358273824
}
7358373825
}
@@ -73650,11 +73892,11 @@
7365073892
pBt = db->aDb[pOp->p1].pBt;
7365173893
7365273894
if( pBt ){
7365373895
rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
7365473896
if( rc==SQLITE_BUSY ){
73655
- p->pc = pc;
73897
+ p->pc = (int)(pOp - aOp);
7365673898
p->rc = rc = SQLITE_BUSY;
7365773899
goto vdbe_return;
7365873900
}
7365973901
if( rc!=SQLITE_OK ){
7366073902
goto abort_due_to_error;
@@ -73729,11 +73971,11 @@
7372973971
**
7373073972
** There must be a read-lock on the database (either a transaction
7373173973
** must be started or there must be an open cursor) before
7373273974
** executing this instruction.
7373373975
*/
73734
-case OP_ReadCookie: { /* out2-prerelease */
73976
+case OP_ReadCookie: { /* out2 */
7373573977
int iMeta;
7373673978
int iDb;
7373773979
int iCookie;
7373873980
7373973981
assert( p->bIsReader );
@@ -73743,10 +73985,11 @@
7374373985
assert( iDb>=0 && iDb<db->nDb );
7374473986
assert( db->aDb[iDb].pBt!=0 );
7374573987
assert( DbMaskTest(p->btreeMask, iDb) );
7374673988
7374773989
sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);
73990
+ pOut = out2Prerelease(p, pOp);
7374873991
pOut->u.i = iMeta;
7374973992
break;
7375073993
}
7375173994
7375273995
/* Opcode: SetCookie P1 P2 P3 * *
@@ -74064,11 +74307,11 @@
7406474307
VdbeCursor *pC;
7406574308
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
7406674309
pC = p->apCsr[pOp->p1];
7406774310
assert( pC->pSorter );
7406874311
if( (pC->seqCount++)==0 ){
74069
- pc = pOp->p2 - 1;
74312
+ goto jump_to_p2;
7407074313
}
7407174314
break;
7407274315
}
7407374316
7407474317
/* Opcode: OpenPseudo P1 P2 P3 * *
@@ -74241,11 +74484,11 @@
7424174484
** loss of information, then special processing is required... */
7424274485
if( (pIn3->flags & MEM_Int)==0 ){
7424374486
if( (pIn3->flags & MEM_Real)==0 ){
7424474487
/* If the P3 value cannot be converted into any kind of a number,
7424574488
** then the seek is not possible, so jump to P2 */
74246
- pc = pOp->p2 - 1; VdbeBranchTaken(1,2);
74489
+ VdbeBranchTaken(1,2); goto jump_to_p2;
7424774490
break;
7424874491
}
7424974492
7425074493
/* If the approximation iKey is larger than the actual real search
7425174494
** term, substitute >= for > and < for <=. e.g. if the search term
@@ -74332,11 +74575,11 @@
7433274575
}
7433374576
}
7433474577
assert( pOp->p2>0 );
7433574578
VdbeBranchTaken(res!=0,2);
7433674579
if( res ){
74337
- pc = pOp->p2 - 1;
74580
+ goto jump_to_p2;
7433874581
}
7433974582
break;
7434074583
}
7434174584
7434274585
/* Opcode: Seek P1 P2 * * *
@@ -74426,10 +74669,11 @@
7442674669
*/
7442774670
case OP_NoConflict: /* jump, in3 */
7442874671
case OP_NotFound: /* jump, in3 */
7442974672
case OP_Found: { /* jump, in3 */
7443074673
int alreadyExists;
74674
+ int takeJump;
7443174675
int ii;
7443274676
VdbeCursor *pC;
7443374677
int res;
7443474678
char *pFree;
7443574679
UnpackedRecord *pIdxKey;
@@ -74448,11 +74692,11 @@
7444874692
pC->seekOp = pOp->opcode;
7444974693
#endif
7445074694
pIn3 = &aMem[pOp->p3];
7445174695
assert( pC->pCursor!=0 );
7445274696
assert( pC->isTable==0 );
74453
- pFree = 0; /* Not needed. Only used to suppress a compiler warning. */
74697
+ pFree = 0;
7445474698
if( pOp->p4.i>0 ){
7445574699
r.pKeyInfo = pC->pKeyInfo;
7445674700
r.nField = (u16)pOp->p4.i;
7445774701
r.aMem = pIn3;
7445874702
for(ii=0; ii<r.nField; ii++){
@@ -74471,25 +74715,24 @@
7447174715
assert( pIn3->flags & MEM_Blob );
7447274716
ExpandBlob(pIn3);
7447374717
sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
7447474718
}
7447574719
pIdxKey->default_rc = 0;
74720
+ takeJump = 0;
7447674721
if( pOp->opcode==OP_NoConflict ){
7447774722
/* For the OP_NoConflict opcode, take the jump if any of the
7447874723
** input fields are NULL, since any key with a NULL will not
7447974724
** conflict */
7448074725
for(ii=0; ii<pIdxKey->nField; ii++){
7448174726
if( pIdxKey->aMem[ii].flags & MEM_Null ){
74482
- pc = pOp->p2 - 1; VdbeBranchTaken(1,2);
74727
+ takeJump = 1;
7448374728
break;
7448474729
}
7448574730
}
7448674731
}
7448774732
rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res);
74488
- if( pOp->p4.i==0 ){
74489
- sqlite3DbFree(db, pFree);
74490
- }
74733
+ sqlite3DbFree(db, pFree);
7449174734
if( rc!=SQLITE_OK ){
7449274735
break;
7449374736
}
7449474737
pC->seekResult = res;
7449574738
alreadyExists = (res==0);
@@ -74496,14 +74739,14 @@
7449674739
pC->nullRow = 1-alreadyExists;
7449774740
pC->deferredMoveto = 0;
7449874741
pC->cacheStatus = CACHE_STALE;
7449974742
if( pOp->opcode==OP_Found ){
7450074743
VdbeBranchTaken(alreadyExists!=0,2);
74501
- if( alreadyExists ) pc = pOp->p2 - 1;
74744
+ if( alreadyExists ) goto jump_to_p2;
7450274745
}else{
74503
- VdbeBranchTaken(alreadyExists==0,2);
74504
- if( !alreadyExists ) pc = pOp->p2 - 1;
74746
+ VdbeBranchTaken(takeJump||alreadyExists==0,2);
74747
+ if( takeJump || !alreadyExists ) goto jump_to_p2;
7450574748
}
7450674749
break;
7450774750
}
7450874751
7450974752
/* Opcode: NotExists P1 P2 P3 * *
@@ -74548,14 +74791,12 @@
7454874791
pC->movetoTarget = iKey; /* Used by OP_Delete */
7454974792
pC->nullRow = 0;
7455074793
pC->cacheStatus = CACHE_STALE;
7455174794
pC->deferredMoveto = 0;
7455274795
VdbeBranchTaken(res!=0,2);
74553
- if( res!=0 ){
74554
- pc = pOp->p2 - 1;
74555
- }
7455674796
pC->seekResult = res;
74797
+ if( res!=0 ) goto jump_to_p2;
7455774798
break;
7455874799
}
7455974800
7456074801
/* Opcode: Sequence P1 P2 * * *
7456174802
** Synopsis: r[P2]=cursor[P1].ctr++
@@ -74563,13 +74804,14 @@
7456374804
** Find the next available sequence number for cursor P1.
7456474805
** Write the sequence number into register P2.
7456574806
** The sequence number on the cursor is incremented after this
7456674807
** instruction.
7456774808
*/
74568
-case OP_Sequence: { /* out2-prerelease */
74809
+case OP_Sequence: { /* out2 */
7456974810
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
7457074811
assert( p->apCsr[pOp->p1]!=0 );
74812
+ pOut = out2Prerelease(p, pOp);
7457174813
pOut->u.i = p->apCsr[pOp->p1]->seqCount++;
7457274814
break;
7457374815
}
7457474816
7457574817
@@ -74586,20 +74828,21 @@
7458674828
** allowed to be less than this value. When this value reaches its maximum,
7458774829
** an SQLITE_FULL error is generated. The P3 register is updated with the '
7458874830
** generated record number. This P3 mechanism is used to help implement the
7458974831
** AUTOINCREMENT feature.
7459074832
*/
74591
-case OP_NewRowid: { /* out2-prerelease */
74833
+case OP_NewRowid: { /* out2 */
7459274834
i64 v; /* The new rowid */
7459374835
VdbeCursor *pC; /* Cursor of table to get the new rowid */
7459474836
int res; /* Result of an sqlite3BtreeLast() */
7459574837
int cnt; /* Counter to limit the number of searches */
7459674838
Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
7459774839
VdbeFrame *pFrame; /* Root frame of VDBE */
7459874840
7459974841
v = 0;
7460074842
res = 0;
74843
+ pOut = out2Prerelease(p, pOp);
7460174844
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
7460274845
pC = p->apCsr[pOp->p1];
7460374846
assert( pC!=0 );
7460474847
if( NEVER(pC->pCursor==0) ){
7460574848
/* The zero initialization above is all that is needed */
@@ -74909,13 +75152,11 @@
7490975152
pIn3 = &aMem[pOp->p3];
7491075153
nKeyCol = pOp->p4.i;
7491175154
res = 0;
7491275155
rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);
7491375156
VdbeBranchTaken(res!=0,2);
74914
- if( res ){
74915
- pc = pOp->p2-1;
74916
- }
75157
+ if( res ) goto jump_to_p2;
7491775158
break;
7491875159
};
7491975160
7492075161
/* Opcode: SorterData P1 P2 P3 * *
7492175162
** Synopsis: r[P2]=data
@@ -75040,16 +75281,17 @@
7504075281
**
7504175282
** P1 can be either an ordinary table or a virtual table. There used to
7504275283
** be a separate OP_VRowid opcode for use with virtual tables, but this
7504375284
** one opcode now works for both table types.
7504475285
*/
75045
-case OP_Rowid: { /* out2-prerelease */
75286
+case OP_Rowid: { /* out2 */
7504675287
VdbeCursor *pC;
7504775288
i64 v;
7504875289
sqlite3_vtab *pVtab;
7504975290
const sqlite3_module *pModule;
7505075291
75292
+ pOut = out2Prerelease(p, pOp);
7505175293
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
7505275294
pC = p->apCsr[pOp->p1];
7505375295
assert( pC!=0 );
7505475296
assert( pC->pseudoTableReg==0 || pC->nullRow );
7505575297
if( pC->nullRow ){
@@ -75098,11 +75340,11 @@
7509875340
sqlite3BtreeClearCursor(pC->pCursor);
7509975341
}
7510075342
break;
7510175343
}
7510275344
75103
-/* Opcode: Last P1 P2 * * *
75345
+/* Opcode: Last P1 P2 P3 * *
7510475346
**
7510575347
** The next use of the Rowid or Column or Prev instruction for P1
7510675348
** will refer to the last entry in the database table or index.
7510775349
** If the table or index is empty and P2>0, then jump immediately to P2.
7510875350
** If P2 is 0 or if the table or index is not empty, fall through
@@ -75125,16 +75367,17 @@
7512575367
assert( pCrsr!=0 );
7512675368
rc = sqlite3BtreeLast(pCrsr, &res);
7512775369
pC->nullRow = (u8)res;
7512875370
pC->deferredMoveto = 0;
7512975371
pC->cacheStatus = CACHE_STALE;
75372
+ pC->seekResult = pOp->p3;
7513075373
#ifdef SQLITE_DEBUG
7513175374
pC->seekOp = OP_Last;
7513275375
#endif
7513375376
if( pOp->p2>0 ){
7513475377
VdbeBranchTaken(res!=0,2);
75135
- if( res ) pc = pOp->p2 - 1;
75378
+ if( res ) goto jump_to_p2;
7513675379
}
7513775380
break;
7513875381
}
7513975382
7514075383
@@ -75194,13 +75437,11 @@
7519475437
pC->cacheStatus = CACHE_STALE;
7519575438
}
7519675439
pC->nullRow = (u8)res;
7519775440
assert( pOp->p2>0 && pOp->p2<p->nOp );
7519875441
VdbeBranchTaken(res!=0,2);
75199
- if( res ){
75200
- pc = pOp->p2 - 1;
75201
- }
75442
+ if( res ) goto jump_to_p2;
7520275443
break;
7520375444
}
7520475445
7520575446
/* Opcode: Next P1 P2 P3 P4 P5
7520675447
**
@@ -75307,15 +75548,15 @@
7530775548
next_tail:
7530875549
pC->cacheStatus = CACHE_STALE;
7530975550
VdbeBranchTaken(res==0,2);
7531075551
if( res==0 ){
7531175552
pC->nullRow = 0;
75312
- pc = pOp->p2 - 1;
7531375553
p->aCounter[pOp->p5]++;
7531475554
#ifdef SQLITE_TEST
7531575555
sqlite3_search_count++;
7531675556
#endif
75557
+ goto jump_to_p2_and_check_for_interrupt;
7531775558
}else{
7531875559
pC->nullRow = 1;
7531975560
}
7532075561
goto check_for_interrupt;
7532175562
}
@@ -75419,15 +75660,16 @@
7541975660
** the end of the index key pointed to by cursor P1. This integer should be
7542075661
** the rowid of the table entry to which this index entry points.
7542175662
**
7542275663
** See also: Rowid, MakeRecord.
7542375664
*/
75424
-case OP_IdxRowid: { /* out2-prerelease */
75665
+case OP_IdxRowid: { /* out2 */
7542575666
BtCursor *pCrsr;
7542675667
VdbeCursor *pC;
7542775668
i64 rowid;
7542875669
75670
+ pOut = out2Prerelease(p, pOp);
7542975671
assert( pOp->p1>=0 && pOp->p1<p->nCursor );
7543075672
pC = p->apCsr[pOp->p1];
7543175673
assert( pC!=0 );
7543275674
pCrsr = pC->pCursor;
7543375675
assert( pCrsr!=0 );
@@ -75536,13 +75778,11 @@
7553675778
}else{
7553775779
assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
7553875780
res++;
7553975781
}
7554075782
VdbeBranchTaken(res>0,2);
75541
- if( res>0 ){
75542
- pc = pOp->p2 - 1 ;
75543
- }
75783
+ if( res>0 ) goto jump_to_p2;
7554475784
break;
7554575785
}
7554675786
7554775787
/* Opcode: Destroy P1 P2 P3 * *
7554875788
**
@@ -75562,15 +75802,16 @@
7556275802
** the last one in the database) then a zero is stored in register P2.
7556375803
** If AUTOVACUUM is disabled then a zero is stored in register P2.
7556475804
**
7556575805
** See also: Clear
7556675806
*/
75567
-case OP_Destroy: { /* out2-prerelease */
75807
+case OP_Destroy: { /* out2 */
7556875808
int iMoved;
7556975809
int iDb;
7557075810
7557175811
assert( p->readOnly==0 );
75812
+ pOut = out2Prerelease(p, pOp);
7557275813
pOut->flags = MEM_Null;
7557375814
if( db->nVdbeRead > db->nVDestroy+1 ){
7557475815
rc = SQLITE_LOCKED;
7557575816
p->errorAction = OE_Abort;
7557675817
}else{
@@ -75675,16 +75916,17 @@
7567575916
** P1>1. Write the root page number of the new table into
7567675917
** register P2.
7567775918
**
7567875919
** See documentation on OP_CreateTable for additional information.
7567975920
*/
75680
-case OP_CreateIndex: /* out2-prerelease */
75681
-case OP_CreateTable: { /* out2-prerelease */
75921
+case OP_CreateIndex: /* out2 */
75922
+case OP_CreateTable: { /* out2 */
7568275923
int pgno;
7568375924
int flags;
7568475925
Db *pDb;
7568575926
75927
+ pOut = out2Prerelease(p, pOp);
7568675928
pgno = 0;
7568775929
assert( pOp->p1>=0 && pOp->p1<db->nDb );
7568875930
assert( DbMaskTest(p->btreeMask, pOp->p1) );
7568975931
assert( p->readOnly==0 );
7569075932
pDb = &db->aDb[pOp->p1];
@@ -75906,16 +76148,16 @@
7590676148
if( (pIn1->flags & MEM_RowSet)==0
7590776149
|| sqlite3RowSetNext(pIn1->u.pRowSet, &val)==0
7590876150
){
7590976151
/* The boolean index is empty */
7591076152
sqlite3VdbeMemSetNull(pIn1);
75911
- pc = pOp->p2 - 1;
7591276153
VdbeBranchTaken(1,2);
76154
+ goto jump_to_p2_and_check_for_interrupt;
7591376155
}else{
7591476156
/* A value was pulled from the index */
75915
- sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);
7591676157
VdbeBranchTaken(0,2);
76158
+ sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);
7591776159
}
7591876160
goto check_for_interrupt;
7591976161
}
7592076162
7592176163
/* Opcode: RowSetTest P1 P2 P3 P4
@@ -75962,14 +76204,11 @@
7596276204
assert( pOp->p4type==P4_INT32 );
7596376205
assert( iSet==-1 || iSet>=0 );
7596476206
if( iSet ){
7596576207
exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i);
7596676208
VdbeBranchTaken(exists!=0,2);
75967
- if( exists ){
75968
- pc = pOp->p2 - 1;
75969
- break;
75970
- }
76209
+ if( exists ) goto jump_to_p2;
7597176210
}
7597276211
if( iSet>=0 ){
7597376212
sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);
7597476213
}
7597576214
break;
@@ -76054,11 +76293,11 @@
7605476293
pRt->u.pFrame = pFrame;
7605576294
7605676295
pFrame->v = p;
7605776296
pFrame->nChildMem = nMem;
7605876297
pFrame->nChildCsr = pProgram->nCsr;
76059
- pFrame->pc = pc;
76298
+ pFrame->pc = (int)(pOp - aOp);
7606076299
pFrame->aMem = p->aMem;
7606176300
pFrame->nMem = p->nMem;
7606276301
pFrame->apCsr = p->apCsr;
7606376302
pFrame->nCursor = p->nCursor;
7606476303
pFrame->aOp = p->aOp;
@@ -76077,11 +76316,11 @@
7607776316
}
7607876317
}else{
7607976318
pFrame = pRt->u.pFrame;
7608076319
assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem );
7608176320
assert( pProgram->nCsr==pFrame->nChildCsr );
76082
- assert( pc==pFrame->pc );
76321
+ assert( (int)(pOp - aOp)==pFrame->pc );
7608376322
}
7608476323
7608576324
p->nFrame++;
7608676325
pFrame->pParent = p->pFrame;
7608776326
pFrame->lastRowid = lastRowid;
@@ -76098,11 +76337,11 @@
7609876337
p->aOnceFlag = (u8 *)&p->apCsr[p->nCursor];
7609976338
p->nOnceFlag = pProgram->nOnce;
7610076339
#ifdef SQLITE_ENABLE_STMT_SCANSTATUS
7610176340
p->anExec = 0;
7610276341
#endif
76103
- pc = -1;
76342
+ pOp = &aOp[-1];
7610476343
memset(p->aOnceFlag, 0, p->nOnceFlag);
7610576344
7610676345
break;
7610776346
}
7610876347
@@ -76116,13 +76355,14 @@
7611676355
**
7611776356
** The address of the cell in the parent frame is determined by adding
7611876357
** the value of the P1 argument to the value of the P1 argument to the
7611976358
** calling OP_Program instruction.
7612076359
*/
76121
-case OP_Param: { /* out2-prerelease */
76360
+case OP_Param: { /* out2 */
7612276361
VdbeFrame *pFrame;
7612376362
Mem *pIn;
76363
+ pOut = out2Prerelease(p, pOp);
7612476364
pFrame = p->pFrame;
7612576365
pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];
7612676366
sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);
7612776367
break;
7612876368
}
@@ -76162,14 +76402,14 @@
7616276402
** (immediate foreign key constraint violations).
7616376403
*/
7616476404
case OP_FkIfZero: { /* jump */
7616576405
if( pOp->p1 ){
7616676406
VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);
76167
- if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1;
76407
+ if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;
7616876408
}else{
7616976409
VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);
76170
- if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1;
76410
+ if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;
7617176411
}
7617276412
break;
7617376413
}
7617476414
#endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
7617576415
@@ -76216,13 +76456,11 @@
7621676456
*/
7621776457
case OP_IfPos: { /* jump, in1 */
7621876458
pIn1 = &aMem[pOp->p1];
7621976459
assert( pIn1->flags&MEM_Int );
7622076460
VdbeBranchTaken( pIn1->u.i>0, 2);
76221
- if( pIn1->u.i>0 ){
76222
- pc = pOp->p2 - 1;
76223
- }
76461
+ if( pIn1->u.i>0 ) goto jump_to_p2;
7622476462
break;
7622576463
}
7622676464
7622776465
/* Opcode: IfNeg P1 P2 P3 * *
7622876466
** Synopsis: r[P1]+=P3, if r[P1]<0 goto P2
@@ -76233,13 +76471,11 @@
7623376471
case OP_IfNeg: { /* jump, in1 */
7623476472
pIn1 = &aMem[pOp->p1];
7623576473
assert( pIn1->flags&MEM_Int );
7623676474
pIn1->u.i += pOp->p3;
7623776475
VdbeBranchTaken(pIn1->u.i<0, 2);
76238
- if( pIn1->u.i<0 ){
76239
- pc = pOp->p2 - 1;
76240
- }
76476
+ if( pIn1->u.i<0 ) goto jump_to_p2;
7624176477
break;
7624276478
}
7624376479
7624476480
/* Opcode: IfNotZero P1 P2 P3 * *
7624576481
** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
@@ -76252,11 +76488,11 @@
7625276488
pIn1 = &aMem[pOp->p1];
7625376489
assert( pIn1->flags&MEM_Int );
7625476490
VdbeBranchTaken(pIn1->u.i<0, 2);
7625576491
if( pIn1->u.i ){
7625676492
pIn1->u.i += pOp->p3;
76257
- pc = pOp->p2 - 1;
76493
+ goto jump_to_p2;
7625876494
}
7625976495
break;
7626076496
}
7626176497
7626276498
/* Opcode: DecrJumpZero P1 P2 * * *
@@ -76268,13 +76504,11 @@
7626876504
case OP_DecrJumpZero: { /* jump, in1 */
7626976505
pIn1 = &aMem[pOp->p1];
7627076506
assert( pIn1->flags&MEM_Int );
7627176507
pIn1->u.i--;
7627276508
VdbeBranchTaken(pIn1->u.i==0, 2);
76273
- if( pIn1->u.i==0 ){
76274
- pc = pOp->p2 - 1;
76275
- }
76509
+ if( pIn1->u.i==0 ) goto jump_to_p2;
7627676510
break;
7627776511
}
7627876512
7627976513
7628076514
/* Opcode: JumpZeroIncr P1 P2 * * *
@@ -76286,13 +76520,11 @@
7628676520
*/
7628776521
case OP_JumpZeroIncr: { /* jump, in1 */
7628876522
pIn1 = &aMem[pOp->p1];
7628976523
assert( pIn1->flags&MEM_Int );
7629076524
VdbeBranchTaken(pIn1->u.i==0, 2);
76291
- if( (pIn1->u.i++)==0 ){
76292
- pc = pOp->p2 - 1;
76293
- }
76525
+ if( (pIn1->u.i++)==0 ) goto jump_to_p2;
7629476526
break;
7629576527
}
7629676528
7629776529
/* Opcode: AggStep * P2 P3 P4 P5
7629876530
** Synopsis: accum=r[P3] step(r[P2@P5])
@@ -76330,11 +76562,11 @@
7633076562
pMem->n++;
7633176563
sqlite3VdbeMemInit(&t, db, MEM_Null);
7633276564
ctx.pOut = &t;
7633376565
ctx.isError = 0;
7633476566
ctx.pVdbe = p;
76335
- ctx.iOp = pc;
76567
+ ctx.iOp = (int)(pOp - aOp);
7633676568
ctx.skipFlag = 0;
7633776569
(ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */
7633876570
if( ctx.isError ){
7633976571
sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&t));
7634076572
rc = ctx.isError;
@@ -76425,19 +76657,20 @@
7642576657
**
7642676658
** If changing into or out of WAL mode the procedure is more complicated.
7642776659
**
7642876660
** Write a string containing the final journal-mode to register P2.
7642976661
*/
76430
-case OP_JournalMode: { /* out2-prerelease */
76662
+case OP_JournalMode: { /* out2 */
7643176663
Btree *pBt; /* Btree to change journal mode of */
7643276664
Pager *pPager; /* Pager associated with pBt */
7643376665
int eNew; /* New journal mode */
7643476666
int eOld; /* The old journal mode */
7643576667
#ifndef SQLITE_OMIT_WAL
7643676668
const char *zFilename; /* Name of database file for pPager */
7643776669
#endif
7643876670
76671
+ pOut = out2Prerelease(p, pOp);
7643976672
eNew = pOp->p3;
7644076673
assert( eNew==PAGER_JOURNALMODE_DELETE
7644176674
|| eNew==PAGER_JOURNALMODE_TRUNCATE
7644276675
|| eNew==PAGER_JOURNALMODE_PERSIST
7644376676
|| eNew==PAGER_JOURNALMODE_OFF
@@ -76509,11 +76742,10 @@
7650976742
if( rc ){
7651076743
eNew = eOld;
7651176744
}
7651276745
eNew = sqlite3PagerSetJournalMode(pPager, eNew);
7651376746
76514
- pOut = &aMem[pOp->p2];
7651576747
pOut->flags = MEM_Str|MEM_Static|MEM_Term;
7651676748
pOut->z = (char *)sqlite3JournalModename(eNew);
7651776749
pOut->n = sqlite3Strlen30(pOut->z);
7651876750
pOut->enc = SQLITE_UTF8;
7651976751
sqlite3VdbeChangeEncoding(pOut, encoding);
@@ -76550,12 +76782,12 @@
7655076782
assert( p->readOnly==0 );
7655176783
pBt = db->aDb[pOp->p1].pBt;
7655276784
rc = sqlite3BtreeIncrVacuum(pBt);
7655376785
VdbeBranchTaken(rc==SQLITE_DONE,2);
7655476786
if( rc==SQLITE_DONE ){
76555
- pc = pOp->p2 - 1;
7655676787
rc = SQLITE_OK;
76788
+ goto jump_to_p2;
7655776789
}
7655876790
break;
7655976791
}
7656076792
#endif
7656176793
@@ -76704,12 +76936,13 @@
7670476936
pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
7670576937
if( pCur ){
7670676938
pCur->pVtabCursor = pVtabCursor;
7670776939
pVtab->nRef++;
7670876940
}else{
76709
- db->mallocFailed = 1;
76941
+ assert( db->mallocFailed );
7671076942
pModule->xClose(pVtabCursor);
76943
+ goto no_mem;
7671176944
}
7671276945
}
7671376946
break;
7671476947
}
7671576948
#endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -76761,29 +76994,23 @@
7676176994
assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );
7676276995
nArg = (int)pArgc->u.i;
7676376996
iQuery = (int)pQuery->u.i;
7676476997
7676576998
/* Invoke the xFilter method */
76766
- {
76767
- res = 0;
76768
- apArg = p->apArg;
76769
- for(i = 0; i<nArg; i++){
76770
- apArg[i] = &pArgc[i+1];
76771
- }
76772
-
76773
- rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
76774
- sqlite3VtabImportErrmsg(p, pVtab);
76775
- if( rc==SQLITE_OK ){
76776
- res = pModule->xEof(pVtabCursor);
76777
- }
76778
- VdbeBranchTaken(res!=0,2);
76779
- if( res ){
76780
- pc = pOp->p2 - 1;
76781
- }
76999
+ res = 0;
77000
+ apArg = p->apArg;
77001
+ for(i = 0; i<nArg; i++){
77002
+ apArg[i] = &pArgc[i+1];
77003
+ }
77004
+ rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
77005
+ sqlite3VtabImportErrmsg(p, pVtab);
77006
+ if( rc==SQLITE_OK ){
77007
+ res = pModule->xEof(pVtabCursor);
7678277008
}
7678377009
pCur->nullRow = 0;
76784
-
77010
+ VdbeBranchTaken(res!=0,2);
77011
+ if( res ) goto jump_to_p2;
7678577012
break;
7678677013
}
7678777014
#endif /* SQLITE_OMIT_VIRTUALTABLE */
7678877015
7678977016
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76866,11 +77093,11 @@
7686677093
res = pModule->xEof(pCur->pVtabCursor);
7686777094
}
7686877095
VdbeBranchTaken(!res,2);
7686977096
if( !res ){
7687077097
/* If there is data, jump to P2 */
76871
- pc = pOp->p2 - 1;
77098
+ goto jump_to_p2_and_check_for_interrupt;
7687277099
}
7687377100
goto check_for_interrupt;
7687477101
}
7687577102
#endif /* SQLITE_OMIT_VIRTUALTABLE */
7687677103
@@ -76989,11 +77216,12 @@
7698977216
#ifndef SQLITE_OMIT_PAGER_PRAGMAS
7699077217
/* Opcode: Pagecount P1 P2 * * *
7699177218
**
7699277219
** Write the current number of pages in database P1 to memory cell P2.
7699377220
*/
76994
-case OP_Pagecount: { /* out2-prerelease */
77221
+case OP_Pagecount: { /* out2 */
77222
+ pOut = out2Prerelease(p, pOp);
7699577223
pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
7699677224
break;
7699777225
}
7699877226
#endif
7699977227
@@ -77005,14 +77233,15 @@
7700577233
** Do not let the maximum page count fall below the current page count and
7700677234
** do not change the maximum page count value if P3==0.
7700777235
**
7700877236
** Store the maximum page count after the change in register P2.
7700977237
*/
77010
-case OP_MaxPgcnt: { /* out2-prerelease */
77238
+case OP_MaxPgcnt: { /* out2 */
7701177239
unsigned int newMax;
7701277240
Btree *pBt;
7701377241
77242
+ pOut = out2Prerelease(p, pOp);
7701477243
pBt = db->aDb[pOp->p1].pBt;
7701577244
newMax = 0;
7701677245
if( pOp->p3 ){
7701777246
newMax = sqlite3BtreeLastPage(pBt);
7701877247
if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;
@@ -77037,13 +77266,10 @@
7703777266
*/
7703877267
case OP_Init: { /* jump */
7703977268
char *zTrace;
7704077269
char *z;
7704177270
77042
- if( pOp->p2 ){
77043
- pc = pOp->p2 - 1;
77044
- }
7704577271
#ifndef SQLITE_OMIT_TRACE
7704677272
if( db->xTrace
7704777273
&& !p->doingRerun
7704877274
&& (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
7704977275
){
@@ -77067,10 +77293,11 @@
7706777293
){
7706877294
sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
7706977295
}
7707077296
#endif /* SQLITE_DEBUG */
7707177297
#endif /* SQLITE_OMIT_TRACE */
77298
+ if( pOp->p2 ) goto jump_to_p2;
7707277299
break;
7707377300
}
7707477301
7707577302
7707677303
/* Opcode: Noop * * * * *
@@ -77098,31 +77325,31 @@
7709877325
}
7709977326
7710077327
#ifdef VDBE_PROFILE
7710177328
{
7710277329
u64 endTime = sqlite3Hwtime();
77103
- if( endTime>start ) pOp->cycles += endTime - start;
77104
- pOp->cnt++;
77330
+ if( endTime>start ) pOrigOp->cycles += endTime - start;
77331
+ pOrigOp->cnt++;
7710577332
}
7710677333
#endif
7710777334
7710877335
/* The following code adds nothing to the actual functionality
7710977336
** of the program. It is only here for testing and debugging.
7711077337
** On the other hand, it does burn CPU cycles every time through
7711177338
** the evaluator loop. So we can leave it out when NDEBUG is defined.
7711277339
*/
7711377340
#ifndef NDEBUG
77114
- assert( pc>=-1 && pc<p->nOp );
77341
+ assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] );
7711577342
7711677343
#ifdef SQLITE_DEBUG
7711777344
if( db->flags & SQLITE_VdbeTrace ){
7711877345
if( rc!=0 ) printf("rc=%d\n",rc);
77119
- if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
77120
- registerTrace(pOp->p2, &aMem[pOp->p2]);
77346
+ if( pOrigOp->opflags & (OPFLG_OUT2) ){
77347
+ registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);
7712177348
}
77122
- if( pOp->opflags & OPFLG_OUT3 ){
77123
- registerTrace(pOp->p3, &aMem[pOp->p3]);
77349
+ if( pOrigOp->opflags & OPFLG_OUT3 ){
77350
+ registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);
7712477351
}
7712577352
}
7712677353
#endif /* SQLITE_DEBUG */
7712777354
#endif /* NDEBUG */
7712877355
} /* The end of the for(;;) loop the loops through opcodes */
@@ -77133,11 +77360,11 @@
7713377360
vdbe_error_halt:
7713477361
assert( rc );
7713577362
p->rc = rc;
7713677363
testcase( sqlite3GlobalConfig.xLog!=0 );
7713777364
sqlite3_log(rc, "statement aborts at %d: [%s] %s",
77138
- pc, p->zSql, p->zErrMsg);
77365
+ (int)(pOp - aOp), p->zSql, p->zErrMsg);
7713977366
sqlite3VdbeHalt(p);
7714077367
if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1;
7714177368
rc = SQLITE_ERROR;
7714277369
if( resetSchemaOnFault>0 ){
7714377370
sqlite3ResetOneSchema(db, resetSchemaOnFault-1);
@@ -77296,11 +77523,11 @@
7729677523
}
7729777524
7729877525
/*
7729977526
** Open a blob handle.
7730077527
*/
77301
-SQLITE_API int sqlite3_blob_open(
77528
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
7730277529
sqlite3* db, /* The database connection */
7730377530
const char *zDb, /* The attached database containing the blob */
7730477531
const char *zTable, /* The table containing the blob */
7730577532
const char *zColumn, /* The column containing the blob */
7730677533
sqlite_int64 iRow, /* The row containing the glob */
@@ -77533,11 +77760,11 @@
7753377760
7753477761
/*
7753577762
** Close a blob handle that was previously created using
7753677763
** sqlite3_blob_open().
7753777764
*/
77538
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
77765
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
7753977766
Incrblob *p = (Incrblob *)pBlob;
7754077767
int rc;
7754177768
sqlite3 *db;
7754277769
7754377770
if( p ){
@@ -77602,28 +77829,28 @@
7760277829
}
7760377830
7760477831
/*
7760577832
** Read data from a blob handle.
7760677833
*/
77607
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77834
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
7760877835
return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
7760977836
}
7761077837
7761177838
/*
7761277839
** Write data to a blob handle.
7761377840
*/
77614
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77841
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
7761577842
return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
7761677843
}
7761777844
7761877845
/*
7761977846
** Query a blob handle for the size of the data.
7762077847
**
7762177848
** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
7762277849
** so no mutex is required for access.
7762377850
*/
77624
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
77851
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
7762577852
Incrblob *p = (Incrblob *)pBlob;
7762677853
return (p && p->pStmt) ? p->nByte : 0;
7762777854
}
7762877855
7762977856
/*
@@ -77634,11 +77861,11 @@
7763477861
** contain a blob or text value, then an error code is returned and the
7763577862
** database handle error code and message set. If this happens, then all
7763677863
** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
7763777864
** immediately return SQLITE_ABORT.
7763877865
*/
77639
-SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77866
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
7764077867
int rc;
7764177868
Incrblob *p = (Incrblob *)pBlob;
7764277869
sqlite3 *db;
7764377870
7764477871
if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -77959,20 +78186,23 @@
7795978186
**
7796078187
** In both cases, the effects of the main thread seeing (bDone==0) even
7796178188
** after the thread has finished are not dire. So we don't worry about
7796278189
** memory barriers and such here.
7796378190
*/
78191
+typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);
7796478192
struct SortSubtask {
7796578193
SQLiteThread *pThread; /* Background thread, if any */
7796678194
int bDone; /* Set if thread is finished but not joined */
7796778195
VdbeSorter *pSorter; /* Sorter that owns this sub-task */
7796878196
UnpackedRecord *pUnpacked; /* Space to unpack a record */
7796978197
SorterList list; /* List for thread to write to a PMA */
7797078198
int nPMA; /* Number of PMAs currently in file */
78199
+ SorterCompare xCompare; /* Compare function to use */
7797178200
SorterFile file; /* Temp file for level-0 PMAs */
7797278201
SorterFile file2; /* Space for other PMAs */
7797378202
};
78203
+
7797478204
7797578205
/*
7797678206
** Main sorter structure. A single instance of this is allocated for each
7797778207
** sorter cursor created by the VDBE.
7797878208
**
@@ -77996,12 +78226,16 @@
7799678226
int nMemory; /* Size of list.aMemory allocation in bytes */
7799778227
u8 bUsePMA; /* True if one or more PMAs created */
7799878228
u8 bUseThreads; /* True to use background threads */
7799978229
u8 iPrev; /* Previous thread used to flush PMA */
7800078230
u8 nTask; /* Size of aTask[] array */
78231
+ u8 typeMask;
7800178232
SortSubtask aTask[1]; /* One or more subtasks */
7800278233
};
78234
+
78235
+#define SORTER_TYPE_INTEGER 0x01
78236
+#define SORTER_TYPE_TEXT 0x02
7800378237
7800478238
/*
7800578239
** An instance of the following object is used to read records out of a
7800678240
** PMA, in sorted order. The next key to be read is cached in nKey/aKey.
7800778241
** aKey might point into aMap or into aBuffer. If neither of those locations
@@ -78410,35 +78644,165 @@
7841078644
rc = vdbePmaReaderNext(pReadr);
7841178645
}
7841278646
return rc;
7841378647
}
7841478648
78649
+/*
78650
+** A version of vdbeSorterCompare() that assumes that it has already been
78651
+** determined that the first field of key1 is equal to the first field of
78652
+** key2.
78653
+*/
78654
+static int vdbeSorterCompareTail(
78655
+ SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78656
+ int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78657
+ const void *pKey1, int nKey1, /* Left side of comparison */
78658
+ const void *pKey2, int nKey2 /* Right side of comparison */
78659
+){
78660
+ UnpackedRecord *r2 = pTask->pUnpacked;
78661
+ if( *pbKey2Cached==0 ){
78662
+ sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);
78663
+ *pbKey2Cached = 1;
78664
+ }
78665
+ return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1);
78666
+}
7841578667
7841678668
/*
7841778669
** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2,
7841878670
** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences
7841978671
** used by the comparison. Return the result of the comparison.
7842078672
**
78421
-** Before returning, object (pTask->pUnpacked) is populated with the
78422
-** unpacked version of key2. Or, if pKey2 is passed a NULL pointer, then it
78423
-** is assumed that the (pTask->pUnpacked) structure already contains the
78424
-** unpacked key to use as key2.
78673
+** If IN/OUT parameter *pbKey2Cached is true when this function is called,
78674
+** it is assumed that (pTask->pUnpacked) contains the unpacked version
78675
+** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked
78676
+** version of key2 and *pbKey2Cached set to true before returning.
7842578677
**
7842678678
** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set
7842778679
** to SQLITE_NOMEM.
7842878680
*/
7842978681
static int vdbeSorterCompare(
7843078682
SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78683
+ int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
7843178684
const void *pKey1, int nKey1, /* Left side of comparison */
7843278685
const void *pKey2, int nKey2 /* Right side of comparison */
7843378686
){
7843478687
UnpackedRecord *r2 = pTask->pUnpacked;
78435
- if( pKey2 ){
78688
+ if( !*pbKey2Cached ){
7843678689
sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);
78690
+ *pbKey2Cached = 1;
7843778691
}
7843878692
return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);
7843978693
}
78694
+
78695
+/*
78696
+** A specially optimized version of vdbeSorterCompare() that assumes that
78697
+** the first field of each key is a TEXT value and that the collation
78698
+** sequence to compare them with is BINARY.
78699
+*/
78700
+static int vdbeSorterCompareText(
78701
+ SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78702
+ int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78703
+ const void *pKey1, int nKey1, /* Left side of comparison */
78704
+ const void *pKey2, int nKey2 /* Right side of comparison */
78705
+){
78706
+ const u8 * const p1 = (const u8 * const)pKey1;
78707
+ const u8 * const p2 = (const u8 * const)pKey2;
78708
+ const u8 * const v1 = &p1[ p1[0] ]; /* Pointer to value 1 */
78709
+ const u8 * const v2 = &p2[ p2[0] ]; /* Pointer to value 2 */
78710
+
78711
+ int n1;
78712
+ int n2;
78713
+ int res;
78714
+
78715
+ getVarint32(&p1[1], n1); n1 = (n1 - 13) / 2;
78716
+ getVarint32(&p2[1], n2); n2 = (n2 - 13) / 2;
78717
+ res = memcmp(v1, v2, MIN(n1, n2));
78718
+ if( res==0 ){
78719
+ res = n1 - n2;
78720
+ }
78721
+
78722
+ if( res==0 ){
78723
+ if( pTask->pSorter->pKeyInfo->nField>1 ){
78724
+ res = vdbeSorterCompareTail(
78725
+ pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
78726
+ );
78727
+ }
78728
+ }else{
78729
+ if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
78730
+ res = res * -1;
78731
+ }
78732
+ }
78733
+
78734
+ return res;
78735
+}
78736
+
78737
+/*
78738
+** A specially optimized version of vdbeSorterCompare() that assumes that
78739
+** the first field of each key is an INTEGER value.
78740
+*/
78741
+static int vdbeSorterCompareInt(
78742
+ SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78743
+ int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78744
+ const void *pKey1, int nKey1, /* Left side of comparison */
78745
+ const void *pKey2, int nKey2 /* Right side of comparison */
78746
+){
78747
+ const u8 * const p1 = (const u8 * const)pKey1;
78748
+ const u8 * const p2 = (const u8 * const)pKey2;
78749
+ const int s1 = p1[1]; /* Left hand serial type */
78750
+ const int s2 = p2[1]; /* Right hand serial type */
78751
+ const u8 * const v1 = &p1[ p1[0] ]; /* Pointer to value 1 */
78752
+ const u8 * const v2 = &p2[ p2[0] ]; /* Pointer to value 2 */
78753
+ int res; /* Return value */
78754
+
78755
+ assert( (s1>0 && s1<7) || s1==8 || s1==9 );
78756
+ assert( (s2>0 && s2<7) || s2==8 || s2==9 );
78757
+
78758
+ if( s1>7 && s2>7 ){
78759
+ res = s1 - s2;
78760
+ }else{
78761
+ if( s1==s2 ){
78762
+ if( (*v1 ^ *v2) & 0x80 ){
78763
+ /* The two values have different signs */
78764
+ res = (*v1 & 0x80) ? -1 : +1;
78765
+ }else{
78766
+ /* The two values have the same sign. Compare using memcmp(). */
78767
+ static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8 };
78768
+ int i;
78769
+ res = 0;
78770
+ for(i=0; i<aLen[s1]; i++){
78771
+ if( (res = v1[i] - v2[i]) ) break;
78772
+ }
78773
+ }
78774
+ }else{
78775
+ if( s2>7 ){
78776
+ res = +1;
78777
+ }else if( s1>7 ){
78778
+ res = -1;
78779
+ }else{
78780
+ res = s1 - s2;
78781
+ }
78782
+ assert( res!=0 );
78783
+
78784
+ if( res>0 ){
78785
+ if( *v1 & 0x80 ) res = -1;
78786
+ }else{
78787
+ if( *v2 & 0x80 ) res = +1;
78788
+ }
78789
+ }
78790
+ }
78791
+
78792
+ if( res==0 ){
78793
+ if( pTask->pSorter->pKeyInfo->nField>1 ){
78794
+ res = vdbeSorterCompareTail(
78795
+ pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
78796
+ );
78797
+ }
78798
+ }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
78799
+ res = res * -1;
78800
+ }
78801
+
78802
+ return res;
78803
+}
7844078804
7844178805
/*
7844278806
** Initialize the temporary index cursor just opened as a sorter cursor.
7844378807
**
7844478808
** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nField)
@@ -78503,13 +78867,17 @@
7850378867
rc = SQLITE_NOMEM;
7850478868
}else{
7850578869
pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);
7850678870
memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);
7850778871
pKeyInfo->db = 0;
78508
- if( nField && nWorker==0 ) pKeyInfo->nField = nField;
78872
+ if( nField && nWorker==0 ){
78873
+ pKeyInfo->nXField += (pKeyInfo->nField - nField);
78874
+ pKeyInfo->nField = nField;
78875
+ }
7850978876
pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);
7851078877
pSorter->nTask = nWorker + 1;
78878
+ pSorter->iPrev = nWorker-1;
7851178879
pSorter->bUseThreads = (pSorter->nTask>1);
7851278880
pSorter->db = db;
7851378881
for(i=0; i<pSorter->nTask; i++){
7851478882
SortSubtask *pTask = &pSorter->aTask[i];
7851578883
pTask->pSorter = pSorter;
@@ -78531,10 +78899,16 @@
7853178899
pSorter->nMemory = pgsz;
7853278900
pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);
7853378901
if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM;
7853478902
}
7853578903
}
78904
+
78905
+ if( (pKeyInfo->nField+pKeyInfo->nXField)<13
78906
+ && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)
78907
+ ){
78908
+ pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;
78909
+ }
7853678910
}
7853778911
7853878912
return rc;
7853978913
}
7854078914
#undef nWorker /* Defined at the top of this function */
@@ -78555,34 +78929,28 @@
7855578929
** Free all resources owned by the object indicated by argument pTask. All
7855678930
** fields of *pTask are zeroed before returning.
7855778931
*/
7855878932
static void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){
7855978933
sqlite3DbFree(db, pTask->pUnpacked);
78560
- pTask->pUnpacked = 0;
7856178934
#if SQLITE_MAX_WORKER_THREADS>0
7856278935
/* pTask->list.aMemory can only be non-zero if it was handed memory
7856378936
** from the main thread. That only occurs SQLITE_MAX_WORKER_THREADS>0 */
7856478937
if( pTask->list.aMemory ){
7856578938
sqlite3_free(pTask->list.aMemory);
78566
- pTask->list.aMemory = 0;
7856778939
}else
7856878940
#endif
7856978941
{
7857078942
assert( pTask->list.aMemory==0 );
7857178943
vdbeSorterRecordFree(0, pTask->list.pList);
7857278944
}
78573
- pTask->list.pList = 0;
7857478945
if( pTask->file.pFd ){
7857578946
sqlite3OsCloseFree(pTask->file.pFd);
78576
- pTask->file.pFd = 0;
78577
- pTask->file.iEof = 0;
7857878947
}
7857978948
if( pTask->file2.pFd ){
7858078949
sqlite3OsCloseFree(pTask->file2.pFd);
78581
- pTask->file2.pFd = 0;
78582
- pTask->file2.iEof = 0;
7858378950
}
78951
+ memset(pTask, 0, sizeof(SortSubtask));
7858478952
}
7858578953
7858678954
#ifdef SQLITE_DEBUG_SORTER_THREADS
7858778955
static void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){
7858878956
i64 t;
@@ -78758,10 +79126,11 @@
7875879126
vdbeMergeEngineFree(pSorter->pMerger);
7875979127
pSorter->pMerger = 0;
7876079128
for(i=0; i<pSorter->nTask; i++){
7876179129
SortSubtask *pTask = &pSorter->aTask[i];
7876279130
vdbeSortSubtaskCleanup(db, pTask);
79131
+ pTask->pSorter = pSorter;
7876379132
}
7876479133
if( pSorter->list.aMemory==0 ){
7876579134
vdbeSorterRecordFree(0, pSorter->list.pList);
7876679135
}
7876779136
pSorter->list.pList = 0;
@@ -78867,31 +79236,45 @@
7886779236
SorterRecord *p2, /* Second list to merge */
7886879237
SorterRecord **ppOut /* OUT: Head of merged list */
7886979238
){
7887079239
SorterRecord *pFinal = 0;
7887179240
SorterRecord **pp = &pFinal;
78872
- void *pVal2 = p2 ? SRVAL(p2) : 0;
79241
+ int bCached = 0;
7887379242
7887479243
while( p1 && p2 ){
7887579244
int res;
78876
- res = vdbeSorterCompare(pTask, SRVAL(p1), p1->nVal, pVal2, p2->nVal);
79245
+ res = pTask->xCompare(
79246
+ pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
79247
+ );
79248
+
7887779249
if( res<=0 ){
7887879250
*pp = p1;
7887979251
pp = &p1->u.pNext;
7888079252
p1 = p1->u.pNext;
78881
- pVal2 = 0;
7888279253
}else{
7888379254
*pp = p2;
78884
- pp = &p2->u.pNext;
79255
+ pp = &p2->u.pNext;
7888579256
p2 = p2->u.pNext;
78886
- if( p2==0 ) break;
78887
- pVal2 = SRVAL(p2);
79257
+ bCached = 0;
7888879258
}
7888979259
}
7889079260
*pp = p1 ? p1 : p2;
7889179261
*ppOut = pFinal;
7889279262
}
79263
+
79264
+/*
79265
+** Return the SorterCompare function to compare values collected by the
79266
+** sorter object passed as the only argument.
79267
+*/
79268
+static SorterCompare vdbeSorterGetCompare(VdbeSorter *p){
79269
+ if( p->typeMask==SORTER_TYPE_INTEGER ){
79270
+ return vdbeSorterCompareInt;
79271
+ }else if( p->typeMask==SORTER_TYPE_TEXT ){
79272
+ return vdbeSorterCompareText;
79273
+ }
79274
+ return vdbeSorterCompare;
79275
+}
7889379276
7889479277
/*
7889579278
** Sort the linked list of records headed at pTask->pList. Return
7889679279
** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
7889779280
** an error occurs.
@@ -78903,16 +79286,18 @@
7890379286
int rc;
7890479287
7890579288
rc = vdbeSortAllocUnpacked(pTask);
7890679289
if( rc!=SQLITE_OK ) return rc;
7890779290
79291
+ p = pList->pList;
79292
+ pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
79293
+
7890879294
aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));
7890979295
if( !aSlot ){
7891079296
return SQLITE_NOMEM;
7891179297
}
7891279298
78913
- p = pList->pList;
7891479299
while( p ){
7891579300
SorterRecord *pNext;
7891679301
if( pList->aMemory ){
7891779302
if( (u8*)p==pList->aMemory ){
7891879303
pNext = 0;
@@ -79122,28 +79507,27 @@
7912279507
/* Update contents of aTree[] */
7912379508
if( rc==SQLITE_OK ){
7912479509
int i; /* Index of aTree[] to recalculate */
7912579510
PmaReader *pReadr1; /* First PmaReader to compare */
7912679511
PmaReader *pReadr2; /* Second PmaReader to compare */
79127
- u8 *pKey2; /* To pReadr2->aKey, or 0 if record cached */
79512
+ int bCached = 0;
7912879513
7912979514
/* Find the first two PmaReaders to compare. The one that was just
7913079515
** advanced (iPrev) and the one next to it in the array. */
7913179516
pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];
7913279517
pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];
79133
- pKey2 = pReadr2->aKey;
7913479518
7913579519
for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){
7913679520
/* Compare pReadr1 and pReadr2. Store the result in variable iRes. */
7913779521
int iRes;
7913879522
if( pReadr1->pFd==0 ){
7913979523
iRes = +1;
7914079524
}else if( pReadr2->pFd==0 ){
7914179525
iRes = -1;
7914279526
}else{
79143
- iRes = vdbeSorterCompare(pTask,
79144
- pReadr1->aKey, pReadr1->nKey, pKey2, pReadr2->nKey
79527
+ iRes = pTask->xCompare(pTask, &bCached,
79528
+ pReadr1->aKey, pReadr1->nKey, pReadr2->aKey, pReadr2->nKey
7914579529
);
7914679530
}
7914779531
7914879532
/* If pReadr1 contained the smaller value, set aTree[i] to its index.
7914979533
** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this
@@ -79161,13 +79545,13 @@
7916179545
** is sorted from oldest to newest, so pReadr1 contains older values
7916279546
** than pReadr2 iff (pReadr1<pReadr2). */
7916379547
if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){
7916479548
pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);
7916579549
pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
79166
- pKey2 = pReadr2->aKey;
79550
+ bCached = 0;
7916779551
}else{
79168
- if( pReadr1->pFd ) pKey2 = 0;
79552
+ if( pReadr1->pFd ) bCached = 0;
7916979553
pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);
7917079554
pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
7917179555
}
7917279556
}
7917379557
*pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);
@@ -79270,10 +79654,20 @@
7927079654
SorterRecord *pNew; /* New list element */
7927179655
7927279656
int bFlush; /* True to flush contents of memory to PMA */
7927379657
int nReq; /* Bytes of memory required */
7927479658
int nPMA; /* Bytes of PMA space required */
79659
+ int t; /* serial type of first record field */
79660
+
79661
+ getVarint32((const u8*)&pVal->z[1], t);
79662
+ if( t>0 && t<10 && t!=7 ){
79663
+ pSorter->typeMask &= SORTER_TYPE_INTEGER;
79664
+ }else if( t>10 && (t & 0x01) ){
79665
+ pSorter->typeMask &= SORTER_TYPE_TEXT;
79666
+ }else{
79667
+ pSorter->typeMask = 0;
79668
+ }
7927579669
7927679670
assert( pSorter );
7927779671
7927879672
/* Figure out whether or not the current contents of memory should be
7927979673
** flushed to a PMA before continuing. If so, do so.
@@ -79535,14 +79929,16 @@
7953579929
if( p1->pFd==0 ){
7953679930
iRes = i2;
7953779931
}else if( p2->pFd==0 ){
7953879932
iRes = i1;
7953979933
}else{
79934
+ SortSubtask *pTask = pMerger->pTask;
79935
+ int bCached = 0;
7954079936
int res;
79541
- assert( pMerger->pTask->pUnpacked!=0 ); /* from vdbeSortSubtaskMain() */
79542
- res = vdbeSorterCompare(
79543
- pMerger->pTask, p1->aKey, p1->nKey, p2->aKey, p2->nKey
79937
+ assert( pTask->pUnpacked!=0 ); /* from vdbeSortSubtaskMain() */
79938
+ res = pTask->xCompare(
79939
+ pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey
7954479940
);
7954579941
if( res<=0 ){
7954679942
iRes = i1;
7954779943
}else{
7954879944
iRes = i2;
@@ -79562,15 +79958,16 @@
7956279958
*/
7956379959
#define INCRINIT_NORMAL 0
7956479960
#define INCRINIT_TASK 1
7956579961
#define INCRINIT_ROOT 2
7956679962
79567
-/* Forward reference.
79568
-** The vdbeIncrMergeInit() and vdbePmaReaderIncrMergeInit() routines call each
79569
-** other (when building a merge tree).
79963
+/*
79964
+** Forward reference required as the vdbeIncrMergeInit() and
79965
+** vdbePmaReaderIncrInit() routines are called mutually recursively when
79966
+** building a merge tree.
7957079967
*/
79571
-static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode);
79968
+static int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode);
7957279969
7957379970
/*
7957479971
** Initialize the MergeEngine object passed as the second argument. Once this
7957579972
** function returns, the first key of merged data may be read from the
7957679973
** MergeEngine object in the usual fashion.
@@ -79613,11 +80010,11 @@
7961380010
** the main thread to fill its buffer. So calling PmaReaderNext()
7961480011
** on this PmaReader before any of the multi-threaded PmaReaders takes
7961580012
** better advantage of multi-processor hardware. */
7961680013
rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);
7961780014
}else{
79618
- rc = vdbePmaReaderIncrMergeInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
80015
+ rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
7961980016
}
7962080017
if( rc!=SQLITE_OK ) return rc;
7962180018
}
7962280019
7962380020
for(i=pMerger->nTree-1; i>0; i--){
@@ -79625,21 +80022,19 @@
7962580022
}
7962680023
return pTask->pUnpacked->errCode;
7962780024
}
7962880025
7962980026
/*
79630
-** Initialize the IncrMerge field of a PmaReader.
79631
-**
79632
-** If the PmaReader passed as the first argument is not an incremental-reader
79633
-** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it serves
79634
-** to open and/or initialize the temp file related fields of the IncrMerge
80027
+** The PmaReader passed as the first argument is guaranteed to be an
80028
+** incremental-reader (pReadr->pIncr!=0). This function serves to open
80029
+** and/or initialize the temp file related fields of the IncrMerge
7963580030
** object at (pReadr->pIncr).
7963680031
**
7963780032
** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders
79638
-** in the sub-tree headed by pReadr are also initialized. Data is then loaded
79639
-** into the buffers belonging to pReadr and it is set to
79640
-** point to the first key in its range.
80033
+** in the sub-tree headed by pReadr are also initialized. Data is then
80034
+** loaded into the buffers belonging to pReadr and it is set to point to
80035
+** the first key in its range.
7964180036
**
7964280037
** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed
7964380038
** to be a multi-threaded PmaReader and this function is being called in a
7964480039
** background thread. In this case all PmaReaders in the sub-tree are
7964580040
** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to
@@ -79662,93 +80057,112 @@
7966280057
** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
7966380058
*/
7966480059
static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){
7966580060
int rc = SQLITE_OK;
7966680061
IncrMerger *pIncr = pReadr->pIncr;
80062
+ SortSubtask *pTask = pIncr->pTask;
80063
+ sqlite3 *db = pTask->pSorter->db;
7966780064
7966880065
/* eMode is always INCRINIT_NORMAL in single-threaded mode */
7966980066
assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );
7967080067
79671
- if( pIncr ){
79672
- SortSubtask *pTask = pIncr->pTask;
79673
- sqlite3 *db = pTask->pSorter->db;
79674
-
79675
- rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
79676
-
79677
- /* Set up the required files for pIncr. A multi-theaded IncrMerge object
79678
- ** requires two temp files to itself, whereas a single-threaded object
79679
- ** only requires a region of pTask->file2. */
79680
- if( rc==SQLITE_OK ){
79681
- int mxSz = pIncr->mxSz;
79682
-#if SQLITE_MAX_WORKER_THREADS>0
79683
- if( pIncr->bUseThread ){
79684
- rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
79685
- if( rc==SQLITE_OK ){
79686
- rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
79687
- }
79688
- }else
79689
-#endif
79690
- /*if( !pIncr->bUseThread )*/{
79691
- if( pTask->file2.pFd==0 ){
79692
- assert( pTask->file2.iEof>0 );
79693
- rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
79694
- pTask->file2.iEof = 0;
79695
- }
79696
- if( rc==SQLITE_OK ){
79697
- pIncr->aFile[1].pFd = pTask->file2.pFd;
79698
- pIncr->iStartOff = pTask->file2.iEof;
79699
- pTask->file2.iEof += mxSz;
79700
- }
79701
- }
79702
- }
79703
-
79704
-#if SQLITE_MAX_WORKER_THREADS>0
79705
- if( rc==SQLITE_OK && pIncr->bUseThread ){
79706
- /* Use the current thread to populate aFile[1], even though this
79707
- ** PmaReader is multi-threaded. The reason being that this function
79708
- ** is already running in background thread pIncr->pTask->thread. */
79709
- assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );
79710
- rc = vdbeIncrPopulate(pIncr);
79711
- }
79712
-#endif
79713
-
79714
- if( rc==SQLITE_OK
79715
- && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK)
79716
- ){
79717
- rc = vdbePmaReaderNext(pReadr);
79718
- }
79719
- }
80068
+ rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
80069
+
80070
+ /* Set up the required files for pIncr. A multi-theaded IncrMerge object
80071
+ ** requires two temp files to itself, whereas a single-threaded object
80072
+ ** only requires a region of pTask->file2. */
80073
+ if( rc==SQLITE_OK ){
80074
+ int mxSz = pIncr->mxSz;
80075
+#if SQLITE_MAX_WORKER_THREADS>0
80076
+ if( pIncr->bUseThread ){
80077
+ rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
80078
+ if( rc==SQLITE_OK ){
80079
+ rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
80080
+ }
80081
+ }else
80082
+#endif
80083
+ /*if( !pIncr->bUseThread )*/{
80084
+ if( pTask->file2.pFd==0 ){
80085
+ assert( pTask->file2.iEof>0 );
80086
+ rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
80087
+ pTask->file2.iEof = 0;
80088
+ }
80089
+ if( rc==SQLITE_OK ){
80090
+ pIncr->aFile[1].pFd = pTask->file2.pFd;
80091
+ pIncr->iStartOff = pTask->file2.iEof;
80092
+ pTask->file2.iEof += mxSz;
80093
+ }
80094
+ }
80095
+ }
80096
+
80097
+#if SQLITE_MAX_WORKER_THREADS>0
80098
+ if( rc==SQLITE_OK && pIncr->bUseThread ){
80099
+ /* Use the current thread to populate aFile[1], even though this
80100
+ ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,
80101
+ ** then this function is already running in background thread
80102
+ ** pIncr->pTask->thread.
80103
+ **
80104
+ ** If this is the INCRINIT_ROOT object, then it is running in the
80105
+ ** main VDBE thread. But that is Ok, as that thread cannot return
80106
+ ** control to the VDBE or proceed with anything useful until the
80107
+ ** first results are ready from this merger object anyway.
80108
+ */
80109
+ assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );
80110
+ rc = vdbeIncrPopulate(pIncr);
80111
+ }
80112
+#endif
80113
+
80114
+ if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){
80115
+ rc = vdbePmaReaderNext(pReadr);
80116
+ }
80117
+
7972080118
return rc;
7972180119
}
7972280120
7972380121
#if SQLITE_MAX_WORKER_THREADS>0
7972480122
/*
7972580123
** The main routine for vdbePmaReaderIncrMergeInit() operations run in
7972680124
** background threads.
7972780125
*/
79728
-static void *vdbePmaReaderBgInit(void *pCtx){
80126
+static void *vdbePmaReaderBgIncrInit(void *pCtx){
7972980127
PmaReader *pReader = (PmaReader*)pCtx;
7973080128
void *pRet = SQLITE_INT_TO_PTR(
7973180129
vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)
7973280130
);
7973380131
pReader->pIncr->pTask->bDone = 1;
7973480132
return pRet;
7973580133
}
80134
+#endif
7973680135
7973780136
/*
79738
-** Use a background thread to invoke vdbePmaReaderIncrMergeInit(INCRINIT_TASK)
79739
-** on the PmaReader object passed as the first argument.
79740
-**
79741
-** This call will initialize the various fields of the pReadr->pIncr
79742
-** structure and, if it is a multi-threaded IncrMerger, launch a
79743
-** background thread to populate aFile[1].
80137
+** If the PmaReader passed as the first argument is not an incremental-reader
80138
+** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes
80139
+** the vdbePmaReaderIncrMergeInit() function with the parameters passed to
80140
+** this routine to initialize the incremental merge.
80141
+**
80142
+** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1),
80143
+** then a background thread is launched to call vdbePmaReaderIncrMergeInit().
80144
+** Or, if the IncrMerger is single threaded, the same function is called
80145
+** using the current thread.
7974480146
*/
79745
-static int vdbePmaReaderBgIncrInit(PmaReader *pReadr){
79746
- void *pCtx = (void*)pReadr;
79747
- return vdbeSorterCreateThread(pReadr->pIncr->pTask, vdbePmaReaderBgInit, pCtx);
80147
+static int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){
80148
+ IncrMerger *pIncr = pReadr->pIncr; /* Incremental merger */
80149
+ int rc = SQLITE_OK; /* Return code */
80150
+ if( pIncr ){
80151
+#if SQLITE_MAX_WORKER_THREADS>0
80152
+ assert( pIncr->bUseThread==0 || eMode==INCRINIT_TASK );
80153
+ if( pIncr->bUseThread ){
80154
+ void *pCtx = (void*)pReadr;
80155
+ rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);
80156
+ }else
80157
+#endif
80158
+ {
80159
+ rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);
80160
+ }
80161
+ }
80162
+ return rc;
7974880163
}
79749
-#endif
7975080164
7975180165
/*
7975280166
** Allocate a new MergeEngine object to merge the contents of nPMA level-0
7975380167
** PMAs from pTask->file. If no error occurs, set *ppOut to point to
7975480168
** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut
@@ -79956,10 +80370,15 @@
7995680370
int rc; /* Return code */
7995780371
SortSubtask *pTask0 = &pSorter->aTask[0];
7995880372
MergeEngine *pMain = 0;
7995980373
#if SQLITE_MAX_WORKER_THREADS
7996080374
sqlite3 *db = pTask0->pSorter->db;
80375
+ int i;
80376
+ SorterCompare xCompare = vdbeSorterGetCompare(pSorter);
80377
+ for(i=0; i<pSorter->nTask; i++){
80378
+ pSorter->aTask[i].xCompare = xCompare;
80379
+ }
7996180380
#endif
7996280381
7996380382
rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);
7996480383
if( rc==SQLITE_OK ){
7996580384
#if SQLITE_MAX_WORKER_THREADS
@@ -79984,19 +80403,25 @@
7998480403
vdbeIncrMergerSetThreads(pIncr);
7998580404
assert( pIncr->pTask!=pLast );
7998680405
}
7998780406
}
7998880407
for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){
80408
+ /* Check that:
80409
+ **
80410
+ ** a) The incremental merge object is configured to use the
80411
+ ** right task, and
80412
+ ** b) If it is using task (nTask-1), it is configured to run
80413
+ ** in single-threaded mode. This is important, as the
80414
+ ** root merge (INCRINIT_ROOT) will be using the same task
80415
+ ** object.
80416
+ */
7998980417
PmaReader *p = &pMain->aReadr[iTask];
79990
- assert( p->pIncr==0 || p->pIncr->pTask==&pSorter->aTask[iTask] );
79991
- if( p->pIncr ){
79992
- if( iTask==pSorter->nTask-1 ){
79993
- rc = vdbePmaReaderIncrMergeInit(p, INCRINIT_TASK);
79994
- }else{
79995
- rc = vdbePmaReaderBgIncrInit(p);
79996
- }
79997
- }
80418
+ assert( p->pIncr==0 || (
80419
+ (p->pIncr->pTask==&pSorter->aTask[iTask]) /* a */
80420
+ && (iTask!=pSorter->nTask-1 || p->pIncr->bUseThread==0) /* b */
80421
+ ));
80422
+ rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);
7999880423
}
7999980424
}
8000080425
pMain = 0;
8000180426
}
8000280427
if( rc==SQLITE_OK ){
@@ -80947,11 +81372,11 @@
8094781372
** Should be transformed into:
8094881373
**
8094981374
** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;
8095081375
**
8095181376
** The nSubquery parameter specifies how many levels of subquery the
80952
-** alias is removed from the original expression. The usually value is
81377
+** alias is removed from the original expression. The usual value is
8095381378
** zero but it might be more if the alias is contained within a subquery
8095481379
** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION
8095581380
** structures must be increased by the nSubquery amount.
8095681381
*/
8095781382
static void resolveAlias(
@@ -80967,11 +81392,10 @@
8096781392
sqlite3 *db; /* The database connection */
8096881393
8096981394
assert( iCol>=0 && iCol<pEList->nExpr );
8097081395
pOrig = pEList->a[iCol].pExpr;
8097181396
assert( pOrig!=0 );
80972
- assert( pOrig->flags & EP_Resolved );
8097381397
db = pParse->db;
8097481398
pDup = sqlite3ExprDup(db, pOrig, 0);
8097581399
if( pDup==0 ) return;
8097681400
if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){
8097781401
incrAggFunctionDepth(pDup, nSubquery);
@@ -81861,13 +82285,15 @@
8186182285
pNew->flags |= EP_IntValue;
8186282286
pNew->u.iValue = iCol;
8186382287
if( pItem->pExpr==pE ){
8186482288
pItem->pExpr = pNew;
8186582289
}else{
81866
- assert( pItem->pExpr->op==TK_COLLATE );
81867
- assert( pItem->pExpr->pLeft==pE );
81868
- pItem->pExpr->pLeft = pNew;
82290
+ Expr *pParent = pItem->pExpr;
82291
+ assert( pParent->op==TK_COLLATE );
82292
+ while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
82293
+ assert( pParent->pLeft==pE );
82294
+ pParent->pLeft = pNew;
8186982295
}
8187082296
sqlite3ExprDelete(db, pE);
8187182297
pItem->u.x.iOrderByCol = (u16)iCol;
8187282298
pItem->done = 1;
8187382299
}else{
@@ -82054,10 +82480,24 @@
8205482480
sNC.pParse = pParse;
8205582481
if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||
8205682482
sqlite3ResolveExprNames(&sNC, p->pOffset) ){
8205782483
return WRC_Abort;
8205882484
}
82485
+
82486
+ /* If the SF_Converted flags is set, then this Select object was
82487
+ ** was created by the convertCompoundSelectToSubquery() function.
82488
+ ** In this case the ORDER BY clause (p->pOrderBy) should be resolved
82489
+ ** as if it were part of the sub-query, not the parent. This block
82490
+ ** moves the pOrderBy down to the sub-query. It will be moved back
82491
+ ** after the names have been resolved. */
82492
+ if( p->selFlags & SF_Converted ){
82493
+ Select *pSub = p->pSrc->a[0].pSelect;
82494
+ assert( p->pSrc->nSrc==1 && p->pOrderBy );
82495
+ assert( pSub->pPrior && pSub->pOrderBy==0 );
82496
+ pSub->pOrderBy = p->pOrderBy;
82497
+ p->pOrderBy = 0;
82498
+ }
8205982499
8206082500
/* Recursively resolve names in all subqueries
8206182501
*/
8206282502
for(i=0; i<p->pSrc->nSrc; i++){
8206382503
struct SrcList_item *pItem = &p->pSrc->a[i];
@@ -82135,17 +82575,35 @@
8213582575
/* The ORDER BY and GROUP BY clauses may not refer to terms in
8213682576
** outer queries
8213782577
*/
8213882578
sNC.pNext = 0;
8213982579
sNC.ncFlags |= NC_AllowAgg;
82580
+
82581
+ /* If this is a converted compound query, move the ORDER BY clause from
82582
+ ** the sub-query back to the parent query. At this point each term
82583
+ ** within the ORDER BY clause has been transformed to an integer value.
82584
+ ** These integers will be replaced by copies of the corresponding result
82585
+ ** set expressions by the call to resolveOrderGroupBy() below. */
82586
+ if( p->selFlags & SF_Converted ){
82587
+ Select *pSub = p->pSrc->a[0].pSelect;
82588
+ p->pOrderBy = pSub->pOrderBy;
82589
+ pSub->pOrderBy = 0;
82590
+ }
8214082591
8214182592
/* Process the ORDER BY clause for singleton SELECT statements.
8214282593
** The ORDER BY clause for compounds SELECT statements is handled
8214382594
** below, after all of the result-sets for all of the elements of
8214482595
** the compound have been resolved.
82596
+ **
82597
+ ** If there is an ORDER BY clause on a term of a compound-select other
82598
+ ** than the right-most term, then that is a syntax error. But the error
82599
+ ** is not detected until much later, and so we need to go ahead and
82600
+ ** resolve those symbols on the incorrect ORDER BY for consistency.
8214582601
*/
82146
- if( !isCompound && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") ){
82602
+ if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
82603
+ && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER")
82604
+ ){
8214782605
return WRC_Abort;
8214882606
}
8214982607
if( db->mallocFailed ){
8215082608
return WRC_Abort;
8215182609
}
@@ -83593,11 +84051,12 @@
8359384051
SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
8359484052
int i;
8359584053
u32 m = 0;
8359684054
if( pList ){
8359784055
for(i=0; i<pList->nExpr; i++){
83598
- m |= pList->a[i].pExpr->flags;
84056
+ Expr *pExpr = pList->a[i].pExpr;
84057
+ if( ALWAYS(pExpr) ) m |= pExpr->flags;
8359984058
}
8360084059
}
8360184060
return m;
8360284061
}
8360384062
@@ -84033,11 +84492,11 @@
8403384492
/* Check to see if an existing table or index can be used to
8403484493
** satisfy the query. This is preferable to generating a new
8403584494
** ephemeral table.
8403684495
*/
8403784496
p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
84038
- if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){
84497
+ if( pParse->nErr==0 && isCandidateForInOpt(p) ){
8403984498
sqlite3 *db = pParse->db; /* Database connection */
8404084499
Table *pTab; /* Table <table>. */
8404184500
Expr *pExpr; /* Expression <column> */
8404284501
i16 iCol; /* Index of column <column> */
8404384502
i16 iDb; /* Database idx for pTab */
@@ -84358,10 +84817,11 @@
8435884817
}
8435984818
sqlite3ExprDelete(pParse->db, pSel->pLimit);
8436084819
pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0,
8436184820
&sqlite3IntTokens[1]);
8436284821
pSel->iLimit = 0;
84822
+ pSel->selFlags &= ~SF_MultiValue;
8436384823
if( sqlite3Select(pParse, pSel, &dest) ){
8436484824
return 0;
8436584825
}
8436684826
rReg = dest.iSDParm;
8436784827
ExprSetVVAProperty(pExpr, EP_NoReduce);
@@ -85723,11 +86183,11 @@
8572386183
sqlite3TreeViewLine(pView,"AS %Q", pExpr->u.zToken);
8572486184
sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
8572586185
break;
8572686186
}
8572786187
case TK_ID: {
85728
- sqlite3TreeViewLine(pView,"ID %Q", pExpr->u.zToken);
86188
+ sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken);
8572986189
break;
8573086190
}
8573186191
#ifndef SQLITE_OMIT_CAST
8573286192
case TK_CAST: {
8573386193
/* Expressions of the form: CAST(pLeft AS token) */
@@ -86358,11 +86818,11 @@
8635886818
if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
8635986819
if( combinedFlags & EP_xIsSelect ) return 2;
8636086820
if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
8636186821
if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
8636286822
if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
86363
- if( ALWAYS((combinedFlags & EP_Reduced)==0) ){
86823
+ if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
8636486824
if( pA->iColumn!=pB->iColumn ) return 2;
8636586825
if( pA->iTable!=pB->iTable
8636686826
&& (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
8636786827
}
8636886828
}
@@ -86890,10 +87350,11 @@
8689087350
do {
8689187351
z += n;
8689287352
n = sqlite3GetToken(z, &token);
8689387353
}while( token==TK_SPACE );
8689487354
87355
+ if( token==TK_ILLEGAL ) break;
8689587356
zParent = sqlite3DbStrNDup(db, (const char *)z, n);
8689687357
if( zParent==0 ) break;
8689787358
sqlite3Dequote(zParent);
8689887359
if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
8689987360
char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
@@ -89116,18 +89577,21 @@
8911689577
pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
8911789578
}
8911889579
z = argv[2];
8911989580
8912089581
if( pIndex ){
89582
+ tRowcnt *aiRowEst = 0;
8912189583
int nCol = pIndex->nKeyCol+1;
8912289584
#ifdef SQLITE_ENABLE_STAT3_OR_STAT4
89123
- tRowcnt * const aiRowEst = pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(
89124
- sizeof(tRowcnt) * nCol
89125
- );
89126
- if( aiRowEst==0 ) pInfo->db->mallocFailed = 1;
89127
-#else
89128
- tRowcnt * const aiRowEst = 0;
89585
+ /* Index.aiRowEst may already be set here if there are duplicate
89586
+ ** sqlite_stat1 entries for this index. In that case just clobber
89587
+ ** the old data with the new instead of allocating a new array. */
89588
+ if( pIndex->aiRowEst==0 ){
89589
+ pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
89590
+ if( pIndex->aiRowEst==0 ) pInfo->db->mallocFailed = 1;
89591
+ }
89592
+ aiRowEst = pIndex->aiRowEst;
8912989593
#endif
8913089594
pIndex->bUnordered = 0;
8913189595
decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
8913289596
if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0];
8913389597
}else{
@@ -89786,11 +90250,11 @@
8978690250
}
8978790251
8978890252
sqlite3BtreeClose(pDb->pBt);
8978990253
pDb->pBt = 0;
8979090254
pDb->pSchema = 0;
89791
- sqlite3ResetAllSchemasOfConnection(db);
90255
+ sqlite3CollapseDatabaseArray(db);
8979290256
return;
8979390257
8979490258
detach_error:
8979590259
sqlite3_result_error(context, zErr, -1);
8979690260
}
@@ -89820,11 +90284,10 @@
8982090284
if(
8982190285
SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
8982290286
SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
8982390287
SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
8982490288
){
89825
- pParse->nErr++;
8982690289
goto attach_end;
8982790290
}
8982890291
8982990292
#ifndef SQLITE_OMIT_AUTHORIZATION
8983090293
if( pAuthArg ){
@@ -90142,11 +90605,11 @@
9014290605
** and attempts to write the column will be ignored.
9014390606
**
9014490607
** Setting the auth function to NULL disables this hook. The default
9014590608
** setting of the auth function is NULL.
9014690609
*/
90147
-SQLITE_API int sqlite3_set_authorizer(
90610
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
9014890611
sqlite3 *db,
9014990612
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
9015090613
void *pArg
9015190614
){
9015290615
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -90479,13 +90942,15 @@
9047990942
sqlite3 *db;
9048090943
Vdbe *v;
9048190944
9048290945
assert( pParse->pToplevel==0 );
9048390946
db = pParse->db;
90484
- if( db->mallocFailed ) return;
9048590947
if( pParse->nested ) return;
90486
- if( pParse->nErr ) return;
90948
+ if( db->mallocFailed || pParse->nErr ){
90949
+ if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
90950
+ return;
90951
+ }
9048790952
9048890953
/* Begin by generating some termination code at the end of the
9048990954
** vdbe program
9049090955
*/
9049190956
v = sqlite3GetVdbe(pParse);
@@ -90563,11 +91028,11 @@
9056391028
}
9056491029
9056591030
9056691031
/* Get the VDBE program ready for execution
9056791032
*/
90568
- if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
91033
+ if( v && pParse->nErr==0 && !db->mallocFailed ){
9056991034
assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
9057091035
/* A minimum of one cursor is required if autoincrement is used
9057191036
* See ticket [a696379c1f08866] */
9057291037
if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
9057391038
sqlite3VdbeMakeReady(v, pParse);
@@ -91098,18 +91563,16 @@
9109891563
sqlite3 *db = pParse->db;
9109991564
9110091565
if( ALWAYS(pName2!=0) && pName2->n>0 ){
9110191566
if( db->init.busy ) {
9110291567
sqlite3ErrorMsg(pParse, "corrupt database");
91103
- pParse->nErr++;
9110491568
return -1;
9110591569
}
9110691570
*pUnqual = pName2;
9110791571
iDb = sqlite3FindDb(db, pName1);
9110891572
if( iDb<0 ){
9110991573
sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
91110
- pParse->nErr++;
9111191574
return -1;
9111291575
}
9111391576
}else{
9111491577
assert( db->init.iDb==0 || db->init.busy );
9111591578
iDb = db->init.iDb;
@@ -91264,11 +91727,11 @@
9126491727
pTable = sqlite3FindTable(db, zName, zDb);
9126591728
if( pTable ){
9126691729
if( !noErr ){
9126791730
sqlite3ErrorMsg(pParse, "table %T already exists", pName);
9126891731
}else{
91269
- assert( !db->init.busy );
91732
+ assert( !db->init.busy || CORRUPT_DB );
9127091733
sqlite3CodeVerifySchema(pParse, iDb);
9127191734
}
9127291735
goto begin_table_error;
9127391736
}
9127491737
if( sqlite3FindIndex(db, zName, zDb)!=0 ){
@@ -91553,11 +92016,12 @@
9155392016
Column *pCol;
9155492017
9155592018
p = pParse->pNewTable;
9155692019
if( p==0 || NEVER(p->nCol<1) ) return;
9155792020
pCol = &p->aCol[p->nCol-1];
91558
- assert( pCol->zType==0 );
92021
+ assert( pCol->zType==0 || CORRUPT_DB );
92022
+ sqlite3DbFree(pParse->db, pCol->zType);
9155992023
pCol->zType = sqlite3NameFromToken(pParse->db, pType);
9156092024
pCol->affinity = sqlite3AffinityType(pCol->zType, &pCol->szEst);
9156192025
}
9156292026
9156392027
/*
@@ -92787,10 +93251,11 @@
9278793251
if( db->mallocFailed ){
9278893252
goto exit_drop_table;
9278993253
}
9279093254
assert( pParse->nErr==0 );
9279193255
assert( pName->nSrc==1 );
93256
+ if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
9279293257
if( noErr ) db->suppressErr++;
9279393258
pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
9279493259
if( noErr ) db->suppressErr--;
9279593260
9279693261
if( pTab==0 ){
@@ -93100,11 +93565,12 @@
9310093565
sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
9310193566
}else{
9310293567
addr2 = sqlite3VdbeCurrentAddr(v);
9310393568
}
9310493569
sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
93105
- sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
93570
+ sqlite3VdbeAddOp3(v, OP_Last, iIdx, 0, -1);
93571
+ sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0);
9310693572
sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
9310793573
sqlite3ReleaseTempReg(pParse, regRecord);
9310893574
sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);
9310993575
sqlite3VdbeJumpHere(v, addr1);
9311093576
@@ -93193,12 +93659,11 @@
9319393659
int nExtra = 0; /* Space allocated for zExtra[] */
9319493660
int nExtraCol; /* Number of extra columns needed */
9319593661
char *zExtra = 0; /* Extra space after the Index object */
9319693662
Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
9319793663
93198
- assert( pParse->nErr==0 ); /* Never called with prior errors */
93199
- if( db->mallocFailed || IN_DECLARE_VTAB ){
93664
+ if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){
9320093665
goto exit_create_index;
9320193666
}
9320293667
if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
9320393668
goto exit_create_index;
9320493669
}
@@ -94113,11 +94578,10 @@
9411394578
** operator with A. This routine shifts that operator over to B.
9411494579
*/
9411594580
SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){
9411694581
if( p ){
9411794582
int i;
94118
- assert( p->a || p->nSrc==0 );
9411994583
for(i=p->nSrc-1; i>0; i--){
9412094584
p->a[i].jointype = p->a[i-1].jointype;
9412194585
}
9412294586
p->a[0].jointype = 0;
9412394587
}
@@ -94360,12 +94824,11 @@
9436094824
char *zErr;
9436194825
int j;
9436294826
StrAccum errMsg;
9436394827
Table *pTab = pIdx->pTable;
9436494828
94365
- sqlite3StrAccumInit(&errMsg, 0, 0, 200);
94366
- errMsg.db = pParse->db;
94829
+ sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);
9436794830
for(j=0; j<pIdx->nKeyCol; j++){
9436894831
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
9436994832
if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
9437094833
sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
9437194834
sqlite3StrAccumAppend(&errMsg, ".", 1);
@@ -96190,17 +96653,17 @@
9619096653
){
9619196654
PrintfArguments x;
9619296655
StrAccum str;
9619396656
const char *zFormat;
9619496657
int n;
96658
+ sqlite3 *db = sqlite3_context_db_handle(context);
9619596659
9619696660
if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){
9619796661
x.nArg = argc-1;
9619896662
x.nUsed = 0;
9619996663
x.apArg = argv+1;
96200
- sqlite3StrAccumInit(&str, 0, 0, SQLITE_MAX_LENGTH);
96201
- str.db = sqlite3_context_db_handle(context);
96664
+ sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
9620296665
sqlite3XPrintf(&str, SQLITE_PRINTF_SQLFUNC, zFormat, &x);
9620396666
n = str.nChar;
9620496667
sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
9620596668
SQLITE_DYNAMIC);
9620696669
}
@@ -96346,11 +96809,11 @@
9634696809
sqlite3_result_double(context, r);
9634796810
}
9634896811
#endif
9634996812
9635096813
/*
96351
-** Allocate nByte bytes of space using sqlite3_malloc(). If the
96814
+** Allocate nByte bytes of space using sqlite3Malloc(). If the
9635296815
** allocation fails, call sqlite3_result_error_nomem() to notify
9635396816
** the database handle that malloc() has failed and return NULL.
9635496817
** If nByte is larger than the maximum string or blob length, then
9635596818
** raise an SQLITE_TOOBIG exception and return NULL.
9635696819
*/
@@ -96720,11 +97183,11 @@
9672097183
}
9672197184
9672297185
/*
9672397186
** The sqlite3_strglob() interface.
9672497187
*/
96725
-SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){
97188
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){
9672697189
return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
9672797190
}
9672897191
9672997192
/*
9673097193
** Count the number of times that the LIKE operator (or GLOB which is
@@ -97015,11 +97478,11 @@
9701597478
int argc,
9701697479
sqlite3_value **argv
9701797480
){
9701897481
unsigned char *z, *zOut;
9701997482
int i;
97020
- zOut = z = sqlite3_malloc( argc*4+1 );
97483
+ zOut = z = sqlite3_malloc64( argc*4+1 );
9702197484
if( z==0 ){
9702297485
sqlite3_result_error_nomem(context);
9702397486
return;
9702497487
}
9702597488
for(i=0; i<argc; i++){
@@ -97163,11 +97626,11 @@
9716397626
sqlite3_result_error_toobig(context);
9716497627
sqlite3_free(zOut);
9716597628
return;
9716697629
}
9716797630
zOld = zOut;
97168
- zOut = sqlite3_realloc(zOut, (int)nOut);
97631
+ zOut = sqlite3_realloc64(zOut, (int)nOut);
9716997632
if( zOut==0 ){
9717097633
sqlite3_result_error_nomem(context);
9717197634
sqlite3_free(zOld);
9717297635
return;
9717397636
}
@@ -97525,12 +97988,11 @@
9752597988
if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
9752697989
pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
9752797990
9752897991
if( pAccum ){
9752997992
sqlite3 *db = sqlite3_context_db_handle(context);
97530
- int firstTerm = pAccum->useMalloc==0;
97531
- pAccum->useMalloc = 2;
97993
+ int firstTerm = pAccum->mxAlloc==0;
9753297994
pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
9753397995
if( !firstTerm ){
9753497996
if( argc==2 ){
9753597997
zSep = (char*)sqlite3_value_text(argv[1]);
9753697998
nSep = sqlite3_value_bytes(argv[1]);
@@ -98946,11 +99408,12 @@
9894699408
int iFromCol; /* Idx of column in child table */
9894799409
Expr *pEq; /* tFromCol = OLD.tToCol */
9894899410
9894999411
iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
9895099412
assert( iFromCol>=0 );
98951
- tToCol.z = pIdx ? pTab->aCol[pIdx->aiColumn[i]].zName : "oid";
99413
+ assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
99414
+ tToCol.z = pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName;
9895299415
tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;
9895399416
9895499417
tToCol.n = sqlite3Strlen30(tToCol.z);
9895599418
tFromCol.n = sqlite3Strlen30(tFromCol.z);
9895699419
@@ -98958,14 +99421,14 @@
9895899421
** that the "OLD.zToCol" term is on the LHS of the = operator, so
9895999422
** that the affinity and collation sequence associated with the
9896099423
** parent table are used for the comparison. */
9896199424
pEq = sqlite3PExpr(pParse, TK_EQ,
9896299425
sqlite3PExpr(pParse, TK_DOT,
98963
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
98964
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
99426
+ sqlite3ExprAlloc(db, TK_ID, &tOld, 0),
99427
+ sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)
9896599428
, 0),
98966
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
99429
+ sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0)
9896799430
, 0);
9896899431
pWhere = sqlite3ExprAnd(db, pWhere, pEq);
9896999432
9897099433
/* For ON UPDATE, construct the next term of the WHEN clause.
9897199434
** The final WHEN clause will be like this:
@@ -98973,27 +99436,27 @@
9897399436
** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)
9897499437
*/
9897599438
if( pChanges ){
9897699439
pEq = sqlite3PExpr(pParse, TK_IS,
9897799440
sqlite3PExpr(pParse, TK_DOT,
98978
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
98979
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
99441
+ sqlite3ExprAlloc(db, TK_ID, &tOld, 0),
99442
+ sqlite3ExprAlloc(db, TK_ID, &tToCol, 0),
9898099443
0),
9898199444
sqlite3PExpr(pParse, TK_DOT,
98982
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
98983
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
99445
+ sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
99446
+ sqlite3ExprAlloc(db, TK_ID, &tToCol, 0),
9898499447
0),
9898599448
0);
9898699449
pWhen = sqlite3ExprAnd(db, pWhen, pEq);
9898799450
}
9898899451
9898999452
if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){
9899099453
Expr *pNew;
9899199454
if( action==OE_Cascade ){
9899299455
pNew = sqlite3PExpr(pParse, TK_DOT,
98993
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
98994
- sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
99456
+ sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
99457
+ sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)
9899599458
, 0);
9899699459
}else if( action==OE_SetDflt ){
9899799460
Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
9899899461
if( pDflt ){
9899999462
pNew = sqlite3ExprDup(db, pDflt, 0);
@@ -99036,17 +99499,16 @@
9903699499
db->lookaside.bEnabled = 0;
9903799500
9903899501
pTrigger = (Trigger *)sqlite3DbMallocZero(db,
9903999502
sizeof(Trigger) + /* struct Trigger */
9904099503
sizeof(TriggerStep) + /* Single step in trigger program */
99041
- nFrom + 1 /* Space for pStep->target.z */
99504
+ nFrom + 1 /* Space for pStep->zTarget */
9904299505
);
9904399506
if( pTrigger ){
9904499507
pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
99045
- pStep->target.z = (char *)&pStep[1];
99046
- pStep->target.n = nFrom;
99047
- memcpy((char *)pStep->target.z, zFrom, nFrom);
99508
+ pStep->zTarget = (char *)&pStep[1];
99509
+ memcpy((char *)pStep->zTarget, zFrom, nFrom);
9904899510
9904999511
pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
9905099512
pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
9905199513
pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
9905299514
if( pWhen ){
@@ -99507,24 +99969,27 @@
9950799969
);
9950899970
9950999971
/*
9951099972
** This routine is called to handle SQL of the following forms:
9951199973
**
99512
-** insert into TABLE (IDLIST) values(EXPRLIST)
99974
+** insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...
9951399975
** insert into TABLE (IDLIST) select
99976
+** insert into TABLE (IDLIST) default values
9951499977
**
9951599978
** The IDLIST following the table name is always optional. If omitted,
99516
-** then a list of all columns for the table is substituted. The IDLIST
99517
-** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted.
99979
+** then a list of all (non-hidden) columns for the table is substituted.
99980
+** The IDLIST appears in the pColumn parameter. pColumn is NULL if IDLIST
99981
+** is omitted.
9951899982
**
99519
-** The pList parameter holds EXPRLIST in the first form of the INSERT
99520
-** statement above, and pSelect is NULL. For the second form, pList is
99521
-** NULL and pSelect is a pointer to the select statement used to generate
99522
-** data for the insert.
99983
+** For the pSelect parameter holds the values to be inserted for the
99984
+** first two forms shown above. A VALUES clause is really just short-hand
99985
+** for a SELECT statement that omits the FROM clause and everything else
99986
+** that follows. If the pSelect parameter is NULL, that means that the
99987
+** DEFAULT VALUES form of the INSERT statement is intended.
9952399988
**
9952499989
** The code generated follows one of four templates. For a simple
99525
-** insert with data coming from a VALUES clause, the code executes
99990
+** insert with data coming from a single-row VALUES clause, the code executes
9952699991
** once straight down through. Pseudo-code follows (we call this
9952799992
** the "1st template"):
9952899993
**
9952999994
** open write cursor to <table> and its indices
9953099995
** put VALUES clause expressions into registers
@@ -99627,11 +100092,11 @@
99627100092
int iDb; /* Index of database holding TABLE */
99628100093
Db *pDb; /* The database containing table being inserted into */
99629100094
u8 useTempTable = 0; /* Store SELECT results in intermediate table */
99630100095
u8 appendFlag = 0; /* True if the insert is likely to be an append */
99631100096
u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
99632
- u8 bIdListInOrder = 1; /* True if IDLIST is in table order */
100097
+ u8 bIdListInOrder; /* True if IDLIST is in table order */
99633100098
ExprList *pList = 0; /* List of VALUES() to be inserted */
99634100099
99635100100
/* Register allocations */
99636100101
int regFromSelect = 0;/* Base register for data coming from SELECT */
99637100102
int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
@@ -99652,12 +100117,12 @@
99652100117
if( pParse->nErr || db->mallocFailed ){
99653100118
goto insert_cleanup;
99654100119
}
99655100120
99656100121
/* If the Select object is really just a simple VALUES() list with a
99657
- ** single row values (the common case) then keep that one row of values
99658
- ** and go ahead and discard the Select object
100122
+ ** single row (the common case) then keep that one row of values
100123
+ ** and discard the other (unused) parts of the pSelect object
99659100124
*/
99660100125
if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){
99661100126
pList = pSelect->pEList;
99662100127
pSelect->pEList = 0;
99663100128
sqlite3SelectDelete(db, pSelect);
@@ -99761,10 +100226,11 @@
99761100226
** the index into IDLIST of the primary key column. ipkColumn is
99762100227
** the index of the primary key as it appears in IDLIST, not as
99763100228
** is appears in the original table. (The index of the INTEGER
99764100229
** PRIMARY KEY in the original table is pTab->iPKey.)
99765100230
*/
100231
+ bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;
99766100232
if( pColumn ){
99767100233
for(i=0; i<pColumn->nId; i++){
99768100234
pColumn->a[i].idx = -1;
99769100235
}
99770100236
for(i=0; i<pColumn->nId; i++){
@@ -99796,11 +100262,12 @@
99796100262
** is coming from a SELECT statement, then generate a co-routine that
99797100263
** produces a single row of the SELECT on each invocation. The
99798100264
** co-routine is the common header to the 3rd and 4th templates.
99799100265
*/
99800100266
if( pSelect ){
99801
- /* Data is coming from a SELECT. Generate a co-routine to run the SELECT */
100267
+ /* Data is coming from a SELECT or from a multi-row VALUES clause.
100268
+ ** Generate a co-routine to run the SELECT. */
99802100269
int regYield; /* Register holding co-routine entry-point */
99803100270
int addrTop; /* Top of the co-routine */
99804100271
int rc; /* Result code */
99805100272
99806100273
regYield = ++pParse->nMem;
@@ -99809,12 +100276,11 @@
99809100276
sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
99810100277
dest.iSdst = bIdListInOrder ? regData : 0;
99811100278
dest.nSdst = pTab->nCol;
99812100279
rc = sqlite3Select(pParse, pSelect, &dest);
99813100280
regFromSelect = dest.iSdst;
99814
- assert( pParse->nErr==0 || rc );
99815
- if( rc || db->mallocFailed ) goto insert_cleanup;
100281
+ if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
99816100282
sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
99817100283
sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
99818100284
assert( pSelect->pEList );
99819100285
nColumn = pSelect->pEList->nExpr;
99820100286
@@ -99858,12 +100324,12 @@
99858100324
sqlite3VdbeJumpHere(v, addrL);
99859100325
sqlite3ReleaseTempReg(pParse, regRec);
99860100326
sqlite3ReleaseTempReg(pParse, regTempRowid);
99861100327
}
99862100328
}else{
99863
- /* This is the case if the data for the INSERT is coming from a VALUES
99864
- ** clause
100329
+ /* This is the case if the data for the INSERT is coming from a
100330
+ ** single-row VALUES clause
99865100331
*/
99866100332
NameContext sNC;
99867100333
memset(&sNC, 0, sizeof(sNC));
99868100334
sNC.pParse = pParse;
99869100335
srcTab = -1;
@@ -100930,10 +101396,11 @@
100930101396
Table *pDest, /* The table we are inserting into */
100931101397
Select *pSelect, /* A SELECT statement to use as the data source */
100932101398
int onError, /* How to handle constraint errors */
100933101399
int iDbDest /* The database of pDest */
100934101400
){
101401
+ sqlite3 *db = pParse->db;
100935101402
ExprList *pEList; /* The result set of the SELECT */
100936101403
Table *pSrc; /* The table in the FROM clause of SELECT */
100937101404
Index *pSrcIdx, *pDestIdx; /* Source and destination indices */
100938101405
struct SrcList_item *pItem; /* An element of pSelect->pSrc */
100939101406
int i; /* Loop counter */
@@ -101077,15 +101544,15 @@
101077101544
** But the main beneficiary of the transfer optimization is the VACUUM
101078101545
** command, and the VACUUM command disables foreign key constraints. So
101079101546
** the extra complication to make this rule less restrictive is probably
101080101547
** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
101081101548
*/
101082
- if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
101549
+ if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
101083101550
return 0;
101084101551
}
101085101552
#endif
101086
- if( (pParse->db->flags & SQLITE_CountRows)!=0 ){
101553
+ if( (db->flags & SQLITE_CountRows)!=0 ){
101087101554
return 0; /* xfer opt does not play well with PRAGMA count_changes */
101088101555
}
101089101556
101090101557
/* If we get this far, it means that the xfer optimization is at
101091101558
** least a possibility, though it might only work if the destination
@@ -101092,28 +101559,32 @@
101092101559
** table (tab1) is initially empty.
101093101560
*/
101094101561
#ifdef SQLITE_TEST
101095101562
sqlite3_xferopt_count++;
101096101563
#endif
101097
- iDbSrc = sqlite3SchemaToIndex(pParse->db, pSrc->pSchema);
101564
+ iDbSrc = sqlite3SchemaToIndex(db, pSrc->pSchema);
101098101565
v = sqlite3GetVdbe(pParse);
101099101566
sqlite3CodeVerifySchema(pParse, iDbSrc);
101100101567
iSrc = pParse->nTab++;
101101101568
iDest = pParse->nTab++;
101102101569
regAutoinc = autoIncBegin(pParse, iDbDest, pDest);
101103101570
regData = sqlite3GetTempReg(pParse);
101104101571
regRowid = sqlite3GetTempReg(pParse);
101105101572
sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);
101106101573
assert( HasRowid(pDest) || destHasUniqueIdx );
101107
- if( (pDest->iPKey<0 && pDest->pIndex!=0) /* (1) */
101574
+ if( (db->flags & SQLITE_Vacuum)==0 && (
101575
+ (pDest->iPKey<0 && pDest->pIndex!=0) /* (1) */
101108101576
|| destHasUniqueIdx /* (2) */
101109101577
|| (onError!=OE_Abort && onError!=OE_Rollback) /* (3) */
101110
- ){
101578
+ )){
101111101579
/* In some circumstances, we are able to run the xfer optimization
101112
- ** only if the destination table is initially empty. This code makes
101113
- ** that determination. Conditions under which the destination must
101114
- ** be empty:
101580
+ ** only if the destination table is initially empty. Unless the
101581
+ ** SQLITE_Vacuum flag is set, this block generates code to make
101582
+ ** that determination. If SQLITE_Vacuum is set, then the destination
101583
+ ** table is always empty.
101584
+ **
101585
+ ** Conditions under which the destination must be empty:
101115101586
**
101116101587
** (1) There is no INTEGER PRIMARY KEY but there are indices.
101117101588
** (If the destination is not initially empty, the rowid fields
101118101589
** of index entries might need to change.)
101119101590
**
@@ -101152,10 +101623,11 @@
101152101623
}else{
101153101624
sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);
101154101625
sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);
101155101626
}
101156101627
for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){
101628
+ u8 useSeekResult = 0;
101157101629
for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){
101158101630
if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;
101159101631
}
101160101632
assert( pSrcIdx );
101161101633
sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);
@@ -101165,11 +101637,37 @@
101165101637
sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);
101166101638
sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
101167101639
VdbeComment((v, "%s", pDestIdx->zName));
101168101640
addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
101169101641
sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
101642
+ if( db->flags & SQLITE_Vacuum ){
101643
+ /* This INSERT command is part of a VACUUM operation, which guarantees
101644
+ ** that the destination table is empty. If all indexed columns use
101645
+ ** collation sequence BINARY, then it can also be assumed that the
101646
+ ** index will be populated by inserting keys in strictly sorted
101647
+ ** order. In this case, instead of seeking within the b-tree as part
101648
+ ** of every OP_IdxInsert opcode, an OP_Last is added before the
101649
+ ** OP_IdxInsert to seek to the point within the b-tree where each key
101650
+ ** should be inserted. This is faster.
101651
+ **
101652
+ ** If any of the indexed columns use a collation sequence other than
101653
+ ** BINARY, this optimization is disabled. This is because the user
101654
+ ** might change the definition of a collation sequence and then run
101655
+ ** a VACUUM command. In that case keys may not be written in strictly
101656
+ ** sorted order. */
101657
+ for(i=0; i<pSrcIdx->nColumn; i++){
101658
+ char *zColl = pSrcIdx->azColl[i];
101659
+ assert( zColl!=0 );
101660
+ if( sqlite3_stricmp("BINARY", zColl) ) break;
101661
+ }
101662
+ if( i==pSrcIdx->nColumn ){
101663
+ useSeekResult = OPFLAG_USESEEKRESULT;
101664
+ sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
101665
+ }
101666
+ }
101170101667
sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);
101668
+ sqlite3VdbeChangeP5(v, useSeekResult);
101171101669
sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);
101172101670
sqlite3VdbeJumpHere(v, addr1);
101173101671
sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
101174101672
sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
101175101673
}
@@ -101215,11 +101713,11 @@
101215101713
** If the SQL is a query, then for each row in the query result
101216101714
** the xCallback() function is called. pArg becomes the first
101217101715
** argument to xCallback(). If xCallback=NULL then no callback
101218101716
** is invoked, even for queries.
101219101717
*/
101220
-SQLITE_API int sqlite3_exec(
101718
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
101221101719
sqlite3 *db, /* The database on which the SQL executes */
101222101720
const char *zSql, /* The SQL to be executed */
101223101721
sqlite3_callback xCallback, /* Invoke this callback routine */
101224101722
void *pArg, /* First argument to xCallback() */
101225101723
char **pzErrMsg /* Write error messages here */
@@ -102284,11 +102782,11 @@
102284102782
int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
102285102783
char *zErrmsg = 0;
102286102784
const char *zEntry;
102287102785
char *zAltEntry = 0;
102288102786
void **aHandle;
102289
- int nMsg = 300 + sqlite3Strlen30(zFile);
102787
+ u64 nMsg = 300 + sqlite3Strlen30(zFile);
102290102788
int ii;
102291102789
102292102790
/* Shared library endings to try if zFile cannot be loaded as written */
102293102791
static const char *azEndings[] = {
102294102792
#if SQLITE_OS_WIN
@@ -102327,11 +102825,11 @@
102327102825
sqlite3_free(zAltFile);
102328102826
}
102329102827
#endif
102330102828
if( handle==0 ){
102331102829
if( pzErrMsg ){
102332
- *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
102830
+ *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
102333102831
if( zErrmsg ){
102334102832
sqlite3_snprintf(nMsg, zErrmsg,
102335102833
"unable to open shared library [%s]", zFile);
102336102834
sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102337102835
}
@@ -102353,11 +102851,11 @@
102353102851
** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init
102354102852
*/
102355102853
if( xInit==0 && zProc==0 ){
102356102854
int iFile, iEntry, c;
102357102855
int ncFile = sqlite3Strlen30(zFile);
102358
- zAltEntry = sqlite3_malloc(ncFile+30);
102856
+ zAltEntry = sqlite3_malloc64(ncFile+30);
102359102857
if( zAltEntry==0 ){
102360102858
sqlite3OsDlClose(pVfs, handle);
102361102859
return SQLITE_NOMEM;
102362102860
}
102363102861
memcpy(zAltEntry, "sqlite3_", 8);
@@ -102375,11 +102873,11 @@
102375102873
sqlite3OsDlSym(pVfs, handle, zEntry);
102376102874
}
102377102875
if( xInit==0 ){
102378102876
if( pzErrMsg ){
102379102877
nMsg += sqlite3Strlen30(zEntry);
102380
- *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
102878
+ *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
102381102879
if( zErrmsg ){
102382102880
sqlite3_snprintf(nMsg, zErrmsg,
102383102881
"no entry point [%s] in shared library [%s]", zEntry, zFile);
102384102882
sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102385102883
}
@@ -102410,11 +102908,11 @@
102410102908
db->aExtension = aHandle;
102411102909
102412102910
db->aExtension[db->nExtension++] = handle;
102413102911
return SQLITE_OK;
102414102912
}
102415
-SQLITE_API int sqlite3_load_extension(
102913
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
102416102914
sqlite3 *db, /* Load the extension into this database connection */
102417102915
const char *zFile, /* Name of the shared library containing extension */
102418102916
const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102419102917
char **pzErrMsg /* Put error message here if not 0 */
102420102918
){
@@ -102441,11 +102939,11 @@
102441102939
102442102940
/*
102443102941
** Enable or disable extension loading. Extension loading is disabled by
102444102942
** default so as not to open security holes in older applications.
102445102943
*/
102446
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102944
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102447102945
sqlite3_mutex_enter(db->mutex);
102448102946
if( onoff ){
102449102947
db->flags |= SQLITE_LoadExtension;
102450102948
}else{
102451102949
db->flags &= ~SQLITE_LoadExtension;
@@ -102474,11 +102972,11 @@
102474102972
** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER
102475102973
** mutex must be held while accessing this list.
102476102974
*/
102477102975
typedef struct sqlite3AutoExtList sqlite3AutoExtList;
102478102976
static SQLITE_WSD struct sqlite3AutoExtList {
102479
- int nExt; /* Number of entries in aExt[] */
102977
+ u32 nExt; /* Number of entries in aExt[] */
102480102978
void (**aExt)(void); /* Pointers to the extension init functions */
102481102979
} sqlite3Autoext = { 0, 0 };
102482102980
102483102981
/* The "wsdAutoext" macro will resolve to the autoextension
102484102982
** state vector. If writable static data is unsupported on the target,
@@ -102498,32 +102996,32 @@
102498102996
102499102997
/*
102500102998
** Register a statically linked extension that is automatically
102501102999
** loaded by every new database connection.
102502103000
*/
102503
-SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
103001
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
102504103002
int rc = SQLITE_OK;
102505103003
#ifndef SQLITE_OMIT_AUTOINIT
102506103004
rc = sqlite3_initialize();
102507103005
if( rc ){
102508103006
return rc;
102509103007
}else
102510103008
#endif
102511103009
{
102512
- int i;
103010
+ u32 i;
102513103011
#if SQLITE_THREADSAFE
102514103012
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102515103013
#endif
102516103014
wsdAutoextInit;
102517103015
sqlite3_mutex_enter(mutex);
102518103016
for(i=0; i<wsdAutoext.nExt; i++){
102519103017
if( wsdAutoext.aExt[i]==xInit ) break;
102520103018
}
102521103019
if( i==wsdAutoext.nExt ){
102522
- int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);
103020
+ u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);
102523103021
void (**aNew)(void);
102524
- aNew = sqlite3_realloc(wsdAutoext.aExt, nByte);
103022
+ aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte);
102525103023
if( aNew==0 ){
102526103024
rc = SQLITE_NOMEM;
102527103025
}else{
102528103026
wsdAutoext.aExt = aNew;
102529103027
wsdAutoext.aExt[wsdAutoext.nExt] = xInit;
@@ -102543,19 +103041,19 @@
102543103041
** routine is a no-op.
102544103042
**
102545103043
** Return 1 if xInit was found on the list and removed. Return 0 if xInit
102546103044
** was not on the list.
102547103045
*/
102548
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
103046
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
102549103047
#if SQLITE_THREADSAFE
102550103048
sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102551103049
#endif
102552103050
int i;
102553103051
int n = 0;
102554103052
wsdAutoextInit;
102555103053
sqlite3_mutex_enter(mutex);
102556
- for(i=wsdAutoext.nExt-1; i>=0; i--){
103054
+ for(i=(int)wsdAutoext.nExt-1; i>=0; i--){
102557103055
if( wsdAutoext.aExt[i]==xInit ){
102558103056
wsdAutoext.nExt--;
102559103057
wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];
102560103058
n++;
102561103059
break;
@@ -102566,11 +103064,11 @@
102566103064
}
102567103065
102568103066
/*
102569103067
** Reset the automatic extension loading mechanism.
102570103068
*/
102571
-SQLITE_API void sqlite3_reset_auto_extension(void){
103069
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){
102572103070
#ifndef SQLITE_OMIT_AUTOINIT
102573103071
if( sqlite3_initialize()==SQLITE_OK )
102574103072
#endif
102575103073
{
102576103074
#if SQLITE_THREADSAFE
@@ -102589,11 +103087,11 @@
102589103087
** Load all automatic extensions.
102590103088
**
102591103089
** If anything goes wrong, set an error in the database connection.
102592103090
*/
102593103091
SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
102594
- int i;
103092
+ u32 i;
102595103093
int go = 1;
102596103094
int rc;
102597103095
int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
102598103096
102599103097
wsdAutoextInit;
@@ -103253,19 +103751,19 @@
103253103751
/*
103254103752
** Generate code to return a single integer value.
103255103753
*/
103256103754
static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
103257103755
Vdbe *v = sqlite3GetVdbe(pParse);
103258
- int mem = ++pParse->nMem;
103756
+ int nMem = ++pParse->nMem;
103259103757
i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
103260103758
if( pI64 ){
103261103759
memcpy(pI64, &value, sizeof(value));
103262103760
}
103263
- sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
103761
+ sqlite3VdbeAddOp4(v, OP_Int64, 0, nMem, 0, (char*)pI64, P4_INT64);
103264103762
sqlite3VdbeSetNumCols(v, 1);
103265103763
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
103266
- sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
103764
+ sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
103267103765
}
103268103766
103269103767
103270103768
/*
103271103769
** Set the safety_level and pager flags for pager iDb. Or if iDb<0
@@ -103426,15 +103924,15 @@
103426103924
aFcntl[3] = 0;
103427103925
db->busyHandler.nBusy = 0;
103428103926
rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
103429103927
if( rc==SQLITE_OK ){
103430103928
if( aFcntl[0] ){
103431
- int mem = ++pParse->nMem;
103432
- sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
103929
+ int nMem = ++pParse->nMem;
103930
+ sqlite3VdbeAddOp4(v, OP_String8, 0, nMem, 0, aFcntl[0], 0);
103433103931
sqlite3VdbeSetNumCols(v, 1);
103434103932
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
103435
- sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
103933
+ sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
103436103934
sqlite3_free(aFcntl[0]);
103437103935
}
103438103936
goto pragma_out;
103439103937
}
103440103938
if( rc!=SQLITE_NOTFOUND ){
@@ -104035,11 +104533,13 @@
104035104533
}else{
104036104534
if( !db->autoCommit ){
104037104535
sqlite3ErrorMsg(pParse,
104038104536
"Safety level may not be changed inside a transaction");
104039104537
}else{
104040
- pDb->safety_level = getSafetyLevel(zRight,0,1)+1;
104538
+ int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
104539
+ if( iLevel==0 ) iLevel = 1;
104540
+ pDb->safety_level = iLevel;
104041104541
setAllPagerFlags(db);
104042104542
}
104043104543
}
104044104544
break;
104045104545
}
@@ -104130,11 +104630,11 @@
104130104630
if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
104131104631
k = 0;
104132104632
}else if( pPk==0 ){
104133104633
k = 1;
104134104634
}else{
104135
- for(k=1; ALWAYS(k<=pTab->nCol) && pPk->aiColumn[k-1]!=i; k++){}
104635
+ for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
104136104636
}
104137104637
sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
104138104638
sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
104139104639
}
104140104640
}
@@ -105136,11 +105636,11 @@
105136105636
105137105637
assert( iDb>=0 && iDb<db->nDb );
105138105638
if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
105139105639
if( argv[1]==0 ){
105140105640
corruptSchema(pData, argv[0], 0);
105141
- }else if( argv[2] && argv[2][0] ){
105641
+ }else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){
105142105642
/* Call the parser to process a CREATE TABLE, INDEX or VIEW.
105143105643
** But because db->init.busy is set to 1, no VDBE code is generated
105144105644
** or executed. All the parser does is build the internal data
105145105645
** structures that describe the table, index, or view.
105146105646
*/
@@ -105167,12 +105667,12 @@
105167105667
corruptSchema(pData, argv[0], sqlite3_errmsg(db));
105168105668
}
105169105669
}
105170105670
}
105171105671
sqlite3_finalize(pStmt);
105172
- }else if( argv[0]==0 ){
105173
- corruptSchema(pData, 0, 0);
105672
+ }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){
105673
+ corruptSchema(pData, argv[0], 0);
105174105674
}else{
105175105675
/* If the SQL column is blank it means this is an index that
105176105676
** was created to be the PRIMARY KEY or to fulfill a UNIQUE
105177105677
** constraint for a CREATE TABLE. The index should have already
105178105678
** been created when we processed the CREATE TABLE. All we have
@@ -105846,11 +106346,11 @@
105846106346
** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105847106347
** sqlite3_step(). In the new version, the original SQL text is retained
105848106348
** and the statement is automatically recompiled if an schema change
105849106349
** occurs.
105850106350
*/
105851
-SQLITE_API int sqlite3_prepare(
106351
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
105852106352
sqlite3 *db, /* Database handle. */
105853106353
const char *zSql, /* UTF-8 encoded SQL statement. */
105854106354
int nBytes, /* Length of zSql in bytes. */
105855106355
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105856106356
const char **pzTail /* OUT: End of parsed string */
@@ -105858,11 +106358,11 @@
105858106358
int rc;
105859106359
rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
105860106360
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105861106361
return rc;
105862106362
}
105863
-SQLITE_API int sqlite3_prepare_v2(
106363
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
105864106364
sqlite3 *db, /* Database handle. */
105865106365
const char *zSql, /* UTF-8 encoded SQL statement. */
105866106366
int nBytes, /* Length of zSql in bytes. */
105867106367
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105868106368
const char **pzTail /* OUT: End of parsed string */
@@ -105934,11 +106434,11 @@
105934106434
** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105935106435
** sqlite3_step(). In the new version, the original SQL text is retained
105936106436
** and the statement is automatically recompiled if an schema change
105937106437
** occurs.
105938106438
*/
105939
-SQLITE_API int sqlite3_prepare16(
106439
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
105940106440
sqlite3 *db, /* Database handle. */
105941106441
const void *zSql, /* UTF-16 encoded SQL statement. */
105942106442
int nBytes, /* Length of zSql in bytes. */
105943106443
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105944106444
const void **pzTail /* OUT: End of parsed string */
@@ -105946,11 +106446,11 @@
105946106446
int rc;
105947106447
rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
105948106448
assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105949106449
return rc;
105950106450
}
105951
-SQLITE_API int sqlite3_prepare16_v2(
106451
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
105952106452
sqlite3 *db, /* Database handle. */
105953106453
const void *zSql, /* UTF-16 encoded SQL statement. */
105954106454
int nBytes, /* Length of zSql in bytes. */
105955106455
sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105956106456
const void **pzTail /* OUT: End of parsed string */
@@ -106075,11 +106575,10 @@
106075106575
){
106076106576
Select *pNew;
106077106577
Select standin;
106078106578
sqlite3 *db = pParse->db;
106079106579
pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
106080
- assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */
106081106580
if( pNew==0 ){
106082106581
assert( db->mallocFailed );
106083106582
pNew = &standin;
106084106583
memset(pNew, 0, sizeof(*pNew));
106085106584
}
@@ -106095,11 +106594,11 @@
106095106594
pNew->pOrderBy = pOrderBy;
106096106595
pNew->selFlags = selFlags;
106097106596
pNew->op = TK_SELECT;
106098106597
pNew->pLimit = pLimit;
106099106598
pNew->pOffset = pOffset;
106100
- assert( pOffset==0 || pLimit!=0 );
106599
+ assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 );
106101106600
pNew->addrOpenEphm[0] = -1;
106102106601
pNew->addrOpenEphm[1] = -1;
106103106602
if( db->mallocFailed ) {
106104106603
clearSelect(db, pNew, pNew!=&standin);
106105106604
pNew = 0;
@@ -107345,11 +107844,11 @@
107345107844
if( pS ){
107346107845
/* The "table" is actually a sub-select or a view in the FROM clause
107347107846
** of the SELECT statement. Return the declaration type and origin
107348107847
** data for the result-set column of the sub-select.
107349107848
*/
107350
- if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
107849
+ if( iCol>=0 && iCol<pS->pEList->nExpr ){
107351107850
/* If iCol is less than zero, then the expression requests the
107352107851
** rowid of the sub-select or view. This expression is legal (see
107353107852
** test case misc2.2.2) - it always evaluates to NULL.
107354107853
*/
107355107854
NameContext sNC;
@@ -107665,16 +108164,18 @@
107665108164
memset(&sNC, 0, sizeof(sNC));
107666108165
sNC.pSrcList = pSelect->pSrc;
107667108166
a = pSelect->pEList->a;
107668108167
for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
107669108168
p = a[i].pExpr;
107670
- pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
108169
+ if( pCol->zType==0 ){
108170
+ pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
108171
+ }
107671108172
szAll += pCol->szEst;
107672108173
pCol->affinity = sqlite3ExprAffinity(p);
107673108174
if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
107674108175
pColl = sqlite3ExprCollSeq(pParse, p);
107675
- if( pColl ){
108176
+ if( pColl && pCol->zColl==0 ){
107676108177
pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
107677108178
}
107678108179
}
107679108180
pTab->szTabRow = sqlite3LogEst(szAll*4);
107680108181
}
@@ -108072,12 +108573,11 @@
108072108573
){
108073108574
Select *pPrior;
108074108575
int nExpr = p->pEList->nExpr;
108075108576
int nRow = 1;
108076108577
int rc = 0;
108077
- assert( p->pNext==0 );
108078
- assert( p->selFlags & SF_AllValues );
108578
+ assert( p->selFlags & SF_MultiValue );
108079108579
do{
108080108580
assert( p->selFlags & SF_Values );
108081108581
assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
108082108582
assert( p->pLimit==0 );
108083108583
assert( p->pOffset==0 );
@@ -108182,11 +108682,11 @@
108182108682
dest.eDest = SRT_Table;
108183108683
}
108184108684
108185108685
/* Special handling for a compound-select that originates as a VALUES clause.
108186108686
*/
108187
- if( p->selFlags & SF_AllValues ){
108687
+ if( p->selFlags & SF_MultiValue ){
108188108688
rc = multiSelectValues(pParse, p, &dest);
108189108689
goto multi_select_end;
108190108690
}
108191108691
108192108692
/* Make sure all SELECTs in the statement have the same number of elements
@@ -108567,11 +109067,11 @@
108567109067
** then there should be a single item on the stack. Write this
108568109068
** item into the set table with bogus data.
108569109069
*/
108570109070
case SRT_Set: {
108571109071
int r1;
108572
- assert( pIn->nSdst==1 );
109072
+ assert( pIn->nSdst==1 || pParse->nErr>0 );
108573109073
pDest->affSdst =
108574109074
sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
108575109075
r1 = sqlite3GetTempReg(pParse);
108576109076
sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
108577109077
sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
@@ -108593,11 +109093,11 @@
108593109093
/* If this is a scalar select that is part of an expression, then
108594109094
** store the results in the appropriate memory cell and break out
108595109095
** of the scan loop.
108596109096
*/
108597109097
case SRT_Mem: {
108598
- assert( pIn->nSdst==1 );
109098
+ assert( pIn->nSdst==1 || pParse->nErr>0 ); testcase( pIn->nSdst!=1 );
108599109099
sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
108600109100
/* The LIMIT clause will jump out of the loop for us */
108601109101
break;
108602109102
}
108603109103
#endif /* #ifndef SQLITE_OMIT_SUBQUERY */
@@ -108608,11 +109108,11 @@
108608109108
case SRT_Coroutine: {
108609109109
if( pDest->iSdst==0 ){
108610109110
pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);
108611109111
pDest->nSdst = pIn->nSdst;
108612109112
}
108613
- sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst);
109113
+ sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);
108614109114
sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
108615109115
break;
108616109116
}
108617109117
108618109118
/* If none of the above, then the result destination must be
@@ -108824,12 +109324,14 @@
108824109324
*/
108825109325
aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy);
108826109326
if( aPermute ){
108827109327
struct ExprList_item *pItem;
108828109328
for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
108829
- assert( pItem->u.x.iOrderByCol>0
108830
- && pItem->u.x.iOrderByCol<=p->pEList->nExpr );
109329
+ assert( pItem->u.x.iOrderByCol>0 );
109330
+ /* assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ) is also true
109331
+ ** but only for well-formed SELECT statements. */
109332
+ testcase( pItem->u.x.iOrderByCol > p->pEList->nExpr );
108831109333
aPermute[i] = pItem->u.x.iOrderByCol - 1;
108832109334
}
108833109335
pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
108834109336
}else{
108835109337
pKeyMerge = 0;
@@ -109035,11 +109537,11 @@
109035109537
pPrior->pNext = p;
109036109538
109037109539
/*** TBD: Insert subroutine calls to close cursors on incomplete
109038109540
**** subqueries ****/
109039109541
explainComposite(pParse, p->op, iSub1, iSub2, 0);
109040
- return SQLITE_OK;
109542
+ return pParse->nErr!=0;
109041109543
}
109042109544
#endif
109043109545
109044109546
#if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
109045109547
/* Forward Declarations */
@@ -109847,11 +110349,14 @@
109847110349
pNew->pGroupBy = 0;
109848110350
pNew->pHaving = 0;
109849110351
pNew->pOrderBy = 0;
109850110352
p->pPrior = 0;
109851110353
p->pNext = 0;
110354
+ p->pWith = 0;
109852110355
p->selFlags &= ~SF_Compound;
110356
+ assert( (p->selFlags & SF_Converted)==0 );
110357
+ p->selFlags |= SF_Converted;
109853110358
assert( pNew->pPrior!=0 );
109854110359
pNew->pPrior->pNext = pNew;
109855110360
pNew->pLimit = 0;
109856110361
pNew->pOffset = 0;
109857110362
return WRC_Continue;
@@ -110383,11 +110888,11 @@
110383110888
if( pParse->hasCompound ){
110384110889
w.xSelectCallback = convertCompoundSelectToSubquery;
110385110890
sqlite3WalkSelect(&w, pSelect);
110386110891
}
110387110892
w.xSelectCallback = selectExpander;
110388
- if( (pSelect->selFlags & SF_AllValues)==0 ){
110893
+ if( (pSelect->selFlags & SF_MultiValue)==0 ){
110389110894
w.xSelectCallback2 = selectPopWith;
110390110895
}
110391110896
sqlite3WalkSelect(&w, pSelect);
110392110897
}
110393110898
@@ -110569,11 +111074,12 @@
110569111074
nArg = 0;
110570111075
regAgg = 0;
110571111076
}
110572111077
if( pF->iDistinct>=0 ){
110573111078
addrNext = sqlite3VdbeMakeLabel(v);
110574
- assert( nArg==1 );
111079
+ testcase( nArg==0 ); /* Error condition */
111080
+ testcase( nArg>1 ); /* Also an error */
110575111081
codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
110576111082
}
110577111083
if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
110578111084
CollSeq *pColl = 0;
110579111085
struct ExprList_item *pItem;
@@ -111444,14 +111950,13 @@
111444111950
111445111951
/* Jump here to skip this query
111446111952
*/
111447111953
sqlite3VdbeResolveLabel(v, iEnd);
111448111954
111449
- /* The SELECT was successfully coded. Set the return code to 0
111450
- ** to indicate no errors.
111451
- */
111452
- rc = 0;
111955
+ /* The SELECT has been coded. If there is an error in the Parse structure,
111956
+ ** set the return code to 1. Otherwise 0. */
111957
+ rc = (pParse->nErr>0);
111453111958
111454111959
/* Control jumps to here if an error is encountered above, or upon
111455111960
** successful coding of the SELECT.
111456111961
*/
111457111962
select_end:
@@ -111498,11 +112003,11 @@
111498112003
sqlite3TreeViewLine(pView, "FROM");
111499112004
for(i=0; i<p->pSrc->nSrc; i++){
111500112005
struct SrcList_item *pItem = &p->pSrc->a[i];
111501112006
StrAccum x;
111502112007
char zLine[100];
111503
- sqlite3StrAccumInit(&x, zLine, sizeof(zLine), 0);
112008
+ sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
111504112009
sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor);
111505112010
if( pItem->zDatabase ){
111506112011
sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName);
111507112012
}else if( pItem->zName ){
111508112013
sqlite3XPrintf(&x, 0, " %s", pItem->zName);
@@ -111657,11 +112162,11 @@
111657112162
for(i=0; i<nCol; i++){
111658112163
if( argv[i]==0 ){
111659112164
z = 0;
111660112165
}else{
111661112166
int n = sqlite3Strlen30(argv[i])+1;
111662
- z = sqlite3_malloc( n );
112167
+ z = sqlite3_malloc64( n );
111663112168
if( z==0 ) goto malloc_failed;
111664112169
memcpy(z, argv[i], n);
111665112170
}
111666112171
p->azResult[p->nData++] = z;
111667112172
}
@@ -111682,11 +112187,11 @@
111682112187
** The result that is written to ***pazResult is held in memory obtained
111683112188
** from malloc(). But the caller cannot free this memory directly.
111684112189
** Instead, the entire table should be passed to sqlite3_free_table() when
111685112190
** the calling procedure is finished using it.
111686112191
*/
111687
-SQLITE_API int sqlite3_get_table(
112192
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
111688112193
sqlite3 *db, /* The database on which the SQL executes */
111689112194
const char *zSql, /* The SQL to be executed */
111690112195
char ***pazResult, /* Write the result table here */
111691112196
int *pnRow, /* Write the number of rows in the result here */
111692112197
int *pnColumn, /* Write the number of columns of result here */
@@ -111706,11 +112211,11 @@
111706112211
res.nRow = 0;
111707112212
res.nColumn = 0;
111708112213
res.nData = 1;
111709112214
res.nAlloc = 20;
111710112215
res.rc = SQLITE_OK;
111711
- res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc );
112216
+ res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );
111712112217
if( res.azResult==0 ){
111713112218
db->errCode = SQLITE_NOMEM;
111714112219
return SQLITE_NOMEM;
111715112220
}
111716112221
res.azResult[0] = 0;
@@ -111734,11 +112239,11 @@
111734112239
sqlite3_free_table(&res.azResult[1]);
111735112240
return rc;
111736112241
}
111737112242
if( res.nAlloc>res.nData ){
111738112243
char **azNew;
111739
- azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
112244
+ azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );
111740112245
if( azNew==0 ){
111741112246
sqlite3_free_table(&res.azResult[1]);
111742112247
db->errCode = SQLITE_NOMEM;
111743112248
return SQLITE_NOMEM;
111744112249
}
@@ -111751,11 +112256,11 @@
111751112256
}
111752112257
111753112258
/*
111754112259
** This routine frees the space the sqlite3_get_table() malloced.
111755112260
*/
111756
-SQLITE_API void sqlite3_free_table(
112261
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(
111757112262
char **azResult /* Result returned from sqlite3_get_table() */
111758112263
){
111759112264
if( azResult ){
111760112265
int i, n;
111761112266
azResult--;
@@ -111962,11 +112467,10 @@
111962112467
}
111963112468
111964112469
/* Do not create a trigger on a system table */
111965112470
if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
111966112471
sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
111967
- pParse->nErr++;
111968112472
goto trigger_cleanup;
111969112473
}
111970112474
111971112475
/* INSTEAD of triggers are only for views and views only support INSTEAD
111972112476
** of triggers.
@@ -112142,16 +112646,16 @@
112142112646
u8 op, /* Trigger opcode */
112143112647
Token *pName /* The target name */
112144112648
){
112145112649
TriggerStep *pTriggerStep;
112146112650
112147
- pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n);
112651
+ pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
112148112652
if( pTriggerStep ){
112149112653
char *z = (char*)&pTriggerStep[1];
112150112654
memcpy(z, pName->z, pName->n);
112151
- pTriggerStep->target.z = z;
112152
- pTriggerStep->target.n = pName->n;
112655
+ sqlite3Dequote(z);
112656
+ pTriggerStep->zTarget = z;
112153112657
pTriggerStep->op = op;
112154112658
}
112155112659
return pTriggerStep;
112156112660
}
112157112661
@@ -112430,11 +112934,11 @@
112430112934
}
112431112935
return (mask ? pList : 0);
112432112936
}
112433112937
112434112938
/*
112435
-** Convert the pStep->target token into a SrcList and return a pointer
112939
+** Convert the pStep->zTarget string into a SrcList and return a pointer
112436112940
** to that SrcList.
112437112941
**
112438112942
** This routine adds a specific database name, if needed, to the target when
112439112943
** forming the SrcList. This prevents a trigger in one database from
112440112944
** referring to a target in another database. An exception is when the
@@ -112443,21 +112947,21 @@
112443112947
*/
112444112948
static SrcList *targetSrcList(
112445112949
Parse *pParse, /* The parsing context */
112446112950
TriggerStep *pStep /* The trigger containing the target token */
112447112951
){
112952
+ sqlite3 *db = pParse->db;
112448112953
int iDb; /* Index of the database to use */
112449112954
SrcList *pSrc; /* SrcList to be returned */
112450112955
112451
- pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0);
112956
+ pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
112452112957
if( pSrc ){
112453112958
assert( pSrc->nSrc>0 );
112454
- assert( pSrc->a!=0 );
112455
- iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema);
112959
+ pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);
112960
+ iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema);
112456112961
if( iDb==0 || iDb>=2 ){
112457
- sqlite3 *db = pParse->db;
112458
- assert( iDb<pParse->db->nDb );
112962
+ assert( iDb<db->nDb );
112459112963
pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
112460112964
}
112461112965
}
112462112966
return pSrc;
112463112967
}
@@ -112565,10 +113069,11 @@
112565113069
assert( pFrom->zErrMsg==0 || pFrom->nErr );
112566113070
assert( pTo->zErrMsg==0 || pTo->nErr );
112567113071
if( pTo->nErr==0 ){
112568113072
pTo->zErrMsg = pFrom->zErrMsg;
112569113073
pTo->nErr = pFrom->nErr;
113074
+ pTo->rc = pFrom->rc;
112570113075
}else{
112571113076
sqlite3DbFree(pFrom->db, pFrom->zErrMsg);
112572113077
}
112573113078
}
112574113079
@@ -113915,17 +114420,21 @@
113915114420
113916114421
/* Loop through the tables in the main database. For each, do
113917114422
** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
113918114423
** the contents to the temporary database.
113919114424
*/
114425
+ assert( (db->flags & SQLITE_Vacuum)==0 );
114426
+ db->flags |= SQLITE_Vacuum;
113920114427
rc = execExecSql(db, pzErrMsg,
113921114428
"SELECT 'INSERT INTO vacuum_db.' || quote(name) "
113922114429
"|| ' SELECT * FROM main.' || quote(name) || ';'"
113923114430
"FROM main.sqlite_master "
113924114431
"WHERE type = 'table' AND name!='sqlite_sequence' "
113925114432
" AND coalesce(rootpage,1)>0"
113926114433
);
114434
+ assert( (db->flags & SQLITE_Vacuum)!=0 );
114435
+ db->flags &= ~SQLITE_Vacuum;
113927114436
if( rc!=SQLITE_OK ) goto end_of_vacuum;
113928114437
113929114438
/* Copy over the sequence table
113930114439
*/
113931114440
rc = execExecSql(db, pzErrMsg,
@@ -114060,10 +114569,12 @@
114060114569
** are invoked only from within xCreate and xConnect methods.
114061114570
*/
114062114571
struct VtabCtx {
114063114572
VTable *pVTable; /* The virtual table being constructed */
114064114573
Table *pTab; /* The Table object to which the virtual table belongs */
114574
+ VtabCtx *pPrior; /* Parent context (if any) */
114575
+ int bDeclared; /* True after sqlite3_declare_vtab() is called */
114065114576
};
114066114577
114067114578
/*
114068114579
** The actual function that does the work of creating a new module.
114069114580
** This function implements the sqlite3_create_module() and
@@ -114111,11 +114622,11 @@
114111114622
114112114623
114113114624
/*
114114114625
** External API function used to create a new virtual-table module.
114115114626
*/
114116
-SQLITE_API int sqlite3_create_module(
114627
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
114117114628
sqlite3 *db, /* Database in which module is registered */
114118114629
const char *zName, /* Name assigned to this module */
114119114630
const sqlite3_module *pModule, /* The definition of the module */
114120114631
void *pAux /* Context pointer for xCreate/xConnect */
114121114632
){
@@ -114126,11 +114637,11 @@
114126114637
}
114127114638
114128114639
/*
114129114640
** External API function used to create a new virtual-table module.
114130114641
*/
114131
-SQLITE_API int sqlite3_create_module_v2(
114642
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
114132114643
sqlite3 *db, /* Database in which module is registered */
114133114644
const char *zName, /* Name assigned to this module */
114134114645
const sqlite3_module *pModule, /* The definition of the module */
114135114646
void *pAux, /* Context pointer for xCreate/xConnect */
114136114647
void (*xDestroy)(void *) /* Module destructor function */
@@ -114506,11 +115017,11 @@
114506115017
Token *pArg = &pParse->sArg;
114507115018
if( pArg->z==0 ){
114508115019
pArg->z = p->z;
114509115020
pArg->n = p->n;
114510115021
}else{
114511
- assert(pArg->z < p->z);
115022
+ assert(pArg->z <= p->z);
114512115023
pArg->n = (int)(&p->z[p->n] - pArg->z);
114513115024
}
114514115025
}
114515115026
114516115027
/*
@@ -114523,19 +115034,31 @@
114523115034
Table *pTab,
114524115035
Module *pMod,
114525115036
int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
114526115037
char **pzErr
114527115038
){
114528
- VtabCtx sCtx, *pPriorCtx;
115039
+ VtabCtx sCtx;
114529115040
VTable *pVTable;
114530115041
int rc;
114531115042
const char *const*azArg = (const char *const*)pTab->azModuleArg;
114532115043
int nArg = pTab->nModuleArg;
114533115044
char *zErr = 0;
114534
- char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
115045
+ char *zModuleName;
114535115046
int iDb;
115047
+ VtabCtx *pCtx;
114536115048
115049
+ /* Check that the virtual-table is not already being initialized */
115050
+ for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){
115051
+ if( pCtx->pTab==pTab ){
115052
+ *pzErr = sqlite3MPrintf(db,
115053
+ "vtable constructor called recursively: %s", pTab->zName
115054
+ );
115055
+ return SQLITE_LOCKED;
115056
+ }
115057
+ }
115058
+
115059
+ zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
114537115060
if( !zModuleName ){
114538115061
return SQLITE_NOMEM;
114539115062
}
114540115063
114541115064
pVTable = sqlite3DbMallocZero(db, sizeof(VTable));
@@ -114552,15 +115075,17 @@
114552115075
/* Invoke the virtual table constructor */
114553115076
assert( &db->pVtabCtx );
114554115077
assert( xConstruct );
114555115078
sCtx.pTab = pTab;
114556115079
sCtx.pVTable = pVTable;
114557
- pPriorCtx = db->pVtabCtx;
115080
+ sCtx.pPrior = db->pVtabCtx;
115081
+ sCtx.bDeclared = 0;
114558115082
db->pVtabCtx = &sCtx;
114559115083
rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
114560
- db->pVtabCtx = pPriorCtx;
115084
+ db->pVtabCtx = sCtx.pPrior;
114561115085
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
115086
+ assert( sCtx.pTab==pTab );
114562115087
114563115088
if( SQLITE_OK!=rc ){
114564115089
if( zErr==0 ){
114565115090
*pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
114566115091
}else {
@@ -114572,17 +115097,18 @@
114572115097
/* Justification of ALWAYS(): A correct vtab constructor must allocate
114573115098
** the sqlite3_vtab object if successful. */
114574115099
memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
114575115100
pVTable->pVtab->pModule = pMod->pModule;
114576115101
pVTable->nRef = 1;
114577
- if( sCtx.pTab ){
115102
+ if( sCtx.bDeclared==0 ){
114578115103
const char *zFormat = "vtable constructor did not declare schema: %s";
114579115104
*pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
114580115105
sqlite3VtabUnlock(pVTable);
114581115106
rc = SQLITE_ERROR;
114582115107
}else{
114583115108
int iCol;
115109
+ u8 oooHidden = 0;
114584115110
/* If everything went according to plan, link the new VTable structure
114585115111
** into the linked list headed by pTab->pVTable. Then loop through the
114586115112
** columns of the table to see if any of them contain the token "hidden".
114587115113
** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
114588115114
** the type string. */
@@ -114591,11 +115117,14 @@
114591115117
114592115118
for(iCol=0; iCol<pTab->nCol; iCol++){
114593115119
char *zType = pTab->aCol[iCol].zType;
114594115120
int nType;
114595115121
int i = 0;
114596
- if( !zType ) continue;
115122
+ if( !zType ){
115123
+ pTab->tabFlags |= oooHidden;
115124
+ continue;
115125
+ }
114597115126
nType = sqlite3Strlen30(zType);
114598115127
if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
114599115128
for(i=0; i<nType; i++){
114600115129
if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
114601115130
&& (zType[i+7]=='\0' || zType[i+7]==' ')
@@ -114614,10 +115143,13 @@
114614115143
if( zType[i]=='\0' && i>0 ){
114615115144
assert(zType[i-1]==' ');
114616115145
zType[i-1] = '\0';
114617115146
}
114618115147
pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;
115148
+ oooHidden = TF_OOOHidden;
115149
+ }else{
115150
+ pTab->tabFlags |= oooHidden;
114619115151
}
114620115152
}
114621115153
}
114622115154
}
114623115155
@@ -114741,13 +115273,13 @@
114741115273
/*
114742115274
** This function is used to set the schema of a virtual table. It is only
114743115275
** valid to call this function from within the xCreate() or xConnect() of a
114744115276
** virtual table module.
114745115277
*/
114746
-SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
115278
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
115279
+ VtabCtx *pCtx;
114747115280
Parse *pParse;
114748
-
114749115281
int rc = SQLITE_OK;
114750115282
Table *pTab;
114751115283
char *zErr = 0;
114752115284
114753115285
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -114754,15 +115286,17 @@
114754115286
if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
114755115287
return SQLITE_MISUSE_BKPT;
114756115288
}
114757115289
#endif
114758115290
sqlite3_mutex_enter(db->mutex);
114759
- if( !db->pVtabCtx || !(pTab = db->pVtabCtx->pTab) ){
115291
+ pCtx = db->pVtabCtx;
115292
+ if( !pCtx || pCtx->bDeclared ){
114760115293
sqlite3Error(db, SQLITE_MISUSE);
114761115294
sqlite3_mutex_leave(db->mutex);
114762115295
return SQLITE_MISUSE_BKPT;
114763115296
}
115297
+ pTab = pCtx->pTab;
114764115298
assert( (pTab->tabFlags & TF_Virtual)!=0 );
114765115299
114766115300
pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
114767115301
if( pParse==0 ){
114768115302
rc = SQLITE_NOMEM;
@@ -114781,11 +115315,11 @@
114781115315
pTab->aCol = pParse->pNewTable->aCol;
114782115316
pTab->nCol = pParse->pNewTable->nCol;
114783115317
pParse->pNewTable->nCol = 0;
114784115318
pParse->pNewTable->aCol = 0;
114785115319
}
114786
- db->pVtabCtx->pTab = 0;
115320
+ pCtx->bDeclared = 1;
114787115321
}else{
114788115322
sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
114789115323
sqlite3DbFree(db, zErr);
114790115324
rc = SQLITE_ERROR;
114791115325
}
@@ -114975,11 +115509,11 @@
114975115509
*/
114976115510
SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
114977115511
int rc = SQLITE_OK;
114978115512
114979115513
assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
114980
- assert( iSavepoint>=0 );
115514
+ assert( iSavepoint>=-1 );
114981115515
if( db->aVTrans ){
114982115516
int i;
114983115517
for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
114984115518
VTable *pVTab = db->aVTrans[i];
114985115519
const sqlite3_module *pMod = pVTab->pMod->pModule;
@@ -115093,11 +115627,11 @@
115093115627
assert( IsVirtual(pTab) );
115094115628
for(i=0; i<pToplevel->nVtabLock; i++){
115095115629
if( pTab==pToplevel->apVtabLock[i] ) return;
115096115630
}
115097115631
n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
115098
- apVtabLock = sqlite3_realloc(pToplevel->apVtabLock, n);
115632
+ apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);
115099115633
if( apVtabLock ){
115100115634
pToplevel->apVtabLock = apVtabLock;
115101115635
pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
115102115636
}else{
115103115637
pToplevel->db->mallocFailed = 1;
@@ -115109,11 +115643,11 @@
115109115643
** table update operation currently in progress.
115110115644
**
115111115645
** The results of this routine are undefined unless it is called from
115112115646
** within an xUpdate method.
115113115647
*/
115114
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
115648
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){
115115115649
static const unsigned char aMap[] = {
115116115650
SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
115117115651
};
115118115652
#ifdef SQLITE_ENABLE_API_ARMOR
115119115653
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115127,11 +115661,11 @@
115127115661
/*
115128115662
** Call from within the xCreate() or xConnect() methods to provide
115129115663
** the SQLite core with additional information about the behavior
115130115664
** of the virtual table being implemented.
115131115665
*/
115132
-SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
115666
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){
115133115667
va_list ap;
115134115668
int rc = SQLITE_OK;
115135115669
115136115670
#ifdef SQLITE_ENABLE_API_ARMOR
115137115671
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115892,17 +116426,18 @@
115892116426
** In the previous sentence and in the diagram, "slot[]" refers to
115893116427
** the WhereClause.a[] array. The slot[] array grows as needed to contain
115894116428
** all terms of the WHERE clause.
115895116429
*/
115896116430
static void whereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
116431
+ Expr *pE2 = sqlite3ExprSkipCollate(pExpr);
115897116432
pWC->op = op;
115898
- if( pExpr==0 ) return;
115899
- if( pExpr->op!=op ){
116433
+ if( pE2==0 ) return;
116434
+ if( pE2->op!=op ){
115900116435
whereClauseInsert(pWC, pExpr, 0);
115901116436
}else{
115902
- whereSplit(pWC, pExpr->pLeft, op);
115903
- whereSplit(pWC, pExpr->pRight, op);
116437
+ whereSplit(pWC, pE2->pLeft, op);
116438
+ whereSplit(pWC, pE2->pRight, op);
115904116439
}
115905116440
}
115906116441
115907116442
/*
115908116443
** Initialize a WhereMaskSet object
@@ -117169,11 +117704,11 @@
117169117704
if( p->op==TK_COLUMN
117170117705
&& p->iColumn==pIdx->aiColumn[iCol]
117171117706
&& p->iTable==iBase
117172117707
){
117173117708
CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
117174
- if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){
117709
+ if( pColl && 0==sqlite3StrICmp(pColl->zName, zColl) ){
117175117710
return i;
117176117711
}
117177117712
}
117178117713
}
117179117714
@@ -117443,11 +117978,11 @@
117443117978
if( (idxCols & cMask)==0 ){
117444117979
Expr *pX = pTerm->pExpr;
117445117980
idxCols |= cMask;
117446117981
pIdx->aiColumn[n] = pTerm->u.leftColumn;
117447117982
pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
117448
- pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : "BINARY";
117983
+ pIdx->azColl[n] = pColl ? pColl->zName : "BINARY";
117449117984
n++;
117450117985
}
117451117986
}
117452117987
}
117453117988
assert( (u32)n==pLoop->u.btree.nEq );
@@ -118739,12 +119274,11 @@
118739119274
118740119275
isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
118741119276
|| ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
118742119277
|| (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
118743119278
118744
- sqlite3StrAccumInit(&str, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
118745
- str.db = db;
119279
+ sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
118746119280
sqlite3StrAccumAppendAll(&str, isSearch ? "SEARCH" : "SCAN");
118747119281
if( pItem->pSelect ){
118748119282
sqlite3XPrintf(&str, 0, " SUBQUERY %d", pItem->iSelectId);
118749119283
}else{
118750119284
sqlite3XPrintf(&str, 0, " TABLE %s", pItem->zName);
@@ -119939,10 +120473,17 @@
119939120473
/*
119940120474
** Free a WhereInfo structure
119941120475
*/
119942120476
static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
119943120477
if( ALWAYS(pWInfo) ){
120478
+ int i;
120479
+ for(i=0; i<pWInfo->nLevel; i++){
120480
+ WhereLevel *pLevel = &pWInfo->a[i];
120481
+ if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){
120482
+ sqlite3DbFree(db, pLevel->u.in.aInLoop);
120483
+ }
120484
+ }
119944120485
whereClauseClear(&pWInfo->sWC);
119945120486
while( pWInfo->pLoops ){
119946120487
WhereLoop *p = pWInfo->pLoops;
119947120488
pWInfo->pLoops = p->pNextLoop;
119948120489
whereLoopDelete(db, p);
@@ -120418,11 +120959,11 @@
120418120959
** changes "x IN (?)" into "x=?". */
120419120960
120420120961
}else if( eOp & (WO_EQ) ){
120421120962
pNew->wsFlags |= WHERE_COLUMN_EQ;
120422120963
if( iCol<0 || (nInMul==0 && pNew->u.btree.nEq==pProbe->nKeyCol-1) ){
120423
- if( iCol>=0 && !IsUniqueIndex(pProbe) ){
120964
+ if( iCol>=0 && pProbe->uniqNotNull==0 ){
120424120965
pNew->wsFlags |= WHERE_UNQ_WANTED;
120425120966
}else{
120426120967
pNew->wsFlags |= WHERE_ONEROW;
120427120968
}
120428120969
}
@@ -121878,11 +122419,11 @@
121878122419
pWInfo->nOBSat = pFrom->isOrdered;
121879122420
if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
121880122421
pWInfo->revMask = pFrom->revLoop;
121881122422
}
121882122423
if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
121883
- && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr
122424
+ && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
121884122425
){
121885122426
Bitmask revMask = 0;
121886122427
int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy,
121887122428
pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask
121888122429
);
@@ -122283,11 +122824,10 @@
122283122824
if( pParse->nErr || NEVER(db->mallocFailed) ){
122284122825
goto whereBeginError;
122285122826
}
122286122827
#ifdef WHERETRACE_ENABLED /* !=0 */
122287122828
if( sqlite3WhereTrace ){
122288
- int ii;
122289122829
sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
122290122830
if( pWInfo->nOBSat>0 ){
122291122831
sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
122292122832
}
122293122833
switch( pWInfo->eDistinct ){
@@ -122536,11 +123076,10 @@
122536123076
VdbeCoverage(v);
122537123077
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
122538123078
VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
122539123079
sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
122540123080
}
122541
- sqlite3DbFree(db, pLevel->u.in.aInLoop);
122542123081
}
122543123082
sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
122544123083
if( pLevel->addrSkip ){
122545123084
sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
122546123085
VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
@@ -122747,10 +123286,32 @@
122747123286
/*
122748123287
** An instance of this structure holds the ATTACH key and the key type.
122749123288
*/
122750123289
struct AttachKey { int type; Token key; };
122751123290
123291
+
123292
+ /*
123293
+ ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
123294
+ ** all elements in the list. And make sure list length does not exceed
123295
+ ** SQLITE_LIMIT_COMPOUND_SELECT.
123296
+ */
123297
+ static void parserDoubleLinkSelect(Parse *pParse, Select *p){
123298
+ if( p->pPrior ){
123299
+ Select *pNext = 0, *pLoop;
123300
+ int mxSelect, cnt = 0;
123301
+ for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
123302
+ pLoop->pNext = pNext;
123303
+ pLoop->selFlags |= SF_Compound;
123304
+ }
123305
+ if( (p->selFlags & SF_MultiValue)==0 &&
123306
+ (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
123307
+ cnt>mxSelect
123308
+ ){
123309
+ sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
123310
+ }
123311
+ }
123312
+ }
122752123313
122753123314
/* This is a utility routine used to set the ExprSpan.zStart and
122754123315
** ExprSpan.zEnd values of pOut so that the span covers the complete
122755123316
** range of text beginning with pStart and going to the end of pEnd.
122756123317
*/
@@ -125064,31 +125625,14 @@
125064125625
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
125065125626
}
125066125627
break;
125067125628
case 112: /* select ::= with selectnowith */
125068125629
{
125069
- Select *p = yymsp[0].minor.yy3, *pNext, *pLoop;
125630
+ Select *p = yymsp[0].minor.yy3;
125070125631
if( p ){
125071
- int cnt = 0, mxSelect;
125072125632
p->pWith = yymsp[-1].minor.yy59;
125073
- if( p->pPrior ){
125074
- u16 allValues = SF_Values;
125075
- pNext = 0;
125076
- for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
125077
- pLoop->pNext = pNext;
125078
- pLoop->selFlags |= SF_Compound;
125079
- allValues &= pLoop->selFlags;
125080
- }
125081
- if( allValues ){
125082
- p->selFlags |= SF_AllValues;
125083
- }else if(
125084
- (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
125085
- && cnt>mxSelect
125086
- ){
125087
- sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
125088
- }
125089
- }
125633
+ parserDoubleLinkSelect(pParse, p);
125090125634
}else{
125091125635
sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy59);
125092125636
}
125093125637
yygotominor.yy3 = p;
125094125638
}
@@ -125102,16 +125646,18 @@
125102125646
Select *pRhs = yymsp[0].minor.yy3;
125103125647
if( pRhs && pRhs->pPrior ){
125104125648
SrcList *pFrom;
125105125649
Token x;
125106125650
x.n = 0;
125651
+ parserDoubleLinkSelect(pParse, pRhs);
125107125652
pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
125108125653
pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
125109125654
}
125110125655
if( pRhs ){
125111125656
pRhs->op = (u8)yymsp[-1].minor.yy328;
125112125657
pRhs->pPrior = yymsp[-2].minor.yy3;
125658
+ pRhs->selFlags &= ~SF_MultiValue;
125113125659
if( yymsp[-1].minor.yy328!=TK_ALL ) pParse->hasCompound = 1;
125114125660
}else{
125115125661
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
125116125662
}
125117125663
yygotominor.yy3 = pRhs;
@@ -125154,17 +125700,20 @@
125154125700
yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
125155125701
}
125156125702
break;
125157125703
case 121: /* values ::= values COMMA LP exprlist RP */
125158125704
{
125159
- Select *pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
125705
+ Select *pRight, *pLeft = yymsp[-4].minor.yy3;
125706
+ pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
125707
+ if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
125160125708
if( pRight ){
125161125709
pRight->op = TK_ALL;
125162
- pRight->pPrior = yymsp[-4].minor.yy3;
125710
+ pLeft = yymsp[-4].minor.yy3;
125711
+ pRight->pPrior = pLeft;
125163125712
yygotominor.yy3 = pRight;
125164125713
}else{
125165
- yygotominor.yy3 = yymsp[-4].minor.yy3;
125714
+ yygotominor.yy3 = pLeft;
125166125715
}
125167125716
}
125168125717
break;
125169125718
case 122: /* distinct ::= DISTINCT */
125170125719
{yygotominor.yy381 = SF_Distinct;}
@@ -126964,14 +127513,12 @@
126964127513
goto abort_parse;
126965127514
}
126966127515
break;
126967127516
}
126968127517
case TK_ILLEGAL: {
126969
- sqlite3DbFree(db, *pzErrMsg);
126970
- *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"",
127518
+ sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"",
126971127519
&pParse->sLastToken);
126972
- nErr++;
126973127520
goto abort_parse;
126974127521
}
126975127522
case TK_SEMI: {
126976127523
pParse->zTail = &zSql[i];
126977127524
/* Fall thru into the default case */
@@ -126985,16 +127532,19 @@
126985127532
break;
126986127533
}
126987127534
}
126988127535
}
126989127536
abort_parse:
126990
- if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){
127537
+ assert( nErr==0 );
127538
+ if( zSql[i]==0 && pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
126991127539
if( lastTokenParsed!=TK_SEMI ){
126992127540
sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
126993127541
pParse->zTail = &zSql[i];
126994127542
}
126995
- sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
127543
+ if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
127544
+ sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
127545
+ }
126996127546
}
126997127547
#ifdef YYTRACKMAXSTACKDEPTH
126998127548
sqlite3_mutex_enter(sqlite3MallocMutex());
126999127549
sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
127000127550
sqlite3ParserStackPeak(pEngine)
@@ -127051,13 +127601,11 @@
127051127601
while( pParse->pZombieTab ){
127052127602
Table *p = pParse->pZombieTab;
127053127603
pParse->pZombieTab = p->pNextZombie;
127054127604
sqlite3DeleteTable(db, p);
127055127605
}
127056
- if( nErr>0 && pParse->rc==SQLITE_OK ){
127057
- pParse->rc = SQLITE_ERROR;
127058
- }
127606
+ assert( nErr==0 || pParse->rc!=SQLITE_OK );
127059127607
return nErr;
127060127608
}
127061127609
127062127610
/************** End of tokenize.c ********************************************/
127063127611
/************** Begin file complete.c ****************************************/
@@ -127161,11 +127709,11 @@
127161127709
**
127162127710
** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
127163127711
** to recognize the end of a trigger can be omitted. All we have to do
127164127712
** is look for a semicolon that is not part of an string or comment.
127165127713
*/
127166
-SQLITE_API int sqlite3_complete(const char *zSql){
127714
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){
127167127715
u8 state = 0; /* Current state, using numbers defined in header comment */
127168127716
u8 token; /* Value of the next token */
127169127717
127170127718
#ifndef SQLITE_OMIT_TRIGGER
127171127719
/* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -127326,14 +127874,14 @@
127326127874
/*
127327127875
** This routine is the same as the sqlite3_complete() routine described
127328127876
** above, except that the parameter is required to be UTF-16 encoded, not
127329127877
** UTF-8.
127330127878
*/
127331
-SQLITE_API int sqlite3_complete16(const void *zSql){
127879
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){
127332127880
sqlite3_value *pVal;
127333127881
char const *zSql8;
127334
- int rc = SQLITE_NOMEM;
127882
+ int rc;
127335127883
127336127884
#ifndef SQLITE_OMIT_AUTOINIT
127337127885
rc = sqlite3_initialize();
127338127886
if( rc ) return rc;
127339127887
#endif
@@ -127476,37 +128024,49 @@
127476128024
#endif
127477128025
127478128026
/* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
127479128027
** a pointer to the to the sqlite3_version[] string constant.
127480128028
*/
127481
-SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
128029
+SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; }
127482128030
127483128031
/* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
127484128032
** pointer to a string constant whose value is the same as the
127485128033
** SQLITE_SOURCE_ID C preprocessor macro.
127486128034
*/
127487
-SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
128035
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
127488128036
127489128037
/* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
127490128038
** returns an integer equal to SQLITE_VERSION_NUMBER.
127491128039
*/
127492
-SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
128040
+SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
127493128041
127494128042
/* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
127495128043
** zero if and only if SQLite was compiled with mutexing code omitted due to
127496128044
** the SQLITE_THREADSAFE compile-time option being set to 0.
127497128045
*/
127498
-SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
128046
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
128047
+
128048
+/*
128049
+** When compiling the test fixture or with debugging enabled (on Win32),
128050
+** this variable being set to non-zero will cause OSTRACE macros to emit
128051
+** extra diagnostic information.
128052
+*/
128053
+#ifdef SQLITE_HAVE_OS_TRACE
128054
+# ifndef SQLITE_DEBUG_OS_TRACE
128055
+# define SQLITE_DEBUG_OS_TRACE 0
128056
+# endif
128057
+ int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
128058
+#endif
127499128059
127500128060
#if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
127501128061
/*
127502128062
** If the following function pointer is not NULL and if
127503128063
** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
127504128064
** I/O active are written using this function. These messages
127505128065
** are intended for debugging activity only.
127506128066
*/
127507
-/* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
128067
+SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
127508128068
#endif
127509128069
127510128070
/*
127511128071
** If the following global variable points to a string which is the
127512128072
** name of a directory, then that directory will be used to store
@@ -127554,11 +128114,11 @@
127554128114
** call by X completes.
127555128115
**
127556128116
** * Recursive calls to this routine from thread X return immediately
127557128117
** without blocking.
127558128118
*/
127559
-SQLITE_API int sqlite3_initialize(void){
128119
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){
127560128120
MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
127561128121
int rc; /* Result code */
127562128122
#ifdef SQLITE_EXTRA_INIT
127563128123
int bRunExtraInit = 0; /* Extra initialization needed */
127564128124
#endif
@@ -127715,11 +128275,11 @@
127715128275
** while any part of SQLite is otherwise in use in any thread. This
127716128276
** routine is not threadsafe. But it is safe to invoke this routine
127717128277
** on when SQLite is already shut down. If SQLite is already shut down
127718128278
** when this routine is invoked, then this routine is a harmless no-op.
127719128279
*/
127720
-SQLITE_API int sqlite3_shutdown(void){
128280
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){
127721128281
#ifdef SQLITE_OMIT_WSD
127722128282
int rc = sqlite3_wsd_init(4096, 24);
127723128283
if( rc!=SQLITE_OK ){
127724128284
return rc;
127725128285
}
@@ -127769,11 +128329,11 @@
127769128329
** This routine should only be called when there are no outstanding
127770128330
** database connections or memory allocations. This routine is not
127771128331
** threadsafe. Failure to heed these warnings can lead to unpredictable
127772128332
** behavior.
127773128333
*/
127774
-SQLITE_API int sqlite3_config(int op, ...){
128334
+SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){
127775128335
va_list ap;
127776128336
int rc = SQLITE_OK;
127777128337
127778128338
/* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
127779128339
** the SQLite library is in use. */
@@ -128126,11 +128686,11 @@
128126128686
}
128127128687
128128128688
/*
128129128689
** Return the mutex associated with a database connection.
128130128690
*/
128131
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
128691
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){
128132128692
#ifdef SQLITE_ENABLE_API_ARMOR
128133128693
if( !sqlite3SafetyCheckOk(db) ){
128134128694
(void)SQLITE_MISUSE_BKPT;
128135128695
return 0;
128136128696
}
@@ -128140,11 +128700,11 @@
128140128700
128141128701
/*
128142128702
** Free up as much memory as we can from the given database
128143128703
** connection.
128144128704
*/
128145
-SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
128705
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){
128146128706
int i;
128147128707
128148128708
#ifdef SQLITE_ENABLE_API_ARMOR
128149128709
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128150128710
#endif
@@ -128163,11 +128723,11 @@
128163128723
}
128164128724
128165128725
/*
128166128726
** Configuration settings for an individual database connection
128167128727
*/
128168
-SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
128728
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){
128169128729
va_list ap;
128170128730
int rc;
128171128731
va_start(ap, op);
128172128732
switch( op ){
128173128733
case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -128282,11 +128842,11 @@
128282128842
}
128283128843
128284128844
/*
128285128845
** Return the ROWID of the most recent insert
128286128846
*/
128287
-SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
128847
+SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){
128288128848
#ifdef SQLITE_ENABLE_API_ARMOR
128289128849
if( !sqlite3SafetyCheckOk(db) ){
128290128850
(void)SQLITE_MISUSE_BKPT;
128291128851
return 0;
128292128852
}
@@ -128295,11 +128855,11 @@
128295128855
}
128296128856
128297128857
/*
128298128858
** Return the number of changes in the most recent call to sqlite3_exec().
128299128859
*/
128300
-SQLITE_API int sqlite3_changes(sqlite3 *db){
128860
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){
128301128861
#ifdef SQLITE_ENABLE_API_ARMOR
128302128862
if( !sqlite3SafetyCheckOk(db) ){
128303128863
(void)SQLITE_MISUSE_BKPT;
128304128864
return 0;
128305128865
}
@@ -128308,11 +128868,11 @@
128308128868
}
128309128869
128310128870
/*
128311128871
** Return the number of changes since the database handle was opened.
128312128872
*/
128313
-SQLITE_API int sqlite3_total_changes(sqlite3 *db){
128873
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){
128314128874
#ifdef SQLITE_ENABLE_API_ARMOR
128315128875
if( !sqlite3SafetyCheckOk(db) ){
128316128876
(void)SQLITE_MISUSE_BKPT;
128317128877
return 0;
128318128878
}
@@ -128450,12 +129010,12 @@
128450129010
** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
128451129011
** version forces the connection to become a zombie if there are
128452129012
** unclosed resources, and arranges for deallocation when the last
128453129013
** prepare statement or sqlite3_backup closes.
128454129014
*/
128455
-SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
128456
-SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
129015
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
129016
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
128457129017
128458129018
128459129019
/*
128460129020
** Close the mutex on database connection db.
128461129021
**
@@ -128634,11 +129194,11 @@
128634129194
128635129195
/*
128636129196
** Return a static string containing the name corresponding to the error code
128637129197
** specified in the argument.
128638129198
*/
128639
-#if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || defined(SQLITE_TEST)
129199
+#if defined(SQLITE_NEED_ERR_NAME)
128640129200
SQLITE_PRIVATE const char *sqlite3ErrName(int rc){
128641129201
const char *zName = 0;
128642129202
int i, origRc = rc;
128643129203
for(i=0; i<2 && zName==0; i++, rc &= 0xff){
128644129204
switch( rc ){
@@ -128858,11 +129418,11 @@
128858129418
128859129419
/*
128860129420
** This routine sets the busy callback for an Sqlite database to the
128861129421
** given callback function with the given argument.
128862129422
*/
128863
-SQLITE_API int sqlite3_busy_handler(
129423
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(
128864129424
sqlite3 *db,
128865129425
int (*xBusy)(void*,int),
128866129426
void *pArg
128867129427
){
128868129428
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -128881,11 +129441,11 @@
128881129441
/*
128882129442
** This routine sets the progress callback for an Sqlite database to the
128883129443
** given callback function with the given argument. The progress callback will
128884129444
** be invoked every nOps opcodes.
128885129445
*/
128886
-SQLITE_API void sqlite3_progress_handler(
129446
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(
128887129447
sqlite3 *db,
128888129448
int nOps,
128889129449
int (*xProgress)(void*),
128890129450
void *pArg
128891129451
){
@@ -128912,11 +129472,11 @@
128912129472
128913129473
/*
128914129474
** This routine installs a default busy handler that waits for the
128915129475
** specified number of milliseconds before returning 0.
128916129476
*/
128917
-SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
129477
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){
128918129478
#ifdef SQLITE_ENABLE_API_ARMOR
128919129479
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128920129480
#endif
128921129481
if( ms>0 ){
128922129482
sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128928,11 +129488,11 @@
128928129488
}
128929129489
128930129490
/*
128931129491
** Cause any pending operation to stop at its earliest opportunity.
128932129492
*/
128933
-SQLITE_API void sqlite3_interrupt(sqlite3 *db){
129493
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){
128934129494
#ifdef SQLITE_ENABLE_API_ARMOR
128935129495
if( !sqlite3SafetyCheckOk(db) ){
128936129496
(void)SQLITE_MISUSE_BKPT;
128937129497
return;
128938129498
}
@@ -129045,11 +129605,11 @@
129045129605
}
129046129606
129047129607
/*
129048129608
** Create new user functions.
129049129609
*/
129050
-SQLITE_API int sqlite3_create_function(
129610
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
129051129611
sqlite3 *db,
129052129612
const char *zFunc,
129053129613
int nArg,
129054129614
int enc,
129055129615
void *p,
@@ -129059,11 +129619,11 @@
129059129619
){
129060129620
return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
129061129621
xFinal, 0);
129062129622
}
129063129623
129064
-SQLITE_API int sqlite3_create_function_v2(
129624
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
129065129625
sqlite3 *db,
129066129626
const char *zFunc,
129067129627
int nArg,
129068129628
int enc,
129069129629
void *p,
@@ -129102,11 +129662,11 @@
129102129662
sqlite3_mutex_leave(db->mutex);
129103129663
return rc;
129104129664
}
129105129665
129106129666
#ifndef SQLITE_OMIT_UTF16
129107
-SQLITE_API int sqlite3_create_function16(
129667
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
129108129668
sqlite3 *db,
129109129669
const void *zFunctionName,
129110129670
int nArg,
129111129671
int eTextRep,
129112129672
void *p,
@@ -129142,11 +129702,11 @@
129142129702
** When virtual tables intend to provide an overloaded function, they
129143129703
** should call this routine to make sure the global function exists.
129144129704
** A global function must exist in order for name resolution to work
129145129705
** properly.
129146129706
*/
129147
-SQLITE_API int sqlite3_overload_function(
129707
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(
129148129708
sqlite3 *db,
129149129709
const char *zName,
129150129710
int nArg
129151129711
){
129152129712
int nName = sqlite3Strlen30(zName);
@@ -129174,11 +129734,11 @@
129174129734
**
129175129735
** A NULL trace function means that no tracing is executes. A non-NULL
129176129736
** trace is a pointer to a function that is invoked at the start of each
129177129737
** SQL statement.
129178129738
*/
129179
-SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129739
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129180129740
void *pOld;
129181129741
129182129742
#ifdef SQLITE_ENABLE_API_ARMOR
129183129743
if( !sqlite3SafetyCheckOk(db) ){
129184129744
(void)SQLITE_MISUSE_BKPT;
@@ -129198,11 +129758,11 @@
129198129758
**
129199129759
** A NULL profile function means that no profiling is executes. A non-NULL
129200129760
** profile is a pointer to a function that is invoked at the conclusion of
129201129761
** each SQL statement that is run.
129202129762
*/
129203
-SQLITE_API void *sqlite3_profile(
129763
+SQLITE_API void *SQLITE_STDCALL sqlite3_profile(
129204129764
sqlite3 *db,
129205129765
void (*xProfile)(void*,const char*,sqlite_uint64),
129206129766
void *pArg
129207129767
){
129208129768
void *pOld;
@@ -129225,11 +129785,11 @@
129225129785
/*
129226129786
** Register a function to be invoked when a transaction commits.
129227129787
** If the invoked function returns non-zero, then the commit becomes a
129228129788
** rollback.
129229129789
*/
129230
-SQLITE_API void *sqlite3_commit_hook(
129790
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(
129231129791
sqlite3 *db, /* Attach the hook to this database */
129232129792
int (*xCallback)(void*), /* Function to invoke on each commit */
129233129793
void *pArg /* Argument to the function */
129234129794
){
129235129795
void *pOld;
@@ -129250,11 +129810,11 @@
129250129810
129251129811
/*
129252129812
** Register a callback to be invoked each time a row is updated,
129253129813
** inserted or deleted using this database connection.
129254129814
*/
129255
-SQLITE_API void *sqlite3_update_hook(
129815
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
129256129816
sqlite3 *db, /* Attach the hook to this database */
129257129817
void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
129258129818
void *pArg /* Argument to the function */
129259129819
){
129260129820
void *pRet;
@@ -129275,11 +129835,11 @@
129275129835
129276129836
/*
129277129837
** Register a callback to be invoked each time a transaction is rolled
129278129838
** back by this database connection.
129279129839
*/
129280
-SQLITE_API void *sqlite3_rollback_hook(
129840
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(
129281129841
sqlite3 *db, /* Attach the hook to this database */
129282129842
void (*xCallback)(void*), /* Callback function */
129283129843
void *pArg /* Argument to the function */
129284129844
){
129285129845
void *pRet;
@@ -129329,11 +129889,11 @@
129329129889
** The callback registered by this function replaces any existing callback
129330129890
** registered using sqlite3_wal_hook(). Likewise, registering a callback
129331129891
** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
129332129892
** configured by this function.
129333129893
*/
129334
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129894
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129335129895
#ifdef SQLITE_OMIT_WAL
129336129896
UNUSED_PARAMETER(db);
129337129897
UNUSED_PARAMETER(nFrame);
129338129898
#else
129339129899
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -129350,11 +129910,11 @@
129350129910
129351129911
/*
129352129912
** Register a callback to be invoked each time a transaction is written
129353129913
** into the write-ahead-log by this database connection.
129354129914
*/
129355
-SQLITE_API void *sqlite3_wal_hook(
129915
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
129356129916
sqlite3 *db, /* Attach the hook to this db handle */
129357129917
int(*xCallback)(void *, sqlite3*, const char*, int),
129358129918
void *pArg /* First argument passed to xCallback() */
129359129919
){
129360129920
#ifndef SQLITE_OMIT_WAL
@@ -129377,11 +129937,11 @@
129377129937
}
129378129938
129379129939
/*
129380129940
** Checkpoint database zDb.
129381129941
*/
129382
-SQLITE_API int sqlite3_wal_checkpoint_v2(
129942
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
129383129943
sqlite3 *db, /* Database handle */
129384129944
const char *zDb, /* Name of attached database (or NULL) */
129385129945
int eMode, /* SQLITE_CHECKPOINT_* value */
129386129946
int *pnLog, /* OUT: Size of WAL log in frames */
129387129947
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -129432,11 +129992,11 @@
129432129992
/*
129433129993
** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
129434129994
** to contains a zero-length string, all attached databases are
129435129995
** checkpointed.
129436129996
*/
129437
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129997
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129438129998
/* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
129439129999
** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
129440130000
return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
129441130001
}
129442130002
@@ -129521,11 +130081,11 @@
129521130081
129522130082
/*
129523130083
** Return UTF-8 encoded English language explanation of the most recent
129524130084
** error.
129525130085
*/
129526
-SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
130086
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){
129527130087
const char *z;
129528130088
if( !db ){
129529130089
return sqlite3ErrStr(SQLITE_NOMEM);
129530130090
}
129531130091
if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -129549,11 +130109,11 @@
129549130109
#ifndef SQLITE_OMIT_UTF16
129550130110
/*
129551130111
** Return UTF-16 encoded English language explanation of the most recent
129552130112
** error.
129553130113
*/
129554
-SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
130114
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){
129555130115
static const u16 outOfMem[] = {
129556130116
'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
129557130117
};
129558130118
static const u16 misuse[] = {
129559130119
'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129594,20 +130154,20 @@
129594130154
129595130155
/*
129596130156
** Return the most recent error code generated by an SQLite routine. If NULL is
129597130157
** passed to this function, we assume a malloc() failed during sqlite3_open().
129598130158
*/
129599
-SQLITE_API int sqlite3_errcode(sqlite3 *db){
130159
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){
129600130160
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129601130161
return SQLITE_MISUSE_BKPT;
129602130162
}
129603130163
if( !db || db->mallocFailed ){
129604130164
return SQLITE_NOMEM;
129605130165
}
129606130166
return db->errCode & db->errMask;
129607130167
}
129608
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
130168
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){
129609130169
if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129610130170
return SQLITE_MISUSE_BKPT;
129611130171
}
129612130172
if( !db || db->mallocFailed ){
129613130173
return SQLITE_NOMEM;
@@ -129618,11 +130178,11 @@
129618130178
/*
129619130179
** Return a string that describes the kind of error specified in the
129620130180
** argument. For now, this simply calls the internal sqlite3ErrStr()
129621130181
** function.
129622130182
*/
129623
-SQLITE_API const char *sqlite3_errstr(int rc){
130183
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){
129624130184
return sqlite3ErrStr(rc);
129625130185
}
129626130186
129627130187
/*
129628130188
** Create a new collating function for database "db". The name is zName
@@ -129766,11 +130326,11 @@
129766130326
**
129767130327
** A new lower limit does not shrink existing constructs.
129768130328
** It merely prevents new constructs that exceed the limit
129769130329
** from forming.
129770130330
*/
129771
-SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
130331
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129772130332
int oldLimit;
129773130333
129774130334
#ifdef SQLITE_ENABLE_API_ARMOR
129775130335
if( !sqlite3SafetyCheckOk(db) ){
129776130336
(void)SQLITE_MISUSE_BKPT;
@@ -129859,18 +130419,18 @@
129859130419
){
129860130420
char *zOpt;
129861130421
int eState; /* Parser state when parsing URI */
129862130422
int iIn; /* Input character index */
129863130423
int iOut = 0; /* Output character index */
129864
- int nByte = nUri+2; /* Bytes of space to allocate */
130424
+ u64 nByte = nUri+2; /* Bytes of space to allocate */
129865130425
129866130426
/* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen
129867130427
** method that there may be extra parameters following the file-name. */
129868130428
flags |= SQLITE_OPEN_URI;
129869130429
129870130430
for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
129871
- zFile = sqlite3_malloc(nByte);
130431
+ zFile = sqlite3_malloc64(nByte);
129872130432
if( !zFile ) return SQLITE_NOMEM;
129873130433
129874130434
iIn = 5;
129875130435
#ifdef SQLITE_ALLOW_URI_AUTHORITY
129876130436
if( strncmp(zUri+5, "///", 3)==0 ){
@@ -130032,11 +130592,11 @@
130032130592
130033130593
zOpt = &zVal[nVal+1];
130034130594
}
130035130595
130036130596
}else{
130037
- zFile = sqlite3_malloc(nUri+2);
130597
+ zFile = sqlite3_malloc64(nUri+2);
130038130598
if( !zFile ) return SQLITE_NOMEM;
130039130599
memcpy(zFile, zUri, nUri);
130040130600
zFile[nUri] = '\0';
130041130601
zFile[nUri+1] = '\0';
130042130602
flags &= ~SQLITE_OPEN_URI;
@@ -130303,10 +130863,17 @@
130303130863
#ifdef SQLITE_ENABLE_RTREE
130304130864
if( !db->mallocFailed && rc==SQLITE_OK){
130305130865
rc = sqlite3RtreeInit(db);
130306130866
}
130307130867
#endif
130868
+
130869
+#ifdef SQLITE_ENABLE_DBSTAT_VTAB
130870
+ if( !db->mallocFailed && rc==SQLITE_OK){
130871
+ int sqlite3_dbstat_register(sqlite3*);
130872
+ rc = sqlite3_dbstat_register(db);
130873
+ }
130874
+#endif
130308130875
130309130876
/* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
130310130877
** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
130311130878
** mode. Doing nothing at all also makes NORMAL the default.
130312130879
*/
@@ -130351,18 +130918,18 @@
130351130918
}
130352130919
130353130920
/*
130354130921
** Open a new database handle.
130355130922
*/
130356
-SQLITE_API int sqlite3_open(
130923
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
130357130924
const char *zFilename,
130358130925
sqlite3 **ppDb
130359130926
){
130360130927
return openDatabase(zFilename, ppDb,
130361130928
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
130362130929
}
130363
-SQLITE_API int sqlite3_open_v2(
130930
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
130364130931
const char *filename, /* Database filename (UTF-8) */
130365130932
sqlite3 **ppDb, /* OUT: SQLite db handle */
130366130933
int flags, /* Flags */
130367130934
const char *zVfs /* Name of VFS module to use */
130368130935
){
@@ -130371,11 +130938,11 @@
130371130938
130372130939
#ifndef SQLITE_OMIT_UTF16
130373130940
/*
130374130941
** Open a new database handle.
130375130942
*/
130376
-SQLITE_API int sqlite3_open16(
130943
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
130377130944
const void *zFilename,
130378130945
sqlite3 **ppDb
130379130946
){
130380130947
char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
130381130948
sqlite3_value *pVal;
@@ -130410,11 +130977,11 @@
130410130977
#endif /* SQLITE_OMIT_UTF16 */
130411130978
130412130979
/*
130413130980
** Register a new collation sequence with the database handle db.
130414130981
*/
130415
-SQLITE_API int sqlite3_create_collation(
130982
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
130416130983
sqlite3* db,
130417130984
const char *zName,
130418130985
int enc,
130419130986
void* pCtx,
130420130987
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130423,11 +130990,11 @@
130423130990
}
130424130991
130425130992
/*
130426130993
** Register a new collation sequence with the database handle db.
130427130994
*/
130428
-SQLITE_API int sqlite3_create_collation_v2(
130995
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
130429130996
sqlite3* db,
130430130997
const char *zName,
130431130998
int enc,
130432130999
void* pCtx,
130433131000
int(*xCompare)(void*,int,const void*,int,const void*),
@@ -130448,11 +131015,11 @@
130448131015
130449131016
#ifndef SQLITE_OMIT_UTF16
130450131017
/*
130451131018
** Register a new collation sequence with the database handle db.
130452131019
*/
130453
-SQLITE_API int sqlite3_create_collation16(
131020
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
130454131021
sqlite3* db,
130455131022
const void *zName,
130456131023
int enc,
130457131024
void* pCtx,
130458131025
int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130478,11 +131045,11 @@
130478131045
130479131046
/*
130480131047
** Register a collation sequence factory callback with the database handle
130481131048
** db. Replace any previously installed collation sequence factory.
130482131049
*/
130483
-SQLITE_API int sqlite3_collation_needed(
131050
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
130484131051
sqlite3 *db,
130485131052
void *pCollNeededArg,
130486131053
void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
130487131054
){
130488131055
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -130499,11 +131066,11 @@
130499131066
#ifndef SQLITE_OMIT_UTF16
130500131067
/*
130501131068
** Register a collation sequence factory callback with the database handle
130502131069
** db. Replace any previously installed collation sequence factory.
130503131070
*/
130504
-SQLITE_API int sqlite3_collation_needed16(
131071
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
130505131072
sqlite3 *db,
130506131073
void *pCollNeededArg,
130507131074
void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
130508131075
){
130509131076
#ifdef SQLITE_ENABLE_API_ARMOR
@@ -130521,11 +131088,11 @@
130521131088
#ifndef SQLITE_OMIT_DEPRECATED
130522131089
/*
130523131090
** This function is now an anachronism. It used to be used to recover from a
130524131091
** malloc() failure, but SQLite now does this automatically.
130525131092
*/
130526
-SQLITE_API int sqlite3_global_recover(void){
131093
+SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){
130527131094
return SQLITE_OK;
130528131095
}
130529131096
#endif
130530131097
130531131098
/*
@@ -130532,11 +131099,11 @@
130532131099
** Test to see whether or not the database connection is in autocommit
130533131100
** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
130534131101
** by default. Autocommit is disabled by a BEGIN statement and reenabled
130535131102
** by the next COMMIT or ROLLBACK.
130536131103
*/
130537
-SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
131104
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){
130538131105
#ifdef SQLITE_ENABLE_API_ARMOR
130539131106
if( !sqlite3SafetyCheckOk(db) ){
130540131107
(void)SQLITE_MISUSE_BKPT;
130541131108
return 0;
130542131109
}
@@ -130584,19 +131151,19 @@
130584131151
** data for this thread has been deallocated.
130585131152
**
130586131153
** SQLite no longer uses thread-specific data so this routine is now a
130587131154
** no-op. It is retained for historical compatibility.
130588131155
*/
130589
-SQLITE_API void sqlite3_thread_cleanup(void){
131156
+SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){
130590131157
}
130591131158
#endif
130592131159
130593131160
/*
130594131161
** Return meta information about a specific column of a database table.
130595131162
** See comment in sqlite3.h (sqlite.h.in) for details.
130596131163
*/
130597
-SQLITE_API int sqlite3_table_column_metadata(
131164
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
130598131165
sqlite3 *db, /* Connection handle */
130599131166
const char *zDbName, /* Database name or NULL */
130600131167
const char *zTableName, /* Table name */
130601131168
const char *zColumnName, /* Column name */
130602131169
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130710,11 +131277,11 @@
130710131277
}
130711131278
130712131279
/*
130713131280
** Sleep for a little while. Return the amount of time slept.
130714131281
*/
130715
-SQLITE_API int sqlite3_sleep(int ms){
131282
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){
130716131283
sqlite3_vfs *pVfs;
130717131284
int rc;
130718131285
pVfs = sqlite3_vfs_find(0);
130719131286
if( pVfs==0 ) return 0;
130720131287
@@ -130726,11 +131293,11 @@
130726131293
}
130727131294
130728131295
/*
130729131296
** Enable or disable the extended result codes.
130730131297
*/
130731
-SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
131298
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130732131299
#ifdef SQLITE_ENABLE_API_ARMOR
130733131300
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
130734131301
#endif
130735131302
sqlite3_mutex_enter(db->mutex);
130736131303
db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130739,11 +131306,11 @@
130739131306
}
130740131307
130741131308
/*
130742131309
** Invoke the xFileControl method on a particular database.
130743131310
*/
130744
-SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
131311
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130745131312
int rc = SQLITE_ERROR;
130746131313
Btree *pBtree;
130747131314
130748131315
#ifdef SQLITE_ENABLE_API_ARMOR
130749131316
if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130773,11 +131340,11 @@
130773131340
}
130774131341
130775131342
/*
130776131343
** Interface to the testing logic.
130777131344
*/
130778
-SQLITE_API int sqlite3_test_control(int op, ...){
131345
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){
130779131346
int rc = 0;
130780131347
#ifndef SQLITE_OMIT_BUILTIN_TEST
130781131348
va_list ap;
130782131349
va_start(ap, op);
130783131350
switch( op ){
@@ -131116,11 +131683,11 @@
131116131683
** method of a VFS implementation. The zParam argument is the name of the
131117131684
** query parameter we seek. This routine returns the value of the zParam
131118131685
** parameter if it exists. If the parameter does not exist, this routine
131119131686
** returns a NULL pointer.
131120131687
*/
131121
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131688
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131122131689
if( zFilename==0 || zParam==0 ) return 0;
131123131690
zFilename += sqlite3Strlen30(zFilename) + 1;
131124131691
while( zFilename[0] ){
131125131692
int x = strcmp(zFilename, zParam);
131126131693
zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -131131,20 +131698,20 @@
131131131698
}
131132131699
131133131700
/*
131134131701
** Return a boolean value for a query parameter.
131135131702
*/
131136
-SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131703
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131137131704
const char *z = sqlite3_uri_parameter(zFilename, zParam);
131138131705
bDflt = bDflt!=0;
131139131706
return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
131140131707
}
131141131708
131142131709
/*
131143131710
** Return a 64-bit integer value for a query parameter.
131144131711
*/
131145
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(
131712
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(
131146131713
const char *zFilename, /* Filename as passed to xOpen */
131147131714
const char *zParam, /* URI parameter sought */
131148131715
sqlite3_int64 bDflt /* return if parameter is missing */
131149131716
){
131150131717
const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -131172,11 +131739,11 @@
131172131739
131173131740
/*
131174131741
** Return the filename of the database associated with a database
131175131742
** connection.
131176131743
*/
131177
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131744
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131178131745
Btree *pBt;
131179131746
#ifdef SQLITE_ENABLE_API_ARMOR
131180131747
if( !sqlite3SafetyCheckOk(db) ){
131181131748
(void)SQLITE_MISUSE_BKPT;
131182131749
return 0;
@@ -131188,11 +131755,11 @@
131188131755
131189131756
/*
131190131757
** Return 1 if database is read-only or 0 if read/write. Return -1 if
131191131758
** no such database exists.
131192131759
*/
131193
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131760
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131194131761
Btree *pBt;
131195131762
#ifdef SQLITE_ENABLE_API_ARMOR
131196131763
if( !sqlite3SafetyCheckOk(db) ){
131197131764
(void)SQLITE_MISUSE_BKPT;
131198131765
return -1;
@@ -131347,11 +131914,11 @@
131347131914
**
131348131915
** Each call to this routine overrides any prior callbacks registered
131349131916
** on the same "db". If xNotify==0 then any prior callbacks are immediately
131350131917
** cancelled.
131351131918
*/
131352
-SQLITE_API int sqlite3_unlock_notify(
131919
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
131353131920
sqlite3 *db,
131354131921
void (*xNotify)(void **, int),
131355131922
void *pArg
131356131923
){
131357131924
int rc = SQLITE_OK;
@@ -132241,10 +132808,15 @@
132241132808
** false.
132242132809
*/
132243132810
#ifdef SQLITE_COVERAGE_TEST
132244132811
# define ALWAYS(x) (1)
132245132812
# define NEVER(X) (0)
132813
+#elif defined(SQLITE_DEBUG)
132814
+# define ALWAYS(x) sqlite3Fts3Always((x)!=0)
132815
+# define NEVER(x) sqlite3Fts3Never((x)!=0)
132816
+SQLITE_PRIVATE int sqlite3Fts3Always(int b);
132817
+SQLITE_PRIVATE int sqlite3Fts3Never(int b);
132246132818
#else
132247132819
# define ALWAYS(x) (x)
132248132820
# define NEVER(x) (x)
132249132821
#endif
132250132822
@@ -132641,10 +133213,11 @@
132641133213
#define fts3GetVarint32(p, piVal) ( \
132642133214
(*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
132643133215
)
132644133216
132645133217
/* fts3.c */
133218
+SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
132646133219
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
132647133220
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
132648133221
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
132649133222
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
132650133223
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
@@ -132729,10 +133302,17 @@
132729133302
132730133303
static int fts3EvalNext(Fts3Cursor *pCsr);
132731133304
static int fts3EvalStart(Fts3Cursor *pCsr);
132732133305
static int fts3TermSegReaderCursor(
132733133306
Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
133307
+
133308
+#ifndef SQLITE_AMALGAMATION
133309
+# if defined(SQLITE_DEBUG)
133310
+SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }
133311
+SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; }
133312
+# endif
133313
+#endif
132734133314
132735133315
/*
132736133316
** Write a 64-bit variable-length integer to memory starting at p[0].
132737133317
** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
132738133318
** The number of bytes written is returned.
@@ -132839,11 +133419,11 @@
132839133419
int iOut = 0; /* Index of next byte to write to output */
132840133420
132841133421
/* If the first byte was a '[', then the close-quote character is a ']' */
132842133422
if( quote=='[' ) quote = ']';
132843133423
132844
- while( ALWAYS(z[iIn]) ){
133424
+ while( z[iIn] ){
132845133425
if( z[iIn]==quote ){
132846133426
if( z[iIn+1]!=quote ) break;
132847133427
z[iOut++] = quote;
132848133428
iIn += 2;
132849133429
}else{
@@ -132917,10 +133497,21 @@
132917133497
p->pTokenizer->pModule->xDestroy(p->pTokenizer);
132918133498
132919133499
sqlite3_free(p);
132920133500
return SQLITE_OK;
132921133501
}
133502
+
133503
+/*
133504
+** Write an error message into *pzErr
133505
+*/
133506
+SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char **pzErr, const char *zFormat, ...){
133507
+ va_list ap;
133508
+ sqlite3_free(*pzErr);
133509
+ va_start(ap, zFormat);
133510
+ *pzErr = sqlite3_vmprintf(zFormat, ap);
133511
+ va_end(ap);
133512
+}
132922133513
132923133514
/*
132924133515
** Construct one or more SQL statements from the format string given
132925133516
** and then evaluate those statements. The success code is written
132926133517
** into *pRc.
@@ -133436,11 +134027,12 @@
133436134027
sqlite3 *db, /* Database handle */
133437134028
const char *zDb, /* Name of db (i.e. "main", "temp" etc.) */
133438134029
const char *zTbl, /* Name of content table */
133439134030
const char ***pazCol, /* OUT: Malloc'd array of column names */
133440134031
int *pnCol, /* OUT: Size of array *pazCol */
133441
- int *pnStr /* OUT: Bytes of string content */
134032
+ int *pnStr, /* OUT: Bytes of string content */
134033
+ char **pzErr /* OUT: error message */
133442134034
){
133443134035
int rc = SQLITE_OK; /* Return code */
133444134036
char *zSql; /* "SELECT *" statement on zTbl */
133445134037
sqlite3_stmt *pStmt = 0; /* Compiled version of zSql */
133446134038
@@ -133447,10 +134039,13 @@
133447134039
zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", zDb, zTbl);
133448134040
if( !zSql ){
133449134041
rc = SQLITE_NOMEM;
133450134042
}else{
133451134043
rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
134044
+ if( rc!=SQLITE_OK ){
134045
+ sqlite3Fts3ErrMsg(pzErr, "%s", sqlite3_errmsg(db));
134046
+ }
133452134047
}
133453134048
sqlite3_free(zSql);
133454134049
133455134050
if( rc==SQLITE_OK ){
133456134051
const char **azCol; /* Output array */
@@ -133525,11 +134120,11 @@
133525134120
int nName; /* Bytes required to hold table name */
133526134121
int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
133527134122
const char **aCol; /* Array of column names */
133528134123
sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
133529134124
133530
- int nIndex; /* Size of aIndex[] array */
134125
+ int nIndex = 0; /* Size of aIndex[] array */
133531134126
struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
133532134127
133533134128
/* The results of parsing supported FTS4 key=value options: */
133534134129
int bNoDocsize = 0; /* True to omit %_docsize table */
133535134130
int bDescIdx = 0; /* True to store descending indexes */
@@ -133613,17 +134208,17 @@
133613134208
if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){
133614134209
break;
133615134210
}
133616134211
}
133617134212
if( iOpt==SizeofArray(aFts4Opt) ){
133618
- *pzErr = sqlite3_mprintf("unrecognized parameter: %s", z);
134213
+ sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z);
133619134214
rc = SQLITE_ERROR;
133620134215
}else{
133621134216
switch( iOpt ){
133622134217
case 0: /* MATCHINFO */
133623134218
if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){
133624
- *pzErr = sqlite3_mprintf("unrecognized matchinfo: %s", zVal);
134219
+ sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal);
133625134220
rc = SQLITE_ERROR;
133626134221
}
133627134222
bNoDocsize = 1;
133628134223
break;
133629134224
@@ -133647,11 +134242,11 @@
133647134242
133648134243
case 4: /* ORDER */
133649134244
if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3))
133650134245
&& (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4))
133651134246
){
133652
- *pzErr = sqlite3_mprintf("unrecognized order: %s", zVal);
134247
+ sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal);
133653134248
rc = SQLITE_ERROR;
133654134249
}
133655134250
bDescIdx = (zVal[0]=='d' || zVal[0]=='D');
133656134251
break;
133657134252
@@ -133698,11 +134293,11 @@
133698134293
zCompress = 0;
133699134294
zUncompress = 0;
133700134295
if( nCol==0 ){
133701134296
sqlite3_free((void*)aCol);
133702134297
aCol = 0;
133703
- rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString);
134298
+ rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);
133704134299
133705134300
/* If a languageid= option was specified, remove the language id
133706134301
** column from the aCol[] array. */
133707134302
if( rc==SQLITE_OK && zLanguageid ){
133708134303
int j;
@@ -133733,11 +134328,11 @@
133733134328
assert( pTokenizer );
133734134329
133735134330
rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);
133736134331
if( rc==SQLITE_ERROR ){
133737134332
assert( zPrefix );
133738
- *pzErr = sqlite3_mprintf("error parsing prefix parameter: %s", zPrefix);
134333
+ sqlite3Fts3ErrMsg(pzErr, "error parsing prefix parameter: %s", zPrefix);
133739134334
}
133740134335
if( rc!=SQLITE_OK ) goto fts3_init_out;
133741134336
133742134337
/* Allocate and populate the Fts3Table structure. */
133743134338
nByte = sizeof(Fts3Table) + /* Fts3Table */
@@ -133815,19 +134410,19 @@
133815134410
}
133816134411
}
133817134412
}
133818134413
for(i=0; i<nNotindexed; i++){
133819134414
if( azNotindexed[i] ){
133820
- *pzErr = sqlite3_mprintf("no such column: %s", azNotindexed[i]);
134415
+ sqlite3Fts3ErrMsg(pzErr, "no such column: %s", azNotindexed[i]);
133821134416
rc = SQLITE_ERROR;
133822134417
}
133823134418
}
133824134419
133825134420
if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){
133826134421
char const *zMiss = (zCompress==0 ? "compress" : "uncompress");
133827134422
rc = SQLITE_ERROR;
133828
- *pzErr = sqlite3_mprintf("missing %s parameter in fts4 constructor", zMiss);
134423
+ sqlite3Fts3ErrMsg(pzErr, "missing %s parameter in fts4 constructor", zMiss);
133829134424
}
133830134425
p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);
133831134426
p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);
133832134427
if( rc!=SQLITE_OK ) goto fts3_init_out;
133833134428
@@ -134919,30 +135514,37 @@
134919135514
** parameter bDescDoclist should be false. If they are sorted in ascending
134920135515
** order, it should be passed a non-zero value.
134921135516
**
134922135517
** The right-hand input doclist is overwritten by this function.
134923135518
*/
134924
-static void fts3DoclistPhraseMerge(
135519
+static int fts3DoclistPhraseMerge(
134925135520
int bDescDoclist, /* True if arguments are desc */
134926135521
int nDist, /* Distance from left to right (1=adjacent) */
134927135522
char *aLeft, int nLeft, /* Left doclist */
134928
- char *aRight, int *pnRight /* IN/OUT: Right/output doclist */
135523
+ char **paRight, int *pnRight /* IN/OUT: Right/output doclist */
134929135524
){
134930135525
sqlite3_int64 i1 = 0;
134931135526
sqlite3_int64 i2 = 0;
134932135527
sqlite3_int64 iPrev = 0;
135528
+ char *aRight = *paRight;
134933135529
char *pEnd1 = &aLeft[nLeft];
134934135530
char *pEnd2 = &aRight[*pnRight];
134935135531
char *p1 = aLeft;
134936135532
char *p2 = aRight;
134937135533
char *p;
134938135534
int bFirstOut = 0;
134939
- char *aOut = aRight;
135535
+ char *aOut;
134940135536
134941135537
assert( nDist>0 );
134942
-
135538
+ if( bDescDoclist ){
135539
+ aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
135540
+ if( aOut==0 ) return SQLITE_NOMEM;
135541
+ }else{
135542
+ aOut = aRight;
135543
+ }
134943135544
p = aOut;
135545
+
134944135546
fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
134945135547
fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
134946135548
134947135549
while( p1 && p2 ){
134948135550
sqlite3_int64 iDiff = DOCID_CMP(i1, i2);
@@ -134967,10 +135569,16 @@
134967135569
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
134968135570
}
134969135571
}
134970135572
134971135573
*pnRight = (int)(p - aOut);
135574
+ if( bDescDoclist ){
135575
+ sqlite3_free(aRight);
135576
+ *paRight = aOut;
135577
+ }
135578
+
135579
+ return SQLITE_OK;
134972135580
}
134973135581
134974135582
/*
134975135583
** Argument pList points to a position list nList bytes in size. This
134976135584
** function checks to see if the position list contains any entries for
@@ -135091,12 +135699,26 @@
135091135699
char *aDoclist, /* Pointer to doclist */
135092135700
int nDoclist /* Size of aDoclist in bytes */
135093135701
){
135094135702
if( pTS->aaOutput[0]==0 ){
135095135703
/* If this is the first term selected, copy the doclist to the output
135096
- ** buffer using memcpy(). */
135097
- pTS->aaOutput[0] = sqlite3_malloc(nDoclist);
135704
+ ** buffer using memcpy().
135705
+ **
135706
+ ** Add FTS3_VARINT_MAX bytes of unused space to the end of the
135707
+ ** allocation. This is so as to ensure that the buffer is big enough
135708
+ ** to hold the current doclist AND'd with any other doclist. If the
135709
+ ** doclists are stored in order=ASC order, this padding would not be
135710
+ ** required (since the size of [doclistA AND doclistB] is always less
135711
+ ** than or equal to the size of [doclistA] in that case). But this is
135712
+ ** not true for order=DESC. For example, a doclist containing (1, -1)
135713
+ ** may be smaller than (-1), as in the first example the -1 may be stored
135714
+ ** as a single-byte delta, whereas in the second it must be stored as a
135715
+ ** FTS3_VARINT_MAX byte varint.
135716
+ **
135717
+ ** Similar padding is added in the fts3DoclistOrMerge() function.
135718
+ */
135719
+ pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);
135098135720
pTS->anOutput[0] = nDoclist;
135099135721
if( pTS->aaOutput[0] ){
135100135722
memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
135101135723
}else{
135102135724
return SQLITE_NOMEM;
@@ -135189,11 +135811,11 @@
135189135811
** Fts3SegReaderPending might segfault, as the data structures used by
135190135812
** fts4aux are not completely populated. So it's easiest to filter these
135191135813
** calls out here. */
135192135814
if( iLevel<0 && p->aIndex ){
135193135815
Fts3SegReader *pSeg = 0;
135194
- rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix, &pSeg);
135816
+ rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
135195135817
if( rc==SQLITE_OK && pSeg ){
135196135818
rc = fts3SegReaderCursorAppend(pCsr, pSeg);
135197135819
}
135198135820
}
135199135821
@@ -135838,15 +136460,35 @@
135838136460
*/
135839136461
static void fts3ReversePoslist(char *pStart, char **ppPoslist){
135840136462
char *p = &(*ppPoslist)[-2];
135841136463
char c = 0;
135842136464
136465
+ /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */
135843136466
while( p>pStart && (c=*p--)==0 );
136467
+
136468
+ /* Search backwards for a varint with value zero (the end of the previous
136469
+ ** poslist). This is an 0x00 byte preceded by some byte that does not
136470
+ ** have the 0x80 bit set. */
135844136471
while( p>pStart && (*p & 0x80) | c ){
135845136472
c = *p--;
135846136473
}
135847
- if( p>pStart ){ p = &p[2]; }
136474
+ assert( p==pStart || c==0 );
136475
+
136476
+ /* At this point p points to that preceding byte without the 0x80 bit
136477
+ ** set. So to find the start of the poslist, skip forward 2 bytes then
136478
+ ** over a varint.
136479
+ **
136480
+ ** Normally. The other case is that p==pStart and the poslist to return
136481
+ ** is the first in the doclist. In this case do not skip forward 2 bytes.
136482
+ ** The second part of the if condition (c==0 && *ppPoslist>&p[2])
136483
+ ** is required for cases where the first byte of a doclist and the
136484
+ ** doclist is empty. For example, if the first docid is 10, a doclist
136485
+ ** that begins with:
136486
+ **
136487
+ ** 0x0A 0x00 <next docid delta varint>
136488
+ */
136489
+ if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; }
135848136490
while( *p++&0x80 );
135849136491
*ppPoslist = p;
135850136492
}
135851136493
135852136494
/*
@@ -135913,10 +136555,12 @@
135913136555
case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
135914136556
case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
135915136557
}
135916136558
if( !zEllipsis || !zEnd || !zStart ){
135917136559
sqlite3_result_error_nomem(pContext);
136560
+ }else if( nToken==0 ){
136561
+ sqlite3_result_text(pContext, "", -1, SQLITE_STATIC);
135918136562
}else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
135919136563
sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
135920136564
}
135921136565
}
135922136566
@@ -136348,18 +136992,21 @@
136348136992
** It is merged into the main doclist stored in p->doclist.aAll/nAll.
136349136993
**
136350136994
** This function assumes that pList points to a buffer allocated using
136351136995
** sqlite3_malloc(). This function takes responsibility for eventually
136352136996
** freeing the buffer.
136997
+**
136998
+** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.
136353136999
*/
136354
-static void fts3EvalPhraseMergeToken(
137000
+static int fts3EvalPhraseMergeToken(
136355137001
Fts3Table *pTab, /* FTS Table pointer */
136356137002
Fts3Phrase *p, /* Phrase to merge pList/nList into */
136357137003
int iToken, /* Token pList/nList corresponds to */
136358137004
char *pList, /* Pointer to doclist */
136359137005
int nList /* Number of bytes in pList */
136360137006
){
137007
+ int rc = SQLITE_OK;
136361137008
assert( iToken!=p->iDoclistToken );
136362137009
136363137010
if( pList==0 ){
136364137011
sqlite3_free(p->doclist.aAll);
136365137012
p->doclist.aAll = 0;
@@ -136394,17 +137041,20 @@
136394137041
pLeft = pList;
136395137042
nLeft = nList;
136396137043
nDiff = p->iDoclistToken - iToken;
136397137044
}
136398137045
136399
- fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
137046
+ rc = fts3DoclistPhraseMerge(
137047
+ pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight
137048
+ );
136400137049
sqlite3_free(pLeft);
136401137050
p->doclist.aAll = pRight;
136402137051
p->doclist.nAll = nRight;
136403137052
}
136404137053
136405137054
if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
137055
+ return rc;
136406137056
}
136407137057
136408137058
/*
136409137059
** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist
136410137060
** does not take deferred tokens into account.
@@ -136426,11 +137076,11 @@
136426137076
if( pToken->pSegcsr ){
136427137077
int nThis = 0;
136428137078
char *pThis = 0;
136429137079
rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
136430137080
if( rc==SQLITE_OK ){
136431
- fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
137081
+ rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
136432137082
}
136433137083
}
136434137084
assert( pToken->pSegcsr==0 );
136435137085
}
136436137086
@@ -136968,16 +137618,18 @@
136968137618
Fts3Expr *pExpr, /* Expression to initialize phrases in */
136969137619
int *pRc /* IN/OUT: Error code */
136970137620
){
136971137621
if( pExpr && SQLITE_OK==*pRc ){
136972137622
if( pExpr->eType==FTSQUERY_PHRASE ){
136973
- int i;
136974137623
int nToken = pExpr->pPhrase->nToken;
136975
- for(i=0; i<nToken; i++){
136976
- if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
137624
+ if( nToken ){
137625
+ int i;
137626
+ for(i=0; i<nToken; i++){
137627
+ if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
137628
+ }
137629
+ pExpr->bDeferred = (i==nToken);
136977137630
}
136978
- pExpr->bDeferred = (i==nToken);
136979137631
*pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);
136980137632
}else{
136981137633
fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);
136982137634
fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);
136983137635
pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
@@ -137228,13 +137880,17 @@
137228137880
Fts3PhraseToken *pToken = pTC->pToken;
137229137881
int nList = 0;
137230137882
char *pList = 0;
137231137883
rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
137232137884
assert( rc==SQLITE_OK || pList==0 );
137885
+ if( rc==SQLITE_OK ){
137886
+ rc = fts3EvalPhraseMergeToken(
137887
+ pTab, pTC->pPhrase, pTC->iToken,pList,nList
137888
+ );
137889
+ }
137233137890
if( rc==SQLITE_OK ){
137234137891
int nCount;
137235
- fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
137236137892
nCount = fts3DoclistCountDocids(
137237137893
pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll
137238137894
);
137239137895
if( ii==0 || nCount<nMinEst ) nMinEst = nCount;
137240137896
}
@@ -138132,11 +138788,12 @@
138132138788
if( rc!=SQLITE_OK ) return rc;
138133138789
138134138790
pIter = pPhrase->pOrPoslist;
138135138791
iDocid = pPhrase->iOrDocid;
138136138792
if( pCsr->bDesc==bDescDoclist ){
138137
- bEof = (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
138793
+ bEof = !pPhrase->doclist.nAll ||
138794
+ (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
138138138795
while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
138139138796
sqlite3Fts3DoclistNext(
138140138797
bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
138141138798
&pIter, &iDocid, &bEof
138142138799
);
@@ -138213,11 +138870,11 @@
138213138870
** Initialize API pointer table, if required.
138214138871
*/
138215138872
#ifdef _WIN32
138216138873
__declspec(dllexport)
138217138874
#endif
138218
-SQLITE_API int sqlite3_fts3_init(
138875
+SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init(
138219138876
sqlite3 *db,
138220138877
char **pzErrMsg,
138221138878
const sqlite3_api_routines *pApi
138222138879
){
138223138880
SQLITE_EXTENSION_INIT2(pApi)
@@ -138344,11 +139001,11 @@
138344139001
138345139002
*ppVtab = (sqlite3_vtab *)p;
138346139003
return SQLITE_OK;
138347139004
138348139005
bad_args:
138349
- *pzErr = sqlite3_mprintf("invalid arguments to fts4aux constructor");
139006
+ sqlite3Fts3ErrMsg(pzErr, "invalid arguments to fts4aux constructor");
138350139007
return SQLITE_ERROR;
138351139008
}
138352139009
138353139010
/*
138354139011
** This function does the work for both the xDisconnect and xDestroy methods.
@@ -139802,17 +140459,17 @@
139802140459
139803140460
if( rc!=SQLITE_OK ){
139804140461
sqlite3Fts3ExprFree(*ppExpr);
139805140462
*ppExpr = 0;
139806140463
if( rc==SQLITE_TOOBIG ){
139807
- *pzErr = sqlite3_mprintf(
140464
+ sqlite3Fts3ErrMsg(pzErr,
139808140465
"FTS expression tree is too large (maximum depth %d)",
139809140466
SQLITE_FTS3_MAX_EXPR_DEPTH
139810140467
);
139811140468
rc = SQLITE_ERROR;
139812140469
}else if( rc==SQLITE_ERROR ){
139813
- *pzErr = sqlite3_mprintf("malformed MATCH expression: [%s]", z);
140470
+ sqlite3Fts3ErrMsg(pzErr, "malformed MATCH expression: [%s]", z);
139814140471
}
139815140472
}
139816140473
139817140474
return rc;
139818140475
}
@@ -141284,11 +141941,11 @@
141284141941
z[n] = '\0';
141285141942
sqlite3Fts3Dequote(z);
141286141943
141287141944
m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
141288141945
if( !m ){
141289
- *pzErr = sqlite3_mprintf("unknown tokenizer: %s", z);
141946
+ sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer: %s", z);
141290141947
rc = SQLITE_ERROR;
141291141948
}else{
141292141949
char const **aArg = 0;
141293141950
int iArg = 0;
141294141951
z = &z[n+1];
@@ -141307,11 +141964,11 @@
141307141964
z = &z[n+1];
141308141965
}
141309141966
rc = m->xCreate(iArg, aArg, ppTok);
141310141967
assert( rc!=SQLITE_OK || *ppTok );
141311141968
if( rc!=SQLITE_OK ){
141312
- *pzErr = sqlite3_mprintf("unknown tokenizer");
141969
+ sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer");
141313141970
}else{
141314141971
(*ppTok)->pModule = m;
141315141972
}
141316141973
sqlite3_free((void *)aArg);
141317141974
}
@@ -141391,13 +142048,13 @@
141391142048
141392142049
pHash = (Fts3Hash *)sqlite3_user_data(context);
141393142050
p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
141394142051
141395142052
if( !p ){
141396
- char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
141397
- sqlite3_result_error(context, zErr, -1);
141398
- sqlite3_free(zErr);
142053
+ char *zErr2 = sqlite3_mprintf("unknown tokenizer: %s", zName);
142054
+ sqlite3_result_error(context, zErr2, -1);
142055
+ sqlite3_free(zErr2);
141399142056
return;
141400142057
}
141401142058
141402142059
pRet = Tcl_NewObj();
141403142060
Tcl_IncrRefCount(pRet);
@@ -141928,11 +142585,11 @@
141928142585
sqlite3_tokenizer_module *p;
141929142586
int nName = (int)strlen(zName);
141930142587
141931142588
p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
141932142589
if( !p ){
141933
- *pzErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
142590
+ sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer: %s", zName);
141934142591
return SQLITE_ERROR;
141935142592
}
141936142593
141937142594
*pp = p;
141938142595
return SQLITE_OK;
@@ -142625,11 +143282,11 @@
142625143282
/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
142626143283
/* 24 */ "",
142627143284
/* 25 */ "",
142628143285
142629143286
/* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
142630
-/* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
143287
+/* 27 */ "SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'",
142631143288
142632143289
/* This statement is used to determine which level to read the input from
142633143290
** when performing an incremental merge. It returns the absolute level number
142634143291
** of the oldest level in the db that contains at least ? segments. Or,
142635143292
** if no level in the FTS index contains more than ? segments, the statement
@@ -145743,11 +146400,12 @@
145743146400
sqlite3_stmt *pAllLangid = 0;
145744146401
145745146402
rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
145746146403
if( rc==SQLITE_OK ){
145747146404
int rc2;
145748
- sqlite3_bind_int(pAllLangid, 1, p->nIndex);
146405
+ sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
146406
+ sqlite3_bind_int(pAllLangid, 2, p->nIndex);
145749146407
while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
145750146408
int i;
145751146409
int iLangid = sqlite3_column_int(pAllLangid, 0);
145752146410
for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
145753146411
rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);
@@ -147075,11 +147733,11 @@
147075147733
while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
147076147734
147077147735
pHint->n = i;
147078147736
i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
147079147737
i += fts3GetVarint32(&pHint->a[i], pnInput);
147080
- if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
147738
+ if( i!=nHint ) return FTS_CORRUPT_VTAB;
147081147739
147082147740
return SQLITE_OK;
147083147741
}
147084147742
147085147743
@@ -147443,11 +148101,12 @@
147443148101
147444148102
/* This block calculates the checksum according to the FTS index. */
147445148103
rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
147446148104
if( rc==SQLITE_OK ){
147447148105
int rc2;
147448
- sqlite3_bind_int(pAllLangid, 1, p->nIndex);
148106
+ sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
148107
+ sqlite3_bind_int(pAllLangid, 2, p->nIndex);
147449148108
while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
147450148109
int iLangid = sqlite3_column_int(pAllLangid, 0);
147451148110
int i;
147452148111
for(i=0; i<p->nIndex; i++){
147453148112
cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
@@ -147456,11 +148115,10 @@
147456148115
rc2 = sqlite3_reset(pAllLangid);
147457148116
if( rc==SQLITE_OK ) rc = rc2;
147458148117
}
147459148118
147460148119
/* This block calculates the checksum according to the %_content table */
147461
- rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
147462148120
if( rc==SQLITE_OK ){
147463148121
sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
147464148122
sqlite3_stmt *pStmt = 0;
147465148123
char *zSql;
147466148124
@@ -147553,11 +148211,11 @@
147553148211
Fts3Table *p /* FTS3 table handle */
147554148212
){
147555148213
int rc;
147556148214
int bOk = 0;
147557148215
rc = fts3IntegrityCheck(p, &bOk);
147558
- if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
148216
+ if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;
147559148217
return rc;
147560148218
}
147561148219
147562148220
/*
147563148221
** Handle a 'special' INSERT of the form:
@@ -147991,10 +148649,11 @@
147991148649
#define FTS3_MATCHINFO_NDOC 'n' /* 1 value */
147992148650
#define FTS3_MATCHINFO_AVGLENGTH 'a' /* nCol values */
147993148651
#define FTS3_MATCHINFO_LENGTH 'l' /* nCol values */
147994148652
#define FTS3_MATCHINFO_LCS 's' /* nCol values */
147995148653
#define FTS3_MATCHINFO_HITS 'x' /* 3*nCol*nPhrase values */
148654
+#define FTS3_MATCHINFO_LHITS 'y' /* nCol*nPhrase values */
147996148655
147997148656
/*
147998148657
** The default value for the second argument to matchinfo().
147999148658
*/
148000148659
#define FTS3_MATCHINFO_DEFAULT "pcx"
@@ -148772,10 +149431,55 @@
148772149431
}
148773149432
}
148774149433
148775149434
return rc;
148776149435
}
149436
+
149437
+/*
149438
+** fts3ExprIterate() callback used to gather information for the matchinfo
149439
+** directive 'y'.
149440
+*/
149441
+static int fts3ExprLHitsCb(
149442
+ Fts3Expr *pExpr, /* Phrase expression node */
149443
+ int iPhrase, /* Phrase number */
149444
+ void *pCtx /* Pointer to MatchInfo structure */
149445
+){
149446
+ MatchInfo *p = (MatchInfo *)pCtx;
149447
+ Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
149448
+ int rc = SQLITE_OK;
149449
+ int iStart = iPhrase * p->nCol;
149450
+ Fts3Expr *pEof; /* Ancestor node already at EOF */
149451
+
149452
+ /* This must be a phrase */
149453
+ assert( pExpr->pPhrase );
149454
+
149455
+ /* Initialize all output integers to zero. */
149456
+ memset(&p->aMatchinfo[iStart], 0, sizeof(u32) * p->nCol);
149457
+
149458
+ /* Check if this or any parent node is at EOF. If so, then all output
149459
+ ** values are zero. */
149460
+ for(pEof=pExpr; pEof && pEof->bEof==0; pEof=pEof->pParent);
149461
+
149462
+ if( pEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
149463
+ Fts3Phrase *pPhrase = pExpr->pPhrase;
149464
+ char *pIter = pPhrase->doclist.pList;
149465
+ int iCol = 0;
149466
+
149467
+ while( 1 ){
149468
+ int nHit = fts3ColumnlistCount(&pIter);
149469
+ if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
149470
+ p->aMatchinfo[iStart + iCol] = (u32)nHit;
149471
+ }
149472
+ assert( *pIter==0x00 || *pIter==0x01 );
149473
+ if( *pIter!=0x01 ) break;
149474
+ pIter++;
149475
+ pIter += fts3GetVarint32(pIter, &iCol);
149476
+ }
149477
+ }
149478
+
149479
+ return rc;
149480
+}
148777149481
148778149482
static int fts3MatchinfoCheck(
148779149483
Fts3Table *pTab,
148780149484
char cArg,
148781149485
char **pzErr
@@ -148785,14 +149489,15 @@
148785149489
|| (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
148786149490
|| (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
148787149491
|| (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
148788149492
|| (cArg==FTS3_MATCHINFO_LCS)
148789149493
|| (cArg==FTS3_MATCHINFO_HITS)
149494
+ || (cArg==FTS3_MATCHINFO_LHITS)
148790149495
){
148791149496
return SQLITE_OK;
148792149497
}
148793
- *pzErr = sqlite3_mprintf("unrecognized matchinfo request: %c", cArg);
149498
+ sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo request: %c", cArg);
148794149499
return SQLITE_ERROR;
148795149500
}
148796149501
148797149502
static int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){
148798149503
int nVal; /* Number of integers output by cArg */
@@ -148807,10 +149512,14 @@
148807149512
case FTS3_MATCHINFO_AVGLENGTH:
148808149513
case FTS3_MATCHINFO_LENGTH:
148809149514
case FTS3_MATCHINFO_LCS:
148810149515
nVal = pInfo->nCol;
148811149516
break;
149517
+
149518
+ case FTS3_MATCHINFO_LHITS:
149519
+ nVal = pInfo->nCol * pInfo->nPhrase;
149520
+ break;
148812149521
148813149522
default:
148814149523
assert( cArg==FTS3_MATCHINFO_HITS );
148815149524
nVal = pInfo->nCol * pInfo->nPhrase * 3;
148816149525
break;
@@ -149061,10 +149770,14 @@
149061149770
rc = fts3ExprLoadDoclists(pCsr, 0, 0);
149062149771
if( rc==SQLITE_OK ){
149063149772
rc = fts3MatchinfoLcs(pCsr, pInfo);
149064149773
}
149065149774
break;
149775
+
149776
+ case FTS3_MATCHINFO_LHITS:
149777
+ (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo);
149778
+ break;
149066149779
149067149780
default: {
149068149781
Fts3Expr *pExpr;
149069149782
assert( zArg[i]==FTS3_MATCHINFO_HITS );
149070149783
pExpr = pCsr->pExpr;
@@ -153074,15 +153787,23 @@
153074153787
** conflict-handling mode specified by the user.
153075153788
*/
153076153789
if( nData>1 ){
153077153790
int ii;
153078153791
153079
- /* Populate the cell.aCoord[] array. The first coordinate is azData[3]. */
153080
- assert( nData==(pRtree->nDim*2 + 3) );
153792
+ /* Populate the cell.aCoord[] array. The first coordinate is azData[3].
153793
+ **
153794
+ ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared
153795
+ ** with "column" that are interpreted as table constraints.
153796
+ ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));
153797
+ ** This problem was discovered after years of use, so we silently ignore
153798
+ ** these kinds of misdeclared tables to avoid breaking any legacy.
153799
+ */
153800
+ assert( nData<=(pRtree->nDim*2 + 3) );
153801
+
153081153802
#ifndef SQLITE_RTREE_INT_ONLY
153082153803
if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
153083
- for(ii=0; ii<(pRtree->nDim*2); ii+=2){
153804
+ for(ii=0; ii<nData-4; ii+=2){
153084153805
cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
153085153806
cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
153086153807
if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
153087153808
rc = SQLITE_CONSTRAINT;
153088153809
goto constraint;
@@ -153089,11 +153810,11 @@
153089153810
}
153090153811
}
153091153812
}else
153092153813
#endif
153093153814
{
153094
- for(ii=0; ii<(pRtree->nDim*2); ii+=2){
153815
+ for(ii=0; ii<nData-4; ii+=2){
153095153816
cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
153096153817
cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
153097153818
if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
153098153819
rc = SQLITE_CONSTRAINT;
153099153820
goto constraint;
@@ -153660,11 +154381,11 @@
153660154381
}
153661154382
153662154383
/*
153663154384
** Register a new geometry function for use with the r-tree MATCH operator.
153664154385
*/
153665
-SQLITE_API int sqlite3_rtree_geometry_callback(
154386
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
153666154387
sqlite3 *db, /* Register SQL function on this connection */
153667154388
const char *zGeom, /* Name of the new SQL function */
153668154389
int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
153669154390
void *pContext /* Extra data associated with the callback */
153670154391
){
@@ -153684,11 +154405,11 @@
153684154405
153685154406
/*
153686154407
** Register a new 2nd-generation geometry function for use with the
153687154408
** r-tree MATCH operator.
153688154409
*/
153689
-SQLITE_API int sqlite3_rtree_query_callback(
154410
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
153690154411
sqlite3 *db, /* Register SQL function on this connection */
153691154412
const char *zQueryFunc, /* Name of new SQL function */
153692154413
int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
153693154414
void *pContext, /* Extra data passed into the callback */
153694154415
void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153709,11 +154430,11 @@
153709154430
153710154431
#if !SQLITE_CORE
153711154432
#ifdef _WIN32
153712154433
__declspec(dllexport)
153713154434
#endif
153714
-SQLITE_API int sqlite3_rtree_init(
154435
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init(
153715154436
sqlite3 *db,
153716154437
char **pzErrMsg,
153717154438
const sqlite3_api_routines *pApi
153718154439
){
153719154440
SQLITE_EXTENSION_INIT2(pApi)
@@ -154214,11 +154935,11 @@
154214154935
154215154936
#if !SQLITE_CORE
154216154937
#ifdef _WIN32
154217154938
__declspec(dllexport)
154218154939
#endif
154219
-SQLITE_API int sqlite3_icu_init(
154940
+SQLITE_API int SQLITE_STDCALL sqlite3_icu_init(
154220154941
sqlite3 *db,
154221154942
char **pzErrMsg,
154222154943
const sqlite3_api_routines *pApi
154223154944
){
154224154945
SQLITE_EXTENSION_INIT2(pApi)
@@ -154489,5 +155210,656 @@
154489155210
154490155211
#endif /* defined(SQLITE_ENABLE_ICU) */
154491155212
#endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
154492155213
154493155214
/************** End of fts3_icu.c ********************************************/
155215
+/************** Begin file dbstat.c ******************************************/
155216
+/*
155217
+** 2010 July 12
155218
+**
155219
+** The author disclaims copyright to this source code. In place of
155220
+** a legal notice, here is a blessing:
155221
+**
155222
+** May you do good and not evil.
155223
+** May you find forgiveness for yourself and forgive others.
155224
+** May you share freely, never taking more than you give.
155225
+**
155226
+******************************************************************************
155227
+**
155228
+** This file contains an implementation of the "dbstat" virtual table.
155229
+**
155230
+** The dbstat virtual table is used to extract low-level formatting
155231
+** information from an SQLite database in order to implement the
155232
+** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
155233
+** for an example implementation.
155234
+*/
155235
+
155236
+#if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
155237
+ && !defined(SQLITE_OMIT_VIRTUALTABLE)
155238
+
155239
+/*
155240
+** Page paths:
155241
+**
155242
+** The value of the 'path' column describes the path taken from the
155243
+** root-node of the b-tree structure to each page. The value of the
155244
+** root-node path is '/'.
155245
+**
155246
+** The value of the path for the left-most child page of the root of
155247
+** a b-tree is '/000/'. (Btrees store content ordered from left to right
155248
+** so the pages to the left have smaller keys than the pages to the right.)
155249
+** The next to left-most child of the root page is
155250
+** '/001', and so on, each sibling page identified by a 3-digit hex
155251
+** value. The children of the 451st left-most sibling have paths such
155252
+** as '/1c2/000/, '/1c2/001/' etc.
155253
+**
155254
+** Overflow pages are specified by appending a '+' character and a
155255
+** six-digit hexadecimal value to the path to the cell they are linked
155256
+** from. For example, the three overflow pages in a chain linked from
155257
+** the left-most cell of the 450th child of the root page are identified
155258
+** by the paths:
155259
+**
155260
+** '/1c2/000+000000' // First page in overflow chain
155261
+** '/1c2/000+000001' // Second page in overflow chain
155262
+** '/1c2/000+000002' // Third page in overflow chain
155263
+**
155264
+** If the paths are sorted using the BINARY collation sequence, then
155265
+** the overflow pages associated with a cell will appear earlier in the
155266
+** sort-order than its child page:
155267
+**
155268
+** '/1c2/000/' // Left-most child of 451st child of root
155269
+*/
155270
+#define VTAB_SCHEMA \
155271
+ "CREATE TABLE xx( " \
155272
+ " name STRING, /* Name of table or index */" \
155273
+ " path INTEGER, /* Path to page from root */" \
155274
+ " pageno INTEGER, /* Page number */" \
155275
+ " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \
155276
+ " ncell INTEGER, /* Cells on page (0 for overflow) */" \
155277
+ " payload INTEGER, /* Bytes of payload on this page */" \
155278
+ " unused INTEGER, /* Bytes of unused space on this page */" \
155279
+ " mx_payload INTEGER, /* Largest payload size of all cells */" \
155280
+ " pgoffset INTEGER, /* Offset of page in file */" \
155281
+ " pgsize INTEGER /* Size of the page */" \
155282
+ ");"
155283
+
155284
+
155285
+typedef struct StatTable StatTable;
155286
+typedef struct StatCursor StatCursor;
155287
+typedef struct StatPage StatPage;
155288
+typedef struct StatCell StatCell;
155289
+
155290
+struct StatCell {
155291
+ int nLocal; /* Bytes of local payload */
155292
+ u32 iChildPg; /* Child node (or 0 if this is a leaf) */
155293
+ int nOvfl; /* Entries in aOvfl[] */
155294
+ u32 *aOvfl; /* Array of overflow page numbers */
155295
+ int nLastOvfl; /* Bytes of payload on final overflow page */
155296
+ int iOvfl; /* Iterates through aOvfl[] */
155297
+};
155298
+
155299
+struct StatPage {
155300
+ u32 iPgno;
155301
+ DbPage *pPg;
155302
+ int iCell;
155303
+
155304
+ char *zPath; /* Path to this page */
155305
+
155306
+ /* Variables populated by statDecodePage(): */
155307
+ u8 flags; /* Copy of flags byte */
155308
+ int nCell; /* Number of cells on page */
155309
+ int nUnused; /* Number of unused bytes on page */
155310
+ StatCell *aCell; /* Array of parsed cells */
155311
+ u32 iRightChildPg; /* Right-child page number (or 0) */
155312
+ int nMxPayload; /* Largest payload of any cell on this page */
155313
+};
155314
+
155315
+struct StatCursor {
155316
+ sqlite3_vtab_cursor base;
155317
+ sqlite3_stmt *pStmt; /* Iterates through set of root pages */
155318
+ int isEof; /* After pStmt has returned SQLITE_DONE */
155319
+
155320
+ StatPage aPage[32];
155321
+ int iPage; /* Current entry in aPage[] */
155322
+
155323
+ /* Values to return. */
155324
+ char *zName; /* Value of 'name' column */
155325
+ char *zPath; /* Value of 'path' column */
155326
+ u32 iPageno; /* Value of 'pageno' column */
155327
+ char *zPagetype; /* Value of 'pagetype' column */
155328
+ int nCell; /* Value of 'ncell' column */
155329
+ int nPayload; /* Value of 'payload' column */
155330
+ int nUnused; /* Value of 'unused' column */
155331
+ int nMxPayload; /* Value of 'mx_payload' column */
155332
+ i64 iOffset; /* Value of 'pgOffset' column */
155333
+ int szPage; /* Value of 'pgSize' column */
155334
+};
155335
+
155336
+struct StatTable {
155337
+ sqlite3_vtab base;
155338
+ sqlite3 *db;
155339
+ int iDb; /* Index of database to analyze */
155340
+};
155341
+
155342
+#ifndef get2byte
155343
+# define get2byte(x) ((x)[0]<<8 | (x)[1])
155344
+#endif
155345
+
155346
+/*
155347
+** Connect to or create a statvfs virtual table.
155348
+*/
155349
+static int statConnect(
155350
+ sqlite3 *db,
155351
+ void *pAux,
155352
+ int argc, const char *const*argv,
155353
+ sqlite3_vtab **ppVtab,
155354
+ char **pzErr
155355
+){
155356
+ StatTable *pTab = 0;
155357
+ int rc = SQLITE_OK;
155358
+ int iDb;
155359
+
155360
+ if( argc>=4 ){
155361
+ iDb = sqlite3FindDbName(db, argv[3]);
155362
+ if( iDb<0 ){
155363
+ *pzErr = sqlite3_mprintf("no such database: %s", argv[3]);
155364
+ return SQLITE_ERROR;
155365
+ }
155366
+ }else{
155367
+ iDb = 0;
155368
+ }
155369
+ rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
155370
+ if( rc==SQLITE_OK ){
155371
+ pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
155372
+ if( pTab==0 ) rc = SQLITE_NOMEM;
155373
+ }
155374
+
155375
+ assert( rc==SQLITE_OK || pTab==0 );
155376
+ if( rc==SQLITE_OK ){
155377
+ memset(pTab, 0, sizeof(StatTable));
155378
+ pTab->db = db;
155379
+ pTab->iDb = iDb;
155380
+ }
155381
+
155382
+ *ppVtab = (sqlite3_vtab*)pTab;
155383
+ return rc;
155384
+}
155385
+
155386
+/*
155387
+** Disconnect from or destroy a statvfs virtual table.
155388
+*/
155389
+static int statDisconnect(sqlite3_vtab *pVtab){
155390
+ sqlite3_free(pVtab);
155391
+ return SQLITE_OK;
155392
+}
155393
+
155394
+/*
155395
+** There is no "best-index". This virtual table always does a linear
155396
+** scan of the binary VFS log file.
155397
+*/
155398
+static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
155399
+
155400
+ /* Records are always returned in ascending order of (name, path).
155401
+ ** If this will satisfy the client, set the orderByConsumed flag so that
155402
+ ** SQLite does not do an external sort.
155403
+ */
155404
+ if( ( pIdxInfo->nOrderBy==1
155405
+ && pIdxInfo->aOrderBy[0].iColumn==0
155406
+ && pIdxInfo->aOrderBy[0].desc==0
155407
+ ) ||
155408
+ ( pIdxInfo->nOrderBy==2
155409
+ && pIdxInfo->aOrderBy[0].iColumn==0
155410
+ && pIdxInfo->aOrderBy[0].desc==0
155411
+ && pIdxInfo->aOrderBy[1].iColumn==1
155412
+ && pIdxInfo->aOrderBy[1].desc==0
155413
+ )
155414
+ ){
155415
+ pIdxInfo->orderByConsumed = 1;
155416
+ }
155417
+
155418
+ pIdxInfo->estimatedCost = 10.0;
155419
+ return SQLITE_OK;
155420
+}
155421
+
155422
+/*
155423
+** Open a new statvfs cursor.
155424
+*/
155425
+static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
155426
+ StatTable *pTab = (StatTable *)pVTab;
155427
+ StatCursor *pCsr;
155428
+ int rc;
155429
+
155430
+ pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor));
155431
+ if( pCsr==0 ){
155432
+ rc = SQLITE_NOMEM;
155433
+ }else{
155434
+ char *zSql;
155435
+ memset(pCsr, 0, sizeof(StatCursor));
155436
+ pCsr->base.pVtab = pVTab;
155437
+
155438
+ zSql = sqlite3_mprintf(
155439
+ "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
155440
+ " UNION ALL "
155441
+ "SELECT name, rootpage, type"
155442
+ " FROM \"%w\".sqlite_master WHERE rootpage!=0"
155443
+ " ORDER BY name", pTab->db->aDb[pTab->iDb].zName);
155444
+ if( zSql==0 ){
155445
+ rc = SQLITE_NOMEM;
155446
+ }else{
155447
+ rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
155448
+ sqlite3_free(zSql);
155449
+ }
155450
+ if( rc!=SQLITE_OK ){
155451
+ sqlite3_free(pCsr);
155452
+ pCsr = 0;
155453
+ }
155454
+ }
155455
+
155456
+ *ppCursor = (sqlite3_vtab_cursor *)pCsr;
155457
+ return rc;
155458
+}
155459
+
155460
+static void statClearPage(StatPage *p){
155461
+ int i;
155462
+ if( p->aCell ){
155463
+ for(i=0; i<p->nCell; i++){
155464
+ sqlite3_free(p->aCell[i].aOvfl);
155465
+ }
155466
+ sqlite3_free(p->aCell);
155467
+ }
155468
+ sqlite3PagerUnref(p->pPg);
155469
+ sqlite3_free(p->zPath);
155470
+ memset(p, 0, sizeof(StatPage));
155471
+}
155472
+
155473
+static void statResetCsr(StatCursor *pCsr){
155474
+ int i;
155475
+ sqlite3_reset(pCsr->pStmt);
155476
+ for(i=0; i<ArraySize(pCsr->aPage); i++){
155477
+ statClearPage(&pCsr->aPage[i]);
155478
+ }
155479
+ pCsr->iPage = 0;
155480
+ sqlite3_free(pCsr->zPath);
155481
+ pCsr->zPath = 0;
155482
+}
155483
+
155484
+/*
155485
+** Close a statvfs cursor.
155486
+*/
155487
+static int statClose(sqlite3_vtab_cursor *pCursor){
155488
+ StatCursor *pCsr = (StatCursor *)pCursor;
155489
+ statResetCsr(pCsr);
155490
+ sqlite3_finalize(pCsr->pStmt);
155491
+ sqlite3_free(pCsr);
155492
+ return SQLITE_OK;
155493
+}
155494
+
155495
+static void getLocalPayload(
155496
+ int nUsable, /* Usable bytes per page */
155497
+ u8 flags, /* Page flags */
155498
+ int nTotal, /* Total record (payload) size */
155499
+ int *pnLocal /* OUT: Bytes stored locally */
155500
+){
155501
+ int nLocal;
155502
+ int nMinLocal;
155503
+ int nMaxLocal;
155504
+
155505
+ if( flags==0x0D ){ /* Table leaf node */
155506
+ nMinLocal = (nUsable - 12) * 32 / 255 - 23;
155507
+ nMaxLocal = nUsable - 35;
155508
+ }else{ /* Index interior and leaf nodes */
155509
+ nMinLocal = (nUsable - 12) * 32 / 255 - 23;
155510
+ nMaxLocal = (nUsable - 12) * 64 / 255 - 23;
155511
+ }
155512
+
155513
+ nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);
155514
+ if( nLocal>nMaxLocal ) nLocal = nMinLocal;
155515
+ *pnLocal = nLocal;
155516
+}
155517
+
155518
+static int statDecodePage(Btree *pBt, StatPage *p){
155519
+ int nUnused;
155520
+ int iOff;
155521
+ int nHdr;
155522
+ int isLeaf;
155523
+ int szPage;
155524
+
155525
+ u8 *aData = sqlite3PagerGetData(p->pPg);
155526
+ u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];
155527
+
155528
+ p->flags = aHdr[0];
155529
+ p->nCell = get2byte(&aHdr[3]);
155530
+ p->nMxPayload = 0;
155531
+
155532
+ isLeaf = (p->flags==0x0A || p->flags==0x0D);
155533
+ nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;
155534
+
155535
+ nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;
155536
+ nUnused += (int)aHdr[7];
155537
+ iOff = get2byte(&aHdr[1]);
155538
+ while( iOff ){
155539
+ nUnused += get2byte(&aData[iOff+2]);
155540
+ iOff = get2byte(&aData[iOff]);
155541
+ }
155542
+ p->nUnused = nUnused;
155543
+ p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
155544
+ szPage = sqlite3BtreeGetPageSize(pBt);
155545
+
155546
+ if( p->nCell ){
155547
+ int i; /* Used to iterate through cells */
155548
+ int nUsable; /* Usable bytes per page */
155549
+
155550
+ sqlite3BtreeEnter(pBt);
155551
+ nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);
155552
+ sqlite3BtreeLeave(pBt);
155553
+ p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell));
155554
+ if( p->aCell==0 ) return SQLITE_NOMEM;
155555
+ memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));
155556
+
155557
+ for(i=0; i<p->nCell; i++){
155558
+ StatCell *pCell = &p->aCell[i];
155559
+
155560
+ iOff = get2byte(&aData[nHdr+i*2]);
155561
+ if( !isLeaf ){
155562
+ pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);
155563
+ iOff += 4;
155564
+ }
155565
+ if( p->flags==0x05 ){
155566
+ /* A table interior node. nPayload==0. */
155567
+ }else{
155568
+ u32 nPayload; /* Bytes of payload total (local+overflow) */
155569
+ int nLocal; /* Bytes of payload stored locally */
155570
+ iOff += getVarint32(&aData[iOff], nPayload);
155571
+ if( p->flags==0x0D ){
155572
+ u64 dummy;
155573
+ iOff += sqlite3GetVarint(&aData[iOff], &dummy);
155574
+ }
155575
+ if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
155576
+ getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
155577
+ pCell->nLocal = nLocal;
155578
+ assert( nLocal>=0 );
155579
+ assert( nPayload>=(u32)nLocal );
155580
+ assert( nLocal<=(nUsable-35) );
155581
+ if( nPayload>(u32)nLocal ){
155582
+ int j;
155583
+ int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);
155584
+ pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4);
155585
+ pCell->nOvfl = nOvfl;
155586
+ pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl);
155587
+ if( pCell->aOvfl==0 ) return SQLITE_NOMEM;
155588
+ pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]);
155589
+ for(j=1; j<nOvfl; j++){
155590
+ int rc;
155591
+ u32 iPrev = pCell->aOvfl[j-1];
155592
+ DbPage *pPg = 0;
155593
+ rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg);
155594
+ if( rc!=SQLITE_OK ){
155595
+ assert( pPg==0 );
155596
+ return rc;
155597
+ }
155598
+ pCell->aOvfl[j] = sqlite3Get4byte(sqlite3PagerGetData(pPg));
155599
+ sqlite3PagerUnref(pPg);
155600
+ }
155601
+ }
155602
+ }
155603
+ }
155604
+ }
155605
+
155606
+ return SQLITE_OK;
155607
+}
155608
+
155609
+/*
155610
+** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
155611
+** the current value of pCsr->iPageno.
155612
+*/
155613
+static void statSizeAndOffset(StatCursor *pCsr){
155614
+ StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;
155615
+ Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
155616
+ Pager *pPager = sqlite3BtreePager(pBt);
155617
+ sqlite3_file *fd;
155618
+ sqlite3_int64 x[2];
155619
+
155620
+ /* The default page size and offset */
155621
+ pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
155622
+ pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
155623
+
155624
+ /* If connected to a ZIPVFS backend, override the page size and
155625
+ ** offset with actual values obtained from ZIPVFS.
155626
+ */
155627
+ fd = sqlite3PagerFile(pPager);
155628
+ x[0] = pCsr->iPageno;
155629
+ if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
155630
+ pCsr->iOffset = x[0];
155631
+ pCsr->szPage = (int)x[1];
155632
+ }
155633
+}
155634
+
155635
+/*
155636
+** Move a statvfs cursor to the next entry in the file.
155637
+*/
155638
+static int statNext(sqlite3_vtab_cursor *pCursor){
155639
+ int rc;
155640
+ int nPayload;
155641
+ char *z;
155642
+ StatCursor *pCsr = (StatCursor *)pCursor;
155643
+ StatTable *pTab = (StatTable *)pCursor->pVtab;
155644
+ Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
155645
+ Pager *pPager = sqlite3BtreePager(pBt);
155646
+
155647
+ sqlite3_free(pCsr->zPath);
155648
+ pCsr->zPath = 0;
155649
+
155650
+statNextRestart:
155651
+ if( pCsr->aPage[0].pPg==0 ){
155652
+ rc = sqlite3_step(pCsr->pStmt);
155653
+ if( rc==SQLITE_ROW ){
155654
+ int nPage;
155655
+ u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);
155656
+ sqlite3PagerPagecount(pPager, &nPage);
155657
+ if( nPage==0 ){
155658
+ pCsr->isEof = 1;
155659
+ return sqlite3_reset(pCsr->pStmt);
155660
+ }
155661
+ rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg);
155662
+ pCsr->aPage[0].iPgno = iRoot;
155663
+ pCsr->aPage[0].iCell = 0;
155664
+ pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
155665
+ pCsr->iPage = 0;
155666
+ if( z==0 ) rc = SQLITE_NOMEM;
155667
+ }else{
155668
+ pCsr->isEof = 1;
155669
+ return sqlite3_reset(pCsr->pStmt);
155670
+ }
155671
+ }else{
155672
+
155673
+ /* Page p itself has already been visited. */
155674
+ StatPage *p = &pCsr->aPage[pCsr->iPage];
155675
+
155676
+ while( p->iCell<p->nCell ){
155677
+ StatCell *pCell = &p->aCell[p->iCell];
155678
+ if( pCell->iOvfl<pCell->nOvfl ){
155679
+ int nUsable;
155680
+ sqlite3BtreeEnter(pBt);
155681
+ nUsable = sqlite3BtreeGetPageSize(pBt) -
155682
+ sqlite3BtreeGetReserveNoMutex(pBt);
155683
+ sqlite3BtreeLeave(pBt);
155684
+ pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
155685
+ pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];
155686
+ pCsr->zPagetype = "overflow";
155687
+ pCsr->nCell = 0;
155688
+ pCsr->nMxPayload = 0;
155689
+ pCsr->zPath = z = sqlite3_mprintf(
155690
+ "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl
155691
+ );
155692
+ if( pCell->iOvfl<pCell->nOvfl-1 ){
155693
+ pCsr->nUnused = 0;
155694
+ pCsr->nPayload = nUsable - 4;
155695
+ }else{
155696
+ pCsr->nPayload = pCell->nLastOvfl;
155697
+ pCsr->nUnused = nUsable - 4 - pCsr->nPayload;
155698
+ }
155699
+ pCell->iOvfl++;
155700
+ statSizeAndOffset(pCsr);
155701
+ return z==0 ? SQLITE_NOMEM : SQLITE_OK;
155702
+ }
155703
+ if( p->iRightChildPg ) break;
155704
+ p->iCell++;
155705
+ }
155706
+
155707
+ if( !p->iRightChildPg || p->iCell>p->nCell ){
155708
+ statClearPage(p);
155709
+ if( pCsr->iPage==0 ) return statNext(pCursor);
155710
+ pCsr->iPage--;
155711
+ goto statNextRestart; /* Tail recursion */
155712
+ }
155713
+ pCsr->iPage++;
155714
+ assert( p==&pCsr->aPage[pCsr->iPage-1] );
155715
+
155716
+ if( p->iCell==p->nCell ){
155717
+ p[1].iPgno = p->iRightChildPg;
155718
+ }else{
155719
+ p[1].iPgno = p->aCell[p->iCell].iChildPg;
155720
+ }
155721
+ rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg);
155722
+ p[1].iCell = 0;
155723
+ p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
155724
+ p->iCell++;
155725
+ if( z==0 ) rc = SQLITE_NOMEM;
155726
+ }
155727
+
155728
+
155729
+ /* Populate the StatCursor fields with the values to be returned
155730
+ ** by the xColumn() and xRowid() methods.
155731
+ */
155732
+ if( rc==SQLITE_OK ){
155733
+ int i;
155734
+ StatPage *p = &pCsr->aPage[pCsr->iPage];
155735
+ pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
155736
+ pCsr->iPageno = p->iPgno;
155737
+
155738
+ rc = statDecodePage(pBt, p);
155739
+ if( rc==SQLITE_OK ){
155740
+ statSizeAndOffset(pCsr);
155741
+
155742
+ switch( p->flags ){
155743
+ case 0x05: /* table internal */
155744
+ case 0x02: /* index internal */
155745
+ pCsr->zPagetype = "internal";
155746
+ break;
155747
+ case 0x0D: /* table leaf */
155748
+ case 0x0A: /* index leaf */
155749
+ pCsr->zPagetype = "leaf";
155750
+ break;
155751
+ default:
155752
+ pCsr->zPagetype = "corrupted";
155753
+ break;
155754
+ }
155755
+ pCsr->nCell = p->nCell;
155756
+ pCsr->nUnused = p->nUnused;
155757
+ pCsr->nMxPayload = p->nMxPayload;
155758
+ pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
155759
+ if( z==0 ) rc = SQLITE_NOMEM;
155760
+ nPayload = 0;
155761
+ for(i=0; i<p->nCell; i++){
155762
+ nPayload += p->aCell[i].nLocal;
155763
+ }
155764
+ pCsr->nPayload = nPayload;
155765
+ }
155766
+ }
155767
+
155768
+ return rc;
155769
+}
155770
+
155771
+static int statEof(sqlite3_vtab_cursor *pCursor){
155772
+ StatCursor *pCsr = (StatCursor *)pCursor;
155773
+ return pCsr->isEof;
155774
+}
155775
+
155776
+static int statFilter(
155777
+ sqlite3_vtab_cursor *pCursor,
155778
+ int idxNum, const char *idxStr,
155779
+ int argc, sqlite3_value **argv
155780
+){
155781
+ StatCursor *pCsr = (StatCursor *)pCursor;
155782
+
155783
+ statResetCsr(pCsr);
155784
+ return statNext(pCursor);
155785
+}
155786
+
155787
+static int statColumn(
155788
+ sqlite3_vtab_cursor *pCursor,
155789
+ sqlite3_context *ctx,
155790
+ int i
155791
+){
155792
+ StatCursor *pCsr = (StatCursor *)pCursor;
155793
+ switch( i ){
155794
+ case 0: /* name */
155795
+ sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);
155796
+ break;
155797
+ case 1: /* path */
155798
+ sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
155799
+ break;
155800
+ case 2: /* pageno */
155801
+ sqlite3_result_int64(ctx, pCsr->iPageno);
155802
+ break;
155803
+ case 3: /* pagetype */
155804
+ sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
155805
+ break;
155806
+ case 4: /* ncell */
155807
+ sqlite3_result_int(ctx, pCsr->nCell);
155808
+ break;
155809
+ case 5: /* payload */
155810
+ sqlite3_result_int(ctx, pCsr->nPayload);
155811
+ break;
155812
+ case 6: /* unused */
155813
+ sqlite3_result_int(ctx, pCsr->nUnused);
155814
+ break;
155815
+ case 7: /* mx_payload */
155816
+ sqlite3_result_int(ctx, pCsr->nMxPayload);
155817
+ break;
155818
+ case 8: /* pgoffset */
155819
+ sqlite3_result_int64(ctx, pCsr->iOffset);
155820
+ break;
155821
+ default: /* pgsize */
155822
+ assert( i==9 );
155823
+ sqlite3_result_int(ctx, pCsr->szPage);
155824
+ break;
155825
+ }
155826
+ return SQLITE_OK;
155827
+}
155828
+
155829
+static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
155830
+ StatCursor *pCsr = (StatCursor *)pCursor;
155831
+ *pRowid = pCsr->iPageno;
155832
+ return SQLITE_OK;
155833
+}
155834
+
155835
+/*
155836
+** Invoke this routine to register the "dbstat" virtual table module
155837
+*/
155838
+SQLITE_API int SQLITE_STDCALL sqlite3_dbstat_register(sqlite3 *db){
155839
+ static sqlite3_module dbstat_module = {
155840
+ 0, /* iVersion */
155841
+ statConnect, /* xCreate */
155842
+ statConnect, /* xConnect */
155843
+ statBestIndex, /* xBestIndex */
155844
+ statDisconnect, /* xDisconnect */
155845
+ statDisconnect, /* xDestroy */
155846
+ statOpen, /* xOpen - open a cursor */
155847
+ statClose, /* xClose - close a cursor */
155848
+ statFilter, /* xFilter - configure scan constraints */
155849
+ statNext, /* xNext - advance a cursor */
155850
+ statEof, /* xEof - check for end of scan */
155851
+ statColumn, /* xColumn - read data */
155852
+ statRowid, /* xRowid - read data */
155853
+ 0, /* xUpdate */
155854
+ 0, /* xBegin */
155855
+ 0, /* xSync */
155856
+ 0, /* xCommit */
155857
+ 0, /* xRollback */
155858
+ 0, /* xFindMethod */
155859
+ 0, /* xRename */
155860
+ };
155861
+ return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
155862
+}
155863
+#endif /* SQLITE_ENABLE_DBSTAT_VTAB */
155864
+
155865
+/************** End of dbstat.c **********************************************/
154494155866
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.8.9. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -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
@@ -71,10 +68,11 @@
71 #if defined(_MSC_VER)
72 #pragma warning(disable : 4054)
73 #pragma warning(disable : 4055)
74 #pragma warning(disable : 4100)
75 #pragma warning(disable : 4127)
 
76 #pragma warning(disable : 4152)
77 #pragma warning(disable : 4189)
78 #pragma warning(disable : 4206)
79 #pragma warning(disable : 4210)
80 #pragma warning(disable : 4232)
@@ -250,27 +248,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 ** Add the ability to override 'cdecl'
268 */
269 #ifndef SQLITE_CDECL
270 # define SQLITE_CDECL
271 #endif
 
 
 
272
273 /*
274 ** These no-op macros are used in front of interfaces to mark those
275 ** interfaces as either deprecated or experimental. New applications
276 ** should not use deprecated interfaces - they are supported for backwards
@@ -321,13 +316,13 @@
321 **
322 ** See also: [sqlite3_libversion()],
323 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
324 ** [sqlite_version()] and [sqlite_source_id()].
325 */
326 #define SQLITE_VERSION "3.8.9"
327 #define SQLITE_VERSION_NUMBER 3008009
328 #define SQLITE_SOURCE_ID "2015-03-24 18:19:39 436314b5728c9413f9ac2d837e1c19364f31be72"
329
330 /*
331 ** CAPI3REF: Run-Time Library Version Numbers
332 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
333 **
@@ -356,13 +351,13 @@
356 ** [SQLITE_SOURCE_ID] C preprocessor macro.
357 **
358 ** See also: [sqlite_version()] and [sqlite_source_id()].
359 */
360 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
361 SQLITE_API const char *sqlite3_libversion(void);
362 SQLITE_API const char *sqlite3_sourceid(void);
363 SQLITE_API int sqlite3_libversion_number(void);
364
365 /*
366 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
367 **
368 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -383,12 +378,12 @@
383 **
384 ** See also: SQL functions [sqlite_compileoption_used()] and
385 ** [sqlite_compileoption_get()] and the [compile_options pragma].
386 */
387 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
388 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
389 SQLITE_API const char *sqlite3_compileoption_get(int N);
390 #endif
391
392 /*
393 ** CAPI3REF: Test To See If The Library Is Threadsafe
394 **
@@ -423,11 +418,11 @@
423 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
424 ** is unchanged by calls to sqlite3_config().)^
425 **
426 ** See the [threading mode] documentation for additional information.
427 */
428 SQLITE_API int sqlite3_threadsafe(void);
429
430 /*
431 ** CAPI3REF: Database Connection Handle
432 ** KEYWORDS: {database connection} {database connections}
433 **
@@ -480,10 +475,11 @@
480 # define double sqlite3_int64
481 #endif
482
483 /*
484 ** CAPI3REF: Closing A Database Connection
 
485 **
486 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
487 ** for the [sqlite3] object.
488 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
489 ** the [sqlite3] object is successfully destroyed and all associated
@@ -519,12 +515,12 @@
519 ** from [sqlite3_open()], [sqlite3_open16()], or
520 ** [sqlite3_open_v2()], and not previously closed.
521 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
522 ** argument is a harmless no-op.
523 */
524 SQLITE_API int sqlite3_close(sqlite3*);
525 SQLITE_API int sqlite3_close_v2(sqlite3*);
526
527 /*
528 ** The type for a callback function.
529 ** This is legacy and deprecated. It is included for historical
530 ** compatibility and is not documented.
@@ -531,10 +527,11 @@
531 */
532 typedef int (*sqlite3_callback)(void*,int,char**, char**);
533
534 /*
535 ** CAPI3REF: One-Step Query Execution Interface
 
536 **
537 ** The sqlite3_exec() interface is a convenience wrapper around
538 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
539 ** that allows an application to run multiple statements of SQL
540 ** without having to use a lot of C code.
@@ -590,11 +587,11 @@
590 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
591 ** <li> The application must not modify the SQL statement text passed into
592 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
593 ** </ul>
594 */
595 SQLITE_API int sqlite3_exec(
596 sqlite3*, /* An open database */
597 const char *sql, /* SQL to be evaluated */
598 int (*callback)(void*,int,char**,char**), /* Callback function */
599 void *, /* 1st argument to callback */
600 char **errmsg /* Error msg written here */
@@ -1550,14 +1547,14 @@
1550 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1551 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1552 ** must return [SQLITE_OK] on success and some other [error code] upon
1553 ** failure.
1554 */
1555 SQLITE_API int sqlite3_initialize(void);
1556 SQLITE_API int sqlite3_shutdown(void);
1557 SQLITE_API int sqlite3_os_init(void);
1558 SQLITE_API int sqlite3_os_end(void);
1559
1560 /*
1561 ** CAPI3REF: Configuring The SQLite Library
1562 **
1563 ** The sqlite3_config() interface is used to make global configuration
@@ -1584,14 +1581,15 @@
1584 **
1585 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1586 ** ^If the option is unknown or SQLite is unable to set the option
1587 ** then this routine returns a non-zero [error code].
1588 */
1589 SQLITE_API int sqlite3_config(int, ...);
1590
1591 /*
1592 ** CAPI3REF: Configure database connections
 
1593 **
1594 ** The sqlite3_db_config() interface is used to make configuration
1595 ** changes to a [database connection]. The interface is similar to
1596 ** [sqlite3_config()] except that the changes apply to a single
1597 ** [database connection] (specified in the first argument).
@@ -1602,11 +1600,11 @@
1602 ** Subsequent arguments vary depending on the configuration verb.
1603 **
1604 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1605 ** the call is considered successful.
1606 */
1607 SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1608
1609 /*
1610 ** CAPI3REF: Memory Allocation Routines
1611 **
1612 ** An instance of this object defines the interface between SQLite
@@ -2085,19 +2083,21 @@
2085 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2086
2087
2088 /*
2089 ** CAPI3REF: Enable Or Disable Extended Result Codes
 
2090 **
2091 ** ^The sqlite3_extended_result_codes() routine enables or disables the
2092 ** [extended result codes] feature of SQLite. ^The extended result
2093 ** codes are disabled by default for historical compatibility.
2094 */
2095 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
2096
2097 /*
2098 ** CAPI3REF: Last Insert Rowid
 
2099 **
2100 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
2101 ** has a unique 64-bit signed
2102 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
2103 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -2141,14 +2141,15 @@
2141 ** function is running and thus changes the last insert [rowid],
2142 ** then the value returned by [sqlite3_last_insert_rowid()] is
2143 ** unpredictable and might not equal either the old or the new
2144 ** last insert [rowid].
2145 */
2146 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
2147
2148 /*
2149 ** CAPI3REF: Count The Number Of Rows Modified
 
2150 **
2151 ** ^This function returns the number of rows modified, inserted or
2152 ** deleted by the most recently completed INSERT, UPDATE or DELETE
2153 ** statement on the database connection specified by the only parameter.
2154 ** ^Executing any other type of SQL statement does not modify the value
@@ -2193,14 +2194,15 @@
2193 **
2194 ** If a separate thread makes changes on the same database connection
2195 ** while [sqlite3_changes()] is running then the value returned
2196 ** is unpredictable and not meaningful.
2197 */
2198 SQLITE_API int sqlite3_changes(sqlite3*);
2199
2200 /*
2201 ** CAPI3REF: Total Number Of Rows Modified
 
2202 **
2203 ** ^This function returns the total number of rows inserted, modified or
2204 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2205 ** since the database connection was opened, including those executed as
2206 ** part of trigger programs. ^Executing any other type of SQL statement
@@ -2216,14 +2218,15 @@
2216 **
2217 ** If a separate thread makes changes on the same database connection
2218 ** while [sqlite3_total_changes()] is running then the value
2219 ** returned is unpredictable and not meaningful.
2220 */
2221 SQLITE_API int sqlite3_total_changes(sqlite3*);
2222
2223 /*
2224 ** CAPI3REF: Interrupt A Long-Running Query
 
2225 **
2226 ** ^This function causes any pending database operation to abort and
2227 ** return at its earliest opportunity. This routine is typically
2228 ** called in response to a user action such as pressing "Cancel"
2229 ** or Ctrl-C where the user wants a long query operation to halt
@@ -2255,11 +2258,11 @@
2255 ** that are started after the sqlite3_interrupt() call returns.
2256 **
2257 ** If the database connection closes while [sqlite3_interrupt()]
2258 ** is running then bad things will likely happen.
2259 */
2260 SQLITE_API void sqlite3_interrupt(sqlite3*);
2261
2262 /*
2263 ** CAPI3REF: Determine If An SQL Statement Is Complete
2264 **
2265 ** These routines are useful during command-line input to determine if the
@@ -2290,16 +2293,17 @@
2290 ** UTF-8 string.
2291 **
2292 ** The input to [sqlite3_complete16()] must be a zero-terminated
2293 ** UTF-16 string in native byte order.
2294 */
2295 SQLITE_API int sqlite3_complete(const char *sql);
2296 SQLITE_API int sqlite3_complete16(const void *sql);
2297
2298 /*
2299 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2300 ** KEYWORDS: {busy-handler callback} {busy handler}
 
2301 **
2302 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
2303 ** that might be invoked with argument P whenever
2304 ** an attempt is made to access a database table associated with
2305 ** [database connection] D when another thread
@@ -2351,14 +2355,15 @@
2351 ** result in undefined behavior.
2352 **
2353 ** A busy handler must not close the database connection
2354 ** or [prepared statement] that invoked the busy handler.
2355 */
2356 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2357
2358 /*
2359 ** CAPI3REF: Set A Busy Timeout
 
2360 **
2361 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2362 ** for a specified amount of time when a table is locked. ^The handler
2363 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2364 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2373,14 +2378,15 @@
2373 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2374 ** this routine, that other busy handler is cleared.)^
2375 **
2376 ** See also: [PRAGMA busy_timeout]
2377 */
2378 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2379
2380 /*
2381 ** CAPI3REF: Convenience Routines For Running Queries
 
2382 **
2383 ** This is a legacy interface that is preserved for backwards compatibility.
2384 ** Use of this interface is not recommended.
2385 **
2386 ** Definition: A <b>result table</b> is memory data structure created by the
@@ -2447,19 +2453,19 @@
2447 ** interface defined here. As a consequence, errors that occur in the
2448 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2449 ** reflected in subsequent calls to [sqlite3_errcode()] or
2450 ** [sqlite3_errmsg()].
2451 */
2452 SQLITE_API int sqlite3_get_table(
2453 sqlite3 *db, /* An open database */
2454 const char *zSql, /* SQL to be evaluated */
2455 char ***pazResult, /* Results of the query */
2456 int *pnRow, /* Number of result rows written here */
2457 int *pnColumn, /* Number of result columns written here */
2458 char **pzErrmsg /* Error msg written here */
2459 );
2460 SQLITE_API void sqlite3_free_table(char **result);
2461
2462 /*
2463 ** CAPI3REF: Formatted String Printing Functions
2464 **
2465 ** These routines are work-alikes of the "printf()" family of functions
@@ -2561,14 +2567,14 @@
2561 **
2562 ** ^(The "%z" formatting option works like "%s" but with the
2563 ** addition that after the string has been read and copied into
2564 ** the result, [sqlite3_free()] is called on the input string.)^
2565 */
2566 SQLITE_API char *sqlite3_mprintf(const char*,...);
2567 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2568 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2569 SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2570
2571 /*
2572 ** CAPI3REF: Memory Allocation Subsystem
2573 **
2574 ** The SQLite core uses these three routines for all of its own
@@ -2654,16 +2660,16 @@
2654 **
2655 ** The application must not read or write any part of
2656 ** a block of memory after it has been released using
2657 ** [sqlite3_free()] or [sqlite3_realloc()].
2658 */
2659 SQLITE_API void *sqlite3_malloc(int);
2660 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2661 SQLITE_API void *sqlite3_realloc(void*, int);
2662 SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2663 SQLITE_API void sqlite3_free(void*);
2664 SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2665
2666 /*
2667 ** CAPI3REF: Memory Allocator Statistics
2668 **
2669 ** SQLite provides these two interfaces for reporting on the status
@@ -2684,12 +2690,12 @@
2684 ** [sqlite3_memory_used()] if and only if the parameter to
2685 ** [sqlite3_memory_highwater()] is true. ^The value returned
2686 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2687 ** prior to the reset.
2688 */
2689 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2690 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2691
2692 /*
2693 ** CAPI3REF: Pseudo-Random Number Generator
2694 **
2695 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2708,14 +2714,15 @@
2708 ** ^If the previous call to this routine had an N of 1 or more and a
2709 ** non-NULL P then the pseudo-randomness is generated
2710 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2711 ** method.
2712 */
2713 SQLITE_API void sqlite3_randomness(int N, void *P);
2714
2715 /*
2716 ** CAPI3REF: Compile-Time Authorization Callbacks
 
2717 **
2718 ** ^This routine registers an authorizer callback with a particular
2719 ** [database connection], supplied in the first argument.
2720 ** ^The authorizer callback is invoked as SQL statements are being compiled
2721 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2790,11 +2797,11 @@
2790 ** [sqlite3_prepare()] or its variants. Authorization is not
2791 ** performed during statement evaluation in [sqlite3_step()], unless
2792 ** as stated in the previous paragraph, sqlite3_step() invokes
2793 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2794 */
2795 SQLITE_API int sqlite3_set_authorizer(
2796 sqlite3*,
2797 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2798 void *pUserData
2799 );
2800
@@ -2868,10 +2875,11 @@
2868 #define SQLITE_COPY 0 /* No longer used */
2869 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2870
2871 /*
2872 ** CAPI3REF: Tracing And Profiling Functions
 
2873 **
2874 ** These routines register callback functions that can be used for
2875 ** tracing and profiling the execution of SQL statements.
2876 **
2877 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2894,16 +2902,17 @@
2894 ** digits in the time are meaningless. Future versions of SQLite
2895 ** might provide greater resolution on the profiler callback. The
2896 ** sqlite3_profile() function is considered experimental and is
2897 ** subject to change in future versions of SQLite.
2898 */
2899 SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2900 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2901 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2902
2903 /*
2904 ** CAPI3REF: Query Progress Callbacks
 
2905 **
2906 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
2907 ** function X to be invoked periodically during long running calls to
2908 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2909 ** database connection D. An example use for this
@@ -2929,14 +2938,15 @@
2929 ** the database connection that invoked the progress handler.
2930 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2931 ** database connections for the meaning of "modify" in this paragraph.
2932 **
2933 */
2934 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2935
2936 /*
2937 ** CAPI3REF: Opening A New Database Connection
 
2938 **
2939 ** ^These routines open an SQLite database file as specified by the
2940 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2941 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2942 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -3157,19 +3167,19 @@
3157 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
3158 ** features that require the use of temporary files may fail.
3159 **
3160 ** See also: [sqlite3_temp_directory]
3161 */
3162 SQLITE_API int sqlite3_open(
3163 const char *filename, /* Database filename (UTF-8) */
3164 sqlite3 **ppDb /* OUT: SQLite db handle */
3165 );
3166 SQLITE_API int sqlite3_open16(
3167 const void *filename, /* Database filename (UTF-16) */
3168 sqlite3 **ppDb /* OUT: SQLite db handle */
3169 );
3170 SQLITE_API int sqlite3_open_v2(
3171 const char *filename, /* Database filename (UTF-8) */
3172 sqlite3 **ppDb, /* OUT: SQLite db handle */
3173 int flags, /* Flags */
3174 const char *zVfs /* Name of VFS module to use */
3175 );
@@ -3211,17 +3221,18 @@
3211 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3212 ** is not a database file pathname pointer that SQLite passed into the xOpen
3213 ** VFS method, then the behavior of this routine is undefined and probably
3214 ** undesirable.
3215 */
3216 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3217 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3218 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3219
3220
3221 /*
3222 ** CAPI3REF: Error Codes And Messages
 
3223 **
3224 ** ^If the most recent sqlite3_* API call associated with
3225 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3226 ** returns the numeric [result code] or [extended result code] for that
3227 ** API call.
@@ -3256,44 +3267,45 @@
3256 **
3257 ** If an interface fails with SQLITE_MISUSE, that means the interface
3258 ** was invoked incorrectly by the application. In that case, the
3259 ** error code and message may or may not be set.
3260 */
3261 SQLITE_API int sqlite3_errcode(sqlite3 *db);
3262 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3263 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3264 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3265 SQLITE_API const char *sqlite3_errstr(int);
3266
3267 /*
3268 ** CAPI3REF: SQL Statement Object
3269 ** KEYWORDS: {prepared statement} {prepared statements}
3270 **
3271 ** An instance of this object represents a single SQL statement.
3272 ** This object is variously known as a "prepared statement" or a
3273 ** "compiled SQL statement" or simply as a "statement".
3274 **
3275 ** The life of a statement object goes something like this:
 
 
 
 
 
3276 **
3277 ** <ol>
3278 ** <li> Create the object using [sqlite3_prepare_v2()] or a related
3279 ** function.
3280 ** <li> Bind values to [host parameters] using the sqlite3_bind_*()
3281 ** interfaces.
3282 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3283 ** <li> Reset the statement using [sqlite3_reset()] then go back
3284 ** to step 2. Do this zero or more times.
3285 ** <li> Destroy the object using [sqlite3_finalize()].
3286 ** </ol>
3287 **
3288 ** Refer to documentation on individual methods above for additional
3289 ** information.
3290 */
3291 typedef struct sqlite3_stmt sqlite3_stmt;
3292
3293 /*
3294 ** CAPI3REF: Run-time Limits
 
3295 **
3296 ** ^(This interface allows the size of various constructs to be limited
3297 ** on a connection by connection basis. The first parameter is the
3298 ** [database connection] whose limit is to be set or queried. The
3299 ** second parameter is one of the [limit categories] that define a
@@ -3327,11 +3339,11 @@
3327 ** created by an untrusted script can be contained using the
3328 ** [max_page_count] [PRAGMA].
3329 **
3330 ** New run-time limit categories may be added in future releases.
3331 */
3332 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3333
3334 /*
3335 ** CAPI3REF: Run-Time Limit Categories
3336 ** KEYWORDS: {limit category} {*limit categories}
3337 **
@@ -3401,10 +3413,12 @@
3401 #define SQLITE_LIMIT_WORKER_THREADS 11
3402
3403 /*
3404 ** CAPI3REF: Compiling An SQL Statement
3405 ** KEYWORDS: {SQL statement compiler}
 
 
3406 **
3407 ** To execute an SQL query, it must first be compiled into a byte-code
3408 ** program using one of these routines.
3409 **
3410 ** The first argument, "db", is a [database connection] obtained from a
@@ -3477,50 +3491,52 @@
3477 ** or [GLOB] operator or if the parameter is compared to an indexed column
3478 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3479 ** </li>
3480 ** </ol>
3481 */
3482 SQLITE_API int sqlite3_prepare(
3483 sqlite3 *db, /* Database handle */
3484 const char *zSql, /* SQL statement, UTF-8 encoded */
3485 int nByte, /* Maximum length of zSql in bytes. */
3486 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3487 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3488 );
3489 SQLITE_API int sqlite3_prepare_v2(
3490 sqlite3 *db, /* Database handle */
3491 const char *zSql, /* SQL statement, UTF-8 encoded */
3492 int nByte, /* Maximum length of zSql in bytes. */
3493 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3494 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3495 );
3496 SQLITE_API int sqlite3_prepare16(
3497 sqlite3 *db, /* Database handle */
3498 const void *zSql, /* SQL statement, UTF-16 encoded */
3499 int nByte, /* Maximum length of zSql in bytes. */
3500 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3501 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3502 );
3503 SQLITE_API int sqlite3_prepare16_v2(
3504 sqlite3 *db, /* Database handle */
3505 const void *zSql, /* SQL statement, UTF-16 encoded */
3506 int nByte, /* Maximum length of zSql in bytes. */
3507 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3508 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3509 );
3510
3511 /*
3512 ** CAPI3REF: Retrieving Statement SQL
 
3513 **
3514 ** ^This interface can be used to retrieve a saved copy of the original
3515 ** SQL text used to create a [prepared statement] if that statement was
3516 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3517 */
3518 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3519
3520 /*
3521 ** CAPI3REF: Determine If An SQL Statement Writes The Database
 
3522 **
3523 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3524 ** and only if the [prepared statement] X makes no direct changes to
3525 ** the content of the database file.
3526 **
@@ -3544,14 +3560,15 @@
3544 ** database. ^The [ATTACH] and [DETACH] statements also cause
3545 ** sqlite3_stmt_readonly() to return true since, while those statements
3546 ** change the configuration of a database connection, they do not make
3547 ** changes to the content of the database files on disk.
3548 */
3549 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3550
3551 /*
3552 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
 
3553 **
3554 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3555 ** [prepared statement] S has been stepped at least once using
3556 ** [sqlite3_step(S)] but has not run to completion and/or has not
3557 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3563,11 +3580,11 @@
3563 ** to locate all prepared statements associated with a database
3564 ** connection that are in need of being reset. This can be used,
3565 ** for example, in diagnostic routines to search for prepared
3566 ** statements that are holding a transaction open.
3567 */
3568 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3569
3570 /*
3571 ** CAPI3REF: Dynamically Typed Value Object
3572 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3573 **
@@ -3622,10 +3639,11 @@
3622
3623 /*
3624 ** CAPI3REF: Binding Values To Prepared Statements
3625 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3626 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
 
3627 **
3628 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3629 ** literals may be replaced by a [parameter] that matches one of following
3630 ** templates:
3631 **
@@ -3724,26 +3742,27 @@
3724 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3725 **
3726 ** See also: [sqlite3_bind_parameter_count()],
3727 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3728 */
3729 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3730 SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3731 void(*)(void*));
3732 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3733 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3734 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3735 SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3736 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3737 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3738 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3739 void(*)(void*), unsigned char encoding);
3740 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3741 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3742
3743 /*
3744 ** CAPI3REF: Number Of SQL Parameters
 
3745 **
3746 ** ^This routine can be used to find the number of [SQL parameters]
3747 ** in a [prepared statement]. SQL parameters are tokens of the
3748 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3749 ** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3756,14 +3775,15 @@
3756 **
3757 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3758 ** [sqlite3_bind_parameter_name()], and
3759 ** [sqlite3_bind_parameter_index()].
3760 */
3761 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3762
3763 /*
3764 ** CAPI3REF: Name Of A Host Parameter
 
3765 **
3766 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3767 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3768 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3769 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3783,14 +3803,15 @@
3783 **
3784 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3785 ** [sqlite3_bind_parameter_count()], and
3786 ** [sqlite3_bind_parameter_index()].
3787 */
3788 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3789
3790 /*
3791 ** CAPI3REF: Index Of A Parameter With A Given Name
 
3792 **
3793 ** ^Return the index of an SQL parameter given its name. ^The
3794 ** index value returned is suitable for use as the second
3795 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3796 ** is returned if no matching parameter is found. ^The parameter
@@ -3799,34 +3820,37 @@
3799 **
3800 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3801 ** [sqlite3_bind_parameter_count()], and
3802 ** [sqlite3_bind_parameter_index()].
3803 */
3804 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3805
3806 /*
3807 ** CAPI3REF: Reset All Bindings On A Prepared Statement
 
3808 **
3809 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3810 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3811 ** ^Use this routine to reset all host parameters to NULL.
3812 */
3813 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3814
3815 /*
3816 ** CAPI3REF: Number Of Columns In A Result Set
 
3817 **
3818 ** ^Return the number of columns in the result set returned by the
3819 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3820 ** statement that does not return data (for example an [UPDATE]).
3821 **
3822 ** See also: [sqlite3_data_count()]
3823 */
3824 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3825
3826 /*
3827 ** CAPI3REF: Column Names In A Result Set
 
3828 **
3829 ** ^These routines return the name assigned to a particular column
3830 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3831 ** interface returns a pointer to a zero-terminated UTF-8 string
3832 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3847,15 +3871,16 @@
3847 ** ^The name of a result column is the value of the "AS" clause for
3848 ** that column, if there is an AS clause. If there is no AS clause
3849 ** then the name of the column is unspecified and may change from
3850 ** one release of SQLite to the next.
3851 */
3852 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3853 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3854
3855 /*
3856 ** CAPI3REF: Source Of Data In A Query Result
 
3857 **
3858 ** ^These routines provide a means to determine the database, table, and
3859 ** table column that is the origin of a particular result column in
3860 ** [SELECT] statement.
3861 ** ^The name of the database or table or column can be returned as
@@ -3895,19 +3920,20 @@
3895 ** If two or more threads call one or more
3896 ** [sqlite3_column_database_name | column metadata interfaces]
3897 ** for the same [prepared statement] and result column
3898 ** at the same time then the results are undefined.
3899 */
3900 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3901 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3902 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3903 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3904 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3905 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3906
3907 /*
3908 ** CAPI3REF: Declared Datatype Of A Query Result
 
3909 **
3910 ** ^(The first parameter is a [prepared statement].
3911 ** If this statement is a [SELECT] statement and the Nth column of the
3912 ** returned result set of that [SELECT] is a table column (not an
3913 ** expression or subquery) then the declared type of the table
@@ -3931,15 +3957,16 @@
3931 ** data stored in that column is of the declared type. SQLite is
3932 ** strongly typed, but the typing is dynamic not static. ^Type
3933 ** is associated with individual values, not with the containers
3934 ** used to hold those values.
3935 */
3936 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3937 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3938
3939 /*
3940 ** CAPI3REF: Evaluate An SQL Statement
 
3941 **
3942 ** After a [prepared statement] has been prepared using either
3943 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3944 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3945 ** must be called one or more times to evaluate the statement.
@@ -4011,14 +4038,15 @@
4011 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
4012 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4013 ** then the more specific [error codes] are returned directly
4014 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4015 */
4016 SQLITE_API int sqlite3_step(sqlite3_stmt*);
4017
4018 /*
4019 ** CAPI3REF: Number of columns in a result set
 
4020 **
4021 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
4022 ** current row of the result set of [prepared statement] P.
4023 ** ^If prepared statement P does not have results ready to return
4024 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -4031,11 +4059,11 @@
4031 ** where it always returns zero since each step of that multi-step
4032 ** pragma returns 0 columns of data.
4033 **
4034 ** See also: [sqlite3_column_count()]
4035 */
4036 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
4037
4038 /*
4039 ** CAPI3REF: Fundamental Datatypes
4040 ** KEYWORDS: SQLITE_TEXT
4041 **
@@ -4068,10 +4096,11 @@
4068 #define SQLITE3_TEXT 3
4069
4070 /*
4071 ** CAPI3REF: Result Values From A Query
4072 ** KEYWORDS: {column access functions}
 
4073 **
4074 ** These routines form the "result set" interface.
4075 **
4076 ** ^These routines return information about a single column of the current
4077 ** result row of a query. ^In every case the first argument is a pointer
@@ -4227,23 +4256,24 @@
4227 ** of these routines, a default value is returned. The default value
4228 ** is either the integer 0, the floating point number 0.0, or a NULL
4229 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4230 ** [SQLITE_NOMEM].)^
4231 */
4232 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4233 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4234 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4235 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4236 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4237 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4238 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4239 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4240 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4241 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4242
4243 /*
4244 ** CAPI3REF: Destroy A Prepared Statement Object
 
4245 **
4246 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4247 ** ^If the most recent evaluation of the statement encountered no errors
4248 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4249 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4263,14 +4293,15 @@
4263 ** resource leaks. It is a grievous error for the application to try to use
4264 ** a prepared statement after it has been finalized. Any use of a prepared
4265 ** statement after it has been finalized can result in undefined and
4266 ** undesirable behavior such as segfaults and heap corruption.
4267 */
4268 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4269
4270 /*
4271 ** CAPI3REF: Reset A Prepared Statement Object
 
4272 **
4273 ** The sqlite3_reset() function is called to reset a [prepared statement]
4274 ** object back to its initial state, ready to be re-executed.
4275 ** ^Any SQL statement variables that had values bound to them using
4276 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4289,17 +4320,18 @@
4289 ** [sqlite3_reset(S)] returns an appropriate [error code].
4290 **
4291 ** ^The [sqlite3_reset(S)] interface does not change the values
4292 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4293 */
4294 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4295
4296 /*
4297 ** CAPI3REF: Create Or Redefine SQL Functions
4298 ** KEYWORDS: {function creation routines}
4299 ** KEYWORDS: {application-defined SQL function}
4300 ** KEYWORDS: {application-defined SQL functions}
 
4301 **
4302 ** ^These functions (collectively known as "function creation routines")
4303 ** are used to add SQL functions or aggregates or to redefine the behavior
4304 ** of existing SQL functions or aggregates. The only differences between
4305 ** these routines are the text encoding expected for
@@ -4388,31 +4420,31 @@
4388 ** ^An application-defined function is permitted to call other
4389 ** SQLite interfaces. However, such calls must not
4390 ** close the database connection nor finalize or reset the prepared
4391 ** statement in which the function is running.
4392 */
4393 SQLITE_API int sqlite3_create_function(
4394 sqlite3 *db,
4395 const char *zFunctionName,
4396 int nArg,
4397 int eTextRep,
4398 void *pApp,
4399 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4400 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4401 void (*xFinal)(sqlite3_context*)
4402 );
4403 SQLITE_API int sqlite3_create_function16(
4404 sqlite3 *db,
4405 const void *zFunctionName,
4406 int nArg,
4407 int eTextRep,
4408 void *pApp,
4409 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4410 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4411 void (*xFinal)(sqlite3_context*)
4412 );
4413 SQLITE_API int sqlite3_create_function_v2(
4414 sqlite3 *db,
4415 const char *zFunctionName,
4416 int nArg,
4417 int eTextRep,
4418 void *pApp,
@@ -4454,21 +4486,22 @@
4454 ** to be supported. However, new applications should avoid
4455 ** the use of these functions. To encourage programmers to avoid
4456 ** these functions, we will not explain what they do.
4457 */
4458 #ifndef SQLITE_OMIT_DEPRECATED
4459 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4460 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4461 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4462 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4463 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4464 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4465 void*,sqlite3_int64);
4466 #endif
4467
4468 /*
4469 ** CAPI3REF: Obtaining SQL Function Parameter Values
 
4470 **
4471 ** The C-language implementation of SQL functions and aggregates uses
4472 ** this set of interface routines to access the parameter values on
4473 ** the function or aggregate.
4474 **
@@ -4508,25 +4541,26 @@
4508 ** or [sqlite3_value_text16()].
4509 **
4510 ** These routines must be called from the same thread as
4511 ** the SQL function that supplied the [sqlite3_value*] parameters.
4512 */
4513 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4514 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4515 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4516 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4517 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4518 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4519 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4520 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4521 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4522 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4523 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4524 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4525
4526 /*
4527 ** CAPI3REF: Obtain Aggregate Function Context
 
4528 **
4529 ** Implementations of aggregate SQL functions use this
4530 ** routine to allocate memory for storing their state.
4531 **
4532 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4563,14 +4597,15 @@
4563 ** function.
4564 **
4565 ** This routine must be called from the same thread in which
4566 ** the aggregate SQL function is running.
4567 */
4568 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4569
4570 /*
4571 ** CAPI3REF: User Data For Functions
 
4572 **
4573 ** ^The sqlite3_user_data() interface returns a copy of
4574 ** the pointer that was the pUserData parameter (the 5th parameter)
4575 ** of the [sqlite3_create_function()]
4576 ** and [sqlite3_create_function16()] routines that originally
@@ -4577,25 +4612,27 @@
4577 ** registered the application defined function.
4578 **
4579 ** This routine must be called from the same thread in which
4580 ** the application-defined function is running.
4581 */
4582 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4583
4584 /*
4585 ** CAPI3REF: Database Connection For Functions
 
4586 **
4587 ** ^The sqlite3_context_db_handle() interface returns a copy of
4588 ** the pointer to the [database connection] (the 1st parameter)
4589 ** of the [sqlite3_create_function()]
4590 ** and [sqlite3_create_function16()] routines that originally
4591 ** registered the application defined function.
4592 */
4593 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4594
4595 /*
4596 ** CAPI3REF: Function Auxiliary Data
 
4597 **
4598 ** These functions may be used by (non-aggregate) SQL functions to
4599 ** associate metadata with argument values. If the same value is passed to
4600 ** multiple invocations of the same SQL function during query execution, under
4601 ** some circumstances the associated metadata may be preserved. An example
@@ -4640,12 +4677,12 @@
4640 ** values and [parameters] and expressions composed from the same.)^
4641 **
4642 ** These routines must be called from the same thread in which
4643 ** the SQL function is running.
4644 */
4645 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4646 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4647
4648
4649 /*
4650 ** CAPI3REF: Constants Defining Special Destructor Behavior
4651 **
@@ -4664,10 +4701,11 @@
4664 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4665 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4666
4667 /*
4668 ** CAPI3REF: Setting The Result Of An SQL Function
 
4669 **
4670 ** These routines are used by the xFunc or xFinal callbacks that
4671 ** implement SQL functions and aggregates. See
4672 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4673 ** for additional information.
@@ -4776,33 +4814,34 @@
4776 **
4777 ** If these routines are called from within the different thread
4778 ** than the one containing the application-defined function that received
4779 ** the [sqlite3_context] pointer, the results are undefined.
4780 */
4781 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4782 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4783 sqlite3_uint64,void(*)(void*));
4784 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4785 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4786 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4787 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4788 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4789 SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4790 SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4791 SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4792 SQLITE_API void sqlite3_result_null(sqlite3_context*);
4793 SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4794 SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4795 void(*)(void*), unsigned char encoding);
4796 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4797 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4798 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4799 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4800 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4801
4802 /*
4803 ** CAPI3REF: Define New Collating Sequences
 
4804 **
4805 ** ^These functions add, remove, or modify a [collation] associated
4806 ** with the [database connection] specified as the first argument.
4807 **
4808 ** ^The name of the collation is a UTF-8 string
@@ -4876,35 +4915,36 @@
4876 ** is unfortunate but cannot be changed without breaking backwards
4877 ** compatibility.
4878 **
4879 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4880 */
4881 SQLITE_API int sqlite3_create_collation(
4882 sqlite3*,
4883 const char *zName,
4884 int eTextRep,
4885 void *pArg,
4886 int(*xCompare)(void*,int,const void*,int,const void*)
4887 );
4888 SQLITE_API int sqlite3_create_collation_v2(
4889 sqlite3*,
4890 const char *zName,
4891 int eTextRep,
4892 void *pArg,
4893 int(*xCompare)(void*,int,const void*,int,const void*),
4894 void(*xDestroy)(void*)
4895 );
4896 SQLITE_API int sqlite3_create_collation16(
4897 sqlite3*,
4898 const void *zName,
4899 int eTextRep,
4900 void *pArg,
4901 int(*xCompare)(void*,int,const void*,int,const void*)
4902 );
4903
4904 /*
4905 ** CAPI3REF: Collation Needed Callbacks
 
4906 **
4907 ** ^To avoid having to register all collation sequences before a database
4908 ** can be used, a single callback function may be registered with the
4909 ** [database connection] to be invoked whenever an undefined collation
4910 ** sequence is required.
@@ -4925,16 +4965,16 @@
4925 **
4926 ** The callback function should register the desired collation using
4927 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4928 ** [sqlite3_create_collation_v2()].
4929 */
4930 SQLITE_API int sqlite3_collation_needed(
4931 sqlite3*,
4932 void*,
4933 void(*)(void*,sqlite3*,int eTextRep,const char*)
4934 );
4935 SQLITE_API int sqlite3_collation_needed16(
4936 sqlite3*,
4937 void*,
4938 void(*)(void*,sqlite3*,int eTextRep,const void*)
4939 );
4940
@@ -4944,15 +4984,15 @@
4944 ** called right after sqlite3_open().
4945 **
4946 ** The code to implement this API is not available in the public release
4947 ** of SQLite.
4948 */
4949 SQLITE_API int sqlite3_key(
4950 sqlite3 *db, /* Database to be rekeyed */
4951 const void *pKey, int nKey /* The key */
4952 );
4953 SQLITE_API int sqlite3_key_v2(
4954 sqlite3 *db, /* Database to be rekeyed */
4955 const char *zDbName, /* Name of the database */
4956 const void *pKey, int nKey /* The key */
4957 );
4958
@@ -4962,35 +5002,35 @@
4962 ** database is decrypted.
4963 **
4964 ** The code to implement this API is not available in the public release
4965 ** of SQLite.
4966 */
4967 SQLITE_API int sqlite3_rekey(
4968 sqlite3 *db, /* Database to be rekeyed */
4969 const void *pKey, int nKey /* The new key */
4970 );
4971 SQLITE_API int sqlite3_rekey_v2(
4972 sqlite3 *db, /* Database to be rekeyed */
4973 const char *zDbName, /* Name of the database */
4974 const void *pKey, int nKey /* The new key */
4975 );
4976
4977 /*
4978 ** Specify the activation key for a SEE database. Unless
4979 ** activated, none of the SEE routines will work.
4980 */
4981 SQLITE_API void sqlite3_activate_see(
4982 const char *zPassPhrase /* Activation phrase */
4983 );
4984 #endif
4985
4986 #ifdef SQLITE_ENABLE_CEROD
4987 /*
4988 ** Specify the activation key for a CEROD database. Unless
4989 ** activated, none of the CEROD routines will work.
4990 */
4991 SQLITE_API void sqlite3_activate_cerod(
4992 const char *zPassPhrase /* Activation phrase */
4993 );
4994 #endif
4995
4996 /*
@@ -5008,11 +5048,11 @@
5008 ** method of the default [sqlite3_vfs] object. If the xSleep() method
5009 ** of the default VFS is not implemented correctly, or not implemented at
5010 ** all, then the behavior of sqlite3_sleep() may deviate from the description
5011 ** in the previous paragraphs.
5012 */
5013 SQLITE_API int sqlite3_sleep(int);
5014
5015 /*
5016 ** CAPI3REF: Name Of The Folder Holding Temporary Files
5017 **
5018 ** ^(If this global variable is made to point to a string which is
@@ -5108,10 +5148,11 @@
5108 SQLITE_API char *sqlite3_data_directory;
5109
5110 /*
5111 ** CAPI3REF: Test For Auto-Commit Mode
5112 ** KEYWORDS: {autocommit mode}
 
5113 **
5114 ** ^The sqlite3_get_autocommit() interface returns non-zero or
5115 ** zero if the given database connection is or is not in autocommit mode,
5116 ** respectively. ^Autocommit mode is on by default.
5117 ** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -5126,26 +5167,28 @@
5126 **
5127 ** If another thread changes the autocommit status of the database
5128 ** connection while this routine is running, then the return value
5129 ** is undefined.
5130 */
5131 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
5132
5133 /*
5134 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
 
5135 **
5136 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5137 ** to which a [prepared statement] belongs. ^The [database connection]
5138 ** returned by sqlite3_db_handle is the same [database connection]
5139 ** that was the first argument
5140 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5141 ** create the statement in the first place.
5142 */
5143 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
5144
5145 /*
5146 ** CAPI3REF: Return The Filename For A Database Connection
 
5147 **
5148 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
5149 ** associated with database N of connection D. ^The main database file
5150 ** has the name "main". If there is no attached database N on the database
5151 ** connection D, or if database N is a temporary or in-memory database, then
@@ -5154,23 +5197,25 @@
5154 ** ^The filename returned by this function is the output of the
5155 ** xFullPathname method of the [VFS]. ^In other words, the filename
5156 ** will be an absolute pathname, even if the filename used
5157 ** to open the database originally was a URI or relative pathname.
5158 */
5159 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5160
5161 /*
5162 ** CAPI3REF: Determine if a database is read-only
 
5163 **
5164 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5165 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
5166 ** the name of a database on connection D.
5167 */
5168 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5169
5170 /*
5171 ** CAPI3REF: Find the next prepared statement
 
5172 **
5173 ** ^This interface returns a pointer to the next [prepared statement] after
5174 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
5175 ** then this interface returns a pointer to the first prepared statement
5176 ** associated with the database connection pDb. ^If no prepared statement
@@ -5178,14 +5223,15 @@
5178 **
5179 ** The [database connection] pointer D in a call to
5180 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5181 ** connection and in particular must not be a NULL pointer.
5182 */
5183 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5184
5185 /*
5186 ** CAPI3REF: Commit And Rollback Notification Callbacks
 
5187 **
5188 ** ^The sqlite3_commit_hook() interface registers a callback
5189 ** function to be invoked whenever a transaction is [COMMIT | committed].
5190 ** ^Any callback set by a previous call to sqlite3_commit_hook()
5191 ** for the same database connection is overridden.
@@ -5226,15 +5272,16 @@
5226 ** ^The rollback callback is not invoked if a transaction is
5227 ** automatically rolled back because the database connection is closed.
5228 **
5229 ** See also the [sqlite3_update_hook()] interface.
5230 */
5231 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5232 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5233
5234 /*
5235 ** CAPI3REF: Data Change Notification Callbacks
 
5236 **
5237 ** ^The sqlite3_update_hook() interface registers a callback function
5238 ** with the [database connection] identified by the first argument
5239 ** to be invoked whenever a row is updated, inserted or deleted in
5240 ** a rowid table.
@@ -5277,11 +5324,11 @@
5277 ** the first call on D.
5278 **
5279 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5280 ** interfaces.
5281 */
5282 SQLITE_API void *sqlite3_update_hook(
5283 sqlite3*,
5284 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5285 void*
5286 );
5287
@@ -5317,11 +5364,11 @@
5317 ** This interface is threadsafe on processors where writing a
5318 ** 32-bit integer is atomic.
5319 **
5320 ** See Also: [SQLite Shared-Cache Mode]
5321 */
5322 SQLITE_API int sqlite3_enable_shared_cache(int);
5323
5324 /*
5325 ** CAPI3REF: Attempt To Free Heap Memory
5326 **
5327 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5333,24 +5380,25 @@
5333 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5334 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5335 **
5336 ** See also: [sqlite3_db_release_memory()]
5337 */
5338 SQLITE_API int sqlite3_release_memory(int);
5339
5340 /*
5341 ** CAPI3REF: Free Memory Used By A Database Connection
 
5342 **
5343 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5344 ** memory as possible from database connection D. Unlike the
5345 ** [sqlite3_release_memory()] interface, this interface is in effect even
5346 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5347 ** omitted.
5348 **
5349 ** See also: [sqlite3_release_memory()]
5350 */
5351 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5352
5353 /*
5354 ** CAPI3REF: Impose A Limit On Heap Size
5355 **
5356 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5398,11 +5446,11 @@
5398 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5399 **
5400 ** The circumstances under which SQLite will enforce the soft heap limit may
5401 ** changes in future releases of SQLite.
5402 */
5403 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5404
5405 /*
5406 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5407 ** DEPRECATED
5408 **
@@ -5409,15 +5457,16 @@
5409 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5410 ** interface. This routine is provided for historical compatibility
5411 ** only. All new applications should use the
5412 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5413 */
5414 SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5415
5416
5417 /*
5418 ** CAPI3REF: Extract Metadata About A Column Of A Table
 
5419 **
5420 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5421 ** information about column C of table T in database D
5422 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5423 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5478,11 +5527,11 @@
5478 **
5479 ** ^This function causes all database schemas to be read from disk and
5480 ** parsed, if that has not already been done, and returns an error if
5481 ** any errors are encountered while loading the schema.
5482 */
5483 SQLITE_API int sqlite3_table_column_metadata(
5484 sqlite3 *db, /* Connection handle */
5485 const char *zDbName, /* Database name or NULL */
5486 const char *zTableName, /* Table name */
5487 const char *zColumnName, /* Column name */
5488 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5492,10 +5541,11 @@
5492 int *pAutoinc /* OUTPUT: True if column is auto-increment */
5493 );
5494
5495 /*
5496 ** CAPI3REF: Load An Extension
 
5497 **
5498 ** ^This interface loads an SQLite extension library from the named file.
5499 **
5500 ** ^The sqlite3_load_extension() interface attempts to load an
5501 ** [SQLite extension] library contained in the file zFile. If
@@ -5524,19 +5574,20 @@
5524 ** [sqlite3_enable_load_extension()] prior to calling this API,
5525 ** otherwise an error will be returned.
5526 **
5527 ** See also the [load_extension() SQL function].
5528 */
5529 SQLITE_API int sqlite3_load_extension(
5530 sqlite3 *db, /* Load the extension into this database connection */
5531 const char *zFile, /* Name of the shared library containing extension */
5532 const char *zProc, /* Entry point. Derived from zFile if 0 */
5533 char **pzErrMsg /* Put error message here if not 0 */
5534 );
5535
5536 /*
5537 ** CAPI3REF: Enable Or Disable Extension Loading
 
5538 **
5539 ** ^So as not to open security holes in older applications that are
5540 ** unprepared to deal with [extension loading], and as a means of disabling
5541 ** [extension loading] while evaluating user-entered SQL, the following API
5542 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5544,11 +5595,11 @@
5544 ** ^Extension loading is off by default.
5545 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5546 ** to turn extension loading on and call it with onoff==0 to turn
5547 ** it back off again.
5548 */
5549 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5550
5551 /*
5552 ** CAPI3REF: Automatically Load Statically Linked Extensions
5553 **
5554 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5582,11 +5633,11 @@
5582 ** will be called more than once for each database connection that is opened.
5583 **
5584 ** See also: [sqlite3_reset_auto_extension()]
5585 ** and [sqlite3_cancel_auto_extension()]
5586 */
5587 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5588
5589 /*
5590 ** CAPI3REF: Cancel Automatic Extension Loading
5591 **
5592 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5594,19 +5645,19 @@
5594 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5595 ** routine returns 1 if initialization routine X was successfully
5596 ** unregistered and it returns 0 if X was not on the list of initialization
5597 ** routines.
5598 */
5599 SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5600
5601 /*
5602 ** CAPI3REF: Reset Automatic Extension Loading
5603 **
5604 ** ^This interface disables all automatic extensions previously
5605 ** registered using [sqlite3_auto_extension()].
5606 */
5607 SQLITE_API void sqlite3_reset_auto_extension(void);
5608
5609 /*
5610 ** The interface to the virtual-table mechanism is currently considered
5611 ** to be experimental. The interface might change in incompatible ways.
5612 ** If this is a problem for you, do not use the interface at this time.
@@ -5782,10 +5833,11 @@
5782 #define SQLITE_INDEX_CONSTRAINT_GE 32
5783 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
5784
5785 /*
5786 ** CAPI3REF: Register A Virtual Table Implementation
 
5787 **
5788 ** ^These routines are used to register a new [virtual table module] name.
5789 ** ^Module names must be registered before
5790 ** creating a new [virtual table] using the module and before using a
5791 ** preexisting [virtual table] for the module.
@@ -5805,17 +5857,17 @@
5805 ** be invoked if the call to sqlite3_create_module_v2() fails.
5806 ** ^The sqlite3_create_module()
5807 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5808 ** destructor.
5809 */
5810 SQLITE_API int sqlite3_create_module(
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 );
5816 SQLITE_API int sqlite3_create_module_v2(
5817 sqlite3 *db, /* SQLite connection to register module with */
5818 const char *zName, /* Name of the module */
5819 const sqlite3_module *p, /* Methods for the module */
5820 void *pClientData, /* Client data for xCreate/xConnect */
5821 void(*xDestroy)(void*) /* Module destructor function */
@@ -5874,14 +5926,15 @@
5874 ** ^The [xCreate] and [xConnect] methods of a
5875 ** [virtual table module] call this interface
5876 ** to declare the format (the names and datatypes of the columns) of
5877 ** the virtual tables they implement.
5878 */
5879 SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5880
5881 /*
5882 ** CAPI3REF: Overload A Function For A Virtual Table
 
5883 **
5884 ** ^(Virtual tables can provide alternative implementations of functions
5885 ** using the [xFindFunction] method of the [virtual table module].
5886 ** But global versions of those functions
5887 ** must exist in order to be overloaded.)^
@@ -5892,11 +5945,11 @@
5892 ** of the new function always causes an exception to be thrown. So
5893 ** the new function is not good for anything by itself. Its only
5894 ** purpose is to be a placeholder function that can be overloaded
5895 ** by a [virtual table].
5896 */
5897 SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5898
5899 /*
5900 ** The interface to the virtual-table mechanism defined above (back up
5901 ** to a comment remarkably similar to this one) is currently considered
5902 ** to be experimental. The interface might change in incompatible ways.
@@ -5920,10 +5973,12 @@
5920 */
5921 typedef struct sqlite3_blob sqlite3_blob;
5922
5923 /*
5924 ** CAPI3REF: Open A BLOB For Incremental I/O
 
 
5925 **
5926 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
5927 ** in row iRow, column zColumn, table zTable in database zDb;
5928 ** in other words, the same BLOB that would be selected by:
5929 **
@@ -5989,11 +6044,11 @@
5989 ** zero-filled blob to read or write using the incremental-blob interface.
5990 **
5991 ** To avoid a resource leak, every open [BLOB handle] should eventually
5992 ** be released by a call to [sqlite3_blob_close()].
5993 */
5994 SQLITE_API int sqlite3_blob_open(
5995 sqlite3*,
5996 const char *zDb,
5997 const char *zTable,
5998 const char *zColumn,
5999 sqlite3_int64 iRow,
@@ -6001,10 +6056,11 @@
6001 sqlite3_blob **ppBlob
6002 );
6003
6004 /*
6005 ** CAPI3REF: Move a BLOB Handle to a New Row
 
6006 **
6007 ** ^This function is used to move an existing blob handle so that it points
6008 ** to a different row of the same database table. ^The new row is identified
6009 ** by the rowid value passed as the second argument. Only the row can be
6010 ** changed. ^The database, table and column on which the blob handle is open
@@ -6021,14 +6077,15 @@
6021 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
6022 ** always returns zero.
6023 **
6024 ** ^This function sets the database handle error code and message.
6025 */
6026 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6027
6028 /*
6029 ** CAPI3REF: Close A BLOB Handle
 
6030 **
6031 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
6032 ** unconditionally. Even if this routine returns an error code, the
6033 ** handle is still closed.)^
6034 **
@@ -6043,14 +6100,15 @@
6043 ** with a null pointer (such as would be returned by a failed call to
6044 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
6045 ** is passed a valid open blob handle, the values returned by the
6046 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
6047 */
6048 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
6049
6050 /*
6051 ** CAPI3REF: Return The Size Of An Open BLOB
 
6052 **
6053 ** ^Returns the size in bytes of the BLOB accessible via the
6054 ** successfully opened [BLOB handle] in its only argument. ^The
6055 ** incremental blob I/O routines can only read or overwriting existing
6056 ** blob content; they cannot change the size of a blob.
@@ -6058,14 +6116,15 @@
6058 ** This routine only works on a [BLOB handle] which has been created
6059 ** by a prior successful call to [sqlite3_blob_open()] and which has not
6060 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6061 ** to this routine results in undefined and probably undesirable behavior.
6062 */
6063 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
6064
6065 /*
6066 ** CAPI3REF: Read Data From A BLOB Incrementally
 
6067 **
6068 ** ^(This function is used to read data from an open [BLOB handle] into a
6069 ** caller-supplied buffer. N bytes of data are copied into buffer Z
6070 ** from the open BLOB, starting at offset iOffset.)^
6071 **
@@ -6086,14 +6145,15 @@
6086 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6087 ** to this routine results in undefined and probably undesirable behavior.
6088 **
6089 ** See also: [sqlite3_blob_write()].
6090 */
6091 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6092
6093 /*
6094 ** CAPI3REF: Write Data Into A BLOB Incrementally
 
6095 **
6096 ** ^(This function is used to write data into an open [BLOB handle] from a
6097 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
6098 ** into the open BLOB, starting at offset iOffset.)^
6099 **
@@ -6127,11 +6187,11 @@
6127 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6128 ** to this routine results in undefined and probably undesirable behavior.
6129 **
6130 ** See also: [sqlite3_blob_read()].
6131 */
6132 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6133
6134 /*
6135 ** CAPI3REF: Virtual File System Objects
6136 **
6137 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6158,13 +6218,13 @@
6158 **
6159 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
6160 ** ^(If the default VFS is unregistered, another VFS is chosen as
6161 ** the default. The choice for the new VFS is arbitrary.)^
6162 */
6163 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
6164 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6165 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
6166
6167 /*
6168 ** CAPI3REF: Mutexes
6169 **
6170 ** The SQLite core uses these routines for thread
@@ -6273,15 +6333,15 @@
6273 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6274 ** behave as no-ops.
6275 **
6276 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6277 */
6278 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6279 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6280 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6281 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6282 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6283
6284 /*
6285 ** CAPI3REF: Mutex Methods Object
6286 **
6287 ** An instance of this structure defines the low-level routines
@@ -6387,12 +6447,12 @@
6387 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6388 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6389 ** interface should also return 1 when given a NULL pointer.
6390 */
6391 #ifndef NDEBUG
6392 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6393 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6394 #endif
6395
6396 /*
6397 ** CAPI3REF: Mutex Types
6398 **
@@ -6417,21 +6477,23 @@
6417 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6418 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6419
6420 /*
6421 ** CAPI3REF: Retrieve the mutex for a database connection
 
6422 **
6423 ** ^This interface returns a pointer the [sqlite3_mutex] object that
6424 ** serializes access to the [database connection] given in the argument
6425 ** when the [threading mode] is Serialized.
6426 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6427 ** routine returns a NULL pointer.
6428 */
6429 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6430
6431 /*
6432 ** CAPI3REF: Low-Level Control Of Database Files
 
6433 **
6434 ** ^The [sqlite3_file_control()] interface makes a direct call to the
6435 ** xFileControl method for the [sqlite3_io_methods] object associated
6436 ** with a particular database identified by the second argument. ^The
6437 ** name of the database is "main" for the main database or "temp" for the
@@ -6458,11 +6520,11 @@
6458 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6459 ** xFileControl method.
6460 **
6461 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6462 */
6463 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6464
6465 /*
6466 ** CAPI3REF: Testing Interface
6467 **
6468 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6477,11 +6539,11 @@
6477 ** The details of the operation codes, their meanings, the parameters
6478 ** they take, and what they do are all subject to change without notice.
6479 ** Unlike most of the SQLite API, this function is not guaranteed to
6480 ** operate consistently from one release to the next.
6481 */
6482 SQLITE_API int sqlite3_test_control(int op, ...);
6483
6484 /*
6485 ** CAPI3REF: Testing Interface Operation Codes
6486 **
6487 ** These constants are the valid operation code parameters used
@@ -6540,12 +6602,12 @@
6540 ** be represented by a 32-bit integer, then the values returned by
6541 ** sqlite3_status() are undefined.
6542 **
6543 ** See also: [sqlite3_db_status()]
6544 */
6545 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6546 SQLITE_API int sqlite3_status64(
6547 int op,
6548 sqlite3_int64 *pCurrent,
6549 sqlite3_int64 *pHighwater,
6550 int resetFlag
6551 );
@@ -6644,10 +6706,11 @@
6644 #define SQLITE_STATUS_SCRATCH_SIZE 8
6645 #define SQLITE_STATUS_MALLOC_COUNT 9
6646
6647 /*
6648 ** CAPI3REF: Database Connection Status
 
6649 **
6650 ** ^This interface is used to retrieve runtime status information
6651 ** about a single [database connection]. ^The first argument is the
6652 ** database connection object to be interrogated. ^The second argument
6653 ** is an integer constant, taken from the set of
@@ -6664,11 +6727,11 @@
6664 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6665 ** non-zero [error code] on failure.
6666 **
6667 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6668 */
6669 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6670
6671 /*
6672 ** CAPI3REF: Status Parameters for database connections
6673 ** KEYWORDS: {SQLITE_DBSTATUS options}
6674 **
@@ -6772,10 +6835,11 @@
6772 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6773
6774
6775 /*
6776 ** CAPI3REF: Prepared Statement Status
 
6777 **
6778 ** ^(Each prepared statement maintains various
6779 ** [SQLITE_STMTSTATUS counters] that measure the number
6780 ** of times it has performed specific operations.)^ These counters can
6781 ** be used to monitor the performance characteristics of the prepared
@@ -6793,11 +6857,11 @@
6793 ** ^If the resetFlg is true, then the counter is reset to zero after this
6794 ** interface call returns.
6795 **
6796 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6797 */
6798 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6799
6800 /*
6801 ** CAPI3REF: Status Parameters for prepared statements
6802 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6803 **
@@ -7262,23 +7326,24 @@
7262 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7263 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7264 ** same time as another thread is invoking sqlite3_backup_step() it is
7265 ** possible that they return invalid values.
7266 */
7267 SQLITE_API sqlite3_backup *sqlite3_backup_init(
7268 sqlite3 *pDest, /* Destination database handle */
7269 const char *zDestName, /* Destination database name */
7270 sqlite3 *pSource, /* Source database handle */
7271 const char *zSourceName /* Source database name */
7272 );
7273 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7274 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7275 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7276 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7277
7278 /*
7279 ** CAPI3REF: Unlock Notification
 
7280 **
7281 ** ^When running in shared-cache mode, a database operation may fail with
7282 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
7283 ** individual tables within the shared-cache cannot be obtained. See
7284 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7387,11 +7452,11 @@
7387 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7388 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7389 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7390 ** SQLITE_LOCKED.)^
7391 */
7392 SQLITE_API int sqlite3_unlock_notify(
7393 sqlite3 *pBlocked, /* Waiting connection */
7394 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7395 void *pNotifyArg /* Argument to pass to xNotify */
7396 );
7397
@@ -7402,12 +7467,12 @@
7402 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7403 ** and extensions to compare the contents of two buffers containing UTF-8
7404 ** strings in a case-independent fashion, using the same definition of "case
7405 ** independence" that SQLite uses internally when comparing identifiers.
7406 */
7407 SQLITE_API int sqlite3_stricmp(const char *, const char *);
7408 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7409
7410 /*
7411 ** CAPI3REF: String Globbing
7412 *
7413 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7418,11 +7483,11 @@
7418 ** sensitive.
7419 **
7420 ** Note that this routine returns zero on a match and non-zero if the strings
7421 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7422 */
7423 SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7424
7425 /*
7426 ** CAPI3REF: Error Logging Interface
7427 **
7428 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7441,14 +7506,15 @@
7441 ** will not use dynamically allocated memory. The log message is stored in
7442 ** a fixed-length buffer on the stack. If the log message is longer than
7443 ** a few hundred characters, it will be truncated to the length of the
7444 ** buffer.
7445 */
7446 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7447
7448 /*
7449 ** CAPI3REF: Write-Ahead Log Commit Hook
 
7450 **
7451 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
7452 ** is invoked each time data is committed to a database in wal mode.
7453 **
7454 ** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7476,18 +7542,19 @@
7476 ** previously registered write-ahead log callback. ^Note that the
7477 ** [sqlite3_wal_autocheckpoint()] interface and the
7478 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7479 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7480 */
7481 SQLITE_API void *sqlite3_wal_hook(
7482 sqlite3*,
7483 int(*)(void *,sqlite3*,const char*,int),
7484 void*
7485 );
7486
7487 /*
7488 ** CAPI3REF: Configure an auto-checkpoint
 
7489 **
7490 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
7491 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7492 ** to automatically [checkpoint]
7493 ** after committing a transaction if there are N or
@@ -7510,14 +7577,15 @@
7510 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7511 ** pages. The use of this interface
7512 ** is only necessary if the default setting is found to be suboptimal
7513 ** for a particular application.
7514 */
7515 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7516
7517 /*
7518 ** CAPI3REF: Checkpoint a database
 
7519 **
7520 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
7521 ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
7522 **
7523 ** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7531,14 +7599,15 @@
7531 ** interface was added. This interface is retained for backwards
7532 ** compatibility and as a convenience for applications that need to manually
7533 ** start a callback but which do not need the full power (and corresponding
7534 ** complication) of [sqlite3_wal_checkpoint_v2()].
7535 */
7536 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7537
7538 /*
7539 ** CAPI3REF: Checkpoint a database
 
7540 **
7541 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
7542 ** operation on database X of [database connection] D in mode M. Status
7543 ** information is written back into integers pointed to by L and C.)^
7544 ** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7624,11 +7693,11 @@
7624 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7625 **
7626 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7627 ** from SQL.
7628 */
7629 SQLITE_API int sqlite3_wal_checkpoint_v2(
7630 sqlite3 *db, /* Database handle */
7631 const char *zDb, /* Name of attached database (or NULL) */
7632 int eMode, /* SQLITE_CHECKPOINT_* value */
7633 int *pnLog, /* OUT: Size of WAL log in frames */
7634 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7660,11 +7729,11 @@
7660 **
7661 ** At present, there is only one option that may be configured using
7662 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7663 ** may be added in the future.
7664 */
7665 SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7666
7667 /*
7668 ** CAPI3REF: Virtual Table Configuration Options
7669 **
7670 ** These macros define the various options to the
@@ -7713,11 +7782,11 @@
7713 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7714 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7715 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7716 ** [virtual table].
7717 */
7718 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7719
7720 /*
7721 ** CAPI3REF: Conflict resolution modes
7722 ** KEYWORDS: {conflict resolution mode}
7723 **
@@ -7789,10 +7858,11 @@
7789 #define SQLITE_SCANSTAT_EXPLAIN 4
7790 #define SQLITE_SCANSTAT_SELECTID 5
7791
7792 /*
7793 ** CAPI3REF: Prepared Statement Scan Status
 
7794 **
7795 ** This interface returns information about the predicted and measured
7796 ** performance for pStmt. Advanced applications can use this
7797 ** interface to compare the predicted and the measured performance and
7798 ** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7817,26 +7887,27 @@
7817 ** as if the loop did not exist - it returns non-zero and leave the variable
7818 ** that pOut points to unchanged.
7819 **
7820 ** See also: [sqlite3_stmt_scanstatus_reset()]
7821 */
7822 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7823 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7824 int idx, /* Index of loop to report on */
7825 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7826 void *pOut /* Result written here */
7827 );
7828
7829 /*
7830 ** CAPI3REF: Zero Scan-Status Counters
 
7831 **
7832 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7833 **
7834 ** This API is only available if the library is built with pre-processor
7835 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7836 */
7837 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7838
7839
7840 /*
7841 ** Undo the hack that converts floating point types to integer for
7842 ** builds on processors without floating point support.
@@ -7887,11 +7958,11 @@
7887 ** Register a geometry callback named zGeom that can be used as part of an
7888 ** R-Tree geometry query as follows:
7889 **
7890 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7891 */
7892 SQLITE_API int sqlite3_rtree_geometry_callback(
7893 sqlite3 *db,
7894 const char *zGeom,
7895 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7896 void *pContext
7897 );
@@ -7913,11 +7984,11 @@
7913 ** Register a 2nd-generation geometry callback named zScore that can be
7914 ** used as part of an R-Tree geometry query as follows:
7915 **
7916 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7917 */
7918 SQLITE_API int sqlite3_rtree_query_callback(
7919 sqlite3 *db,
7920 const char *zQueryFunc,
7921 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7922 void *pContext,
7923 void (*xDestructor)(void*)
@@ -8436,10 +8507,36 @@
8436 #else
8437 # define ALWAYS(X) (X)
8438 # define NEVER(X) (X)
8439 #endif
8440
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8441 /*
8442 ** Return true (non-zero) if the input is an integer that is too large
8443 ** to fit in 32-bits. This macro is used inside of various testcase()
8444 ** macros to verify that we have tested SQLite for large-file support.
8445 */
@@ -9157,12 +9254,12 @@
9157 */
9158 #ifdef SQLITE_OMIT_WSD
9159 #define SQLITE_WSD const
9160 #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
9161 #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9162 SQLITE_API int sqlite3_wsd_init(int N, int J);
9163 SQLITE_API void *sqlite3_wsd_find(void *K, int L);
9164 #else
9165 #define SQLITE_WSD
9166 #define GLOBAL(t,v) v
9167 #define sqlite3GlobalConfig sqlite3Config
9168 #endif
@@ -9847,37 +9944,36 @@
9847 /* Properties such as "out2" or "jump" that are specified in
9848 ** comments following the "case" for each opcode in the vdbe.c
9849 ** are encoded into bitvectors as follows:
9850 */
9851 #define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */
9852 #define OPFLG_OUT2_PRERELEASE 0x0002 /* out2-prerelease: */
9853 #define OPFLG_IN1 0x0004 /* in1: P1 is an input */
9854 #define OPFLG_IN2 0x0008 /* in2: P2 is an input */
9855 #define OPFLG_IN3 0x0010 /* in3: P3 is an input */
9856 #define OPFLG_OUT2 0x0020 /* out2: P2 is an output */
9857 #define OPFLG_OUT3 0x0040 /* out3: P3 is an output */
9858 #define OPFLG_INITIALIZER {\
9859 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9860 /* 8 */ 0x01, 0x01, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00,\
9861 /* 16 */ 0x01, 0x01, 0x04, 0x24, 0x01, 0x04, 0x05, 0x10,\
9862 /* 24 */ 0x00, 0x02, 0x02, 0x02, 0x02, 0x00, 0x02, 0x02,\
9863 /* 32 */ 0x00, 0x00, 0x20, 0x00, 0x00, 0x04, 0x05, 0x04,\
9864 /* 40 */ 0x04, 0x00, 0x00, 0x01, 0x01, 0x05, 0x05, 0x00,\
9865 /* 48 */ 0x00, 0x00, 0x02, 0x02, 0x10, 0x00, 0x00, 0x00,\
9866 /* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x11,\
9867 /* 64 */ 0x11, 0x11, 0x08, 0x11, 0x11, 0x11, 0x11, 0x4c,\
9868 /* 72 */ 0x4c, 0x02, 0x02, 0x00, 0x05, 0x05, 0x15, 0x15,\
9869 /* 80 */ 0x15, 0x15, 0x15, 0x15, 0x00, 0x4c, 0x4c, 0x4c,\
9870 /* 88 */ 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x4c, 0x00,\
9871 /* 96 */ 0x24, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02,\
9872 /* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x08, 0x08, 0x00,\
9873 /* 112 */ 0x02, 0x01, 0x01, 0x01, 0x01, 0x02, 0x00, 0x00,\
9874 /* 120 */ 0x02, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9875 /* 128 */ 0x0c, 0x45, 0x15, 0x01, 0x02, 0x02, 0x00, 0x01,\
9876 /* 136 */ 0x08, 0x05, 0x05, 0x05, 0x05, 0x05, 0x00, 0x01,\
9877 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
9878 /* 152 */ 0x00, 0x02, 0x02, 0x01, 0x00, 0x00,}
9879
9880 /************** End of opcodes.h *********************************************/
9881 /************** Continuing where we left off in vdbe.h ***********************/
9882
9883 /*
@@ -9932,10 +10028,11 @@
9932 #endif
9933 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
9934
9935 SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
9936 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
 
9937 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
9938
9939 typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
9940 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
9941
@@ -11069,10 +11166,11 @@
11069 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
11070 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
11071 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
11072 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
11073 #define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
 
11074
11075
11076 /*
11077 ** Bits of the sqlite3.dbOptFlags field that are used by the
11078 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -11399,38 +11497,12 @@
11399 int iSavepoint; /* Depth of the SAVEPOINT stack */
11400 VTable *pNext; /* Next in linked list (see above) */
11401 };
11402
11403 /*
11404 ** Each SQL table is represented in memory by an instance of the
11405 ** following structure.
11406 **
11407 ** Table.zName is the name of the table. The case of the original
11408 ** CREATE TABLE statement is stored, but case is not significant for
11409 ** comparisons.
11410 **
11411 ** Table.nCol is the number of columns in this table. Table.aCol is a
11412 ** pointer to an array of Column structures, one for each column.
11413 **
11414 ** If the table has an INTEGER PRIMARY KEY, then Table.iPKey is the index of
11415 ** the column that is that key. Otherwise Table.iPKey is negative. Note
11416 ** that the datatype of the PRIMARY KEY must be INTEGER for this field to
11417 ** be set. An INTEGER PRIMARY KEY is used as the rowid for each row of
11418 ** the table. If a table has no INTEGER PRIMARY KEY, then a random rowid
11419 ** is generated for each row of the table. TF_HasPrimaryKey is set if
11420 ** the table has any PRIMARY KEY, INTEGER or otherwise.
11421 **
11422 ** Table.tnum is the page number for the root BTree page of the table in the
11423 ** database file. If Table.iDb is the index of the database table backend
11424 ** in sqlite.aDb[]. 0 is for the main database and 1 is for the file that
11425 ** holds temporary tables and indices. If TF_Ephemeral is set
11426 ** then the table is stored in a file that is automatically deleted
11427 ** when the VDBE cursor to the table is closed. In this case Table.tnum
11428 ** refers VDBE cursor number that holds the table open, not to the root
11429 ** page number. Transient tables are used to hold the results of a
11430 ** sub-query that appears instead of a real table name in the FROM clause
11431 ** of a SELECT statement.
11432 */
11433 struct Table {
11434 char *zName; /* Name of the table or view */
11435 Column *aCol; /* Information about each column */
11436 Index *pIndex; /* List of SQL indexes on this table. */
@@ -11438,15 +11510,15 @@
11438 FKey *pFKey; /* Linked list of all foreign keys in this table */
11439 char *zColAff; /* String defining the affinity of each column */
11440 #ifndef SQLITE_OMIT_CHECK
11441 ExprList *pCheck; /* All CHECK constraints */
11442 #endif
11443 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
11444 int tnum; /* Root BTree node for this table (see note above) */
11445 i16 iPKey; /* If not negative, use aCol[iPKey] as the primary key */
11446 i16 nCol; /* Number of columns in this table */
11447 u16 nRef; /* Number of pointers to this Table */
 
11448 LogEst szTabRow; /* Estimated size of each table row in bytes */
11449 #ifdef SQLITE_ENABLE_COSTMULT
11450 LogEst costMult; /* Cost multiplier for using this table */
11451 #endif
11452 u8 tabFlags; /* Mask of TF_* values */
@@ -11464,17 +11536,24 @@
11464 Table *pNextZombie; /* Next on the Parse.pZombieTab list */
11465 };
11466
11467 /*
11468 ** Allowed values for Table.tabFlags.
 
 
 
 
 
 
11469 */
11470 #define TF_Readonly 0x01 /* Read-only system table */
11471 #define TF_Ephemeral 0x02 /* An ephemeral table */
11472 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */
11473 #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
11474 #define TF_Virtual 0x10 /* Is a virtual table */
11475 #define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */
 
11476
11477
11478 /*
11479 ** Test to see whether or not a table is a virtual table. This is
11480 ** done as a macro so that it will be optimized out when virtual
@@ -12227,15 +12306,16 @@
12227 #define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
12228 #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
12229 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
12230 #define SF_Compound 0x0040 /* Part of a compound query */
12231 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
12232 #define SF_AllValues 0x0100 /* All terms of compound are VALUES */
12233 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
12234 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
12235 #define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
12236 #define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
 
12237
12238
12239 /*
12240 ** The results of a SELECT can be distributed in several ways, as defined
12241 ** by one of the following macros. The "SRT" prefix means "SELECT Result
@@ -12610,24 +12690,24 @@
12610 *
12611 * (op == TK_INSERT)
12612 * orconf -> stores the ON CONFLICT algorithm
12613 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
12614 * this stores a pointer to the SELECT statement. Otherwise NULL.
12615 * target -> A token holding the quoted name of the table to insert into.
12616 * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
12617 * this stores values to be inserted. Otherwise NULL.
12618 * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
12619 * statement, then this stores the column-names to be
12620 * inserted into.
12621 *
12622 * (op == TK_DELETE)
12623 * target -> A token holding the quoted name of the table to delete from.
12624 * pWhere -> The WHERE clause of the DELETE statement if one is specified.
12625 * Otherwise NULL.
12626 *
12627 * (op == TK_UPDATE)
12628 * target -> A token holding the quoted name of the table to update rows of.
12629 * pWhere -> The WHERE clause of the UPDATE statement if one is specified.
12630 * Otherwise NULL.
12631 * pExprList -> A list of the columns to update and the expressions to update
12632 * them to. See sqlite3Update() documentation of "pChanges"
12633 * argument.
@@ -12635,12 +12715,12 @@
12635 */
12636 struct TriggerStep {
12637 u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
12638 u8 orconf; /* OE_Rollback etc. */
12639 Trigger *pTrig; /* The trigger that this step is a part of */
12640 Select *pSelect; /* SELECT statment or RHS of INSERT INTO .. SELECT ... */
12641 Token target; /* Target table for DELETE, UPDATE, INSERT */
12642 Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
12643 ExprList *pExprList; /* SET clause for UPDATE. */
12644 IdList *pIdList; /* Column names for INSERT */
12645 TriggerStep *pNext; /* Next in the link-list */
12646 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
@@ -12669,12 +12749,11 @@
12669 sqlite3 *db; /* Optional database for lookaside. Can be NULL */
12670 char *zBase; /* A base allocation. Not from malloc. */
12671 char *zText; /* The string collected so far */
12672 int nChar; /* Length of the string so far */
12673 int nAlloc; /* Amount of space allocated in zText */
12674 int mxAlloc; /* Maximum allowed string length */
12675 u8 useMalloc; /* 0: none, 1: sqlite3DbMalloc, 2: sqlite3_malloc */
12676 u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
12677 };
12678 #define STRACCUM_NOMEM 1
12679 #define STRACCUM_TOOBIG 2
12680
@@ -12987,11 +13066,11 @@
12987 SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
12988 SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
12989 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
12990 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
12991 SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
12992 #if defined(SQLITE_TEST) || defined(SQLITE_DEBUG)
12993 SQLITE_PRIVATE void sqlite3DebugPrintf(const char*, ...);
12994 #endif
12995 #if defined(SQLITE_TEST)
12996 SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
12997 #endif
@@ -13334,11 +13413,11 @@
13334 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
13335 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
13336 SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
13337 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
13338
13339 #if defined(SQLITE_TEST)
13340 SQLITE_PRIVATE const char *sqlite3ErrName(int);
13341 #endif
13342
13343 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
13344 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -13428,11 +13507,11 @@
13428 FuncDestructor *pDestructor
13429 );
13430 SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
13431 SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
13432
13433 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, char*, int, int);
13434 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
13435 SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
13436 SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
13437 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
13438 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
@@ -13646,11 +13725,11 @@
13646 ** print I/O tracing messages.
13647 */
13648 #ifdef SQLITE_ENABLE_IOTRACE
13649 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
13650 SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13651 void (*sqlite3IoTrace)(const char*,...);
13652 #else
13653 # define IOTRACE(A)
13654 # define sqlite3VdbeIOTraceSql(X)
13655 #endif
13656
@@ -14044,10 +14123,13 @@
14044 #if SQLITE_ENABLE_CEROD
14045 "ENABLE_CEROD",
14046 #endif
14047 #if SQLITE_ENABLE_COLUMN_METADATA
14048 "ENABLE_COLUMN_METADATA",
 
 
 
14049 #endif
14050 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
14051 "ENABLE_EXPENSIVE_ASSERT",
14052 #endif
14053 #if SQLITE_ENABLE_FTS1
@@ -14359,11 +14441,11 @@
14359 ** was used and false if not.
14360 **
14361 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
14362 ** is not required for a match.
14363 */
14364 SQLITE_API int sqlite3_compileoption_used(const char *zOptName){
14365 int i, n;
14366
14367 #if SQLITE_ENABLE_API_ARMOR
14368 if( zOptName==0 ){
14369 (void)SQLITE_MISUSE_BKPT;
@@ -14387,11 +14469,11 @@
14387
14388 /*
14389 ** Return the N-th compile-time option string. If N is out of range,
14390 ** return a NULL pointer.
14391 */
14392 SQLITE_API const char *sqlite3_compileoption_get(int N){
14393 if( N>=0 && N<ArraySize(azCompileOpt) ){
14394 return azCompileOpt[N];
14395 }
14396 return 0;
14397 }
@@ -15024,11 +15106,11 @@
15024 }
15025
15026 /*
15027 ** Query status information.
15028 */
15029 SQLITE_API int sqlite3_status64(
15030 int op,
15031 sqlite3_int64 *pCurrent,
15032 sqlite3_int64 *pHighwater,
15033 int resetFlag
15034 ){
@@ -15049,11 +15131,11 @@
15049 }
15050 sqlite3_mutex_leave(pMutex);
15051 (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
15052 return SQLITE_OK;
15053 }
15054 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15055 sqlite3_int64 iCur, iHwtr;
15056 int rc;
15057 #ifdef SQLITE_ENABLE_API_ARMOR
15058 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
15059 #endif
@@ -15066,11 +15148,11 @@
15066 }
15067
15068 /*
15069 ** Query status information for a single database connection
15070 */
15071 SQLITE_API int sqlite3_db_status(
15072 sqlite3 *db, /* The database connection whose status is desired */
15073 int op, /* Status verb */
15074 int *pCurrent, /* Write current value here */
15075 int *pHighwater, /* Write high-water mark here */
15076 int resetFlag /* Reset high-water mark if true */
@@ -16690,11 +16772,11 @@
16690
16691 /*
16692 ** Locate a VFS by name. If no name is given, simply return the
16693 ** first VFS on the list.
16694 */
16695 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfs){
16696 sqlite3_vfs *pVfs = 0;
16697 #if SQLITE_THREADSAFE
16698 sqlite3_mutex *mutex;
16699 #endif
16700 #ifndef SQLITE_OMIT_AUTOINIT
@@ -16736,11 +16818,11 @@
16736 /*
16737 ** Register a VFS with the system. It is harmless to register the same
16738 ** VFS multiple times. The new VFS becomes the default if makeDflt is
16739 ** true.
16740 */
16741 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16742 MUTEX_LOGIC(sqlite3_mutex *mutex;)
16743 #ifndef SQLITE_OMIT_AUTOINIT
16744 int rc = sqlite3_initialize();
16745 if( rc ) return rc;
16746 #endif
@@ -16764,11 +16846,11 @@
16764 }
16765
16766 /*
16767 ** Unregister a VFS so that it is no longer accessible.
16768 */
16769 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16770 #if SQLITE_THREADSAFE
16771 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
16772 #endif
16773 sqlite3_mutex_enter(mutex);
16774 vfsUnlink(pVfs);
@@ -19100,11 +19182,11 @@
19100 }
19101
19102 /*
19103 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
19104 */
19105 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int id){
19106 #ifndef SQLITE_OMIT_AUTOINIT
19107 if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
19108 if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
19109 #endif
19110 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19119,31 +19201,31 @@
19119 }
19120
19121 /*
19122 ** Free a dynamic mutex.
19123 */
19124 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *p){
19125 if( p ){
19126 sqlite3GlobalConfig.mutex.xMutexFree(p);
19127 }
19128 }
19129
19130 /*
19131 ** Obtain the mutex p. If some other thread already has the mutex, block
19132 ** until it can be obtained.
19133 */
19134 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *p){
19135 if( p ){
19136 sqlite3GlobalConfig.mutex.xMutexEnter(p);
19137 }
19138 }
19139
19140 /*
19141 ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
19142 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
19143 */
19144 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *p){
19145 int rc = SQLITE_OK;
19146 if( p ){
19147 return sqlite3GlobalConfig.mutex.xMutexTry(p);
19148 }
19149 return rc;
@@ -19153,11 +19235,11 @@
19153 ** The sqlite3_mutex_leave() routine exits a mutex that was previously
19154 ** entered by the same thread. The behavior is undefined if the mutex
19155 ** is not currently entered. If a NULL pointer is passed as an argument
19156 ** this function is a no-op.
19157 */
19158 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *p){
19159 if( p ){
19160 sqlite3GlobalConfig.mutex.xMutexLeave(p);
19161 }
19162 }
19163
@@ -19164,14 +19246,14 @@
19164 #ifndef NDEBUG
19165 /*
19166 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
19167 ** intended for use inside assert() statements.
19168 */
19169 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *p){
19170 return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
19171 }
19172 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *p){
19173 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
19174 }
19175 #endif
19176
19177 #endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -19812,20 +19894,10 @@
19812 */
19813 #ifdef MEMORY_DEBUG
19814 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
19815 #endif
19816
19817 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
19818 # ifndef SQLITE_DEBUG_OS_TRACE
19819 # define SQLITE_DEBUG_OS_TRACE 0
19820 # endif
19821 int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
19822 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
19823 #else
19824 # define OSTRACE(X)
19825 #endif
19826
19827 /*
19828 ** Macros for performance tracing. Normally turned off. Only works
19829 ** on i486 hardware.
19830 */
19831 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -20163,12 +20235,12 @@
20163 ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
20164 ** "interlocked" magic used here is probably not strictly necessary.
20165 */
20166 static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
20167
20168 SQLITE_API int sqlite3_win32_is_nt(void); /* os_win.c */
20169 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20170
20171 static int winMutexInit(void){
20172 /* The first to increment to 1 does actual initialization */
20173 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
20174 int i;
@@ -20460,11 +20532,11 @@
20460 /*
20461 ** Attempt to release up to n bytes of non-essential memory currently
20462 ** held by SQLite. An example of non-essential memory is memory used to
20463 ** cache database pages that are not currently in use.
20464 */
20465 SQLITE_API int sqlite3_release_memory(int n){
20466 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20467 return sqlite3PcacheReleaseMemory(n);
20468 #else
20469 /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
20470 ** is a no-op returning zero if SQLite is not compiled with
@@ -20560,11 +20632,11 @@
20560 #ifndef SQLITE_OMIT_DEPRECATED
20561 /*
20562 ** Deprecated external interface. Internal/core SQLite code
20563 ** should call sqlite3MemoryAlarm.
20564 */
20565 SQLITE_API int sqlite3_memory_alarm(
20566 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20567 void *pArg,
20568 sqlite3_int64 iThreshold
20569 ){
20570 return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20573,11 +20645,11 @@
20573
20574 /*
20575 ** Set the soft heap-size limit for the library. Passing a zero or
20576 ** negative value indicates no limit.
20577 */
20578 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 n){
20579 sqlite3_int64 priorLimit;
20580 sqlite3_int64 excess;
20581 #ifndef SQLITE_OMIT_AUTOINIT
20582 int rc = sqlite3_initialize();
20583 if( rc ) return -1;
@@ -20593,19 +20665,20 @@
20593 }
20594 excess = sqlite3_memory_used() - n;
20595 if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
20596 return priorLimit;
20597 }
20598 SQLITE_API void sqlite3_soft_heap_limit(int n){
20599 if( n<0 ) n = 0;
20600 sqlite3_soft_heap_limit64(n);
20601 }
20602
20603 /*
20604 ** Initialize the memory allocation subsystem.
20605 */
20606 SQLITE_PRIVATE int sqlite3MallocInit(void){
 
20607 if( sqlite3GlobalConfig.m.xMalloc==0 ){
20608 sqlite3MemSetDefault();
20609 }
20610 memset(&mem0, 0, sizeof(mem0));
20611 if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20637,11 +20710,13 @@
20637 || sqlite3GlobalConfig.nPage<1 ){
20638 sqlite3GlobalConfig.pPage = 0;
20639 sqlite3GlobalConfig.szPage = 0;
20640 sqlite3GlobalConfig.nPage = 0;
20641 }
20642 return sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
 
 
20643 }
20644
20645 /*
20646 ** Return true if the heap is currently under memory pressure - in other
20647 ** words if the amount of heap used is close to the limit set by
@@ -20662,11 +20737,11 @@
20662 }
20663
20664 /*
20665 ** Return the amount of memory currently checked out.
20666 */
20667 SQLITE_API sqlite3_int64 sqlite3_memory_used(void){
20668 int n, mx;
20669 sqlite3_int64 res;
20670 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
20671 res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
20672 return res;
@@ -20675,11 +20750,11 @@
20675 /*
20676 ** Return the maximum amount of memory that has ever been
20677 ** checked out since either the beginning of this process
20678 ** or since the most recent reset.
20679 */
20680 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag){
20681 int n, mx;
20682 sqlite3_int64 res;
20683 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
20684 res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
20685 return res;
@@ -20766,17 +20841,17 @@
20766 /*
20767 ** This version of the memory allocation is for use by the application.
20768 ** First make sure the memory subsystem is initialized, then do the
20769 ** allocation.
20770 */
20771 SQLITE_API void *sqlite3_malloc(int n){
20772 #ifndef SQLITE_OMIT_AUTOINIT
20773 if( sqlite3_initialize() ) return 0;
20774 #endif
20775 return n<=0 ? 0 : sqlite3Malloc(n);
20776 }
20777 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 n){
20778 #ifndef SQLITE_OMIT_AUTOINIT
20779 if( sqlite3_initialize() ) return 0;
20780 #endif
20781 return sqlite3Malloc(n);
20782 }
@@ -20913,20 +20988,20 @@
20913 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20914 return sqlite3GlobalConfig.m.xSize(p);
20915 }
20916 }
20917 }
20918 SQLITE_API sqlite3_uint64 sqlite3_msize(void *p){
20919 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20920 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20921 return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
20922 }
20923
20924 /*
20925 ** Free memory previously obtained from sqlite3Malloc().
20926 */
20927 SQLITE_API void sqlite3_free(void *p){
20928 if( p==0 ) return; /* IMP: R-49053-54554 */
20929 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20930 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20931 if( sqlite3GlobalConfig.bMemstat ){
20932 sqlite3_mutex_enter(mem0.mutex);
@@ -21031,18 +21106,18 @@
21031
21032 /*
21033 ** The public interface to sqlite3Realloc. Make sure that the memory
21034 ** subsystem is initialized prior to invoking sqliteRealloc.
21035 */
21036 SQLITE_API void *sqlite3_realloc(void *pOld, int n){
21037 #ifndef SQLITE_OMIT_AUTOINIT
21038 if( sqlite3_initialize() ) return 0;
21039 #endif
21040 if( n<0 ) n = 0; /* IMP: R-26507-47431 */
21041 return sqlite3Realloc(pOld, n);
21042 }
21043 SQLITE_API void *sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
21044 #ifndef SQLITE_OMIT_AUTOINIT
21045 if( sqlite3_initialize() ) return 0;
21046 #endif
21047 return sqlite3Realloc(pOld, n);
21048 }
@@ -21403,10 +21478,11 @@
21403
21404 /*
21405 ** Set the StrAccum object to an error mode.
21406 */
21407 static void setStrAccumError(StrAccum *p, u8 eError){
 
21408 p->accError = eError;
21409 p->nAlloc = 0;
21410 }
21411
21412 /*
@@ -21517,45 +21593,52 @@
21517 case '0': flag_zeropad = 1; break;
21518 default: done = 1; break;
21519 }
21520 }while( !done && (c=(*++fmt))!=0 );
21521 /* Get the field width */
21522 width = 0;
21523 if( c=='*' ){
21524 if( bArgList ){
21525 width = (int)getIntArg(pArgList);
21526 }else{
21527 width = va_arg(ap,int);
21528 }
21529 if( width<0 ){
21530 flag_leftjustify = 1;
21531 width = -width;
21532 }
21533 c = *++fmt;
21534 }else{
 
21535 while( c>='0' && c<='9' ){
21536 width = width*10 + c - '0';
21537 c = *++fmt;
21538 }
 
 
21539 }
 
21540 /* Get the precision */
21541 if( c=='.' ){
21542 precision = 0;
21543 c = *++fmt;
21544 if( c=='*' ){
21545 if( bArgList ){
21546 precision = (int)getIntArg(pArgList);
21547 }else{
21548 precision = va_arg(ap,int);
21549 }
21550 if( precision<0 ) precision = -precision;
21551 c = *++fmt;
 
 
 
21552 }else{
 
21553 while( c>='0' && c<='9' ){
21554 precision = precision*10 + c - '0';
21555 c = *++fmt;
21556 }
 
 
21557 }
21558 }else{
21559 precision = -1;
21560 }
21561 /* Get the conversion type modifier */
@@ -21715,11 +21798,12 @@
21715 if( flag_plussign ) prefix = '+';
21716 else if( flag_blanksign ) prefix = ' ';
21717 else prefix = 0;
21718 }
21719 if( xtype==etGENERIC && precision>0 ) precision--;
21720 for(idx=precision, rounder=0.5; idx>0; idx--, rounder*=0.1){}
 
21721 if( xtype==etFLOAT ) realvalue += rounder;
21722 /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
21723 exp = 0;
21724 if( sqlite3IsNaN((double)realvalue) ){
21725 bufpt = "NaN";
@@ -21770,12 +21854,13 @@
21770 if( xtype==etEXP ){
21771 e2 = 0;
21772 }else{
21773 e2 = exp;
21774 }
21775 if( MAX(e2,0)+precision+width > etBUFSIZE - 15 ){
21776 bufpt = zExtra = sqlite3Malloc( MAX(e2,0)+precision+width+15 );
 
21777 if( bufpt==0 ){
21778 setStrAccumError(pAccum, STRACCUM_NOMEM);
21779 return;
21780 }
21781 }
@@ -22003,17 +22088,17 @@
22003 ** Return the number of bytes of text that StrAccum is able to accept
22004 ** after the attempted enlargement. The value returned might be zero.
22005 */
22006 static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
22007 char *zNew;
22008 assert( p->nChar+N >= p->nAlloc ); /* Only called if really needed */
22009 if( p->accError ){
22010 testcase(p->accError==STRACCUM_TOOBIG);
22011 testcase(p->accError==STRACCUM_NOMEM);
22012 return 0;
22013 }
22014 if( !p->useMalloc ){
22015 N = p->nAlloc - p->nChar - 1;
22016 setStrAccumError(p, STRACCUM_TOOBIG);
22017 return N;
22018 }else{
22019 char *zOld = (p->zText==p->zBase ? 0 : p->zText);
@@ -22029,14 +22114,14 @@
22029 setStrAccumError(p, STRACCUM_TOOBIG);
22030 return 0;
22031 }else{
22032 p->nAlloc = (int)szNew;
22033 }
22034 if( p->useMalloc==1 ){
22035 zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
22036 }else{
22037 zNew = sqlite3_realloc(zOld, p->nAlloc);
22038 }
22039 if( zNew ){
22040 assert( p->zText!=0 || p->nChar==0 );
22041 if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
22042 p->zText = zNew;
@@ -22052,11 +22137,14 @@
22052
22053 /*
22054 ** Append N copies of character c to the given string buffer.
22055 */
22056 SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
22057 if( p->nChar+N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ) return;
 
 
 
22058 while( (N--)>0 ) p->zText[p->nChar++] = c;
22059 }
22060
22061 /*
22062 ** The StrAccum "p" is not large enough to accept N new bytes of z[].
@@ -22077,11 +22165,11 @@
22077 /*
22078 ** Append N bytes of text from z to the StrAccum object. Increase the
22079 ** size of the memory allocation for StrAccum if necessary.
22080 */
22081 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
22082 assert( z!=0 );
22083 assert( p->zText!=0 || p->nChar==0 || p->accError );
22084 assert( N>=0 );
22085 assert( p->accError==0 || p->nAlloc==0 );
22086 if( p->nChar+N >= p->nAlloc ){
22087 enlargeAndAppend(p,z,N);
@@ -22106,16 +22194,12 @@
22106 ** pointer if any kind of error was encountered.
22107 */
22108 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
22109 if( p->zText ){
22110 p->zText[p->nChar] = 0;
22111 if( p->useMalloc && p->zText==p->zBase ){
22112 if( p->useMalloc==1 ){
22113 p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
22114 }else{
22115 p->zText = sqlite3_malloc(p->nChar+1);
22116 }
22117 if( p->zText ){
22118 memcpy(p->zText, p->zBase, p->nChar+1);
22119 }else{
22120 setStrAccumError(p, STRACCUM_NOMEM);
22121 }
@@ -22127,29 +22211,35 @@
22127 /*
22128 ** Reset an StrAccum string. Reclaim all malloced memory.
22129 */
22130 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
22131 if( p->zText!=p->zBase ){
22132 if( p->useMalloc==1 ){
22133 sqlite3DbFree(p->db, p->zText);
22134 }else{
22135 sqlite3_free(p->zText);
22136 }
22137 }
22138 p->zText = 0;
22139 }
22140
22141 /*
22142 ** Initialize a string accumulator
 
 
 
 
 
 
 
 
 
 
 
22143 */
22144 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, char *zBase, int n, int mx){
22145 p->zText = p->zBase = zBase;
22146 p->db = 0;
22147 p->nChar = 0;
22148 p->nAlloc = n;
22149 p->mxAlloc = mx;
22150 p->useMalloc = 1;
22151 p->accError = 0;
22152 }
22153
22154 /*
22155 ** Print into memory obtained from sqliteMalloc(). Use the internal
@@ -22158,13 +22248,12 @@
22158 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
22159 char *z;
22160 char zBase[SQLITE_PRINT_BUF_SIZE];
22161 StrAccum acc;
22162 assert( db!=0 );
22163 sqlite3StrAccumInit(&acc, zBase, sizeof(zBase),
22164 db->aLimit[SQLITE_LIMIT_LENGTH]);
22165 acc.db = db;
22166 sqlite3VXPrintf(&acc, SQLITE_PRINTF_INTERNAL, zFormat, ap);
22167 z = sqlite3StrAccumFinish(&acc);
22168 if( acc.accError==STRACCUM_NOMEM ){
22169 db->mallocFailed = 1;
22170 }
@@ -22204,11 +22293,11 @@
22204
22205 /*
22206 ** Print into memory obtained from sqlite3_malloc(). Omit the internal
22207 ** %-conversion extensions.
22208 */
22209 SQLITE_API char *sqlite3_vmprintf(const char *zFormat, va_list ap){
22210 char *z;
22211 char zBase[SQLITE_PRINT_BUF_SIZE];
22212 StrAccum acc;
22213
22214 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -22218,22 +22307,21 @@
22218 }
22219 #endif
22220 #ifndef SQLITE_OMIT_AUTOINIT
22221 if( sqlite3_initialize() ) return 0;
22222 #endif
22223 sqlite3StrAccumInit(&acc, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
22224 acc.useMalloc = 2;
22225 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22226 z = sqlite3StrAccumFinish(&acc);
22227 return z;
22228 }
22229
22230 /*
22231 ** Print into memory obtained from sqlite3_malloc()(). Omit the internal
22232 ** %-conversion extensions.
22233 */
22234 SQLITE_API char *sqlite3_mprintf(const char *zFormat, ...){
22235 va_list ap;
22236 char *z;
22237 #ifndef SQLITE_OMIT_AUTOINIT
22238 if( sqlite3_initialize() ) return 0;
22239 #endif
@@ -22254,26 +22342,25 @@
22254 ** this without breaking compatibility, so we just have to live with the
22255 ** mistake.
22256 **
22257 ** sqlite3_vsnprintf() is the varargs version.
22258 */
22259 SQLITE_API char *sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22260 StrAccum acc;
22261 if( n<=0 ) return zBuf;
22262 #ifdef SQLITE_ENABLE_API_ARMOR
22263 if( zBuf==0 || zFormat==0 ) {
22264 (void)SQLITE_MISUSE_BKPT;
22265 if( zBuf ) zBuf[0] = 0;
22266 return zBuf;
22267 }
22268 #endif
22269 sqlite3StrAccumInit(&acc, zBuf, n, 0);
22270 acc.useMalloc = 0;
22271 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22272 return sqlite3StrAccumFinish(&acc);
22273 }
22274 SQLITE_API char *sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22275 char *z;
22276 va_list ap;
22277 va_start(ap,zFormat);
22278 z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
22279 va_end(ap);
@@ -22291,41 +22378,39 @@
22291 */
22292 static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
22293 StrAccum acc; /* String accumulator */
22294 char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
22295
22296 sqlite3StrAccumInit(&acc, zMsg, sizeof(zMsg), 0);
22297 acc.useMalloc = 0;
22298 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22299 sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,
22300 sqlite3StrAccumFinish(&acc));
22301 }
22302
22303 /*
22304 ** Format and write a message to the log if logging is enabled.
22305 */
22306 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...){
22307 va_list ap; /* Vararg list */
22308 if( sqlite3GlobalConfig.xLog ){
22309 va_start(ap, zFormat);
22310 renderLogMsg(iErrCode, zFormat, ap);
22311 va_end(ap);
22312 }
22313 }
22314
22315 #if defined(SQLITE_DEBUG)
22316 /*
22317 ** A version of printf() that understands %lld. Used for debugging.
22318 ** The printf() built into some versions of windows does not understand %lld
22319 ** and segfaults if you give it a long long int.
22320 */
22321 SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
22322 va_list ap;
22323 StrAccum acc;
22324 char zBuf[500];
22325 sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
22326 acc.useMalloc = 0;
22327 va_start(ap,zFormat);
22328 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22329 va_end(ap);
22330 sqlite3StrAccumFinish(&acc);
22331 fprintf(stdout,"%s", zBuf);
@@ -22348,11 +22433,11 @@
22348 */
22349 /* Add a new subitem to the tree. The moreToFollow flag indicates that this
22350 ** is not the last item in the tree. */
22351 SQLITE_PRIVATE TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){
22352 if( p==0 ){
22353 p = sqlite3_malloc( sizeof(*p) );
22354 if( p==0 ) return 0;
22355 memset(p, 0, sizeof(*p));
22356 }else{
22357 p->iLevel++;
22358 }
@@ -22371,12 +22456,11 @@
22371 SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
22372 va_list ap;
22373 int i;
22374 StrAccum acc;
22375 char zBuf[500];
22376 sqlite3StrAccumInit(&acc, zBuf, sizeof(zBuf), 0);
22377 acc.useMalloc = 0;
22378 if( p ){
22379 for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
22380 sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4);
22381 }
22382 sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
@@ -22437,11 +22521,11 @@
22437 } sqlite3Prng;
22438
22439 /*
22440 ** Return N random bytes.
22441 */
22442 SQLITE_API void sqlite3_randomness(int N, void *pBuf){
22443 unsigned char t;
22444 unsigned char *zBuf = pBuf;
22445
22446 /* The "wsdPrng" macro will resolve to the pseudo-random number generator
22447 ** state vector. If writable static data is unsupported on the target,
@@ -23589,11 +23673,11 @@
23589 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
23590 ** the contents of two buffers containing UTF-8 strings in a
23591 ** case-independent fashion, using the same definition of "case
23592 ** independence" that SQLite uses internally when comparing identifiers.
23593 */
23594 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
23595 register unsigned char *a, *b;
23596 if( zLeft==0 ){
23597 return zRight ? -1 : 0;
23598 }else if( zRight==0 ){
23599 return 1;
@@ -23601,11 +23685,11 @@
23601 a = (unsigned char *)zLeft;
23602 b = (unsigned char *)zRight;
23603 while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
23604 return UpperToLower[*a] - UpperToLower[*b];
23605 }
23606 SQLITE_API int sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23607 register unsigned char *a, *b;
23608 if( zLeft==0 ){
23609 return zRight ? -1 : 0;
23610 }else if( zRight==0 ){
23611 return 1;
@@ -23995,10 +24079,11 @@
23995 }else{
23996 return 0;
23997 }
23998 }
23999 #endif
 
24000 for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){
24001 v = v*10 + c;
24002 }
24003
24004 /* The longest decimal representation of a 32 bit integer is 10 digits:
@@ -25249,10 +25334,21 @@
25249 #if SQLITE_ENABLE_LOCKING_STYLE
25250 # include <sys/ioctl.h>
25251 # include <sys/file.h>
25252 # include <sys/param.h>
25253 #endif /* SQLITE_ENABLE_LOCKING_STYLE */
 
 
 
 
 
 
 
 
 
 
 
25254
25255 #if OS_VXWORKS
25256 /* # include <sys/ioctl.h> */
25257 # include <semaphore.h>
25258 # include <limits.h>
@@ -25445,20 +25541,10 @@
25445 */
25446 #ifdef MEMORY_DEBUG
25447 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
25448 #endif
25449
25450 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
25451 # ifndef SQLITE_DEBUG_OS_TRACE
25452 # define SQLITE_DEBUG_OS_TRACE 0
25453 # endif
25454 int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
25455 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
25456 #else
25457 # define OSTRACE(X)
25458 #endif
25459
25460 /*
25461 ** Macros for performance tracing. Normally turned off. Only works
25462 ** on i486 hardware.
25463 */
25464 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -25997,11 +26083,11 @@
25997 return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
25998 }
25999 #endif
26000
26001
26002 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
26003 /*
26004 ** Helper function for printing out trace information from debugging
26005 ** binaries. This returns the string representation of the supplied
26006 ** integer lock-type.
26007 */
@@ -26260,11 +26346,11 @@
26260 struct vxworksFileId *pCandidate; /* For looping over existing file IDs */
26261 int n; /* Length of zAbsoluteName string */
26262
26263 assert( zAbsoluteName[0]=='/' );
26264 n = (int)strlen(zAbsoluteName);
26265 pNew = sqlite3_malloc( sizeof(*pNew) + (n+1) );
26266 if( pNew==0 ) return 0;
26267 pNew->zCanonicalName = (char*)&pNew[1];
26268 memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);
26269 n = vxworksSimplifyName(pNew->zCanonicalName, n);
26270
@@ -26664,11 +26750,11 @@
26664 pInode = inodeList;
26665 while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
26666 pInode = pInode->pNext;
26667 }
26668 if( pInode==0 ){
26669 pInode = sqlite3_malloc( sizeof(*pInode) );
26670 if( pInode==0 ){
26671 return SQLITE_NOMEM;
26672 }
26673 memset(pInode, 0, sizeof(*pInode));
26674 memcpy(&pInode->fileId, &fileId, sizeof(fileId));
@@ -29150,11 +29236,11 @@
29150 */
29151 static int unixFileControl(sqlite3_file *id, int op, void *pArg){
29152 unixFile *pFile = (unixFile*)id;
29153 switch( op ){
29154 case SQLITE_FCNTL_WAL_BLOCK: {
29155 pFile->ctrlFlags |= UNIXFILE_BLOCK;
29156 return SQLITE_OK;
29157 }
29158 case SQLITE_FCNTL_LOCKSTATE: {
29159 *(int*)pArg = pFile->eFileLock;
29160 return SQLITE_OK;
@@ -29185,11 +29271,11 @@
29185 case SQLITE_FCNTL_VFSNAME: {
29186 *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
29187 return SQLITE_OK;
29188 }
29189 case SQLITE_FCNTL_TEMPFILENAME: {
29190 char *zTFile = sqlite3_malloc( pFile->pVfs->mxPathname );
29191 if( zTFile ){
29192 unixGetTempname(pFile->pVfs->mxPathname, zTFile);
29193 *(char**)pArg = zTFile;
29194 }
29195 return SQLITE_OK;
@@ -29626,11 +29712,11 @@
29626 unixInodeInfo *pInode; /* The inode of fd */
29627 char *zShmFilename; /* Name of the file used for SHM */
29628 int nShmFilename; /* Size of the SHM filename in bytes */
29629
29630 /* Allocate space for the new unixShm object. */
29631 p = sqlite3_malloc( sizeof(*p) );
29632 if( p==0 ) return SQLITE_NOMEM;
29633 memset(p, 0, sizeof(*p));
29634 assert( pDbFd->pShm==0 );
29635
29636 /* Check to see if a unixShmNode object already exists. Reuse an existing
@@ -29657,11 +29743,11 @@
29657 #ifdef SQLITE_SHM_DIRECTORY
29658 nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
29659 #else
29660 nShmFilename = 6 + (int)strlen(zBasePath);
29661 #endif
29662 pShmNode = sqlite3_malloc( sizeof(*pShmNode) + nShmFilename );
29663 if( pShmNode==0 ){
29664 rc = SQLITE_NOMEM;
29665 goto shm_open_err;
29666 }
29667 memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);
@@ -29867,11 +29953,11 @@
29867 if( pMem==MAP_FAILED ){
29868 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
29869 goto shmpage_out;
29870 }
29871 }else{
29872 pMem = sqlite3_malloc(szRegion);
29873 if( pMem==0 ){
29874 rc = SQLITE_NOMEM;
29875 goto shmpage_out;
29876 }
29877 memset(pMem, 0, szRegion);
@@ -30704,11 +30790,11 @@
30704 else if( pLockingStyle == &afpIoMethods ){
30705 /* AFP locking uses the file path so it needs to be included in
30706 ** the afpLockingContext.
30707 */
30708 afpLockingContext *pCtx;
30709 pNew->lockingContext = pCtx = sqlite3_malloc( sizeof(*pCtx) );
30710 if( pCtx==0 ){
30711 rc = SQLITE_NOMEM;
30712 }else{
30713 /* NB: zFilename exists and remains valid until the file is closed
30714 ** according to requirement F11141. So we do not need to make a
@@ -30734,11 +30820,11 @@
30734 */
30735 char *zLockFile;
30736 int nFilename;
30737 assert( zFilename!=0 );
30738 nFilename = (int)strlen(zFilename) + 6;
30739 zLockFile = (char *)sqlite3_malloc(nFilename);
30740 if( zLockFile==0 ){
30741 rc = SQLITE_NOMEM;
30742 }else{
30743 sqlite3_snprintf(nFilename, zLockFile, "%s" DOTLOCK_SUFFIX, zFilename);
30744 }
@@ -31111,11 +31197,11 @@
31111 UnixUnusedFd *pUnused;
31112 pUnused = findReusableFd(zName, flags);
31113 if( pUnused ){
31114 fd = pUnused->fd;
31115 }else{
31116 pUnused = sqlite3_malloc(sizeof(*pUnused));
31117 if( !pUnused ){
31118 return SQLITE_NOMEM;
31119 }
31120 }
31121 p->pUnused = pUnused;
@@ -31491,11 +31577,11 @@
31491 ** that we always use the same random number sequence. This makes the
31492 ** tests repeatable.
31493 */
31494 memset(zBuf, 0, nBuf);
31495 randomnessPid = osGetpid(0);
31496 #if !defined(SQLITE_TEST)
31497 {
31498 int fd, got;
31499 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31500 if( fd<0 ){
31501 time_t t;
@@ -31903,11 +31989,11 @@
31903 */
31904 pUnused = findReusableFd(path, openFlags);
31905 if( pUnused ){
31906 fd = pUnused->fd;
31907 }else{
31908 pUnused = sqlite3_malloc(sizeof(*pUnused));
31909 if( !pUnused ){
31910 return SQLITE_NOMEM;
31911 }
31912 }
31913 if( fd<0 ){
@@ -31936,11 +32022,11 @@
31936 default:
31937 return SQLITE_CANTOPEN_BKPT;
31938 }
31939 }
31940
31941 pNew = (unixFile *)sqlite3_malloc(sizeof(*pNew));
31942 if( pNew==NULL ){
31943 rc = SQLITE_NOMEM;
31944 goto end_create_proxy;
31945 }
31946 memset(pNew, 0, sizeof(unixFile));
@@ -31969,21 +32055,22 @@
31969 SQLITE_API int sqlite3_hostid_num = 0;
31970 #endif
31971
31972 #define PROXY_HOSTIDLEN 16 /* conch file host id length */
31973
 
31974 /* Not always defined in the headers as it ought to be */
31975 extern int gethostuuid(uuid_t id, const struct timespec *wait);
 
31976
31977 /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN
31978 ** bytes of writable memory.
31979 */
31980 static int proxyGetHostID(unsigned char *pHostID, int *pError){
31981 assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
31982 memset(pHostID, 0, PROXY_HOSTIDLEN);
31983 # if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
31984 (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
31985 {
31986 struct timespec timeout = {1, 0}; /* 1 sec timeout */
31987 if( gethostuuid(pHostID, &timeout) ){
31988 int err = errno;
31989 if( pError ){
@@ -32397,11 +32484,11 @@
32397 return rc;
32398 }
32399
32400 /*
32401 ** Given the name of a database file, compute the name of its conch file.
32402 ** Store the conch filename in memory obtained from sqlite3_malloc().
32403 ** Make *pConchPath point to the new name. Return SQLITE_OK on success
32404 ** or SQLITE_NOMEM if unable to obtain memory.
32405 **
32406 ** The caller is responsible for ensuring that the allocated memory
32407 ** space is eventually freed.
@@ -32413,11 +32500,11 @@
32413 int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
32414 char *conchPath; /* buffer in which to construct conch name */
32415
32416 /* Allocate space for the conch filename and initialize the name to
32417 ** the name of the original database file. */
32418 *pConchPath = conchPath = (char *)sqlite3_malloc(len + 8);
32419 if( conchPath==0 ){
32420 return SQLITE_NOMEM;
32421 }
32422 memcpy(conchPath, dbPath, len+1);
32423
@@ -32529,11 +32616,11 @@
32529 }
32530
32531 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32532 (lockPath ? lockPath : ":auto:"), osGetpid(0)));
32533
32534 pCtx = sqlite3_malloc( sizeof(*pCtx) );
32535 if( pCtx==0 ){
32536 return SQLITE_NOMEM;
32537 }
32538 memset(pCtx, 0, sizeof(*pCtx));
32539
@@ -32814,11 +32901,11 @@
32814 ** This routine is called once during SQLite initialization and by a
32815 ** single thread. The memory allocation and mutex subsystems have not
32816 ** necessarily been initialized when this routine is called, and so they
32817 ** should not be used.
32818 */
32819 SQLITE_API int sqlite3_os_init(void){
32820 /*
32821 ** The following macro defines an initializer for an sqlite3_vfs object.
32822 ** The name of the VFS is NAME. The pAppData is a pointer to a pointer
32823 ** to the "finder" function. (pAppData is a pointer to a pointer because
32824 ** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32913,11 +33000,11 @@
32913 **
32914 ** Some operating systems might need to do some cleanup in this routine,
32915 ** to release dynamically allocated objects. But not on unix.
32916 ** This routine is a no-op for unix.
32917 */
32918 SQLITE_API int sqlite3_os_end(void){
32919 return SQLITE_OK;
32920 }
32921
32922 #endif /* SQLITE_OS_UNIX */
32923
@@ -32973,20 +33060,10 @@
32973 */
32974 #ifdef MEMORY_DEBUG
32975 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
32976 #endif
32977
32978 #if defined(SQLITE_TEST) && defined(SQLITE_DEBUG)
32979 # ifndef SQLITE_DEBUG_OS_TRACE
32980 # define SQLITE_DEBUG_OS_TRACE 0
32981 # endif
32982 int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
32983 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
32984 #else
32985 # define OSTRACE(X)
32986 #endif
32987
32988 /*
32989 ** Macros for performance tracing. Normally turned off. Only works
32990 ** on i486 hardware.
32991 */
32992 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -33326,12 +33403,14 @@
33326
33327 WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
33328 #endif /* SQLITE_OS_WINRT */
33329
33330 /*
33331 ** This file mapping API is common to both Win32 and WinRT.
33332 */
 
 
33333 WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
33334 #endif /* SQLITE_WIN32_FILEMAPPING_API */
33335
33336 /*
33337 ** Some Microsoft compilers lack this definition.
@@ -34212,10 +34291,19 @@
34212 #endif
34213
34214 #define osUuidCreateSequential \
34215 ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)
34216
 
 
 
 
 
 
 
 
 
34217 }; /* End of the overrideable system calls */
34218
34219 /*
34220 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
34221 ** "win32" VFSes. Return SQLITE_OK opon successfully updating the
@@ -34305,11 +34393,11 @@
34305 ** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
34306 ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
34307 ** "pnLargest" argument, if non-zero, will be used to return the size of the
34308 ** largest committed free block in the heap, in bytes.
34309 */
34310 SQLITE_API int sqlite3_win32_compact_heap(LPUINT pnLargest){
34311 int rc = SQLITE_OK;
34312 UINT nLargest = 0;
34313 HANDLE hHeap;
34314
34315 winMemAssertMagic();
@@ -34345,11 +34433,11 @@
34345 ** If a Win32 native heap has been configured, this function will attempt to
34346 ** destroy and recreate it. If the Win32 native heap is not isolated and/or
34347 ** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
34348 ** be returned and no changes will be made to the Win32 native heap.
34349 */
34350 SQLITE_API int sqlite3_win32_reset_heap(){
34351 int rc;
34352 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
34353 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
34354 MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
34355 MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34390,11 +34478,11 @@
34390 /*
34391 ** This function outputs the specified (ANSI) string to the Win32 debugger
34392 ** (if available).
34393 */
34394
34395 SQLITE_API void sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34396 char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
34397 int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
34398 if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
34399 assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
34400 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34430,11 +34518,11 @@
34430 */
34431 #if SQLITE_OS_WINRT
34432 static HANDLE sleepObj = NULL;
34433 #endif
34434
34435 SQLITE_API void sqlite3_win32_sleep(DWORD milliseconds){
34436 #if SQLITE_OS_WINRT
34437 if ( sleepObj==NULL ){
34438 sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
34439 SYNCHRONIZE);
34440 }
@@ -34479,11 +34567,11 @@
34479
34480 /*
34481 ** This function determines if the machine is running a version of Windows
34482 ** based on the NT kernel.
34483 */
34484 SQLITE_API int sqlite3_win32_is_nt(void){
34485 #if SQLITE_OS_WINRT
34486 /*
34487 ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
34488 ** kernel.
34489 */
@@ -34833,11 +34921,11 @@
34833
34834 /*
34835 ** Convert multibyte character string to UTF-8. Space to hold the
34836 ** returned string is obtained from sqlite3_malloc().
34837 */
34838 SQLITE_API char *sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34839 char *zFilenameUtf8;
34840 LPWSTR zTmpWide;
34841
34842 zTmpWide = winMbcsToUnicode(zFilename);
34843 if( zTmpWide==0 ){
@@ -34850,11 +34938,11 @@
34850
34851 /*
34852 ** Convert UTF-8 to multibyte character string. Space to hold the
34853 ** returned string is obtained from sqlite3_malloc().
34854 */
34855 SQLITE_API char *sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34856 char *zFilenameMbcs;
34857 LPWSTR zTmpWide;
34858
34859 zTmpWide = winUtf8ToUnicode(zFilename);
34860 if( zTmpWide==0 ){
@@ -34870,11 +34958,11 @@
34870 ** the provided arguments. The type argument must be 1 in order to set the
34871 ** data directory or 2 in order to set the temporary directory. The zValue
34872 ** argument is the name of the directory to use. The return value will be
34873 ** SQLITE_OK if successful.
34874 */
34875 SQLITE_API int sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34876 char **ppDirectory = 0;
34877 #ifndef SQLITE_OMIT_AUTOINIT
34878 int rc = sqlite3_initialize();
34879 if( rc ) return rc;
34880 #endif
@@ -35095,15 +35183,15 @@
35095 }
35096
35097 /*
35098 ** Log a I/O error retry episode.
35099 */
35100 static void winLogIoerr(int nRetry){
35101 if( nRetry ){
35102 sqlite3_log(SQLITE_IOERR,
35103 "delayed %dms for lock/sharing conflict",
35104 winIoerrRetryDelay*nRetry*(nRetry+1)/2
35105 );
35106 }
35107 }
35108
35109 #if SQLITE_OS_WINCE
@@ -35579,11 +35667,12 @@
35579 assert( id!=0 );
35580 #ifndef SQLITE_OMIT_WAL
35581 assert( pFile->pShm==0 );
35582 #endif
35583 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35584 OSTRACE(("CLOSE file=%p\n", pFile->h));
 
35585
35586 #if SQLITE_MAX_MMAP_SIZE>0
35587 winUnmapfile(pFile);
35588 #endif
35589
@@ -35608,11 +35697,12 @@
35608 #endif
35609 if( rc ){
35610 pFile->h = NULL;
35611 }
35612 OpenCounter(-1);
35613 OSTRACE(("CLOSE file=%p, rc=%s\n", pFile->h, rc ? "ok" : "failed"));
 
35614 return rc ? SQLITE_OK
35615 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
35616 "winClose", pFile->zPath);
35617 }
35618
@@ -35636,20 +35726,22 @@
35636
35637 assert( id!=0 );
35638 assert( amt>0 );
35639 assert( offset>=0 );
35640 SimulateIOError(return SQLITE_IOERR_READ);
35641 OSTRACE(("READ file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
 
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 file=%p, rc=SQLITE_OK\n", pFile->h));
 
35651 return SQLITE_OK;
35652 }else{
35653 int nCopy = (int)(pFile->mmapSize - offset);
35654 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
35655 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35659,11 +35751,12 @@
35659 }
35660 #endif
35661
35662 #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
35663 if( winSeekFile(pFile, offset) ){
35664 OSTRACE(("READ file=%p, rc=SQLITE_FULL\n", pFile->h));
 
35665 return SQLITE_FULL;
35666 }
35667 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
35668 #else
35669 memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35673,23 +35766,26 @@
35673 osGetLastError()!=ERROR_HANDLE_EOF ){
35674 #endif
35675 DWORD lastErrno;
35676 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
35677 pFile->lastErrno = lastErrno;
35678 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_READ\n", pFile->h));
 
35679 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
35680 "winRead", pFile->zPath);
35681 }
35682 winLogIoerr(nRetry);
35683 if( nRead<(DWORD)amt ){
35684 /* Unread parts of the buffer must be zero-filled */
35685 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35686 OSTRACE(("READ file=%p, rc=SQLITE_IOERR_SHORT_READ\n", pFile->h));
 
35687 return SQLITE_IOERR_SHORT_READ;
35688 }
35689
35690 OSTRACE(("READ file=%p, rc=SQLITE_OK\n", pFile->h));
 
35691 return SQLITE_OK;
35692 }
35693
35694 /*
35695 ** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35708,20 +35804,22 @@
35708 assert( amt>0 );
35709 assert( pFile );
35710 SimulateIOError(return SQLITE_IOERR_WRITE);
35711 SimulateDiskfullError(return SQLITE_FULL);
35712
35713 OSTRACE(("WRITE file=%p, buffer=%p, amount=%d, offset=%lld, lock=%d\n",
 
35714 pFile->h, pBuf, amt, offset, pFile->locktype));
35715
35716 #if SQLITE_MAX_MMAP_SIZE>0
35717 /* Deal with as much of this write request as possible by transfering
35718 ** data from the memory mapping using memcpy(). */
35719 if( offset<pFile->mmapSize ){
35720 if( offset+amt <= pFile->mmapSize ){
35721 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35722 OSTRACE(("WRITE-MMAP file=%p, rc=SQLITE_OK\n", pFile->h));
 
35723 return SQLITE_OK;
35724 }else{
35725 int nCopy = (int)(pFile->mmapSize - offset);
35726 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
35727 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35780,21 +35878,24 @@
35780 }
35781
35782 if( rc ){
35783 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
35784 || ( pFile->lastErrno==ERROR_DISK_FULL )){
35785 OSTRACE(("WRITE file=%p, rc=SQLITE_FULL\n", pFile->h));
 
35786 return winLogError(SQLITE_FULL, pFile->lastErrno,
35787 "winWrite1", pFile->zPath);
35788 }
35789 OSTRACE(("WRITE file=%p, rc=SQLITE_IOERR_WRITE\n", pFile->h));
 
35790 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
35791 "winWrite2", pFile->zPath);
35792 }else{
35793 winLogIoerr(nRetry);
35794 }
35795 OSTRACE(("WRITE file=%p, rc=SQLITE_OK\n", pFile->h));
 
35796 return SQLITE_OK;
35797 }
35798
35799 /*
35800 ** Truncate an open file to a specified size
@@ -35804,12 +35905,12 @@
35804 int rc = SQLITE_OK; /* Return code for this function */
35805 DWORD lastErrno;
35806
35807 assert( pFile );
35808 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35809 OSTRACE(("TRUNCATE file=%p, size=%lld, lock=%d\n",
35810 pFile->h, nByte, pFile->locktype));
35811
35812 /* If the user has configured a chunk-size for this file, truncate the
35813 ** file so that it consists of an integer number of chunks (i.e. the
35814 ** actual file size after the operation may be larger than the requested
35815 ** size).
@@ -35837,11 +35938,12 @@
35837 if( pFile->pMapRegion && nByte<pFile->mmapSize ){
35838 pFile->mmapSize = nByte;
35839 }
35840 #endif
35841
35842 OSTRACE(("TRUNCATE file=%p, rc=%s\n", pFile->h, sqlite3ErrName(rc)));
 
35843 return rc;
35844 }
35845
35846 #ifdef SQLITE_TEST
35847 /*
@@ -35861,11 +35963,11 @@
35861 ** Used only when SQLITE_NO_SYNC is not defined.
35862 */
35863 BOOL rc;
35864 #endif
35865 #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \
35866 (defined(SQLITE_TEST) && defined(SQLITE_DEBUG))
35867 /*
35868 ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or
35869 ** OSTRACE() macros.
35870 */
35871 winFile *pFile = (winFile*)id;
@@ -35882,12 +35984,13 @@
35882 /* Unix cannot, but some systems may return SQLITE_FULL from here. This
35883 ** line is to test that doing so does not cause any problems.
35884 */
35885 SimulateDiskfullError( return SQLITE_FULL );
35886
35887 OSTRACE(("SYNC file=%p, flags=%x, lock=%d\n",
35888 pFile->h, flags, pFile->locktype));
 
35889
35890 #ifndef SQLITE_TEST
35891 UNUSED_PARAMETER(flags);
35892 #else
35893 if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35898,23 +36001,42 @@
35898
35899 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
35900 ** no-op
35901 */
35902 #ifdef SQLITE_NO_SYNC
35903 OSTRACE(("SYNC-NOP file=%p, rc=SQLITE_OK\n", pFile->h));
 
35904 return SQLITE_OK;
35905 #else
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35906 rc = osFlushFileBuffers(pFile->h);
35907 SimulateIOError( rc=FALSE );
35908 if( rc ){
35909 OSTRACE(("SYNC file=%p, rc=SQLITE_OK\n", pFile->h));
 
35910 return SQLITE_OK;
35911 }else{
35912 pFile->lastErrno = osGetLastError();
35913 OSTRACE(("SYNC file=%p, rc=SQLITE_IOERR_FSYNC\n", pFile->h));
 
35914 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
35915 "winSync", pFile->zPath);
35916 }
35917 #endif
35918 }
35919
35920 /*
@@ -36518,11 +36640,11 @@
36518 DWORD lastErrno; /* The Windows errno from the last I/O error */
36519
36520 int nRef; /* Number of winShm objects pointing to this */
36521 winShm *pFirst; /* All winShm objects pointing to this */
36522 winShmNode *pNext; /* Next in list of all winShmNode objects */
36523 #ifdef SQLITE_DEBUG
36524 u8 nextShmId; /* Next available winShm.id value */
36525 #endif
36526 };
36527
36528 /*
@@ -36549,11 +36671,11 @@
36549 winShmNode *pShmNode; /* The underlying winShmNode object */
36550 winShm *pNext; /* Next winShm with the same winShmNode */
36551 u8 hasMutex; /* True if holding the winShmNode mutex */
36552 u16 sharedMask; /* Mask of shared locks held */
36553 u16 exclMask; /* Mask of exclusive locks held */
36554 #ifdef SQLITE_DEBUG
36555 u8 id; /* Id of this connection with its winShmNode */
36556 #endif
36557 };
36558
36559 /*
@@ -36740,11 +36862,11 @@
36740 if( rc ) goto shm_open_err;
36741 }
36742
36743 /* Make the new connection a child of the winShmNode */
36744 p->pShmNode = pShmNode;
36745 #ifdef SQLITE_DEBUG
36746 p->id = pShmNode->nextShmId++;
36747 #endif
36748 pShmNode->nRef++;
36749 pDbFd->pShm = p;
36750 winShmLeaveMutex();
@@ -37009,11 +37131,11 @@
37009 goto shmpage_out;
37010 }
37011 }
37012
37013 /* Map the requested memory region into this processes address space. */
37014 apNew = (struct ShmRegion *)sqlite3_realloc(
37015 pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
37016 );
37017 if( !apNew ){
37018 rc = SQLITE_IOERR_NOMEM;
37019 goto shmpage_out;
@@ -37881,11 +38003,11 @@
37881 winRetryIoerr(&cnt, &lastErrno) ){
37882 /* Noop */
37883 }
37884 }
37885 #endif
37886 winLogIoerr(cnt);
37887
37888 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
37889 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
37890
37891 if( h==INVALID_HANDLE_VALUE ){
@@ -38065,11 +38187,11 @@
38065 }
38066 #endif
38067 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
38068 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
38069 }else{
38070 winLogIoerr(cnt);
38071 }
38072 sqlite3_free(zConverted);
38073 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
38074 return rc;
38075 }
@@ -38115,11 +38237,11 @@
38115 attr = INVALID_FILE_ATTRIBUTES;
38116 }else{
38117 attr = sAttrData.dwFileAttributes;
38118 }
38119 }else{
38120 winLogIoerr(cnt);
38121 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
38122 sqlite3_free(zConverted);
38123 return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
38124 zFilename);
38125 }else{
@@ -38456,11 +38578,11 @@
38456 ** Write up to nBuf bytes of randomness into zBuf.
38457 */
38458 static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
38459 int n = 0;
38460 UNUSED_PARAMETER(pVfs);
38461 #if defined(SQLITE_TEST)
38462 n = nBuf;
38463 memset(zBuf, 0, nBuf);
38464 #else
38465 if( sizeof(SYSTEMTIME)<=nBuf-n ){
38466 SYSTEMTIME x;
@@ -38490,11 +38612,10 @@
38490 LARGE_INTEGER i;
38491 osQueryPerformanceCounter(&i);
38492 memcpy(&zBuf[n], &i, sizeof(i));
38493 n += sizeof(i);
38494 }
38495 #endif
38496 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
38497 if( sizeof(UUID)<=nBuf-n ){
38498 UUID id;
38499 memset(&id, 0, sizeof(UUID));
38500 osUuidCreate(&id);
@@ -38507,10 +38628,11 @@
38507 osUuidCreateSequential(&id);
38508 memcpy(zBuf, &id, sizeof(UUID));
38509 n += sizeof(UUID);
38510 }
38511 #endif
 
38512 return n;
38513 }
38514
38515
38516 /*
@@ -38630,11 +38752,11 @@
38630 }
38631
38632 /*
38633 ** Initialize and deinitialize the operating system interface.
38634 */
38635 SQLITE_API int sqlite3_os_init(void){
38636 static sqlite3_vfs winVfs = {
38637 3, /* iVersion */
38638 sizeof(winFile), /* szOsFile */
38639 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
38640 0, /* pNext */
@@ -38684,11 +38806,11 @@
38684 };
38685 #endif
38686
38687 /* Double-check that the aSyscall[] array has been constructed
38688 ** correctly. See ticket [bb3a86e890c8e96ab] */
38689 assert( ArraySize(aSyscall)==79 );
38690
38691 /* get memory map allocation granularity */
38692 memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
38693 #if SQLITE_OS_WINRT
38694 osGetNativeSystemInfo(&winSysInfo);
@@ -38705,11 +38827,11 @@
38705 #endif
38706
38707 return SQLITE_OK;
38708 }
38709
38710 SQLITE_API int sqlite3_os_end(void){
38711 #if SQLITE_OS_WINRT
38712 if( sleepObj!=NULL ){
38713 osCloseHandle(sleepObj);
38714 sleepObj = NULL;
38715 }
@@ -39061,11 +39183,11 @@
39061
39062 /* Allocate the Bitvec to be tested and a linear array of
39063 ** bits to act as the reference */
39064 pBitvec = sqlite3BitvecCreate( sz );
39065 pV = sqlite3MallocZero( (sz+7)/8 + 1 );
39066 pTmpSpace = sqlite3_malloc(BITVEC_SZ);
39067 if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
39068
39069 /* NULL pBitvec tests */
39070 sqlite3BitvecSet(0, 1);
39071 sqlite3BitvecClear(0, 1, pTmpSpace);
@@ -44550,13 +44672,11 @@
44550 Pgno nTruncate, /* Database size after this commit */
44551 int isCommit /* True if this is a commit */
44552 ){
44553 int rc; /* Return code */
44554 int nList; /* Number of pages in pList */
44555 #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
44556 PgHdr *p; /* For looping over pages */
44557 #endif
44558
44559 assert( pPager->pWal );
44560 assert( pList );
44561 #ifdef SQLITE_DEBUG
44562 /* Verify that the page list is in accending order */
@@ -44569,11 +44689,10 @@
44569 if( isCommit ){
44570 /* If a WAL transaction is being committed, there is no point in writing
44571 ** any pages with page numbers greater than nTruncate into the WAL file.
44572 ** They will never be read by any client. So remove them from the pDirty
44573 ** list here. */
44574 PgHdr *p;
44575 PgHdr **ppNext = &pList;
44576 nList = 0;
44577 for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
44578 if( p->pgno<=nTruncate ){
44579 ppNext = &p->pDirty;
@@ -44589,11 +44708,10 @@
44589 if( pList->pgno==1 ) pager_write_changecounter(pList);
44590 rc = sqlite3WalFrames(pPager->pWal,
44591 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
44592 );
44593 if( rc==SQLITE_OK && pPager->pBackup ){
44594 PgHdr *p;
44595 for(p=pList; p; p=p->pDirty){
44596 sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
44597 }
44598 }
44599
@@ -48520,10 +48638,12 @@
48520 }else if( state==PAGER_OPEN ){
48521 pager_unlock(pPager);
48522 }
48523 assert( state==pPager->eState );
48524 }
 
 
48525 }
48526 }
48527
48528 /* Return the new journal mode */
48529 return (int)pPager->journalMode;
@@ -49302,11 +49422,11 @@
49302
49303 /* Enlarge the pWal->apWiData[] array if required */
49304 if( pWal->nWiData<=iPage ){
49305 int nByte = sizeof(u32*)*(iPage+1);
49306 volatile u32 **apNew;
49307 apNew = (volatile u32 **)sqlite3_realloc((void *)pWal->apWiData, nByte);
49308 if( !apNew ){
49309 *ppPage = 0;
49310 return SQLITE_NOMEM;
49311 }
49312 memset((void*)&apNew[pWal->nWiData], 0,
@@ -49927,11 +50047,11 @@
49927 goto finished;
49928 }
49929
49930 /* Malloc a buffer to read frames into. */
49931 szFrame = szPage + WAL_FRAME_HDRSIZE;
49932 aFrame = (u8 *)sqlite3_malloc(szFrame);
49933 if( !aFrame ){
49934 rc = SQLITE_NOMEM;
49935 goto recovery_error;
49936 }
49937 aData = &aFrame[WAL_FRAME_HDRSIZE];
@@ -50320,21 +50440,21 @@
50320 /* Allocate space for the WalIterator object. */
50321 nSegment = walFramePage(iLast) + 1;
50322 nByte = sizeof(WalIterator)
50323 + (nSegment-1)*sizeof(struct WalSegment)
50324 + iLast*sizeof(ht_slot);
50325 p = (WalIterator *)sqlite3_malloc(nByte);
50326 if( !p ){
50327 return SQLITE_NOMEM;
50328 }
50329 memset(p, 0, nByte);
50330 p->nSegment = nSegment;
50331
50332 /* Allocate temporary space used by the merge-sort routine. This block
50333 ** of memory will be freed before this function returns.
50334 */
50335 aTmp = (ht_slot *)sqlite3_malloc(
50336 sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
50337 );
50338 if( !aTmp ){
50339 rc = SQLITE_NOMEM;
50340 }
@@ -50510,10 +50630,18 @@
50510 ** cannot be backfilled from the WAL.
50511 */
50512 mxSafeFrame = pWal->hdr.mxFrame;
50513 mxPage = pWal->hdr.nPage;
50514 for(i=1; i<WAL_NREADER; i++){
 
 
 
 
 
 
 
 
50515 u32 y = pInfo->aReadMark[i];
50516 if( mxSafeFrame>y ){
50517 assert( y<=pWal->hdr.mxFrame );
50518 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50519 if( rc==SQLITE_OK ){
@@ -52231,10 +52359,11 @@
52231 u8 noPayload; /* True if internal intKey page (thus w/o data) */
52232 u8 leaf; /* True if a leaf page */
52233 u8 hdrOffset; /* 100 for page 1. 0 otherwise */
52234 u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */
52235 u8 max1bytePayload; /* min(maxLocal,127) */
 
52236 u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
52237 u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
52238 u16 cellOffset; /* Index in aData of first cell pointer */
52239 u16 nFree; /* Number of free bytes on the page */
52240 u16 nCell; /* Number of cells on this page, local and ovfl */
@@ -53006,11 +53135,11 @@
53006 **
53007 ** This routine has no effect on existing database connections.
53008 ** The shared cache setting effects only future calls to
53009 ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
53010 */
53011 SQLITE_API int sqlite3_enable_shared_cache(int enable){
53012 sqlite3GlobalConfig.sharedCacheEnabled = enable;
53013 return SQLITE_OK;
53014 }
53015 #endif
53016
@@ -53520,14 +53649,19 @@
53520 ** prior to calling this routine.
53521 */
53522 static int saveCursorPosition(BtCursor *pCur){
53523 int rc;
53524
53525 assert( CURSOR_VALID==pCur->eState );
53526 assert( 0==pCur->pKey );
53527 assert( cursorHoldsMutex(pCur) );
53528
 
 
 
 
 
53529 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
53530 assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
53531
53532 /* If this is an intKey table, then the above call to BtreeKeySize()
53533 ** stores the integer key in pCur->nKey. In this case this value is
@@ -53594,11 +53728,11 @@
53594 Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
53595 BtCursor *pExcept /* Do not save this cursor */
53596 ){
53597 do{
53598 if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53599 if( p->eState==CURSOR_VALID ){
53600 int rc = saveCursorPosition(p);
53601 if( SQLITE_OK!=rc ){
53602 return rc;
53603 }
53604 }else{
@@ -53666,21 +53800,23 @@
53666 ** at most one effective restoreCursorPosition() call after each
53667 ** saveCursorPosition().
53668 */
53669 static int btreeRestoreCursorPosition(BtCursor *pCur){
53670 int rc;
 
53671 assert( cursorHoldsMutex(pCur) );
53672 assert( pCur->eState>=CURSOR_REQUIRESEEK );
53673 if( pCur->eState==CURSOR_FAULT ){
53674 return pCur->skipNext;
53675 }
53676 pCur->eState = CURSOR_INVALID;
53677 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &pCur->skipNext);
53678 if( rc==SQLITE_OK ){
53679 sqlite3_free(pCur->pKey);
53680 pCur->pKey = 0;
53681 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
 
53682 if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
53683 pCur->eState = CURSOR_SKIPNEXT;
53684 }
53685 }
53686 return rc;
@@ -53728,13 +53864,14 @@
53728 rc = restoreCursorPosition(pCur);
53729 if( rc ){
53730 *pDifferentRow = 1;
53731 return rc;
53732 }
53733 if( pCur->eState!=CURSOR_VALID || NEVER(pCur->skipNext!=0) ){
53734 *pDifferentRow = 1;
53735 }else{
 
53736 *pDifferentRow = 0;
53737 }
53738 return SQLITE_OK;
53739 }
53740
@@ -54871,20 +55008,22 @@
54871 ** If this Btree is a candidate for shared cache, try to find an
54872 ** existing BtShared object that we can share with
54873 */
54874 if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){
54875 if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
 
54876 int nFullPathname = pVfs->mxPathname+1;
54877 char *zFullPathname = sqlite3Malloc(nFullPathname);
54878 MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
 
54879 p->sharable = 1;
54880 if( !zFullPathname ){
54881 sqlite3_free(p);
54882 return SQLITE_NOMEM;
54883 }
54884 if( isMemdb ){
54885 memcpy(zFullPathname, zFilename, sqlite3Strlen30(zFilename)+1);
54886 }else{
54887 rc = sqlite3OsFullPathname(pVfs, zFilename,
54888 nFullPathname, zFullPathname);
54889 if( rc ){
54890 sqlite3_free(zFullPathname);
@@ -55339,11 +55478,11 @@
55339 }
55340 assert( nReserve>=0 && nReserve<=255 );
55341 if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
55342 ((pageSize-1)&pageSize)==0 ){
55343 assert( (pageSize & 7)==0 );
55344 assert( !pBt->pPage1 && !pBt->pCursor );
55345 pBt->pageSize = (u32)pageSize;
55346 freeTempSpace(pBt);
55347 }
55348 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
55349 pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -56545,11 +56684,11 @@
56545 if( pBtree ){
56546 sqlite3BtreeEnter(pBtree);
56547 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
56548 int i;
56549 if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56550 if( p->eState==CURSOR_VALID ){
56551 rc = saveCursorPosition(p);
56552 if( rc!=SQLITE_OK ){
56553 (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
56554 break;
56555 }
@@ -56951,10 +57090,12 @@
56951 ** to return an integer result code for historical reasons.
56952 */
56953 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
56954 assert( cursorHoldsMutex(pCur) );
56955 assert( pCur->eState==CURSOR_VALID );
 
 
56956 assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
56957 getCellInfo(pCur);
56958 *pSize = pCur->info.nPayload;
56959 return SQLITE_OK;
56960 }
@@ -57359,17 +57500,22 @@
57359 */
57360 static const void *fetchPayload(
57361 BtCursor *pCur, /* Cursor pointing to entry to read from */
57362 u32 *pAmt /* Write the number of available bytes here */
57363 ){
 
57364 assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
57365 assert( pCur->eState==CURSOR_VALID );
57366 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
57367 assert( cursorHoldsMutex(pCur) );
57368 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
57369 assert( pCur->info.nSize>0 );
57370 *pAmt = pCur->info.nLocal;
 
 
 
 
57371 return (void*)pCur->info.pPayload;
57372 }
57373
57374
57375 /*
@@ -57429,19 +57575,21 @@
57429 return SQLITE_CORRUPT_BKPT;
57430 }
57431 return SQLITE_OK;
57432 }
57433
57434 #if 0
57435 /*
57436 ** Page pParent is an internal (non-leaf) tree page. This function
57437 ** asserts that page number iChild is the left-child if the iIdx'th
57438 ** cell in page pParent. Or, if iIdx is equal to the total number of
57439 ** cells in pParent, that page number iChild is the right-child of
57440 ** the page.
57441 */
57442 static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
 
 
57443 assert( iIdx<=pParent->nCell );
57444 if( iIdx==pParent->nCell ){
57445 assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
57446 }else{
57447 assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57462,23 +57610,15 @@
57462 static void moveToParent(BtCursor *pCur){
57463 assert( cursorHoldsMutex(pCur) );
57464 assert( pCur->eState==CURSOR_VALID );
57465 assert( pCur->iPage>0 );
57466 assert( pCur->apPage[pCur->iPage] );
57467
57468 /* UPDATE: It is actually possible for the condition tested by the assert
57469 ** below to be untrue if the database file is corrupt. This can occur if
57470 ** one cursor has modified page pParent while a reference to it is held
57471 ** by a second cursor. Which can only happen if a single page is linked
57472 ** into more than one b-tree structure in a corrupt database. */
57473 #if 0
57474 assertParentIndex(
57475 pCur->apPage[pCur->iPage-1],
57476 pCur->aiIdx[pCur->iPage-1],
57477 pCur->apPage[pCur->iPage]->pgno
57478 );
57479 #endif
57480 testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
57481
57482 releasePage(pCur->apPage[pCur->iPage]);
57483 pCur->iPage--;
57484 pCur->info.nSize = 0;
@@ -59649,11 +59789,10 @@
59649 if( iParentIdx==0 ){
59650 nxDiv = 0;
59651 }else if( iParentIdx==i ){
59652 nxDiv = i-2+bBulk;
59653 }else{
59654 assert( bBulk==0 );
59655 nxDiv = iParentIdx-1;
59656 }
59657 i = 2-bBulk;
59658 }
59659 nOld = i+1;
@@ -60422,10 +60561,11 @@
60422 pPage->nOverflow = 0;
60423
60424 /* The next iteration of the do-loop balances the parent page. */
60425 releasePage(pPage);
60426 pCur->iPage--;
 
60427 }
60428 }while( rc==SQLITE_OK );
60429
60430 if( pFree ){
60431 sqlite3PageFree(pFree);
@@ -60898,13 +61038,17 @@
60898
60899 assert( sqlite3_mutex_held(pBt->mutex) );
60900 if( pgno>btreePagecount(pBt) ){
60901 return SQLITE_CORRUPT_BKPT;
60902 }
60903
60904 rc = getAndInitPage(pBt, pgno, &pPage, 0);
60905 if( rc ) return rc;
 
 
 
 
 
60906 hdr = pPage->hdrOffset;
60907 for(i=0; i<pPage->nCell; i++){
60908 pCell = findCell(pPage, i);
60909 if( !pPage->leaf ){
60910 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
@@ -60925,10 +61069,11 @@
60925 }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
60926 zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);
60927 }
60928
60929 cleardatabasepage_out:
 
60930 releasePage(pPage);
60931 return rc;
60932 }
60933
60934 /*
@@ -61431,10 +61576,61 @@
61431 iPage = get4byte(pOvflData);
61432 sqlite3PagerUnref(pOvflPage);
61433 }
61434 }
61435 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
61436
61437 #ifndef SQLITE_OMIT_INTEGRITY_CHECK
61438 /*
61439 ** Do various sanity checks on a single page of a tree. Return
61440 ** the tree depth. Root pages return 0. Parents of root pages
@@ -61464,11 +61660,12 @@
61464 int hdr, cellStart;
61465 int nCell;
61466 u8 *data;
61467 BtShared *pBt;
61468 int usableSize;
61469 char *hit = 0;
 
61470 i64 nMinKey = 0;
61471 i64 nMaxKey = 0;
61472 const char *saved_zPfx = pCheck->zPfx;
61473 int saved_v1 = pCheck->v1;
61474 int saved_v2 = pCheck->v2;
@@ -61609,19 +61806,19 @@
61609
61610 /* Check for complete coverage of the page
61611 */
61612 data = pPage->aData;
61613 hdr = pPage->hdrOffset;
61614 hit = sqlite3PageMalloc( pBt->pageSize );
61615 pCheck->zPfx = 0;
61616 if( hit==0 ){
61617 pCheck->mallocFailed = 1;
61618 }else{
61619 int contentOffset = get2byteNotZero(&data[hdr+5]);
61620 assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
61621 memset(hit+contentOffset, 0, usableSize-contentOffset);
61622 memset(hit, 1, contentOffset);
61623 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
61624 ** number of cells on the page. */
61625 nCell = get2byte(&data[hdr+3]);
61626 /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
61627 ** immediately follows the b-tree page header. */
@@ -61629,20 +61826,19 @@
61629 /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte
61630 ** integer offsets to the cell contents. */
61631 for(i=0; i<nCell; i++){
61632 int pc = get2byte(&data[cellStart+i*2]);
61633 u32 size = 65536;
61634 int j;
61635 if( pc<=usableSize-4 ){
61636 size = cellSizePtr(pPage, &data[pc]);
61637 }
61638 if( (int)(pc+size-1)>=usableSize ){
61639 pCheck->zPfx = 0;
61640 checkAppendMsg(pCheck,
61641 "Corruption detected in cell %d on page %d",i,iPage);
61642 }else{
61643 for(j=pc+size-1; j>=pc; j--) hit[j]++;
61644 }
61645 }
61646 /* EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
61647 ** is the offset of the first freeblock, or zero if there are no
61648 ** freeblocks on the page. */
@@ -61650,11 +61846,11 @@
61650 while( i>0 ){
61651 int size, j;
61652 assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */
61653 size = get2byte(&data[i+2]);
61654 assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */
61655 for(j=i+size-1; j>=i; j--) hit[j]++;
61656 /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a
61657 ** big-endian integer which is the offset in the b-tree page of the next
61658 ** freeblock in the chain, or zero if the freeblock is the last on the
61659 ** chain. */
61660 j = get2byte(&data[i]);
@@ -61662,31 +61858,37 @@
61662 ** increasing offset. */
61663 assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */
61664 assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */
61665 i = j;
61666 }
61667 for(i=cnt=0; i<usableSize; i++){
61668 if( hit[i]==0 ){
61669 cnt++;
61670 }else if( hit[i]>1 ){
 
 
61671 checkAppendMsg(pCheck,
61672 "Multiple uses for byte %d of page %d", i, iPage);
61673 break;
 
 
 
61674 }
61675 }
 
61676 /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments
61677 ** is stored in the fifth field of the b-tree page header.
61678 ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the
61679 ** number of fragmented free bytes within the cell content area.
61680 */
61681 if( cnt!=data[hdr+7] ){
61682 checkAppendMsg(pCheck,
61683 "Fragmentation of %d bytes reported as %d on page %d",
61684 cnt, data[hdr+7], iPage);
61685 }
61686 }
61687 sqlite3PageFree(hit);
61688 releasePage(pPage);
61689
61690 end_of_check:
61691 pCheck->zPfx = saved_zPfx;
61692 pCheck->v1 = saved_v1;
@@ -61746,12 +61948,11 @@
61746 sqlite3BtreeLeave(p);
61747 return 0;
61748 }
61749 i = PENDING_BYTE_PAGE(pBt);
61750 if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);
61751 sqlite3StrAccumInit(&sCheck.errMsg, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
61752 sCheck.errMsg.useMalloc = 2;
61753
61754 /* Check the integrity of the freelist
61755 */
61756 sCheck.zPfx = "Main freelist: ";
61757 checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
@@ -62239,11 +62440,11 @@
62239 ** a pointer to the new sqlite3_backup object.
62240 **
62241 ** If an error occurs, NULL is returned and an error code and error message
62242 ** stored in database handle pDestDb.
62243 */
62244 SQLITE_API sqlite3_backup *sqlite3_backup_init(
62245 sqlite3* pDestDb, /* Database to write to */
62246 const char *zDestDb, /* Name of database within pDestDb */
62247 sqlite3* pSrcDb, /* Database connection to read from */
62248 const char *zSrcDb /* Name of database within pSrcDb */
62249 ){
@@ -62447,11 +62648,11 @@
62447 }
62448
62449 /*
62450 ** Copy nPage pages from the source b-tree to the destination.
62451 */
62452 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage){
62453 int rc;
62454 int destMode; /* Destination journal mode */
62455 int pgszSrc = 0; /* Source page size */
62456 int pgszDest = 0; /* Destination page size */
62457
@@ -62692,11 +62893,11 @@
62692 }
62693
62694 /*
62695 ** Release all resources associated with an sqlite3_backup* handle.
62696 */
62697 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p){
62698 sqlite3_backup **pp; /* Ptr to head of pagers backup list */
62699 sqlite3 *pSrcDb; /* Source database connection */
62700 int rc; /* Value to return */
62701
62702 /* Enter the mutexes */
@@ -62744,11 +62945,11 @@
62744
62745 /*
62746 ** Return the number of pages still to be backed up as of the most recent
62747 ** call to sqlite3_backup_step().
62748 */
62749 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p){
62750 #ifdef SQLITE_ENABLE_API_ARMOR
62751 if( p==0 ){
62752 (void)SQLITE_MISUSE_BKPT;
62753 return 0;
62754 }
@@ -62758,11 +62959,11 @@
62758
62759 /*
62760 ** Return the total number of pages in the source database as of the most
62761 ** recent call to sqlite3_backup_step().
62762 */
62763 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p){
62764 #ifdef SQLITE_ENABLE_API_ARMOR
62765 if( p==0 ){
62766 (void)SQLITE_MISUSE_BKPT;
62767 return 0;
62768 }
@@ -63083,14 +63284,15 @@
63083 return SQLITE_NOMEM;
63084 }
63085 pMem->z[pMem->n] = 0;
63086 pMem->z[pMem->n+1] = 0;
63087 pMem->flags |= MEM_Term;
 
 
63088 #ifdef SQLITE_DEBUG
63089 pMem->pScopyFrom = 0;
63090 #endif
63091 }
63092
63093 return SQLITE_OK;
63094 }
63095
63096 /*
@@ -64530,11 +64732,11 @@
64530 int i;
64531 int nCol = pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField;
64532 Mem *aMem = pRec->aMem;
64533 sqlite3 *db = aMem[0].db;
64534 for(i=0; i<nCol; i++){
64535 if( aMem[i].szMalloc ) sqlite3DbFree(db, aMem[i].zMalloc);
64536 }
64537 sqlite3KeyInfoUnref(pRec->pKeyInfo);
64538 sqlite3DbFree(db, pRec);
64539 }
64540 }
@@ -64633,11 +64835,11 @@
64633 }
64634
64635 /*
64636 ** Return the SQL associated with a prepared statement
64637 */
64638 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt){
64639 Vdbe *p = (Vdbe *)pStmt;
64640 return (p && p->isPrepareV2) ? p->zSql : 0;
64641 }
64642
64643 /*
@@ -66366,18 +66568,35 @@
66366 pVtabCursor->pVtab->nRef--;
66367 pModule->xClose(pVtabCursor);
66368 }
66369 #endif
66370 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
66371
66372 /*
66373 ** Copy the values stored in the VdbeFrame structure to its Vdbe. This
66374 ** is used, for example, when a trigger sub-program is halted to restore
66375 ** control to the main program.
66376 */
66377 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
66378 Vdbe *v = pFrame->v;
 
66379 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
66380 v->anExec = pFrame->anExec;
66381 #endif
66382 v->aOnceFlag = pFrame->aOnceFlag;
66383 v->nOnceFlag = pFrame->nOnceFlag;
@@ -66408,21 +66627,11 @@
66408 sqlite3VdbeFrameRestore(pFrame);
66409 p->pFrame = 0;
66410 p->nFrame = 0;
66411 }
66412 assert( p->nFrame==0 );
66413
66414 if( p->apCsr ){
66415 int i;
66416 for(i=0; i<p->nCursor; i++){
66417 VdbeCursor *pC = p->apCsr[i];
66418 if( pC ){
66419 sqlite3VdbeFreeCursor(p, pC);
66420 p->apCsr[i] = 0;
66421 }
66422 }
66423 }
66424 if( p->aMem ){
66425 releaseMemArray(&p->aMem[1], p->nMem);
66426 }
66427 while( p->pDelFrame ){
66428 VdbeFrame *pDel = p->pDelFrame;
@@ -68163,11 +68372,11 @@
68163 ** If database corruption is discovered, set pPKey2->errCode to
68164 ** SQLITE_CORRUPT and return 0. If an OOM error is encountered,
68165 ** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the
68166 ** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).
68167 */
68168 static int vdbeRecordCompareWithSkip(
68169 int nKey1, const void *pKey1, /* Left key */
68170 UnpackedRecord *pPKey2, /* Right key */
68171 int bSkip /* If true, skip the first field */
68172 ){
68173 u32 d1; /* Offset into aKey[] of next data element */
@@ -68349,11 +68558,11 @@
68349 }
68350 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
68351 int nKey1, const void *pKey1, /* Left key */
68352 UnpackedRecord *pPKey2 /* Right key */
68353 ){
68354 return vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
68355 }
68356
68357
68358 /*
68359 ** This function is an optimized version of sqlite3VdbeRecordCompare()
@@ -68437,11 +68646,11 @@
68437 }else if( v<lhs ){
68438 res = pPKey2->r2;
68439 }else if( pPKey2->nField>1 ){
68440 /* The first fields of the two keys are equal. Compare the trailing
68441 ** fields. */
68442 res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68443 }else{
68444 /* The first fields of the two keys are equal and there are no trailing
68445 ** fields. Return pPKey2->default_rc in this case. */
68446 res = pPKey2->default_rc;
68447 }
@@ -68485,11 +68694,11 @@
68485
68486 if( res==0 ){
68487 res = nStr - pPKey2->aMem[0].n;
68488 if( res==0 ){
68489 if( pPKey2->nField>1 ){
68490 res = vdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68491 }else{
68492 res = pPKey2->default_rc;
68493 }
68494 }else if( res>0 ){
68495 res = pPKey2->r2;
@@ -68789,11 +68998,11 @@
68789 ** execution environment changes in a way that would alter the program
68790 ** that sqlite3_prepare() generates. For example, if new functions or
68791 ** collating sequences are registered or if an authorizer function is
68792 ** added or changed.
68793 */
68794 SQLITE_API int sqlite3_expired(sqlite3_stmt *pStmt){
68795 Vdbe *p = (Vdbe*)pStmt;
68796 return p==0 || p->expired;
68797 }
68798 #endif
68799
@@ -68826,11 +69035,11 @@
68826 ** machine.
68827 **
68828 ** This routine sets the error code and string returned by
68829 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68830 */
68831 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt){
68832 int rc;
68833 if( pStmt==0 ){
68834 /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
68835 ** pointer is a harmless no-op. */
68836 rc = SQLITE_OK;
@@ -68852,11 +69061,11 @@
68852 ** the prior execution is returned.
68853 **
68854 ** This routine sets the error code and string returned by
68855 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
68856 */
68857 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt){
68858 int rc;
68859 if( pStmt==0 ){
68860 rc = SQLITE_OK;
68861 }else{
68862 Vdbe *v = (Vdbe*)pStmt;
@@ -68871,11 +69080,11 @@
68871 }
68872
68873 /*
68874 ** Set all the parameters in the compiled SQL statement to NULL.
68875 */
68876 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *pStmt){
68877 int i;
68878 int rc = SQLITE_OK;
68879 Vdbe *p = (Vdbe*)pStmt;
68880 #if SQLITE_THREADSAFE
68881 sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68895,54 +69104,54 @@
68895
68896 /**************************** sqlite3_value_ *******************************
68897 ** The following routines extract information from a Mem or sqlite3_value
68898 ** structure.
68899 */
68900 SQLITE_API const void *sqlite3_value_blob(sqlite3_value *pVal){
68901 Mem *p = (Mem*)pVal;
68902 if( p->flags & (MEM_Blob|MEM_Str) ){
68903 sqlite3VdbeMemExpandBlob(p);
68904 p->flags |= MEM_Blob;
68905 return p->n ? p->z : 0;
68906 }else{
68907 return sqlite3_value_text(pVal);
68908 }
68909 }
68910 SQLITE_API int sqlite3_value_bytes(sqlite3_value *pVal){
68911 return sqlite3ValueBytes(pVal, SQLITE_UTF8);
68912 }
68913 SQLITE_API int sqlite3_value_bytes16(sqlite3_value *pVal){
68914 return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
68915 }
68916 SQLITE_API double sqlite3_value_double(sqlite3_value *pVal){
68917 return sqlite3VdbeRealValue((Mem*)pVal);
68918 }
68919 SQLITE_API int sqlite3_value_int(sqlite3_value *pVal){
68920 return (int)sqlite3VdbeIntValue((Mem*)pVal);
68921 }
68922 SQLITE_API sqlite_int64 sqlite3_value_int64(sqlite3_value *pVal){
68923 return sqlite3VdbeIntValue((Mem*)pVal);
68924 }
68925 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *pVal){
68926 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
68927 }
68928 #ifndef SQLITE_OMIT_UTF16
68929 SQLITE_API const void *sqlite3_value_text16(sqlite3_value* pVal){
68930 return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
68931 }
68932 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *pVal){
68933 return sqlite3ValueText(pVal, SQLITE_UTF16BE);
68934 }
68935 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *pVal){
68936 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
68937 }
68938 #endif /* SQLITE_OMIT_UTF16 */
68939 /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
68940 ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
68941 ** point number string BLOB NULL
68942 */
68943 SQLITE_API int sqlite3_value_type(sqlite3_value* pVal){
68944 static const u8 aType[] = {
68945 SQLITE_BLOB, /* 0x00 */
68946 SQLITE_NULL, /* 0x01 */
68947 SQLITE_TEXT, /* 0x02 */
68948 SQLITE_NULL, /* 0x03 */
@@ -69014,21 +69223,21 @@
69014 xDel((void*)p);
69015 }
69016 if( pCtx ) sqlite3_result_error_toobig(pCtx);
69017 return SQLITE_TOOBIG;
69018 }
69019 SQLITE_API void sqlite3_result_blob(
69020 sqlite3_context *pCtx,
69021 const void *z,
69022 int n,
69023 void (*xDel)(void *)
69024 ){
69025 assert( n>=0 );
69026 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69027 setResultStrOrError(pCtx, z, n, 0, xDel);
69028 }
69029 SQLITE_API void sqlite3_result_blob64(
69030 sqlite3_context *pCtx,
69031 const void *z,
69032 sqlite3_uint64 n,
69033 void (*xDel)(void *)
69034 ){
@@ -69038,50 +69247,50 @@
69038 (void)invokeValueDestructor(z, xDel, pCtx);
69039 }else{
69040 setResultStrOrError(pCtx, z, (int)n, 0, xDel);
69041 }
69042 }
69043 SQLITE_API void sqlite3_result_double(sqlite3_context *pCtx, double rVal){
69044 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69045 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
69046 }
69047 SQLITE_API void sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
69048 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69049 pCtx->isError = SQLITE_ERROR;
69050 pCtx->fErrorOrAux = 1;
69051 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
69052 }
69053 #ifndef SQLITE_OMIT_UTF16
69054 SQLITE_API void sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
69055 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69056 pCtx->isError = SQLITE_ERROR;
69057 pCtx->fErrorOrAux = 1;
69058 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
69059 }
69060 #endif
69061 SQLITE_API void sqlite3_result_int(sqlite3_context *pCtx, int iVal){
69062 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69063 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
69064 }
69065 SQLITE_API void sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
69066 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69067 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
69068 }
69069 SQLITE_API void sqlite3_result_null(sqlite3_context *pCtx){
69070 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69071 sqlite3VdbeMemSetNull(pCtx->pOut);
69072 }
69073 SQLITE_API void sqlite3_result_text(
69074 sqlite3_context *pCtx,
69075 const char *z,
69076 int n,
69077 void (*xDel)(void *)
69078 ){
69079 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69080 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
69081 }
69082 SQLITE_API void sqlite3_result_text64(
69083 sqlite3_context *pCtx,
69084 const char *z,
69085 sqlite3_uint64 n,
69086 void (*xDel)(void *),
69087 unsigned char enc
@@ -69094,47 +69303,47 @@
69094 }else{
69095 setResultStrOrError(pCtx, z, (int)n, enc, xDel);
69096 }
69097 }
69098 #ifndef SQLITE_OMIT_UTF16
69099 SQLITE_API void sqlite3_result_text16(
69100 sqlite3_context *pCtx,
69101 const void *z,
69102 int n,
69103 void (*xDel)(void *)
69104 ){
69105 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69106 setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
69107 }
69108 SQLITE_API void sqlite3_result_text16be(
69109 sqlite3_context *pCtx,
69110 const void *z,
69111 int n,
69112 void (*xDel)(void *)
69113 ){
69114 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69115 setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
69116 }
69117 SQLITE_API void sqlite3_result_text16le(
69118 sqlite3_context *pCtx,
69119 const void *z,
69120 int n,
69121 void (*xDel)(void *)
69122 ){
69123 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69124 setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
69125 }
69126 #endif /* SQLITE_OMIT_UTF16 */
69127 SQLITE_API void sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
69128 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69129 sqlite3VdbeMemCopy(pCtx->pOut, pValue);
69130 }
69131 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
69132 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69133 sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
69134 }
69135 SQLITE_API void sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
69136 pCtx->isError = errCode;
69137 pCtx->fErrorOrAux = 1;
69138 #ifdef SQLITE_DEBUG
69139 if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
69140 #endif
@@ -69143,20 +69352,20 @@
69143 SQLITE_UTF8, SQLITE_STATIC);
69144 }
69145 }
69146
69147 /* Force an SQLITE_TOOBIG error. */
69148 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *pCtx){
69149 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69150 pCtx->isError = SQLITE_TOOBIG;
69151 pCtx->fErrorOrAux = 1;
69152 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
69153 SQLITE_UTF8, SQLITE_STATIC);
69154 }
69155
69156 /* An SQLITE_NOMEM error. */
69157 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *pCtx){
69158 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69159 sqlite3VdbeMemSetNull(pCtx->pOut);
69160 pCtx->isError = SQLITE_NOMEM;
69161 pCtx->fErrorOrAux = 1;
69162 pCtx->pOut->db->mallocFailed = 1;
@@ -69325,11 +69534,11 @@
69325 /*
69326 ** This is the top-level implementation of sqlite3_step(). Call
69327 ** sqlite3Step() to do most of the work. If a schema error occurs,
69328 ** call sqlite3Reprepare() and try again.
69329 */
69330 SQLITE_API int sqlite3_step(sqlite3_stmt *pStmt){
69331 int rc = SQLITE_OK; /* Result from sqlite3Step() */
69332 int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
69333 Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
69334 int cnt = 0; /* Counter to prevent infinite loop of reprepares */
69335 sqlite3 *db; /* The database connection */
@@ -69376,11 +69585,11 @@
69376
69377 /*
69378 ** Extract the user data from a sqlite3_context structure and return a
69379 ** pointer to it.
69380 */
69381 SQLITE_API void *sqlite3_user_data(sqlite3_context *p){
69382 assert( p && p->pFunc );
69383 return p->pFunc->pUserData;
69384 }
69385
69386 /*
@@ -69391,11 +69600,11 @@
69391 ** returns a copy of the pointer to the database connection (the 1st
69392 ** parameter) of the sqlite3_create_function() and
69393 ** sqlite3_create_function16() routines that originally registered the
69394 ** application defined function.
69395 */
69396 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *p){
69397 assert( p && p->pFunc );
69398 return p->pOut->db;
69399 }
69400
69401 /*
@@ -69467,11 +69676,11 @@
69467 /*
69468 ** Allocate or return the aggregate context for a user function. A new
69469 ** context is allocated on the first call. Subsequent calls return the
69470 ** same context that was returned on prior calls.
69471 */
69472 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69473 assert( p && p->pFunc && p->pFunc->xStep );
69474 assert( sqlite3_mutex_held(p->pOut->db->mutex) );
69475 testcase( nByte<0 );
69476 if( (p->pMem->flags & MEM_Agg)==0 ){
69477 return createAggContext(p, nByte);
@@ -69482,11 +69691,11 @@
69482
69483 /*
69484 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
69485 ** the user-function defined by pCtx.
69486 */
69487 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69488 AuxData *pAuxData;
69489
69490 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69491 #if SQLITE_ENABLE_STAT3_OR_STAT4
69492 if( pCtx->pVdbe==0 ) return 0;
@@ -69503,11 +69712,11 @@
69503 /*
69504 ** Set the auxiliary data pointer and delete function, for the iArg'th
69505 ** argument to the user-function defined by pCtx. Any previous value is
69506 ** deleted by calling the delete function specified when it was set.
69507 */
69508 SQLITE_API void sqlite3_set_auxdata(
69509 sqlite3_context *pCtx,
69510 int iArg,
69511 void *pAux,
69512 void (*xDelete)(void*)
69513 ){
@@ -69558,29 +69767,29 @@
69558 ** This function is deprecated. Do not use it for new code. It is
69559 ** provide only to avoid breaking legacy code. New aggregate function
69560 ** implementations should keep their own counts within their aggregate
69561 ** context.
69562 */
69563 SQLITE_API int sqlite3_aggregate_count(sqlite3_context *p){
69564 assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
69565 return p->pMem->n;
69566 }
69567 #endif
69568
69569 /*
69570 ** Return the number of columns in the result set for the statement pStmt.
69571 */
69572 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt){
69573 Vdbe *pVm = (Vdbe *)pStmt;
69574 return pVm ? pVm->nResColumn : 0;
69575 }
69576
69577 /*
69578 ** Return the number of values available from the current row of the
69579 ** currently executing statement pStmt.
69580 */
69581 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt){
69582 Vdbe *pVm = (Vdbe *)pStmt;
69583 if( pVm==0 || pVm->pResultSet==0 ) return 0;
69584 return pVm->nResColumn;
69585 }
69586
@@ -69678,67 +69887,67 @@
69678
69679 /**************************** sqlite3_column_ *******************************
69680 ** The following routines are used to access elements of the current row
69681 ** in the result set.
69682 */
69683 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69684 const void *val;
69685 val = sqlite3_value_blob( columnMem(pStmt,i) );
69686 /* Even though there is no encoding conversion, value_blob() might
69687 ** need to call malloc() to expand the result of a zeroblob()
69688 ** expression.
69689 */
69690 columnMallocFailure(pStmt);
69691 return val;
69692 }
69693 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69694 int val = sqlite3_value_bytes( columnMem(pStmt,i) );
69695 columnMallocFailure(pStmt);
69696 return val;
69697 }
69698 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69699 int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
69700 columnMallocFailure(pStmt);
69701 return val;
69702 }
69703 SQLITE_API double sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69704 double val = sqlite3_value_double( columnMem(pStmt,i) );
69705 columnMallocFailure(pStmt);
69706 return val;
69707 }
69708 SQLITE_API int sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69709 int val = sqlite3_value_int( columnMem(pStmt,i) );
69710 columnMallocFailure(pStmt);
69711 return val;
69712 }
69713 SQLITE_API sqlite_int64 sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69714 sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
69715 columnMallocFailure(pStmt);
69716 return val;
69717 }
69718 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69719 const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
69720 columnMallocFailure(pStmt);
69721 return val;
69722 }
69723 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69724 Mem *pOut = columnMem(pStmt, i);
69725 if( pOut->flags&MEM_Static ){
69726 pOut->flags &= ~MEM_Static;
69727 pOut->flags |= MEM_Ephem;
69728 }
69729 columnMallocFailure(pStmt);
69730 return (sqlite3_value *)pOut;
69731 }
69732 #ifndef SQLITE_OMIT_UTF16
69733 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69734 const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
69735 columnMallocFailure(pStmt);
69736 return val;
69737 }
69738 #endif /* SQLITE_OMIT_UTF16 */
69739 SQLITE_API int sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69740 int iType = sqlite3_value_type( columnMem(pStmt,i) );
69741 columnMallocFailure(pStmt);
69742 return iType;
69743 }
69744
@@ -69798,16 +70007,16 @@
69798
69799 /*
69800 ** Return the name of the Nth column of the result set returned by SQL
69801 ** statement pStmt.
69802 */
69803 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *pStmt, int N){
69804 return columnName(
69805 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
69806 }
69807 #ifndef SQLITE_OMIT_UTF16
69808 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
69809 return columnName(
69810 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
69811 }
69812 #endif
69813
@@ -69823,16 +70032,16 @@
69823 #ifndef SQLITE_OMIT_DECLTYPE
69824 /*
69825 ** Return the column declaration type (if applicable) of the 'i'th column
69826 ** of the result set of SQL statement pStmt.
69827 */
69828 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
69829 return columnName(
69830 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
69831 }
69832 #ifndef SQLITE_OMIT_UTF16
69833 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
69834 return columnName(
69835 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
69836 }
69837 #endif /* SQLITE_OMIT_UTF16 */
69838 #endif /* SQLITE_OMIT_DECLTYPE */
@@ -69841,16 +70050,16 @@
69841 /*
69842 ** Return the name of the database from which a result column derives.
69843 ** NULL is returned if the result column is an expression or constant or
69844 ** anything else which is not an unambiguous reference to a database column.
69845 */
69846 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
69847 return columnName(
69848 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
69849 }
69850 #ifndef SQLITE_OMIT_UTF16
69851 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
69852 return columnName(
69853 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
69854 }
69855 #endif /* SQLITE_OMIT_UTF16 */
69856
@@ -69857,16 +70066,16 @@
69857 /*
69858 ** Return the name of the table from which a result column derives.
69859 ** NULL is returned if the result column is an expression or constant or
69860 ** anything else which is not an unambiguous reference to a database column.
69861 */
69862 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
69863 return columnName(
69864 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
69865 }
69866 #ifndef SQLITE_OMIT_UTF16
69867 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
69868 return columnName(
69869 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
69870 }
69871 #endif /* SQLITE_OMIT_UTF16 */
69872
@@ -69873,16 +70082,16 @@
69873 /*
69874 ** Return the name of the table column from which a result column derives.
69875 ** NULL is returned if the result column is an expression or constant or
69876 ** anything else which is not an unambiguous reference to a database column.
69877 */
69878 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
69879 return columnName(
69880 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
69881 }
69882 #ifndef SQLITE_OMIT_UTF16
69883 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
69884 return columnName(
69885 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
69886 }
69887 #endif /* SQLITE_OMIT_UTF16 */
69888 #endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69979,20 +70188,20 @@
69979
69980
69981 /*
69982 ** Bind a blob value to an SQL statement variable.
69983 */
69984 SQLITE_API int sqlite3_bind_blob(
69985 sqlite3_stmt *pStmt,
69986 int i,
69987 const void *zData,
69988 int nData,
69989 void (*xDel)(void*)
69990 ){
69991 return bindText(pStmt, i, zData, nData, xDel, 0);
69992 }
69993 SQLITE_API int sqlite3_bind_blob64(
69994 sqlite3_stmt *pStmt,
69995 int i,
69996 const void *zData,
69997 sqlite3_uint64 nData,
69998 void (*xDel)(void*)
@@ -70002,52 +70211,52 @@
70002 return invokeValueDestructor(zData, xDel, 0);
70003 }else{
70004 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
70005 }
70006 }
70007 SQLITE_API int sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
70008 int rc;
70009 Vdbe *p = (Vdbe *)pStmt;
70010 rc = vdbeUnbind(p, i);
70011 if( rc==SQLITE_OK ){
70012 sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
70013 sqlite3_mutex_leave(p->db->mutex);
70014 }
70015 return rc;
70016 }
70017 SQLITE_API int sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
70018 return sqlite3_bind_int64(p, i, (i64)iValue);
70019 }
70020 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
70021 int rc;
70022 Vdbe *p = (Vdbe *)pStmt;
70023 rc = vdbeUnbind(p, i);
70024 if( rc==SQLITE_OK ){
70025 sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
70026 sqlite3_mutex_leave(p->db->mutex);
70027 }
70028 return rc;
70029 }
70030 SQLITE_API int sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
70031 int rc;
70032 Vdbe *p = (Vdbe*)pStmt;
70033 rc = vdbeUnbind(p, i);
70034 if( rc==SQLITE_OK ){
70035 sqlite3_mutex_leave(p->db->mutex);
70036 }
70037 return rc;
70038 }
70039 SQLITE_API int sqlite3_bind_text(
70040 sqlite3_stmt *pStmt,
70041 int i,
70042 const char *zData,
70043 int nData,
70044 void (*xDel)(void*)
70045 ){
70046 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
70047 }
70048 SQLITE_API int sqlite3_bind_text64(
70049 sqlite3_stmt *pStmt,
70050 int i,
70051 const char *zData,
70052 sqlite3_uint64 nData,
70053 void (*xDel)(void*),
@@ -70060,21 +70269,21 @@
70060 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
70061 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
70062 }
70063 }
70064 #ifndef SQLITE_OMIT_UTF16
70065 SQLITE_API int sqlite3_bind_text16(
70066 sqlite3_stmt *pStmt,
70067 int i,
70068 const void *zData,
70069 int nData,
70070 void (*xDel)(void*)
70071 ){
70072 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
70073 }
70074 #endif /* SQLITE_OMIT_UTF16 */
70075 SQLITE_API int sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
70076 int rc;
70077 switch( sqlite3_value_type((sqlite3_value*)pValue) ){
70078 case SQLITE_INTEGER: {
70079 rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
70080 break;
@@ -70101,11 +70310,11 @@
70101 break;
70102 }
70103 }
70104 return rc;
70105 }
70106 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
70107 int rc;
70108 Vdbe *p = (Vdbe *)pStmt;
70109 rc = vdbeUnbind(p, i);
70110 if( rc==SQLITE_OK ){
70111 sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -70116,11 +70325,11 @@
70116
70117 /*
70118 ** Return the number of wildcards that can be potentially bound to.
70119 ** This routine is added to support DBD::SQLite.
70120 */
70121 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
70122 Vdbe *p = (Vdbe*)pStmt;
70123 return p ? p->nVar : 0;
70124 }
70125
70126 /*
@@ -70127,11 +70336,11 @@
70127 ** Return the name of a wildcard parameter. Return NULL if the index
70128 ** is out of range or if the wildcard is unnamed.
70129 **
70130 ** The result is always UTF-8.
70131 */
70132 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
70133 Vdbe *p = (Vdbe*)pStmt;
70134 if( p==0 || i<1 || i>p->nzVar ){
70135 return 0;
70136 }
70137 return p->azVar[i-1];
@@ -70155,11 +70364,11 @@
70155 }
70156 }
70157 }
70158 return 0;
70159 }
70160 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
70161 return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
70162 }
70163
70164 /*
70165 ** Transfer all bindings from the first statement over to the second.
@@ -70189,11 +70398,11 @@
70189 **
70190 ** If the two statements contain a different number of bindings, then
70191 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
70192 ** SQLITE_OK is returned.
70193 */
70194 SQLITE_API int sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
70195 Vdbe *pFrom = (Vdbe*)pFromStmt;
70196 Vdbe *pTo = (Vdbe*)pToStmt;
70197 if( pFrom->nVar!=pTo->nVar ){
70198 return SQLITE_ERROR;
70199 }
@@ -70211,26 +70420,26 @@
70211 ** Return the sqlite3* database handle to which the prepared statement given
70212 ** in the argument belongs. This is the same database handle that was
70213 ** the first argument to the sqlite3_prepare() that was used to create
70214 ** the statement in the first place.
70215 */
70216 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *pStmt){
70217 return pStmt ? ((Vdbe*)pStmt)->db : 0;
70218 }
70219
70220 /*
70221 ** Return true if the prepared statement is guaranteed to not modify the
70222 ** database.
70223 */
70224 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
70225 return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
70226 }
70227
70228 /*
70229 ** Return true if the prepared statement is in need of being reset.
70230 */
70231 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *pStmt){
70232 Vdbe *v = (Vdbe*)pStmt;
70233 return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
70234 }
70235
70236 /*
@@ -70237,11 +70446,11 @@
70237 ** Return a pointer to the next prepared statement after pStmt associated
70238 ** with database connection pDb. If pStmt is NULL, return the first
70239 ** prepared statement for the database connection. Return NULL if there
70240 ** are no more.
70241 */
70242 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
70243 sqlite3_stmt *pNext;
70244 #ifdef SQLITE_ENABLE_API_ARMOR
70245 if( !sqlite3SafetyCheckOk(pDb) ){
70246 (void)SQLITE_MISUSE_BKPT;
70247 return 0;
@@ -70258,11 +70467,11 @@
70258 }
70259
70260 /*
70261 ** Return the value of a status counter for a prepared statement
70262 */
70263 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
70264 Vdbe *pVdbe = (Vdbe*)pStmt;
70265 u32 v;
70266 #ifdef SQLITE_ENABLE_API_ARMOR
70267 if( !pStmt ){
70268 (void)SQLITE_MISUSE_BKPT;
@@ -70276,11 +70485,11 @@
70276
70277 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
70278 /*
70279 ** Return status data for a single loop within query pStmt.
70280 */
70281 SQLITE_API int sqlite3_stmt_scanstatus(
70282 sqlite3_stmt *pStmt, /* Prepared statement being queried */
70283 int idx, /* Index of loop to report on */
70284 int iScanStatusOp, /* Which metric to return */
70285 void *pOut /* OUT: Write the answer here */
70286 ){
@@ -70335,11 +70544,11 @@
70335 }
70336
70337 /*
70338 ** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
70339 */
70340 SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70341 Vdbe *p = (Vdbe*)pStmt;
70342 memset(p->anExec, 0, p->nOp * sizeof(i64));
70343 }
70344 #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
70345
@@ -70427,21 +70636,22 @@
70427 Mem *pVar; /* Value of a host parameter */
70428 StrAccum out; /* Accumulate the output here */
70429 char zBase[100]; /* Initial working space */
70430
70431 db = p->db;
70432 sqlite3StrAccumInit(&out, zBase, sizeof(zBase),
70433 db->aLimit[SQLITE_LIMIT_LENGTH]);
70434 out.db = db;
70435 if( db->nVdbeExec>1 ){
70436 while( *zRawSql ){
70437 const char *zStart = zRawSql;
70438 while( *(zRawSql++)!='\n' && *zRawSql );
70439 sqlite3StrAccumAppend(&out, "-- ", 3);
70440 assert( (zRawSql - zStart) > 0 );
70441 sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
70442 }
 
 
70443 }else{
70444 while( zRawSql[0] ){
70445 n = findNextHostParameter(zRawSql, &nToken);
70446 assert( n>0 );
70447 sqlite3StrAccumAppend(&out, zRawSql, n);
@@ -70454,14 +70664,16 @@
70454 sqlite3GetInt32(&zRawSql[1], &idx);
70455 }else{
70456 idx = nextIndex;
70457 }
70458 }else{
70459 assert( zRawSql[0]==':' || zRawSql[0]=='$' || zRawSql[0]=='@' );
 
70460 testcase( zRawSql[0]==':' );
70461 testcase( zRawSql[0]=='$' );
70462 testcase( zRawSql[0]=='@' );
 
70463 idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);
70464 assert( idx>0 );
70465 }
70466 zRawSql += nToken;
70467 nextIndex = idx + 1;
@@ -70834,11 +71046,11 @@
70834 ** Try to convert the type of a function argument or a result column
70835 ** into a numeric representation. Use either INTEGER or REAL whichever
70836 ** is appropriate. But only do the conversion if it is possible without
70837 ** loss of information and return the revised type of the argument.
70838 */
70839 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *pVal){
70840 int eType = sqlite3_value_type(pVal);
70841 if( eType==SQLITE_TEXT ){
70842 Mem *pMem = (Mem*)pVal;
70843 applyNumericAffinity(pMem, 0);
70844 eType = sqlite3_value_type(pVal);
@@ -71132,21 +71344,38 @@
71132 assert( n==(db->nSavepoint + db->isTransactionSavepoint) );
71133 return 1;
71134 }
71135 #endif
71136
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71137
71138 /*
71139 ** Execute as much of a VDBE program as we can.
71140 ** This is the core of sqlite3_step().
71141 */
71142 SQLITE_PRIVATE int sqlite3VdbeExec(
71143 Vdbe *p /* The VDBE */
71144 ){
71145 int pc=0; /* The program counter */
71146 Op *aOp = p->aOp; /* Copy of p->aOp */
71147 Op *pOp; /* Current operation */
 
 
 
71148 int rc = SQLITE_OK; /* Value to return */
71149 sqlite3 *db = p->db; /* The database */
71150 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
71151 u8 encoding = ENC(db); /* The database encoding */
71152 int iCompare = 0; /* Result of last OP_Compare operation */
@@ -71218,27 +71447,26 @@
71218 }
71219 if( p->db->flags & SQLITE_VdbeTrace ) printf("VDBE Trace:\n");
71220 }
71221 sqlite3EndBenignMalloc();
71222 #endif
71223 for(pc=p->pc; rc==SQLITE_OK; pc++){
71224 assert( pc>=0 && pc<p->nOp );
71225 if( db->mallocFailed ) goto no_mem;
71226 #ifdef VDBE_PROFILE
71227 start = sqlite3Hwtime();
71228 #endif
71229 nVmStep++;
71230 pOp = &aOp[pc];
71231 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
71232 if( p->anExec ) p->anExec[pc]++;
71233 #endif
71234
71235 /* Only allow tracing if SQLITE_DEBUG is defined.
71236 */
71237 #ifdef SQLITE_DEBUG
71238 if( db->flags & SQLITE_VdbeTrace ){
71239 sqlite3VdbePrintOp(stdout, pc, pOp);
71240 }
71241 #endif
71242
71243
71244 /* Check to see if we need to simulate an interrupt. This only happens
@@ -71251,27 +71479,13 @@
71251 sqlite3_interrupt(db);
71252 }
71253 }
71254 #endif
71255
71256 /* On any opcode with the "out2-prerelease" tag, free any
71257 ** external allocations out of mem[p2] and set mem[p2] to be
71258 ** an undefined integer. Opcodes will either fill in the integer
71259 ** value or convert mem[p2] to a different type.
71260 */
71261 assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
71262 if( pOp->opflags & OPFLG_OUT2_PRERELEASE ){
71263 assert( pOp->p2>0 );
71264 assert( pOp->p2<=(p->nMem-p->nCursor) );
71265 pOut = &aMem[pOp->p2];
71266 memAboutToChange(p, pOut);
71267 if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
71268 pOut->flags = MEM_Int;
71269 }
71270
71271 /* Sanity checking on other operands */
71272 #ifdef SQLITE_DEBUG
 
71273 if( (pOp->opflags & OPFLG_IN1)!=0 ){
71274 assert( pOp->p1>0 );
71275 assert( pOp->p1<=(p->nMem-p->nCursor) );
71276 assert( memIsValid(&aMem[pOp->p1]) );
71277 assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );
@@ -71300,10 +71514,13 @@
71300 assert( pOp->p3>0 );
71301 assert( pOp->p3<=(p->nMem-p->nCursor) );
71302 memAboutToChange(p, &aMem[pOp->p3]);
71303 }
71304 #endif
 
 
 
71305
71306 switch( pOp->opcode ){
71307
71308 /*****************************************************************************
71309 ** What follows is a massive switch statement where each case implements a
@@ -71323,11 +71540,11 @@
71323 ** case statement is followed by a comment of the form "/# same as ... #/"
71324 ** that comment is used to determine the particular value of the opcode.
71325 **
71326 ** Other keywords in the comment that follows each case are used to
71327 ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].
71328 ** Keywords include: in1, in2, in3, out2_prerelease, out2, out3. See
71329 ** the mkopcodeh.awk script for additional information.
71330 **
71331 ** Documentation about VDBE opcodes is generated by scanning this file
71332 ** for lines of that contain "Opcode:". That line and all subsequent
71333 ** comment lines are used in the generation of the opcode.html documentation
@@ -71351,11 +71568,12 @@
71351 ** is sometimes set to 1 instead of 0 as a hint to the command-line shell
71352 ** that this Goto is the bottom of a loop and that the lines from P2 down
71353 ** to the current line should be indented for EXPLAIN output.
71354 */
71355 case OP_Goto: { /* jump */
71356 pc = pOp->p2 - 1;
 
71357
71358 /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,
71359 ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon
71360 ** completion. Check to see if sqlite3_interrupt() has been called
71361 ** or if the progress callback needs to be invoked.
@@ -71396,13 +71614,17 @@
71396 assert( pOp->p1>0 && pOp->p1<=(p->nMem-p->nCursor) );
71397 pIn1 = &aMem[pOp->p1];
71398 assert( VdbeMemDynamic(pIn1)==0 );
71399 memAboutToChange(p, pIn1);
71400 pIn1->flags = MEM_Int;
71401 pIn1->u.i = pc;
71402 REGISTER_TRACE(pOp->p1, pIn1);
71403 pc = pOp->p2 - 1;
 
 
 
 
71404 break;
71405 }
71406
71407 /* Opcode: Return P1 * * * *
71408 **
@@ -71410,11 +71632,11 @@
71410 ** the jump, register P1 becomes undefined.
71411 */
71412 case OP_Return: { /* in1 */
71413 pIn1 = &aMem[pOp->p1];
71414 assert( pIn1->flags==MEM_Int );
71415 pc = (int)pIn1->u.i;
71416 pIn1->flags = MEM_Undefined;
71417 break;
71418 }
71419
71420 /* Opcode: InitCoroutine P1 P2 P3 * *
@@ -71434,11 +71656,11 @@
71434 assert( pOp->p3>=0 && pOp->p3<p->nOp );
71435 pOut = &aMem[pOp->p1];
71436 assert( !VdbeMemDynamic(pOut) );
71437 pOut->u.i = pOp->p3 - 1;
71438 pOut->flags = MEM_Int;
71439 if( pOp->p2 ) pc = pOp->p2 - 1;
71440 break;
71441 }
71442
71443 /* Opcode: EndCoroutine P1 * * * *
71444 **
@@ -71454,11 +71676,11 @@
71454 assert( pIn1->flags==MEM_Int );
71455 assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );
71456 pCaller = &aOp[pIn1->u.i];
71457 assert( pCaller->opcode==OP_Yield );
71458 assert( pCaller->p2>=0 && pCaller->p2<p->nOp );
71459 pc = pCaller->p2 - 1;
71460 pIn1->flags = MEM_Undefined;
71461 break;
71462 }
71463
71464 /* Opcode: Yield P1 P2 * * *
@@ -71478,13 +71700,13 @@
71478 int pcDest;
71479 pIn1 = &aMem[pOp->p1];
71480 assert( VdbeMemDynamic(pIn1)==0 );
71481 pIn1->flags = MEM_Int;
71482 pcDest = (int)pIn1->u.i;
71483 pIn1->u.i = pc;
71484 REGISTER_TRACE(pOp->p1, pIn1);
71485 pc = pcDest;
71486 break;
71487 }
71488
71489 /* Opcode: HaltIfNull P1 P2 P3 P4 P5
71490 ** Synopsis: if r[P3]=null halt
@@ -71531,34 +71753,38 @@
71531 ** is the same as executing Halt.
71532 */
71533 case OP_Halt: {
71534 const char *zType;
71535 const char *zLogFmt;
 
 
71536
 
71537 if( pOp->p1==SQLITE_OK && p->pFrame ){
71538 /* Halt the sub-program. Return control to the parent frame. */
71539 VdbeFrame *pFrame = p->pFrame;
71540 p->pFrame = pFrame->pParent;
71541 p->nFrame--;
71542 sqlite3VdbeSetChanges(db, p->nChange);
71543 pc = sqlite3VdbeFrameRestore(pFrame);
71544 lastRowid = db->lastRowid;
71545 if( pOp->p2==OE_Ignore ){
71546 /* Instruction pc is the OP_Program that invoked the sub-program
71547 ** currently being halted. If the p2 instruction of this OP_Halt
71548 ** instruction is set to OE_Ignore, then the sub-program is throwing
71549 ** an IGNORE exception. In this case jump to the address specified
71550 ** as the p2 of the calling OP_Program. */
71551 pc = p->aOp[pc].p2-1;
71552 }
71553 aOp = p->aOp;
71554 aMem = p->aMem;
 
71555 break;
71556 }
71557 p->rc = pOp->p1;
71558 p->errorAction = (u8)pOp->p2;
71559 p->pc = pc;
71560 if( p->rc ){
71561 if( pOp->p5 ){
71562 static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK",
71563 "FOREIGN KEY" };
71564 assert( pOp->p5>=1 && pOp->p5<=4 );
@@ -71578,11 +71804,11 @@
71578 }else if( pOp->p4.z ){
71579 sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
71580 }else{
71581 sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType);
71582 }
71583 sqlite3_log(pOp->p1, zLogFmt, pc, p->zSql, p->zErrMsg);
71584 }
71585 rc = sqlite3VdbeHalt(p);
71586 assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
71587 if( rc==SQLITE_BUSY ){
71588 p->rc = rc = SQLITE_BUSY;
@@ -71597,11 +71823,12 @@
71597 /* Opcode: Integer P1 P2 * * *
71598 ** Synopsis: r[P2]=P1
71599 **
71600 ** The 32-bit integer value P1 is written into register P2.
71601 */
71602 case OP_Integer: { /* out2-prerelease */
 
71603 pOut->u.i = pOp->p1;
71604 break;
71605 }
71606
71607 /* Opcode: Int64 * P2 * P4 *
@@ -71608,11 +71835,12 @@
71608 ** Synopsis: r[P2]=P4
71609 **
71610 ** P4 is a pointer to a 64-bit integer value.
71611 ** Write that value into register P2.
71612 */
71613 case OP_Int64: { /* out2-prerelease */
 
71614 assert( pOp->p4.pI64!=0 );
71615 pOut->u.i = *pOp->p4.pI64;
71616 break;
71617 }
71618
@@ -71621,11 +71849,12 @@
71621 ** Synopsis: r[P2]=P4
71622 **
71623 ** P4 is a pointer to a 64-bit floating point value.
71624 ** Write that value into register P2.
71625 */
71626 case OP_Real: { /* same as TK_FLOAT, out2-prerelease */
 
71627 pOut->flags = MEM_Real;
71628 assert( !sqlite3IsNaN(*pOp->p4.pReal) );
71629 pOut->u.r = *pOp->p4.pReal;
71630 break;
71631 }
@@ -71637,12 +71866,13 @@
71637 ** P4 points to a nul terminated UTF-8 string. This opcode is transformed
71638 ** into a String opcode before it is executed for the first time. During
71639 ** this transformation, the length of string P4 is computed and stored
71640 ** as the P1 parameter.
71641 */
71642 case OP_String8: { /* same as TK_STRING, out2-prerelease */
71643 assert( pOp->p4.z!=0 );
 
71644 pOp->opcode = OP_String;
71645 pOp->p1 = sqlite3Strlen30(pOp->p4.z);
71646
71647 #ifndef SQLITE_OMIT_UTF16
71648 if( encoding!=SQLITE_UTF8 ){
@@ -71675,12 +71905,13 @@
71675 ** If P5!=0 and the content of register P3 is greater than zero, then
71676 ** the datatype of the register P2 is converted to BLOB. The content is
71677 ** the same sequence of bytes, it is merely interpreted as a BLOB instead
71678 ** of a string, as if it had been CAST.
71679 */
71680 case OP_String: { /* out2-prerelease */
71681 assert( pOp->p4.z!=0 );
 
71682 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
71683 pOut->z = pOp->p4.z;
71684 pOut->n = pOp->p1;
71685 pOut->enc = encoding;
71686 UPDATE_MAX_BLOBSIZE(pOut);
@@ -71704,13 +71935,14 @@
71704 **
71705 ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that
71706 ** NULL values will not compare equal even if SQLITE_NULLEQ is set on
71707 ** OP_Ne or OP_Eq.
71708 */
71709 case OP_Null: { /* out2-prerelease */
71710 int cnt;
71711 u16 nullFlag;
 
71712 cnt = pOp->p3-pOp->p2;
71713 assert( pOp->p3<=(p->nMem-p->nCursor) );
71714 pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
71715 while( cnt>0 ){
71716 pOut++;
@@ -71741,12 +71973,13 @@
71741 ** Synopsis: r[P2]=P4 (len=P1)
71742 **
71743 ** P4 points to a blob of data P1 bytes long. Store this
71744 ** blob in register P2.
71745 */
71746 case OP_Blob: { /* out2-prerelease */
71747 assert( pOp->p1 <= SQLITE_MAX_LENGTH );
 
71748 sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
71749 pOut->enc = encoding;
71750 UPDATE_MAX_BLOBSIZE(pOut);
71751 break;
71752 }
@@ -71757,19 +71990,20 @@
71757 ** Transfer the values of bound parameter P1 into register P2
71758 **
71759 ** If the parameter is named, then its name appears in P4.
71760 ** The P4 value is used by sqlite3_bind_parameter_name().
71761 */
71762 case OP_Variable: { /* out2-prerelease */
71763 Mem *pVar; /* Value being transferred */
71764
71765 assert( pOp->p1>0 && pOp->p1<=p->nVar );
71766 assert( pOp->p4.z==0 || pOp->p4.z==p->azVar[pOp->p1-1] );
71767 pVar = &p->aVar[pOp->p1 - 1];
71768 if( sqlite3VdbeMemTooBig(pVar) ){
71769 goto too_big;
71770 }
 
71771 sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
71772 UPDATE_MAX_BLOBSIZE(pOut);
71773 break;
71774 }
71775
@@ -71800,14 +72034,15 @@
71800 assert( pIn1<=&aMem[(p->nMem-p->nCursor)] );
71801 assert( memIsValid(pIn1) );
71802 memAboutToChange(p, pOut);
71803 sqlite3VdbeMemMove(pOut, pIn1);
71804 #ifdef SQLITE_DEBUG
71805 if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<&aMem[p1+pOp->p3] ){
71806 pOut->pScopyFrom += p1 - pOp->p2;
71807 }
71808 #endif
 
71809 REGISTER_TRACE(p2++, pOut);
71810 pIn1++;
71811 pOut++;
71812 }while( --n );
71813 break;
@@ -71942,11 +72177,11 @@
71942 }
71943 if( db->mallocFailed ) goto no_mem;
71944
71945 /* Return SQLITE_ROW
71946 */
71947 p->pc = pc + 1;
71948 rc = SQLITE_ROW;
71949 goto vdbe_return;
71950 }
71951
71952 /* Opcode: Concat P1 P2 P3 * *
@@ -72188,11 +72423,11 @@
72188 REGISTER_TRACE(pOp->p2+i, pArg);
72189 }
72190
72191 assert( pOp->p4type==P4_FUNCDEF );
72192 ctx.pFunc = pOp->p4.pFunc;
72193 ctx.iOp = pc;
72194 ctx.pVdbe = p;
72195 MemSetTypeFlag(ctx.pOut, MEM_Null);
72196 ctx.fErrorOrAux = 0;
72197 db->lastRowid = lastRowid;
72198 (*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
@@ -72202,11 +72437,11 @@
72202 if( ctx.fErrorOrAux ){
72203 if( ctx.isError ){
72204 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(ctx.pOut));
72205 rc = ctx.isError;
72206 }
72207 sqlite3VdbeDeleteAuxData(p, pc, pOp->p1);
72208 }
72209
72210 /* Copy the result of the function into register P3 */
72211 sqlite3VdbeChangeEncoding(ctx.pOut, encoding);
72212 if( sqlite3VdbeMemTooBig(ctx.pOut) ){
@@ -72331,12 +72566,11 @@
72331 if( (pIn1->flags & MEM_Int)==0 ){
72332 if( pOp->p2==0 ){
72333 rc = SQLITE_MISMATCH;
72334 goto abort_due_to_error;
72335 }else{
72336 pc = pOp->p2 - 1;
72337 break;
72338 }
72339 }
72340 }
72341 MemSetTypeFlag(pIn1, MEM_Int);
72342 break;
@@ -72518,11 +72752,11 @@
72518 MemSetTypeFlag(pOut, MEM_Null);
72519 REGISTER_TRACE(pOp->p2, pOut);
72520 }else{
72521 VdbeBranchTaken(2,3);
72522 if( pOp->p5 & SQLITE_JUMPIFNULL ){
72523 pc = pOp->p2-1;
72524 }
72525 }
72526 break;
72527 }
72528 }else{
@@ -72538,15 +72772,19 @@
72538 }else if( affinity==SQLITE_AFF_TEXT ){
72539 if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
72540 testcase( pIn1->flags & MEM_Int );
72541 testcase( pIn1->flags & MEM_Real );
72542 sqlite3VdbeMemStringify(pIn1, encoding, 1);
 
 
72543 }
72544 if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
72545 testcase( pIn3->flags & MEM_Int );
72546 testcase( pIn3->flags & MEM_Real );
72547 sqlite3VdbeMemStringify(pIn3, encoding, 1);
 
 
72548 }
72549 }
72550 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
72551 if( pIn1->flags & MEM_Zero ){
72552 sqlite3VdbeMemExpandBlob(pIn1);
@@ -72565,10 +72803,16 @@
72565 case OP_Lt: res = res<0; break;
72566 case OP_Le: res = res<=0; break;
72567 case OP_Gt: res = res>0; break;
72568 default: res = res>=0; break;
72569 }
 
 
 
 
 
 
72570
72571 if( pOp->p5 & SQLITE_STOREP2 ){
72572 pOut = &aMem[pOp->p2];
72573 memAboutToChange(p, pOut);
72574 MemSetTypeFlag(pOut, MEM_Int);
@@ -72575,16 +72819,13 @@
72575 pOut->u.i = res;
72576 REGISTER_TRACE(pOp->p2, pOut);
72577 }else{
72578 VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
72579 if( res ){
72580 pc = pOp->p2-1;
72581 }
72582 }
72583 /* Undo any changes made by applyAffinity() to the input registers. */
72584 pIn1->flags = flags1;
72585 pIn3->flags = flags3;
72586 break;
72587 }
72588
72589 /* Opcode: Permutation * * * P4 *
72590 **
@@ -72675,15 +72916,15 @@
72675 ** in the most recent OP_Compare instruction the P1 vector was less than
72676 ** equal to, or greater than the P2 vector, respectively.
72677 */
72678 case OP_Jump: { /* jump */
72679 if( iCompare<0 ){
72680 pc = pOp->p1 - 1; VdbeBranchTaken(0,3);
72681 }else if( iCompare==0 ){
72682 pc = pOp->p2 - 1; VdbeBranchTaken(1,3);
72683 }else{
72684 pc = pOp->p3 - 1; VdbeBranchTaken(2,3);
72685 }
72686 break;
72687 }
72688
72689 /* Opcode: And P1 P2 P3 * *
@@ -72789,11 +73030,11 @@
72789 */
72790 case OP_Once: { /* jump */
72791 assert( pOp->p1<p->nOnceFlag );
72792 VdbeBranchTaken(p->aOnceFlag[pOp->p1]!=0, 2);
72793 if( p->aOnceFlag[pOp->p1] ){
72794 pc = pOp->p2-1;
72795 }else{
72796 p->aOnceFlag[pOp->p1] = 1;
72797 }
72798 break;
72799 }
@@ -72824,11 +73065,11 @@
72824 #endif
72825 if( pOp->opcode==OP_IfNot ) c = !c;
72826 }
72827 VdbeBranchTaken(c!=0, 2);
72828 if( c ){
72829 pc = pOp->p2-1;
72830 }
72831 break;
72832 }
72833
72834 /* Opcode: IsNull P1 P2 * * *
@@ -72838,11 +73079,11 @@
72838 */
72839 case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
72840 pIn1 = &aMem[pOp->p1];
72841 VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);
72842 if( (pIn1->flags & MEM_Null)!=0 ){
72843 pc = pOp->p2 - 1;
72844 }
72845 break;
72846 }
72847
72848 /* Opcode: NotNull P1 P2 * * *
@@ -72852,11 +73093,11 @@
72852 */
72853 case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */
72854 pIn1 = &aMem[pOp->p1];
72855 VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);
72856 if( (pIn1->flags & MEM_Null)==0 ){
72857 pc = pOp->p2 - 1;
72858 }
72859 break;
72860 }
72861
72862 /* Opcode: Column P1 P2 P3 P4 P5
@@ -73066,11 +73307,11 @@
73066 rc = SQLITE_CORRUPT_BKPT;
73067 goto op_column_error;
73068 }
73069 }
73070
73071 /* If after trying to extra new entries from the header, nHdrParsed is
73072 ** still not up to p2, that means that the record has fewer than p2
73073 ** columns. So the result will be either the default value or a NULL.
73074 */
73075 if( pC->nHdrParsed<=p2 ){
73076 if( pOp->p4type==P4_MEM ){
@@ -73190,11 +73431,11 @@
73190 u8 *zNewRecord; /* A buffer to hold the data for the new record */
73191 Mem *pRec; /* The new record */
73192 u64 nData; /* Number of bytes of data space */
73193 int nHdr; /* Number of bytes of header space */
73194 i64 nByte; /* Data space required for this record */
73195 int nZero; /* Number of zero bytes at the end of the record */
73196 int nVarint; /* Number of bytes in a varint */
73197 u32 serial_type; /* Type field */
73198 Mem *pData0; /* First field to be combined into the record */
73199 Mem *pLast; /* Last field of the record */
73200 int nField; /* Number of fields in the record */
@@ -73282,11 +73523,11 @@
73282 nVarint = sqlite3VarintLen(nHdr);
73283 nHdr += nVarint;
73284 if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
73285 }
73286 nByte = nHdr+nData;
73287 if( nByte>db->aLimit[SQLITE_LIMIT_LENGTH] ){
73288 goto too_big;
73289 }
73290
73291 /* Make sure the output register has a buffer large enough to store
73292 ** the new record. The output register (pOp->p3) is not allowed to
@@ -73333,18 +73574,19 @@
73333 **
73334 ** Store the number of entries (an integer value) in the table or index
73335 ** opened by cursor P1 in register P2
73336 */
73337 #ifndef SQLITE_OMIT_BTREECOUNT
73338 case OP_Count: { /* out2-prerelease */
73339 i64 nEntry;
73340 BtCursor *pCrsr;
73341
73342 pCrsr = p->apCsr[pOp->p1]->pCursor;
73343 assert( pCrsr );
73344 nEntry = 0; /* Not needed. Only used to silence a warning. */
73345 rc = sqlite3BtreeCount(pCrsr, &nEntry);
 
73346 pOut->u.i = nEntry;
73347 break;
73348 }
73349 #endif
73350
@@ -73454,11 +73696,11 @@
73454 if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
73455 goto vdbe_return;
73456 }
73457 db->autoCommit = 1;
73458 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73459 p->pc = pc;
73460 db->autoCommit = 0;
73461 p->rc = rc = SQLITE_BUSY;
73462 goto vdbe_return;
73463 }
73464 db->isTransactionSavepoint = 0;
@@ -73513,11 +73755,11 @@
73513 }else{
73514 db->nDeferredCons = pSavepoint->nDeferredCons;
73515 db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
73516 }
73517
73518 if( !isTransaction ){
73519 rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
73520 if( rc!=SQLITE_OK ) goto abort_due_to_error;
73521 }
73522 }
73523 }
@@ -73573,11 +73815,11 @@
73573 }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
73574 goto vdbe_return;
73575 }else{
73576 db->autoCommit = (u8)desiredAutoCommit;
73577 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73578 p->pc = pc;
73579 db->autoCommit = (u8)(1-desiredAutoCommit);
73580 p->rc = rc = SQLITE_BUSY;
73581 goto vdbe_return;
73582 }
73583 }
@@ -73650,11 +73892,11 @@
73650 pBt = db->aDb[pOp->p1].pBt;
73651
73652 if( pBt ){
73653 rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
73654 if( rc==SQLITE_BUSY ){
73655 p->pc = pc;
73656 p->rc = rc = SQLITE_BUSY;
73657 goto vdbe_return;
73658 }
73659 if( rc!=SQLITE_OK ){
73660 goto abort_due_to_error;
@@ -73729,11 +73971,11 @@
73729 **
73730 ** There must be a read-lock on the database (either a transaction
73731 ** must be started or there must be an open cursor) before
73732 ** executing this instruction.
73733 */
73734 case OP_ReadCookie: { /* out2-prerelease */
73735 int iMeta;
73736 int iDb;
73737 int iCookie;
73738
73739 assert( p->bIsReader );
@@ -73743,10 +73985,11 @@
73743 assert( iDb>=0 && iDb<db->nDb );
73744 assert( db->aDb[iDb].pBt!=0 );
73745 assert( DbMaskTest(p->btreeMask, iDb) );
73746
73747 sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);
 
73748 pOut->u.i = iMeta;
73749 break;
73750 }
73751
73752 /* Opcode: SetCookie P1 P2 P3 * *
@@ -74064,11 +74307,11 @@
74064 VdbeCursor *pC;
74065 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74066 pC = p->apCsr[pOp->p1];
74067 assert( pC->pSorter );
74068 if( (pC->seqCount++)==0 ){
74069 pc = pOp->p2 - 1;
74070 }
74071 break;
74072 }
74073
74074 /* Opcode: OpenPseudo P1 P2 P3 * *
@@ -74241,11 +74484,11 @@
74241 ** loss of information, then special processing is required... */
74242 if( (pIn3->flags & MEM_Int)==0 ){
74243 if( (pIn3->flags & MEM_Real)==0 ){
74244 /* If the P3 value cannot be converted into any kind of a number,
74245 ** then the seek is not possible, so jump to P2 */
74246 pc = pOp->p2 - 1; VdbeBranchTaken(1,2);
74247 break;
74248 }
74249
74250 /* If the approximation iKey is larger than the actual real search
74251 ** term, substitute >= for > and < for <=. e.g. if the search term
@@ -74332,11 +74575,11 @@
74332 }
74333 }
74334 assert( pOp->p2>0 );
74335 VdbeBranchTaken(res!=0,2);
74336 if( res ){
74337 pc = pOp->p2 - 1;
74338 }
74339 break;
74340 }
74341
74342 /* Opcode: Seek P1 P2 * * *
@@ -74426,10 +74669,11 @@
74426 */
74427 case OP_NoConflict: /* jump, in3 */
74428 case OP_NotFound: /* jump, in3 */
74429 case OP_Found: { /* jump, in3 */
74430 int alreadyExists;
 
74431 int ii;
74432 VdbeCursor *pC;
74433 int res;
74434 char *pFree;
74435 UnpackedRecord *pIdxKey;
@@ -74448,11 +74692,11 @@
74448 pC->seekOp = pOp->opcode;
74449 #endif
74450 pIn3 = &aMem[pOp->p3];
74451 assert( pC->pCursor!=0 );
74452 assert( pC->isTable==0 );
74453 pFree = 0; /* Not needed. Only used to suppress a compiler warning. */
74454 if( pOp->p4.i>0 ){
74455 r.pKeyInfo = pC->pKeyInfo;
74456 r.nField = (u16)pOp->p4.i;
74457 r.aMem = pIn3;
74458 for(ii=0; ii<r.nField; ii++){
@@ -74471,25 +74715,24 @@
74471 assert( pIn3->flags & MEM_Blob );
74472 ExpandBlob(pIn3);
74473 sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
74474 }
74475 pIdxKey->default_rc = 0;
 
74476 if( pOp->opcode==OP_NoConflict ){
74477 /* For the OP_NoConflict opcode, take the jump if any of the
74478 ** input fields are NULL, since any key with a NULL will not
74479 ** conflict */
74480 for(ii=0; ii<pIdxKey->nField; ii++){
74481 if( pIdxKey->aMem[ii].flags & MEM_Null ){
74482 pc = pOp->p2 - 1; VdbeBranchTaken(1,2);
74483 break;
74484 }
74485 }
74486 }
74487 rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res);
74488 if( pOp->p4.i==0 ){
74489 sqlite3DbFree(db, pFree);
74490 }
74491 if( rc!=SQLITE_OK ){
74492 break;
74493 }
74494 pC->seekResult = res;
74495 alreadyExists = (res==0);
@@ -74496,14 +74739,14 @@
74496 pC->nullRow = 1-alreadyExists;
74497 pC->deferredMoveto = 0;
74498 pC->cacheStatus = CACHE_STALE;
74499 if( pOp->opcode==OP_Found ){
74500 VdbeBranchTaken(alreadyExists!=0,2);
74501 if( alreadyExists ) pc = pOp->p2 - 1;
74502 }else{
74503 VdbeBranchTaken(alreadyExists==0,2);
74504 if( !alreadyExists ) pc = pOp->p2 - 1;
74505 }
74506 break;
74507 }
74508
74509 /* Opcode: NotExists P1 P2 P3 * *
@@ -74548,14 +74791,12 @@
74548 pC->movetoTarget = iKey; /* Used by OP_Delete */
74549 pC->nullRow = 0;
74550 pC->cacheStatus = CACHE_STALE;
74551 pC->deferredMoveto = 0;
74552 VdbeBranchTaken(res!=0,2);
74553 if( res!=0 ){
74554 pc = pOp->p2 - 1;
74555 }
74556 pC->seekResult = res;
 
74557 break;
74558 }
74559
74560 /* Opcode: Sequence P1 P2 * * *
74561 ** Synopsis: r[P2]=cursor[P1].ctr++
@@ -74563,13 +74804,14 @@
74563 ** Find the next available sequence number for cursor P1.
74564 ** Write the sequence number into register P2.
74565 ** The sequence number on the cursor is incremented after this
74566 ** instruction.
74567 */
74568 case OP_Sequence: { /* out2-prerelease */
74569 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74570 assert( p->apCsr[pOp->p1]!=0 );
 
74571 pOut->u.i = p->apCsr[pOp->p1]->seqCount++;
74572 break;
74573 }
74574
74575
@@ -74586,20 +74828,21 @@
74586 ** allowed to be less than this value. When this value reaches its maximum,
74587 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
74588 ** generated record number. This P3 mechanism is used to help implement the
74589 ** AUTOINCREMENT feature.
74590 */
74591 case OP_NewRowid: { /* out2-prerelease */
74592 i64 v; /* The new rowid */
74593 VdbeCursor *pC; /* Cursor of table to get the new rowid */
74594 int res; /* Result of an sqlite3BtreeLast() */
74595 int cnt; /* Counter to limit the number of searches */
74596 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
74597 VdbeFrame *pFrame; /* Root frame of VDBE */
74598
74599 v = 0;
74600 res = 0;
 
74601 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74602 pC = p->apCsr[pOp->p1];
74603 assert( pC!=0 );
74604 if( NEVER(pC->pCursor==0) ){
74605 /* The zero initialization above is all that is needed */
@@ -74909,13 +75152,11 @@
74909 pIn3 = &aMem[pOp->p3];
74910 nKeyCol = pOp->p4.i;
74911 res = 0;
74912 rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);
74913 VdbeBranchTaken(res!=0,2);
74914 if( res ){
74915 pc = pOp->p2-1;
74916 }
74917 break;
74918 };
74919
74920 /* Opcode: SorterData P1 P2 P3 * *
74921 ** Synopsis: r[P2]=data
@@ -75040,16 +75281,17 @@
75040 **
75041 ** P1 can be either an ordinary table or a virtual table. There used to
75042 ** be a separate OP_VRowid opcode for use with virtual tables, but this
75043 ** one opcode now works for both table types.
75044 */
75045 case OP_Rowid: { /* out2-prerelease */
75046 VdbeCursor *pC;
75047 i64 v;
75048 sqlite3_vtab *pVtab;
75049 const sqlite3_module *pModule;
75050
 
75051 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
75052 pC = p->apCsr[pOp->p1];
75053 assert( pC!=0 );
75054 assert( pC->pseudoTableReg==0 || pC->nullRow );
75055 if( pC->nullRow ){
@@ -75098,11 +75340,11 @@
75098 sqlite3BtreeClearCursor(pC->pCursor);
75099 }
75100 break;
75101 }
75102
75103 /* Opcode: Last P1 P2 * * *
75104 **
75105 ** The next use of the Rowid or Column or Prev instruction for P1
75106 ** will refer to the last entry in the database table or index.
75107 ** If the table or index is empty and P2>0, then jump immediately to P2.
75108 ** If P2 is 0 or if the table or index is not empty, fall through
@@ -75125,16 +75367,17 @@
75125 assert( pCrsr!=0 );
75126 rc = sqlite3BtreeLast(pCrsr, &res);
75127 pC->nullRow = (u8)res;
75128 pC->deferredMoveto = 0;
75129 pC->cacheStatus = CACHE_STALE;
 
75130 #ifdef SQLITE_DEBUG
75131 pC->seekOp = OP_Last;
75132 #endif
75133 if( pOp->p2>0 ){
75134 VdbeBranchTaken(res!=0,2);
75135 if( res ) pc = pOp->p2 - 1;
75136 }
75137 break;
75138 }
75139
75140
@@ -75194,13 +75437,11 @@
75194 pC->cacheStatus = CACHE_STALE;
75195 }
75196 pC->nullRow = (u8)res;
75197 assert( pOp->p2>0 && pOp->p2<p->nOp );
75198 VdbeBranchTaken(res!=0,2);
75199 if( res ){
75200 pc = pOp->p2 - 1;
75201 }
75202 break;
75203 }
75204
75205 /* Opcode: Next P1 P2 P3 P4 P5
75206 **
@@ -75307,15 +75548,15 @@
75307 next_tail:
75308 pC->cacheStatus = CACHE_STALE;
75309 VdbeBranchTaken(res==0,2);
75310 if( res==0 ){
75311 pC->nullRow = 0;
75312 pc = pOp->p2 - 1;
75313 p->aCounter[pOp->p5]++;
75314 #ifdef SQLITE_TEST
75315 sqlite3_search_count++;
75316 #endif
 
75317 }else{
75318 pC->nullRow = 1;
75319 }
75320 goto check_for_interrupt;
75321 }
@@ -75419,15 +75660,16 @@
75419 ** the end of the index key pointed to by cursor P1. This integer should be
75420 ** the rowid of the table entry to which this index entry points.
75421 **
75422 ** See also: Rowid, MakeRecord.
75423 */
75424 case OP_IdxRowid: { /* out2-prerelease */
75425 BtCursor *pCrsr;
75426 VdbeCursor *pC;
75427 i64 rowid;
75428
 
75429 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
75430 pC = p->apCsr[pOp->p1];
75431 assert( pC!=0 );
75432 pCrsr = pC->pCursor;
75433 assert( pCrsr!=0 );
@@ -75536,13 +75778,11 @@
75536 }else{
75537 assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
75538 res++;
75539 }
75540 VdbeBranchTaken(res>0,2);
75541 if( res>0 ){
75542 pc = pOp->p2 - 1 ;
75543 }
75544 break;
75545 }
75546
75547 /* Opcode: Destroy P1 P2 P3 * *
75548 **
@@ -75562,15 +75802,16 @@
75562 ** the last one in the database) then a zero is stored in register P2.
75563 ** If AUTOVACUUM is disabled then a zero is stored in register P2.
75564 **
75565 ** See also: Clear
75566 */
75567 case OP_Destroy: { /* out2-prerelease */
75568 int iMoved;
75569 int iDb;
75570
75571 assert( p->readOnly==0 );
 
75572 pOut->flags = MEM_Null;
75573 if( db->nVdbeRead > db->nVDestroy+1 ){
75574 rc = SQLITE_LOCKED;
75575 p->errorAction = OE_Abort;
75576 }else{
@@ -75675,16 +75916,17 @@
75675 ** P1>1. Write the root page number of the new table into
75676 ** register P2.
75677 **
75678 ** See documentation on OP_CreateTable for additional information.
75679 */
75680 case OP_CreateIndex: /* out2-prerelease */
75681 case OP_CreateTable: { /* out2-prerelease */
75682 int pgno;
75683 int flags;
75684 Db *pDb;
75685
 
75686 pgno = 0;
75687 assert( pOp->p1>=0 && pOp->p1<db->nDb );
75688 assert( DbMaskTest(p->btreeMask, pOp->p1) );
75689 assert( p->readOnly==0 );
75690 pDb = &db->aDb[pOp->p1];
@@ -75906,16 +76148,16 @@
75906 if( (pIn1->flags & MEM_RowSet)==0
75907 || sqlite3RowSetNext(pIn1->u.pRowSet, &val)==0
75908 ){
75909 /* The boolean index is empty */
75910 sqlite3VdbeMemSetNull(pIn1);
75911 pc = pOp->p2 - 1;
75912 VdbeBranchTaken(1,2);
 
75913 }else{
75914 /* A value was pulled from the index */
75915 sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);
75916 VdbeBranchTaken(0,2);
 
75917 }
75918 goto check_for_interrupt;
75919 }
75920
75921 /* Opcode: RowSetTest P1 P2 P3 P4
@@ -75962,14 +76204,11 @@
75962 assert( pOp->p4type==P4_INT32 );
75963 assert( iSet==-1 || iSet>=0 );
75964 if( iSet ){
75965 exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i);
75966 VdbeBranchTaken(exists!=0,2);
75967 if( exists ){
75968 pc = pOp->p2 - 1;
75969 break;
75970 }
75971 }
75972 if( iSet>=0 ){
75973 sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);
75974 }
75975 break;
@@ -76054,11 +76293,11 @@
76054 pRt->u.pFrame = pFrame;
76055
76056 pFrame->v = p;
76057 pFrame->nChildMem = nMem;
76058 pFrame->nChildCsr = pProgram->nCsr;
76059 pFrame->pc = pc;
76060 pFrame->aMem = p->aMem;
76061 pFrame->nMem = p->nMem;
76062 pFrame->apCsr = p->apCsr;
76063 pFrame->nCursor = p->nCursor;
76064 pFrame->aOp = p->aOp;
@@ -76077,11 +76316,11 @@
76077 }
76078 }else{
76079 pFrame = pRt->u.pFrame;
76080 assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem );
76081 assert( pProgram->nCsr==pFrame->nChildCsr );
76082 assert( pc==pFrame->pc );
76083 }
76084
76085 p->nFrame++;
76086 pFrame->pParent = p->pFrame;
76087 pFrame->lastRowid = lastRowid;
@@ -76098,11 +76337,11 @@
76098 p->aOnceFlag = (u8 *)&p->apCsr[p->nCursor];
76099 p->nOnceFlag = pProgram->nOnce;
76100 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
76101 p->anExec = 0;
76102 #endif
76103 pc = -1;
76104 memset(p->aOnceFlag, 0, p->nOnceFlag);
76105
76106 break;
76107 }
76108
@@ -76116,13 +76355,14 @@
76116 **
76117 ** The address of the cell in the parent frame is determined by adding
76118 ** the value of the P1 argument to the value of the P1 argument to the
76119 ** calling OP_Program instruction.
76120 */
76121 case OP_Param: { /* out2-prerelease */
76122 VdbeFrame *pFrame;
76123 Mem *pIn;
 
76124 pFrame = p->pFrame;
76125 pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];
76126 sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);
76127 break;
76128 }
@@ -76162,14 +76402,14 @@
76162 ** (immediate foreign key constraint violations).
76163 */
76164 case OP_FkIfZero: { /* jump */
76165 if( pOp->p1 ){
76166 VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);
76167 if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1;
76168 }else{
76169 VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);
76170 if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) pc = pOp->p2-1;
76171 }
76172 break;
76173 }
76174 #endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
76175
@@ -76216,13 +76456,11 @@
76216 */
76217 case OP_IfPos: { /* jump, in1 */
76218 pIn1 = &aMem[pOp->p1];
76219 assert( pIn1->flags&MEM_Int );
76220 VdbeBranchTaken( pIn1->u.i>0, 2);
76221 if( pIn1->u.i>0 ){
76222 pc = pOp->p2 - 1;
76223 }
76224 break;
76225 }
76226
76227 /* Opcode: IfNeg P1 P2 P3 * *
76228 ** Synopsis: r[P1]+=P3, if r[P1]<0 goto P2
@@ -76233,13 +76471,11 @@
76233 case OP_IfNeg: { /* jump, in1 */
76234 pIn1 = &aMem[pOp->p1];
76235 assert( pIn1->flags&MEM_Int );
76236 pIn1->u.i += pOp->p3;
76237 VdbeBranchTaken(pIn1->u.i<0, 2);
76238 if( pIn1->u.i<0 ){
76239 pc = pOp->p2 - 1;
76240 }
76241 break;
76242 }
76243
76244 /* Opcode: IfNotZero P1 P2 P3 * *
76245 ** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
@@ -76252,11 +76488,11 @@
76252 pIn1 = &aMem[pOp->p1];
76253 assert( pIn1->flags&MEM_Int );
76254 VdbeBranchTaken(pIn1->u.i<0, 2);
76255 if( pIn1->u.i ){
76256 pIn1->u.i += pOp->p3;
76257 pc = pOp->p2 - 1;
76258 }
76259 break;
76260 }
76261
76262 /* Opcode: DecrJumpZero P1 P2 * * *
@@ -76268,13 +76504,11 @@
76268 case OP_DecrJumpZero: { /* jump, in1 */
76269 pIn1 = &aMem[pOp->p1];
76270 assert( pIn1->flags&MEM_Int );
76271 pIn1->u.i--;
76272 VdbeBranchTaken(pIn1->u.i==0, 2);
76273 if( pIn1->u.i==0 ){
76274 pc = pOp->p2 - 1;
76275 }
76276 break;
76277 }
76278
76279
76280 /* Opcode: JumpZeroIncr P1 P2 * * *
@@ -76286,13 +76520,11 @@
76286 */
76287 case OP_JumpZeroIncr: { /* jump, in1 */
76288 pIn1 = &aMem[pOp->p1];
76289 assert( pIn1->flags&MEM_Int );
76290 VdbeBranchTaken(pIn1->u.i==0, 2);
76291 if( (pIn1->u.i++)==0 ){
76292 pc = pOp->p2 - 1;
76293 }
76294 break;
76295 }
76296
76297 /* Opcode: AggStep * P2 P3 P4 P5
76298 ** Synopsis: accum=r[P3] step(r[P2@P5])
@@ -76330,11 +76562,11 @@
76330 pMem->n++;
76331 sqlite3VdbeMemInit(&t, db, MEM_Null);
76332 ctx.pOut = &t;
76333 ctx.isError = 0;
76334 ctx.pVdbe = p;
76335 ctx.iOp = pc;
76336 ctx.skipFlag = 0;
76337 (ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */
76338 if( ctx.isError ){
76339 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&t));
76340 rc = ctx.isError;
@@ -76425,19 +76657,20 @@
76425 **
76426 ** If changing into or out of WAL mode the procedure is more complicated.
76427 **
76428 ** Write a string containing the final journal-mode to register P2.
76429 */
76430 case OP_JournalMode: { /* out2-prerelease */
76431 Btree *pBt; /* Btree to change journal mode of */
76432 Pager *pPager; /* Pager associated with pBt */
76433 int eNew; /* New journal mode */
76434 int eOld; /* The old journal mode */
76435 #ifndef SQLITE_OMIT_WAL
76436 const char *zFilename; /* Name of database file for pPager */
76437 #endif
76438
 
76439 eNew = pOp->p3;
76440 assert( eNew==PAGER_JOURNALMODE_DELETE
76441 || eNew==PAGER_JOURNALMODE_TRUNCATE
76442 || eNew==PAGER_JOURNALMODE_PERSIST
76443 || eNew==PAGER_JOURNALMODE_OFF
@@ -76509,11 +76742,10 @@
76509 if( rc ){
76510 eNew = eOld;
76511 }
76512 eNew = sqlite3PagerSetJournalMode(pPager, eNew);
76513
76514 pOut = &aMem[pOp->p2];
76515 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
76516 pOut->z = (char *)sqlite3JournalModename(eNew);
76517 pOut->n = sqlite3Strlen30(pOut->z);
76518 pOut->enc = SQLITE_UTF8;
76519 sqlite3VdbeChangeEncoding(pOut, encoding);
@@ -76550,12 +76782,12 @@
76550 assert( p->readOnly==0 );
76551 pBt = db->aDb[pOp->p1].pBt;
76552 rc = sqlite3BtreeIncrVacuum(pBt);
76553 VdbeBranchTaken(rc==SQLITE_DONE,2);
76554 if( rc==SQLITE_DONE ){
76555 pc = pOp->p2 - 1;
76556 rc = SQLITE_OK;
 
76557 }
76558 break;
76559 }
76560 #endif
76561
@@ -76704,12 +76936,13 @@
76704 pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
76705 if( pCur ){
76706 pCur->pVtabCursor = pVtabCursor;
76707 pVtab->nRef++;
76708 }else{
76709 db->mallocFailed = 1;
76710 pModule->xClose(pVtabCursor);
 
76711 }
76712 }
76713 break;
76714 }
76715 #endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -76761,29 +76994,23 @@
76761 assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );
76762 nArg = (int)pArgc->u.i;
76763 iQuery = (int)pQuery->u.i;
76764
76765 /* Invoke the xFilter method */
76766 {
76767 res = 0;
76768 apArg = p->apArg;
76769 for(i = 0; i<nArg; i++){
76770 apArg[i] = &pArgc[i+1];
76771 }
76772
76773 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
76774 sqlite3VtabImportErrmsg(p, pVtab);
76775 if( rc==SQLITE_OK ){
76776 res = pModule->xEof(pVtabCursor);
76777 }
76778 VdbeBranchTaken(res!=0,2);
76779 if( res ){
76780 pc = pOp->p2 - 1;
76781 }
76782 }
76783 pCur->nullRow = 0;
76784
 
76785 break;
76786 }
76787 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76788
76789 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76866,11 +77093,11 @@
76866 res = pModule->xEof(pCur->pVtabCursor);
76867 }
76868 VdbeBranchTaken(!res,2);
76869 if( !res ){
76870 /* If there is data, jump to P2 */
76871 pc = pOp->p2 - 1;
76872 }
76873 goto check_for_interrupt;
76874 }
76875 #endif /* SQLITE_OMIT_VIRTUALTABLE */
76876
@@ -76989,11 +77216,12 @@
76989 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
76990 /* Opcode: Pagecount P1 P2 * * *
76991 **
76992 ** Write the current number of pages in database P1 to memory cell P2.
76993 */
76994 case OP_Pagecount: { /* out2-prerelease */
 
76995 pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
76996 break;
76997 }
76998 #endif
76999
@@ -77005,14 +77233,15 @@
77005 ** Do not let the maximum page count fall below the current page count and
77006 ** do not change the maximum page count value if P3==0.
77007 **
77008 ** Store the maximum page count after the change in register P2.
77009 */
77010 case OP_MaxPgcnt: { /* out2-prerelease */
77011 unsigned int newMax;
77012 Btree *pBt;
77013
 
77014 pBt = db->aDb[pOp->p1].pBt;
77015 newMax = 0;
77016 if( pOp->p3 ){
77017 newMax = sqlite3BtreeLastPage(pBt);
77018 if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;
@@ -77037,13 +77266,10 @@
77037 */
77038 case OP_Init: { /* jump */
77039 char *zTrace;
77040 char *z;
77041
77042 if( pOp->p2 ){
77043 pc = pOp->p2 - 1;
77044 }
77045 #ifndef SQLITE_OMIT_TRACE
77046 if( db->xTrace
77047 && !p->doingRerun
77048 && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
77049 ){
@@ -77067,10 +77293,11 @@
77067 ){
77068 sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
77069 }
77070 #endif /* SQLITE_DEBUG */
77071 #endif /* SQLITE_OMIT_TRACE */
 
77072 break;
77073 }
77074
77075
77076 /* Opcode: Noop * * * * *
@@ -77098,31 +77325,31 @@
77098 }
77099
77100 #ifdef VDBE_PROFILE
77101 {
77102 u64 endTime = sqlite3Hwtime();
77103 if( endTime>start ) pOp->cycles += endTime - start;
77104 pOp->cnt++;
77105 }
77106 #endif
77107
77108 /* The following code adds nothing to the actual functionality
77109 ** of the program. It is only here for testing and debugging.
77110 ** On the other hand, it does burn CPU cycles every time through
77111 ** the evaluator loop. So we can leave it out when NDEBUG is defined.
77112 */
77113 #ifndef NDEBUG
77114 assert( pc>=-1 && pc<p->nOp );
77115
77116 #ifdef SQLITE_DEBUG
77117 if( db->flags & SQLITE_VdbeTrace ){
77118 if( rc!=0 ) printf("rc=%d\n",rc);
77119 if( pOp->opflags & (OPFLG_OUT2_PRERELEASE|OPFLG_OUT2) ){
77120 registerTrace(pOp->p2, &aMem[pOp->p2]);
77121 }
77122 if( pOp->opflags & OPFLG_OUT3 ){
77123 registerTrace(pOp->p3, &aMem[pOp->p3]);
77124 }
77125 }
77126 #endif /* SQLITE_DEBUG */
77127 #endif /* NDEBUG */
77128 } /* The end of the for(;;) loop the loops through opcodes */
@@ -77133,11 +77360,11 @@
77133 vdbe_error_halt:
77134 assert( rc );
77135 p->rc = rc;
77136 testcase( sqlite3GlobalConfig.xLog!=0 );
77137 sqlite3_log(rc, "statement aborts at %d: [%s] %s",
77138 pc, p->zSql, p->zErrMsg);
77139 sqlite3VdbeHalt(p);
77140 if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1;
77141 rc = SQLITE_ERROR;
77142 if( resetSchemaOnFault>0 ){
77143 sqlite3ResetOneSchema(db, resetSchemaOnFault-1);
@@ -77296,11 +77523,11 @@
77296 }
77297
77298 /*
77299 ** Open a blob handle.
77300 */
77301 SQLITE_API int sqlite3_blob_open(
77302 sqlite3* db, /* The database connection */
77303 const char *zDb, /* The attached database containing the blob */
77304 const char *zTable, /* The table containing the blob */
77305 const char *zColumn, /* The column containing the blob */
77306 sqlite_int64 iRow, /* The row containing the glob */
@@ -77533,11 +77760,11 @@
77533
77534 /*
77535 ** Close a blob handle that was previously created using
77536 ** sqlite3_blob_open().
77537 */
77538 SQLITE_API int sqlite3_blob_close(sqlite3_blob *pBlob){
77539 Incrblob *p = (Incrblob *)pBlob;
77540 int rc;
77541 sqlite3 *db;
77542
77543 if( p ){
@@ -77602,28 +77829,28 @@
77602 }
77603
77604 /*
77605 ** Read data from a blob handle.
77606 */
77607 SQLITE_API int sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77608 return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
77609 }
77610
77611 /*
77612 ** Write data to a blob handle.
77613 */
77614 SQLITE_API int sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77615 return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
77616 }
77617
77618 /*
77619 ** Query a blob handle for the size of the data.
77620 **
77621 ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
77622 ** so no mutex is required for access.
77623 */
77624 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *pBlob){
77625 Incrblob *p = (Incrblob *)pBlob;
77626 return (p && p->pStmt) ? p->nByte : 0;
77627 }
77628
77629 /*
@@ -77634,11 +77861,11 @@
77634 ** contain a blob or text value, then an error code is returned and the
77635 ** database handle error code and message set. If this happens, then all
77636 ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
77637 ** immediately return SQLITE_ABORT.
77638 */
77639 SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77640 int rc;
77641 Incrblob *p = (Incrblob *)pBlob;
77642 sqlite3 *db;
77643
77644 if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -77959,20 +78186,23 @@
77959 **
77960 ** In both cases, the effects of the main thread seeing (bDone==0) even
77961 ** after the thread has finished are not dire. So we don't worry about
77962 ** memory barriers and such here.
77963 */
 
77964 struct SortSubtask {
77965 SQLiteThread *pThread; /* Background thread, if any */
77966 int bDone; /* Set if thread is finished but not joined */
77967 VdbeSorter *pSorter; /* Sorter that owns this sub-task */
77968 UnpackedRecord *pUnpacked; /* Space to unpack a record */
77969 SorterList list; /* List for thread to write to a PMA */
77970 int nPMA; /* Number of PMAs currently in file */
 
77971 SorterFile file; /* Temp file for level-0 PMAs */
77972 SorterFile file2; /* Space for other PMAs */
77973 };
 
77974
77975 /*
77976 ** Main sorter structure. A single instance of this is allocated for each
77977 ** sorter cursor created by the VDBE.
77978 **
@@ -77996,12 +78226,16 @@
77996 int nMemory; /* Size of list.aMemory allocation in bytes */
77997 u8 bUsePMA; /* True if one or more PMAs created */
77998 u8 bUseThreads; /* True to use background threads */
77999 u8 iPrev; /* Previous thread used to flush PMA */
78000 u8 nTask; /* Size of aTask[] array */
 
78001 SortSubtask aTask[1]; /* One or more subtasks */
78002 };
 
 
 
78003
78004 /*
78005 ** An instance of the following object is used to read records out of a
78006 ** PMA, in sorted order. The next key to be read is cached in nKey/aKey.
78007 ** aKey might point into aMap or into aBuffer. If neither of those locations
@@ -78410,35 +78644,165 @@
78410 rc = vdbePmaReaderNext(pReadr);
78411 }
78412 return rc;
78413 }
78414
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78415
78416 /*
78417 ** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2,
78418 ** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences
78419 ** used by the comparison. Return the result of the comparison.
78420 **
78421 ** Before returning, object (pTask->pUnpacked) is populated with the
78422 ** unpacked version of key2. Or, if pKey2 is passed a NULL pointer, then it
78423 ** is assumed that the (pTask->pUnpacked) structure already contains the
78424 ** unpacked key to use as key2.
78425 **
78426 ** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set
78427 ** to SQLITE_NOMEM.
78428 */
78429 static int vdbeSorterCompare(
78430 SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
 
78431 const void *pKey1, int nKey1, /* Left side of comparison */
78432 const void *pKey2, int nKey2 /* Right side of comparison */
78433 ){
78434 UnpackedRecord *r2 = pTask->pUnpacked;
78435 if( pKey2 ){
78436 sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);
 
78437 }
78438 return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);
78439 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
78440
78441 /*
78442 ** Initialize the temporary index cursor just opened as a sorter cursor.
78443 **
78444 ** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nField)
@@ -78503,13 +78867,17 @@
78503 rc = SQLITE_NOMEM;
78504 }else{
78505 pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);
78506 memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);
78507 pKeyInfo->db = 0;
78508 if( nField && nWorker==0 ) pKeyInfo->nField = nField;
 
 
 
78509 pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);
78510 pSorter->nTask = nWorker + 1;
 
78511 pSorter->bUseThreads = (pSorter->nTask>1);
78512 pSorter->db = db;
78513 for(i=0; i<pSorter->nTask; i++){
78514 SortSubtask *pTask = &pSorter->aTask[i];
78515 pTask->pSorter = pSorter;
@@ -78531,10 +78899,16 @@
78531 pSorter->nMemory = pgsz;
78532 pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);
78533 if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM;
78534 }
78535 }
 
 
 
 
 
 
78536 }
78537
78538 return rc;
78539 }
78540 #undef nWorker /* Defined at the top of this function */
@@ -78555,34 +78929,28 @@
78555 ** Free all resources owned by the object indicated by argument pTask. All
78556 ** fields of *pTask are zeroed before returning.
78557 */
78558 static void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){
78559 sqlite3DbFree(db, pTask->pUnpacked);
78560 pTask->pUnpacked = 0;
78561 #if SQLITE_MAX_WORKER_THREADS>0
78562 /* pTask->list.aMemory can only be non-zero if it was handed memory
78563 ** from the main thread. That only occurs SQLITE_MAX_WORKER_THREADS>0 */
78564 if( pTask->list.aMemory ){
78565 sqlite3_free(pTask->list.aMemory);
78566 pTask->list.aMemory = 0;
78567 }else
78568 #endif
78569 {
78570 assert( pTask->list.aMemory==0 );
78571 vdbeSorterRecordFree(0, pTask->list.pList);
78572 }
78573 pTask->list.pList = 0;
78574 if( pTask->file.pFd ){
78575 sqlite3OsCloseFree(pTask->file.pFd);
78576 pTask->file.pFd = 0;
78577 pTask->file.iEof = 0;
78578 }
78579 if( pTask->file2.pFd ){
78580 sqlite3OsCloseFree(pTask->file2.pFd);
78581 pTask->file2.pFd = 0;
78582 pTask->file2.iEof = 0;
78583 }
 
78584 }
78585
78586 #ifdef SQLITE_DEBUG_SORTER_THREADS
78587 static void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){
78588 i64 t;
@@ -78758,10 +79126,11 @@
78758 vdbeMergeEngineFree(pSorter->pMerger);
78759 pSorter->pMerger = 0;
78760 for(i=0; i<pSorter->nTask; i++){
78761 SortSubtask *pTask = &pSorter->aTask[i];
78762 vdbeSortSubtaskCleanup(db, pTask);
 
78763 }
78764 if( pSorter->list.aMemory==0 ){
78765 vdbeSorterRecordFree(0, pSorter->list.pList);
78766 }
78767 pSorter->list.pList = 0;
@@ -78867,31 +79236,45 @@
78867 SorterRecord *p2, /* Second list to merge */
78868 SorterRecord **ppOut /* OUT: Head of merged list */
78869 ){
78870 SorterRecord *pFinal = 0;
78871 SorterRecord **pp = &pFinal;
78872 void *pVal2 = p2 ? SRVAL(p2) : 0;
78873
78874 while( p1 && p2 ){
78875 int res;
78876 res = vdbeSorterCompare(pTask, SRVAL(p1), p1->nVal, pVal2, p2->nVal);
 
 
 
78877 if( res<=0 ){
78878 *pp = p1;
78879 pp = &p1->u.pNext;
78880 p1 = p1->u.pNext;
78881 pVal2 = 0;
78882 }else{
78883 *pp = p2;
78884 pp = &p2->u.pNext;
78885 p2 = p2->u.pNext;
78886 if( p2==0 ) break;
78887 pVal2 = SRVAL(p2);
78888 }
78889 }
78890 *pp = p1 ? p1 : p2;
78891 *ppOut = pFinal;
78892 }
 
 
 
 
 
 
 
 
 
 
 
 
 
78893
78894 /*
78895 ** Sort the linked list of records headed at pTask->pList. Return
78896 ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
78897 ** an error occurs.
@@ -78903,16 +79286,18 @@
78903 int rc;
78904
78905 rc = vdbeSortAllocUnpacked(pTask);
78906 if( rc!=SQLITE_OK ) return rc;
78907
 
 
 
78908 aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));
78909 if( !aSlot ){
78910 return SQLITE_NOMEM;
78911 }
78912
78913 p = pList->pList;
78914 while( p ){
78915 SorterRecord *pNext;
78916 if( pList->aMemory ){
78917 if( (u8*)p==pList->aMemory ){
78918 pNext = 0;
@@ -79122,28 +79507,27 @@
79122 /* Update contents of aTree[] */
79123 if( rc==SQLITE_OK ){
79124 int i; /* Index of aTree[] to recalculate */
79125 PmaReader *pReadr1; /* First PmaReader to compare */
79126 PmaReader *pReadr2; /* Second PmaReader to compare */
79127 u8 *pKey2; /* To pReadr2->aKey, or 0 if record cached */
79128
79129 /* Find the first two PmaReaders to compare. The one that was just
79130 ** advanced (iPrev) and the one next to it in the array. */
79131 pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];
79132 pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];
79133 pKey2 = pReadr2->aKey;
79134
79135 for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){
79136 /* Compare pReadr1 and pReadr2. Store the result in variable iRes. */
79137 int iRes;
79138 if( pReadr1->pFd==0 ){
79139 iRes = +1;
79140 }else if( pReadr2->pFd==0 ){
79141 iRes = -1;
79142 }else{
79143 iRes = vdbeSorterCompare(pTask,
79144 pReadr1->aKey, pReadr1->nKey, pKey2, pReadr2->nKey
79145 );
79146 }
79147
79148 /* If pReadr1 contained the smaller value, set aTree[i] to its index.
79149 ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this
@@ -79161,13 +79545,13 @@
79161 ** is sorted from oldest to newest, so pReadr1 contains older values
79162 ** than pReadr2 iff (pReadr1<pReadr2). */
79163 if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){
79164 pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);
79165 pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
79166 pKey2 = pReadr2->aKey;
79167 }else{
79168 if( pReadr1->pFd ) pKey2 = 0;
79169 pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);
79170 pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
79171 }
79172 }
79173 *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);
@@ -79270,10 +79654,20 @@
79270 SorterRecord *pNew; /* New list element */
79271
79272 int bFlush; /* True to flush contents of memory to PMA */
79273 int nReq; /* Bytes of memory required */
79274 int nPMA; /* Bytes of PMA space required */
 
 
 
 
 
 
 
 
 
 
79275
79276 assert( pSorter );
79277
79278 /* Figure out whether or not the current contents of memory should be
79279 ** flushed to a PMA before continuing. If so, do so.
@@ -79535,14 +79929,16 @@
79535 if( p1->pFd==0 ){
79536 iRes = i2;
79537 }else if( p2->pFd==0 ){
79538 iRes = i1;
79539 }else{
 
 
79540 int res;
79541 assert( pMerger->pTask->pUnpacked!=0 ); /* from vdbeSortSubtaskMain() */
79542 res = vdbeSorterCompare(
79543 pMerger->pTask, p1->aKey, p1->nKey, p2->aKey, p2->nKey
79544 );
79545 if( res<=0 ){
79546 iRes = i1;
79547 }else{
79548 iRes = i2;
@@ -79562,15 +79958,16 @@
79562 */
79563 #define INCRINIT_NORMAL 0
79564 #define INCRINIT_TASK 1
79565 #define INCRINIT_ROOT 2
79566
79567 /* Forward reference.
79568 ** The vdbeIncrMergeInit() and vdbePmaReaderIncrMergeInit() routines call each
79569 ** other (when building a merge tree).
 
79570 */
79571 static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode);
79572
79573 /*
79574 ** Initialize the MergeEngine object passed as the second argument. Once this
79575 ** function returns, the first key of merged data may be read from the
79576 ** MergeEngine object in the usual fashion.
@@ -79613,11 +80010,11 @@
79613 ** the main thread to fill its buffer. So calling PmaReaderNext()
79614 ** on this PmaReader before any of the multi-threaded PmaReaders takes
79615 ** better advantage of multi-processor hardware. */
79616 rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);
79617 }else{
79618 rc = vdbePmaReaderIncrMergeInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
79619 }
79620 if( rc!=SQLITE_OK ) return rc;
79621 }
79622
79623 for(i=pMerger->nTree-1; i>0; i--){
@@ -79625,21 +80022,19 @@
79625 }
79626 return pTask->pUnpacked->errCode;
79627 }
79628
79629 /*
79630 ** Initialize the IncrMerge field of a PmaReader.
79631 **
79632 ** If the PmaReader passed as the first argument is not an incremental-reader
79633 ** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it serves
79634 ** to open and/or initialize the temp file related fields of the IncrMerge
79635 ** object at (pReadr->pIncr).
79636 **
79637 ** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders
79638 ** in the sub-tree headed by pReadr are also initialized. Data is then loaded
79639 ** into the buffers belonging to pReadr and it is set to
79640 ** point to the first key in its range.
79641 **
79642 ** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed
79643 ** to be a multi-threaded PmaReader and this function is being called in a
79644 ** background thread. In this case all PmaReaders in the sub-tree are
79645 ** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to
@@ -79662,93 +80057,112 @@
79662 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
79663 */
79664 static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){
79665 int rc = SQLITE_OK;
79666 IncrMerger *pIncr = pReadr->pIncr;
 
 
79667
79668 /* eMode is always INCRINIT_NORMAL in single-threaded mode */
79669 assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );
79670
79671 if( pIncr ){
79672 SortSubtask *pTask = pIncr->pTask;
79673 sqlite3 *db = pTask->pSorter->db;
79674
79675 rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
79676
79677 /* Set up the required files for pIncr. A multi-theaded IncrMerge object
79678 ** requires two temp files to itself, whereas a single-threaded object
79679 ** only requires a region of pTask->file2. */
79680 if( rc==SQLITE_OK ){
79681 int mxSz = pIncr->mxSz;
79682 #if SQLITE_MAX_WORKER_THREADS>0
79683 if( pIncr->bUseThread ){
79684 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
79685 if( rc==SQLITE_OK ){
79686 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
79687 }
79688 }else
79689 #endif
79690 /*if( !pIncr->bUseThread )*/{
79691 if( pTask->file2.pFd==0 ){
79692 assert( pTask->file2.iEof>0 );
79693 rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
79694 pTask->file2.iEof = 0;
79695 }
79696 if( rc==SQLITE_OK ){
79697 pIncr->aFile[1].pFd = pTask->file2.pFd;
79698 pIncr->iStartOff = pTask->file2.iEof;
79699 pTask->file2.iEof += mxSz;
79700 }
79701 }
79702 }
79703
79704 #if SQLITE_MAX_WORKER_THREADS>0
79705 if( rc==SQLITE_OK && pIncr->bUseThread ){
79706 /* Use the current thread to populate aFile[1], even though this
79707 ** PmaReader is multi-threaded. The reason being that this function
79708 ** is already running in background thread pIncr->pTask->thread. */
79709 assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );
79710 rc = vdbeIncrPopulate(pIncr);
79711 }
79712 #endif
79713
79714 if( rc==SQLITE_OK
79715 && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK)
79716 ){
79717 rc = vdbePmaReaderNext(pReadr);
79718 }
79719 }
 
79720 return rc;
79721 }
79722
79723 #if SQLITE_MAX_WORKER_THREADS>0
79724 /*
79725 ** The main routine for vdbePmaReaderIncrMergeInit() operations run in
79726 ** background threads.
79727 */
79728 static void *vdbePmaReaderBgInit(void *pCtx){
79729 PmaReader *pReader = (PmaReader*)pCtx;
79730 void *pRet = SQLITE_INT_TO_PTR(
79731 vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)
79732 );
79733 pReader->pIncr->pTask->bDone = 1;
79734 return pRet;
79735 }
 
79736
79737 /*
79738 ** Use a background thread to invoke vdbePmaReaderIncrMergeInit(INCRINIT_TASK)
79739 ** on the PmaReader object passed as the first argument.
79740 **
79741 ** This call will initialize the various fields of the pReadr->pIncr
79742 ** structure and, if it is a multi-threaded IncrMerger, launch a
79743 ** background thread to populate aFile[1].
 
 
 
79744 */
79745 static int vdbePmaReaderBgIncrInit(PmaReader *pReadr){
79746 void *pCtx = (void*)pReadr;
79747 return vdbeSorterCreateThread(pReadr->pIncr->pTask, vdbePmaReaderBgInit, pCtx);
 
 
 
 
 
 
 
 
 
 
 
 
 
79748 }
79749 #endif
79750
79751 /*
79752 ** Allocate a new MergeEngine object to merge the contents of nPMA level-0
79753 ** PMAs from pTask->file. If no error occurs, set *ppOut to point to
79754 ** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut
@@ -79956,10 +80370,15 @@
79956 int rc; /* Return code */
79957 SortSubtask *pTask0 = &pSorter->aTask[0];
79958 MergeEngine *pMain = 0;
79959 #if SQLITE_MAX_WORKER_THREADS
79960 sqlite3 *db = pTask0->pSorter->db;
 
 
 
 
 
79961 #endif
79962
79963 rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);
79964 if( rc==SQLITE_OK ){
79965 #if SQLITE_MAX_WORKER_THREADS
@@ -79984,19 +80403,25 @@
79984 vdbeIncrMergerSetThreads(pIncr);
79985 assert( pIncr->pTask!=pLast );
79986 }
79987 }
79988 for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){
 
 
 
 
 
 
 
 
 
79989 PmaReader *p = &pMain->aReadr[iTask];
79990 assert( p->pIncr==0 || p->pIncr->pTask==&pSorter->aTask[iTask] );
79991 if( p->pIncr ){
79992 if( iTask==pSorter->nTask-1 ){
79993 rc = vdbePmaReaderIncrMergeInit(p, INCRINIT_TASK);
79994 }else{
79995 rc = vdbePmaReaderBgIncrInit(p);
79996 }
79997 }
79998 }
79999 }
80000 pMain = 0;
80001 }
80002 if( rc==SQLITE_OK ){
@@ -80947,11 +81372,11 @@
80947 ** Should be transformed into:
80948 **
80949 ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;
80950 **
80951 ** The nSubquery parameter specifies how many levels of subquery the
80952 ** alias is removed from the original expression. The usually value is
80953 ** zero but it might be more if the alias is contained within a subquery
80954 ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION
80955 ** structures must be increased by the nSubquery amount.
80956 */
80957 static void resolveAlias(
@@ -80967,11 +81392,10 @@
80967 sqlite3 *db; /* The database connection */
80968
80969 assert( iCol>=0 && iCol<pEList->nExpr );
80970 pOrig = pEList->a[iCol].pExpr;
80971 assert( pOrig!=0 );
80972 assert( pOrig->flags & EP_Resolved );
80973 db = pParse->db;
80974 pDup = sqlite3ExprDup(db, pOrig, 0);
80975 if( pDup==0 ) return;
80976 if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){
80977 incrAggFunctionDepth(pDup, nSubquery);
@@ -81861,13 +82285,15 @@
81861 pNew->flags |= EP_IntValue;
81862 pNew->u.iValue = iCol;
81863 if( pItem->pExpr==pE ){
81864 pItem->pExpr = pNew;
81865 }else{
81866 assert( pItem->pExpr->op==TK_COLLATE );
81867 assert( pItem->pExpr->pLeft==pE );
81868 pItem->pExpr->pLeft = pNew;
 
 
81869 }
81870 sqlite3ExprDelete(db, pE);
81871 pItem->u.x.iOrderByCol = (u16)iCol;
81872 pItem->done = 1;
81873 }else{
@@ -82054,10 +82480,24 @@
82054 sNC.pParse = pParse;
82055 if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||
82056 sqlite3ResolveExprNames(&sNC, p->pOffset) ){
82057 return WRC_Abort;
82058 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82059
82060 /* Recursively resolve names in all subqueries
82061 */
82062 for(i=0; i<p->pSrc->nSrc; i++){
82063 struct SrcList_item *pItem = &p->pSrc->a[i];
@@ -82135,17 +82575,35 @@
82135 /* The ORDER BY and GROUP BY clauses may not refer to terms in
82136 ** outer queries
82137 */
82138 sNC.pNext = 0;
82139 sNC.ncFlags |= NC_AllowAgg;
 
 
 
 
 
 
 
 
 
 
 
82140
82141 /* Process the ORDER BY clause for singleton SELECT statements.
82142 ** The ORDER BY clause for compounds SELECT statements is handled
82143 ** below, after all of the result-sets for all of the elements of
82144 ** the compound have been resolved.
 
 
 
 
 
82145 */
82146 if( !isCompound && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER") ){
 
 
82147 return WRC_Abort;
82148 }
82149 if( db->mallocFailed ){
82150 return WRC_Abort;
82151 }
@@ -83593,11 +84051,12 @@
83593 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
83594 int i;
83595 u32 m = 0;
83596 if( pList ){
83597 for(i=0; i<pList->nExpr; i++){
83598 m |= pList->a[i].pExpr->flags;
 
83599 }
83600 }
83601 return m;
83602 }
83603
@@ -84033,11 +84492,11 @@
84033 /* Check to see if an existing table or index can be used to
84034 ** satisfy the query. This is preferable to generating a new
84035 ** ephemeral table.
84036 */
84037 p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
84038 if( ALWAYS(pParse->nErr==0) && isCandidateForInOpt(p) ){
84039 sqlite3 *db = pParse->db; /* Database connection */
84040 Table *pTab; /* Table <table>. */
84041 Expr *pExpr; /* Expression <column> */
84042 i16 iCol; /* Index of column <column> */
84043 i16 iDb; /* Database idx for pTab */
@@ -84358,10 +84817,11 @@
84358 }
84359 sqlite3ExprDelete(pParse->db, pSel->pLimit);
84360 pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0,
84361 &sqlite3IntTokens[1]);
84362 pSel->iLimit = 0;
 
84363 if( sqlite3Select(pParse, pSel, &dest) ){
84364 return 0;
84365 }
84366 rReg = dest.iSDParm;
84367 ExprSetVVAProperty(pExpr, EP_NoReduce);
@@ -85723,11 +86183,11 @@
85723 sqlite3TreeViewLine(pView,"AS %Q", pExpr->u.zToken);
85724 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
85725 break;
85726 }
85727 case TK_ID: {
85728 sqlite3TreeViewLine(pView,"ID %Q", pExpr->u.zToken);
85729 break;
85730 }
85731 #ifndef SQLITE_OMIT_CAST
85732 case TK_CAST: {
85733 /* Expressions of the form: CAST(pLeft AS token) */
@@ -86358,11 +86818,11 @@
86358 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
86359 if( combinedFlags & EP_xIsSelect ) return 2;
86360 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
86361 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
86362 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
86363 if( ALWAYS((combinedFlags & EP_Reduced)==0) ){
86364 if( pA->iColumn!=pB->iColumn ) return 2;
86365 if( pA->iTable!=pB->iTable
86366 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
86367 }
86368 }
@@ -86890,10 +87350,11 @@
86890 do {
86891 z += n;
86892 n = sqlite3GetToken(z, &token);
86893 }while( token==TK_SPACE );
86894
 
86895 zParent = sqlite3DbStrNDup(db, (const char *)z, n);
86896 if( zParent==0 ) break;
86897 sqlite3Dequote(zParent);
86898 if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
86899 char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
@@ -89116,18 +89577,21 @@
89116 pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
89117 }
89118 z = argv[2];
89119
89120 if( pIndex ){
 
89121 int nCol = pIndex->nKeyCol+1;
89122 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
89123 tRowcnt * const aiRowEst = pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(
89124 sizeof(tRowcnt) * nCol
89125 );
89126 if( aiRowEst==0 ) pInfo->db->mallocFailed = 1;
89127 #else
89128 tRowcnt * const aiRowEst = 0;
 
 
89129 #endif
89130 pIndex->bUnordered = 0;
89131 decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
89132 if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0];
89133 }else{
@@ -89786,11 +90250,11 @@
89786 }
89787
89788 sqlite3BtreeClose(pDb->pBt);
89789 pDb->pBt = 0;
89790 pDb->pSchema = 0;
89791 sqlite3ResetAllSchemasOfConnection(db);
89792 return;
89793
89794 detach_error:
89795 sqlite3_result_error(context, zErr, -1);
89796 }
@@ -89820,11 +90284,10 @@
89820 if(
89821 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
89822 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
89823 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
89824 ){
89825 pParse->nErr++;
89826 goto attach_end;
89827 }
89828
89829 #ifndef SQLITE_OMIT_AUTHORIZATION
89830 if( pAuthArg ){
@@ -90142,11 +90605,11 @@
90142 ** and attempts to write the column will be ignored.
90143 **
90144 ** Setting the auth function to NULL disables this hook. The default
90145 ** setting of the auth function is NULL.
90146 */
90147 SQLITE_API int sqlite3_set_authorizer(
90148 sqlite3 *db,
90149 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
90150 void *pArg
90151 ){
90152 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -90479,13 +90942,15 @@
90479 sqlite3 *db;
90480 Vdbe *v;
90481
90482 assert( pParse->pToplevel==0 );
90483 db = pParse->db;
90484 if( db->mallocFailed ) return;
90485 if( pParse->nested ) return;
90486 if( pParse->nErr ) return;
 
 
 
90487
90488 /* Begin by generating some termination code at the end of the
90489 ** vdbe program
90490 */
90491 v = sqlite3GetVdbe(pParse);
@@ -90563,11 +91028,11 @@
90563 }
90564
90565
90566 /* Get the VDBE program ready for execution
90567 */
90568 if( v && ALWAYS(pParse->nErr==0) && !db->mallocFailed ){
90569 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
90570 /* A minimum of one cursor is required if autoincrement is used
90571 * See ticket [a696379c1f08866] */
90572 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
90573 sqlite3VdbeMakeReady(v, pParse);
@@ -91098,18 +91563,16 @@
91098 sqlite3 *db = pParse->db;
91099
91100 if( ALWAYS(pName2!=0) && pName2->n>0 ){
91101 if( db->init.busy ) {
91102 sqlite3ErrorMsg(pParse, "corrupt database");
91103 pParse->nErr++;
91104 return -1;
91105 }
91106 *pUnqual = pName2;
91107 iDb = sqlite3FindDb(db, pName1);
91108 if( iDb<0 ){
91109 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
91110 pParse->nErr++;
91111 return -1;
91112 }
91113 }else{
91114 assert( db->init.iDb==0 || db->init.busy );
91115 iDb = db->init.iDb;
@@ -91264,11 +91727,11 @@
91264 pTable = sqlite3FindTable(db, zName, zDb);
91265 if( pTable ){
91266 if( !noErr ){
91267 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
91268 }else{
91269 assert( !db->init.busy );
91270 sqlite3CodeVerifySchema(pParse, iDb);
91271 }
91272 goto begin_table_error;
91273 }
91274 if( sqlite3FindIndex(db, zName, zDb)!=0 ){
@@ -91553,11 +92016,12 @@
91553 Column *pCol;
91554
91555 p = pParse->pNewTable;
91556 if( p==0 || NEVER(p->nCol<1) ) return;
91557 pCol = &p->aCol[p->nCol-1];
91558 assert( pCol->zType==0 );
 
91559 pCol->zType = sqlite3NameFromToken(pParse->db, pType);
91560 pCol->affinity = sqlite3AffinityType(pCol->zType, &pCol->szEst);
91561 }
91562
91563 /*
@@ -92787,10 +93251,11 @@
92787 if( db->mallocFailed ){
92788 goto exit_drop_table;
92789 }
92790 assert( pParse->nErr==0 );
92791 assert( pName->nSrc==1 );
 
92792 if( noErr ) db->suppressErr++;
92793 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
92794 if( noErr ) db->suppressErr--;
92795
92796 if( pTab==0 ){
@@ -93100,11 +93565,12 @@
93100 sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
93101 }else{
93102 addr2 = sqlite3VdbeCurrentAddr(v);
93103 }
93104 sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
93105 sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 1);
 
93106 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
93107 sqlite3ReleaseTempReg(pParse, regRecord);
93108 sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);
93109 sqlite3VdbeJumpHere(v, addr1);
93110
@@ -93193,12 +93659,11 @@
93193 int nExtra = 0; /* Space allocated for zExtra[] */
93194 int nExtraCol; /* Number of extra columns needed */
93195 char *zExtra = 0; /* Extra space after the Index object */
93196 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
93197
93198 assert( pParse->nErr==0 ); /* Never called with prior errors */
93199 if( db->mallocFailed || IN_DECLARE_VTAB ){
93200 goto exit_create_index;
93201 }
93202 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
93203 goto exit_create_index;
93204 }
@@ -94113,11 +94578,10 @@
94113 ** operator with A. This routine shifts that operator over to B.
94114 */
94115 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){
94116 if( p ){
94117 int i;
94118 assert( p->a || p->nSrc==0 );
94119 for(i=p->nSrc-1; i>0; i--){
94120 p->a[i].jointype = p->a[i-1].jointype;
94121 }
94122 p->a[0].jointype = 0;
94123 }
@@ -94360,12 +94824,11 @@
94360 char *zErr;
94361 int j;
94362 StrAccum errMsg;
94363 Table *pTab = pIdx->pTable;
94364
94365 sqlite3StrAccumInit(&errMsg, 0, 0, 200);
94366 errMsg.db = pParse->db;
94367 for(j=0; j<pIdx->nKeyCol; j++){
94368 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
94369 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
94370 sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
94371 sqlite3StrAccumAppend(&errMsg, ".", 1);
@@ -96190,17 +96653,17 @@
96190 ){
96191 PrintfArguments x;
96192 StrAccum str;
96193 const char *zFormat;
96194 int n;
 
96195
96196 if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){
96197 x.nArg = argc-1;
96198 x.nUsed = 0;
96199 x.apArg = argv+1;
96200 sqlite3StrAccumInit(&str, 0, 0, SQLITE_MAX_LENGTH);
96201 str.db = sqlite3_context_db_handle(context);
96202 sqlite3XPrintf(&str, SQLITE_PRINTF_SQLFUNC, zFormat, &x);
96203 n = str.nChar;
96204 sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
96205 SQLITE_DYNAMIC);
96206 }
@@ -96346,11 +96809,11 @@
96346 sqlite3_result_double(context, r);
96347 }
96348 #endif
96349
96350 /*
96351 ** Allocate nByte bytes of space using sqlite3_malloc(). If the
96352 ** allocation fails, call sqlite3_result_error_nomem() to notify
96353 ** the database handle that malloc() has failed and return NULL.
96354 ** If nByte is larger than the maximum string or blob length, then
96355 ** raise an SQLITE_TOOBIG exception and return NULL.
96356 */
@@ -96720,11 +97183,11 @@
96720 }
96721
96722 /*
96723 ** The sqlite3_strglob() interface.
96724 */
96725 SQLITE_API int sqlite3_strglob(const char *zGlobPattern, const char *zString){
96726 return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
96727 }
96728
96729 /*
96730 ** Count the number of times that the LIKE operator (or GLOB which is
@@ -97015,11 +97478,11 @@
97015 int argc,
97016 sqlite3_value **argv
97017 ){
97018 unsigned char *z, *zOut;
97019 int i;
97020 zOut = z = sqlite3_malloc( argc*4+1 );
97021 if( z==0 ){
97022 sqlite3_result_error_nomem(context);
97023 return;
97024 }
97025 for(i=0; i<argc; i++){
@@ -97163,11 +97626,11 @@
97163 sqlite3_result_error_toobig(context);
97164 sqlite3_free(zOut);
97165 return;
97166 }
97167 zOld = zOut;
97168 zOut = sqlite3_realloc(zOut, (int)nOut);
97169 if( zOut==0 ){
97170 sqlite3_result_error_nomem(context);
97171 sqlite3_free(zOld);
97172 return;
97173 }
@@ -97525,12 +97988,11 @@
97525 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
97526 pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
97527
97528 if( pAccum ){
97529 sqlite3 *db = sqlite3_context_db_handle(context);
97530 int firstTerm = pAccum->useMalloc==0;
97531 pAccum->useMalloc = 2;
97532 pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
97533 if( !firstTerm ){
97534 if( argc==2 ){
97535 zSep = (char*)sqlite3_value_text(argv[1]);
97536 nSep = sqlite3_value_bytes(argv[1]);
@@ -98946,11 +99408,12 @@
98946 int iFromCol; /* Idx of column in child table */
98947 Expr *pEq; /* tFromCol = OLD.tToCol */
98948
98949 iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
98950 assert( iFromCol>=0 );
98951 tToCol.z = pIdx ? pTab->aCol[pIdx->aiColumn[i]].zName : "oid";
 
98952 tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;
98953
98954 tToCol.n = sqlite3Strlen30(tToCol.z);
98955 tFromCol.n = sqlite3Strlen30(tFromCol.z);
98956
@@ -98958,14 +99421,14 @@
98958 ** that the "OLD.zToCol" term is on the LHS of the = operator, so
98959 ** that the affinity and collation sequence associated with the
98960 ** parent table are used for the comparison. */
98961 pEq = sqlite3PExpr(pParse, TK_EQ,
98962 sqlite3PExpr(pParse, TK_DOT,
98963 sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
98964 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
98965 , 0),
98966 sqlite3PExpr(pParse, TK_ID, 0, 0, &tFromCol)
98967 , 0);
98968 pWhere = sqlite3ExprAnd(db, pWhere, pEq);
98969
98970 /* For ON UPDATE, construct the next term of the WHEN clause.
98971 ** The final WHEN clause will be like this:
@@ -98973,27 +99436,27 @@
98973 ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)
98974 */
98975 if( pChanges ){
98976 pEq = sqlite3PExpr(pParse, TK_IS,
98977 sqlite3PExpr(pParse, TK_DOT,
98978 sqlite3PExpr(pParse, TK_ID, 0, 0, &tOld),
98979 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
98980 0),
98981 sqlite3PExpr(pParse, TK_DOT,
98982 sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
98983 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol),
98984 0),
98985 0);
98986 pWhen = sqlite3ExprAnd(db, pWhen, pEq);
98987 }
98988
98989 if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){
98990 Expr *pNew;
98991 if( action==OE_Cascade ){
98992 pNew = sqlite3PExpr(pParse, TK_DOT,
98993 sqlite3PExpr(pParse, TK_ID, 0, 0, &tNew),
98994 sqlite3PExpr(pParse, TK_ID, 0, 0, &tToCol)
98995 , 0);
98996 }else if( action==OE_SetDflt ){
98997 Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
98998 if( pDflt ){
98999 pNew = sqlite3ExprDup(db, pDflt, 0);
@@ -99036,17 +99499,16 @@
99036 db->lookaside.bEnabled = 0;
99037
99038 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
99039 sizeof(Trigger) + /* struct Trigger */
99040 sizeof(TriggerStep) + /* Single step in trigger program */
99041 nFrom + 1 /* Space for pStep->target.z */
99042 );
99043 if( pTrigger ){
99044 pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
99045 pStep->target.z = (char *)&pStep[1];
99046 pStep->target.n = nFrom;
99047 memcpy((char *)pStep->target.z, zFrom, nFrom);
99048
99049 pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
99050 pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
99051 pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
99052 if( pWhen ){
@@ -99507,24 +99969,27 @@
99507 );
99508
99509 /*
99510 ** This routine is called to handle SQL of the following forms:
99511 **
99512 ** insert into TABLE (IDLIST) values(EXPRLIST)
99513 ** insert into TABLE (IDLIST) select
 
99514 **
99515 ** The IDLIST following the table name is always optional. If omitted,
99516 ** then a list of all columns for the table is substituted. The IDLIST
99517 ** appears in the pColumn parameter. pColumn is NULL if IDLIST is omitted.
 
99518 **
99519 ** The pList parameter holds EXPRLIST in the first form of the INSERT
99520 ** statement above, and pSelect is NULL. For the second form, pList is
99521 ** NULL and pSelect is a pointer to the select statement used to generate
99522 ** data for the insert.
 
99523 **
99524 ** The code generated follows one of four templates. For a simple
99525 ** insert with data coming from a VALUES clause, the code executes
99526 ** once straight down through. Pseudo-code follows (we call this
99527 ** the "1st template"):
99528 **
99529 ** open write cursor to <table> and its indices
99530 ** put VALUES clause expressions into registers
@@ -99627,11 +100092,11 @@
99627 int iDb; /* Index of database holding TABLE */
99628 Db *pDb; /* The database containing table being inserted into */
99629 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
99630 u8 appendFlag = 0; /* True if the insert is likely to be an append */
99631 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
99632 u8 bIdListInOrder = 1; /* True if IDLIST is in table order */
99633 ExprList *pList = 0; /* List of VALUES() to be inserted */
99634
99635 /* Register allocations */
99636 int regFromSelect = 0;/* Base register for data coming from SELECT */
99637 int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
@@ -99652,12 +100117,12 @@
99652 if( pParse->nErr || db->mallocFailed ){
99653 goto insert_cleanup;
99654 }
99655
99656 /* If the Select object is really just a simple VALUES() list with a
99657 ** single row values (the common case) then keep that one row of values
99658 ** and go ahead and discard the Select object
99659 */
99660 if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){
99661 pList = pSelect->pEList;
99662 pSelect->pEList = 0;
99663 sqlite3SelectDelete(db, pSelect);
@@ -99761,10 +100226,11 @@
99761 ** the index into IDLIST of the primary key column. ipkColumn is
99762 ** the index of the primary key as it appears in IDLIST, not as
99763 ** is appears in the original table. (The index of the INTEGER
99764 ** PRIMARY KEY in the original table is pTab->iPKey.)
99765 */
 
99766 if( pColumn ){
99767 for(i=0; i<pColumn->nId; i++){
99768 pColumn->a[i].idx = -1;
99769 }
99770 for(i=0; i<pColumn->nId; i++){
@@ -99796,11 +100262,12 @@
99796 ** is coming from a SELECT statement, then generate a co-routine that
99797 ** produces a single row of the SELECT on each invocation. The
99798 ** co-routine is the common header to the 3rd and 4th templates.
99799 */
99800 if( pSelect ){
99801 /* Data is coming from a SELECT. Generate a co-routine to run the SELECT */
 
99802 int regYield; /* Register holding co-routine entry-point */
99803 int addrTop; /* Top of the co-routine */
99804 int rc; /* Result code */
99805
99806 regYield = ++pParse->nMem;
@@ -99809,12 +100276,11 @@
99809 sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
99810 dest.iSdst = bIdListInOrder ? regData : 0;
99811 dest.nSdst = pTab->nCol;
99812 rc = sqlite3Select(pParse, pSelect, &dest);
99813 regFromSelect = dest.iSdst;
99814 assert( pParse->nErr==0 || rc );
99815 if( rc || db->mallocFailed ) goto insert_cleanup;
99816 sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
99817 sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
99818 assert( pSelect->pEList );
99819 nColumn = pSelect->pEList->nExpr;
99820
@@ -99858,12 +100324,12 @@
99858 sqlite3VdbeJumpHere(v, addrL);
99859 sqlite3ReleaseTempReg(pParse, regRec);
99860 sqlite3ReleaseTempReg(pParse, regTempRowid);
99861 }
99862 }else{
99863 /* This is the case if the data for the INSERT is coming from a VALUES
99864 ** clause
99865 */
99866 NameContext sNC;
99867 memset(&sNC, 0, sizeof(sNC));
99868 sNC.pParse = pParse;
99869 srcTab = -1;
@@ -100930,10 +101396,11 @@
100930 Table *pDest, /* The table we are inserting into */
100931 Select *pSelect, /* A SELECT statement to use as the data source */
100932 int onError, /* How to handle constraint errors */
100933 int iDbDest /* The database of pDest */
100934 ){
 
100935 ExprList *pEList; /* The result set of the SELECT */
100936 Table *pSrc; /* The table in the FROM clause of SELECT */
100937 Index *pSrcIdx, *pDestIdx; /* Source and destination indices */
100938 struct SrcList_item *pItem; /* An element of pSelect->pSrc */
100939 int i; /* Loop counter */
@@ -101077,15 +101544,15 @@
101077 ** But the main beneficiary of the transfer optimization is the VACUUM
101078 ** command, and the VACUUM command disables foreign key constraints. So
101079 ** the extra complication to make this rule less restrictive is probably
101080 ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
101081 */
101082 if( (pParse->db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
101083 return 0;
101084 }
101085 #endif
101086 if( (pParse->db->flags & SQLITE_CountRows)!=0 ){
101087 return 0; /* xfer opt does not play well with PRAGMA count_changes */
101088 }
101089
101090 /* If we get this far, it means that the xfer optimization is at
101091 ** least a possibility, though it might only work if the destination
@@ -101092,28 +101559,32 @@
101092 ** table (tab1) is initially empty.
101093 */
101094 #ifdef SQLITE_TEST
101095 sqlite3_xferopt_count++;
101096 #endif
101097 iDbSrc = sqlite3SchemaToIndex(pParse->db, pSrc->pSchema);
101098 v = sqlite3GetVdbe(pParse);
101099 sqlite3CodeVerifySchema(pParse, iDbSrc);
101100 iSrc = pParse->nTab++;
101101 iDest = pParse->nTab++;
101102 regAutoinc = autoIncBegin(pParse, iDbDest, pDest);
101103 regData = sqlite3GetTempReg(pParse);
101104 regRowid = sqlite3GetTempReg(pParse);
101105 sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);
101106 assert( HasRowid(pDest) || destHasUniqueIdx );
101107 if( (pDest->iPKey<0 && pDest->pIndex!=0) /* (1) */
 
101108 || destHasUniqueIdx /* (2) */
101109 || (onError!=OE_Abort && onError!=OE_Rollback) /* (3) */
101110 ){
101111 /* In some circumstances, we are able to run the xfer optimization
101112 ** only if the destination table is initially empty. This code makes
101113 ** that determination. Conditions under which the destination must
101114 ** be empty:
 
 
 
101115 **
101116 ** (1) There is no INTEGER PRIMARY KEY but there are indices.
101117 ** (If the destination is not initially empty, the rowid fields
101118 ** of index entries might need to change.)
101119 **
@@ -101152,10 +101623,11 @@
101152 }else{
101153 sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);
101154 sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);
101155 }
101156 for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){
 
101157 for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){
101158 if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;
101159 }
101160 assert( pSrcIdx );
101161 sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);
@@ -101165,11 +101637,37 @@
101165 sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);
101166 sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
101167 VdbeComment((v, "%s", pDestIdx->zName));
101168 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
101169 sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101170 sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);
 
101171 sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);
101172 sqlite3VdbeJumpHere(v, addr1);
101173 sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
101174 sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
101175 }
@@ -101215,11 +101713,11 @@
101215 ** If the SQL is a query, then for each row in the query result
101216 ** the xCallback() function is called. pArg becomes the first
101217 ** argument to xCallback(). If xCallback=NULL then no callback
101218 ** is invoked, even for queries.
101219 */
101220 SQLITE_API int sqlite3_exec(
101221 sqlite3 *db, /* The database on which the SQL executes */
101222 const char *zSql, /* The SQL to be executed */
101223 sqlite3_callback xCallback, /* Invoke this callback routine */
101224 void *pArg, /* First argument to xCallback() */
101225 char **pzErrMsg /* Write error messages here */
@@ -102284,11 +102782,11 @@
102284 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
102285 char *zErrmsg = 0;
102286 const char *zEntry;
102287 char *zAltEntry = 0;
102288 void **aHandle;
102289 int nMsg = 300 + sqlite3Strlen30(zFile);
102290 int ii;
102291
102292 /* Shared library endings to try if zFile cannot be loaded as written */
102293 static const char *azEndings[] = {
102294 #if SQLITE_OS_WIN
@@ -102327,11 +102825,11 @@
102327 sqlite3_free(zAltFile);
102328 }
102329 #endif
102330 if( handle==0 ){
102331 if( pzErrMsg ){
102332 *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
102333 if( zErrmsg ){
102334 sqlite3_snprintf(nMsg, zErrmsg,
102335 "unable to open shared library [%s]", zFile);
102336 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102337 }
@@ -102353,11 +102851,11 @@
102353 ** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init
102354 */
102355 if( xInit==0 && zProc==0 ){
102356 int iFile, iEntry, c;
102357 int ncFile = sqlite3Strlen30(zFile);
102358 zAltEntry = sqlite3_malloc(ncFile+30);
102359 if( zAltEntry==0 ){
102360 sqlite3OsDlClose(pVfs, handle);
102361 return SQLITE_NOMEM;
102362 }
102363 memcpy(zAltEntry, "sqlite3_", 8);
@@ -102375,11 +102873,11 @@
102375 sqlite3OsDlSym(pVfs, handle, zEntry);
102376 }
102377 if( xInit==0 ){
102378 if( pzErrMsg ){
102379 nMsg += sqlite3Strlen30(zEntry);
102380 *pzErrMsg = zErrmsg = sqlite3_malloc(nMsg);
102381 if( zErrmsg ){
102382 sqlite3_snprintf(nMsg, zErrmsg,
102383 "no entry point [%s] in shared library [%s]", zEntry, zFile);
102384 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102385 }
@@ -102410,11 +102908,11 @@
102410 db->aExtension = aHandle;
102411
102412 db->aExtension[db->nExtension++] = handle;
102413 return SQLITE_OK;
102414 }
102415 SQLITE_API int sqlite3_load_extension(
102416 sqlite3 *db, /* Load the extension into this database connection */
102417 const char *zFile, /* Name of the shared library containing extension */
102418 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102419 char **pzErrMsg /* Put error message here if not 0 */
102420 ){
@@ -102441,11 +102939,11 @@
102441
102442 /*
102443 ** Enable or disable extension loading. Extension loading is disabled by
102444 ** default so as not to open security holes in older applications.
102445 */
102446 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102447 sqlite3_mutex_enter(db->mutex);
102448 if( onoff ){
102449 db->flags |= SQLITE_LoadExtension;
102450 }else{
102451 db->flags &= ~SQLITE_LoadExtension;
@@ -102474,11 +102972,11 @@
102474 ** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER
102475 ** mutex must be held while accessing this list.
102476 */
102477 typedef struct sqlite3AutoExtList sqlite3AutoExtList;
102478 static SQLITE_WSD struct sqlite3AutoExtList {
102479 int nExt; /* Number of entries in aExt[] */
102480 void (**aExt)(void); /* Pointers to the extension init functions */
102481 } sqlite3Autoext = { 0, 0 };
102482
102483 /* The "wsdAutoext" macro will resolve to the autoextension
102484 ** state vector. If writable static data is unsupported on the target,
@@ -102498,32 +102996,32 @@
102498
102499 /*
102500 ** Register a statically linked extension that is automatically
102501 ** loaded by every new database connection.
102502 */
102503 SQLITE_API int sqlite3_auto_extension(void (*xInit)(void)){
102504 int rc = SQLITE_OK;
102505 #ifndef SQLITE_OMIT_AUTOINIT
102506 rc = sqlite3_initialize();
102507 if( rc ){
102508 return rc;
102509 }else
102510 #endif
102511 {
102512 int i;
102513 #if SQLITE_THREADSAFE
102514 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102515 #endif
102516 wsdAutoextInit;
102517 sqlite3_mutex_enter(mutex);
102518 for(i=0; i<wsdAutoext.nExt; i++){
102519 if( wsdAutoext.aExt[i]==xInit ) break;
102520 }
102521 if( i==wsdAutoext.nExt ){
102522 int nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);
102523 void (**aNew)(void);
102524 aNew = sqlite3_realloc(wsdAutoext.aExt, nByte);
102525 if( aNew==0 ){
102526 rc = SQLITE_NOMEM;
102527 }else{
102528 wsdAutoext.aExt = aNew;
102529 wsdAutoext.aExt[wsdAutoext.nExt] = xInit;
@@ -102543,19 +103041,19 @@
102543 ** routine is a no-op.
102544 **
102545 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
102546 ** was not on the list.
102547 */
102548 SQLITE_API int sqlite3_cancel_auto_extension(void (*xInit)(void)){
102549 #if SQLITE_THREADSAFE
102550 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
102551 #endif
102552 int i;
102553 int n = 0;
102554 wsdAutoextInit;
102555 sqlite3_mutex_enter(mutex);
102556 for(i=wsdAutoext.nExt-1; i>=0; i--){
102557 if( wsdAutoext.aExt[i]==xInit ){
102558 wsdAutoext.nExt--;
102559 wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];
102560 n++;
102561 break;
@@ -102566,11 +103064,11 @@
102566 }
102567
102568 /*
102569 ** Reset the automatic extension loading mechanism.
102570 */
102571 SQLITE_API void sqlite3_reset_auto_extension(void){
102572 #ifndef SQLITE_OMIT_AUTOINIT
102573 if( sqlite3_initialize()==SQLITE_OK )
102574 #endif
102575 {
102576 #if SQLITE_THREADSAFE
@@ -102589,11 +103087,11 @@
102589 ** Load all automatic extensions.
102590 **
102591 ** If anything goes wrong, set an error in the database connection.
102592 */
102593 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
102594 int i;
102595 int go = 1;
102596 int rc;
102597 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
102598
102599 wsdAutoextInit;
@@ -103253,19 +103751,19 @@
103253 /*
103254 ** Generate code to return a single integer value.
103255 */
103256 static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
103257 Vdbe *v = sqlite3GetVdbe(pParse);
103258 int mem = ++pParse->nMem;
103259 i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
103260 if( pI64 ){
103261 memcpy(pI64, &value, sizeof(value));
103262 }
103263 sqlite3VdbeAddOp4(v, OP_Int64, 0, mem, 0, (char*)pI64, P4_INT64);
103264 sqlite3VdbeSetNumCols(v, 1);
103265 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
103266 sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
103267 }
103268
103269
103270 /*
103271 ** Set the safety_level and pager flags for pager iDb. Or if iDb<0
@@ -103426,15 +103924,15 @@
103426 aFcntl[3] = 0;
103427 db->busyHandler.nBusy = 0;
103428 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
103429 if( rc==SQLITE_OK ){
103430 if( aFcntl[0] ){
103431 int mem = ++pParse->nMem;
103432 sqlite3VdbeAddOp4(v, OP_String8, 0, mem, 0, aFcntl[0], 0);
103433 sqlite3VdbeSetNumCols(v, 1);
103434 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
103435 sqlite3VdbeAddOp2(v, OP_ResultRow, mem, 1);
103436 sqlite3_free(aFcntl[0]);
103437 }
103438 goto pragma_out;
103439 }
103440 if( rc!=SQLITE_NOTFOUND ){
@@ -104035,11 +104533,13 @@
104035 }else{
104036 if( !db->autoCommit ){
104037 sqlite3ErrorMsg(pParse,
104038 "Safety level may not be changed inside a transaction");
104039 }else{
104040 pDb->safety_level = getSafetyLevel(zRight,0,1)+1;
 
 
104041 setAllPagerFlags(db);
104042 }
104043 }
104044 break;
104045 }
@@ -104130,11 +104630,11 @@
104130 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
104131 k = 0;
104132 }else if( pPk==0 ){
104133 k = 1;
104134 }else{
104135 for(k=1; ALWAYS(k<=pTab->nCol) && pPk->aiColumn[k-1]!=i; k++){}
104136 }
104137 sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
104138 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
104139 }
104140 }
@@ -105136,11 +105636,11 @@
105136
105137 assert( iDb>=0 && iDb<db->nDb );
105138 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
105139 if( argv[1]==0 ){
105140 corruptSchema(pData, argv[0], 0);
105141 }else if( argv[2] && argv[2][0] ){
105142 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
105143 ** But because db->init.busy is set to 1, no VDBE code is generated
105144 ** or executed. All the parser does is build the internal data
105145 ** structures that describe the table, index, or view.
105146 */
@@ -105167,12 +105667,12 @@
105167 corruptSchema(pData, argv[0], sqlite3_errmsg(db));
105168 }
105169 }
105170 }
105171 sqlite3_finalize(pStmt);
105172 }else if( argv[0]==0 ){
105173 corruptSchema(pData, 0, 0);
105174 }else{
105175 /* If the SQL column is blank it means this is an index that
105176 ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
105177 ** constraint for a CREATE TABLE. The index should have already
105178 ** been created when we processed the CREATE TABLE. All we have
@@ -105846,11 +106346,11 @@
105846 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105847 ** sqlite3_step(). In the new version, the original SQL text is retained
105848 ** and the statement is automatically recompiled if an schema change
105849 ** occurs.
105850 */
105851 SQLITE_API int sqlite3_prepare(
105852 sqlite3 *db, /* Database handle. */
105853 const char *zSql, /* UTF-8 encoded SQL statement. */
105854 int nBytes, /* Length of zSql in bytes. */
105855 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105856 const char **pzTail /* OUT: End of parsed string */
@@ -105858,11 +106358,11 @@
105858 int rc;
105859 rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
105860 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105861 return rc;
105862 }
105863 SQLITE_API int sqlite3_prepare_v2(
105864 sqlite3 *db, /* Database handle. */
105865 const char *zSql, /* UTF-8 encoded SQL statement. */
105866 int nBytes, /* Length of zSql in bytes. */
105867 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105868 const char **pzTail /* OUT: End of parsed string */
@@ -105934,11 +106434,11 @@
105934 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
105935 ** sqlite3_step(). In the new version, the original SQL text is retained
105936 ** and the statement is automatically recompiled if an schema change
105937 ** occurs.
105938 */
105939 SQLITE_API int sqlite3_prepare16(
105940 sqlite3 *db, /* Database handle. */
105941 const void *zSql, /* UTF-16 encoded SQL statement. */
105942 int nBytes, /* Length of zSql in bytes. */
105943 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105944 const void **pzTail /* OUT: End of parsed string */
@@ -105946,11 +106446,11 @@
105946 int rc;
105947 rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
105948 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
105949 return rc;
105950 }
105951 SQLITE_API int sqlite3_prepare16_v2(
105952 sqlite3 *db, /* Database handle. */
105953 const void *zSql, /* UTF-16 encoded SQL statement. */
105954 int nBytes, /* Length of zSql in bytes. */
105955 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
105956 const void **pzTail /* OUT: End of parsed string */
@@ -106075,11 +106575,10 @@
106075 ){
106076 Select *pNew;
106077 Select standin;
106078 sqlite3 *db = pParse->db;
106079 pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
106080 assert( db->mallocFailed || !pOffset || pLimit ); /* OFFSET implies LIMIT */
106081 if( pNew==0 ){
106082 assert( db->mallocFailed );
106083 pNew = &standin;
106084 memset(pNew, 0, sizeof(*pNew));
106085 }
@@ -106095,11 +106594,11 @@
106095 pNew->pOrderBy = pOrderBy;
106096 pNew->selFlags = selFlags;
106097 pNew->op = TK_SELECT;
106098 pNew->pLimit = pLimit;
106099 pNew->pOffset = pOffset;
106100 assert( pOffset==0 || pLimit!=0 );
106101 pNew->addrOpenEphm[0] = -1;
106102 pNew->addrOpenEphm[1] = -1;
106103 if( db->mallocFailed ) {
106104 clearSelect(db, pNew, pNew!=&standin);
106105 pNew = 0;
@@ -107345,11 +107844,11 @@
107345 if( pS ){
107346 /* The "table" is actually a sub-select or a view in the FROM clause
107347 ** of the SELECT statement. Return the declaration type and origin
107348 ** data for the result-set column of the sub-select.
107349 */
107350 if( iCol>=0 && ALWAYS(iCol<pS->pEList->nExpr) ){
107351 /* If iCol is less than zero, then the expression requests the
107352 ** rowid of the sub-select or view. This expression is legal (see
107353 ** test case misc2.2.2) - it always evaluates to NULL.
107354 */
107355 NameContext sNC;
@@ -107665,16 +108164,18 @@
107665 memset(&sNC, 0, sizeof(sNC));
107666 sNC.pSrcList = pSelect->pSrc;
107667 a = pSelect->pEList->a;
107668 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
107669 p = a[i].pExpr;
107670 pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
 
 
107671 szAll += pCol->szEst;
107672 pCol->affinity = sqlite3ExprAffinity(p);
107673 if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
107674 pColl = sqlite3ExprCollSeq(pParse, p);
107675 if( pColl ){
107676 pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
107677 }
107678 }
107679 pTab->szTabRow = sqlite3LogEst(szAll*4);
107680 }
@@ -108072,12 +108573,11 @@
108072 ){
108073 Select *pPrior;
108074 int nExpr = p->pEList->nExpr;
108075 int nRow = 1;
108076 int rc = 0;
108077 assert( p->pNext==0 );
108078 assert( p->selFlags & SF_AllValues );
108079 do{
108080 assert( p->selFlags & SF_Values );
108081 assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
108082 assert( p->pLimit==0 );
108083 assert( p->pOffset==0 );
@@ -108182,11 +108682,11 @@
108182 dest.eDest = SRT_Table;
108183 }
108184
108185 /* Special handling for a compound-select that originates as a VALUES clause.
108186 */
108187 if( p->selFlags & SF_AllValues ){
108188 rc = multiSelectValues(pParse, p, &dest);
108189 goto multi_select_end;
108190 }
108191
108192 /* Make sure all SELECTs in the statement have the same number of elements
@@ -108567,11 +109067,11 @@
108567 ** then there should be a single item on the stack. Write this
108568 ** item into the set table with bogus data.
108569 */
108570 case SRT_Set: {
108571 int r1;
108572 assert( pIn->nSdst==1 );
108573 pDest->affSdst =
108574 sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
108575 r1 = sqlite3GetTempReg(pParse);
108576 sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
108577 sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
@@ -108593,11 +109093,11 @@
108593 /* If this is a scalar select that is part of an expression, then
108594 ** store the results in the appropriate memory cell and break out
108595 ** of the scan loop.
108596 */
108597 case SRT_Mem: {
108598 assert( pIn->nSdst==1 );
108599 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
108600 /* The LIMIT clause will jump out of the loop for us */
108601 break;
108602 }
108603 #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
@@ -108608,11 +109108,11 @@
108608 case SRT_Coroutine: {
108609 if( pDest->iSdst==0 ){
108610 pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);
108611 pDest->nSdst = pIn->nSdst;
108612 }
108613 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pDest->nSdst);
108614 sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
108615 break;
108616 }
108617
108618 /* If none of the above, then the result destination must be
@@ -108824,12 +109324,14 @@
108824 */
108825 aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy);
108826 if( aPermute ){
108827 struct ExprList_item *pItem;
108828 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
108829 assert( pItem->u.x.iOrderByCol>0
108830 && pItem->u.x.iOrderByCol<=p->pEList->nExpr );
 
 
108831 aPermute[i] = pItem->u.x.iOrderByCol - 1;
108832 }
108833 pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
108834 }else{
108835 pKeyMerge = 0;
@@ -109035,11 +109537,11 @@
109035 pPrior->pNext = p;
109036
109037 /*** TBD: Insert subroutine calls to close cursors on incomplete
109038 **** subqueries ****/
109039 explainComposite(pParse, p->op, iSub1, iSub2, 0);
109040 return SQLITE_OK;
109041 }
109042 #endif
109043
109044 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
109045 /* Forward Declarations */
@@ -109847,11 +110349,14 @@
109847 pNew->pGroupBy = 0;
109848 pNew->pHaving = 0;
109849 pNew->pOrderBy = 0;
109850 p->pPrior = 0;
109851 p->pNext = 0;
 
109852 p->selFlags &= ~SF_Compound;
 
 
109853 assert( pNew->pPrior!=0 );
109854 pNew->pPrior->pNext = pNew;
109855 pNew->pLimit = 0;
109856 pNew->pOffset = 0;
109857 return WRC_Continue;
@@ -110383,11 +110888,11 @@
110383 if( pParse->hasCompound ){
110384 w.xSelectCallback = convertCompoundSelectToSubquery;
110385 sqlite3WalkSelect(&w, pSelect);
110386 }
110387 w.xSelectCallback = selectExpander;
110388 if( (pSelect->selFlags & SF_AllValues)==0 ){
110389 w.xSelectCallback2 = selectPopWith;
110390 }
110391 sqlite3WalkSelect(&w, pSelect);
110392 }
110393
@@ -110569,11 +111074,12 @@
110569 nArg = 0;
110570 regAgg = 0;
110571 }
110572 if( pF->iDistinct>=0 ){
110573 addrNext = sqlite3VdbeMakeLabel(v);
110574 assert( nArg==1 );
 
110575 codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
110576 }
110577 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
110578 CollSeq *pColl = 0;
110579 struct ExprList_item *pItem;
@@ -111444,14 +111950,13 @@
111444
111445 /* Jump here to skip this query
111446 */
111447 sqlite3VdbeResolveLabel(v, iEnd);
111448
111449 /* The SELECT was successfully coded. Set the return code to 0
111450 ** to indicate no errors.
111451 */
111452 rc = 0;
111453
111454 /* Control jumps to here if an error is encountered above, or upon
111455 ** successful coding of the SELECT.
111456 */
111457 select_end:
@@ -111498,11 +112003,11 @@
111498 sqlite3TreeViewLine(pView, "FROM");
111499 for(i=0; i<p->pSrc->nSrc; i++){
111500 struct SrcList_item *pItem = &p->pSrc->a[i];
111501 StrAccum x;
111502 char zLine[100];
111503 sqlite3StrAccumInit(&x, zLine, sizeof(zLine), 0);
111504 sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor);
111505 if( pItem->zDatabase ){
111506 sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName);
111507 }else if( pItem->zName ){
111508 sqlite3XPrintf(&x, 0, " %s", pItem->zName);
@@ -111657,11 +112162,11 @@
111657 for(i=0; i<nCol; i++){
111658 if( argv[i]==0 ){
111659 z = 0;
111660 }else{
111661 int n = sqlite3Strlen30(argv[i])+1;
111662 z = sqlite3_malloc( n );
111663 if( z==0 ) goto malloc_failed;
111664 memcpy(z, argv[i], n);
111665 }
111666 p->azResult[p->nData++] = z;
111667 }
@@ -111682,11 +112187,11 @@
111682 ** The result that is written to ***pazResult is held in memory obtained
111683 ** from malloc(). But the caller cannot free this memory directly.
111684 ** Instead, the entire table should be passed to sqlite3_free_table() when
111685 ** the calling procedure is finished using it.
111686 */
111687 SQLITE_API int sqlite3_get_table(
111688 sqlite3 *db, /* The database on which the SQL executes */
111689 const char *zSql, /* The SQL to be executed */
111690 char ***pazResult, /* Write the result table here */
111691 int *pnRow, /* Write the number of rows in the result here */
111692 int *pnColumn, /* Write the number of columns of result here */
@@ -111706,11 +112211,11 @@
111706 res.nRow = 0;
111707 res.nColumn = 0;
111708 res.nData = 1;
111709 res.nAlloc = 20;
111710 res.rc = SQLITE_OK;
111711 res.azResult = sqlite3_malloc(sizeof(char*)*res.nAlloc );
111712 if( res.azResult==0 ){
111713 db->errCode = SQLITE_NOMEM;
111714 return SQLITE_NOMEM;
111715 }
111716 res.azResult[0] = 0;
@@ -111734,11 +112239,11 @@
111734 sqlite3_free_table(&res.azResult[1]);
111735 return rc;
111736 }
111737 if( res.nAlloc>res.nData ){
111738 char **azNew;
111739 azNew = sqlite3_realloc( res.azResult, sizeof(char*)*res.nData );
111740 if( azNew==0 ){
111741 sqlite3_free_table(&res.azResult[1]);
111742 db->errCode = SQLITE_NOMEM;
111743 return SQLITE_NOMEM;
111744 }
@@ -111751,11 +112256,11 @@
111751 }
111752
111753 /*
111754 ** This routine frees the space the sqlite3_get_table() malloced.
111755 */
111756 SQLITE_API void sqlite3_free_table(
111757 char **azResult /* Result returned from sqlite3_get_table() */
111758 ){
111759 if( azResult ){
111760 int i, n;
111761 azResult--;
@@ -111962,11 +112467,10 @@
111962 }
111963
111964 /* Do not create a trigger on a system table */
111965 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
111966 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
111967 pParse->nErr++;
111968 goto trigger_cleanup;
111969 }
111970
111971 /* INSTEAD of triggers are only for views and views only support INSTEAD
111972 ** of triggers.
@@ -112142,16 +112646,16 @@
112142 u8 op, /* Trigger opcode */
112143 Token *pName /* The target name */
112144 ){
112145 TriggerStep *pTriggerStep;
112146
112147 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n);
112148 if( pTriggerStep ){
112149 char *z = (char*)&pTriggerStep[1];
112150 memcpy(z, pName->z, pName->n);
112151 pTriggerStep->target.z = z;
112152 pTriggerStep->target.n = pName->n;
112153 pTriggerStep->op = op;
112154 }
112155 return pTriggerStep;
112156 }
112157
@@ -112430,11 +112934,11 @@
112430 }
112431 return (mask ? pList : 0);
112432 }
112433
112434 /*
112435 ** Convert the pStep->target token into a SrcList and return a pointer
112436 ** to that SrcList.
112437 **
112438 ** This routine adds a specific database name, if needed, to the target when
112439 ** forming the SrcList. This prevents a trigger in one database from
112440 ** referring to a target in another database. An exception is when the
@@ -112443,21 +112947,21 @@
112443 */
112444 static SrcList *targetSrcList(
112445 Parse *pParse, /* The parsing context */
112446 TriggerStep *pStep /* The trigger containing the target token */
112447 ){
 
112448 int iDb; /* Index of the database to use */
112449 SrcList *pSrc; /* SrcList to be returned */
112450
112451 pSrc = sqlite3SrcListAppend(pParse->db, 0, &pStep->target, 0);
112452 if( pSrc ){
112453 assert( pSrc->nSrc>0 );
112454 assert( pSrc->a!=0 );
112455 iDb = sqlite3SchemaToIndex(pParse->db, pStep->pTrig->pSchema);
112456 if( iDb==0 || iDb>=2 ){
112457 sqlite3 *db = pParse->db;
112458 assert( iDb<pParse->db->nDb );
112459 pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
112460 }
112461 }
112462 return pSrc;
112463 }
@@ -112565,10 +113069,11 @@
112565 assert( pFrom->zErrMsg==0 || pFrom->nErr );
112566 assert( pTo->zErrMsg==0 || pTo->nErr );
112567 if( pTo->nErr==0 ){
112568 pTo->zErrMsg = pFrom->zErrMsg;
112569 pTo->nErr = pFrom->nErr;
 
112570 }else{
112571 sqlite3DbFree(pFrom->db, pFrom->zErrMsg);
112572 }
112573 }
112574
@@ -113915,17 +114420,21 @@
113915
113916 /* Loop through the tables in the main database. For each, do
113917 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
113918 ** the contents to the temporary database.
113919 */
 
 
113920 rc = execExecSql(db, pzErrMsg,
113921 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
113922 "|| ' SELECT * FROM main.' || quote(name) || ';'"
113923 "FROM main.sqlite_master "
113924 "WHERE type = 'table' AND name!='sqlite_sequence' "
113925 " AND coalesce(rootpage,1)>0"
113926 );
 
 
113927 if( rc!=SQLITE_OK ) goto end_of_vacuum;
113928
113929 /* Copy over the sequence table
113930 */
113931 rc = execExecSql(db, pzErrMsg,
@@ -114060,10 +114569,12 @@
114060 ** are invoked only from within xCreate and xConnect methods.
114061 */
114062 struct VtabCtx {
114063 VTable *pVTable; /* The virtual table being constructed */
114064 Table *pTab; /* The Table object to which the virtual table belongs */
 
 
114065 };
114066
114067 /*
114068 ** The actual function that does the work of creating a new module.
114069 ** This function implements the sqlite3_create_module() and
@@ -114111,11 +114622,11 @@
114111
114112
114113 /*
114114 ** External API function used to create a new virtual-table module.
114115 */
114116 SQLITE_API int sqlite3_create_module(
114117 sqlite3 *db, /* Database in which module is registered */
114118 const char *zName, /* Name assigned to this module */
114119 const sqlite3_module *pModule, /* The definition of the module */
114120 void *pAux /* Context pointer for xCreate/xConnect */
114121 ){
@@ -114126,11 +114637,11 @@
114126 }
114127
114128 /*
114129 ** External API function used to create a new virtual-table module.
114130 */
114131 SQLITE_API int sqlite3_create_module_v2(
114132 sqlite3 *db, /* Database in which module is registered */
114133 const char *zName, /* Name assigned to this module */
114134 const sqlite3_module *pModule, /* The definition of the module */
114135 void *pAux, /* Context pointer for xCreate/xConnect */
114136 void (*xDestroy)(void *) /* Module destructor function */
@@ -114506,11 +115017,11 @@
114506 Token *pArg = &pParse->sArg;
114507 if( pArg->z==0 ){
114508 pArg->z = p->z;
114509 pArg->n = p->n;
114510 }else{
114511 assert(pArg->z < p->z);
114512 pArg->n = (int)(&p->z[p->n] - pArg->z);
114513 }
114514 }
114515
114516 /*
@@ -114523,19 +115034,31 @@
114523 Table *pTab,
114524 Module *pMod,
114525 int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
114526 char **pzErr
114527 ){
114528 VtabCtx sCtx, *pPriorCtx;
114529 VTable *pVTable;
114530 int rc;
114531 const char *const*azArg = (const char *const*)pTab->azModuleArg;
114532 int nArg = pTab->nModuleArg;
114533 char *zErr = 0;
114534 char *zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
114535 int iDb;
 
114536
 
 
 
 
 
 
 
 
 
 
 
114537 if( !zModuleName ){
114538 return SQLITE_NOMEM;
114539 }
114540
114541 pVTable = sqlite3DbMallocZero(db, sizeof(VTable));
@@ -114552,15 +115075,17 @@
114552 /* Invoke the virtual table constructor */
114553 assert( &db->pVtabCtx );
114554 assert( xConstruct );
114555 sCtx.pTab = pTab;
114556 sCtx.pVTable = pVTable;
114557 pPriorCtx = db->pVtabCtx;
 
114558 db->pVtabCtx = &sCtx;
114559 rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
114560 db->pVtabCtx = pPriorCtx;
114561 if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
 
114562
114563 if( SQLITE_OK!=rc ){
114564 if( zErr==0 ){
114565 *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
114566 }else {
@@ -114572,17 +115097,18 @@
114572 /* Justification of ALWAYS(): A correct vtab constructor must allocate
114573 ** the sqlite3_vtab object if successful. */
114574 memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
114575 pVTable->pVtab->pModule = pMod->pModule;
114576 pVTable->nRef = 1;
114577 if( sCtx.pTab ){
114578 const char *zFormat = "vtable constructor did not declare schema: %s";
114579 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
114580 sqlite3VtabUnlock(pVTable);
114581 rc = SQLITE_ERROR;
114582 }else{
114583 int iCol;
 
114584 /* If everything went according to plan, link the new VTable structure
114585 ** into the linked list headed by pTab->pVTable. Then loop through the
114586 ** columns of the table to see if any of them contain the token "hidden".
114587 ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
114588 ** the type string. */
@@ -114591,11 +115117,14 @@
114591
114592 for(iCol=0; iCol<pTab->nCol; iCol++){
114593 char *zType = pTab->aCol[iCol].zType;
114594 int nType;
114595 int i = 0;
114596 if( !zType ) continue;
 
 
 
114597 nType = sqlite3Strlen30(zType);
114598 if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
114599 for(i=0; i<nType; i++){
114600 if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
114601 && (zType[i+7]=='\0' || zType[i+7]==' ')
@@ -114614,10 +115143,13 @@
114614 if( zType[i]=='\0' && i>0 ){
114615 assert(zType[i-1]==' ');
114616 zType[i-1] = '\0';
114617 }
114618 pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;
 
 
 
114619 }
114620 }
114621 }
114622 }
114623
@@ -114741,13 +115273,13 @@
114741 /*
114742 ** This function is used to set the schema of a virtual table. It is only
114743 ** valid to call this function from within the xCreate() or xConnect() of a
114744 ** virtual table module.
114745 */
114746 SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
 
114747 Parse *pParse;
114748
114749 int rc = SQLITE_OK;
114750 Table *pTab;
114751 char *zErr = 0;
114752
114753 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -114754,15 +115286,17 @@
114754 if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
114755 return SQLITE_MISUSE_BKPT;
114756 }
114757 #endif
114758 sqlite3_mutex_enter(db->mutex);
114759 if( !db->pVtabCtx || !(pTab = db->pVtabCtx->pTab) ){
 
114760 sqlite3Error(db, SQLITE_MISUSE);
114761 sqlite3_mutex_leave(db->mutex);
114762 return SQLITE_MISUSE_BKPT;
114763 }
 
114764 assert( (pTab->tabFlags & TF_Virtual)!=0 );
114765
114766 pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
114767 if( pParse==0 ){
114768 rc = SQLITE_NOMEM;
@@ -114781,11 +115315,11 @@
114781 pTab->aCol = pParse->pNewTable->aCol;
114782 pTab->nCol = pParse->pNewTable->nCol;
114783 pParse->pNewTable->nCol = 0;
114784 pParse->pNewTable->aCol = 0;
114785 }
114786 db->pVtabCtx->pTab = 0;
114787 }else{
114788 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
114789 sqlite3DbFree(db, zErr);
114790 rc = SQLITE_ERROR;
114791 }
@@ -114975,11 +115509,11 @@
114975 */
114976 SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
114977 int rc = SQLITE_OK;
114978
114979 assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
114980 assert( iSavepoint>=0 );
114981 if( db->aVTrans ){
114982 int i;
114983 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
114984 VTable *pVTab = db->aVTrans[i];
114985 const sqlite3_module *pMod = pVTab->pMod->pModule;
@@ -115093,11 +115627,11 @@
115093 assert( IsVirtual(pTab) );
115094 for(i=0; i<pToplevel->nVtabLock; i++){
115095 if( pTab==pToplevel->apVtabLock[i] ) return;
115096 }
115097 n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
115098 apVtabLock = sqlite3_realloc(pToplevel->apVtabLock, n);
115099 if( apVtabLock ){
115100 pToplevel->apVtabLock = apVtabLock;
115101 pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
115102 }else{
115103 pToplevel->db->mallocFailed = 1;
@@ -115109,11 +115643,11 @@
115109 ** table update operation currently in progress.
115110 **
115111 ** The results of this routine are undefined unless it is called from
115112 ** within an xUpdate method.
115113 */
115114 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db){
115115 static const unsigned char aMap[] = {
115116 SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
115117 };
115118 #ifdef SQLITE_ENABLE_API_ARMOR
115119 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115127,11 +115661,11 @@
115127 /*
115128 ** Call from within the xCreate() or xConnect() methods to provide
115129 ** the SQLite core with additional information about the behavior
115130 ** of the virtual table being implemented.
115131 */
115132 SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...){
115133 va_list ap;
115134 int rc = SQLITE_OK;
115135
115136 #ifdef SQLITE_ENABLE_API_ARMOR
115137 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115892,17 +116426,18 @@
115892 ** In the previous sentence and in the diagram, "slot[]" refers to
115893 ** the WhereClause.a[] array. The slot[] array grows as needed to contain
115894 ** all terms of the WHERE clause.
115895 */
115896 static void whereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
 
115897 pWC->op = op;
115898 if( pExpr==0 ) return;
115899 if( pExpr->op!=op ){
115900 whereClauseInsert(pWC, pExpr, 0);
115901 }else{
115902 whereSplit(pWC, pExpr->pLeft, op);
115903 whereSplit(pWC, pExpr->pRight, op);
115904 }
115905 }
115906
115907 /*
115908 ** Initialize a WhereMaskSet object
@@ -117169,11 +117704,11 @@
117169 if( p->op==TK_COLUMN
117170 && p->iColumn==pIdx->aiColumn[iCol]
117171 && p->iTable==iBase
117172 ){
117173 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
117174 if( ALWAYS(pColl) && 0==sqlite3StrICmp(pColl->zName, zColl) ){
117175 return i;
117176 }
117177 }
117178 }
117179
@@ -117443,11 +117978,11 @@
117443 if( (idxCols & cMask)==0 ){
117444 Expr *pX = pTerm->pExpr;
117445 idxCols |= cMask;
117446 pIdx->aiColumn[n] = pTerm->u.leftColumn;
117447 pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
117448 pIdx->azColl[n] = ALWAYS(pColl) ? pColl->zName : "BINARY";
117449 n++;
117450 }
117451 }
117452 }
117453 assert( (u32)n==pLoop->u.btree.nEq );
@@ -118739,12 +119274,11 @@
118739
118740 isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
118741 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
118742 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
118743
118744 sqlite3StrAccumInit(&str, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
118745 str.db = db;
118746 sqlite3StrAccumAppendAll(&str, isSearch ? "SEARCH" : "SCAN");
118747 if( pItem->pSelect ){
118748 sqlite3XPrintf(&str, 0, " SUBQUERY %d", pItem->iSelectId);
118749 }else{
118750 sqlite3XPrintf(&str, 0, " TABLE %s", pItem->zName);
@@ -119939,10 +120473,17 @@
119939 /*
119940 ** Free a WhereInfo structure
119941 */
119942 static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
119943 if( ALWAYS(pWInfo) ){
 
 
 
 
 
 
 
119944 whereClauseClear(&pWInfo->sWC);
119945 while( pWInfo->pLoops ){
119946 WhereLoop *p = pWInfo->pLoops;
119947 pWInfo->pLoops = p->pNextLoop;
119948 whereLoopDelete(db, p);
@@ -120418,11 +120959,11 @@
120418 ** changes "x IN (?)" into "x=?". */
120419
120420 }else if( eOp & (WO_EQ) ){
120421 pNew->wsFlags |= WHERE_COLUMN_EQ;
120422 if( iCol<0 || (nInMul==0 && pNew->u.btree.nEq==pProbe->nKeyCol-1) ){
120423 if( iCol>=0 && !IsUniqueIndex(pProbe) ){
120424 pNew->wsFlags |= WHERE_UNQ_WANTED;
120425 }else{
120426 pNew->wsFlags |= WHERE_ONEROW;
120427 }
120428 }
@@ -121878,11 +122419,11 @@
121878 pWInfo->nOBSat = pFrom->isOrdered;
121879 if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
121880 pWInfo->revMask = pFrom->revLoop;
121881 }
121882 if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
121883 && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr
121884 ){
121885 Bitmask revMask = 0;
121886 int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy,
121887 pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask
121888 );
@@ -122283,11 +122824,10 @@
122283 if( pParse->nErr || NEVER(db->mallocFailed) ){
122284 goto whereBeginError;
122285 }
122286 #ifdef WHERETRACE_ENABLED /* !=0 */
122287 if( sqlite3WhereTrace ){
122288 int ii;
122289 sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
122290 if( pWInfo->nOBSat>0 ){
122291 sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
122292 }
122293 switch( pWInfo->eDistinct ){
@@ -122536,11 +123076,10 @@
122536 VdbeCoverage(v);
122537 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
122538 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
122539 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
122540 }
122541 sqlite3DbFree(db, pLevel->u.in.aInLoop);
122542 }
122543 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
122544 if( pLevel->addrSkip ){
122545 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
122546 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
@@ -122747,10 +123286,32 @@
122747 /*
122748 ** An instance of this structure holds the ATTACH key and the key type.
122749 */
122750 struct AttachKey { int type; Token key; };
122751
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
122752
122753 /* This is a utility routine used to set the ExprSpan.zStart and
122754 ** ExprSpan.zEnd values of pOut so that the span covers the complete
122755 ** range of text beginning with pStart and going to the end of pEnd.
122756 */
@@ -125064,31 +125625,14 @@
125064 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
125065 }
125066 break;
125067 case 112: /* select ::= with selectnowith */
125068 {
125069 Select *p = yymsp[0].minor.yy3, *pNext, *pLoop;
125070 if( p ){
125071 int cnt = 0, mxSelect;
125072 p->pWith = yymsp[-1].minor.yy59;
125073 if( p->pPrior ){
125074 u16 allValues = SF_Values;
125075 pNext = 0;
125076 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
125077 pLoop->pNext = pNext;
125078 pLoop->selFlags |= SF_Compound;
125079 allValues &= pLoop->selFlags;
125080 }
125081 if( allValues ){
125082 p->selFlags |= SF_AllValues;
125083 }else if(
125084 (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0
125085 && cnt>mxSelect
125086 ){
125087 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
125088 }
125089 }
125090 }else{
125091 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy59);
125092 }
125093 yygotominor.yy3 = p;
125094 }
@@ -125102,16 +125646,18 @@
125102 Select *pRhs = yymsp[0].minor.yy3;
125103 if( pRhs && pRhs->pPrior ){
125104 SrcList *pFrom;
125105 Token x;
125106 x.n = 0;
 
125107 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
125108 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
125109 }
125110 if( pRhs ){
125111 pRhs->op = (u8)yymsp[-1].minor.yy328;
125112 pRhs->pPrior = yymsp[-2].minor.yy3;
 
125113 if( yymsp[-1].minor.yy328!=TK_ALL ) pParse->hasCompound = 1;
125114 }else{
125115 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
125116 }
125117 yygotominor.yy3 = pRhs;
@@ -125154,17 +125700,20 @@
125154 yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
125155 }
125156 break;
125157 case 121: /* values ::= values COMMA LP exprlist RP */
125158 {
125159 Select *pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
 
 
125160 if( pRight ){
125161 pRight->op = TK_ALL;
125162 pRight->pPrior = yymsp[-4].minor.yy3;
 
125163 yygotominor.yy3 = pRight;
125164 }else{
125165 yygotominor.yy3 = yymsp[-4].minor.yy3;
125166 }
125167 }
125168 break;
125169 case 122: /* distinct ::= DISTINCT */
125170 {yygotominor.yy381 = SF_Distinct;}
@@ -126964,14 +127513,12 @@
126964 goto abort_parse;
126965 }
126966 break;
126967 }
126968 case TK_ILLEGAL: {
126969 sqlite3DbFree(db, *pzErrMsg);
126970 *pzErrMsg = sqlite3MPrintf(db, "unrecognized token: \"%T\"",
126971 &pParse->sLastToken);
126972 nErr++;
126973 goto abort_parse;
126974 }
126975 case TK_SEMI: {
126976 pParse->zTail = &zSql[i];
126977 /* Fall thru into the default case */
@@ -126985,16 +127532,19 @@
126985 break;
126986 }
126987 }
126988 }
126989 abort_parse:
126990 if( zSql[i]==0 && nErr==0 && pParse->rc==SQLITE_OK ){
 
126991 if( lastTokenParsed!=TK_SEMI ){
126992 sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
126993 pParse->zTail = &zSql[i];
126994 }
126995 sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
 
 
126996 }
126997 #ifdef YYTRACKMAXSTACKDEPTH
126998 sqlite3_mutex_enter(sqlite3MallocMutex());
126999 sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
127000 sqlite3ParserStackPeak(pEngine)
@@ -127051,13 +127601,11 @@
127051 while( pParse->pZombieTab ){
127052 Table *p = pParse->pZombieTab;
127053 pParse->pZombieTab = p->pNextZombie;
127054 sqlite3DeleteTable(db, p);
127055 }
127056 if( nErr>0 && pParse->rc==SQLITE_OK ){
127057 pParse->rc = SQLITE_ERROR;
127058 }
127059 return nErr;
127060 }
127061
127062 /************** End of tokenize.c ********************************************/
127063 /************** Begin file complete.c ****************************************/
@@ -127161,11 +127709,11 @@
127161 **
127162 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
127163 ** to recognize the end of a trigger can be omitted. All we have to do
127164 ** is look for a semicolon that is not part of an string or comment.
127165 */
127166 SQLITE_API int sqlite3_complete(const char *zSql){
127167 u8 state = 0; /* Current state, using numbers defined in header comment */
127168 u8 token; /* Value of the next token */
127169
127170 #ifndef SQLITE_OMIT_TRIGGER
127171 /* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -127326,14 +127874,14 @@
127326 /*
127327 ** This routine is the same as the sqlite3_complete() routine described
127328 ** above, except that the parameter is required to be UTF-16 encoded, not
127329 ** UTF-8.
127330 */
127331 SQLITE_API int sqlite3_complete16(const void *zSql){
127332 sqlite3_value *pVal;
127333 char const *zSql8;
127334 int rc = SQLITE_NOMEM;
127335
127336 #ifndef SQLITE_OMIT_AUTOINIT
127337 rc = sqlite3_initialize();
127338 if( rc ) return rc;
127339 #endif
@@ -127476,37 +128024,49 @@
127476 #endif
127477
127478 /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
127479 ** a pointer to the to the sqlite3_version[] string constant.
127480 */
127481 SQLITE_API const char *sqlite3_libversion(void){ return sqlite3_version; }
127482
127483 /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
127484 ** pointer to a string constant whose value is the same as the
127485 ** SQLITE_SOURCE_ID C preprocessor macro.
127486 */
127487 SQLITE_API const char *sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
127488
127489 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
127490 ** returns an integer equal to SQLITE_VERSION_NUMBER.
127491 */
127492 SQLITE_API int sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
127493
127494 /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
127495 ** zero if and only if SQLite was compiled with mutexing code omitted due to
127496 ** the SQLITE_THREADSAFE compile-time option being set to 0.
127497 */
127498 SQLITE_API int sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
 
 
 
 
 
 
 
 
 
 
 
 
127499
127500 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
127501 /*
127502 ** If the following function pointer is not NULL and if
127503 ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
127504 ** I/O active are written using this function. These messages
127505 ** are intended for debugging activity only.
127506 */
127507 /* not-private */ void (*sqlite3IoTrace)(const char*, ...) = 0;
127508 #endif
127509
127510 /*
127511 ** If the following global variable points to a string which is the
127512 ** name of a directory, then that directory will be used to store
@@ -127554,11 +128114,11 @@
127554 ** call by X completes.
127555 **
127556 ** * Recursive calls to this routine from thread X return immediately
127557 ** without blocking.
127558 */
127559 SQLITE_API int sqlite3_initialize(void){
127560 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
127561 int rc; /* Result code */
127562 #ifdef SQLITE_EXTRA_INIT
127563 int bRunExtraInit = 0; /* Extra initialization needed */
127564 #endif
@@ -127715,11 +128275,11 @@
127715 ** while any part of SQLite is otherwise in use in any thread. This
127716 ** routine is not threadsafe. But it is safe to invoke this routine
127717 ** on when SQLite is already shut down. If SQLite is already shut down
127718 ** when this routine is invoked, then this routine is a harmless no-op.
127719 */
127720 SQLITE_API int sqlite3_shutdown(void){
127721 #ifdef SQLITE_OMIT_WSD
127722 int rc = sqlite3_wsd_init(4096, 24);
127723 if( rc!=SQLITE_OK ){
127724 return rc;
127725 }
@@ -127769,11 +128329,11 @@
127769 ** This routine should only be called when there are no outstanding
127770 ** database connections or memory allocations. This routine is not
127771 ** threadsafe. Failure to heed these warnings can lead to unpredictable
127772 ** behavior.
127773 */
127774 SQLITE_API int sqlite3_config(int op, ...){
127775 va_list ap;
127776 int rc = SQLITE_OK;
127777
127778 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
127779 ** the SQLite library is in use. */
@@ -128126,11 +128686,11 @@
128126 }
128127
128128 /*
128129 ** Return the mutex associated with a database connection.
128130 */
128131 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db){
128132 #ifdef SQLITE_ENABLE_API_ARMOR
128133 if( !sqlite3SafetyCheckOk(db) ){
128134 (void)SQLITE_MISUSE_BKPT;
128135 return 0;
128136 }
@@ -128140,11 +128700,11 @@
128140
128141 /*
128142 ** Free up as much memory as we can from the given database
128143 ** connection.
128144 */
128145 SQLITE_API int sqlite3_db_release_memory(sqlite3 *db){
128146 int i;
128147
128148 #ifdef SQLITE_ENABLE_API_ARMOR
128149 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128150 #endif
@@ -128163,11 +128723,11 @@
128163 }
128164
128165 /*
128166 ** Configuration settings for an individual database connection
128167 */
128168 SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...){
128169 va_list ap;
128170 int rc;
128171 va_start(ap, op);
128172 switch( op ){
128173 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -128282,11 +128842,11 @@
128282 }
128283
128284 /*
128285 ** Return the ROWID of the most recent insert
128286 */
128287 SQLITE_API sqlite_int64 sqlite3_last_insert_rowid(sqlite3 *db){
128288 #ifdef SQLITE_ENABLE_API_ARMOR
128289 if( !sqlite3SafetyCheckOk(db) ){
128290 (void)SQLITE_MISUSE_BKPT;
128291 return 0;
128292 }
@@ -128295,11 +128855,11 @@
128295 }
128296
128297 /*
128298 ** Return the number of changes in the most recent call to sqlite3_exec().
128299 */
128300 SQLITE_API int sqlite3_changes(sqlite3 *db){
128301 #ifdef SQLITE_ENABLE_API_ARMOR
128302 if( !sqlite3SafetyCheckOk(db) ){
128303 (void)SQLITE_MISUSE_BKPT;
128304 return 0;
128305 }
@@ -128308,11 +128868,11 @@
128308 }
128309
128310 /*
128311 ** Return the number of changes since the database handle was opened.
128312 */
128313 SQLITE_API int sqlite3_total_changes(sqlite3 *db){
128314 #ifdef SQLITE_ENABLE_API_ARMOR
128315 if( !sqlite3SafetyCheckOk(db) ){
128316 (void)SQLITE_MISUSE_BKPT;
128317 return 0;
128318 }
@@ -128450,12 +129010,12 @@
128450 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
128451 ** version forces the connection to become a zombie if there are
128452 ** unclosed resources, and arranges for deallocation when the last
128453 ** prepare statement or sqlite3_backup closes.
128454 */
128455 SQLITE_API int sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
128456 SQLITE_API int sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
128457
128458
128459 /*
128460 ** Close the mutex on database connection db.
128461 **
@@ -128634,11 +129194,11 @@
128634
128635 /*
128636 ** Return a static string containing the name corresponding to the error code
128637 ** specified in the argument.
128638 */
128639 #if (defined(SQLITE_DEBUG) && SQLITE_OS_WIN) || defined(SQLITE_TEST)
128640 SQLITE_PRIVATE const char *sqlite3ErrName(int rc){
128641 const char *zName = 0;
128642 int i, origRc = rc;
128643 for(i=0; i<2 && zName==0; i++, rc &= 0xff){
128644 switch( rc ){
@@ -128858,11 +129418,11 @@
128858
128859 /*
128860 ** This routine sets the busy callback for an Sqlite database to the
128861 ** given callback function with the given argument.
128862 */
128863 SQLITE_API int sqlite3_busy_handler(
128864 sqlite3 *db,
128865 int (*xBusy)(void*,int),
128866 void *pArg
128867 ){
128868 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128881,11 +129441,11 @@
128881 /*
128882 ** This routine sets the progress callback for an Sqlite database to the
128883 ** given callback function with the given argument. The progress callback will
128884 ** be invoked every nOps opcodes.
128885 */
128886 SQLITE_API void sqlite3_progress_handler(
128887 sqlite3 *db,
128888 int nOps,
128889 int (*xProgress)(void*),
128890 void *pArg
128891 ){
@@ -128912,11 +129472,11 @@
128912
128913 /*
128914 ** This routine installs a default busy handler that waits for the
128915 ** specified number of milliseconds before returning 0.
128916 */
128917 SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms){
128918 #ifdef SQLITE_ENABLE_API_ARMOR
128919 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128920 #endif
128921 if( ms>0 ){
128922 sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128928,11 +129488,11 @@
128928 }
128929
128930 /*
128931 ** Cause any pending operation to stop at its earliest opportunity.
128932 */
128933 SQLITE_API void sqlite3_interrupt(sqlite3 *db){
128934 #ifdef SQLITE_ENABLE_API_ARMOR
128935 if( !sqlite3SafetyCheckOk(db) ){
128936 (void)SQLITE_MISUSE_BKPT;
128937 return;
128938 }
@@ -129045,11 +129605,11 @@
129045 }
129046
129047 /*
129048 ** Create new user functions.
129049 */
129050 SQLITE_API int sqlite3_create_function(
129051 sqlite3 *db,
129052 const char *zFunc,
129053 int nArg,
129054 int enc,
129055 void *p,
@@ -129059,11 +129619,11 @@
129059 ){
129060 return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
129061 xFinal, 0);
129062 }
129063
129064 SQLITE_API int sqlite3_create_function_v2(
129065 sqlite3 *db,
129066 const char *zFunc,
129067 int nArg,
129068 int enc,
129069 void *p,
@@ -129102,11 +129662,11 @@
129102 sqlite3_mutex_leave(db->mutex);
129103 return rc;
129104 }
129105
129106 #ifndef SQLITE_OMIT_UTF16
129107 SQLITE_API int sqlite3_create_function16(
129108 sqlite3 *db,
129109 const void *zFunctionName,
129110 int nArg,
129111 int eTextRep,
129112 void *p,
@@ -129142,11 +129702,11 @@
129142 ** When virtual tables intend to provide an overloaded function, they
129143 ** should call this routine to make sure the global function exists.
129144 ** A global function must exist in order for name resolution to work
129145 ** properly.
129146 */
129147 SQLITE_API int sqlite3_overload_function(
129148 sqlite3 *db,
129149 const char *zName,
129150 int nArg
129151 ){
129152 int nName = sqlite3Strlen30(zName);
@@ -129174,11 +129734,11 @@
129174 **
129175 ** A NULL trace function means that no tracing is executes. A non-NULL
129176 ** trace is a pointer to a function that is invoked at the start of each
129177 ** SQL statement.
129178 */
129179 SQLITE_API void *sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129180 void *pOld;
129181
129182 #ifdef SQLITE_ENABLE_API_ARMOR
129183 if( !sqlite3SafetyCheckOk(db) ){
129184 (void)SQLITE_MISUSE_BKPT;
@@ -129198,11 +129758,11 @@
129198 **
129199 ** A NULL profile function means that no profiling is executes. A non-NULL
129200 ** profile is a pointer to a function that is invoked at the conclusion of
129201 ** each SQL statement that is run.
129202 */
129203 SQLITE_API void *sqlite3_profile(
129204 sqlite3 *db,
129205 void (*xProfile)(void*,const char*,sqlite_uint64),
129206 void *pArg
129207 ){
129208 void *pOld;
@@ -129225,11 +129785,11 @@
129225 /*
129226 ** Register a function to be invoked when a transaction commits.
129227 ** If the invoked function returns non-zero, then the commit becomes a
129228 ** rollback.
129229 */
129230 SQLITE_API void *sqlite3_commit_hook(
129231 sqlite3 *db, /* Attach the hook to this database */
129232 int (*xCallback)(void*), /* Function to invoke on each commit */
129233 void *pArg /* Argument to the function */
129234 ){
129235 void *pOld;
@@ -129250,11 +129810,11 @@
129250
129251 /*
129252 ** Register a callback to be invoked each time a row is updated,
129253 ** inserted or deleted using this database connection.
129254 */
129255 SQLITE_API void *sqlite3_update_hook(
129256 sqlite3 *db, /* Attach the hook to this database */
129257 void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
129258 void *pArg /* Argument to the function */
129259 ){
129260 void *pRet;
@@ -129275,11 +129835,11 @@
129275
129276 /*
129277 ** Register a callback to be invoked each time a transaction is rolled
129278 ** back by this database connection.
129279 */
129280 SQLITE_API void *sqlite3_rollback_hook(
129281 sqlite3 *db, /* Attach the hook to this database */
129282 void (*xCallback)(void*), /* Callback function */
129283 void *pArg /* Argument to the function */
129284 ){
129285 void *pRet;
@@ -129329,11 +129889,11 @@
129329 ** The callback registered by this function replaces any existing callback
129330 ** registered using sqlite3_wal_hook(). Likewise, registering a callback
129331 ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
129332 ** configured by this function.
129333 */
129334 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129335 #ifdef SQLITE_OMIT_WAL
129336 UNUSED_PARAMETER(db);
129337 UNUSED_PARAMETER(nFrame);
129338 #else
129339 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129350,11 +129910,11 @@
129350
129351 /*
129352 ** Register a callback to be invoked each time a transaction is written
129353 ** into the write-ahead-log by this database connection.
129354 */
129355 SQLITE_API void *sqlite3_wal_hook(
129356 sqlite3 *db, /* Attach the hook to this db handle */
129357 int(*xCallback)(void *, sqlite3*, const char*, int),
129358 void *pArg /* First argument passed to xCallback() */
129359 ){
129360 #ifndef SQLITE_OMIT_WAL
@@ -129377,11 +129937,11 @@
129377 }
129378
129379 /*
129380 ** Checkpoint database zDb.
129381 */
129382 SQLITE_API int sqlite3_wal_checkpoint_v2(
129383 sqlite3 *db, /* Database handle */
129384 const char *zDb, /* Name of attached database (or NULL) */
129385 int eMode, /* SQLITE_CHECKPOINT_* value */
129386 int *pnLog, /* OUT: Size of WAL log in frames */
129387 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -129432,11 +129992,11 @@
129432 /*
129433 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
129434 ** to contains a zero-length string, all attached databases are
129435 ** checkpointed.
129436 */
129437 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129438 /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
129439 ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
129440 return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
129441 }
129442
@@ -129521,11 +130081,11 @@
129521
129522 /*
129523 ** Return UTF-8 encoded English language explanation of the most recent
129524 ** error.
129525 */
129526 SQLITE_API const char *sqlite3_errmsg(sqlite3 *db){
129527 const char *z;
129528 if( !db ){
129529 return sqlite3ErrStr(SQLITE_NOMEM);
129530 }
129531 if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -129549,11 +130109,11 @@
129549 #ifndef SQLITE_OMIT_UTF16
129550 /*
129551 ** Return UTF-16 encoded English language explanation of the most recent
129552 ** error.
129553 */
129554 SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db){
129555 static const u16 outOfMem[] = {
129556 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
129557 };
129558 static const u16 misuse[] = {
129559 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129594,20 +130154,20 @@
129594
129595 /*
129596 ** Return the most recent error code generated by an SQLite routine. If NULL is
129597 ** passed to this function, we assume a malloc() failed during sqlite3_open().
129598 */
129599 SQLITE_API int sqlite3_errcode(sqlite3 *db){
129600 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129601 return SQLITE_MISUSE_BKPT;
129602 }
129603 if( !db || db->mallocFailed ){
129604 return SQLITE_NOMEM;
129605 }
129606 return db->errCode & db->errMask;
129607 }
129608 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db){
129609 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
129610 return SQLITE_MISUSE_BKPT;
129611 }
129612 if( !db || db->mallocFailed ){
129613 return SQLITE_NOMEM;
@@ -129618,11 +130178,11 @@
129618 /*
129619 ** Return a string that describes the kind of error specified in the
129620 ** argument. For now, this simply calls the internal sqlite3ErrStr()
129621 ** function.
129622 */
129623 SQLITE_API const char *sqlite3_errstr(int rc){
129624 return sqlite3ErrStr(rc);
129625 }
129626
129627 /*
129628 ** Create a new collating function for database "db". The name is zName
@@ -129766,11 +130326,11 @@
129766 **
129767 ** A new lower limit does not shrink existing constructs.
129768 ** It merely prevents new constructs that exceed the limit
129769 ** from forming.
129770 */
129771 SQLITE_API int sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
129772 int oldLimit;
129773
129774 #ifdef SQLITE_ENABLE_API_ARMOR
129775 if( !sqlite3SafetyCheckOk(db) ){
129776 (void)SQLITE_MISUSE_BKPT;
@@ -129859,18 +130419,18 @@
129859 ){
129860 char *zOpt;
129861 int eState; /* Parser state when parsing URI */
129862 int iIn; /* Input character index */
129863 int iOut = 0; /* Output character index */
129864 int nByte = nUri+2; /* Bytes of space to allocate */
129865
129866 /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen
129867 ** method that there may be extra parameters following the file-name. */
129868 flags |= SQLITE_OPEN_URI;
129869
129870 for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
129871 zFile = sqlite3_malloc(nByte);
129872 if( !zFile ) return SQLITE_NOMEM;
129873
129874 iIn = 5;
129875 #ifdef SQLITE_ALLOW_URI_AUTHORITY
129876 if( strncmp(zUri+5, "///", 3)==0 ){
@@ -130032,11 +130592,11 @@
130032
130033 zOpt = &zVal[nVal+1];
130034 }
130035
130036 }else{
130037 zFile = sqlite3_malloc(nUri+2);
130038 if( !zFile ) return SQLITE_NOMEM;
130039 memcpy(zFile, zUri, nUri);
130040 zFile[nUri] = '\0';
130041 zFile[nUri+1] = '\0';
130042 flags &= ~SQLITE_OPEN_URI;
@@ -130303,10 +130863,17 @@
130303 #ifdef SQLITE_ENABLE_RTREE
130304 if( !db->mallocFailed && rc==SQLITE_OK){
130305 rc = sqlite3RtreeInit(db);
130306 }
130307 #endif
 
 
 
 
 
 
 
130308
130309 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
130310 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
130311 ** mode. Doing nothing at all also makes NORMAL the default.
130312 */
@@ -130351,18 +130918,18 @@
130351 }
130352
130353 /*
130354 ** Open a new database handle.
130355 */
130356 SQLITE_API int sqlite3_open(
130357 const char *zFilename,
130358 sqlite3 **ppDb
130359 ){
130360 return openDatabase(zFilename, ppDb,
130361 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
130362 }
130363 SQLITE_API int sqlite3_open_v2(
130364 const char *filename, /* Database filename (UTF-8) */
130365 sqlite3 **ppDb, /* OUT: SQLite db handle */
130366 int flags, /* Flags */
130367 const char *zVfs /* Name of VFS module to use */
130368 ){
@@ -130371,11 +130938,11 @@
130371
130372 #ifndef SQLITE_OMIT_UTF16
130373 /*
130374 ** Open a new database handle.
130375 */
130376 SQLITE_API int sqlite3_open16(
130377 const void *zFilename,
130378 sqlite3 **ppDb
130379 ){
130380 char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
130381 sqlite3_value *pVal;
@@ -130410,11 +130977,11 @@
130410 #endif /* SQLITE_OMIT_UTF16 */
130411
130412 /*
130413 ** Register a new collation sequence with the database handle db.
130414 */
130415 SQLITE_API int sqlite3_create_collation(
130416 sqlite3* db,
130417 const char *zName,
130418 int enc,
130419 void* pCtx,
130420 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130423,11 +130990,11 @@
130423 }
130424
130425 /*
130426 ** Register a new collation sequence with the database handle db.
130427 */
130428 SQLITE_API int sqlite3_create_collation_v2(
130429 sqlite3* db,
130430 const char *zName,
130431 int enc,
130432 void* pCtx,
130433 int(*xCompare)(void*,int,const void*,int,const void*),
@@ -130448,11 +131015,11 @@
130448
130449 #ifndef SQLITE_OMIT_UTF16
130450 /*
130451 ** Register a new collation sequence with the database handle db.
130452 */
130453 SQLITE_API int sqlite3_create_collation16(
130454 sqlite3* db,
130455 const void *zName,
130456 int enc,
130457 void* pCtx,
130458 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130478,11 +131045,11 @@
130478
130479 /*
130480 ** Register a collation sequence factory callback with the database handle
130481 ** db. Replace any previously installed collation sequence factory.
130482 */
130483 SQLITE_API int sqlite3_collation_needed(
130484 sqlite3 *db,
130485 void *pCollNeededArg,
130486 void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
130487 ){
130488 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -130499,11 +131066,11 @@
130499 #ifndef SQLITE_OMIT_UTF16
130500 /*
130501 ** Register a collation sequence factory callback with the database handle
130502 ** db. Replace any previously installed collation sequence factory.
130503 */
130504 SQLITE_API int sqlite3_collation_needed16(
130505 sqlite3 *db,
130506 void *pCollNeededArg,
130507 void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
130508 ){
130509 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -130521,11 +131088,11 @@
130521 #ifndef SQLITE_OMIT_DEPRECATED
130522 /*
130523 ** This function is now an anachronism. It used to be used to recover from a
130524 ** malloc() failure, but SQLite now does this automatically.
130525 */
130526 SQLITE_API int sqlite3_global_recover(void){
130527 return SQLITE_OK;
130528 }
130529 #endif
130530
130531 /*
@@ -130532,11 +131099,11 @@
130532 ** Test to see whether or not the database connection is in autocommit
130533 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
130534 ** by default. Autocommit is disabled by a BEGIN statement and reenabled
130535 ** by the next COMMIT or ROLLBACK.
130536 */
130537 SQLITE_API int sqlite3_get_autocommit(sqlite3 *db){
130538 #ifdef SQLITE_ENABLE_API_ARMOR
130539 if( !sqlite3SafetyCheckOk(db) ){
130540 (void)SQLITE_MISUSE_BKPT;
130541 return 0;
130542 }
@@ -130584,19 +131151,19 @@
130584 ** data for this thread has been deallocated.
130585 **
130586 ** SQLite no longer uses thread-specific data so this routine is now a
130587 ** no-op. It is retained for historical compatibility.
130588 */
130589 SQLITE_API void sqlite3_thread_cleanup(void){
130590 }
130591 #endif
130592
130593 /*
130594 ** Return meta information about a specific column of a database table.
130595 ** See comment in sqlite3.h (sqlite.h.in) for details.
130596 */
130597 SQLITE_API int sqlite3_table_column_metadata(
130598 sqlite3 *db, /* Connection handle */
130599 const char *zDbName, /* Database name or NULL */
130600 const char *zTableName, /* Table name */
130601 const char *zColumnName, /* Column name */
130602 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130710,11 +131277,11 @@
130710 }
130711
130712 /*
130713 ** Sleep for a little while. Return the amount of time slept.
130714 */
130715 SQLITE_API int sqlite3_sleep(int ms){
130716 sqlite3_vfs *pVfs;
130717 int rc;
130718 pVfs = sqlite3_vfs_find(0);
130719 if( pVfs==0 ) return 0;
130720
@@ -130726,11 +131293,11 @@
130726 }
130727
130728 /*
130729 ** Enable or disable the extended result codes.
130730 */
130731 SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff){
130732 #ifdef SQLITE_ENABLE_API_ARMOR
130733 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
130734 #endif
130735 sqlite3_mutex_enter(db->mutex);
130736 db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130739,11 +131306,11 @@
130739 }
130740
130741 /*
130742 ** Invoke the xFileControl method on a particular database.
130743 */
130744 SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
130745 int rc = SQLITE_ERROR;
130746 Btree *pBtree;
130747
130748 #ifdef SQLITE_ENABLE_API_ARMOR
130749 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130773,11 +131340,11 @@
130773 }
130774
130775 /*
130776 ** Interface to the testing logic.
130777 */
130778 SQLITE_API int sqlite3_test_control(int op, ...){
130779 int rc = 0;
130780 #ifndef SQLITE_OMIT_BUILTIN_TEST
130781 va_list ap;
130782 va_start(ap, op);
130783 switch( op ){
@@ -131116,11 +131683,11 @@
131116 ** method of a VFS implementation. The zParam argument is the name of the
131117 ** query parameter we seek. This routine returns the value of the zParam
131118 ** parameter if it exists. If the parameter does not exist, this routine
131119 ** returns a NULL pointer.
131120 */
131121 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131122 if( zFilename==0 || zParam==0 ) return 0;
131123 zFilename += sqlite3Strlen30(zFilename) + 1;
131124 while( zFilename[0] ){
131125 int x = strcmp(zFilename, zParam);
131126 zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -131131,20 +131698,20 @@
131131 }
131132
131133 /*
131134 ** Return a boolean value for a query parameter.
131135 */
131136 SQLITE_API int sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131137 const char *z = sqlite3_uri_parameter(zFilename, zParam);
131138 bDflt = bDflt!=0;
131139 return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
131140 }
131141
131142 /*
131143 ** Return a 64-bit integer value for a query parameter.
131144 */
131145 SQLITE_API sqlite3_int64 sqlite3_uri_int64(
131146 const char *zFilename, /* Filename as passed to xOpen */
131147 const char *zParam, /* URI parameter sought */
131148 sqlite3_int64 bDflt /* return if parameter is missing */
131149 ){
131150 const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -131172,11 +131739,11 @@
131172
131173 /*
131174 ** Return the filename of the database associated with a database
131175 ** connection.
131176 */
131177 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131178 Btree *pBt;
131179 #ifdef SQLITE_ENABLE_API_ARMOR
131180 if( !sqlite3SafetyCheckOk(db) ){
131181 (void)SQLITE_MISUSE_BKPT;
131182 return 0;
@@ -131188,11 +131755,11 @@
131188
131189 /*
131190 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
131191 ** no such database exists.
131192 */
131193 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131194 Btree *pBt;
131195 #ifdef SQLITE_ENABLE_API_ARMOR
131196 if( !sqlite3SafetyCheckOk(db) ){
131197 (void)SQLITE_MISUSE_BKPT;
131198 return -1;
@@ -131347,11 +131914,11 @@
131347 **
131348 ** Each call to this routine overrides any prior callbacks registered
131349 ** on the same "db". If xNotify==0 then any prior callbacks are immediately
131350 ** cancelled.
131351 */
131352 SQLITE_API int sqlite3_unlock_notify(
131353 sqlite3 *db,
131354 void (*xNotify)(void **, int),
131355 void *pArg
131356 ){
131357 int rc = SQLITE_OK;
@@ -132241,10 +132808,15 @@
132241 ** false.
132242 */
132243 #ifdef SQLITE_COVERAGE_TEST
132244 # define ALWAYS(x) (1)
132245 # define NEVER(X) (0)
 
 
 
 
 
132246 #else
132247 # define ALWAYS(x) (x)
132248 # define NEVER(x) (x)
132249 #endif
132250
@@ -132641,10 +133213,11 @@
132641 #define fts3GetVarint32(p, piVal) ( \
132642 (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
132643 )
132644
132645 /* fts3.c */
 
132646 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
132647 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
132648 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
132649 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
132650 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
@@ -132729,10 +133302,17 @@
132729
132730 static int fts3EvalNext(Fts3Cursor *pCsr);
132731 static int fts3EvalStart(Fts3Cursor *pCsr);
132732 static int fts3TermSegReaderCursor(
132733 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
 
 
 
 
 
 
 
132734
132735 /*
132736 ** Write a 64-bit variable-length integer to memory starting at p[0].
132737 ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
132738 ** The number of bytes written is returned.
@@ -132839,11 +133419,11 @@
132839 int iOut = 0; /* Index of next byte to write to output */
132840
132841 /* If the first byte was a '[', then the close-quote character is a ']' */
132842 if( quote=='[' ) quote = ']';
132843
132844 while( ALWAYS(z[iIn]) ){
132845 if( z[iIn]==quote ){
132846 if( z[iIn+1]!=quote ) break;
132847 z[iOut++] = quote;
132848 iIn += 2;
132849 }else{
@@ -132917,10 +133497,21 @@
132917 p->pTokenizer->pModule->xDestroy(p->pTokenizer);
132918
132919 sqlite3_free(p);
132920 return SQLITE_OK;
132921 }
 
 
 
 
 
 
 
 
 
 
 
132922
132923 /*
132924 ** Construct one or more SQL statements from the format string given
132925 ** and then evaluate those statements. The success code is written
132926 ** into *pRc.
@@ -133436,11 +134027,12 @@
133436 sqlite3 *db, /* Database handle */
133437 const char *zDb, /* Name of db (i.e. "main", "temp" etc.) */
133438 const char *zTbl, /* Name of content table */
133439 const char ***pazCol, /* OUT: Malloc'd array of column names */
133440 int *pnCol, /* OUT: Size of array *pazCol */
133441 int *pnStr /* OUT: Bytes of string content */
 
133442 ){
133443 int rc = SQLITE_OK; /* Return code */
133444 char *zSql; /* "SELECT *" statement on zTbl */
133445 sqlite3_stmt *pStmt = 0; /* Compiled version of zSql */
133446
@@ -133447,10 +134039,13 @@
133447 zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", zDb, zTbl);
133448 if( !zSql ){
133449 rc = SQLITE_NOMEM;
133450 }else{
133451 rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
 
 
 
133452 }
133453 sqlite3_free(zSql);
133454
133455 if( rc==SQLITE_OK ){
133456 const char **azCol; /* Output array */
@@ -133525,11 +134120,11 @@
133525 int nName; /* Bytes required to hold table name */
133526 int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
133527 const char **aCol; /* Array of column names */
133528 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
133529
133530 int nIndex; /* Size of aIndex[] array */
133531 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
133532
133533 /* The results of parsing supported FTS4 key=value options: */
133534 int bNoDocsize = 0; /* True to omit %_docsize table */
133535 int bDescIdx = 0; /* True to store descending indexes */
@@ -133613,17 +134208,17 @@
133613 if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){
133614 break;
133615 }
133616 }
133617 if( iOpt==SizeofArray(aFts4Opt) ){
133618 *pzErr = sqlite3_mprintf("unrecognized parameter: %s", z);
133619 rc = SQLITE_ERROR;
133620 }else{
133621 switch( iOpt ){
133622 case 0: /* MATCHINFO */
133623 if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){
133624 *pzErr = sqlite3_mprintf("unrecognized matchinfo: %s", zVal);
133625 rc = SQLITE_ERROR;
133626 }
133627 bNoDocsize = 1;
133628 break;
133629
@@ -133647,11 +134242,11 @@
133647
133648 case 4: /* ORDER */
133649 if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3))
133650 && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4))
133651 ){
133652 *pzErr = sqlite3_mprintf("unrecognized order: %s", zVal);
133653 rc = SQLITE_ERROR;
133654 }
133655 bDescIdx = (zVal[0]=='d' || zVal[0]=='D');
133656 break;
133657
@@ -133698,11 +134293,11 @@
133698 zCompress = 0;
133699 zUncompress = 0;
133700 if( nCol==0 ){
133701 sqlite3_free((void*)aCol);
133702 aCol = 0;
133703 rc = fts3ContentColumns(db, argv[1], zContent, &aCol, &nCol, &nString);
133704
133705 /* If a languageid= option was specified, remove the language id
133706 ** column from the aCol[] array. */
133707 if( rc==SQLITE_OK && zLanguageid ){
133708 int j;
@@ -133733,11 +134328,11 @@
133733 assert( pTokenizer );
133734
133735 rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);
133736 if( rc==SQLITE_ERROR ){
133737 assert( zPrefix );
133738 *pzErr = sqlite3_mprintf("error parsing prefix parameter: %s", zPrefix);
133739 }
133740 if( rc!=SQLITE_OK ) goto fts3_init_out;
133741
133742 /* Allocate and populate the Fts3Table structure. */
133743 nByte = sizeof(Fts3Table) + /* Fts3Table */
@@ -133815,19 +134410,19 @@
133815 }
133816 }
133817 }
133818 for(i=0; i<nNotindexed; i++){
133819 if( azNotindexed[i] ){
133820 *pzErr = sqlite3_mprintf("no such column: %s", azNotindexed[i]);
133821 rc = SQLITE_ERROR;
133822 }
133823 }
133824
133825 if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){
133826 char const *zMiss = (zCompress==0 ? "compress" : "uncompress");
133827 rc = SQLITE_ERROR;
133828 *pzErr = sqlite3_mprintf("missing %s parameter in fts4 constructor", zMiss);
133829 }
133830 p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);
133831 p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);
133832 if( rc!=SQLITE_OK ) goto fts3_init_out;
133833
@@ -134919,30 +135514,37 @@
134919 ** parameter bDescDoclist should be false. If they are sorted in ascending
134920 ** order, it should be passed a non-zero value.
134921 **
134922 ** The right-hand input doclist is overwritten by this function.
134923 */
134924 static void fts3DoclistPhraseMerge(
134925 int bDescDoclist, /* True if arguments are desc */
134926 int nDist, /* Distance from left to right (1=adjacent) */
134927 char *aLeft, int nLeft, /* Left doclist */
134928 char *aRight, int *pnRight /* IN/OUT: Right/output doclist */
134929 ){
134930 sqlite3_int64 i1 = 0;
134931 sqlite3_int64 i2 = 0;
134932 sqlite3_int64 iPrev = 0;
 
134933 char *pEnd1 = &aLeft[nLeft];
134934 char *pEnd2 = &aRight[*pnRight];
134935 char *p1 = aLeft;
134936 char *p2 = aRight;
134937 char *p;
134938 int bFirstOut = 0;
134939 char *aOut = aRight;
134940
134941 assert( nDist>0 );
134942
 
 
 
 
 
134943 p = aOut;
 
134944 fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
134945 fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
134946
134947 while( p1 && p2 ){
134948 sqlite3_int64 iDiff = DOCID_CMP(i1, i2);
@@ -134967,10 +135569,16 @@
134967 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
134968 }
134969 }
134970
134971 *pnRight = (int)(p - aOut);
 
 
 
 
 
 
134972 }
134973
134974 /*
134975 ** Argument pList points to a position list nList bytes in size. This
134976 ** function checks to see if the position list contains any entries for
@@ -135091,12 +135699,26 @@
135091 char *aDoclist, /* Pointer to doclist */
135092 int nDoclist /* Size of aDoclist in bytes */
135093 ){
135094 if( pTS->aaOutput[0]==0 ){
135095 /* If this is the first term selected, copy the doclist to the output
135096 ** buffer using memcpy(). */
135097 pTS->aaOutput[0] = sqlite3_malloc(nDoclist);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135098 pTS->anOutput[0] = nDoclist;
135099 if( pTS->aaOutput[0] ){
135100 memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
135101 }else{
135102 return SQLITE_NOMEM;
@@ -135189,11 +135811,11 @@
135189 ** Fts3SegReaderPending might segfault, as the data structures used by
135190 ** fts4aux are not completely populated. So it's easiest to filter these
135191 ** calls out here. */
135192 if( iLevel<0 && p->aIndex ){
135193 Fts3SegReader *pSeg = 0;
135194 rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix, &pSeg);
135195 if( rc==SQLITE_OK && pSeg ){
135196 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
135197 }
135198 }
135199
@@ -135838,15 +136460,35 @@
135838 */
135839 static void fts3ReversePoslist(char *pStart, char **ppPoslist){
135840 char *p = &(*ppPoslist)[-2];
135841 char c = 0;
135842
 
135843 while( p>pStart && (c=*p--)==0 );
 
 
 
 
135844 while( p>pStart && (*p & 0x80) | c ){
135845 c = *p--;
135846 }
135847 if( p>pStart ){ p = &p[2]; }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
135848 while( *p++&0x80 );
135849 *ppPoslist = p;
135850 }
135851
135852 /*
@@ -135913,10 +136555,12 @@
135913 case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
135914 case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
135915 }
135916 if( !zEllipsis || !zEnd || !zStart ){
135917 sqlite3_result_error_nomem(pContext);
 
 
135918 }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
135919 sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
135920 }
135921 }
135922
@@ -136348,18 +136992,21 @@
136348 ** It is merged into the main doclist stored in p->doclist.aAll/nAll.
136349 **
136350 ** This function assumes that pList points to a buffer allocated using
136351 ** sqlite3_malloc(). This function takes responsibility for eventually
136352 ** freeing the buffer.
 
 
136353 */
136354 static void fts3EvalPhraseMergeToken(
136355 Fts3Table *pTab, /* FTS Table pointer */
136356 Fts3Phrase *p, /* Phrase to merge pList/nList into */
136357 int iToken, /* Token pList/nList corresponds to */
136358 char *pList, /* Pointer to doclist */
136359 int nList /* Number of bytes in pList */
136360 ){
 
136361 assert( iToken!=p->iDoclistToken );
136362
136363 if( pList==0 ){
136364 sqlite3_free(p->doclist.aAll);
136365 p->doclist.aAll = 0;
@@ -136394,17 +137041,20 @@
136394 pLeft = pList;
136395 nLeft = nList;
136396 nDiff = p->iDoclistToken - iToken;
136397 }
136398
136399 fts3DoclistPhraseMerge(pTab->bDescIdx, nDiff, pLeft, nLeft, pRight,&nRight);
 
 
136400 sqlite3_free(pLeft);
136401 p->doclist.aAll = pRight;
136402 p->doclist.nAll = nRight;
136403 }
136404
136405 if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
 
136406 }
136407
136408 /*
136409 ** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist
136410 ** does not take deferred tokens into account.
@@ -136426,11 +137076,11 @@
136426 if( pToken->pSegcsr ){
136427 int nThis = 0;
136428 char *pThis = 0;
136429 rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
136430 if( rc==SQLITE_OK ){
136431 fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
136432 }
136433 }
136434 assert( pToken->pSegcsr==0 );
136435 }
136436
@@ -136968,16 +137618,18 @@
136968 Fts3Expr *pExpr, /* Expression to initialize phrases in */
136969 int *pRc /* IN/OUT: Error code */
136970 ){
136971 if( pExpr && SQLITE_OK==*pRc ){
136972 if( pExpr->eType==FTSQUERY_PHRASE ){
136973 int i;
136974 int nToken = pExpr->pPhrase->nToken;
136975 for(i=0; i<nToken; i++){
136976 if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
 
 
 
 
136977 }
136978 pExpr->bDeferred = (i==nToken);
136979 *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);
136980 }else{
136981 fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);
136982 fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);
136983 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
@@ -137228,13 +137880,17 @@
137228 Fts3PhraseToken *pToken = pTC->pToken;
137229 int nList = 0;
137230 char *pList = 0;
137231 rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
137232 assert( rc==SQLITE_OK || pList==0 );
 
 
 
 
 
137233 if( rc==SQLITE_OK ){
137234 int nCount;
137235 fts3EvalPhraseMergeToken(pTab, pTC->pPhrase, pTC->iToken,pList,nList);
137236 nCount = fts3DoclistCountDocids(
137237 pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll
137238 );
137239 if( ii==0 || nCount<nMinEst ) nMinEst = nCount;
137240 }
@@ -138132,11 +138788,12 @@
138132 if( rc!=SQLITE_OK ) return rc;
138133
138134 pIter = pPhrase->pOrPoslist;
138135 iDocid = pPhrase->iOrDocid;
138136 if( pCsr->bDesc==bDescDoclist ){
138137 bEof = (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
 
138138 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
138139 sqlite3Fts3DoclistNext(
138140 bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
138141 &pIter, &iDocid, &bEof
138142 );
@@ -138213,11 +138870,11 @@
138213 ** Initialize API pointer table, if required.
138214 */
138215 #ifdef _WIN32
138216 __declspec(dllexport)
138217 #endif
138218 SQLITE_API int sqlite3_fts3_init(
138219 sqlite3 *db,
138220 char **pzErrMsg,
138221 const sqlite3_api_routines *pApi
138222 ){
138223 SQLITE_EXTENSION_INIT2(pApi)
@@ -138344,11 +139001,11 @@
138344
138345 *ppVtab = (sqlite3_vtab *)p;
138346 return SQLITE_OK;
138347
138348 bad_args:
138349 *pzErr = sqlite3_mprintf("invalid arguments to fts4aux constructor");
138350 return SQLITE_ERROR;
138351 }
138352
138353 /*
138354 ** This function does the work for both the xDisconnect and xDestroy methods.
@@ -139802,17 +140459,17 @@
139802
139803 if( rc!=SQLITE_OK ){
139804 sqlite3Fts3ExprFree(*ppExpr);
139805 *ppExpr = 0;
139806 if( rc==SQLITE_TOOBIG ){
139807 *pzErr = sqlite3_mprintf(
139808 "FTS expression tree is too large (maximum depth %d)",
139809 SQLITE_FTS3_MAX_EXPR_DEPTH
139810 );
139811 rc = SQLITE_ERROR;
139812 }else if( rc==SQLITE_ERROR ){
139813 *pzErr = sqlite3_mprintf("malformed MATCH expression: [%s]", z);
139814 }
139815 }
139816
139817 return rc;
139818 }
@@ -141284,11 +141941,11 @@
141284 z[n] = '\0';
141285 sqlite3Fts3Dequote(z);
141286
141287 m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
141288 if( !m ){
141289 *pzErr = sqlite3_mprintf("unknown tokenizer: %s", z);
141290 rc = SQLITE_ERROR;
141291 }else{
141292 char const **aArg = 0;
141293 int iArg = 0;
141294 z = &z[n+1];
@@ -141307,11 +141964,11 @@
141307 z = &z[n+1];
141308 }
141309 rc = m->xCreate(iArg, aArg, ppTok);
141310 assert( rc!=SQLITE_OK || *ppTok );
141311 if( rc!=SQLITE_OK ){
141312 *pzErr = sqlite3_mprintf("unknown tokenizer");
141313 }else{
141314 (*ppTok)->pModule = m;
141315 }
141316 sqlite3_free((void *)aArg);
141317 }
@@ -141391,13 +142048,13 @@
141391
141392 pHash = (Fts3Hash *)sqlite3_user_data(context);
141393 p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
141394
141395 if( !p ){
141396 char *zErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
141397 sqlite3_result_error(context, zErr, -1);
141398 sqlite3_free(zErr);
141399 return;
141400 }
141401
141402 pRet = Tcl_NewObj();
141403 Tcl_IncrRefCount(pRet);
@@ -141928,11 +142585,11 @@
141928 sqlite3_tokenizer_module *p;
141929 int nName = (int)strlen(zName);
141930
141931 p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
141932 if( !p ){
141933 *pzErr = sqlite3_mprintf("unknown tokenizer: %s", zName);
141934 return SQLITE_ERROR;
141935 }
141936
141937 *pp = p;
141938 return SQLITE_OK;
@@ -142625,11 +143282,11 @@
142625 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
142626 /* 24 */ "",
142627 /* 25 */ "",
142628
142629 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
142630 /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
142631
142632 /* This statement is used to determine which level to read the input from
142633 ** when performing an incremental merge. It returns the absolute level number
142634 ** of the oldest level in the db that contains at least ? segments. Or,
142635 ** if no level in the FTS index contains more than ? segments, the statement
@@ -145743,11 +146400,12 @@
145743 sqlite3_stmt *pAllLangid = 0;
145744
145745 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
145746 if( rc==SQLITE_OK ){
145747 int rc2;
145748 sqlite3_bind_int(pAllLangid, 1, p->nIndex);
 
145749 while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
145750 int i;
145751 int iLangid = sqlite3_column_int(pAllLangid, 0);
145752 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
145753 rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);
@@ -147075,11 +147733,11 @@
147075 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
147076
147077 pHint->n = i;
147078 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
147079 i += fts3GetVarint32(&pHint->a[i], pnInput);
147080 if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
147081
147082 return SQLITE_OK;
147083 }
147084
147085
@@ -147443,11 +148101,12 @@
147443
147444 /* This block calculates the checksum according to the FTS index. */
147445 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
147446 if( rc==SQLITE_OK ){
147447 int rc2;
147448 sqlite3_bind_int(pAllLangid, 1, p->nIndex);
 
147449 while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
147450 int iLangid = sqlite3_column_int(pAllLangid, 0);
147451 int i;
147452 for(i=0; i<p->nIndex; i++){
147453 cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
@@ -147456,11 +148115,10 @@
147456 rc2 = sqlite3_reset(pAllLangid);
147457 if( rc==SQLITE_OK ) rc = rc2;
147458 }
147459
147460 /* This block calculates the checksum according to the %_content table */
147461 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
147462 if( rc==SQLITE_OK ){
147463 sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
147464 sqlite3_stmt *pStmt = 0;
147465 char *zSql;
147466
@@ -147553,11 +148211,11 @@
147553 Fts3Table *p /* FTS3 table handle */
147554 ){
147555 int rc;
147556 int bOk = 0;
147557 rc = fts3IntegrityCheck(p, &bOk);
147558 if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
147559 return rc;
147560 }
147561
147562 /*
147563 ** Handle a 'special' INSERT of the form:
@@ -147991,10 +148649,11 @@
147991 #define FTS3_MATCHINFO_NDOC 'n' /* 1 value */
147992 #define FTS3_MATCHINFO_AVGLENGTH 'a' /* nCol values */
147993 #define FTS3_MATCHINFO_LENGTH 'l' /* nCol values */
147994 #define FTS3_MATCHINFO_LCS 's' /* nCol values */
147995 #define FTS3_MATCHINFO_HITS 'x' /* 3*nCol*nPhrase values */
 
147996
147997 /*
147998 ** The default value for the second argument to matchinfo().
147999 */
148000 #define FTS3_MATCHINFO_DEFAULT "pcx"
@@ -148772,10 +149431,55 @@
148772 }
148773 }
148774
148775 return rc;
148776 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
148777
148778 static int fts3MatchinfoCheck(
148779 Fts3Table *pTab,
148780 char cArg,
148781 char **pzErr
@@ -148785,14 +149489,15 @@
148785 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
148786 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
148787 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
148788 || (cArg==FTS3_MATCHINFO_LCS)
148789 || (cArg==FTS3_MATCHINFO_HITS)
 
148790 ){
148791 return SQLITE_OK;
148792 }
148793 *pzErr = sqlite3_mprintf("unrecognized matchinfo request: %c", cArg);
148794 return SQLITE_ERROR;
148795 }
148796
148797 static int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){
148798 int nVal; /* Number of integers output by cArg */
@@ -148807,10 +149512,14 @@
148807 case FTS3_MATCHINFO_AVGLENGTH:
148808 case FTS3_MATCHINFO_LENGTH:
148809 case FTS3_MATCHINFO_LCS:
148810 nVal = pInfo->nCol;
148811 break;
 
 
 
 
148812
148813 default:
148814 assert( cArg==FTS3_MATCHINFO_HITS );
148815 nVal = pInfo->nCol * pInfo->nPhrase * 3;
148816 break;
@@ -149061,10 +149770,14 @@
149061 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
149062 if( rc==SQLITE_OK ){
149063 rc = fts3MatchinfoLcs(pCsr, pInfo);
149064 }
149065 break;
 
 
 
 
149066
149067 default: {
149068 Fts3Expr *pExpr;
149069 assert( zArg[i]==FTS3_MATCHINFO_HITS );
149070 pExpr = pCsr->pExpr;
@@ -153074,15 +153787,23 @@
153074 ** conflict-handling mode specified by the user.
153075 */
153076 if( nData>1 ){
153077 int ii;
153078
153079 /* Populate the cell.aCoord[] array. The first coordinate is azData[3]. */
153080 assert( nData==(pRtree->nDim*2 + 3) );
 
 
 
 
 
 
 
 
153081 #ifndef SQLITE_RTREE_INT_ONLY
153082 if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
153083 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
153084 cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
153085 cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
153086 if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
153087 rc = SQLITE_CONSTRAINT;
153088 goto constraint;
@@ -153089,11 +153810,11 @@
153089 }
153090 }
153091 }else
153092 #endif
153093 {
153094 for(ii=0; ii<(pRtree->nDim*2); ii+=2){
153095 cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
153096 cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
153097 if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
153098 rc = SQLITE_CONSTRAINT;
153099 goto constraint;
@@ -153660,11 +154381,11 @@
153660 }
153661
153662 /*
153663 ** Register a new geometry function for use with the r-tree MATCH operator.
153664 */
153665 SQLITE_API int sqlite3_rtree_geometry_callback(
153666 sqlite3 *db, /* Register SQL function on this connection */
153667 const char *zGeom, /* Name of the new SQL function */
153668 int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
153669 void *pContext /* Extra data associated with the callback */
153670 ){
@@ -153684,11 +154405,11 @@
153684
153685 /*
153686 ** Register a new 2nd-generation geometry function for use with the
153687 ** r-tree MATCH operator.
153688 */
153689 SQLITE_API int sqlite3_rtree_query_callback(
153690 sqlite3 *db, /* Register SQL function on this connection */
153691 const char *zQueryFunc, /* Name of new SQL function */
153692 int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
153693 void *pContext, /* Extra data passed into the callback */
153694 void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153709,11 +154430,11 @@
153709
153710 #if !SQLITE_CORE
153711 #ifdef _WIN32
153712 __declspec(dllexport)
153713 #endif
153714 SQLITE_API int sqlite3_rtree_init(
153715 sqlite3 *db,
153716 char **pzErrMsg,
153717 const sqlite3_api_routines *pApi
153718 ){
153719 SQLITE_EXTENSION_INIT2(pApi)
@@ -154214,11 +154935,11 @@
154214
154215 #if !SQLITE_CORE
154216 #ifdef _WIN32
154217 __declspec(dllexport)
154218 #endif
154219 SQLITE_API int sqlite3_icu_init(
154220 sqlite3 *db,
154221 char **pzErrMsg,
154222 const sqlite3_api_routines *pApi
154223 ){
154224 SQLITE_EXTENSION_INIT2(pApi)
@@ -154489,5 +155210,656 @@
154489
154490 #endif /* defined(SQLITE_ENABLE_ICU) */
154491 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
154492
154493 /************** End of fts3_icu.c ********************************************/
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
154494
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.8.10.1. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -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
@@ -71,10 +68,11 @@
68 #if defined(_MSC_VER)
69 #pragma warning(disable : 4054)
70 #pragma warning(disable : 4055)
71 #pragma warning(disable : 4100)
72 #pragma warning(disable : 4127)
73 #pragma warning(disable : 4130)
74 #pragma warning(disable : 4152)
75 #pragma warning(disable : 4189)
76 #pragma warning(disable : 4206)
77 #pragma warning(disable : 4210)
78 #pragma warning(disable : 4232)
@@ -250,27 +248,24 @@
248 extern "C" {
249 #endif
250
251
252 /*
253 ** Provide the ability to override linkage features of the interface.
254 */
255 #ifndef SQLITE_EXTERN
256 # define SQLITE_EXTERN extern
257 #endif
 
258 #ifndef SQLITE_API
259 # define SQLITE_API
260 #endif
 
 
 
 
 
261 #ifndef SQLITE_CDECL
262 # define SQLITE_CDECL
263 #endif
264 #ifndef SQLITE_STDCALL
265 # define SQLITE_STDCALL
266 #endif
267
268 /*
269 ** These no-op macros are used in front of interfaces to mark those
270 ** interfaces as either deprecated or experimental. New applications
271 ** should not use deprecated interfaces - they are supported for backwards
@@ -321,13 +316,13 @@
316 **
317 ** See also: [sqlite3_libversion()],
318 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
319 ** [sqlite_version()] and [sqlite_source_id()].
320 */
321 #define SQLITE_VERSION "3.8.10.1"
322 #define SQLITE_VERSION_NUMBER 3008010
323 #define SQLITE_SOURCE_ID "2015-05-09 12:14:55 05b4b1f2a937c06c90db70c09890038f6c98ec40"
324
325 /*
326 ** CAPI3REF: Run-Time Library Version Numbers
327 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
328 **
@@ -356,13 +351,13 @@
351 ** [SQLITE_SOURCE_ID] C preprocessor macro.
352 **
353 ** See also: [sqlite_version()] and [sqlite_source_id()].
354 */
355 SQLITE_API const char sqlite3_version[] = SQLITE_VERSION;
356 SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void);
357 SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void);
358 SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void);
359
360 /*
361 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
362 **
363 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -383,12 +378,12 @@
378 **
379 ** See also: SQL functions [sqlite_compileoption_used()] and
380 ** [sqlite_compileoption_get()] and the [compile_options pragma].
381 */
382 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
383 SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName);
384 SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N);
385 #endif
386
387 /*
388 ** CAPI3REF: Test To See If The Library Is Threadsafe
389 **
@@ -423,11 +418,11 @@
418 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
419 ** is unchanged by calls to sqlite3_config().)^
420 **
421 ** See the [threading mode] documentation for additional information.
422 */
423 SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
424
425 /*
426 ** CAPI3REF: Database Connection Handle
427 ** KEYWORDS: {database connection} {database connections}
428 **
@@ -480,10 +475,11 @@
475 # define double sqlite3_int64
476 #endif
477
478 /*
479 ** CAPI3REF: Closing A Database Connection
480 ** DESTRUCTOR: sqlite3
481 **
482 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
483 ** for the [sqlite3] object.
484 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
485 ** the [sqlite3] object is successfully destroyed and all associated
@@ -519,12 +515,12 @@
515 ** from [sqlite3_open()], [sqlite3_open16()], or
516 ** [sqlite3_open_v2()], and not previously closed.
517 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
518 ** argument is a harmless no-op.
519 */
520 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
521 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
522
523 /*
524 ** The type for a callback function.
525 ** This is legacy and deprecated. It is included for historical
526 ** compatibility and is not documented.
@@ -531,10 +527,11 @@
527 */
528 typedef int (*sqlite3_callback)(void*,int,char**, char**);
529
530 /*
531 ** CAPI3REF: One-Step Query Execution Interface
532 ** METHOD: sqlite3
533 **
534 ** The sqlite3_exec() interface is a convenience wrapper around
535 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
536 ** that allows an application to run multiple statements of SQL
537 ** without having to use a lot of C code.
@@ -590,11 +587,11 @@
587 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
588 ** <li> The application must not modify the SQL statement text passed into
589 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
590 ** </ul>
591 */
592 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
593 sqlite3*, /* An open database */
594 const char *sql, /* SQL to be evaluated */
595 int (*callback)(void*,int,char**,char**), /* Callback function */
596 void *, /* 1st argument to callback */
597 char **errmsg /* Error msg written here */
@@ -1550,14 +1547,14 @@
1547 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1548 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1549 ** must return [SQLITE_OK] on success and some other [error code] upon
1550 ** failure.
1551 */
1552 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1553 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1554 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1555 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
1556
1557 /*
1558 ** CAPI3REF: Configuring The SQLite Library
1559 **
1560 ** The sqlite3_config() interface is used to make global configuration
@@ -1584,14 +1581,15 @@
1581 **
1582 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1583 ** ^If the option is unknown or SQLite is unable to set the option
1584 ** then this routine returns a non-zero [error code].
1585 */
1586 SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
1587
1588 /*
1589 ** CAPI3REF: Configure database connections
1590 ** METHOD: sqlite3
1591 **
1592 ** The sqlite3_db_config() interface is used to make configuration
1593 ** changes to a [database connection]. The interface is similar to
1594 ** [sqlite3_config()] except that the changes apply to a single
1595 ** [database connection] (specified in the first argument).
@@ -1602,11 +1600,11 @@
1600 ** Subsequent arguments vary depending on the configuration verb.
1601 **
1602 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1603 ** the call is considered successful.
1604 */
1605 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
1606
1607 /*
1608 ** CAPI3REF: Memory Allocation Routines
1609 **
1610 ** An instance of this object defines the interface between SQLite
@@ -2085,19 +2083,21 @@
2083 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
2084
2085
2086 /*
2087 ** CAPI3REF: Enable Or Disable Extended Result Codes
2088 ** METHOD: sqlite3
2089 **
2090 ** ^The sqlite3_extended_result_codes() routine enables or disables the
2091 ** [extended result codes] feature of SQLite. ^The extended result
2092 ** codes are disabled by default for historical compatibility.
2093 */
2094 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
2095
2096 /*
2097 ** CAPI3REF: Last Insert Rowid
2098 ** METHOD: sqlite3
2099 **
2100 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
2101 ** has a unique 64-bit signed
2102 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
2103 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -2141,14 +2141,15 @@
2141 ** function is running and thus changes the last insert [rowid],
2142 ** then the value returned by [sqlite3_last_insert_rowid()] is
2143 ** unpredictable and might not equal either the old or the new
2144 ** last insert [rowid].
2145 */
2146 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
2147
2148 /*
2149 ** CAPI3REF: Count The Number Of Rows Modified
2150 ** METHOD: sqlite3
2151 **
2152 ** ^This function returns the number of rows modified, inserted or
2153 ** deleted by the most recently completed INSERT, UPDATE or DELETE
2154 ** statement on the database connection specified by the only parameter.
2155 ** ^Executing any other type of SQL statement does not modify the value
@@ -2193,14 +2194,15 @@
2194 **
2195 ** If a separate thread makes changes on the same database connection
2196 ** while [sqlite3_changes()] is running then the value returned
2197 ** is unpredictable and not meaningful.
2198 */
2199 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
2200
2201 /*
2202 ** CAPI3REF: Total Number Of Rows Modified
2203 ** METHOD: sqlite3
2204 **
2205 ** ^This function returns the total number of rows inserted, modified or
2206 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2207 ** since the database connection was opened, including those executed as
2208 ** part of trigger programs. ^Executing any other type of SQL statement
@@ -2216,14 +2218,15 @@
2218 **
2219 ** If a separate thread makes changes on the same database connection
2220 ** while [sqlite3_total_changes()] is running then the value
2221 ** returned is unpredictable and not meaningful.
2222 */
2223 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
2224
2225 /*
2226 ** CAPI3REF: Interrupt A Long-Running Query
2227 ** METHOD: sqlite3
2228 **
2229 ** ^This function causes any pending database operation to abort and
2230 ** return at its earliest opportunity. This routine is typically
2231 ** called in response to a user action such as pressing "Cancel"
2232 ** or Ctrl-C where the user wants a long query operation to halt
@@ -2255,11 +2258,11 @@
2258 ** that are started after the sqlite3_interrupt() call returns.
2259 **
2260 ** If the database connection closes while [sqlite3_interrupt()]
2261 ** is running then bad things will likely happen.
2262 */
2263 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
2264
2265 /*
2266 ** CAPI3REF: Determine If An SQL Statement Is Complete
2267 **
2268 ** These routines are useful during command-line input to determine if the
@@ -2290,16 +2293,17 @@
2293 ** UTF-8 string.
2294 **
2295 ** The input to [sqlite3_complete16()] must be a zero-terminated
2296 ** UTF-16 string in native byte order.
2297 */
2298 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2299 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
2300
2301 /*
2302 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2303 ** KEYWORDS: {busy-handler callback} {busy handler}
2304 ** METHOD: sqlite3
2305 **
2306 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
2307 ** that might be invoked with argument P whenever
2308 ** an attempt is made to access a database table associated with
2309 ** [database connection] D when another thread
@@ -2351,14 +2355,15 @@
2355 ** result in undefined behavior.
2356 **
2357 ** A busy handler must not close the database connection
2358 ** or [prepared statement] that invoked the busy handler.
2359 */
2360 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2361
2362 /*
2363 ** CAPI3REF: Set A Busy Timeout
2364 ** METHOD: sqlite3
2365 **
2366 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2367 ** for a specified amount of time when a table is locked. ^The handler
2368 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2369 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2373,14 +2378,15 @@
2378 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2379 ** this routine, that other busy handler is cleared.)^
2380 **
2381 ** See also: [PRAGMA busy_timeout]
2382 */
2383 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
2384
2385 /*
2386 ** CAPI3REF: Convenience Routines For Running Queries
2387 ** METHOD: sqlite3
2388 **
2389 ** This is a legacy interface that is preserved for backwards compatibility.
2390 ** Use of this interface is not recommended.
2391 **
2392 ** Definition: A <b>result table</b> is memory data structure created by the
@@ -2447,19 +2453,19 @@
2453 ** interface defined here. As a consequence, errors that occur in the
2454 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2455 ** reflected in subsequent calls to [sqlite3_errcode()] or
2456 ** [sqlite3_errmsg()].
2457 */
2458 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
2459 sqlite3 *db, /* An open database */
2460 const char *zSql, /* SQL to be evaluated */
2461 char ***pazResult, /* Results of the query */
2462 int *pnRow, /* Number of result rows written here */
2463 int *pnColumn, /* Number of result columns written here */
2464 char **pzErrmsg /* Error msg written here */
2465 );
2466 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
2467
2468 /*
2469 ** CAPI3REF: Formatted String Printing Functions
2470 **
2471 ** These routines are work-alikes of the "printf()" family of functions
@@ -2561,14 +2567,14 @@
2567 **
2568 ** ^(The "%z" formatting option works like "%s" but with the
2569 ** addition that after the string has been read and copied into
2570 ** the result, [sqlite3_free()] is called on the input string.)^
2571 */
2572 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2573 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2574 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2575 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
2576
2577 /*
2578 ** CAPI3REF: Memory Allocation Subsystem
2579 **
2580 ** The SQLite core uses these three routines for all of its own
@@ -2654,16 +2660,16 @@
2660 **
2661 ** The application must not read or write any part of
2662 ** a block of memory after it has been released using
2663 ** [sqlite3_free()] or [sqlite3_realloc()].
2664 */
2665 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2666 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2667 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2668 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2669 SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2670 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
2671
2672 /*
2673 ** CAPI3REF: Memory Allocator Statistics
2674 **
2675 ** SQLite provides these two interfaces for reporting on the status
@@ -2684,12 +2690,12 @@
2690 ** [sqlite3_memory_used()] if and only if the parameter to
2691 ** [sqlite3_memory_highwater()] is true. ^The value returned
2692 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2693 ** prior to the reset.
2694 */
2695 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2696 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
2697
2698 /*
2699 ** CAPI3REF: Pseudo-Random Number Generator
2700 **
2701 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2708,14 +2714,15 @@
2714 ** ^If the previous call to this routine had an N of 1 or more and a
2715 ** non-NULL P then the pseudo-randomness is generated
2716 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2717 ** method.
2718 */
2719 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
2720
2721 /*
2722 ** CAPI3REF: Compile-Time Authorization Callbacks
2723 ** METHOD: sqlite3
2724 **
2725 ** ^This routine registers an authorizer callback with a particular
2726 ** [database connection], supplied in the first argument.
2727 ** ^The authorizer callback is invoked as SQL statements are being compiled
2728 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2790,11 +2797,11 @@
2797 ** [sqlite3_prepare()] or its variants. Authorization is not
2798 ** performed during statement evaluation in [sqlite3_step()], unless
2799 ** as stated in the previous paragraph, sqlite3_step() invokes
2800 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2801 */
2802 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
2803 sqlite3*,
2804 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2805 void *pUserData
2806 );
2807
@@ -2868,10 +2875,11 @@
2875 #define SQLITE_COPY 0 /* No longer used */
2876 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2877
2878 /*
2879 ** CAPI3REF: Tracing And Profiling Functions
2880 ** METHOD: sqlite3
2881 **
2882 ** These routines register callback functions that can be used for
2883 ** tracing and profiling the execution of SQL statements.
2884 **
2885 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2894,16 +2902,17 @@
2902 ** digits in the time are meaningless. Future versions of SQLite
2903 ** might provide greater resolution on the profiler callback. The
2904 ** sqlite3_profile() function is considered experimental and is
2905 ** subject to change in future versions of SQLite.
2906 */
2907 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2908 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2909 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2910
2911 /*
2912 ** CAPI3REF: Query Progress Callbacks
2913 ** METHOD: sqlite3
2914 **
2915 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
2916 ** function X to be invoked periodically during long running calls to
2917 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2918 ** database connection D. An example use for this
@@ -2929,14 +2938,15 @@
2938 ** the database connection that invoked the progress handler.
2939 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2940 ** database connections for the meaning of "modify" in this paragraph.
2941 **
2942 */
2943 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2944
2945 /*
2946 ** CAPI3REF: Opening A New Database Connection
2947 ** CONSTRUCTOR: sqlite3
2948 **
2949 ** ^These routines open an SQLite database file as specified by the
2950 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2951 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2952 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -3157,19 +3167,19 @@
3167 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
3168 ** features that require the use of temporary files may fail.
3169 **
3170 ** See also: [sqlite3_temp_directory]
3171 */
3172 SQLITE_API int SQLITE_STDCALL sqlite3_open(
3173 const char *filename, /* Database filename (UTF-8) */
3174 sqlite3 **ppDb /* OUT: SQLite db handle */
3175 );
3176 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
3177 const void *filename, /* Database filename (UTF-16) */
3178 sqlite3 **ppDb /* OUT: SQLite db handle */
3179 );
3180 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
3181 const char *filename, /* Database filename (UTF-8) */
3182 sqlite3 **ppDb, /* OUT: SQLite db handle */
3183 int flags, /* Flags */
3184 const char *zVfs /* Name of VFS module to use */
3185 );
@@ -3211,17 +3221,18 @@
3221 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3222 ** is not a database file pathname pointer that SQLite passed into the xOpen
3223 ** VFS method, then the behavior of this routine is undefined and probably
3224 ** undesirable.
3225 */
3226 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3227 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3228 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3229
3230
3231 /*
3232 ** CAPI3REF: Error Codes And Messages
3233 ** METHOD: sqlite3
3234 **
3235 ** ^If the most recent sqlite3_* API call associated with
3236 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3237 ** returns the numeric [result code] or [extended result code] for that
3238 ** API call.
@@ -3256,44 +3267,45 @@
3267 **
3268 ** If an interface fails with SQLITE_MISUSE, that means the interface
3269 ** was invoked incorrectly by the application. In that case, the
3270 ** error code and message may or may not be set.
3271 */
3272 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3273 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3274 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3275 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3276 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
3277
3278 /*
3279 ** CAPI3REF: Prepared Statement Object
3280 ** KEYWORDS: {prepared statement} {prepared statements}
3281 **
3282 ** An instance of this object represents a single SQL statement that
3283 ** has been compiled into binary form and is ready to be evaluated.
 
3284 **
3285 ** Think of each SQL statement as a separate computer program. The
3286 ** original SQL text is source code. A prepared statement object
3287 ** is the compiled object code. All SQL must be converted into a
3288 ** prepared statement before it can be run.
3289 **
3290 ** The life-cycle of a prepared statement object usually goes like this:
3291 **
3292 ** <ol>
3293 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3294 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
 
3295 ** interfaces.
3296 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3297 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3298 ** to step 2. Do this zero or more times.
3299 ** <li> Destroy the object using [sqlite3_finalize()].
3300 ** </ol>
 
 
 
3301 */
3302 typedef struct sqlite3_stmt sqlite3_stmt;
3303
3304 /*
3305 ** CAPI3REF: Run-time Limits
3306 ** METHOD: sqlite3
3307 **
3308 ** ^(This interface allows the size of various constructs to be limited
3309 ** on a connection by connection basis. The first parameter is the
3310 ** [database connection] whose limit is to be set or queried. The
3311 ** second parameter is one of the [limit categories] that define a
@@ -3327,11 +3339,11 @@
3339 ** created by an untrusted script can be contained using the
3340 ** [max_page_count] [PRAGMA].
3341 **
3342 ** New run-time limit categories may be added in future releases.
3343 */
3344 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
3345
3346 /*
3347 ** CAPI3REF: Run-Time Limit Categories
3348 ** KEYWORDS: {limit category} {*limit categories}
3349 **
@@ -3401,10 +3413,12 @@
3413 #define SQLITE_LIMIT_WORKER_THREADS 11
3414
3415 /*
3416 ** CAPI3REF: Compiling An SQL Statement
3417 ** KEYWORDS: {SQL statement compiler}
3418 ** METHOD: sqlite3
3419 ** CONSTRUCTOR: sqlite3_stmt
3420 **
3421 ** To execute an SQL query, it must first be compiled into a byte-code
3422 ** program using one of these routines.
3423 **
3424 ** The first argument, "db", is a [database connection] obtained from a
@@ -3477,50 +3491,52 @@
3491 ** or [GLOB] operator or if the parameter is compared to an indexed column
3492 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3493 ** </li>
3494 ** </ol>
3495 */
3496 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
3497 sqlite3 *db, /* Database handle */
3498 const char *zSql, /* SQL statement, UTF-8 encoded */
3499 int nByte, /* Maximum length of zSql in bytes. */
3500 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3501 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3502 );
3503 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
3504 sqlite3 *db, /* Database handle */
3505 const char *zSql, /* SQL statement, UTF-8 encoded */
3506 int nByte, /* Maximum length of zSql in bytes. */
3507 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3508 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3509 );
3510 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
3511 sqlite3 *db, /* Database handle */
3512 const void *zSql, /* SQL statement, UTF-16 encoded */
3513 int nByte, /* Maximum length of zSql in bytes. */
3514 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3515 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3516 );
3517 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
3518 sqlite3 *db, /* Database handle */
3519 const void *zSql, /* SQL statement, UTF-16 encoded */
3520 int nByte, /* Maximum length of zSql in bytes. */
3521 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3522 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3523 );
3524
3525 /*
3526 ** CAPI3REF: Retrieving Statement SQL
3527 ** METHOD: sqlite3_stmt
3528 **
3529 ** ^This interface can be used to retrieve a saved copy of the original
3530 ** SQL text used to create a [prepared statement] if that statement was
3531 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3532 */
3533 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3534
3535 /*
3536 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3537 ** METHOD: sqlite3_stmt
3538 **
3539 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3540 ** and only if the [prepared statement] X makes no direct changes to
3541 ** the content of the database file.
3542 **
@@ -3544,14 +3560,15 @@
3560 ** database. ^The [ATTACH] and [DETACH] statements also cause
3561 ** sqlite3_stmt_readonly() to return true since, while those statements
3562 ** change the configuration of a database connection, they do not make
3563 ** changes to the content of the database files on disk.
3564 */
3565 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3566
3567 /*
3568 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3569 ** METHOD: sqlite3_stmt
3570 **
3571 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3572 ** [prepared statement] S has been stepped at least once using
3573 ** [sqlite3_step(S)] but has not run to completion and/or has not
3574 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3563,11 +3580,11 @@
3580 ** to locate all prepared statements associated with a database
3581 ** connection that are in need of being reset. This can be used,
3582 ** for example, in diagnostic routines to search for prepared
3583 ** statements that are holding a transaction open.
3584 */
3585 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
3586
3587 /*
3588 ** CAPI3REF: Dynamically Typed Value Object
3589 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3590 **
@@ -3622,10 +3639,11 @@
3639
3640 /*
3641 ** CAPI3REF: Binding Values To Prepared Statements
3642 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3643 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3644 ** METHOD: sqlite3_stmt
3645 **
3646 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3647 ** literals may be replaced by a [parameter] that matches one of following
3648 ** templates:
3649 **
@@ -3724,26 +3742,27 @@
3742 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3743 **
3744 ** See also: [sqlite3_bind_parameter_count()],
3745 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3746 */
3747 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3748 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3749 void(*)(void*));
3750 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3751 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3752 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3753 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3754 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3755 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3756 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3757 void(*)(void*), unsigned char encoding);
3758 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3759 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3760
3761 /*
3762 ** CAPI3REF: Number Of SQL Parameters
3763 ** METHOD: sqlite3_stmt
3764 **
3765 ** ^This routine can be used to find the number of [SQL parameters]
3766 ** in a [prepared statement]. SQL parameters are tokens of the
3767 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3768 ** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3756,14 +3775,15 @@
3775 **
3776 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3777 ** [sqlite3_bind_parameter_name()], and
3778 ** [sqlite3_bind_parameter_index()].
3779 */
3780 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
3781
3782 /*
3783 ** CAPI3REF: Name Of A Host Parameter
3784 ** METHOD: sqlite3_stmt
3785 **
3786 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3787 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3788 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3789 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3783,14 +3803,15 @@
3803 **
3804 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3805 ** [sqlite3_bind_parameter_count()], and
3806 ** [sqlite3_bind_parameter_index()].
3807 */
3808 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3809
3810 /*
3811 ** CAPI3REF: Index Of A Parameter With A Given Name
3812 ** METHOD: sqlite3_stmt
3813 **
3814 ** ^Return the index of an SQL parameter given its name. ^The
3815 ** index value returned is suitable for use as the second
3816 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3817 ** is returned if no matching parameter is found. ^The parameter
@@ -3799,34 +3820,37 @@
3820 **
3821 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3822 ** [sqlite3_bind_parameter_count()], and
3823 ** [sqlite3_bind_parameter_index()].
3824 */
3825 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3826
3827 /*
3828 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3829 ** METHOD: sqlite3_stmt
3830 **
3831 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3832 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3833 ** ^Use this routine to reset all host parameters to NULL.
3834 */
3835 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
3836
3837 /*
3838 ** CAPI3REF: Number Of Columns In A Result Set
3839 ** METHOD: sqlite3_stmt
3840 **
3841 ** ^Return the number of columns in the result set returned by the
3842 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3843 ** statement that does not return data (for example an [UPDATE]).
3844 **
3845 ** See also: [sqlite3_data_count()]
3846 */
3847 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
3848
3849 /*
3850 ** CAPI3REF: Column Names In A Result Set
3851 ** METHOD: sqlite3_stmt
3852 **
3853 ** ^These routines return the name assigned to a particular column
3854 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3855 ** interface returns a pointer to a zero-terminated UTF-8 string
3856 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3847,15 +3871,16 @@
3871 ** ^The name of a result column is the value of the "AS" clause for
3872 ** that column, if there is an AS clause. If there is no AS clause
3873 ** then the name of the column is unspecified and may change from
3874 ** one release of SQLite to the next.
3875 */
3876 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3877 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
3878
3879 /*
3880 ** CAPI3REF: Source Of Data In A Query Result
3881 ** METHOD: sqlite3_stmt
3882 **
3883 ** ^These routines provide a means to determine the database, table, and
3884 ** table column that is the origin of a particular result column in
3885 ** [SELECT] statement.
3886 ** ^The name of the database or table or column can be returned as
@@ -3895,19 +3920,20 @@
3920 ** If two or more threads call one or more
3921 ** [sqlite3_column_database_name | column metadata interfaces]
3922 ** for the same [prepared statement] and result column
3923 ** at the same time then the results are undefined.
3924 */
3925 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3926 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3927 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3928 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3929 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3930 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
3931
3932 /*
3933 ** CAPI3REF: Declared Datatype Of A Query Result
3934 ** METHOD: sqlite3_stmt
3935 **
3936 ** ^(The first parameter is a [prepared statement].
3937 ** If this statement is a [SELECT] statement and the Nth column of the
3938 ** returned result set of that [SELECT] is a table column (not an
3939 ** expression or subquery) then the declared type of the table
@@ -3931,15 +3957,16 @@
3957 ** data stored in that column is of the declared type. SQLite is
3958 ** strongly typed, but the typing is dynamic not static. ^Type
3959 ** is associated with individual values, not with the containers
3960 ** used to hold those values.
3961 */
3962 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3963 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
3964
3965 /*
3966 ** CAPI3REF: Evaluate An SQL Statement
3967 ** METHOD: sqlite3_stmt
3968 **
3969 ** After a [prepared statement] has been prepared using either
3970 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3971 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3972 ** must be called one or more times to evaluate the statement.
@@ -4011,14 +4038,15 @@
4038 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
4039 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
4040 ** then the more specific [error codes] are returned directly
4041 ** by sqlite3_step(). The use of the "v2" interface is recommended.
4042 */
4043 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
4044
4045 /*
4046 ** CAPI3REF: Number of columns in a result set
4047 ** METHOD: sqlite3_stmt
4048 **
4049 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
4050 ** current row of the result set of [prepared statement] P.
4051 ** ^If prepared statement P does not have results ready to return
4052 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -4031,11 +4059,11 @@
4059 ** where it always returns zero since each step of that multi-step
4060 ** pragma returns 0 columns of data.
4061 **
4062 ** See also: [sqlite3_column_count()]
4063 */
4064 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
4065
4066 /*
4067 ** CAPI3REF: Fundamental Datatypes
4068 ** KEYWORDS: SQLITE_TEXT
4069 **
@@ -4068,10 +4096,11 @@
4096 #define SQLITE3_TEXT 3
4097
4098 /*
4099 ** CAPI3REF: Result Values From A Query
4100 ** KEYWORDS: {column access functions}
4101 ** METHOD: sqlite3_stmt
4102 **
4103 ** These routines form the "result set" interface.
4104 **
4105 ** ^These routines return information about a single column of the current
4106 ** result row of a query. ^In every case the first argument is a pointer
@@ -4227,23 +4256,24 @@
4256 ** of these routines, a default value is returned. The default value
4257 ** is either the integer 0, the floating point number 0.0, or a NULL
4258 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4259 ** [SQLITE_NOMEM].)^
4260 */
4261 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4262 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4263 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4264 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4265 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4266 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4267 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4268 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4269 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4270 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
4271
4272 /*
4273 ** CAPI3REF: Destroy A Prepared Statement Object
4274 ** DESTRUCTOR: sqlite3_stmt
4275 **
4276 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4277 ** ^If the most recent evaluation of the statement encountered no errors
4278 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4279 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4263,14 +4293,15 @@
4293 ** resource leaks. It is a grievous error for the application to try to use
4294 ** a prepared statement after it has been finalized. Any use of a prepared
4295 ** statement after it has been finalized can result in undefined and
4296 ** undesirable behavior such as segfaults and heap corruption.
4297 */
4298 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
4299
4300 /*
4301 ** CAPI3REF: Reset A Prepared Statement Object
4302 ** METHOD: sqlite3_stmt
4303 **
4304 ** The sqlite3_reset() function is called to reset a [prepared statement]
4305 ** object back to its initial state, ready to be re-executed.
4306 ** ^Any SQL statement variables that had values bound to them using
4307 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4289,17 +4320,18 @@
4320 ** [sqlite3_reset(S)] returns an appropriate [error code].
4321 **
4322 ** ^The [sqlite3_reset(S)] interface does not change the values
4323 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4324 */
4325 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
4326
4327 /*
4328 ** CAPI3REF: Create Or Redefine SQL Functions
4329 ** KEYWORDS: {function creation routines}
4330 ** KEYWORDS: {application-defined SQL function}
4331 ** KEYWORDS: {application-defined SQL functions}
4332 ** METHOD: sqlite3
4333 **
4334 ** ^These functions (collectively known as "function creation routines")
4335 ** are used to add SQL functions or aggregates or to redefine the behavior
4336 ** of existing SQL functions or aggregates. The only differences between
4337 ** these routines are the text encoding expected for
@@ -4388,31 +4420,31 @@
4420 ** ^An application-defined function is permitted to call other
4421 ** SQLite interfaces. However, such calls must not
4422 ** close the database connection nor finalize or reset the prepared
4423 ** statement in which the function is running.
4424 */
4425 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
4426 sqlite3 *db,
4427 const char *zFunctionName,
4428 int nArg,
4429 int eTextRep,
4430 void *pApp,
4431 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4432 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4433 void (*xFinal)(sqlite3_context*)
4434 );
4435 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
4436 sqlite3 *db,
4437 const void *zFunctionName,
4438 int nArg,
4439 int eTextRep,
4440 void *pApp,
4441 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4442 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4443 void (*xFinal)(sqlite3_context*)
4444 );
4445 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
4446 sqlite3 *db,
4447 const char *zFunctionName,
4448 int nArg,
4449 int eTextRep,
4450 void *pApp,
@@ -4454,21 +4486,22 @@
4486 ** to be supported. However, new applications should avoid
4487 ** the use of these functions. To encourage programmers to avoid
4488 ** these functions, we will not explain what they do.
4489 */
4490 #ifndef SQLITE_OMIT_DEPRECATED
4491 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4492 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4493 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4494 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4495 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4496 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4497 void*,sqlite3_int64);
4498 #endif
4499
4500 /*
4501 ** CAPI3REF: Obtaining SQL Function Parameter Values
4502 ** METHOD: sqlite3_value
4503 **
4504 ** The C-language implementation of SQL functions and aggregates uses
4505 ** this set of interface routines to access the parameter values on
4506 ** the function or aggregate.
4507 **
@@ -4508,25 +4541,26 @@
4541 ** or [sqlite3_value_text16()].
4542 **
4543 ** These routines must be called from the same thread as
4544 ** the SQL function that supplied the [sqlite3_value*] parameters.
4545 */
4546 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4547 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4548 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4549 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4550 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4551 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4552 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4553 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4554 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4555 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4556 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4557 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
4558
4559 /*
4560 ** CAPI3REF: Obtain Aggregate Function Context
4561 ** METHOD: sqlite3_context
4562 **
4563 ** Implementations of aggregate SQL functions use this
4564 ** routine to allocate memory for storing their state.
4565 **
4566 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4563,14 +4597,15 @@
4597 ** function.
4598 **
4599 ** This routine must be called from the same thread in which
4600 ** the aggregate SQL function is running.
4601 */
4602 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4603
4604 /*
4605 ** CAPI3REF: User Data For Functions
4606 ** METHOD: sqlite3_context
4607 **
4608 ** ^The sqlite3_user_data() interface returns a copy of
4609 ** the pointer that was the pUserData parameter (the 5th parameter)
4610 ** of the [sqlite3_create_function()]
4611 ** and [sqlite3_create_function16()] routines that originally
@@ -4577,25 +4612,27 @@
4612 ** registered the application defined function.
4613 **
4614 ** This routine must be called from the same thread in which
4615 ** the application-defined function is running.
4616 */
4617 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
4618
4619 /*
4620 ** CAPI3REF: Database Connection For Functions
4621 ** METHOD: sqlite3_context
4622 **
4623 ** ^The sqlite3_context_db_handle() interface returns a copy of
4624 ** the pointer to the [database connection] (the 1st parameter)
4625 ** of the [sqlite3_create_function()]
4626 ** and [sqlite3_create_function16()] routines that originally
4627 ** registered the application defined function.
4628 */
4629 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
4630
4631 /*
4632 ** CAPI3REF: Function Auxiliary Data
4633 ** METHOD: sqlite3_context
4634 **
4635 ** These functions may be used by (non-aggregate) SQL functions to
4636 ** associate metadata with argument values. If the same value is passed to
4637 ** multiple invocations of the same SQL function during query execution, under
4638 ** some circumstances the associated metadata may be preserved. An example
@@ -4640,12 +4677,12 @@
4677 ** values and [parameters] and expressions composed from the same.)^
4678 **
4679 ** These routines must be called from the same thread in which
4680 ** the SQL function is running.
4681 */
4682 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4683 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4684
4685
4686 /*
4687 ** CAPI3REF: Constants Defining Special Destructor Behavior
4688 **
@@ -4664,10 +4701,11 @@
4701 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4702 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4703
4704 /*
4705 ** CAPI3REF: Setting The Result Of An SQL Function
4706 ** METHOD: sqlite3_context
4707 **
4708 ** These routines are used by the xFunc or xFinal callbacks that
4709 ** implement SQL functions and aggregates. See
4710 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4711 ** for additional information.
@@ -4776,33 +4814,34 @@
4814 **
4815 ** If these routines are called from within the different thread
4816 ** than the one containing the application-defined function that received
4817 ** the [sqlite3_context] pointer, the results are undefined.
4818 */
4819 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4820 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
4821 sqlite3_uint64,void(*)(void*));
4822 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4823 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4824 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4825 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4826 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4827 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4828 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4829 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4830 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4831 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4832 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4833 void(*)(void*), unsigned char encoding);
4834 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4835 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4836 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4837 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4838 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
4839
4840 /*
4841 ** CAPI3REF: Define New Collating Sequences
4842 ** METHOD: sqlite3
4843 **
4844 ** ^These functions add, remove, or modify a [collation] associated
4845 ** with the [database connection] specified as the first argument.
4846 **
4847 ** ^The name of the collation is a UTF-8 string
@@ -4876,35 +4915,36 @@
4915 ** is unfortunate but cannot be changed without breaking backwards
4916 ** compatibility.
4917 **
4918 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4919 */
4920 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
4921 sqlite3*,
4922 const char *zName,
4923 int eTextRep,
4924 void *pArg,
4925 int(*xCompare)(void*,int,const void*,int,const void*)
4926 );
4927 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
4928 sqlite3*,
4929 const char *zName,
4930 int eTextRep,
4931 void *pArg,
4932 int(*xCompare)(void*,int,const void*,int,const void*),
4933 void(*xDestroy)(void*)
4934 );
4935 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
4936 sqlite3*,
4937 const void *zName,
4938 int eTextRep,
4939 void *pArg,
4940 int(*xCompare)(void*,int,const void*,int,const void*)
4941 );
4942
4943 /*
4944 ** CAPI3REF: Collation Needed Callbacks
4945 ** METHOD: sqlite3
4946 **
4947 ** ^To avoid having to register all collation sequences before a database
4948 ** can be used, a single callback function may be registered with the
4949 ** [database connection] to be invoked whenever an undefined collation
4950 ** sequence is required.
@@ -4925,16 +4965,16 @@
4965 **
4966 ** The callback function should register the desired collation using
4967 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4968 ** [sqlite3_create_collation_v2()].
4969 */
4970 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
4971 sqlite3*,
4972 void*,
4973 void(*)(void*,sqlite3*,int eTextRep,const char*)
4974 );
4975 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
4976 sqlite3*,
4977 void*,
4978 void(*)(void*,sqlite3*,int eTextRep,const void*)
4979 );
4980
@@ -4944,15 +4984,15 @@
4984 ** called right after sqlite3_open().
4985 **
4986 ** The code to implement this API is not available in the public release
4987 ** of SQLite.
4988 */
4989 SQLITE_API int SQLITE_STDCALL sqlite3_key(
4990 sqlite3 *db, /* Database to be rekeyed */
4991 const void *pKey, int nKey /* The key */
4992 );
4993 SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
4994 sqlite3 *db, /* Database to be rekeyed */
4995 const char *zDbName, /* Name of the database */
4996 const void *pKey, int nKey /* The key */
4997 );
4998
@@ -4962,35 +5002,35 @@
5002 ** database is decrypted.
5003 **
5004 ** The code to implement this API is not available in the public release
5005 ** of SQLite.
5006 */
5007 SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
5008 sqlite3 *db, /* Database to be rekeyed */
5009 const void *pKey, int nKey /* The new key */
5010 );
5011 SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
5012 sqlite3 *db, /* Database to be rekeyed */
5013 const char *zDbName, /* Name of the database */
5014 const void *pKey, int nKey /* The new key */
5015 );
5016
5017 /*
5018 ** Specify the activation key for a SEE database. Unless
5019 ** activated, none of the SEE routines will work.
5020 */
5021 SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
5022 const char *zPassPhrase /* Activation phrase */
5023 );
5024 #endif
5025
5026 #ifdef SQLITE_ENABLE_CEROD
5027 /*
5028 ** Specify the activation key for a CEROD database. Unless
5029 ** activated, none of the CEROD routines will work.
5030 */
5031 SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
5032 const char *zPassPhrase /* Activation phrase */
5033 );
5034 #endif
5035
5036 /*
@@ -5008,11 +5048,11 @@
5048 ** method of the default [sqlite3_vfs] object. If the xSleep() method
5049 ** of the default VFS is not implemented correctly, or not implemented at
5050 ** all, then the behavior of sqlite3_sleep() may deviate from the description
5051 ** in the previous paragraphs.
5052 */
5053 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
5054
5055 /*
5056 ** CAPI3REF: Name Of The Folder Holding Temporary Files
5057 **
5058 ** ^(If this global variable is made to point to a string which is
@@ -5108,10 +5148,11 @@
5148 SQLITE_API char *sqlite3_data_directory;
5149
5150 /*
5151 ** CAPI3REF: Test For Auto-Commit Mode
5152 ** KEYWORDS: {autocommit mode}
5153 ** METHOD: sqlite3
5154 **
5155 ** ^The sqlite3_get_autocommit() interface returns non-zero or
5156 ** zero if the given database connection is or is not in autocommit mode,
5157 ** respectively. ^Autocommit mode is on by default.
5158 ** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -5126,26 +5167,28 @@
5167 **
5168 ** If another thread changes the autocommit status of the database
5169 ** connection while this routine is running, then the return value
5170 ** is undefined.
5171 */
5172 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
5173
5174 /*
5175 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
5176 ** METHOD: sqlite3_stmt
5177 **
5178 ** ^The sqlite3_db_handle interface returns the [database connection] handle
5179 ** to which a [prepared statement] belongs. ^The [database connection]
5180 ** returned by sqlite3_db_handle is the same [database connection]
5181 ** that was the first argument
5182 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
5183 ** create the statement in the first place.
5184 */
5185 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
5186
5187 /*
5188 ** CAPI3REF: Return The Filename For A Database Connection
5189 ** METHOD: sqlite3
5190 **
5191 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
5192 ** associated with database N of connection D. ^The main database file
5193 ** has the name "main". If there is no attached database N on the database
5194 ** connection D, or if database N is a temporary or in-memory database, then
@@ -5154,23 +5197,25 @@
5197 ** ^The filename returned by this function is the output of the
5198 ** xFullPathname method of the [VFS]. ^In other words, the filename
5199 ** will be an absolute pathname, even if the filename used
5200 ** to open the database originally was a URI or relative pathname.
5201 */
5202 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
5203
5204 /*
5205 ** CAPI3REF: Determine if a database is read-only
5206 ** METHOD: sqlite3
5207 **
5208 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5209 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
5210 ** the name of a database on connection D.
5211 */
5212 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5213
5214 /*
5215 ** CAPI3REF: Find the next prepared statement
5216 ** METHOD: sqlite3
5217 **
5218 ** ^This interface returns a pointer to the next [prepared statement] after
5219 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
5220 ** then this interface returns a pointer to the first prepared statement
5221 ** associated with the database connection pDb. ^If no prepared statement
@@ -5178,14 +5223,15 @@
5223 **
5224 ** The [database connection] pointer D in a call to
5225 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5226 ** connection and in particular must not be a NULL pointer.
5227 */
5228 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5229
5230 /*
5231 ** CAPI3REF: Commit And Rollback Notification Callbacks
5232 ** METHOD: sqlite3
5233 **
5234 ** ^The sqlite3_commit_hook() interface registers a callback
5235 ** function to be invoked whenever a transaction is [COMMIT | committed].
5236 ** ^Any callback set by a previous call to sqlite3_commit_hook()
5237 ** for the same database connection is overridden.
@@ -5226,15 +5272,16 @@
5272 ** ^The rollback callback is not invoked if a transaction is
5273 ** automatically rolled back because the database connection is closed.
5274 **
5275 ** See also the [sqlite3_update_hook()] interface.
5276 */
5277 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5278 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5279
5280 /*
5281 ** CAPI3REF: Data Change Notification Callbacks
5282 ** METHOD: sqlite3
5283 **
5284 ** ^The sqlite3_update_hook() interface registers a callback function
5285 ** with the [database connection] identified by the first argument
5286 ** to be invoked whenever a row is updated, inserted or deleted in
5287 ** a rowid table.
@@ -5277,11 +5324,11 @@
5324 ** the first call on D.
5325 **
5326 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5327 ** interfaces.
5328 */
5329 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
5330 sqlite3*,
5331 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5332 void*
5333 );
5334
@@ -5317,11 +5364,11 @@
5364 ** This interface is threadsafe on processors where writing a
5365 ** 32-bit integer is atomic.
5366 **
5367 ** See Also: [SQLite Shared-Cache Mode]
5368 */
5369 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
5370
5371 /*
5372 ** CAPI3REF: Attempt To Free Heap Memory
5373 **
5374 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5333,24 +5380,25 @@
5380 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5381 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5382 **
5383 ** See also: [sqlite3_db_release_memory()]
5384 */
5385 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
5386
5387 /*
5388 ** CAPI3REF: Free Memory Used By A Database Connection
5389 ** METHOD: sqlite3
5390 **
5391 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5392 ** memory as possible from database connection D. Unlike the
5393 ** [sqlite3_release_memory()] interface, this interface is in effect even
5394 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5395 ** omitted.
5396 **
5397 ** See also: [sqlite3_release_memory()]
5398 */
5399 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
5400
5401 /*
5402 ** CAPI3REF: Impose A Limit On Heap Size
5403 **
5404 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5398,11 +5446,11 @@
5446 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5447 **
5448 ** The circumstances under which SQLite will enforce the soft heap limit may
5449 ** changes in future releases of SQLite.
5450 */
5451 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
5452
5453 /*
5454 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5455 ** DEPRECATED
5456 **
@@ -5409,15 +5457,16 @@
5457 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5458 ** interface. This routine is provided for historical compatibility
5459 ** only. All new applications should use the
5460 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5461 */
5462 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
5463
5464
5465 /*
5466 ** CAPI3REF: Extract Metadata About A Column Of A Table
5467 ** METHOD: sqlite3
5468 **
5469 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5470 ** information about column C of table T in database D
5471 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5472 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5478,11 +5527,11 @@
5527 **
5528 ** ^This function causes all database schemas to be read from disk and
5529 ** parsed, if that has not already been done, and returns an error if
5530 ** any errors are encountered while loading the schema.
5531 */
5532 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
5533 sqlite3 *db, /* Connection handle */
5534 const char *zDbName, /* Database name or NULL */
5535 const char *zTableName, /* Table name */
5536 const char *zColumnName, /* Column name */
5537 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5492,10 +5541,11 @@
5541 int *pAutoinc /* OUTPUT: True if column is auto-increment */
5542 );
5543
5544 /*
5545 ** CAPI3REF: Load An Extension
5546 ** METHOD: sqlite3
5547 **
5548 ** ^This interface loads an SQLite extension library from the named file.
5549 **
5550 ** ^The sqlite3_load_extension() interface attempts to load an
5551 ** [SQLite extension] library contained in the file zFile. If
@@ -5524,19 +5574,20 @@
5574 ** [sqlite3_enable_load_extension()] prior to calling this API,
5575 ** otherwise an error will be returned.
5576 **
5577 ** See also the [load_extension() SQL function].
5578 */
5579 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
5580 sqlite3 *db, /* Load the extension into this database connection */
5581 const char *zFile, /* Name of the shared library containing extension */
5582 const char *zProc, /* Entry point. Derived from zFile if 0 */
5583 char **pzErrMsg /* Put error message here if not 0 */
5584 );
5585
5586 /*
5587 ** CAPI3REF: Enable Or Disable Extension Loading
5588 ** METHOD: sqlite3
5589 **
5590 ** ^So as not to open security holes in older applications that are
5591 ** unprepared to deal with [extension loading], and as a means of disabling
5592 ** [extension loading] while evaluating user-entered SQL, the following API
5593 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5544,11 +5595,11 @@
5595 ** ^Extension loading is off by default.
5596 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5597 ** to turn extension loading on and call it with onoff==0 to turn
5598 ** it back off again.
5599 */
5600 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5601
5602 /*
5603 ** CAPI3REF: Automatically Load Statically Linked Extensions
5604 **
5605 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5582,11 +5633,11 @@
5633 ** will be called more than once for each database connection that is opened.
5634 **
5635 ** See also: [sqlite3_reset_auto_extension()]
5636 ** and [sqlite3_cancel_auto_extension()]
5637 */
5638 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5639
5640 /*
5641 ** CAPI3REF: Cancel Automatic Extension Loading
5642 **
5643 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5594,19 +5645,19 @@
5645 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5646 ** routine returns 1 if initialization routine X was successfully
5647 ** unregistered and it returns 0 if X was not on the list of initialization
5648 ** routines.
5649 */
5650 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5651
5652 /*
5653 ** CAPI3REF: Reset Automatic Extension Loading
5654 **
5655 ** ^This interface disables all automatic extensions previously
5656 ** registered using [sqlite3_auto_extension()].
5657 */
5658 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
5659
5660 /*
5661 ** The interface to the virtual-table mechanism is currently considered
5662 ** to be experimental. The interface might change in incompatible ways.
5663 ** If this is a problem for you, do not use the interface at this time.
@@ -5782,10 +5833,11 @@
5833 #define SQLITE_INDEX_CONSTRAINT_GE 32
5834 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
5835
5836 /*
5837 ** CAPI3REF: Register A Virtual Table Implementation
5838 ** METHOD: sqlite3
5839 **
5840 ** ^These routines are used to register a new [virtual table module] name.
5841 ** ^Module names must be registered before
5842 ** creating a new [virtual table] using the module and before using a
5843 ** preexisting [virtual table] for the module.
@@ -5805,17 +5857,17 @@
5857 ** be invoked if the call to sqlite3_create_module_v2() fails.
5858 ** ^The sqlite3_create_module()
5859 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5860 ** destructor.
5861 */
5862 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
5863 sqlite3 *db, /* SQLite connection to register module with */
5864 const char *zName, /* Name of the module */
5865 const sqlite3_module *p, /* Methods for the module */
5866 void *pClientData /* Client data for xCreate/xConnect */
5867 );
5868 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
5869 sqlite3 *db, /* SQLite connection to register module with */
5870 const char *zName, /* Name of the module */
5871 const sqlite3_module *p, /* Methods for the module */
5872 void *pClientData, /* Client data for xCreate/xConnect */
5873 void(*xDestroy)(void*) /* Module destructor function */
@@ -5874,14 +5926,15 @@
5926 ** ^The [xCreate] and [xConnect] methods of a
5927 ** [virtual table module] call this interface
5928 ** to declare the format (the names and datatypes of the columns) of
5929 ** the virtual tables they implement.
5930 */
5931 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5932
5933 /*
5934 ** CAPI3REF: Overload A Function For A Virtual Table
5935 ** METHOD: sqlite3
5936 **
5937 ** ^(Virtual tables can provide alternative implementations of functions
5938 ** using the [xFindFunction] method of the [virtual table module].
5939 ** But global versions of those functions
5940 ** must exist in order to be overloaded.)^
@@ -5892,11 +5945,11 @@
5945 ** of the new function always causes an exception to be thrown. So
5946 ** the new function is not good for anything by itself. Its only
5947 ** purpose is to be a placeholder function that can be overloaded
5948 ** by a [virtual table].
5949 */
5950 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5951
5952 /*
5953 ** The interface to the virtual-table mechanism defined above (back up
5954 ** to a comment remarkably similar to this one) is currently considered
5955 ** to be experimental. The interface might change in incompatible ways.
@@ -5920,10 +5973,12 @@
5973 */
5974 typedef struct sqlite3_blob sqlite3_blob;
5975
5976 /*
5977 ** CAPI3REF: Open A BLOB For Incremental I/O
5978 ** METHOD: sqlite3
5979 ** CONSTRUCTOR: sqlite3_blob
5980 **
5981 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
5982 ** in row iRow, column zColumn, table zTable in database zDb;
5983 ** in other words, the same BLOB that would be selected by:
5984 **
@@ -5989,11 +6044,11 @@
6044 ** zero-filled blob to read or write using the incremental-blob interface.
6045 **
6046 ** To avoid a resource leak, every open [BLOB handle] should eventually
6047 ** be released by a call to [sqlite3_blob_close()].
6048 */
6049 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
6050 sqlite3*,
6051 const char *zDb,
6052 const char *zTable,
6053 const char *zColumn,
6054 sqlite3_int64 iRow,
@@ -6001,10 +6056,11 @@
6056 sqlite3_blob **ppBlob
6057 );
6058
6059 /*
6060 ** CAPI3REF: Move a BLOB Handle to a New Row
6061 ** METHOD: sqlite3_blob
6062 **
6063 ** ^This function is used to move an existing blob handle so that it points
6064 ** to a different row of the same database table. ^The new row is identified
6065 ** by the rowid value passed as the second argument. Only the row can be
6066 ** changed. ^The database, table and column on which the blob handle is open
@@ -6021,14 +6077,15 @@
6077 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
6078 ** always returns zero.
6079 **
6080 ** ^This function sets the database handle error code and message.
6081 */
6082 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
6083
6084 /*
6085 ** CAPI3REF: Close A BLOB Handle
6086 ** DESTRUCTOR: sqlite3_blob
6087 **
6088 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
6089 ** unconditionally. Even if this routine returns an error code, the
6090 ** handle is still closed.)^
6091 **
@@ -6043,14 +6100,15 @@
6100 ** with a null pointer (such as would be returned by a failed call to
6101 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
6102 ** is passed a valid open blob handle, the values returned by the
6103 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
6104 */
6105 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
6106
6107 /*
6108 ** CAPI3REF: Return The Size Of An Open BLOB
6109 ** METHOD: sqlite3_blob
6110 **
6111 ** ^Returns the size in bytes of the BLOB accessible via the
6112 ** successfully opened [BLOB handle] in its only argument. ^The
6113 ** incremental blob I/O routines can only read or overwriting existing
6114 ** blob content; they cannot change the size of a blob.
@@ -6058,14 +6116,15 @@
6116 ** This routine only works on a [BLOB handle] which has been created
6117 ** by a prior successful call to [sqlite3_blob_open()] and which has not
6118 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6119 ** to this routine results in undefined and probably undesirable behavior.
6120 */
6121 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
6122
6123 /*
6124 ** CAPI3REF: Read Data From A BLOB Incrementally
6125 ** METHOD: sqlite3_blob
6126 **
6127 ** ^(This function is used to read data from an open [BLOB handle] into a
6128 ** caller-supplied buffer. N bytes of data are copied into buffer Z
6129 ** from the open BLOB, starting at offset iOffset.)^
6130 **
@@ -6086,14 +6145,15 @@
6145 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6146 ** to this routine results in undefined and probably undesirable behavior.
6147 **
6148 ** See also: [sqlite3_blob_write()].
6149 */
6150 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
6151
6152 /*
6153 ** CAPI3REF: Write Data Into A BLOB Incrementally
6154 ** METHOD: sqlite3_blob
6155 **
6156 ** ^(This function is used to write data into an open [BLOB handle] from a
6157 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
6158 ** into the open BLOB, starting at offset iOffset.)^
6159 **
@@ -6127,11 +6187,11 @@
6187 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
6188 ** to this routine results in undefined and probably undesirable behavior.
6189 **
6190 ** See also: [sqlite3_blob_read()].
6191 */
6192 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
6193
6194 /*
6195 ** CAPI3REF: Virtual File System Objects
6196 **
6197 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -6158,13 +6218,13 @@
6218 **
6219 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
6220 ** ^(If the default VFS is unregistered, another VFS is chosen as
6221 ** the default. The choice for the new VFS is arbitrary.)^
6222 */
6223 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6224 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6225 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
6226
6227 /*
6228 ** CAPI3REF: Mutexes
6229 **
6230 ** The SQLite core uses these routines for thread
@@ -6273,15 +6333,15 @@
6333 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6334 ** behave as no-ops.
6335 **
6336 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6337 */
6338 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6339 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6340 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6341 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6342 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
6343
6344 /*
6345 ** CAPI3REF: Mutex Methods Object
6346 **
6347 ** An instance of this structure defines the low-level routines
@@ -6387,12 +6447,12 @@
6447 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6448 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6449 ** interface should also return 1 when given a NULL pointer.
6450 */
6451 #ifndef NDEBUG
6452 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6453 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
6454 #endif
6455
6456 /*
6457 ** CAPI3REF: Mutex Types
6458 **
@@ -6417,21 +6477,23 @@
6477 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6478 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6479
6480 /*
6481 ** CAPI3REF: Retrieve the mutex for a database connection
6482 ** METHOD: sqlite3
6483 **
6484 ** ^This interface returns a pointer the [sqlite3_mutex] object that
6485 ** serializes access to the [database connection] given in the argument
6486 ** when the [threading mode] is Serialized.
6487 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6488 ** routine returns a NULL pointer.
6489 */
6490 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
6491
6492 /*
6493 ** CAPI3REF: Low-Level Control Of Database Files
6494 ** METHOD: sqlite3
6495 **
6496 ** ^The [sqlite3_file_control()] interface makes a direct call to the
6497 ** xFileControl method for the [sqlite3_io_methods] object associated
6498 ** with a particular database identified by the second argument. ^The
6499 ** name of the database is "main" for the main database or "temp" for the
@@ -6458,11 +6520,11 @@
6520 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6521 ** xFileControl method.
6522 **
6523 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6524 */
6525 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6526
6527 /*
6528 ** CAPI3REF: Testing Interface
6529 **
6530 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6477,11 +6539,11 @@
6539 ** The details of the operation codes, their meanings, the parameters
6540 ** they take, and what they do are all subject to change without notice.
6541 ** Unlike most of the SQLite API, this function is not guaranteed to
6542 ** operate consistently from one release to the next.
6543 */
6544 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
6545
6546 /*
6547 ** CAPI3REF: Testing Interface Operation Codes
6548 **
6549 ** These constants are the valid operation code parameters used
@@ -6540,12 +6602,12 @@
6602 ** be represented by a 32-bit integer, then the values returned by
6603 ** sqlite3_status() are undefined.
6604 **
6605 ** See also: [sqlite3_db_status()]
6606 */
6607 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6608 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6609 int op,
6610 sqlite3_int64 *pCurrent,
6611 sqlite3_int64 *pHighwater,
6612 int resetFlag
6613 );
@@ -6644,10 +6706,11 @@
6706 #define SQLITE_STATUS_SCRATCH_SIZE 8
6707 #define SQLITE_STATUS_MALLOC_COUNT 9
6708
6709 /*
6710 ** CAPI3REF: Database Connection Status
6711 ** METHOD: sqlite3
6712 **
6713 ** ^This interface is used to retrieve runtime status information
6714 ** about a single [database connection]. ^The first argument is the
6715 ** database connection object to be interrogated. ^The second argument
6716 ** is an integer constant, taken from the set of
@@ -6664,11 +6727,11 @@
6727 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6728 ** non-zero [error code] on failure.
6729 **
6730 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6731 */
6732 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6733
6734 /*
6735 ** CAPI3REF: Status Parameters for database connections
6736 ** KEYWORDS: {SQLITE_DBSTATUS options}
6737 **
@@ -6772,10 +6835,11 @@
6835 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6836
6837
6838 /*
6839 ** CAPI3REF: Prepared Statement Status
6840 ** METHOD: sqlite3_stmt
6841 **
6842 ** ^(Each prepared statement maintains various
6843 ** [SQLITE_STMTSTATUS counters] that measure the number
6844 ** of times it has performed specific operations.)^ These counters can
6845 ** be used to monitor the performance characteristics of the prepared
@@ -6793,11 +6857,11 @@
6857 ** ^If the resetFlg is true, then the counter is reset to zero after this
6858 ** interface call returns.
6859 **
6860 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6861 */
6862 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6863
6864 /*
6865 ** CAPI3REF: Status Parameters for prepared statements
6866 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6867 **
@@ -7262,23 +7326,24 @@
7326 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7327 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7328 ** same time as another thread is invoking sqlite3_backup_step() it is
7329 ** possible that they return invalid values.
7330 */
7331 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
7332 sqlite3 *pDest, /* Destination database handle */
7333 const char *zDestName, /* Destination database name */
7334 sqlite3 *pSource, /* Source database handle */
7335 const char *zSourceName /* Source database name */
7336 );
7337 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7338 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7339 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7340 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
7341
7342 /*
7343 ** CAPI3REF: Unlock Notification
7344 ** METHOD: sqlite3
7345 **
7346 ** ^When running in shared-cache mode, a database operation may fail with
7347 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
7348 ** individual tables within the shared-cache cannot be obtained. See
7349 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7387,11 +7452,11 @@
7452 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7453 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7454 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7455 ** SQLITE_LOCKED.)^
7456 */
7457 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
7458 sqlite3 *pBlocked, /* Waiting connection */
7459 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7460 void *pNotifyArg /* Argument to pass to xNotify */
7461 );
7462
@@ -7402,12 +7467,12 @@
7467 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7468 ** and extensions to compare the contents of two buffers containing UTF-8
7469 ** strings in a case-independent fashion, using the same definition of "case
7470 ** independence" that SQLite uses internally when comparing identifiers.
7471 */
7472 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7473 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
7474
7475 /*
7476 ** CAPI3REF: String Globbing
7477 *
7478 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7418,11 +7483,11 @@
7483 ** sensitive.
7484 **
7485 ** Note that this routine returns zero on a match and non-zero if the strings
7486 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7487 */
7488 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
7489
7490 /*
7491 ** CAPI3REF: Error Logging Interface
7492 **
7493 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7441,14 +7506,15 @@
7506 ** will not use dynamically allocated memory. The log message is stored in
7507 ** a fixed-length buffer on the stack. If the log message is longer than
7508 ** a few hundred characters, it will be truncated to the length of the
7509 ** buffer.
7510 */
7511 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
7512
7513 /*
7514 ** CAPI3REF: Write-Ahead Log Commit Hook
7515 ** METHOD: sqlite3
7516 **
7517 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
7518 ** is invoked each time data is committed to a database in wal mode.
7519 **
7520 ** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7476,18 +7542,19 @@
7542 ** previously registered write-ahead log callback. ^Note that the
7543 ** [sqlite3_wal_autocheckpoint()] interface and the
7544 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7545 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7546 */
7547 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
7548 sqlite3*,
7549 int(*)(void *,sqlite3*,const char*,int),
7550 void*
7551 );
7552
7553 /*
7554 ** CAPI3REF: Configure an auto-checkpoint
7555 ** METHOD: sqlite3
7556 **
7557 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
7558 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7559 ** to automatically [checkpoint]
7560 ** after committing a transaction if there are N or
@@ -7510,14 +7577,15 @@
7577 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7578 ** pages. The use of this interface
7579 ** is only necessary if the default setting is found to be suboptimal
7580 ** for a particular application.
7581 */
7582 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7583
7584 /*
7585 ** CAPI3REF: Checkpoint a database
7586 ** METHOD: sqlite3
7587 **
7588 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
7589 ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
7590 **
7591 ** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7531,14 +7599,15 @@
7599 ** interface was added. This interface is retained for backwards
7600 ** compatibility and as a convenience for applications that need to manually
7601 ** start a callback but which do not need the full power (and corresponding
7602 ** complication) of [sqlite3_wal_checkpoint_v2()].
7603 */
7604 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7605
7606 /*
7607 ** CAPI3REF: Checkpoint a database
7608 ** METHOD: sqlite3
7609 **
7610 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
7611 ** operation on database X of [database connection] D in mode M. Status
7612 ** information is written back into integers pointed to by L and C.)^
7613 ** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7624,11 +7693,11 @@
7693 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7694 **
7695 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7696 ** from SQL.
7697 */
7698 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
7699 sqlite3 *db, /* Database handle */
7700 const char *zDb, /* Name of attached database (or NULL) */
7701 int eMode, /* SQLITE_CHECKPOINT_* value */
7702 int *pnLog, /* OUT: Size of WAL log in frames */
7703 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7660,11 +7729,11 @@
7729 **
7730 ** At present, there is only one option that may be configured using
7731 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7732 ** may be added in the future.
7733 */
7734 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
7735
7736 /*
7737 ** CAPI3REF: Virtual Table Configuration Options
7738 **
7739 ** These macros define the various options to the
@@ -7713,11 +7782,11 @@
7782 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7783 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7784 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7785 ** [virtual table].
7786 */
7787 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
7788
7789 /*
7790 ** CAPI3REF: Conflict resolution modes
7791 ** KEYWORDS: {conflict resolution mode}
7792 **
@@ -7789,10 +7858,11 @@
7858 #define SQLITE_SCANSTAT_EXPLAIN 4
7859 #define SQLITE_SCANSTAT_SELECTID 5
7860
7861 /*
7862 ** CAPI3REF: Prepared Statement Scan Status
7863 ** METHOD: sqlite3_stmt
7864 **
7865 ** This interface returns information about the predicted and measured
7866 ** performance for pStmt. Advanced applications can use this
7867 ** interface to compare the predicted and the measured performance and
7868 ** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7817,26 +7887,27 @@
7887 ** as if the loop did not exist - it returns non-zero and leave the variable
7888 ** that pOut points to unchanged.
7889 **
7890 ** See also: [sqlite3_stmt_scanstatus_reset()]
7891 */
7892 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
7893 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7894 int idx, /* Index of loop to report on */
7895 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7896 void *pOut /* Result written here */
7897 );
7898
7899 /*
7900 ** CAPI3REF: Zero Scan-Status Counters
7901 ** METHOD: sqlite3_stmt
7902 **
7903 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7904 **
7905 ** This API is only available if the library is built with pre-processor
7906 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7907 */
7908 SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7909
7910
7911 /*
7912 ** Undo the hack that converts floating point types to integer for
7913 ** builds on processors without floating point support.
@@ -7887,11 +7958,11 @@
7958 ** Register a geometry callback named zGeom that can be used as part of an
7959 ** R-Tree geometry query as follows:
7960 **
7961 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7962 */
7963 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
7964 sqlite3 *db,
7965 const char *zGeom,
7966 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7967 void *pContext
7968 );
@@ -7913,11 +7984,11 @@
7984 ** Register a 2nd-generation geometry callback named zScore that can be
7985 ** used as part of an R-Tree geometry query as follows:
7986 **
7987 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7988 */
7989 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
7990 sqlite3 *db,
7991 const char *zQueryFunc,
7992 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7993 void *pContext,
7994 void (*xDestructor)(void*)
@@ -8436,10 +8507,36 @@
8507 #else
8508 # define ALWAYS(X) (X)
8509 # define NEVER(X) (X)
8510 #endif
8511
8512 /*
8513 ** Declarations used for tracing the operating system interfaces.
8514 */
8515 #if defined(SQLITE_FORCE_OS_TRACE) || defined(SQLITE_TEST) || \
8516 (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
8517 extern int sqlite3OSTrace;
8518 # define OSTRACE(X) if( sqlite3OSTrace ) sqlite3DebugPrintf X
8519 # define SQLITE_HAVE_OS_TRACE
8520 #else
8521 # define OSTRACE(X)
8522 # undef SQLITE_HAVE_OS_TRACE
8523 #endif
8524
8525 /*
8526 ** Is the sqlite3ErrName() function needed in the build? Currently,
8527 ** it is needed by "mutex_w32.c" (when debugging), "os_win.c" (when
8528 ** OSTRACE is enabled), and by several "test*.c" files (which are
8529 ** compiled using SQLITE_TEST).
8530 */
8531 #if defined(SQLITE_HAVE_OS_TRACE) || defined(SQLITE_TEST) || \
8532 (defined(SQLITE_DEBUG) && SQLITE_OS_WIN)
8533 # define SQLITE_NEED_ERR_NAME
8534 #else
8535 # undef SQLITE_NEED_ERR_NAME
8536 #endif
8537
8538 /*
8539 ** Return true (non-zero) if the input is an integer that is too large
8540 ** to fit in 32-bits. This macro is used inside of various testcase()
8541 ** macros to verify that we have tested SQLite for large-file support.
8542 */
@@ -9157,12 +9254,12 @@
9254 */
9255 #ifdef SQLITE_OMIT_WSD
9256 #define SQLITE_WSD const
9257 #define GLOBAL(t,v) (*(t*)sqlite3_wsd_find((void*)&(v), sizeof(v)))
9258 #define sqlite3GlobalConfig GLOBAL(struct Sqlite3Config, sqlite3Config)
9259 SQLITE_API int SQLITE_STDCALL sqlite3_wsd_init(int N, int J);
9260 SQLITE_API void *SQLITE_STDCALL sqlite3_wsd_find(void *K, int L);
9261 #else
9262 #define SQLITE_WSD
9263 #define GLOBAL(t,v) v
9264 #define sqlite3GlobalConfig sqlite3Config
9265 #endif
@@ -9847,37 +9944,36 @@
9944 /* Properties such as "out2" or "jump" that are specified in
9945 ** comments following the "case" for each opcode in the vdbe.c
9946 ** are encoded into bitvectors as follows:
9947 */
9948 #define OPFLG_JUMP 0x0001 /* jump: P2 holds jmp target */
9949 #define OPFLG_IN1 0x0002 /* in1: P1 is an input */
9950 #define OPFLG_IN2 0x0004 /* in2: P2 is an input */
9951 #define OPFLG_IN3 0x0008 /* in3: P3 is an input */
9952 #define OPFLG_OUT2 0x0010 /* out2: P2 is an output */
9953 #define OPFLG_OUT3 0x0020 /* out3: P3 is an output */
 
9954 #define OPFLG_INITIALIZER {\
9955 /* 0 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x01, 0x01,\
9956 /* 8 */ 0x01, 0x01, 0x00, 0x00, 0x10, 0x00, 0x01, 0x00,\
9957 /* 16 */ 0x01, 0x01, 0x02, 0x12, 0x01, 0x02, 0x03, 0x08,\
9958 /* 24 */ 0x00, 0x10, 0x10, 0x10, 0x10, 0x00, 0x10, 0x10,\
9959 /* 32 */ 0x00, 0x00, 0x10, 0x00, 0x00, 0x02, 0x03, 0x02,\
9960 /* 40 */ 0x02, 0x00, 0x00, 0x01, 0x01, 0x03, 0x03, 0x00,\
9961 /* 48 */ 0x00, 0x00, 0x10, 0x10, 0x08, 0x00, 0x00, 0x00,\
9962 /* 56 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x09,\
9963 /* 64 */ 0x09, 0x09, 0x04, 0x09, 0x09, 0x09, 0x09, 0x26,\
9964 /* 72 */ 0x26, 0x10, 0x10, 0x00, 0x03, 0x03, 0x0b, 0x0b,\
9965 /* 80 */ 0x0b, 0x0b, 0x0b, 0x0b, 0x00, 0x26, 0x26, 0x26,\
9966 /* 88 */ 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x26, 0x00,\
9967 /* 96 */ 0x12, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10,\
9968 /* 104 */ 0x00, 0x01, 0x01, 0x01, 0x01, 0x04, 0x04, 0x00,\
9969 /* 112 */ 0x10, 0x01, 0x01, 0x01, 0x01, 0x10, 0x00, 0x00,\
9970 /* 120 */ 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\
9971 /* 128 */ 0x06, 0x23, 0x0b, 0x01, 0x10, 0x10, 0x00, 0x01,\
9972 /* 136 */ 0x04, 0x03, 0x03, 0x03, 0x03, 0x03, 0x00, 0x01,\
9973 /* 144 */ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01,\
9974 /* 152 */ 0x00, 0x10, 0x10, 0x01, 0x00, 0x00,}
9975
9976 /************** End of opcodes.h *********************************************/
9977 /************** Continuing where we left off in vdbe.h ***********************/
9978
9979 /*
@@ -9932,10 +10028,11 @@
10028 #endif
10029 SQLITE_PRIVATE int sqlite3MemCompare(const Mem*, const Mem*, const CollSeq*);
10030
10031 SQLITE_PRIVATE void sqlite3VdbeRecordUnpack(KeyInfo*,int,const void*,UnpackedRecord*);
10032 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(int,const void*,UnpackedRecord*);
10033 SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(int, const void *, UnpackedRecord *, int);
10034 SQLITE_PRIVATE UnpackedRecord *sqlite3VdbeAllocUnpackedRecord(KeyInfo *, char *, int, char **);
10035
10036 typedef int (*RecordCompare)(int,const void*,UnpackedRecord*);
10037 SQLITE_PRIVATE RecordCompare sqlite3VdbeFindCompare(UnpackedRecord*);
10038
@@ -11069,10 +11166,11 @@
11166 #define SQLITE_LoadExtension 0x00400000 /* Enable load_extension */
11167 #define SQLITE_EnableTrigger 0x00800000 /* True to enable triggers */
11168 #define SQLITE_DeferFKs 0x01000000 /* Defer all FK constraints */
11169 #define SQLITE_QueryOnly 0x02000000 /* Disable database changes */
11170 #define SQLITE_VdbeEQP 0x04000000 /* Debug EXPLAIN QUERY PLAN */
11171 #define SQLITE_Vacuum 0x08000000 /* Currently in a VACUUM */
11172
11173
11174 /*
11175 ** Bits of the sqlite3.dbOptFlags field that are used by the
11176 ** sqlite3_test_control(SQLITE_TESTCTRL_OPTIMIZATIONS,...) interface to
@@ -11399,38 +11497,12 @@
11497 int iSavepoint; /* Depth of the SAVEPOINT stack */
11498 VTable *pNext; /* Next in linked list (see above) */
11499 };
11500
11501 /*
11502 ** The schema for each SQL table and view is represented in memory
11503 ** by an instance of the following structure.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11504 */
11505 struct Table {
11506 char *zName; /* Name of the table or view */
11507 Column *aCol; /* Information about each column */
11508 Index *pIndex; /* List of SQL indexes on this table. */
@@ -11438,15 +11510,15 @@
11510 FKey *pFKey; /* Linked list of all foreign keys in this table */
11511 char *zColAff; /* String defining the affinity of each column */
11512 #ifndef SQLITE_OMIT_CHECK
11513 ExprList *pCheck; /* All CHECK constraints */
11514 #endif
11515 int tnum; /* Root BTree page for this table */
11516 i16 iPKey; /* If not negative, use aCol[iPKey] as the rowid */
 
11517 i16 nCol; /* Number of columns in this table */
11518 u16 nRef; /* Number of pointers to this Table */
11519 LogEst nRowLogEst; /* Estimated rows in table - from sqlite_stat1 table */
11520 LogEst szTabRow; /* Estimated size of each table row in bytes */
11521 #ifdef SQLITE_ENABLE_COSTMULT
11522 LogEst costMult; /* Cost multiplier for using this table */
11523 #endif
11524 u8 tabFlags; /* Mask of TF_* values */
@@ -11464,17 +11536,24 @@
11536 Table *pNextZombie; /* Next on the Parse.pZombieTab list */
11537 };
11538
11539 /*
11540 ** Allowed values for Table.tabFlags.
11541 **
11542 ** TF_OOOHidden applies to virtual tables that have hidden columns that are
11543 ** followed by non-hidden columns. Example: "CREATE VIRTUAL TABLE x USING
11544 ** vtab1(a HIDDEN, b);". Since "b" is a non-hidden column but "a" is hidden,
11545 ** the TF_OOOHidden attribute would apply in this case. Such tables require
11546 ** special handling during INSERT processing.
11547 */
11548 #define TF_Readonly 0x01 /* Read-only system table */
11549 #define TF_Ephemeral 0x02 /* An ephemeral table */
11550 #define TF_HasPrimaryKey 0x04 /* Table has a primary key */
11551 #define TF_Autoincrement 0x08 /* Integer primary key is autoincrement */
11552 #define TF_Virtual 0x10 /* Is a virtual table */
11553 #define TF_WithoutRowid 0x20 /* No rowid used. PRIMARY KEY is the key */
11554 #define TF_OOOHidden 0x40 /* Out-of-Order hidden columns */
11555
11556
11557 /*
11558 ** Test to see whether or not a table is a virtual table. This is
11559 ** done as a macro so that it will be optimized out when virtual
@@ -12227,15 +12306,16 @@
12306 #define SF_UsesEphemeral 0x0008 /* Uses the OpenEphemeral opcode */
12307 #define SF_Expanded 0x0010 /* sqlite3SelectExpand() called on this */
12308 #define SF_HasTypeInfo 0x0020 /* FROM subqueries have Table metadata */
12309 #define SF_Compound 0x0040 /* Part of a compound query */
12310 #define SF_Values 0x0080 /* Synthesized from VALUES clause */
12311 #define SF_MultiValue 0x0100 /* Single VALUES term with multiple rows */
12312 #define SF_NestedFrom 0x0200 /* Part of a parenthesized FROM clause */
12313 #define SF_MaybeConvert 0x0400 /* Need convertCompoundSelectToSubquery() */
12314 #define SF_Recursive 0x0800 /* The recursive part of a recursive CTE */
12315 #define SF_MinMaxAgg 0x1000 /* Aggregate containing min() or max() */
12316 #define SF_Converted 0x2000 /* By convertCompoundSelectToSubquery() */
12317
12318
12319 /*
12320 ** The results of a SELECT can be distributed in several ways, as defined
12321 ** by one of the following macros. The "SRT" prefix means "SELECT Result
@@ -12610,24 +12690,24 @@
12690 *
12691 * (op == TK_INSERT)
12692 * orconf -> stores the ON CONFLICT algorithm
12693 * pSelect -> If this is an INSERT INTO ... SELECT ... statement, then
12694 * this stores a pointer to the SELECT statement. Otherwise NULL.
12695 * zTarget -> Dequoted name of the table to insert into.
12696 * pExprList -> If this is an INSERT INTO ... VALUES ... statement, then
12697 * this stores values to be inserted. Otherwise NULL.
12698 * pIdList -> If this is an INSERT INTO ... (<column-names>) VALUES ...
12699 * statement, then this stores the column-names to be
12700 * inserted into.
12701 *
12702 * (op == TK_DELETE)
12703 * zTarget -> Dequoted name of the table to delete from.
12704 * pWhere -> The WHERE clause of the DELETE statement if one is specified.
12705 * Otherwise NULL.
12706 *
12707 * (op == TK_UPDATE)
12708 * zTarget -> Dequoted name of the table to update.
12709 * pWhere -> The WHERE clause of the UPDATE statement if one is specified.
12710 * Otherwise NULL.
12711 * pExprList -> A list of the columns to update and the expressions to update
12712 * them to. See sqlite3Update() documentation of "pChanges"
12713 * argument.
@@ -12635,12 +12715,12 @@
12715 */
12716 struct TriggerStep {
12717 u8 op; /* One of TK_DELETE, TK_UPDATE, TK_INSERT, TK_SELECT */
12718 u8 orconf; /* OE_Rollback etc. */
12719 Trigger *pTrig; /* The trigger that this step is a part of */
12720 Select *pSelect; /* SELECT statement or RHS of INSERT INTO SELECT ... */
12721 char *zTarget; /* Target table for DELETE, UPDATE, INSERT */
12722 Expr *pWhere; /* The WHERE clause for DELETE or UPDATE steps */
12723 ExprList *pExprList; /* SET clause for UPDATE. */
12724 IdList *pIdList; /* Column names for INSERT */
12725 TriggerStep *pNext; /* Next in the link-list */
12726 TriggerStep *pLast; /* Last element in link-list. Valid for 1st elem only */
@@ -12669,12 +12749,11 @@
12749 sqlite3 *db; /* Optional database for lookaside. Can be NULL */
12750 char *zBase; /* A base allocation. Not from malloc. */
12751 char *zText; /* The string collected so far */
12752 int nChar; /* Length of the string so far */
12753 int nAlloc; /* Amount of space allocated in zText */
12754 int mxAlloc; /* Maximum allowed allocation. 0 for no malloc usage */
 
12755 u8 accError; /* STRACCUM_NOMEM or STRACCUM_TOOBIG */
12756 };
12757 #define STRACCUM_NOMEM 1
12758 #define STRACCUM_TOOBIG 2
12759
@@ -12987,11 +13066,11 @@
13066 SQLITE_PRIVATE void sqlite3VXPrintf(StrAccum*, u32, const char*, va_list);
13067 SQLITE_PRIVATE void sqlite3XPrintf(StrAccum*, u32, const char*, ...);
13068 SQLITE_PRIVATE char *sqlite3MPrintf(sqlite3*,const char*, ...);
13069 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3*,const char*, va_list);
13070 SQLITE_PRIVATE char *sqlite3MAppendf(sqlite3*,char*,const char*,...);
13071 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
13072 SQLITE_PRIVATE void sqlite3DebugPrintf(const char*, ...);
13073 #endif
13074 #if defined(SQLITE_TEST)
13075 SQLITE_PRIVATE void *sqlite3TestTextToPtr(const char*);
13076 #endif
@@ -13334,11 +13413,11 @@
13413 SQLITE_PRIVATE void sqlite3Error(sqlite3*,int);
13414 SQLITE_PRIVATE void *sqlite3HexToBlob(sqlite3*, const char *z, int n);
13415 SQLITE_PRIVATE u8 sqlite3HexToInt(int h);
13416 SQLITE_PRIVATE int sqlite3TwoPartName(Parse *, Token *, Token *, Token **);
13417
13418 #if defined(SQLITE_NEED_ERR_NAME)
13419 SQLITE_PRIVATE const char *sqlite3ErrName(int);
13420 #endif
13421
13422 SQLITE_PRIVATE const char *sqlite3ErrStr(int);
13423 SQLITE_PRIVATE int sqlite3ReadSchema(Parse *pParse);
@@ -13428,11 +13507,11 @@
13507 FuncDestructor *pDestructor
13508 );
13509 SQLITE_PRIVATE int sqlite3ApiExit(sqlite3 *db, int);
13510 SQLITE_PRIVATE int sqlite3OpenTempDatabase(Parse *);
13511
13512 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum*, sqlite3*, char*, int, int);
13513 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum*,const char*,int);
13514 SQLITE_PRIVATE void sqlite3StrAccumAppendAll(StrAccum*,const char*);
13515 SQLITE_PRIVATE void sqlite3AppendChar(StrAccum*,int,char);
13516 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum*);
13517 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum*);
@@ -13646,11 +13725,11 @@
13725 ** print I/O tracing messages.
13726 */
13727 #ifdef SQLITE_ENABLE_IOTRACE
13728 # define IOTRACE(A) if( sqlite3IoTrace ){ sqlite3IoTrace A; }
13729 SQLITE_PRIVATE void sqlite3VdbeIOTraceSql(Vdbe*);
13730 SQLITE_API SQLITE_EXTERN void (SQLITE_CDECL *sqlite3IoTrace)(const char*,...);
13731 #else
13732 # define IOTRACE(A)
13733 # define sqlite3VdbeIOTraceSql(X)
13734 #endif
13735
@@ -14044,10 +14123,13 @@
14123 #if SQLITE_ENABLE_CEROD
14124 "ENABLE_CEROD",
14125 #endif
14126 #if SQLITE_ENABLE_COLUMN_METADATA
14127 "ENABLE_COLUMN_METADATA",
14128 #endif
14129 #if SQLITE_ENABLE_DBSTAT_VTAB
14130 "ENABLE_DBSTAT_VTAB",
14131 #endif
14132 #if SQLITE_ENABLE_EXPENSIVE_ASSERT
14133 "ENABLE_EXPENSIVE_ASSERT",
14134 #endif
14135 #if SQLITE_ENABLE_FTS1
@@ -14359,11 +14441,11 @@
14441 ** was used and false if not.
14442 **
14443 ** The name can optionally begin with "SQLITE_" but the "SQLITE_" prefix
14444 ** is not required for a match.
14445 */
14446 SQLITE_API int SQLITE_STDCALL sqlite3_compileoption_used(const char *zOptName){
14447 int i, n;
14448
14449 #if SQLITE_ENABLE_API_ARMOR
14450 if( zOptName==0 ){
14451 (void)SQLITE_MISUSE_BKPT;
@@ -14387,11 +14469,11 @@
14469
14470 /*
14471 ** Return the N-th compile-time option string. If N is out of range,
14472 ** return a NULL pointer.
14473 */
14474 SQLITE_API const char *SQLITE_STDCALL sqlite3_compileoption_get(int N){
14475 if( N>=0 && N<ArraySize(azCompileOpt) ){
14476 return azCompileOpt[N];
14477 }
14478 return 0;
14479 }
@@ -15024,11 +15106,11 @@
15106 }
15107
15108 /*
15109 ** Query status information.
15110 */
15111 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
15112 int op,
15113 sqlite3_int64 *pCurrent,
15114 sqlite3_int64 *pHighwater,
15115 int resetFlag
15116 ){
@@ -15049,11 +15131,11 @@
15131 }
15132 sqlite3_mutex_leave(pMutex);
15133 (void)pMutex; /* Prevent warning when SQLITE_THREADSAFE=0 */
15134 return SQLITE_OK;
15135 }
15136 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag){
15137 sqlite3_int64 iCur, iHwtr;
15138 int rc;
15139 #ifdef SQLITE_ENABLE_API_ARMOR
15140 if( pCurrent==0 || pHighwater==0 ) return SQLITE_MISUSE_BKPT;
15141 #endif
@@ -15066,11 +15148,11 @@
15148 }
15149
15150 /*
15151 ** Query status information for a single database connection
15152 */
15153 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(
15154 sqlite3 *db, /* The database connection whose status is desired */
15155 int op, /* Status verb */
15156 int *pCurrent, /* Write current value here */
15157 int *pHighwater, /* Write high-water mark here */
15158 int resetFlag /* Reset high-water mark if true */
@@ -16690,11 +16772,11 @@
16772
16773 /*
16774 ** Locate a VFS by name. If no name is given, simply return the
16775 ** first VFS on the list.
16776 */
16777 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfs){
16778 sqlite3_vfs *pVfs = 0;
16779 #if SQLITE_THREADSAFE
16780 sqlite3_mutex *mutex;
16781 #endif
16782 #ifndef SQLITE_OMIT_AUTOINIT
@@ -16736,11 +16818,11 @@
16818 /*
16819 ** Register a VFS with the system. It is harmless to register the same
16820 ** VFS multiple times. The new VFS becomes the default if makeDflt is
16821 ** true.
16822 */
16823 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs *pVfs, int makeDflt){
16824 MUTEX_LOGIC(sqlite3_mutex *mutex;)
16825 #ifndef SQLITE_OMIT_AUTOINIT
16826 int rc = sqlite3_initialize();
16827 if( rc ) return rc;
16828 #endif
@@ -16764,11 +16846,11 @@
16846 }
16847
16848 /*
16849 ** Unregister a VFS so that it is no longer accessible.
16850 */
16851 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs *pVfs){
16852 #if SQLITE_THREADSAFE
16853 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
16854 #endif
16855 sqlite3_mutex_enter(mutex);
16856 vfsUnlink(pVfs);
@@ -19100,11 +19182,11 @@
19182 }
19183
19184 /*
19185 ** Retrieve a pointer to a static mutex or allocate a new dynamic one.
19186 */
19187 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int id){
19188 #ifndef SQLITE_OMIT_AUTOINIT
19189 if( id<=SQLITE_MUTEX_RECURSIVE && sqlite3_initialize() ) return 0;
19190 if( id>SQLITE_MUTEX_RECURSIVE && sqlite3MutexInit() ) return 0;
19191 #endif
19192 return sqlite3GlobalConfig.mutex.xMutexAlloc(id);
@@ -19119,31 +19201,31 @@
19201 }
19202
19203 /*
19204 ** Free a dynamic mutex.
19205 */
19206 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex *p){
19207 if( p ){
19208 sqlite3GlobalConfig.mutex.xMutexFree(p);
19209 }
19210 }
19211
19212 /*
19213 ** Obtain the mutex p. If some other thread already has the mutex, block
19214 ** until it can be obtained.
19215 */
19216 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex *p){
19217 if( p ){
19218 sqlite3GlobalConfig.mutex.xMutexEnter(p);
19219 }
19220 }
19221
19222 /*
19223 ** Obtain the mutex p. If successful, return SQLITE_OK. Otherwise, if another
19224 ** thread holds the mutex and it cannot be obtained, return SQLITE_BUSY.
19225 */
19226 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex *p){
19227 int rc = SQLITE_OK;
19228 if( p ){
19229 return sqlite3GlobalConfig.mutex.xMutexTry(p);
19230 }
19231 return rc;
@@ -19153,11 +19235,11 @@
19235 ** The sqlite3_mutex_leave() routine exits a mutex that was previously
19236 ** entered by the same thread. The behavior is undefined if the mutex
19237 ** is not currently entered. If a NULL pointer is passed as an argument
19238 ** this function is a no-op.
19239 */
19240 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex *p){
19241 if( p ){
19242 sqlite3GlobalConfig.mutex.xMutexLeave(p);
19243 }
19244 }
19245
@@ -19164,14 +19246,14 @@
19246 #ifndef NDEBUG
19247 /*
19248 ** The sqlite3_mutex_held() and sqlite3_mutex_notheld() routine are
19249 ** intended for use inside assert() statements.
19250 */
19251 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex *p){
19252 return p==0 || sqlite3GlobalConfig.mutex.xMutexHeld(p);
19253 }
19254 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex *p){
19255 return p==0 || sqlite3GlobalConfig.mutex.xMutexNotheld(p);
19256 }
19257 #endif
19258
19259 #endif /* !defined(SQLITE_MUTEX_OMIT) */
@@ -19812,20 +19894,10 @@
19894 */
19895 #ifdef MEMORY_DEBUG
19896 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
19897 #endif
19898
 
 
 
 
 
 
 
 
 
 
19899 /*
19900 ** Macros for performance tracing. Normally turned off. Only works
19901 ** on i486 hardware.
19902 */
19903 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -20163,12 +20235,12 @@
20235 ** of the sqlite3_initialize() and sqlite3_shutdown() processing, the
20236 ** "interlocked" magic used here is probably not strictly necessary.
20237 */
20238 static LONG SQLITE_WIN32_VOLATILE winMutex_lock = 0;
20239
20240 SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void); /* os_win.c */
20241 SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds); /* os_win.c */
20242
20243 static int winMutexInit(void){
20244 /* The first to increment to 1 does actual initialization */
20245 if( InterlockedCompareExchange(&winMutex_lock, 1, 0)==0 ){
20246 int i;
@@ -20460,11 +20532,11 @@
20532 /*
20533 ** Attempt to release up to n bytes of non-essential memory currently
20534 ** held by SQLite. An example of non-essential memory is memory used to
20535 ** cache database pages that are not currently in use.
20536 */
20537 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int n){
20538 #ifdef SQLITE_ENABLE_MEMORY_MANAGEMENT
20539 return sqlite3PcacheReleaseMemory(n);
20540 #else
20541 /* IMPLEMENTATION-OF: R-34391-24921 The sqlite3_release_memory() routine
20542 ** is a no-op returning zero if SQLite is not compiled with
@@ -20560,11 +20632,11 @@
20632 #ifndef SQLITE_OMIT_DEPRECATED
20633 /*
20634 ** Deprecated external interface. Internal/core SQLite code
20635 ** should call sqlite3MemoryAlarm.
20636 */
20637 SQLITE_API int SQLITE_STDCALL sqlite3_memory_alarm(
20638 void(*xCallback)(void *pArg, sqlite3_int64 used,int N),
20639 void *pArg,
20640 sqlite3_int64 iThreshold
20641 ){
20642 return sqlite3MemoryAlarm(xCallback, pArg, iThreshold);
@@ -20573,11 +20645,11 @@
20645
20646 /*
20647 ** Set the soft heap-size limit for the library. Passing a zero or
20648 ** negative value indicates no limit.
20649 */
20650 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 n){
20651 sqlite3_int64 priorLimit;
20652 sqlite3_int64 excess;
20653 #ifndef SQLITE_OMIT_AUTOINIT
20654 int rc = sqlite3_initialize();
20655 if( rc ) return -1;
@@ -20593,19 +20665,20 @@
20665 }
20666 excess = sqlite3_memory_used() - n;
20667 if( excess>0 ) sqlite3_release_memory((int)(excess & 0x7fffffff));
20668 return priorLimit;
20669 }
20670 SQLITE_API void SQLITE_STDCALL sqlite3_soft_heap_limit(int n){
20671 if( n<0 ) n = 0;
20672 sqlite3_soft_heap_limit64(n);
20673 }
20674
20675 /*
20676 ** Initialize the memory allocation subsystem.
20677 */
20678 SQLITE_PRIVATE int sqlite3MallocInit(void){
20679 int rc;
20680 if( sqlite3GlobalConfig.m.xMalloc==0 ){
20681 sqlite3MemSetDefault();
20682 }
20683 memset(&mem0, 0, sizeof(mem0));
20684 if( sqlite3GlobalConfig.bCoreMutex ){
@@ -20637,11 +20710,13 @@
20710 || sqlite3GlobalConfig.nPage<1 ){
20711 sqlite3GlobalConfig.pPage = 0;
20712 sqlite3GlobalConfig.szPage = 0;
20713 sqlite3GlobalConfig.nPage = 0;
20714 }
20715 rc = sqlite3GlobalConfig.m.xInit(sqlite3GlobalConfig.m.pAppData);
20716 if( rc!=SQLITE_OK ) memset(&mem0, 0, sizeof(mem0));
20717 return rc;
20718 }
20719
20720 /*
20721 ** Return true if the heap is currently under memory pressure - in other
20722 ** words if the amount of heap used is close to the limit set by
@@ -20662,11 +20737,11 @@
20737 }
20738
20739 /*
20740 ** Return the amount of memory currently checked out.
20741 */
20742 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void){
20743 int n, mx;
20744 sqlite3_int64 res;
20745 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, 0);
20746 res = (sqlite3_int64)n; /* Work around bug in Borland C. Ticket #3216 */
20747 return res;
@@ -20675,11 +20750,11 @@
20750 /*
20751 ** Return the maximum amount of memory that has ever been
20752 ** checked out since either the beginning of this process
20753 ** or since the most recent reset.
20754 */
20755 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag){
20756 int n, mx;
20757 sqlite3_int64 res;
20758 sqlite3_status(SQLITE_STATUS_MEMORY_USED, &n, &mx, resetFlag);
20759 res = (sqlite3_int64)mx; /* Work around bug in Borland C. Ticket #3216 */
20760 return res;
@@ -20766,17 +20841,17 @@
20841 /*
20842 ** This version of the memory allocation is for use by the application.
20843 ** First make sure the memory subsystem is initialized, then do the
20844 ** allocation.
20845 */
20846 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int n){
20847 #ifndef SQLITE_OMIT_AUTOINIT
20848 if( sqlite3_initialize() ) return 0;
20849 #endif
20850 return n<=0 ? 0 : sqlite3Malloc(n);
20851 }
20852 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64 n){
20853 #ifndef SQLITE_OMIT_AUTOINIT
20854 if( sqlite3_initialize() ) return 0;
20855 #endif
20856 return sqlite3Malloc(n);
20857 }
@@ -20913,20 +20988,20 @@
20988 assert( sqlite3MemdebugNoType(p, (u8)~(MEMTYPE_LOOKASIDE|MEMTYPE_HEAP)) );
20989 return sqlite3GlobalConfig.m.xSize(p);
20990 }
20991 }
20992 }
20993 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void *p){
20994 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
20995 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
20996 return (sqlite3_uint64)sqlite3GlobalConfig.m.xSize(p);
20997 }
20998
20999 /*
21000 ** Free memory previously obtained from sqlite3Malloc().
21001 */
21002 SQLITE_API void SQLITE_STDCALL sqlite3_free(void *p){
21003 if( p==0 ) return; /* IMP: R-49053-54554 */
21004 assert( sqlite3MemdebugHasType(p, MEMTYPE_HEAP) );
21005 assert( sqlite3MemdebugNoType(p, (u8)~MEMTYPE_HEAP) );
21006 if( sqlite3GlobalConfig.bMemstat ){
21007 sqlite3_mutex_enter(mem0.mutex);
@@ -21031,18 +21106,18 @@
21106
21107 /*
21108 ** The public interface to sqlite3Realloc. Make sure that the memory
21109 ** subsystem is initialized prior to invoking sqliteRealloc.
21110 */
21111 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void *pOld, int n){
21112 #ifndef SQLITE_OMIT_AUTOINIT
21113 if( sqlite3_initialize() ) return 0;
21114 #endif
21115 if( n<0 ) n = 0; /* IMP: R-26507-47431 */
21116 return sqlite3Realloc(pOld, n);
21117 }
21118 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void *pOld, sqlite3_uint64 n){
21119 #ifndef SQLITE_OMIT_AUTOINIT
21120 if( sqlite3_initialize() ) return 0;
21121 #endif
21122 return sqlite3Realloc(pOld, n);
21123 }
@@ -21403,10 +21478,11 @@
21478
21479 /*
21480 ** Set the StrAccum object to an error mode.
21481 */
21482 static void setStrAccumError(StrAccum *p, u8 eError){
21483 assert( eError==STRACCUM_NOMEM || eError==STRACCUM_TOOBIG );
21484 p->accError = eError;
21485 p->nAlloc = 0;
21486 }
21487
21488 /*
@@ -21517,45 +21593,52 @@
21593 case '0': flag_zeropad = 1; break;
21594 default: done = 1; break;
21595 }
21596 }while( !done && (c=(*++fmt))!=0 );
21597 /* Get the field width */
 
21598 if( c=='*' ){
21599 if( bArgList ){
21600 width = (int)getIntArg(pArgList);
21601 }else{
21602 width = va_arg(ap,int);
21603 }
21604 if( width<0 ){
21605 flag_leftjustify = 1;
21606 width = width >= -2147483647 ? -width : 0;
21607 }
21608 c = *++fmt;
21609 }else{
21610 unsigned wx = 0;
21611 while( c>='0' && c<='9' ){
21612 wx = wx*10 + c - '0';
21613 c = *++fmt;
21614 }
21615 testcase( wx>0x7fffffff );
21616 width = wx & 0x7fffffff;
21617 }
21618
21619 /* Get the precision */
21620 if( c=='.' ){
 
21621 c = *++fmt;
21622 if( c=='*' ){
21623 if( bArgList ){
21624 precision = (int)getIntArg(pArgList);
21625 }else{
21626 precision = va_arg(ap,int);
21627 }
 
21628 c = *++fmt;
21629 if( precision<0 ){
21630 precision = precision >= -2147483647 ? -precision : -1;
21631 }
21632 }else{
21633 unsigned px = 0;
21634 while( c>='0' && c<='9' ){
21635 px = px*10 + c - '0';
21636 c = *++fmt;
21637 }
21638 testcase( px>0x7fffffff );
21639 precision = px & 0x7fffffff;
21640 }
21641 }else{
21642 precision = -1;
21643 }
21644 /* Get the conversion type modifier */
@@ -21715,11 +21798,12 @@
21798 if( flag_plussign ) prefix = '+';
21799 else if( flag_blanksign ) prefix = ' ';
21800 else prefix = 0;
21801 }
21802 if( xtype==etGENERIC && precision>0 ) precision--;
21803 testcase( precision>0xfff );
21804 for(idx=precision&0xfff, rounder=0.5; idx>0; idx--, rounder*=0.1){}
21805 if( xtype==etFLOAT ) realvalue += rounder;
21806 /* Normalize realvalue to within 10.0 > realvalue >= 1.0 */
21807 exp = 0;
21808 if( sqlite3IsNaN((double)realvalue) ){
21809 bufpt = "NaN";
@@ -21770,12 +21854,13 @@
21854 if( xtype==etEXP ){
21855 e2 = 0;
21856 }else{
21857 e2 = exp;
21858 }
21859 if( MAX(e2,0)+(i64)precision+(i64)width > etBUFSIZE - 15 ){
21860 bufpt = zExtra
21861 = sqlite3Malloc( MAX(e2,0)+(i64)precision+(i64)width+15 );
21862 if( bufpt==0 ){
21863 setStrAccumError(pAccum, STRACCUM_NOMEM);
21864 return;
21865 }
21866 }
@@ -22003,17 +22088,17 @@
22088 ** Return the number of bytes of text that StrAccum is able to accept
22089 ** after the attempted enlargement. The value returned might be zero.
22090 */
22091 static int sqlite3StrAccumEnlarge(StrAccum *p, int N){
22092 char *zNew;
22093 assert( p->nChar+(i64)N >= p->nAlloc ); /* Only called if really needed */
22094 if( p->accError ){
22095 testcase(p->accError==STRACCUM_TOOBIG);
22096 testcase(p->accError==STRACCUM_NOMEM);
22097 return 0;
22098 }
22099 if( p->mxAlloc==0 ){
22100 N = p->nAlloc - p->nChar - 1;
22101 setStrAccumError(p, STRACCUM_TOOBIG);
22102 return N;
22103 }else{
22104 char *zOld = (p->zText==p->zBase ? 0 : p->zText);
@@ -22029,14 +22114,14 @@
22114 setStrAccumError(p, STRACCUM_TOOBIG);
22115 return 0;
22116 }else{
22117 p->nAlloc = (int)szNew;
22118 }
22119 if( p->db ){
22120 zNew = sqlite3DbRealloc(p->db, zOld, p->nAlloc);
22121 }else{
22122 zNew = sqlite3_realloc64(zOld, p->nAlloc);
22123 }
22124 if( zNew ){
22125 assert( p->zText!=0 || p->nChar==0 );
22126 if( zOld==0 && p->nChar>0 ) memcpy(zNew, p->zText, p->nChar);
22127 p->zText = zNew;
@@ -22052,11 +22137,14 @@
22137
22138 /*
22139 ** Append N copies of character c to the given string buffer.
22140 */
22141 SQLITE_PRIVATE void sqlite3AppendChar(StrAccum *p, int N, char c){
22142 testcase( p->nChar + (i64)N > 0x7fffffff );
22143 if( p->nChar+(i64)N >= p->nAlloc && (N = sqlite3StrAccumEnlarge(p, N))<=0 ){
22144 return;
22145 }
22146 while( (N--)>0 ) p->zText[p->nChar++] = c;
22147 }
22148
22149 /*
22150 ** The StrAccum "p" is not large enough to accept N new bytes of z[].
@@ -22077,11 +22165,11 @@
22165 /*
22166 ** Append N bytes of text from z to the StrAccum object. Increase the
22167 ** size of the memory allocation for StrAccum if necessary.
22168 */
22169 SQLITE_PRIVATE void sqlite3StrAccumAppend(StrAccum *p, const char *z, int N){
22170 assert( z!=0 || N==0 );
22171 assert( p->zText!=0 || p->nChar==0 || p->accError );
22172 assert( N>=0 );
22173 assert( p->accError==0 || p->nAlloc==0 );
22174 if( p->nChar+N >= p->nAlloc ){
22175 enlargeAndAppend(p,z,N);
@@ -22106,16 +22194,12 @@
22194 ** pointer if any kind of error was encountered.
22195 */
22196 SQLITE_PRIVATE char *sqlite3StrAccumFinish(StrAccum *p){
22197 if( p->zText ){
22198 p->zText[p->nChar] = 0;
22199 if( p->mxAlloc>0 && p->zText==p->zBase ){
22200 p->zText = sqlite3DbMallocRaw(p->db, p->nChar+1 );
 
 
 
 
22201 if( p->zText ){
22202 memcpy(p->zText, p->zBase, p->nChar+1);
22203 }else{
22204 setStrAccumError(p, STRACCUM_NOMEM);
22205 }
@@ -22127,29 +22211,35 @@
22211 /*
22212 ** Reset an StrAccum string. Reclaim all malloced memory.
22213 */
22214 SQLITE_PRIVATE void sqlite3StrAccumReset(StrAccum *p){
22215 if( p->zText!=p->zBase ){
22216 sqlite3DbFree(p->db, p->zText);
 
 
 
 
22217 }
22218 p->zText = 0;
22219 }
22220
22221 /*
22222 ** Initialize a string accumulator.
22223 **
22224 ** p: The accumulator to be initialized.
22225 ** db: Pointer to a database connection. May be NULL. Lookaside
22226 ** memory is used if not NULL. db->mallocFailed is set appropriately
22227 ** when not NULL.
22228 ** zBase: An initial buffer. May be NULL in which case the initial buffer
22229 ** is malloced.
22230 ** n: Size of zBase in bytes. If total space requirements never exceed
22231 ** n then no memory allocations ever occur.
22232 ** mx: Maximum number of bytes to accumulate. If mx==0 then no memory
22233 ** allocations will ever occur.
22234 */
22235 SQLITE_PRIVATE void sqlite3StrAccumInit(StrAccum *p, sqlite3 *db, char *zBase, int n, int mx){
22236 p->zText = p->zBase = zBase;
22237 p->db = db;
22238 p->nChar = 0;
22239 p->nAlloc = n;
22240 p->mxAlloc = mx;
 
22241 p->accError = 0;
22242 }
22243
22244 /*
22245 ** Print into memory obtained from sqliteMalloc(). Use the internal
@@ -22158,13 +22248,12 @@
22248 SQLITE_PRIVATE char *sqlite3VMPrintf(sqlite3 *db, const char *zFormat, va_list ap){
22249 char *z;
22250 char zBase[SQLITE_PRINT_BUF_SIZE];
22251 StrAccum acc;
22252 assert( db!=0 );
22253 sqlite3StrAccumInit(&acc, db, zBase, sizeof(zBase),
22254 db->aLimit[SQLITE_LIMIT_LENGTH]);
 
22255 sqlite3VXPrintf(&acc, SQLITE_PRINTF_INTERNAL, zFormat, ap);
22256 z = sqlite3StrAccumFinish(&acc);
22257 if( acc.accError==STRACCUM_NOMEM ){
22258 db->mallocFailed = 1;
22259 }
@@ -22204,11 +22293,11 @@
22293
22294 /*
22295 ** Print into memory obtained from sqlite3_malloc(). Omit the internal
22296 ** %-conversion extensions.
22297 */
22298 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char *zFormat, va_list ap){
22299 char *z;
22300 char zBase[SQLITE_PRINT_BUF_SIZE];
22301 StrAccum acc;
22302
22303 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -22218,22 +22307,21 @@
22307 }
22308 #endif
22309 #ifndef SQLITE_OMIT_AUTOINIT
22310 if( sqlite3_initialize() ) return 0;
22311 #endif
22312 sqlite3StrAccumInit(&acc, 0, zBase, sizeof(zBase), SQLITE_MAX_LENGTH);
 
22313 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22314 z = sqlite3StrAccumFinish(&acc);
22315 return z;
22316 }
22317
22318 /*
22319 ** Print into memory obtained from sqlite3_malloc()(). Omit the internal
22320 ** %-conversion extensions.
22321 */
22322 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char *zFormat, ...){
22323 va_list ap;
22324 char *z;
22325 #ifndef SQLITE_OMIT_AUTOINIT
22326 if( sqlite3_initialize() ) return 0;
22327 #endif
@@ -22254,26 +22342,25 @@
22342 ** this without breaking compatibility, so we just have to live with the
22343 ** mistake.
22344 **
22345 ** sqlite3_vsnprintf() is the varargs version.
22346 */
22347 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int n, char *zBuf, const char *zFormat, va_list ap){
22348 StrAccum acc;
22349 if( n<=0 ) return zBuf;
22350 #ifdef SQLITE_ENABLE_API_ARMOR
22351 if( zBuf==0 || zFormat==0 ) {
22352 (void)SQLITE_MISUSE_BKPT;
22353 if( zBuf ) zBuf[0] = 0;
22354 return zBuf;
22355 }
22356 #endif
22357 sqlite3StrAccumInit(&acc, 0, zBuf, n, 0);
 
22358 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22359 return sqlite3StrAccumFinish(&acc);
22360 }
22361 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int n, char *zBuf, const char *zFormat, ...){
22362 char *z;
22363 va_list ap;
22364 va_start(ap,zFormat);
22365 z = sqlite3_vsnprintf(n, zBuf, zFormat, ap);
22366 va_end(ap);
@@ -22291,41 +22378,39 @@
22378 */
22379 static void renderLogMsg(int iErrCode, const char *zFormat, va_list ap){
22380 StrAccum acc; /* String accumulator */
22381 char zMsg[SQLITE_PRINT_BUF_SIZE*3]; /* Complete log message */
22382
22383 sqlite3StrAccumInit(&acc, 0, zMsg, sizeof(zMsg), 0);
 
22384 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22385 sqlite3GlobalConfig.xLog(sqlite3GlobalConfig.pLogArg, iErrCode,
22386 sqlite3StrAccumFinish(&acc));
22387 }
22388
22389 /*
22390 ** Format and write a message to the log if logging is enabled.
22391 */
22392 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...){
22393 va_list ap; /* Vararg list */
22394 if( sqlite3GlobalConfig.xLog ){
22395 va_start(ap, zFormat);
22396 renderLogMsg(iErrCode, zFormat, ap);
22397 va_end(ap);
22398 }
22399 }
22400
22401 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
22402 /*
22403 ** A version of printf() that understands %lld. Used for debugging.
22404 ** The printf() built into some versions of windows does not understand %lld
22405 ** and segfaults if you give it a long long int.
22406 */
22407 SQLITE_PRIVATE void sqlite3DebugPrintf(const char *zFormat, ...){
22408 va_list ap;
22409 StrAccum acc;
22410 char zBuf[500];
22411 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
 
22412 va_start(ap,zFormat);
22413 sqlite3VXPrintf(&acc, 0, zFormat, ap);
22414 va_end(ap);
22415 sqlite3StrAccumFinish(&acc);
22416 fprintf(stdout,"%s", zBuf);
@@ -22348,11 +22433,11 @@
22433 */
22434 /* Add a new subitem to the tree. The moreToFollow flag indicates that this
22435 ** is not the last item in the tree. */
22436 SQLITE_PRIVATE TreeView *sqlite3TreeViewPush(TreeView *p, u8 moreToFollow){
22437 if( p==0 ){
22438 p = sqlite3_malloc64( sizeof(*p) );
22439 if( p==0 ) return 0;
22440 memset(p, 0, sizeof(*p));
22441 }else{
22442 p->iLevel++;
22443 }
@@ -22371,12 +22456,11 @@
22456 SQLITE_PRIVATE void sqlite3TreeViewLine(TreeView *p, const char *zFormat, ...){
22457 va_list ap;
22458 int i;
22459 StrAccum acc;
22460 char zBuf[500];
22461 sqlite3StrAccumInit(&acc, 0, zBuf, sizeof(zBuf), 0);
 
22462 if( p ){
22463 for(i=0; i<p->iLevel && i<sizeof(p->bLine)-1; i++){
22464 sqlite3StrAccumAppend(&acc, p->bLine[i] ? "| " : " ", 4);
22465 }
22466 sqlite3StrAccumAppend(&acc, p->bLine[i] ? "|-- " : "'-- ", 4);
@@ -22437,11 +22521,11 @@
22521 } sqlite3Prng;
22522
22523 /*
22524 ** Return N random bytes.
22525 */
22526 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *pBuf){
22527 unsigned char t;
22528 unsigned char *zBuf = pBuf;
22529
22530 /* The "wsdPrng" macro will resolve to the pseudo-random number generator
22531 ** state vector. If writable static data is unsupported on the target,
@@ -23589,11 +23673,11 @@
23673 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
23674 ** the contents of two buffers containing UTF-8 strings in a
23675 ** case-independent fashion, using the same definition of "case
23676 ** independence" that SQLite uses internally when comparing identifiers.
23677 */
23678 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *zLeft, const char *zRight){
23679 register unsigned char *a, *b;
23680 if( zLeft==0 ){
23681 return zRight ? -1 : 0;
23682 }else if( zRight==0 ){
23683 return 1;
@@ -23601,11 +23685,11 @@
23685 a = (unsigned char *)zLeft;
23686 b = (unsigned char *)zRight;
23687 while( *a!=0 && UpperToLower[*a]==UpperToLower[*b]){ a++; b++; }
23688 return UpperToLower[*a] - UpperToLower[*b];
23689 }
23690 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *zLeft, const char *zRight, int N){
23691 register unsigned char *a, *b;
23692 if( zLeft==0 ){
23693 return zRight ? -1 : 0;
23694 }else if( zRight==0 ){
23695 return 1;
@@ -23995,10 +24079,11 @@
24079 }else{
24080 return 0;
24081 }
24082 }
24083 #endif
24084 while( zNum[0]=='0' ) zNum++;
24085 for(i=0; i<11 && (c = zNum[i] - '0')>=0 && c<=9; i++){
24086 v = v*10 + c;
24087 }
24088
24089 /* The longest decimal representation of a 32 bit integer is 10 digits:
@@ -25249,10 +25334,21 @@
25334 #if SQLITE_ENABLE_LOCKING_STYLE
25335 # include <sys/ioctl.h>
25336 # include <sys/file.h>
25337 # include <sys/param.h>
25338 #endif /* SQLITE_ENABLE_LOCKING_STYLE */
25339
25340 #if defined(__APPLE__) && ((__MAC_OS_X_VERSION_MIN_REQUIRED > 1050) || \
25341 (__IPHONE_OS_VERSION_MIN_REQUIRED > 2000))
25342 # if (!defined(TARGET_OS_EMBEDDED) || (TARGET_OS_EMBEDDED==0)) \
25343 && (!defined(TARGET_IPHONE_SIMULATOR) || (TARGET_IPHONE_SIMULATOR==0))
25344 # define HAVE_GETHOSTUUID 1
25345 # else
25346 # warning "gethostuuid() is disabled."
25347 # endif
25348 #endif
25349
25350
25351 #if OS_VXWORKS
25352 /* # include <sys/ioctl.h> */
25353 # include <semaphore.h>
25354 # include <limits.h>
@@ -25445,20 +25541,10 @@
25541 */
25542 #ifdef MEMORY_DEBUG
25543 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
25544 #endif
25545
 
 
 
 
 
 
 
 
 
 
25546 /*
25547 ** Macros for performance tracing. Normally turned off. Only works
25548 ** on i486 hardware.
25549 */
25550 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -25997,11 +26083,11 @@
26083 return sqlite3_mutex_held(sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER));
26084 }
26085 #endif
26086
26087
26088 #ifdef SQLITE_HAVE_OS_TRACE
26089 /*
26090 ** Helper function for printing out trace information from debugging
26091 ** binaries. This returns the string representation of the supplied
26092 ** integer lock-type.
26093 */
@@ -26260,11 +26346,11 @@
26346 struct vxworksFileId *pCandidate; /* For looping over existing file IDs */
26347 int n; /* Length of zAbsoluteName string */
26348
26349 assert( zAbsoluteName[0]=='/' );
26350 n = (int)strlen(zAbsoluteName);
26351 pNew = sqlite3_malloc64( sizeof(*pNew) + (n+1) );
26352 if( pNew==0 ) return 0;
26353 pNew->zCanonicalName = (char*)&pNew[1];
26354 memcpy(pNew->zCanonicalName, zAbsoluteName, n+1);
26355 n = vxworksSimplifyName(pNew->zCanonicalName, n);
26356
@@ -26664,11 +26750,11 @@
26750 pInode = inodeList;
26751 while( pInode && memcmp(&fileId, &pInode->fileId, sizeof(fileId)) ){
26752 pInode = pInode->pNext;
26753 }
26754 if( pInode==0 ){
26755 pInode = sqlite3_malloc64( sizeof(*pInode) );
26756 if( pInode==0 ){
26757 return SQLITE_NOMEM;
26758 }
26759 memset(pInode, 0, sizeof(*pInode));
26760 memcpy(&pInode->fileId, &fileId, sizeof(fileId));
@@ -29150,11 +29236,11 @@
29236 */
29237 static int unixFileControl(sqlite3_file *id, int op, void *pArg){
29238 unixFile *pFile = (unixFile*)id;
29239 switch( op ){
29240 case SQLITE_FCNTL_WAL_BLOCK: {
29241 /* pFile->ctrlFlags |= UNIXFILE_BLOCK; // Deferred feature */
29242 return SQLITE_OK;
29243 }
29244 case SQLITE_FCNTL_LOCKSTATE: {
29245 *(int*)pArg = pFile->eFileLock;
29246 return SQLITE_OK;
@@ -29185,11 +29271,11 @@
29271 case SQLITE_FCNTL_VFSNAME: {
29272 *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
29273 return SQLITE_OK;
29274 }
29275 case SQLITE_FCNTL_TEMPFILENAME: {
29276 char *zTFile = sqlite3_malloc64( pFile->pVfs->mxPathname );
29277 if( zTFile ){
29278 unixGetTempname(pFile->pVfs->mxPathname, zTFile);
29279 *(char**)pArg = zTFile;
29280 }
29281 return SQLITE_OK;
@@ -29626,11 +29712,11 @@
29712 unixInodeInfo *pInode; /* The inode of fd */
29713 char *zShmFilename; /* Name of the file used for SHM */
29714 int nShmFilename; /* Size of the SHM filename in bytes */
29715
29716 /* Allocate space for the new unixShm object. */
29717 p = sqlite3_malloc64( sizeof(*p) );
29718 if( p==0 ) return SQLITE_NOMEM;
29719 memset(p, 0, sizeof(*p));
29720 assert( pDbFd->pShm==0 );
29721
29722 /* Check to see if a unixShmNode object already exists. Reuse an existing
@@ -29657,11 +29743,11 @@
29743 #ifdef SQLITE_SHM_DIRECTORY
29744 nShmFilename = sizeof(SQLITE_SHM_DIRECTORY) + 31;
29745 #else
29746 nShmFilename = 6 + (int)strlen(zBasePath);
29747 #endif
29748 pShmNode = sqlite3_malloc64( sizeof(*pShmNode) + nShmFilename );
29749 if( pShmNode==0 ){
29750 rc = SQLITE_NOMEM;
29751 goto shm_open_err;
29752 }
29753 memset(pShmNode, 0, sizeof(*pShmNode)+nShmFilename);
@@ -29867,11 +29953,11 @@
29953 if( pMem==MAP_FAILED ){
29954 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
29955 goto shmpage_out;
29956 }
29957 }else{
29958 pMem = sqlite3_malloc64(szRegion);
29959 if( pMem==0 ){
29960 rc = SQLITE_NOMEM;
29961 goto shmpage_out;
29962 }
29963 memset(pMem, 0, szRegion);
@@ -30704,11 +30790,11 @@
30790 else if( pLockingStyle == &afpIoMethods ){
30791 /* AFP locking uses the file path so it needs to be included in
30792 ** the afpLockingContext.
30793 */
30794 afpLockingContext *pCtx;
30795 pNew->lockingContext = pCtx = sqlite3_malloc64( sizeof(*pCtx) );
30796 if( pCtx==0 ){
30797 rc = SQLITE_NOMEM;
30798 }else{
30799 /* NB: zFilename exists and remains valid until the file is closed
30800 ** according to requirement F11141. So we do not need to make a
@@ -30734,11 +30820,11 @@
30820 */
30821 char *zLockFile;
30822 int nFilename;
30823 assert( zFilename!=0 );
30824 nFilename = (int)strlen(zFilename) + 6;
30825 zLockFile = (char *)sqlite3_malloc64(nFilename);
30826 if( zLockFile==0 ){
30827 rc = SQLITE_NOMEM;
30828 }else{
30829 sqlite3_snprintf(nFilename, zLockFile, "%s" DOTLOCK_SUFFIX, zFilename);
30830 }
@@ -31111,11 +31197,11 @@
31197 UnixUnusedFd *pUnused;
31198 pUnused = findReusableFd(zName, flags);
31199 if( pUnused ){
31200 fd = pUnused->fd;
31201 }else{
31202 pUnused = sqlite3_malloc64(sizeof(*pUnused));
31203 if( !pUnused ){
31204 return SQLITE_NOMEM;
31205 }
31206 }
31207 p->pUnused = pUnused;
@@ -31491,11 +31577,11 @@
31577 ** that we always use the same random number sequence. This makes the
31578 ** tests repeatable.
31579 */
31580 memset(zBuf, 0, nBuf);
31581 randomnessPid = osGetpid(0);
31582 #if !defined(SQLITE_TEST) && !defined(SQLITE_OMIT_RANDOMNESS)
31583 {
31584 int fd, got;
31585 fd = robust_open("/dev/urandom", O_RDONLY, 0);
31586 if( fd<0 ){
31587 time_t t;
@@ -31903,11 +31989,11 @@
31989 */
31990 pUnused = findReusableFd(path, openFlags);
31991 if( pUnused ){
31992 fd = pUnused->fd;
31993 }else{
31994 pUnused = sqlite3_malloc64(sizeof(*pUnused));
31995 if( !pUnused ){
31996 return SQLITE_NOMEM;
31997 }
31998 }
31999 if( fd<0 ){
@@ -31936,11 +32022,11 @@
32022 default:
32023 return SQLITE_CANTOPEN_BKPT;
32024 }
32025 }
32026
32027 pNew = (unixFile *)sqlite3_malloc64(sizeof(*pNew));
32028 if( pNew==NULL ){
32029 rc = SQLITE_NOMEM;
32030 goto end_create_proxy;
32031 }
32032 memset(pNew, 0, sizeof(unixFile));
@@ -31969,21 +32055,22 @@
32055 SQLITE_API int sqlite3_hostid_num = 0;
32056 #endif
32057
32058 #define PROXY_HOSTIDLEN 16 /* conch file host id length */
32059
32060 #ifdef HAVE_GETHOSTUUID
32061 /* Not always defined in the headers as it ought to be */
32062 extern int gethostuuid(uuid_t id, const struct timespec *wait);
32063 #endif
32064
32065 /* get the host ID via gethostuuid(), pHostID must point to PROXY_HOSTIDLEN
32066 ** bytes of writable memory.
32067 */
32068 static int proxyGetHostID(unsigned char *pHostID, int *pError){
32069 assert(PROXY_HOSTIDLEN == sizeof(uuid_t));
32070 memset(pHostID, 0, PROXY_HOSTIDLEN);
32071 #ifdef HAVE_GETHOSTUUID
 
32072 {
32073 struct timespec timeout = {1, 0}; /* 1 sec timeout */
32074 if( gethostuuid(pHostID, &timeout) ){
32075 int err = errno;
32076 if( pError ){
@@ -32397,11 +32484,11 @@
32484 return rc;
32485 }
32486
32487 /*
32488 ** Given the name of a database file, compute the name of its conch file.
32489 ** Store the conch filename in memory obtained from sqlite3_malloc64().
32490 ** Make *pConchPath point to the new name. Return SQLITE_OK on success
32491 ** or SQLITE_NOMEM if unable to obtain memory.
32492 **
32493 ** The caller is responsible for ensuring that the allocated memory
32494 ** space is eventually freed.
@@ -32413,11 +32500,11 @@
32500 int len = (int)strlen(dbPath); /* Length of database filename - dbPath */
32501 char *conchPath; /* buffer in which to construct conch name */
32502
32503 /* Allocate space for the conch filename and initialize the name to
32504 ** the name of the original database file. */
32505 *pConchPath = conchPath = (char *)sqlite3_malloc64(len + 8);
32506 if( conchPath==0 ){
32507 return SQLITE_NOMEM;
32508 }
32509 memcpy(conchPath, dbPath, len+1);
32510
@@ -32529,11 +32616,11 @@
32616 }
32617
32618 OSTRACE(("TRANSPROXY %d for %s pid=%d\n", pFile->h,
32619 (lockPath ? lockPath : ":auto:"), osGetpid(0)));
32620
32621 pCtx = sqlite3_malloc64( sizeof(*pCtx) );
32622 if( pCtx==0 ){
32623 return SQLITE_NOMEM;
32624 }
32625 memset(pCtx, 0, sizeof(*pCtx));
32626
@@ -32814,11 +32901,11 @@
32901 ** This routine is called once during SQLite initialization and by a
32902 ** single thread. The memory allocation and mutex subsystems have not
32903 ** necessarily been initialized when this routine is called, and so they
32904 ** should not be used.
32905 */
32906 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
32907 /*
32908 ** The following macro defines an initializer for an sqlite3_vfs object.
32909 ** The name of the VFS is NAME. The pAppData is a pointer to a pointer
32910 ** to the "finder" function. (pAppData is a pointer to a pointer because
32911 ** silly C90 rules prohibit a void* from being cast to a function pointer
@@ -32913,11 +33000,11 @@
33000 **
33001 ** Some operating systems might need to do some cleanup in this routine,
33002 ** to release dynamically allocated objects. But not on unix.
33003 ** This routine is a no-op for unix.
33004 */
33005 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
33006 return SQLITE_OK;
33007 }
33008
33009 #endif /* SQLITE_OS_UNIX */
33010
@@ -32973,20 +33060,10 @@
33060 */
33061 #ifdef MEMORY_DEBUG
33062 # error "The MEMORY_DEBUG macro is obsolete. Use SQLITE_DEBUG instead."
33063 #endif
33064
 
 
 
 
 
 
 
 
 
 
33065 /*
33066 ** Macros for performance tracing. Normally turned off. Only works
33067 ** on i486 hardware.
33068 */
33069 #ifdef SQLITE_PERFORMANCE_TRACE
@@ -33326,12 +33403,14 @@
33403
33404 WINBASEAPI LPVOID WINAPI MapViewOfFile(HANDLE, DWORD, DWORD, DWORD, SIZE_T);
33405 #endif /* SQLITE_OS_WINRT */
33406
33407 /*
33408 ** These file mapping APIs are common to both Win32 and WinRT.
33409 */
33410
33411 WINBASEAPI BOOL WINAPI FlushViewOfFile(LPCVOID, SIZE_T);
33412 WINBASEAPI BOOL WINAPI UnmapViewOfFile(LPCVOID);
33413 #endif /* SQLITE_WIN32_FILEMAPPING_API */
33414
33415 /*
33416 ** Some Microsoft compilers lack this definition.
@@ -34212,10 +34291,19 @@
34291 #endif
34292
34293 #define osUuidCreateSequential \
34294 ((RPC_STATUS(RPC_ENTRY*)(UUID*))aSyscall[78].pCurrent)
34295
34296 #if !defined(SQLITE_NO_SYNC) && SQLITE_MAX_MMAP_SIZE>0
34297 { "FlushViewOfFile", (SYSCALL)FlushViewOfFile, 0 },
34298 #else
34299 { "FlushViewOfFile", (SYSCALL)0, 0 },
34300 #endif
34301
34302 #define osFlushViewOfFile \
34303 ((BOOL(WINAPI*)(LPCVOID,SIZE_T))aSyscall[79].pCurrent)
34304
34305 }; /* End of the overrideable system calls */
34306
34307 /*
34308 ** This is the xSetSystemCall() method of sqlite3_vfs for all of the
34309 ** "win32" VFSes. Return SQLITE_OK opon successfully updating the
@@ -34305,11 +34393,11 @@
34393 ** compact it. Upon success, SQLITE_OK will be returned. Upon failure, one
34394 ** of SQLITE_NOMEM, SQLITE_ERROR, or SQLITE_NOTFOUND will be returned. The
34395 ** "pnLargest" argument, if non-zero, will be used to return the size of the
34396 ** largest committed free block in the heap, in bytes.
34397 */
34398 SQLITE_API int SQLITE_STDCALL sqlite3_win32_compact_heap(LPUINT pnLargest){
34399 int rc = SQLITE_OK;
34400 UINT nLargest = 0;
34401 HANDLE hHeap;
34402
34403 winMemAssertMagic();
@@ -34345,11 +34433,11 @@
34433 ** If a Win32 native heap has been configured, this function will attempt to
34434 ** destroy and recreate it. If the Win32 native heap is not isolated and/or
34435 ** the sqlite3_memory_used() function does not return zero, SQLITE_BUSY will
34436 ** be returned and no changes will be made to the Win32 native heap.
34437 */
34438 SQLITE_API int SQLITE_STDCALL sqlite3_win32_reset_heap(){
34439 int rc;
34440 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
34441 MUTEX_LOGIC( sqlite3_mutex *pMem; ) /* The memsys static mutex */
34442 MUTEX_LOGIC( pMaster = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MASTER); )
34443 MUTEX_LOGIC( pMem = sqlite3_mutex_alloc(SQLITE_MUTEX_STATIC_MEM); )
@@ -34390,11 +34478,11 @@
34478 /*
34479 ** This function outputs the specified (ANSI) string to the Win32 debugger
34480 ** (if available).
34481 */
34482
34483 SQLITE_API void SQLITE_STDCALL sqlite3_win32_write_debug(const char *zBuf, int nBuf){
34484 char zDbgBuf[SQLITE_WIN32_DBG_BUF_SIZE];
34485 int nMin = MIN(nBuf, (SQLITE_WIN32_DBG_BUF_SIZE - 1)); /* may be negative. */
34486 if( nMin<-1 ) nMin = -1; /* all negative values become -1. */
34487 assert( nMin==-1 || nMin==0 || nMin<SQLITE_WIN32_DBG_BUF_SIZE );
34488 #if defined(SQLITE_WIN32_HAS_ANSI)
@@ -34430,11 +34518,11 @@
34518 */
34519 #if SQLITE_OS_WINRT
34520 static HANDLE sleepObj = NULL;
34521 #endif
34522
34523 SQLITE_API void SQLITE_STDCALL sqlite3_win32_sleep(DWORD milliseconds){
34524 #if SQLITE_OS_WINRT
34525 if ( sleepObj==NULL ){
34526 sleepObj = osCreateEventExW(NULL, NULL, CREATE_EVENT_MANUAL_RESET,
34527 SYNCHRONIZE);
34528 }
@@ -34479,11 +34567,11 @@
34567
34568 /*
34569 ** This function determines if the machine is running a version of Windows
34570 ** based on the NT kernel.
34571 */
34572 SQLITE_API int SQLITE_STDCALL sqlite3_win32_is_nt(void){
34573 #if SQLITE_OS_WINRT
34574 /*
34575 ** NOTE: The WinRT sub-platform is always assumed to be based on the NT
34576 ** kernel.
34577 */
@@ -34833,11 +34921,11 @@
34921
34922 /*
34923 ** Convert multibyte character string to UTF-8. Space to hold the
34924 ** returned string is obtained from sqlite3_malloc().
34925 */
34926 SQLITE_API char *SQLITE_STDCALL sqlite3_win32_mbcs_to_utf8(const char *zFilename){
34927 char *zFilenameUtf8;
34928 LPWSTR zTmpWide;
34929
34930 zTmpWide = winMbcsToUnicode(zFilename);
34931 if( zTmpWide==0 ){
@@ -34850,11 +34938,11 @@
34938
34939 /*
34940 ** Convert UTF-8 to multibyte character string. Space to hold the
34941 ** returned string is obtained from sqlite3_malloc().
34942 */
34943 SQLITE_API char *SQLITE_STDCALL sqlite3_win32_utf8_to_mbcs(const char *zFilename){
34944 char *zFilenameMbcs;
34945 LPWSTR zTmpWide;
34946
34947 zTmpWide = winUtf8ToUnicode(zFilename);
34948 if( zTmpWide==0 ){
@@ -34870,11 +34958,11 @@
34958 ** the provided arguments. The type argument must be 1 in order to set the
34959 ** data directory or 2 in order to set the temporary directory. The zValue
34960 ** argument is the name of the directory to use. The return value will be
34961 ** SQLITE_OK if successful.
34962 */
34963 SQLITE_API int SQLITE_STDCALL sqlite3_win32_set_directory(DWORD type, LPCWSTR zValue){
34964 char **ppDirectory = 0;
34965 #ifndef SQLITE_OMIT_AUTOINIT
34966 int rc = sqlite3_initialize();
34967 if( rc ) return rc;
34968 #endif
@@ -35095,15 +35183,15 @@
35183 }
35184
35185 /*
35186 ** Log a I/O error retry episode.
35187 */
35188 static void winLogIoerr(int nRetry, int lineno){
35189 if( nRetry ){
35190 sqlite3_log(SQLITE_NOTICE,
35191 "delayed %dms for lock/sharing conflict at line %d",
35192 winIoerrRetryDelay*nRetry*(nRetry+1)/2, lineno
35193 );
35194 }
35195 }
35196
35197 #if SQLITE_OS_WINCE
@@ -35579,11 +35667,12 @@
35667 assert( id!=0 );
35668 #ifndef SQLITE_OMIT_WAL
35669 assert( pFile->pShm==0 );
35670 #endif
35671 assert( pFile->h!=NULL && pFile->h!=INVALID_HANDLE_VALUE );
35672 OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p\n",
35673 osGetCurrentProcessId(), pFile, pFile->h));
35674
35675 #if SQLITE_MAX_MMAP_SIZE>0
35676 winUnmapfile(pFile);
35677 #endif
35678
@@ -35608,11 +35697,12 @@
35697 #endif
35698 if( rc ){
35699 pFile->h = NULL;
35700 }
35701 OpenCounter(-1);
35702 OSTRACE(("CLOSE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35703 osGetCurrentProcessId(), pFile, pFile->h, rc ? "ok" : "failed"));
35704 return rc ? SQLITE_OK
35705 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
35706 "winClose", pFile->zPath);
35707 }
35708
@@ -35636,20 +35726,22 @@
35726
35727 assert( id!=0 );
35728 assert( amt>0 );
35729 assert( offset>=0 );
35730 SimulateIOError(return SQLITE_IOERR_READ);
35731 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35732 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
35733 pFile->h, pBuf, amt, offset, pFile->locktype));
35734
35735 #if SQLITE_MAX_MMAP_SIZE>0
35736 /* Deal with as much of this read request as possible by transfering
35737 ** data from the memory mapping using memcpy(). */
35738 if( offset<pFile->mmapSize ){
35739 if( offset+amt <= pFile->mmapSize ){
35740 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], amt);
35741 OSTRACE(("READ-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35742 osGetCurrentProcessId(), pFile, pFile->h));
35743 return SQLITE_OK;
35744 }else{
35745 int nCopy = (int)(pFile->mmapSize - offset);
35746 memcpy(pBuf, &((u8 *)(pFile->pMapRegion))[offset], nCopy);
35747 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35659,11 +35751,12 @@
35751 }
35752 #endif
35753
35754 #if SQLITE_OS_WINCE || defined(SQLITE_WIN32_NO_OVERLAPPED)
35755 if( winSeekFile(pFile, offset) ){
35756 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35757 osGetCurrentProcessId(), pFile, pFile->h));
35758 return SQLITE_FULL;
35759 }
35760 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
35761 #else
35762 memset(&overlapped, 0, sizeof(OVERLAPPED));
@@ -35673,23 +35766,26 @@
35766 osGetLastError()!=ERROR_HANDLE_EOF ){
35767 #endif
35768 DWORD lastErrno;
35769 if( winRetryIoerr(&nRetry, &lastErrno) ) continue;
35770 pFile->lastErrno = lastErrno;
35771 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_READ\n",
35772 osGetCurrentProcessId(), pFile, pFile->h));
35773 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
35774 "winRead", pFile->zPath);
35775 }
35776 winLogIoerr(nRetry, __LINE__);
35777 if( nRead<(DWORD)amt ){
35778 /* Unread parts of the buffer must be zero-filled */
35779 memset(&((char*)pBuf)[nRead], 0, amt-nRead);
35780 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_SHORT_READ\n",
35781 osGetCurrentProcessId(), pFile, pFile->h));
35782 return SQLITE_IOERR_SHORT_READ;
35783 }
35784
35785 OSTRACE(("READ pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35786 osGetCurrentProcessId(), pFile, pFile->h));
35787 return SQLITE_OK;
35788 }
35789
35790 /*
35791 ** Write data from a buffer into a file. Return SQLITE_OK on success
@@ -35708,20 +35804,22 @@
35804 assert( amt>0 );
35805 assert( pFile );
35806 SimulateIOError(return SQLITE_IOERR_WRITE);
35807 SimulateDiskfullError(return SQLITE_FULL);
35808
35809 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, buffer=%p, amount=%d, "
35810 "offset=%lld, lock=%d\n", osGetCurrentProcessId(), pFile,
35811 pFile->h, pBuf, amt, offset, pFile->locktype));
35812
35813 #if SQLITE_MAX_MMAP_SIZE>0
35814 /* Deal with as much of this write request as possible by transfering
35815 ** data from the memory mapping using memcpy(). */
35816 if( offset<pFile->mmapSize ){
35817 if( offset+amt <= pFile->mmapSize ){
35818 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, amt);
35819 OSTRACE(("WRITE-MMAP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35820 osGetCurrentProcessId(), pFile, pFile->h));
35821 return SQLITE_OK;
35822 }else{
35823 int nCopy = (int)(pFile->mmapSize - offset);
35824 memcpy(&((u8 *)(pFile->pMapRegion))[offset], pBuf, nCopy);
35825 pBuf = &((u8 *)pBuf)[nCopy];
@@ -35780,21 +35878,24 @@
35878 }
35879
35880 if( rc ){
35881 if( ( pFile->lastErrno==ERROR_HANDLE_DISK_FULL )
35882 || ( pFile->lastErrno==ERROR_DISK_FULL )){
35883 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_FULL\n",
35884 osGetCurrentProcessId(), pFile, pFile->h));
35885 return winLogError(SQLITE_FULL, pFile->lastErrno,
35886 "winWrite1", pFile->zPath);
35887 }
35888 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_WRITE\n",
35889 osGetCurrentProcessId(), pFile, pFile->h));
35890 return winLogError(SQLITE_IOERR_WRITE, pFile->lastErrno,
35891 "winWrite2", pFile->zPath);
35892 }else{
35893 winLogIoerr(nRetry, __LINE__);
35894 }
35895 OSTRACE(("WRITE pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
35896 osGetCurrentProcessId(), pFile, pFile->h));
35897 return SQLITE_OK;
35898 }
35899
35900 /*
35901 ** Truncate an open file to a specified size
@@ -35804,12 +35905,12 @@
35905 int rc = SQLITE_OK; /* Return code for this function */
35906 DWORD lastErrno;
35907
35908 assert( pFile );
35909 SimulateIOError(return SQLITE_IOERR_TRUNCATE);
35910 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, size=%lld, lock=%d\n",
35911 osGetCurrentProcessId(), pFile, pFile->h, nByte, pFile->locktype));
35912
35913 /* If the user has configured a chunk-size for this file, truncate the
35914 ** file so that it consists of an integer number of chunks (i.e. the
35915 ** actual file size after the operation may be larger than the requested
35916 ** size).
@@ -35837,11 +35938,12 @@
35938 if( pFile->pMapRegion && nByte<pFile->mmapSize ){
35939 pFile->mmapSize = nByte;
35940 }
35941 #endif
35942
35943 OSTRACE(("TRUNCATE pid=%lu, pFile=%p, file=%p, rc=%s\n",
35944 osGetCurrentProcessId(), pFile, pFile->h, sqlite3ErrName(rc)));
35945 return rc;
35946 }
35947
35948 #ifdef SQLITE_TEST
35949 /*
@@ -35861,11 +35963,11 @@
35963 ** Used only when SQLITE_NO_SYNC is not defined.
35964 */
35965 BOOL rc;
35966 #endif
35967 #if !defined(NDEBUG) || !defined(SQLITE_NO_SYNC) || \
35968 defined(SQLITE_HAVE_OS_TRACE)
35969 /*
35970 ** Used when SQLITE_NO_SYNC is not defined and by the assert() and/or
35971 ** OSTRACE() macros.
35972 */
35973 winFile *pFile = (winFile*)id;
@@ -35882,12 +35984,13 @@
35984 /* Unix cannot, but some systems may return SQLITE_FULL from here. This
35985 ** line is to test that doing so does not cause any problems.
35986 */
35987 SimulateDiskfullError( return SQLITE_FULL );
35988
35989 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, flags=%x, lock=%d\n",
35990 osGetCurrentProcessId(), pFile, pFile->h, flags,
35991 pFile->locktype));
35992
35993 #ifndef SQLITE_TEST
35994 UNUSED_PARAMETER(flags);
35995 #else
35996 if( (flags&0x0F)==SQLITE_SYNC_FULL ){
@@ -35898,23 +36001,42 @@
36001
36002 /* If we compiled with the SQLITE_NO_SYNC flag, then syncing is a
36003 ** no-op
36004 */
36005 #ifdef SQLITE_NO_SYNC
36006 OSTRACE(("SYNC-NOP pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
36007 osGetCurrentProcessId(), pFile, pFile->h));
36008 return SQLITE_OK;
36009 #else
36010 #if SQLITE_MAX_MMAP_SIZE>0
36011 if( pFile->pMapRegion ){
36012 if( osFlushViewOfFile(pFile->pMapRegion, 0) ){
36013 OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
36014 "rc=SQLITE_OK\n", osGetCurrentProcessId(),
36015 pFile, pFile->pMapRegion));
36016 }else{
36017 pFile->lastErrno = osGetLastError();
36018 OSTRACE(("SYNC-MMAP pid=%lu, pFile=%p, pMapRegion=%p, "
36019 "rc=SQLITE_IOERR_MMAP\n", osGetCurrentProcessId(),
36020 pFile, pFile->pMapRegion));
36021 return winLogError(SQLITE_IOERR_MMAP, pFile->lastErrno,
36022 "winSync1", pFile->zPath);
36023 }
36024 }
36025 #endif
36026 rc = osFlushFileBuffers(pFile->h);
36027 SimulateIOError( rc=FALSE );
36028 if( rc ){
36029 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_OK\n",
36030 osGetCurrentProcessId(), pFile, pFile->h));
36031 return SQLITE_OK;
36032 }else{
36033 pFile->lastErrno = osGetLastError();
36034 OSTRACE(("SYNC pid=%lu, pFile=%p, file=%p, rc=SQLITE_IOERR_FSYNC\n",
36035 osGetCurrentProcessId(), pFile, pFile->h));
36036 return winLogError(SQLITE_IOERR_FSYNC, pFile->lastErrno,
36037 "winSync2", pFile->zPath);
36038 }
36039 #endif
36040 }
36041
36042 /*
@@ -36518,11 +36640,11 @@
36640 DWORD lastErrno; /* The Windows errno from the last I/O error */
36641
36642 int nRef; /* Number of winShm objects pointing to this */
36643 winShm *pFirst; /* All winShm objects pointing to this */
36644 winShmNode *pNext; /* Next in list of all winShmNode objects */
36645 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
36646 u8 nextShmId; /* Next available winShm.id value */
36647 #endif
36648 };
36649
36650 /*
@@ -36549,11 +36671,11 @@
36671 winShmNode *pShmNode; /* The underlying winShmNode object */
36672 winShm *pNext; /* Next winShm with the same winShmNode */
36673 u8 hasMutex; /* True if holding the winShmNode mutex */
36674 u16 sharedMask; /* Mask of shared locks held */
36675 u16 exclMask; /* Mask of exclusive locks held */
36676 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
36677 u8 id; /* Id of this connection with its winShmNode */
36678 #endif
36679 };
36680
36681 /*
@@ -36740,11 +36862,11 @@
36862 if( rc ) goto shm_open_err;
36863 }
36864
36865 /* Make the new connection a child of the winShmNode */
36866 p->pShmNode = pShmNode;
36867 #if defined(SQLITE_DEBUG) || defined(SQLITE_HAVE_OS_TRACE)
36868 p->id = pShmNode->nextShmId++;
36869 #endif
36870 pShmNode->nRef++;
36871 pDbFd->pShm = p;
36872 winShmLeaveMutex();
@@ -37009,11 +37131,11 @@
37131 goto shmpage_out;
37132 }
37133 }
37134
37135 /* Map the requested memory region into this processes address space. */
37136 apNew = (struct ShmRegion *)sqlite3_realloc64(
37137 pShmNode->aRegion, (iRegion+1)*sizeof(apNew[0])
37138 );
37139 if( !apNew ){
37140 rc = SQLITE_IOERR_NOMEM;
37141 goto shmpage_out;
@@ -37881,11 +38003,11 @@
38003 winRetryIoerr(&cnt, &lastErrno) ){
38004 /* Noop */
38005 }
38006 }
38007 #endif
38008 winLogIoerr(cnt, __LINE__);
38009
38010 OSTRACE(("OPEN file=%p, name=%s, access=%lx, rc=%s\n", h, zUtf8Name,
38011 dwDesiredAccess, (h==INVALID_HANDLE_VALUE) ? "failed" : "ok"));
38012
38013 if( h==INVALID_HANDLE_VALUE ){
@@ -38065,11 +38187,11 @@
38187 }
38188 #endif
38189 if( rc && rc!=SQLITE_IOERR_DELETE_NOENT ){
38190 rc = winLogError(SQLITE_IOERR_DELETE, lastErrno, "winDelete", zFilename);
38191 }else{
38192 winLogIoerr(cnt, __LINE__);
38193 }
38194 sqlite3_free(zConverted);
38195 OSTRACE(("DELETE name=%s, rc=%s\n", zFilename, sqlite3ErrName(rc)));
38196 return rc;
38197 }
@@ -38115,11 +38237,11 @@
38237 attr = INVALID_FILE_ATTRIBUTES;
38238 }else{
38239 attr = sAttrData.dwFileAttributes;
38240 }
38241 }else{
38242 winLogIoerr(cnt, __LINE__);
38243 if( lastErrno!=ERROR_FILE_NOT_FOUND && lastErrno!=ERROR_PATH_NOT_FOUND ){
38244 sqlite3_free(zConverted);
38245 return winLogError(SQLITE_IOERR_ACCESS, lastErrno, "winAccess",
38246 zFilename);
38247 }else{
@@ -38456,11 +38578,11 @@
38578 ** Write up to nBuf bytes of randomness into zBuf.
38579 */
38580 static int winRandomness(sqlite3_vfs *pVfs, int nBuf, char *zBuf){
38581 int n = 0;
38582 UNUSED_PARAMETER(pVfs);
38583 #if defined(SQLITE_TEST) || defined(SQLITE_OMIT_RANDOMNESS)
38584 n = nBuf;
38585 memset(zBuf, 0, nBuf);
38586 #else
38587 if( sizeof(SYSTEMTIME)<=nBuf-n ){
38588 SYSTEMTIME x;
@@ -38490,11 +38612,10 @@
38612 LARGE_INTEGER i;
38613 osQueryPerformanceCounter(&i);
38614 memcpy(&zBuf[n], &i, sizeof(i));
38615 n += sizeof(i);
38616 }
 
38617 #if !SQLITE_OS_WINCE && !SQLITE_OS_WINRT && SQLITE_WIN32_USE_UUID
38618 if( sizeof(UUID)<=nBuf-n ){
38619 UUID id;
38620 memset(&id, 0, sizeof(UUID));
38621 osUuidCreate(&id);
@@ -38507,10 +38628,11 @@
38628 osUuidCreateSequential(&id);
38629 memcpy(zBuf, &id, sizeof(UUID));
38630 n += sizeof(UUID);
38631 }
38632 #endif
38633 #endif /* defined(SQLITE_TEST) || defined(SQLITE_ZERO_PRNG_SEED) */
38634 return n;
38635 }
38636
38637
38638 /*
@@ -38630,11 +38752,11 @@
38752 }
38753
38754 /*
38755 ** Initialize and deinitialize the operating system interface.
38756 */
38757 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void){
38758 static sqlite3_vfs winVfs = {
38759 3, /* iVersion */
38760 sizeof(winFile), /* szOsFile */
38761 SQLITE_WIN32_MAX_PATH_BYTES, /* mxPathname */
38762 0, /* pNext */
@@ -38684,11 +38806,11 @@
38806 };
38807 #endif
38808
38809 /* Double-check that the aSyscall[] array has been constructed
38810 ** correctly. See ticket [bb3a86e890c8e96ab] */
38811 assert( ArraySize(aSyscall)==80 );
38812
38813 /* get memory map allocation granularity */
38814 memset(&winSysInfo, 0, sizeof(SYSTEM_INFO));
38815 #if SQLITE_OS_WINRT
38816 osGetNativeSystemInfo(&winSysInfo);
@@ -38705,11 +38827,11 @@
38827 #endif
38828
38829 return SQLITE_OK;
38830 }
38831
38832 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void){
38833 #if SQLITE_OS_WINRT
38834 if( sleepObj!=NULL ){
38835 osCloseHandle(sleepObj);
38836 sleepObj = NULL;
38837 }
@@ -39061,11 +39183,11 @@
39183
39184 /* Allocate the Bitvec to be tested and a linear array of
39185 ** bits to act as the reference */
39186 pBitvec = sqlite3BitvecCreate( sz );
39187 pV = sqlite3MallocZero( (sz+7)/8 + 1 );
39188 pTmpSpace = sqlite3_malloc64(BITVEC_SZ);
39189 if( pBitvec==0 || pV==0 || pTmpSpace==0 ) goto bitvec_end;
39190
39191 /* NULL pBitvec tests */
39192 sqlite3BitvecSet(0, 1);
39193 sqlite3BitvecClear(0, 1, pTmpSpace);
@@ -44550,13 +44672,11 @@
44672 Pgno nTruncate, /* Database size after this commit */
44673 int isCommit /* True if this is a commit */
44674 ){
44675 int rc; /* Return code */
44676 int nList; /* Number of pages in pList */
 
44677 PgHdr *p; /* For looping over pages */
 
44678
44679 assert( pPager->pWal );
44680 assert( pList );
44681 #ifdef SQLITE_DEBUG
44682 /* Verify that the page list is in accending order */
@@ -44569,11 +44689,10 @@
44689 if( isCommit ){
44690 /* If a WAL transaction is being committed, there is no point in writing
44691 ** any pages with page numbers greater than nTruncate into the WAL file.
44692 ** They will never be read by any client. So remove them from the pDirty
44693 ** list here. */
 
44694 PgHdr **ppNext = &pList;
44695 nList = 0;
44696 for(p=pList; (*ppNext = p)!=0; p=p->pDirty){
44697 if( p->pgno<=nTruncate ){
44698 ppNext = &p->pDirty;
@@ -44589,11 +44708,10 @@
44708 if( pList->pgno==1 ) pager_write_changecounter(pList);
44709 rc = sqlite3WalFrames(pPager->pWal,
44710 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
44711 );
44712 if( rc==SQLITE_OK && pPager->pBackup ){
 
44713 for(p=pList; p; p=p->pDirty){
44714 sqlite3BackupUpdate(pPager->pBackup, p->pgno, (u8 *)p->pData);
44715 }
44716 }
44717
@@ -48520,10 +48638,12 @@
48638 }else if( state==PAGER_OPEN ){
48639 pager_unlock(pPager);
48640 }
48641 assert( state==pPager->eState );
48642 }
48643 }else if( eMode==PAGER_JOURNALMODE_OFF ){
48644 sqlite3OsClose(pPager->jfd);
48645 }
48646 }
48647
48648 /* Return the new journal mode */
48649 return (int)pPager->journalMode;
@@ -49302,11 +49422,11 @@
49422
49423 /* Enlarge the pWal->apWiData[] array if required */
49424 if( pWal->nWiData<=iPage ){
49425 int nByte = sizeof(u32*)*(iPage+1);
49426 volatile u32 **apNew;
49427 apNew = (volatile u32 **)sqlite3_realloc64((void *)pWal->apWiData, nByte);
49428 if( !apNew ){
49429 *ppPage = 0;
49430 return SQLITE_NOMEM;
49431 }
49432 memset((void*)&apNew[pWal->nWiData], 0,
@@ -49927,11 +50047,11 @@
50047 goto finished;
50048 }
50049
50050 /* Malloc a buffer to read frames into. */
50051 szFrame = szPage + WAL_FRAME_HDRSIZE;
50052 aFrame = (u8 *)sqlite3_malloc64(szFrame);
50053 if( !aFrame ){
50054 rc = SQLITE_NOMEM;
50055 goto recovery_error;
50056 }
50057 aData = &aFrame[WAL_FRAME_HDRSIZE];
@@ -50320,21 +50440,21 @@
50440 /* Allocate space for the WalIterator object. */
50441 nSegment = walFramePage(iLast) + 1;
50442 nByte = sizeof(WalIterator)
50443 + (nSegment-1)*sizeof(struct WalSegment)
50444 + iLast*sizeof(ht_slot);
50445 p = (WalIterator *)sqlite3_malloc64(nByte);
50446 if( !p ){
50447 return SQLITE_NOMEM;
50448 }
50449 memset(p, 0, nByte);
50450 p->nSegment = nSegment;
50451
50452 /* Allocate temporary space used by the merge-sort routine. This block
50453 ** of memory will be freed before this function returns.
50454 */
50455 aTmp = (ht_slot *)sqlite3_malloc64(
50456 sizeof(ht_slot) * (iLast>HASHTABLE_NPAGE?HASHTABLE_NPAGE:iLast)
50457 );
50458 if( !aTmp ){
50459 rc = SQLITE_NOMEM;
50460 }
@@ -50510,10 +50630,18 @@
50630 ** cannot be backfilled from the WAL.
50631 */
50632 mxSafeFrame = pWal->hdr.mxFrame;
50633 mxPage = pWal->hdr.nPage;
50634 for(i=1; i<WAL_NREADER; i++){
50635 /* Thread-sanitizer reports that the following is an unsafe read,
50636 ** as some other thread may be in the process of updating the value
50637 ** of the aReadMark[] slot. The assumption here is that if that is
50638 ** happening, the other client may only be increasing the value,
50639 ** not decreasing it. So assuming either that either the "old" or
50640 ** "new" version of the value is read, and not some arbitrary value
50641 ** that would never be written by a real client, things are still
50642 ** safe. */
50643 u32 y = pInfo->aReadMark[i];
50644 if( mxSafeFrame>y ){
50645 assert( y<=pWal->hdr.mxFrame );
50646 rc = walBusyLock(pWal, xBusy, pBusyArg, WAL_READ_LOCK(i), 1);
50647 if( rc==SQLITE_OK ){
@@ -52231,10 +52359,11 @@
52359 u8 noPayload; /* True if internal intKey page (thus w/o data) */
52360 u8 leaf; /* True if a leaf page */
52361 u8 hdrOffset; /* 100 for page 1. 0 otherwise */
52362 u8 childPtrSize; /* 0 if leaf==1. 4 if leaf==0 */
52363 u8 max1bytePayload; /* min(maxLocal,127) */
52364 u8 bBusy; /* Prevent endless loops on corrupt database files */
52365 u16 maxLocal; /* Copy of BtShared.maxLocal or BtShared.maxLeaf */
52366 u16 minLocal; /* Copy of BtShared.minLocal or BtShared.minLeaf */
52367 u16 cellOffset; /* Index in aData of first cell pointer */
52368 u16 nFree; /* Number of free bytes on the page */
52369 u16 nCell; /* Number of cells on this page, local and ovfl */
@@ -53006,11 +53135,11 @@
53135 **
53136 ** This routine has no effect on existing database connections.
53137 ** The shared cache setting effects only future calls to
53138 ** sqlite3_open(), sqlite3_open16(), or sqlite3_open_v2().
53139 */
53140 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int enable){
53141 sqlite3GlobalConfig.sharedCacheEnabled = enable;
53142 return SQLITE_OK;
53143 }
53144 #endif
53145
@@ -53520,14 +53649,19 @@
53649 ** prior to calling this routine.
53650 */
53651 static int saveCursorPosition(BtCursor *pCur){
53652 int rc;
53653
53654 assert( CURSOR_VALID==pCur->eState || CURSOR_SKIPNEXT==pCur->eState );
53655 assert( 0==pCur->pKey );
53656 assert( cursorHoldsMutex(pCur) );
53657
53658 if( pCur->eState==CURSOR_SKIPNEXT ){
53659 pCur->eState = CURSOR_VALID;
53660 }else{
53661 pCur->skipNext = 0;
53662 }
53663 rc = sqlite3BtreeKeySize(pCur, &pCur->nKey);
53664 assert( rc==SQLITE_OK ); /* KeySize() cannot fail */
53665
53666 /* If this is an intKey table, then the above call to BtreeKeySize()
53667 ** stores the integer key in pCur->nKey. In this case this value is
@@ -53594,11 +53728,11 @@
53728 Pgno iRoot, /* Only save cursor with this iRoot. Save all if zero */
53729 BtCursor *pExcept /* Do not save this cursor */
53730 ){
53731 do{
53732 if( p!=pExcept && (0==iRoot || p->pgnoRoot==iRoot) ){
53733 if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
53734 int rc = saveCursorPosition(p);
53735 if( SQLITE_OK!=rc ){
53736 return rc;
53737 }
53738 }else{
@@ -53666,21 +53800,23 @@
53800 ** at most one effective restoreCursorPosition() call after each
53801 ** saveCursorPosition().
53802 */
53803 static int btreeRestoreCursorPosition(BtCursor *pCur){
53804 int rc;
53805 int skipNext;
53806 assert( cursorHoldsMutex(pCur) );
53807 assert( pCur->eState>=CURSOR_REQUIRESEEK );
53808 if( pCur->eState==CURSOR_FAULT ){
53809 return pCur->skipNext;
53810 }
53811 pCur->eState = CURSOR_INVALID;
53812 rc = btreeMoveto(pCur, pCur->pKey, pCur->nKey, 0, &skipNext);
53813 if( rc==SQLITE_OK ){
53814 sqlite3_free(pCur->pKey);
53815 pCur->pKey = 0;
53816 assert( pCur->eState==CURSOR_VALID || pCur->eState==CURSOR_INVALID );
53817 pCur->skipNext |= skipNext;
53818 if( pCur->skipNext && pCur->eState==CURSOR_VALID ){
53819 pCur->eState = CURSOR_SKIPNEXT;
53820 }
53821 }
53822 return rc;
@@ -53728,13 +53864,14 @@
53864 rc = restoreCursorPosition(pCur);
53865 if( rc ){
53866 *pDifferentRow = 1;
53867 return rc;
53868 }
53869 if( pCur->eState!=CURSOR_VALID ){
53870 *pDifferentRow = 1;
53871 }else{
53872 assert( pCur->skipNext==0 );
53873 *pDifferentRow = 0;
53874 }
53875 return SQLITE_OK;
53876 }
53877
@@ -54871,20 +55008,22 @@
55008 ** If this Btree is a candidate for shared cache, try to find an
55009 ** existing BtShared object that we can share with
55010 */
55011 if( isTempDb==0 && (isMemdb==0 || (vfsFlags&SQLITE_OPEN_URI)!=0) ){
55012 if( vfsFlags & SQLITE_OPEN_SHAREDCACHE ){
55013 int nFilename = sqlite3Strlen30(zFilename)+1;
55014 int nFullPathname = pVfs->mxPathname+1;
55015 char *zFullPathname = sqlite3Malloc(MAX(nFullPathname,nFilename));
55016 MUTEX_LOGIC( sqlite3_mutex *mutexShared; )
55017
55018 p->sharable = 1;
55019 if( !zFullPathname ){
55020 sqlite3_free(p);
55021 return SQLITE_NOMEM;
55022 }
55023 if( isMemdb ){
55024 memcpy(zFullPathname, zFilename, nFilename);
55025 }else{
55026 rc = sqlite3OsFullPathname(pVfs, zFilename,
55027 nFullPathname, zFullPathname);
55028 if( rc ){
55029 sqlite3_free(zFullPathname);
@@ -55339,11 +55478,11 @@
55478 }
55479 assert( nReserve>=0 && nReserve<=255 );
55480 if( pageSize>=512 && pageSize<=SQLITE_MAX_PAGE_SIZE &&
55481 ((pageSize-1)&pageSize)==0 ){
55482 assert( (pageSize & 7)==0 );
55483 assert( !pBt->pCursor );
55484 pBt->pageSize = (u32)pageSize;
55485 freeTempSpace(pBt);
55486 }
55487 rc = sqlite3PagerSetPagesize(pBt->pPager, &pBt->pageSize, nReserve);
55488 pBt->usableSize = pBt->pageSize - (u16)nReserve;
@@ -56545,11 +56684,11 @@
56684 if( pBtree ){
56685 sqlite3BtreeEnter(pBtree);
56686 for(p=pBtree->pBt->pCursor; p; p=p->pNext){
56687 int i;
56688 if( writeOnly && (p->curFlags & BTCF_WriteFlag)==0 ){
56689 if( p->eState==CURSOR_VALID || p->eState==CURSOR_SKIPNEXT ){
56690 rc = saveCursorPosition(p);
56691 if( rc!=SQLITE_OK ){
56692 (void)sqlite3BtreeTripAllCursors(pBtree, rc, 0);
56693 break;
56694 }
@@ -56951,10 +57090,12 @@
57090 ** to return an integer result code for historical reasons.
57091 */
57092 SQLITE_PRIVATE int sqlite3BtreeDataSize(BtCursor *pCur, u32 *pSize){
57093 assert( cursorHoldsMutex(pCur) );
57094 assert( pCur->eState==CURSOR_VALID );
57095 assert( pCur->iPage>=0 );
57096 assert( pCur->iPage<BTCURSOR_MAX_DEPTH );
57097 assert( pCur->apPage[pCur->iPage]->intKeyLeaf==1 );
57098 getCellInfo(pCur);
57099 *pSize = pCur->info.nPayload;
57100 return SQLITE_OK;
57101 }
@@ -57359,17 +57500,22 @@
57500 */
57501 static const void *fetchPayload(
57502 BtCursor *pCur, /* Cursor pointing to entry to read from */
57503 u32 *pAmt /* Write the number of available bytes here */
57504 ){
57505 u32 amt;
57506 assert( pCur!=0 && pCur->iPage>=0 && pCur->apPage[pCur->iPage]);
57507 assert( pCur->eState==CURSOR_VALID );
57508 assert( sqlite3_mutex_held(pCur->pBtree->db->mutex) );
57509 assert( cursorHoldsMutex(pCur) );
57510 assert( pCur->aiIdx[pCur->iPage]<pCur->apPage[pCur->iPage]->nCell );
57511 assert( pCur->info.nSize>0 );
57512 assert( pCur->info.pPayload>pCur->apPage[pCur->iPage]->aData || CORRUPT_DB );
57513 assert( pCur->info.pPayload<pCur->apPage[pCur->iPage]->aDataEnd ||CORRUPT_DB);
57514 amt = (int)(pCur->apPage[pCur->iPage]->aDataEnd - pCur->info.pPayload);
57515 if( pCur->info.nLocal<amt ) amt = pCur->info.nLocal;
57516 *pAmt = amt;
57517 return (void*)pCur->info.pPayload;
57518 }
57519
57520
57521 /*
@@ -57429,19 +57575,21 @@
57575 return SQLITE_CORRUPT_BKPT;
57576 }
57577 return SQLITE_OK;
57578 }
57579
57580 #if SQLITE_DEBUG
57581 /*
57582 ** Page pParent is an internal (non-leaf) tree page. This function
57583 ** asserts that page number iChild is the left-child if the iIdx'th
57584 ** cell in page pParent. Or, if iIdx is equal to the total number of
57585 ** cells in pParent, that page number iChild is the right-child of
57586 ** the page.
57587 */
57588 static void assertParentIndex(MemPage *pParent, int iIdx, Pgno iChild){
57589 if( CORRUPT_DB ) return; /* The conditions tested below might not be true
57590 ** in a corrupt database */
57591 assert( iIdx<=pParent->nCell );
57592 if( iIdx==pParent->nCell ){
57593 assert( get4byte(&pParent->aData[pParent->hdrOffset+8])==iChild );
57594 }else{
57595 assert( get4byte(findCell(pParent, iIdx))==iChild );
@@ -57462,23 +57610,15 @@
57610 static void moveToParent(BtCursor *pCur){
57611 assert( cursorHoldsMutex(pCur) );
57612 assert( pCur->eState==CURSOR_VALID );
57613 assert( pCur->iPage>0 );
57614 assert( pCur->apPage[pCur->iPage] );
 
 
 
 
 
 
 
57615 assertParentIndex(
57616 pCur->apPage[pCur->iPage-1],
57617 pCur->aiIdx[pCur->iPage-1],
57618 pCur->apPage[pCur->iPage]->pgno
57619 );
 
57620 testcase( pCur->aiIdx[pCur->iPage-1] > pCur->apPage[pCur->iPage-1]->nCell );
57621
57622 releasePage(pCur->apPage[pCur->iPage]);
57623 pCur->iPage--;
57624 pCur->info.nSize = 0;
@@ -59649,11 +59789,10 @@
59789 if( iParentIdx==0 ){
59790 nxDiv = 0;
59791 }else if( iParentIdx==i ){
59792 nxDiv = i-2+bBulk;
59793 }else{
 
59794 nxDiv = iParentIdx-1;
59795 }
59796 i = 2-bBulk;
59797 }
59798 nOld = i+1;
@@ -60422,10 +60561,11 @@
60561 pPage->nOverflow = 0;
60562
60563 /* The next iteration of the do-loop balances the parent page. */
60564 releasePage(pPage);
60565 pCur->iPage--;
60566 assert( pCur->iPage>=0 );
60567 }
60568 }while( rc==SQLITE_OK );
60569
60570 if( pFree ){
60571 sqlite3PageFree(pFree);
@@ -60898,13 +61038,17 @@
61038
61039 assert( sqlite3_mutex_held(pBt->mutex) );
61040 if( pgno>btreePagecount(pBt) ){
61041 return SQLITE_CORRUPT_BKPT;
61042 }
 
61043 rc = getAndInitPage(pBt, pgno, &pPage, 0);
61044 if( rc ) return rc;
61045 if( pPage->bBusy ){
61046 rc = SQLITE_CORRUPT_BKPT;
61047 goto cleardatabasepage_out;
61048 }
61049 pPage->bBusy = 1;
61050 hdr = pPage->hdrOffset;
61051 for(i=0; i<pPage->nCell; i++){
61052 pCell = findCell(pPage, i);
61053 if( !pPage->leaf ){
61054 rc = clearDatabasePage(pBt, get4byte(pCell), 1, pnChange);
@@ -60925,10 +61069,11 @@
61069 }else if( (rc = sqlite3PagerWrite(pPage->pDbPage))==0 ){
61070 zeroPage(pPage, pPage->aData[hdr] | PTF_LEAF);
61071 }
61072
61073 cleardatabasepage_out:
61074 pPage->bBusy = 0;
61075 releasePage(pPage);
61076 return rc;
61077 }
61078
61079 /*
@@ -61431,10 +61576,61 @@
61576 iPage = get4byte(pOvflData);
61577 sqlite3PagerUnref(pOvflPage);
61578 }
61579 }
61580 #endif /* SQLITE_OMIT_INTEGRITY_CHECK */
61581
61582 /*
61583 ** An implementation of a min-heap.
61584 **
61585 ** aHeap[0] is the number of elements on the heap. aHeap[1] is the
61586 ** root element. The daughter nodes of aHeap[N] are aHeap[N*2]
61587 ** and aHeap[N*2+1].
61588 **
61589 ** The heap property is this: Every node is less than or equal to both
61590 ** of its daughter nodes. A consequence of the heap property is that the
61591 ** root node aHeap[1] is always the minimum value currently in the heap.
61592 **
61593 ** The btreeHeapInsert() routine inserts an unsigned 32-bit number onto
61594 ** the heap, preserving the heap property. The btreeHeapPull() routine
61595 ** removes the root element from the heap (the minimum value in the heap)
61596 ** and then moves other nodes around as necessary to preserve the heap
61597 ** property.
61598 **
61599 ** This heap is used for cell overlap and coverage testing. Each u32
61600 ** entry represents the span of a cell or freeblock on a btree page.
61601 ** The upper 16 bits are the index of the first byte of a range and the
61602 ** lower 16 bits are the index of the last byte of that range.
61603 */
61604 static void btreeHeapInsert(u32 *aHeap, u32 x){
61605 u32 j, i = ++aHeap[0];
61606 aHeap[i] = x;
61607 while( (j = i/2)>0 && aHeap[j]>aHeap[i] ){
61608 x = aHeap[j];
61609 aHeap[j] = aHeap[i];
61610 aHeap[i] = x;
61611 i = j;
61612 }
61613 }
61614 static int btreeHeapPull(u32 *aHeap, u32 *pOut){
61615 u32 j, i, x;
61616 if( (x = aHeap[0])==0 ) return 0;
61617 *pOut = aHeap[1];
61618 aHeap[1] = aHeap[x];
61619 aHeap[x] = 0xffffffff;
61620 aHeap[0]--;
61621 i = 1;
61622 while( (j = i*2)<=aHeap[0] ){
61623 if( aHeap[j]>aHeap[j+1] ) j++;
61624 if( aHeap[i]<aHeap[j] ) break;
61625 x = aHeap[i];
61626 aHeap[i] = aHeap[j];
61627 aHeap[j] = x;
61628 i = j;
61629 }
61630 return 1;
61631 }
61632
61633 #ifndef SQLITE_OMIT_INTEGRITY_CHECK
61634 /*
61635 ** Do various sanity checks on a single page of a tree. Return
61636 ** the tree depth. Root pages return 0. Parents of root pages
@@ -61464,11 +61660,12 @@
61660 int hdr, cellStart;
61661 int nCell;
61662 u8 *data;
61663 BtShared *pBt;
61664 int usableSize;
61665 u32 *heap = 0;
61666 u32 x, prev = 0;
61667 i64 nMinKey = 0;
61668 i64 nMaxKey = 0;
61669 const char *saved_zPfx = pCheck->zPfx;
61670 int saved_v1 = pCheck->v1;
61671 int saved_v2 = pCheck->v2;
@@ -61609,19 +61806,19 @@
61806
61807 /* Check for complete coverage of the page
61808 */
61809 data = pPage->aData;
61810 hdr = pPage->hdrOffset;
61811 heap = (u32*)sqlite3PageMalloc( pBt->pageSize );
61812 pCheck->zPfx = 0;
61813 if( heap==0 ){
61814 pCheck->mallocFailed = 1;
61815 }else{
61816 int contentOffset = get2byteNotZero(&data[hdr+5]);
61817 assert( contentOffset<=usableSize ); /* Enforced by btreeInitPage() */
61818 heap[0] = 0;
61819 btreeHeapInsert(heap, contentOffset-1);
61820 /* EVIDENCE-OF: R-37002-32774 The two-byte integer at offset 3 gives the
61821 ** number of cells on the page. */
61822 nCell = get2byte(&data[hdr+3]);
61823 /* EVIDENCE-OF: R-23882-45353 The cell pointer array of a b-tree page
61824 ** immediately follows the b-tree page header. */
@@ -61629,20 +61826,19 @@
61826 /* EVIDENCE-OF: R-02776-14802 The cell pointer array consists of K 2-byte
61827 ** integer offsets to the cell contents. */
61828 for(i=0; i<nCell; i++){
61829 int pc = get2byte(&data[cellStart+i*2]);
61830 u32 size = 65536;
 
61831 if( pc<=usableSize-4 ){
61832 size = cellSizePtr(pPage, &data[pc]);
61833 }
61834 if( (int)(pc+size-1)>=usableSize ){
61835 pCheck->zPfx = 0;
61836 checkAppendMsg(pCheck,
61837 "Corruption detected in cell %d on page %d",i,iPage);
61838 }else{
61839 btreeHeapInsert(heap, (pc<<16)|(pc+size-1));
61840 }
61841 }
61842 /* EVIDENCE-OF: R-20690-50594 The second field of the b-tree page header
61843 ** is the offset of the first freeblock, or zero if there are no
61844 ** freeblocks on the page. */
@@ -61650,11 +61846,11 @@
61846 while( i>0 ){
61847 int size, j;
61848 assert( i<=usableSize-4 ); /* Enforced by btreeInitPage() */
61849 size = get2byte(&data[i+2]);
61850 assert( i+size<=usableSize ); /* Enforced by btreeInitPage() */
61851 btreeHeapInsert(heap, (i<<16)|(i+size-1));
61852 /* EVIDENCE-OF: R-58208-19414 The first 2 bytes of a freeblock are a
61853 ** big-endian integer which is the offset in the b-tree page of the next
61854 ** freeblock in the chain, or zero if the freeblock is the last on the
61855 ** chain. */
61856 j = get2byte(&data[i]);
@@ -61662,31 +61858,37 @@
61858 ** increasing offset. */
61859 assert( j==0 || j>i+size ); /* Enforced by btreeInitPage() */
61860 assert( j<=usableSize-4 ); /* Enforced by btreeInitPage() */
61861 i = j;
61862 }
61863 cnt = 0;
61864 assert( heap[0]>0 );
61865 assert( (heap[1]>>16)==0 );
61866 btreeHeapPull(heap,&prev);
61867 while( btreeHeapPull(heap,&x) ){
61868 if( (prev&0xffff)+1>(x>>16) ){
61869 checkAppendMsg(pCheck,
61870 "Multiple uses for byte %u of page %d", x>>16, iPage);
61871 break;
61872 }else{
61873 cnt += (x>>16) - (prev&0xffff) - 1;
61874 prev = x;
61875 }
61876 }
61877 cnt += usableSize - (prev&0xffff) - 1;
61878 /* EVIDENCE-OF: R-43263-13491 The total number of bytes in all fragments
61879 ** is stored in the fifth field of the b-tree page header.
61880 ** EVIDENCE-OF: R-07161-27322 The one-byte integer at offset 7 gives the
61881 ** number of fragmented free bytes within the cell content area.
61882 */
61883 if( heap[0]==0 && cnt!=data[hdr+7] ){
61884 checkAppendMsg(pCheck,
61885 "Fragmentation of %d bytes reported as %d on page %d",
61886 cnt, data[hdr+7], iPage);
61887 }
61888 }
61889 sqlite3PageFree(heap);
61890 releasePage(pPage);
61891
61892 end_of_check:
61893 pCheck->zPfx = saved_zPfx;
61894 pCheck->v1 = saved_v1;
@@ -61746,12 +61948,11 @@
61948 sqlite3BtreeLeave(p);
61949 return 0;
61950 }
61951 i = PENDING_BYTE_PAGE(pBt);
61952 if( i<=sCheck.nPage ) setPageReferenced(&sCheck, i);
61953 sqlite3StrAccumInit(&sCheck.errMsg, 0, zErr, sizeof(zErr), SQLITE_MAX_LENGTH);
 
61954
61955 /* Check the integrity of the freelist
61956 */
61957 sCheck.zPfx = "Main freelist: ";
61958 checkList(&sCheck, 1, get4byte(&pBt->pPage1->aData[32]),
@@ -62239,11 +62440,11 @@
62440 ** a pointer to the new sqlite3_backup object.
62441 **
62442 ** If an error occurs, NULL is returned and an error code and error message
62443 ** stored in database handle pDestDb.
62444 */
62445 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
62446 sqlite3* pDestDb, /* Database to write to */
62447 const char *zDestDb, /* Name of database within pDestDb */
62448 sqlite3* pSrcDb, /* Database connection to read from */
62449 const char *zSrcDb /* Name of database within pSrcDb */
62450 ){
@@ -62447,11 +62648,11 @@
62648 }
62649
62650 /*
62651 ** Copy nPage pages from the source b-tree to the destination.
62652 */
62653 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage){
62654 int rc;
62655 int destMode; /* Destination journal mode */
62656 int pgszSrc = 0; /* Source page size */
62657 int pgszDest = 0; /* Destination page size */
62658
@@ -62692,11 +62893,11 @@
62893 }
62894
62895 /*
62896 ** Release all resources associated with an sqlite3_backup* handle.
62897 */
62898 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p){
62899 sqlite3_backup **pp; /* Ptr to head of pagers backup list */
62900 sqlite3 *pSrcDb; /* Source database connection */
62901 int rc; /* Value to return */
62902
62903 /* Enter the mutexes */
@@ -62744,11 +62945,11 @@
62945
62946 /*
62947 ** Return the number of pages still to be backed up as of the most recent
62948 ** call to sqlite3_backup_step().
62949 */
62950 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p){
62951 #ifdef SQLITE_ENABLE_API_ARMOR
62952 if( p==0 ){
62953 (void)SQLITE_MISUSE_BKPT;
62954 return 0;
62955 }
@@ -62758,11 +62959,11 @@
62959
62960 /*
62961 ** Return the total number of pages in the source database as of the most
62962 ** recent call to sqlite3_backup_step().
62963 */
62964 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p){
62965 #ifdef SQLITE_ENABLE_API_ARMOR
62966 if( p==0 ){
62967 (void)SQLITE_MISUSE_BKPT;
62968 return 0;
62969 }
@@ -63083,14 +63284,15 @@
63284 return SQLITE_NOMEM;
63285 }
63286 pMem->z[pMem->n] = 0;
63287 pMem->z[pMem->n+1] = 0;
63288 pMem->flags |= MEM_Term;
63289 }
63290 pMem->flags &= ~MEM_Ephem;
63291 #ifdef SQLITE_DEBUG
63292 pMem->pScopyFrom = 0;
63293 #endif
 
63294
63295 return SQLITE_OK;
63296 }
63297
63298 /*
@@ -64530,11 +64732,11 @@
64732 int i;
64733 int nCol = pRec->pKeyInfo->nField+pRec->pKeyInfo->nXField;
64734 Mem *aMem = pRec->aMem;
64735 sqlite3 *db = aMem[0].db;
64736 for(i=0; i<nCol; i++){
64737 sqlite3VdbeMemRelease(&aMem[i]);
64738 }
64739 sqlite3KeyInfoUnref(pRec->pKeyInfo);
64740 sqlite3DbFree(db, pRec);
64741 }
64742 }
@@ -64633,11 +64835,11 @@
64835 }
64836
64837 /*
64838 ** Return the SQL associated with a prepared statement
64839 */
64840 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt){
64841 Vdbe *p = (Vdbe *)pStmt;
64842 return (p && p->isPrepareV2) ? p->zSql : 0;
64843 }
64844
64845 /*
@@ -66366,18 +66568,35 @@
66568 pVtabCursor->pVtab->nRef--;
66569 pModule->xClose(pVtabCursor);
66570 }
66571 #endif
66572 }
66573
66574 /*
66575 ** Close all cursors in the current frame.
66576 */
66577 static void closeCursorsInFrame(Vdbe *p){
66578 if( p->apCsr ){
66579 int i;
66580 for(i=0; i<p->nCursor; i++){
66581 VdbeCursor *pC = p->apCsr[i];
66582 if( pC ){
66583 sqlite3VdbeFreeCursor(p, pC);
66584 p->apCsr[i] = 0;
66585 }
66586 }
66587 }
66588 }
66589
66590 /*
66591 ** Copy the values stored in the VdbeFrame structure to its Vdbe. This
66592 ** is used, for example, when a trigger sub-program is halted to restore
66593 ** control to the main program.
66594 */
66595 SQLITE_PRIVATE int sqlite3VdbeFrameRestore(VdbeFrame *pFrame){
66596 Vdbe *v = pFrame->v;
66597 closeCursorsInFrame(v);
66598 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
66599 v->anExec = pFrame->anExec;
66600 #endif
66601 v->aOnceFlag = pFrame->aOnceFlag;
66602 v->nOnceFlag = pFrame->nOnceFlag;
@@ -66408,21 +66627,11 @@
66627 sqlite3VdbeFrameRestore(pFrame);
66628 p->pFrame = 0;
66629 p->nFrame = 0;
66630 }
66631 assert( p->nFrame==0 );
66632 closeCursorsInFrame(p);
 
 
 
 
 
 
 
 
 
 
66633 if( p->aMem ){
66634 releaseMemArray(&p->aMem[1], p->nMem);
66635 }
66636 while( p->pDelFrame ){
66637 VdbeFrame *pDel = p->pDelFrame;
@@ -68163,11 +68372,11 @@
68372 ** If database corruption is discovered, set pPKey2->errCode to
68373 ** SQLITE_CORRUPT and return 0. If an OOM error is encountered,
68374 ** pPKey2->errCode is set to SQLITE_NOMEM and, if it is not NULL, the
68375 ** malloc-failed flag set on database handle (pPKey2->pKeyInfo->db).
68376 */
68377 SQLITE_PRIVATE int sqlite3VdbeRecordCompareWithSkip(
68378 int nKey1, const void *pKey1, /* Left key */
68379 UnpackedRecord *pPKey2, /* Right key */
68380 int bSkip /* If true, skip the first field */
68381 ){
68382 u32 d1; /* Offset into aKey[] of next data element */
@@ -68349,11 +68558,11 @@
68558 }
68559 SQLITE_PRIVATE int sqlite3VdbeRecordCompare(
68560 int nKey1, const void *pKey1, /* Left key */
68561 UnpackedRecord *pPKey2 /* Right key */
68562 ){
68563 return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 0);
68564 }
68565
68566
68567 /*
68568 ** This function is an optimized version of sqlite3VdbeRecordCompare()
@@ -68437,11 +68646,11 @@
68646 }else if( v<lhs ){
68647 res = pPKey2->r2;
68648 }else if( pPKey2->nField>1 ){
68649 /* The first fields of the two keys are equal. Compare the trailing
68650 ** fields. */
68651 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68652 }else{
68653 /* The first fields of the two keys are equal and there are no trailing
68654 ** fields. Return pPKey2->default_rc in this case. */
68655 res = pPKey2->default_rc;
68656 }
@@ -68485,11 +68694,11 @@
68694
68695 if( res==0 ){
68696 res = nStr - pPKey2->aMem[0].n;
68697 if( res==0 ){
68698 if( pPKey2->nField>1 ){
68699 res = sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, pPKey2, 1);
68700 }else{
68701 res = pPKey2->default_rc;
68702 }
68703 }else if( res>0 ){
68704 res = pPKey2->r2;
@@ -68789,11 +68998,11 @@
68998 ** execution environment changes in a way that would alter the program
68999 ** that sqlite3_prepare() generates. For example, if new functions or
69000 ** collating sequences are registered or if an authorizer function is
69001 ** added or changed.
69002 */
69003 SQLITE_API int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt *pStmt){
69004 Vdbe *p = (Vdbe*)pStmt;
69005 return p==0 || p->expired;
69006 }
69007 #endif
69008
@@ -68826,11 +69035,11 @@
69035 ** machine.
69036 **
69037 ** This routine sets the error code and string returned by
69038 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
69039 */
69040 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt){
69041 int rc;
69042 if( pStmt==0 ){
69043 /* IMPLEMENTATION-OF: R-57228-12904 Invoking sqlite3_finalize() on a NULL
69044 ** pointer is a harmless no-op. */
69045 rc = SQLITE_OK;
@@ -68852,11 +69061,11 @@
69061 ** the prior execution is returned.
69062 **
69063 ** This routine sets the error code and string returned by
69064 ** sqlite3_errcode(), sqlite3_errmsg() and sqlite3_errmsg16().
69065 */
69066 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt){
69067 int rc;
69068 if( pStmt==0 ){
69069 rc = SQLITE_OK;
69070 }else{
69071 Vdbe *v = (Vdbe*)pStmt;
@@ -68871,11 +69080,11 @@
69080 }
69081
69082 /*
69083 ** Set all the parameters in the compiled SQL statement to NULL.
69084 */
69085 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt *pStmt){
69086 int i;
69087 int rc = SQLITE_OK;
69088 Vdbe *p = (Vdbe*)pStmt;
69089 #if SQLITE_THREADSAFE
69090 sqlite3_mutex *mutex = ((Vdbe*)pStmt)->db->mutex;
@@ -68895,54 +69104,54 @@
69104
69105 /**************************** sqlite3_value_ *******************************
69106 ** The following routines extract information from a Mem or sqlite3_value
69107 ** structure.
69108 */
69109 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value *pVal){
69110 Mem *p = (Mem*)pVal;
69111 if( p->flags & (MEM_Blob|MEM_Str) ){
69112 sqlite3VdbeMemExpandBlob(p);
69113 p->flags |= MEM_Blob;
69114 return p->n ? p->z : 0;
69115 }else{
69116 return sqlite3_value_text(pVal);
69117 }
69118 }
69119 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value *pVal){
69120 return sqlite3ValueBytes(pVal, SQLITE_UTF8);
69121 }
69122 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value *pVal){
69123 return sqlite3ValueBytes(pVal, SQLITE_UTF16NATIVE);
69124 }
69125 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value *pVal){
69126 return sqlite3VdbeRealValue((Mem*)pVal);
69127 }
69128 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value *pVal){
69129 return (int)sqlite3VdbeIntValue((Mem*)pVal);
69130 }
69131 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value *pVal){
69132 return sqlite3VdbeIntValue((Mem*)pVal);
69133 }
69134 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value *pVal){
69135 return (const unsigned char *)sqlite3ValueText(pVal, SQLITE_UTF8);
69136 }
69137 #ifndef SQLITE_OMIT_UTF16
69138 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value* pVal){
69139 return sqlite3ValueText(pVal, SQLITE_UTF16NATIVE);
69140 }
69141 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value *pVal){
69142 return sqlite3ValueText(pVal, SQLITE_UTF16BE);
69143 }
69144 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value *pVal){
69145 return sqlite3ValueText(pVal, SQLITE_UTF16LE);
69146 }
69147 #endif /* SQLITE_OMIT_UTF16 */
69148 /* EVIDENCE-OF: R-12793-43283 Every value in SQLite has one of five
69149 ** fundamental datatypes: 64-bit signed integer 64-bit IEEE floating
69150 ** point number string BLOB NULL
69151 */
69152 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value* pVal){
69153 static const u8 aType[] = {
69154 SQLITE_BLOB, /* 0x00 */
69155 SQLITE_NULL, /* 0x01 */
69156 SQLITE_TEXT, /* 0x02 */
69157 SQLITE_NULL, /* 0x03 */
@@ -69014,21 +69223,21 @@
69223 xDel((void*)p);
69224 }
69225 if( pCtx ) sqlite3_result_error_toobig(pCtx);
69226 return SQLITE_TOOBIG;
69227 }
69228 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(
69229 sqlite3_context *pCtx,
69230 const void *z,
69231 int n,
69232 void (*xDel)(void *)
69233 ){
69234 assert( n>=0 );
69235 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69236 setResultStrOrError(pCtx, z, n, 0, xDel);
69237 }
69238 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(
69239 sqlite3_context *pCtx,
69240 const void *z,
69241 sqlite3_uint64 n,
69242 void (*xDel)(void *)
69243 ){
@@ -69038,50 +69247,50 @@
69247 (void)invokeValueDestructor(z, xDel, pCtx);
69248 }else{
69249 setResultStrOrError(pCtx, z, (int)n, 0, xDel);
69250 }
69251 }
69252 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context *pCtx, double rVal){
69253 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69254 sqlite3VdbeMemSetDouble(pCtx->pOut, rVal);
69255 }
69256 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context *pCtx, const char *z, int n){
69257 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69258 pCtx->isError = SQLITE_ERROR;
69259 pCtx->fErrorOrAux = 1;
69260 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF8, SQLITE_TRANSIENT);
69261 }
69262 #ifndef SQLITE_OMIT_UTF16
69263 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context *pCtx, const void *z, int n){
69264 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69265 pCtx->isError = SQLITE_ERROR;
69266 pCtx->fErrorOrAux = 1;
69267 sqlite3VdbeMemSetStr(pCtx->pOut, z, n, SQLITE_UTF16NATIVE, SQLITE_TRANSIENT);
69268 }
69269 #endif
69270 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context *pCtx, int iVal){
69271 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69272 sqlite3VdbeMemSetInt64(pCtx->pOut, (i64)iVal);
69273 }
69274 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context *pCtx, i64 iVal){
69275 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69276 sqlite3VdbeMemSetInt64(pCtx->pOut, iVal);
69277 }
69278 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context *pCtx){
69279 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69280 sqlite3VdbeMemSetNull(pCtx->pOut);
69281 }
69282 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(
69283 sqlite3_context *pCtx,
69284 const char *z,
69285 int n,
69286 void (*xDel)(void *)
69287 ){
69288 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69289 setResultStrOrError(pCtx, z, n, SQLITE_UTF8, xDel);
69290 }
69291 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(
69292 sqlite3_context *pCtx,
69293 const char *z,
69294 sqlite3_uint64 n,
69295 void (*xDel)(void *),
69296 unsigned char enc
@@ -69094,47 +69303,47 @@
69303 }else{
69304 setResultStrOrError(pCtx, z, (int)n, enc, xDel);
69305 }
69306 }
69307 #ifndef SQLITE_OMIT_UTF16
69308 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(
69309 sqlite3_context *pCtx,
69310 const void *z,
69311 int n,
69312 void (*xDel)(void *)
69313 ){
69314 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69315 setResultStrOrError(pCtx, z, n, SQLITE_UTF16NATIVE, xDel);
69316 }
69317 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(
69318 sqlite3_context *pCtx,
69319 const void *z,
69320 int n,
69321 void (*xDel)(void *)
69322 ){
69323 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69324 setResultStrOrError(pCtx, z, n, SQLITE_UTF16BE, xDel);
69325 }
69326 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(
69327 sqlite3_context *pCtx,
69328 const void *z,
69329 int n,
69330 void (*xDel)(void *)
69331 ){
69332 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69333 setResultStrOrError(pCtx, z, n, SQLITE_UTF16LE, xDel);
69334 }
69335 #endif /* SQLITE_OMIT_UTF16 */
69336 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context *pCtx, sqlite3_value *pValue){
69337 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69338 sqlite3VdbeMemCopy(pCtx->pOut, pValue);
69339 }
69340 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context *pCtx, int n){
69341 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69342 sqlite3VdbeMemSetZeroBlob(pCtx->pOut, n);
69343 }
69344 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context *pCtx, int errCode){
69345 pCtx->isError = errCode;
69346 pCtx->fErrorOrAux = 1;
69347 #ifdef SQLITE_DEBUG
69348 if( pCtx->pVdbe ) pCtx->pVdbe->rcApp = errCode;
69349 #endif
@@ -69143,20 +69352,20 @@
69352 SQLITE_UTF8, SQLITE_STATIC);
69353 }
69354 }
69355
69356 /* Force an SQLITE_TOOBIG error. */
69357 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context *pCtx){
69358 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69359 pCtx->isError = SQLITE_TOOBIG;
69360 pCtx->fErrorOrAux = 1;
69361 sqlite3VdbeMemSetStr(pCtx->pOut, "string or blob too big", -1,
69362 SQLITE_UTF8, SQLITE_STATIC);
69363 }
69364
69365 /* An SQLITE_NOMEM error. */
69366 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context *pCtx){
69367 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69368 sqlite3VdbeMemSetNull(pCtx->pOut);
69369 pCtx->isError = SQLITE_NOMEM;
69370 pCtx->fErrorOrAux = 1;
69371 pCtx->pOut->db->mallocFailed = 1;
@@ -69325,11 +69534,11 @@
69534 /*
69535 ** This is the top-level implementation of sqlite3_step(). Call
69536 ** sqlite3Step() to do most of the work. If a schema error occurs,
69537 ** call sqlite3Reprepare() and try again.
69538 */
69539 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt *pStmt){
69540 int rc = SQLITE_OK; /* Result from sqlite3Step() */
69541 int rc2 = SQLITE_OK; /* Result from sqlite3Reprepare() */
69542 Vdbe *v = (Vdbe*)pStmt; /* the prepared statement */
69543 int cnt = 0; /* Counter to prevent infinite loop of reprepares */
69544 sqlite3 *db; /* The database connection */
@@ -69376,11 +69585,11 @@
69585
69586 /*
69587 ** Extract the user data from a sqlite3_context structure and return a
69588 ** pointer to it.
69589 */
69590 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context *p){
69591 assert( p && p->pFunc );
69592 return p->pFunc->pUserData;
69593 }
69594
69595 /*
@@ -69391,11 +69600,11 @@
69600 ** returns a copy of the pointer to the database connection (the 1st
69601 ** parameter) of the sqlite3_create_function() and
69602 ** sqlite3_create_function16() routines that originally registered the
69603 ** application defined function.
69604 */
69605 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context *p){
69606 assert( p && p->pFunc );
69607 return p->pOut->db;
69608 }
69609
69610 /*
@@ -69467,11 +69676,11 @@
69676 /*
69677 ** Allocate or return the aggregate context for a user function. A new
69678 ** context is allocated on the first call. Subsequent calls return the
69679 ** same context that was returned on prior calls.
69680 */
69681 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context *p, int nByte){
69682 assert( p && p->pFunc && p->pFunc->xStep );
69683 assert( sqlite3_mutex_held(p->pOut->db->mutex) );
69684 testcase( nByte<0 );
69685 if( (p->pMem->flags & MEM_Agg)==0 ){
69686 return createAggContext(p, nByte);
@@ -69482,11 +69691,11 @@
69691
69692 /*
69693 ** Return the auxiliary data pointer, if any, for the iArg'th argument to
69694 ** the user-function defined by pCtx.
69695 */
69696 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context *pCtx, int iArg){
69697 AuxData *pAuxData;
69698
69699 assert( sqlite3_mutex_held(pCtx->pOut->db->mutex) );
69700 #if SQLITE_ENABLE_STAT3_OR_STAT4
69701 if( pCtx->pVdbe==0 ) return 0;
@@ -69503,11 +69712,11 @@
69712 /*
69713 ** Set the auxiliary data pointer and delete function, for the iArg'th
69714 ** argument to the user-function defined by pCtx. Any previous value is
69715 ** deleted by calling the delete function specified when it was set.
69716 */
69717 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(
69718 sqlite3_context *pCtx,
69719 int iArg,
69720 void *pAux,
69721 void (*xDelete)(void*)
69722 ){
@@ -69558,29 +69767,29 @@
69767 ** This function is deprecated. Do not use it for new code. It is
69768 ** provide only to avoid breaking legacy code. New aggregate function
69769 ** implementations should keep their own counts within their aggregate
69770 ** context.
69771 */
69772 SQLITE_API int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context *p){
69773 assert( p && p->pMem && p->pFunc && p->pFunc->xStep );
69774 return p->pMem->n;
69775 }
69776 #endif
69777
69778 /*
69779 ** Return the number of columns in the result set for the statement pStmt.
69780 */
69781 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt){
69782 Vdbe *pVm = (Vdbe *)pStmt;
69783 return pVm ? pVm->nResColumn : 0;
69784 }
69785
69786 /*
69787 ** Return the number of values available from the current row of the
69788 ** currently executing statement pStmt.
69789 */
69790 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt){
69791 Vdbe *pVm = (Vdbe *)pStmt;
69792 if( pVm==0 || pVm->pResultSet==0 ) return 0;
69793 return pVm->nResColumn;
69794 }
69795
@@ -69678,67 +69887,67 @@
69887
69888 /**************************** sqlite3_column_ *******************************
69889 ** The following routines are used to access elements of the current row
69890 ** in the result set.
69891 */
69892 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt *pStmt, int i){
69893 const void *val;
69894 val = sqlite3_value_blob( columnMem(pStmt,i) );
69895 /* Even though there is no encoding conversion, value_blob() might
69896 ** need to call malloc() to expand the result of a zeroblob()
69897 ** expression.
69898 */
69899 columnMallocFailure(pStmt);
69900 return val;
69901 }
69902 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt *pStmt, int i){
69903 int val = sqlite3_value_bytes( columnMem(pStmt,i) );
69904 columnMallocFailure(pStmt);
69905 return val;
69906 }
69907 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt *pStmt, int i){
69908 int val = sqlite3_value_bytes16( columnMem(pStmt,i) );
69909 columnMallocFailure(pStmt);
69910 return val;
69911 }
69912 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt *pStmt, int i){
69913 double val = sqlite3_value_double( columnMem(pStmt,i) );
69914 columnMallocFailure(pStmt);
69915 return val;
69916 }
69917 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt *pStmt, int i){
69918 int val = sqlite3_value_int( columnMem(pStmt,i) );
69919 columnMallocFailure(pStmt);
69920 return val;
69921 }
69922 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt *pStmt, int i){
69923 sqlite_int64 val = sqlite3_value_int64( columnMem(pStmt,i) );
69924 columnMallocFailure(pStmt);
69925 return val;
69926 }
69927 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt *pStmt, int i){
69928 const unsigned char *val = sqlite3_value_text( columnMem(pStmt,i) );
69929 columnMallocFailure(pStmt);
69930 return val;
69931 }
69932 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt *pStmt, int i){
69933 Mem *pOut = columnMem(pStmt, i);
69934 if( pOut->flags&MEM_Static ){
69935 pOut->flags &= ~MEM_Static;
69936 pOut->flags |= MEM_Ephem;
69937 }
69938 columnMallocFailure(pStmt);
69939 return (sqlite3_value *)pOut;
69940 }
69941 #ifndef SQLITE_OMIT_UTF16
69942 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt *pStmt, int i){
69943 const void *val = sqlite3_value_text16( columnMem(pStmt,i) );
69944 columnMallocFailure(pStmt);
69945 return val;
69946 }
69947 #endif /* SQLITE_OMIT_UTF16 */
69948 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt *pStmt, int i){
69949 int iType = sqlite3_value_type( columnMem(pStmt,i) );
69950 columnMallocFailure(pStmt);
69951 return iType;
69952 }
69953
@@ -69798,16 +70007,16 @@
70007
70008 /*
70009 ** Return the name of the Nth column of the result set returned by SQL
70010 ** statement pStmt.
70011 */
70012 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt *pStmt, int N){
70013 return columnName(
70014 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_NAME);
70015 }
70016 #ifndef SQLITE_OMIT_UTF16
70017 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt *pStmt, int N){
70018 return columnName(
70019 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_NAME);
70020 }
70021 #endif
70022
@@ -69823,16 +70032,16 @@
70032 #ifndef SQLITE_OMIT_DECLTYPE
70033 /*
70034 ** Return the column declaration type (if applicable) of the 'i'th column
70035 ** of the result set of SQL statement pStmt.
70036 */
70037 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt *pStmt, int N){
70038 return columnName(
70039 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DECLTYPE);
70040 }
70041 #ifndef SQLITE_OMIT_UTF16
70042 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt *pStmt, int N){
70043 return columnName(
70044 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DECLTYPE);
70045 }
70046 #endif /* SQLITE_OMIT_UTF16 */
70047 #endif /* SQLITE_OMIT_DECLTYPE */
@@ -69841,16 +70050,16 @@
70050 /*
70051 ** Return the name of the database from which a result column derives.
70052 ** NULL is returned if the result column is an expression or constant or
70053 ** anything else which is not an unambiguous reference to a database column.
70054 */
70055 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt *pStmt, int N){
70056 return columnName(
70057 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_DATABASE);
70058 }
70059 #ifndef SQLITE_OMIT_UTF16
70060 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt *pStmt, int N){
70061 return columnName(
70062 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_DATABASE);
70063 }
70064 #endif /* SQLITE_OMIT_UTF16 */
70065
@@ -69857,16 +70066,16 @@
70066 /*
70067 ** Return the name of the table from which a result column derives.
70068 ** NULL is returned if the result column is an expression or constant or
70069 ** anything else which is not an unambiguous reference to a database column.
70070 */
70071 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt *pStmt, int N){
70072 return columnName(
70073 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_TABLE);
70074 }
70075 #ifndef SQLITE_OMIT_UTF16
70076 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt *pStmt, int N){
70077 return columnName(
70078 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_TABLE);
70079 }
70080 #endif /* SQLITE_OMIT_UTF16 */
70081
@@ -69873,16 +70082,16 @@
70082 /*
70083 ** Return the name of the table column from which a result column derives.
70084 ** NULL is returned if the result column is an expression or constant or
70085 ** anything else which is not an unambiguous reference to a database column.
70086 */
70087 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt *pStmt, int N){
70088 return columnName(
70089 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text, COLNAME_COLUMN);
70090 }
70091 #ifndef SQLITE_OMIT_UTF16
70092 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt *pStmt, int N){
70093 return columnName(
70094 pStmt, N, (const void*(*)(Mem*))sqlite3_value_text16, COLNAME_COLUMN);
70095 }
70096 #endif /* SQLITE_OMIT_UTF16 */
70097 #endif /* SQLITE_ENABLE_COLUMN_METADATA */
@@ -69979,20 +70188,20 @@
70188
70189
70190 /*
70191 ** Bind a blob value to an SQL statement variable.
70192 */
70193 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(
70194 sqlite3_stmt *pStmt,
70195 int i,
70196 const void *zData,
70197 int nData,
70198 void (*xDel)(void*)
70199 ){
70200 return bindText(pStmt, i, zData, nData, xDel, 0);
70201 }
70202 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(
70203 sqlite3_stmt *pStmt,
70204 int i,
70205 const void *zData,
70206 sqlite3_uint64 nData,
70207 void (*xDel)(void*)
@@ -70002,52 +70211,52 @@
70211 return invokeValueDestructor(zData, xDel, 0);
70212 }else{
70213 return bindText(pStmt, i, zData, (int)nData, xDel, 0);
70214 }
70215 }
70216 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt *pStmt, int i, double rValue){
70217 int rc;
70218 Vdbe *p = (Vdbe *)pStmt;
70219 rc = vdbeUnbind(p, i);
70220 if( rc==SQLITE_OK ){
70221 sqlite3VdbeMemSetDouble(&p->aVar[i-1], rValue);
70222 sqlite3_mutex_leave(p->db->mutex);
70223 }
70224 return rc;
70225 }
70226 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt *p, int i, int iValue){
70227 return sqlite3_bind_int64(p, i, (i64)iValue);
70228 }
70229 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt *pStmt, int i, sqlite_int64 iValue){
70230 int rc;
70231 Vdbe *p = (Vdbe *)pStmt;
70232 rc = vdbeUnbind(p, i);
70233 if( rc==SQLITE_OK ){
70234 sqlite3VdbeMemSetInt64(&p->aVar[i-1], iValue);
70235 sqlite3_mutex_leave(p->db->mutex);
70236 }
70237 return rc;
70238 }
70239 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt *pStmt, int i){
70240 int rc;
70241 Vdbe *p = (Vdbe*)pStmt;
70242 rc = vdbeUnbind(p, i);
70243 if( rc==SQLITE_OK ){
70244 sqlite3_mutex_leave(p->db->mutex);
70245 }
70246 return rc;
70247 }
70248 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(
70249 sqlite3_stmt *pStmt,
70250 int i,
70251 const char *zData,
70252 int nData,
70253 void (*xDel)(void*)
70254 ){
70255 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF8);
70256 }
70257 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(
70258 sqlite3_stmt *pStmt,
70259 int i,
70260 const char *zData,
70261 sqlite3_uint64 nData,
70262 void (*xDel)(void*),
@@ -70060,21 +70269,21 @@
70269 if( enc==SQLITE_UTF16 ) enc = SQLITE_UTF16NATIVE;
70270 return bindText(pStmt, i, zData, (int)nData, xDel, enc);
70271 }
70272 }
70273 #ifndef SQLITE_OMIT_UTF16
70274 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(
70275 sqlite3_stmt *pStmt,
70276 int i,
70277 const void *zData,
70278 int nData,
70279 void (*xDel)(void*)
70280 ){
70281 return bindText(pStmt, i, zData, nData, xDel, SQLITE_UTF16NATIVE);
70282 }
70283 #endif /* SQLITE_OMIT_UTF16 */
70284 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt *pStmt, int i, const sqlite3_value *pValue){
70285 int rc;
70286 switch( sqlite3_value_type((sqlite3_value*)pValue) ){
70287 case SQLITE_INTEGER: {
70288 rc = sqlite3_bind_int64(pStmt, i, pValue->u.i);
70289 break;
@@ -70101,11 +70310,11 @@
70310 break;
70311 }
70312 }
70313 return rc;
70314 }
70315 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt *pStmt, int i, int n){
70316 int rc;
70317 Vdbe *p = (Vdbe *)pStmt;
70318 rc = vdbeUnbind(p, i);
70319 if( rc==SQLITE_OK ){
70320 sqlite3VdbeMemSetZeroBlob(&p->aVar[i-1], n);
@@ -70116,11 +70325,11 @@
70325
70326 /*
70327 ** Return the number of wildcards that can be potentially bound to.
70328 ** This routine is added to support DBD::SQLite.
70329 */
70330 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt *pStmt){
70331 Vdbe *p = (Vdbe*)pStmt;
70332 return p ? p->nVar : 0;
70333 }
70334
70335 /*
@@ -70127,11 +70336,11 @@
70336 ** Return the name of a wildcard parameter. Return NULL if the index
70337 ** is out of range or if the wildcard is unnamed.
70338 **
70339 ** The result is always UTF-8.
70340 */
70341 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt *pStmt, int i){
70342 Vdbe *p = (Vdbe*)pStmt;
70343 if( p==0 || i<1 || i>p->nzVar ){
70344 return 0;
70345 }
70346 return p->azVar[i-1];
@@ -70155,11 +70364,11 @@
70364 }
70365 }
70366 }
70367 return 0;
70368 }
70369 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt *pStmt, const char *zName){
70370 return sqlite3VdbeParameterIndex((Vdbe*)pStmt, zName, sqlite3Strlen30(zName));
70371 }
70372
70373 /*
70374 ** Transfer all bindings from the first statement over to the second.
@@ -70189,11 +70398,11 @@
70398 **
70399 ** If the two statements contain a different number of bindings, then
70400 ** an SQLITE_ERROR is returned. Nothing else can go wrong, so otherwise
70401 ** SQLITE_OK is returned.
70402 */
70403 SQLITE_API int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt *pFromStmt, sqlite3_stmt *pToStmt){
70404 Vdbe *pFrom = (Vdbe*)pFromStmt;
70405 Vdbe *pTo = (Vdbe*)pToStmt;
70406 if( pFrom->nVar!=pTo->nVar ){
70407 return SQLITE_ERROR;
70408 }
@@ -70211,26 +70420,26 @@
70420 ** Return the sqlite3* database handle to which the prepared statement given
70421 ** in the argument belongs. This is the same database handle that was
70422 ** the first argument to the sqlite3_prepare() that was used to create
70423 ** the statement in the first place.
70424 */
70425 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt *pStmt){
70426 return pStmt ? ((Vdbe*)pStmt)->db : 0;
70427 }
70428
70429 /*
70430 ** Return true if the prepared statement is guaranteed to not modify the
70431 ** database.
70432 */
70433 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt){
70434 return pStmt ? ((Vdbe*)pStmt)->readOnly : 1;
70435 }
70436
70437 /*
70438 ** Return true if the prepared statement is in need of being reset.
70439 */
70440 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt *pStmt){
70441 Vdbe *v = (Vdbe*)pStmt;
70442 return v!=0 && v->pc>=0 && v->magic==VDBE_MAGIC_RUN;
70443 }
70444
70445 /*
@@ -70237,11 +70446,11 @@
70446 ** Return a pointer to the next prepared statement after pStmt associated
70447 ** with database connection pDb. If pStmt is NULL, return the first
70448 ** prepared statement for the database connection. Return NULL if there
70449 ** are no more.
70450 */
70451 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt){
70452 sqlite3_stmt *pNext;
70453 #ifdef SQLITE_ENABLE_API_ARMOR
70454 if( !sqlite3SafetyCheckOk(pDb) ){
70455 (void)SQLITE_MISUSE_BKPT;
70456 return 0;
@@ -70258,11 +70467,11 @@
70467 }
70468
70469 /*
70470 ** Return the value of a status counter for a prepared statement
70471 */
70472 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt *pStmt, int op, int resetFlag){
70473 Vdbe *pVdbe = (Vdbe*)pStmt;
70474 u32 v;
70475 #ifdef SQLITE_ENABLE_API_ARMOR
70476 if( !pStmt ){
70477 (void)SQLITE_MISUSE_BKPT;
@@ -70276,11 +70485,11 @@
70485
70486 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
70487 /*
70488 ** Return status data for a single loop within query pStmt.
70489 */
70490 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_scanstatus(
70491 sqlite3_stmt *pStmt, /* Prepared statement being queried */
70492 int idx, /* Index of loop to report on */
70493 int iScanStatusOp, /* Which metric to return */
70494 void *pOut /* OUT: Write the answer here */
70495 ){
@@ -70335,11 +70544,11 @@
70544 }
70545
70546 /*
70547 ** Zero all counters associated with the sqlite3_stmt_scanstatus() data.
70548 */
70549 SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt *pStmt){
70550 Vdbe *p = (Vdbe*)pStmt;
70551 memset(p->anExec, 0, p->nOp * sizeof(i64));
70552 }
70553 #endif /* SQLITE_ENABLE_STMT_SCANSTATUS */
70554
@@ -70427,21 +70636,22 @@
70636 Mem *pVar; /* Value of a host parameter */
70637 StrAccum out; /* Accumulate the output here */
70638 char zBase[100]; /* Initial working space */
70639
70640 db = p->db;
70641 sqlite3StrAccumInit(&out, db, zBase, sizeof(zBase),
70642 db->aLimit[SQLITE_LIMIT_LENGTH]);
 
70643 if( db->nVdbeExec>1 ){
70644 while( *zRawSql ){
70645 const char *zStart = zRawSql;
70646 while( *(zRawSql++)!='\n' && *zRawSql );
70647 sqlite3StrAccumAppend(&out, "-- ", 3);
70648 assert( (zRawSql - zStart) > 0 );
70649 sqlite3StrAccumAppend(&out, zStart, (int)(zRawSql-zStart));
70650 }
70651 }else if( p->nVar==0 ){
70652 sqlite3StrAccumAppend(&out, zRawSql, sqlite3Strlen30(zRawSql));
70653 }else{
70654 while( zRawSql[0] ){
70655 n = findNextHostParameter(zRawSql, &nToken);
70656 assert( n>0 );
70657 sqlite3StrAccumAppend(&out, zRawSql, n);
@@ -70454,14 +70664,16 @@
70664 sqlite3GetInt32(&zRawSql[1], &idx);
70665 }else{
70666 idx = nextIndex;
70667 }
70668 }else{
70669 assert( zRawSql[0]==':' || zRawSql[0]=='$' ||
70670 zRawSql[0]=='@' || zRawSql[0]=='#' );
70671 testcase( zRawSql[0]==':' );
70672 testcase( zRawSql[0]=='$' );
70673 testcase( zRawSql[0]=='@' );
70674 testcase( zRawSql[0]=='#' );
70675 idx = sqlite3VdbeParameterIndex(p, zRawSql, nToken);
70676 assert( idx>0 );
70677 }
70678 zRawSql += nToken;
70679 nextIndex = idx + 1;
@@ -70834,11 +71046,11 @@
71046 ** Try to convert the type of a function argument or a result column
71047 ** into a numeric representation. Use either INTEGER or REAL whichever
71048 ** is appropriate. But only do the conversion if it is possible without
71049 ** loss of information and return the revised type of the argument.
71050 */
71051 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value *pVal){
71052 int eType = sqlite3_value_type(pVal);
71053 if( eType==SQLITE_TEXT ){
71054 Mem *pMem = (Mem*)pVal;
71055 applyNumericAffinity(pMem, 0);
71056 eType = sqlite3_value_type(pVal);
@@ -71132,21 +71344,38 @@
71344 assert( n==(db->nSavepoint + db->isTransactionSavepoint) );
71345 return 1;
71346 }
71347 #endif
71348
71349 /*
71350 ** Return the register of pOp->p2 after first preparing it to be
71351 ** overwritten with an integer value.
71352 */
71353 static Mem *out2Prerelease(Vdbe *p, VdbeOp *pOp){
71354 Mem *pOut;
71355 assert( pOp->p2>0 );
71356 assert( pOp->p2<=(p->nMem-p->nCursor) );
71357 pOut = &p->aMem[pOp->p2];
71358 memAboutToChange(p, pOut);
71359 if( VdbeMemDynamic(pOut) ) sqlite3VdbeMemSetNull(pOut);
71360 pOut->flags = MEM_Int;
71361 return pOut;
71362 }
71363
71364
71365 /*
71366 ** Execute as much of a VDBE program as we can.
71367 ** This is the core of sqlite3_step().
71368 */
71369 SQLITE_PRIVATE int sqlite3VdbeExec(
71370 Vdbe *p /* The VDBE */
71371 ){
 
71372 Op *aOp = p->aOp; /* Copy of p->aOp */
71373 Op *pOp = aOp; /* Current operation */
71374 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
71375 Op *pOrigOp; /* Value of pOp at the top of the loop */
71376 #endif
71377 int rc = SQLITE_OK; /* Value to return */
71378 sqlite3 *db = p->db; /* The database */
71379 u8 resetSchemaOnFault = 0; /* Reset schema after an error if positive */
71380 u8 encoding = ENC(db); /* The database encoding */
71381 int iCompare = 0; /* Result of last OP_Compare operation */
@@ -71218,27 +71447,26 @@
71447 }
71448 if( p->db->flags & SQLITE_VdbeTrace ) printf("VDBE Trace:\n");
71449 }
71450 sqlite3EndBenignMalloc();
71451 #endif
71452 for(pOp=&aOp[p->pc]; rc==SQLITE_OK; pOp++){
71453 assert( pOp>=aOp && pOp<&aOp[p->nOp]);
71454 if( db->mallocFailed ) goto no_mem;
71455 #ifdef VDBE_PROFILE
71456 start = sqlite3Hwtime();
71457 #endif
71458 nVmStep++;
 
71459 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
71460 if( p->anExec ) p->anExec[(int)(pOp-aOp)]++;
71461 #endif
71462
71463 /* Only allow tracing if SQLITE_DEBUG is defined.
71464 */
71465 #ifdef SQLITE_DEBUG
71466 if( db->flags & SQLITE_VdbeTrace ){
71467 sqlite3VdbePrintOp(stdout, (int)(pOp - aOp), pOp);
71468 }
71469 #endif
71470
71471
71472 /* Check to see if we need to simulate an interrupt. This only happens
@@ -71251,27 +71479,13 @@
71479 sqlite3_interrupt(db);
71480 }
71481 }
71482 #endif
71483
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
71484 /* Sanity checking on other operands */
71485 #ifdef SQLITE_DEBUG
71486 assert( pOp->opflags==sqlite3OpcodeProperty[pOp->opcode] );
71487 if( (pOp->opflags & OPFLG_IN1)!=0 ){
71488 assert( pOp->p1>0 );
71489 assert( pOp->p1<=(p->nMem-p->nCursor) );
71490 assert( memIsValid(&aMem[pOp->p1]) );
71491 assert( sqlite3VdbeCheckMemInvariants(&aMem[pOp->p1]) );
@@ -71300,10 +71514,13 @@
71514 assert( pOp->p3>0 );
71515 assert( pOp->p3<=(p->nMem-p->nCursor) );
71516 memAboutToChange(p, &aMem[pOp->p3]);
71517 }
71518 #endif
71519 #if defined(SQLITE_DEBUG) || defined(VDBE_PROFILE)
71520 pOrigOp = pOp;
71521 #endif
71522
71523 switch( pOp->opcode ){
71524
71525 /*****************************************************************************
71526 ** What follows is a massive switch statement where each case implements a
@@ -71323,11 +71540,11 @@
71540 ** case statement is followed by a comment of the form "/# same as ... #/"
71541 ** that comment is used to determine the particular value of the opcode.
71542 **
71543 ** Other keywords in the comment that follows each case are used to
71544 ** construct the OPFLG_INITIALIZER value that initializes opcodeProperty[].
71545 ** Keywords include: in1, in2, in3, out2, out3. See
71546 ** the mkopcodeh.awk script for additional information.
71547 **
71548 ** Documentation about VDBE opcodes is generated by scanning this file
71549 ** for lines of that contain "Opcode:". That line and all subsequent
71550 ** comment lines are used in the generation of the opcode.html documentation
@@ -71351,11 +71568,12 @@
71568 ** is sometimes set to 1 instead of 0 as a hint to the command-line shell
71569 ** that this Goto is the bottom of a loop and that the lines from P2 down
71570 ** to the current line should be indented for EXPLAIN output.
71571 */
71572 case OP_Goto: { /* jump */
71573 jump_to_p2_and_check_for_interrupt:
71574 pOp = &aOp[pOp->p2 - 1];
71575
71576 /* Opcodes that are used as the bottom of a loop (OP_Next, OP_Prev,
71577 ** OP_VNext, OP_RowSetNext, or OP_SorterNext) all jump here upon
71578 ** completion. Check to see if sqlite3_interrupt() has been called
71579 ** or if the progress callback needs to be invoked.
@@ -71396,13 +71614,17 @@
71614 assert( pOp->p1>0 && pOp->p1<=(p->nMem-p->nCursor) );
71615 pIn1 = &aMem[pOp->p1];
71616 assert( VdbeMemDynamic(pIn1)==0 );
71617 memAboutToChange(p, pIn1);
71618 pIn1->flags = MEM_Int;
71619 pIn1->u.i = (int)(pOp-aOp);
71620 REGISTER_TRACE(pOp->p1, pIn1);
71621
71622 /* Most jump operations do a goto to this spot in order to update
71623 ** the pOp pointer. */
71624 jump_to_p2:
71625 pOp = &aOp[pOp->p2 - 1];
71626 break;
71627 }
71628
71629 /* Opcode: Return P1 * * * *
71630 **
@@ -71410,11 +71632,11 @@
71632 ** the jump, register P1 becomes undefined.
71633 */
71634 case OP_Return: { /* in1 */
71635 pIn1 = &aMem[pOp->p1];
71636 assert( pIn1->flags==MEM_Int );
71637 pOp = &aOp[pIn1->u.i];
71638 pIn1->flags = MEM_Undefined;
71639 break;
71640 }
71641
71642 /* Opcode: InitCoroutine P1 P2 P3 * *
@@ -71434,11 +71656,11 @@
71656 assert( pOp->p3>=0 && pOp->p3<p->nOp );
71657 pOut = &aMem[pOp->p1];
71658 assert( !VdbeMemDynamic(pOut) );
71659 pOut->u.i = pOp->p3 - 1;
71660 pOut->flags = MEM_Int;
71661 if( pOp->p2 ) goto jump_to_p2;
71662 break;
71663 }
71664
71665 /* Opcode: EndCoroutine P1 * * * *
71666 **
@@ -71454,11 +71676,11 @@
71676 assert( pIn1->flags==MEM_Int );
71677 assert( pIn1->u.i>=0 && pIn1->u.i<p->nOp );
71678 pCaller = &aOp[pIn1->u.i];
71679 assert( pCaller->opcode==OP_Yield );
71680 assert( pCaller->p2>=0 && pCaller->p2<p->nOp );
71681 pOp = &aOp[pCaller->p2 - 1];
71682 pIn1->flags = MEM_Undefined;
71683 break;
71684 }
71685
71686 /* Opcode: Yield P1 P2 * * *
@@ -71478,13 +71700,13 @@
71700 int pcDest;
71701 pIn1 = &aMem[pOp->p1];
71702 assert( VdbeMemDynamic(pIn1)==0 );
71703 pIn1->flags = MEM_Int;
71704 pcDest = (int)pIn1->u.i;
71705 pIn1->u.i = (int)(pOp - aOp);
71706 REGISTER_TRACE(pOp->p1, pIn1);
71707 pOp = &aOp[pcDest];
71708 break;
71709 }
71710
71711 /* Opcode: HaltIfNull P1 P2 P3 P4 P5
71712 ** Synopsis: if r[P3]=null halt
@@ -71531,34 +71753,38 @@
71753 ** is the same as executing Halt.
71754 */
71755 case OP_Halt: {
71756 const char *zType;
71757 const char *zLogFmt;
71758 VdbeFrame *pFrame;
71759 int pcx;
71760
71761 pcx = (int)(pOp - aOp);
71762 if( pOp->p1==SQLITE_OK && p->pFrame ){
71763 /* Halt the sub-program. Return control to the parent frame. */
71764 pFrame = p->pFrame;
71765 p->pFrame = pFrame->pParent;
71766 p->nFrame--;
71767 sqlite3VdbeSetChanges(db, p->nChange);
71768 pcx = sqlite3VdbeFrameRestore(pFrame);
71769 lastRowid = db->lastRowid;
71770 if( pOp->p2==OE_Ignore ){
71771 /* Instruction pcx is the OP_Program that invoked the sub-program
71772 ** currently being halted. If the p2 instruction of this OP_Halt
71773 ** instruction is set to OE_Ignore, then the sub-program is throwing
71774 ** an IGNORE exception. In this case jump to the address specified
71775 ** as the p2 of the calling OP_Program. */
71776 pcx = p->aOp[pcx].p2-1;
71777 }
71778 aOp = p->aOp;
71779 aMem = p->aMem;
71780 pOp = &aOp[pcx];
71781 break;
71782 }
71783 p->rc = pOp->p1;
71784 p->errorAction = (u8)pOp->p2;
71785 p->pc = pcx;
71786 if( p->rc ){
71787 if( pOp->p5 ){
71788 static const char * const azType[] = { "NOT NULL", "UNIQUE", "CHECK",
71789 "FOREIGN KEY" };
71790 assert( pOp->p5>=1 && pOp->p5<=4 );
@@ -71578,11 +71804,11 @@
71804 }else if( pOp->p4.z ){
71805 sqlite3SetString(&p->zErrMsg, db, "%s", pOp->p4.z);
71806 }else{
71807 sqlite3SetString(&p->zErrMsg, db, "%s constraint failed", zType);
71808 }
71809 sqlite3_log(pOp->p1, zLogFmt, pcx, p->zSql, p->zErrMsg);
71810 }
71811 rc = sqlite3VdbeHalt(p);
71812 assert( rc==SQLITE_BUSY || rc==SQLITE_OK || rc==SQLITE_ERROR );
71813 if( rc==SQLITE_BUSY ){
71814 p->rc = rc = SQLITE_BUSY;
@@ -71597,11 +71823,12 @@
71823 /* Opcode: Integer P1 P2 * * *
71824 ** Synopsis: r[P2]=P1
71825 **
71826 ** The 32-bit integer value P1 is written into register P2.
71827 */
71828 case OP_Integer: { /* out2 */
71829 pOut = out2Prerelease(p, pOp);
71830 pOut->u.i = pOp->p1;
71831 break;
71832 }
71833
71834 /* Opcode: Int64 * P2 * P4 *
@@ -71608,11 +71835,12 @@
71835 ** Synopsis: r[P2]=P4
71836 **
71837 ** P4 is a pointer to a 64-bit integer value.
71838 ** Write that value into register P2.
71839 */
71840 case OP_Int64: { /* out2 */
71841 pOut = out2Prerelease(p, pOp);
71842 assert( pOp->p4.pI64!=0 );
71843 pOut->u.i = *pOp->p4.pI64;
71844 break;
71845 }
71846
@@ -71621,11 +71849,12 @@
71849 ** Synopsis: r[P2]=P4
71850 **
71851 ** P4 is a pointer to a 64-bit floating point value.
71852 ** Write that value into register P2.
71853 */
71854 case OP_Real: { /* same as TK_FLOAT, out2 */
71855 pOut = out2Prerelease(p, pOp);
71856 pOut->flags = MEM_Real;
71857 assert( !sqlite3IsNaN(*pOp->p4.pReal) );
71858 pOut->u.r = *pOp->p4.pReal;
71859 break;
71860 }
@@ -71637,12 +71866,13 @@
71866 ** P4 points to a nul terminated UTF-8 string. This opcode is transformed
71867 ** into a String opcode before it is executed for the first time. During
71868 ** this transformation, the length of string P4 is computed and stored
71869 ** as the P1 parameter.
71870 */
71871 case OP_String8: { /* same as TK_STRING, out2 */
71872 assert( pOp->p4.z!=0 );
71873 pOut = out2Prerelease(p, pOp);
71874 pOp->opcode = OP_String;
71875 pOp->p1 = sqlite3Strlen30(pOp->p4.z);
71876
71877 #ifndef SQLITE_OMIT_UTF16
71878 if( encoding!=SQLITE_UTF8 ){
@@ -71675,12 +71905,13 @@
71905 ** If P5!=0 and the content of register P3 is greater than zero, then
71906 ** the datatype of the register P2 is converted to BLOB. The content is
71907 ** the same sequence of bytes, it is merely interpreted as a BLOB instead
71908 ** of a string, as if it had been CAST.
71909 */
71910 case OP_String: { /* out2 */
71911 assert( pOp->p4.z!=0 );
71912 pOut = out2Prerelease(p, pOp);
71913 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
71914 pOut->z = pOp->p4.z;
71915 pOut->n = pOp->p1;
71916 pOut->enc = encoding;
71917 UPDATE_MAX_BLOBSIZE(pOut);
@@ -71704,13 +71935,14 @@
71935 **
71936 ** If the P1 value is non-zero, then also set the MEM_Cleared flag so that
71937 ** NULL values will not compare equal even if SQLITE_NULLEQ is set on
71938 ** OP_Ne or OP_Eq.
71939 */
71940 case OP_Null: { /* out2 */
71941 int cnt;
71942 u16 nullFlag;
71943 pOut = out2Prerelease(p, pOp);
71944 cnt = pOp->p3-pOp->p2;
71945 assert( pOp->p3<=(p->nMem-p->nCursor) );
71946 pOut->flags = nullFlag = pOp->p1 ? (MEM_Null|MEM_Cleared) : MEM_Null;
71947 while( cnt>0 ){
71948 pOut++;
@@ -71741,12 +71973,13 @@
71973 ** Synopsis: r[P2]=P4 (len=P1)
71974 **
71975 ** P4 points to a blob of data P1 bytes long. Store this
71976 ** blob in register P2.
71977 */
71978 case OP_Blob: { /* out2 */
71979 assert( pOp->p1 <= SQLITE_MAX_LENGTH );
71980 pOut = out2Prerelease(p, pOp);
71981 sqlite3VdbeMemSetStr(pOut, pOp->p4.z, pOp->p1, 0, 0);
71982 pOut->enc = encoding;
71983 UPDATE_MAX_BLOBSIZE(pOut);
71984 break;
71985 }
@@ -71757,19 +71990,20 @@
71990 ** Transfer the values of bound parameter P1 into register P2
71991 **
71992 ** If the parameter is named, then its name appears in P4.
71993 ** The P4 value is used by sqlite3_bind_parameter_name().
71994 */
71995 case OP_Variable: { /* out2 */
71996 Mem *pVar; /* Value being transferred */
71997
71998 assert( pOp->p1>0 && pOp->p1<=p->nVar );
71999 assert( pOp->p4.z==0 || pOp->p4.z==p->azVar[pOp->p1-1] );
72000 pVar = &p->aVar[pOp->p1 - 1];
72001 if( sqlite3VdbeMemTooBig(pVar) ){
72002 goto too_big;
72003 }
72004 pOut = out2Prerelease(p, pOp);
72005 sqlite3VdbeMemShallowCopy(pOut, pVar, MEM_Static);
72006 UPDATE_MAX_BLOBSIZE(pOut);
72007 break;
72008 }
72009
@@ -71800,14 +72034,15 @@
72034 assert( pIn1<=&aMem[(p->nMem-p->nCursor)] );
72035 assert( memIsValid(pIn1) );
72036 memAboutToChange(p, pOut);
72037 sqlite3VdbeMemMove(pOut, pIn1);
72038 #ifdef SQLITE_DEBUG
72039 if( pOut->pScopyFrom>=&aMem[p1] && pOut->pScopyFrom<pOut ){
72040 pOut->pScopyFrom += pOp->p2 - p1;
72041 }
72042 #endif
72043 Deephemeralize(pOut);
72044 REGISTER_TRACE(p2++, pOut);
72045 pIn1++;
72046 pOut++;
72047 }while( --n );
72048 break;
@@ -71942,11 +72177,11 @@
72177 }
72178 if( db->mallocFailed ) goto no_mem;
72179
72180 /* Return SQLITE_ROW
72181 */
72182 p->pc = (int)(pOp - aOp) + 1;
72183 rc = SQLITE_ROW;
72184 goto vdbe_return;
72185 }
72186
72187 /* Opcode: Concat P1 P2 P3 * *
@@ -72188,11 +72423,11 @@
72423 REGISTER_TRACE(pOp->p2+i, pArg);
72424 }
72425
72426 assert( pOp->p4type==P4_FUNCDEF );
72427 ctx.pFunc = pOp->p4.pFunc;
72428 ctx.iOp = (int)(pOp - aOp);
72429 ctx.pVdbe = p;
72430 MemSetTypeFlag(ctx.pOut, MEM_Null);
72431 ctx.fErrorOrAux = 0;
72432 db->lastRowid = lastRowid;
72433 (*ctx.pFunc->xFunc)(&ctx, n, apVal); /* IMP: R-24505-23230 */
@@ -72202,11 +72437,11 @@
72437 if( ctx.fErrorOrAux ){
72438 if( ctx.isError ){
72439 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(ctx.pOut));
72440 rc = ctx.isError;
72441 }
72442 sqlite3VdbeDeleteAuxData(p, (int)(pOp - aOp), pOp->p1);
72443 }
72444
72445 /* Copy the result of the function into register P3 */
72446 sqlite3VdbeChangeEncoding(ctx.pOut, encoding);
72447 if( sqlite3VdbeMemTooBig(ctx.pOut) ){
@@ -72331,12 +72566,11 @@
72566 if( (pIn1->flags & MEM_Int)==0 ){
72567 if( pOp->p2==0 ){
72568 rc = SQLITE_MISMATCH;
72569 goto abort_due_to_error;
72570 }else{
72571 goto jump_to_p2;
 
72572 }
72573 }
72574 }
72575 MemSetTypeFlag(pIn1, MEM_Int);
72576 break;
@@ -72518,11 +72752,11 @@
72752 MemSetTypeFlag(pOut, MEM_Null);
72753 REGISTER_TRACE(pOp->p2, pOut);
72754 }else{
72755 VdbeBranchTaken(2,3);
72756 if( pOp->p5 & SQLITE_JUMPIFNULL ){
72757 goto jump_to_p2;
72758 }
72759 }
72760 break;
72761 }
72762 }else{
@@ -72538,15 +72772,19 @@
72772 }else if( affinity==SQLITE_AFF_TEXT ){
72773 if( (pIn1->flags & MEM_Str)==0 && (pIn1->flags & (MEM_Int|MEM_Real))!=0 ){
72774 testcase( pIn1->flags & MEM_Int );
72775 testcase( pIn1->flags & MEM_Real );
72776 sqlite3VdbeMemStringify(pIn1, encoding, 1);
72777 testcase( (flags1&MEM_Dyn) != (pIn1->flags&MEM_Dyn) );
72778 flags1 = (pIn1->flags & ~MEM_TypeMask) | (flags1 & MEM_TypeMask);
72779 }
72780 if( (pIn3->flags & MEM_Str)==0 && (pIn3->flags & (MEM_Int|MEM_Real))!=0 ){
72781 testcase( pIn3->flags & MEM_Int );
72782 testcase( pIn3->flags & MEM_Real );
72783 sqlite3VdbeMemStringify(pIn3, encoding, 1);
72784 testcase( (flags3&MEM_Dyn) != (pIn3->flags&MEM_Dyn) );
72785 flags3 = (pIn3->flags & ~MEM_TypeMask) | (flags3 & MEM_TypeMask);
72786 }
72787 }
72788 assert( pOp->p4type==P4_COLLSEQ || pOp->p4.pColl==0 );
72789 if( pIn1->flags & MEM_Zero ){
72790 sqlite3VdbeMemExpandBlob(pIn1);
@@ -72565,10 +72803,16 @@
72803 case OP_Lt: res = res<0; break;
72804 case OP_Le: res = res<=0; break;
72805 case OP_Gt: res = res>0; break;
72806 default: res = res>=0; break;
72807 }
72808
72809 /* Undo any changes made by applyAffinity() to the input registers. */
72810 assert( (pIn1->flags & MEM_Dyn) == (flags1 & MEM_Dyn) );
72811 pIn1->flags = flags1;
72812 assert( (pIn3->flags & MEM_Dyn) == (flags3 & MEM_Dyn) );
72813 pIn3->flags = flags3;
72814
72815 if( pOp->p5 & SQLITE_STOREP2 ){
72816 pOut = &aMem[pOp->p2];
72817 memAboutToChange(p, pOut);
72818 MemSetTypeFlag(pOut, MEM_Int);
@@ -72575,16 +72819,13 @@
72819 pOut->u.i = res;
72820 REGISTER_TRACE(pOp->p2, pOut);
72821 }else{
72822 VdbeBranchTaken(res!=0, (pOp->p5 & SQLITE_NULLEQ)?2:3);
72823 if( res ){
72824 goto jump_to_p2;
72825 }
72826 }
 
 
 
72827 break;
72828 }
72829
72830 /* Opcode: Permutation * * * P4 *
72831 **
@@ -72675,15 +72916,15 @@
72916 ** in the most recent OP_Compare instruction the P1 vector was less than
72917 ** equal to, or greater than the P2 vector, respectively.
72918 */
72919 case OP_Jump: { /* jump */
72920 if( iCompare<0 ){
72921 VdbeBranchTaken(0,3); pOp = &aOp[pOp->p1 - 1];
72922 }else if( iCompare==0 ){
72923 VdbeBranchTaken(1,3); pOp = &aOp[pOp->p2 - 1];
72924 }else{
72925 VdbeBranchTaken(2,3); pOp = &aOp[pOp->p3 - 1];
72926 }
72927 break;
72928 }
72929
72930 /* Opcode: And P1 P2 P3 * *
@@ -72789,11 +73030,11 @@
73030 */
73031 case OP_Once: { /* jump */
73032 assert( pOp->p1<p->nOnceFlag );
73033 VdbeBranchTaken(p->aOnceFlag[pOp->p1]!=0, 2);
73034 if( p->aOnceFlag[pOp->p1] ){
73035 goto jump_to_p2;
73036 }else{
73037 p->aOnceFlag[pOp->p1] = 1;
73038 }
73039 break;
73040 }
@@ -72824,11 +73065,11 @@
73065 #endif
73066 if( pOp->opcode==OP_IfNot ) c = !c;
73067 }
73068 VdbeBranchTaken(c!=0, 2);
73069 if( c ){
73070 goto jump_to_p2;
73071 }
73072 break;
73073 }
73074
73075 /* Opcode: IsNull P1 P2 * * *
@@ -72838,11 +73079,11 @@
73079 */
73080 case OP_IsNull: { /* same as TK_ISNULL, jump, in1 */
73081 pIn1 = &aMem[pOp->p1];
73082 VdbeBranchTaken( (pIn1->flags & MEM_Null)!=0, 2);
73083 if( (pIn1->flags & MEM_Null)!=0 ){
73084 goto jump_to_p2;
73085 }
73086 break;
73087 }
73088
73089 /* Opcode: NotNull P1 P2 * * *
@@ -72852,11 +73093,11 @@
73093 */
73094 case OP_NotNull: { /* same as TK_NOTNULL, jump, in1 */
73095 pIn1 = &aMem[pOp->p1];
73096 VdbeBranchTaken( (pIn1->flags & MEM_Null)==0, 2);
73097 if( (pIn1->flags & MEM_Null)==0 ){
73098 goto jump_to_p2;
73099 }
73100 break;
73101 }
73102
73103 /* Opcode: Column P1 P2 P3 P4 P5
@@ -73066,11 +73307,11 @@
73307 rc = SQLITE_CORRUPT_BKPT;
73308 goto op_column_error;
73309 }
73310 }
73311
73312 /* If after trying to extract new entries from the header, nHdrParsed is
73313 ** still not up to p2, that means that the record has fewer than p2
73314 ** columns. So the result will be either the default value or a NULL.
73315 */
73316 if( pC->nHdrParsed<=p2 ){
73317 if( pOp->p4type==P4_MEM ){
@@ -73190,11 +73431,11 @@
73431 u8 *zNewRecord; /* A buffer to hold the data for the new record */
73432 Mem *pRec; /* The new record */
73433 u64 nData; /* Number of bytes of data space */
73434 int nHdr; /* Number of bytes of header space */
73435 i64 nByte; /* Data space required for this record */
73436 i64 nZero; /* Number of zero bytes at the end of the record */
73437 int nVarint; /* Number of bytes in a varint */
73438 u32 serial_type; /* Type field */
73439 Mem *pData0; /* First field to be combined into the record */
73440 Mem *pLast; /* Last field of the record */
73441 int nField; /* Number of fields in the record */
@@ -73282,11 +73523,11 @@
73523 nVarint = sqlite3VarintLen(nHdr);
73524 nHdr += nVarint;
73525 if( nVarint<sqlite3VarintLen(nHdr) ) nHdr++;
73526 }
73527 nByte = nHdr+nData;
73528 if( nByte+nZero>db->aLimit[SQLITE_LIMIT_LENGTH] ){
73529 goto too_big;
73530 }
73531
73532 /* Make sure the output register has a buffer large enough to store
73533 ** the new record. The output register (pOp->p3) is not allowed to
@@ -73333,18 +73574,19 @@
73574 **
73575 ** Store the number of entries (an integer value) in the table or index
73576 ** opened by cursor P1 in register P2
73577 */
73578 #ifndef SQLITE_OMIT_BTREECOUNT
73579 case OP_Count: { /* out2 */
73580 i64 nEntry;
73581 BtCursor *pCrsr;
73582
73583 pCrsr = p->apCsr[pOp->p1]->pCursor;
73584 assert( pCrsr );
73585 nEntry = 0; /* Not needed. Only used to silence a warning. */
73586 rc = sqlite3BtreeCount(pCrsr, &nEntry);
73587 pOut = out2Prerelease(p, pOp);
73588 pOut->u.i = nEntry;
73589 break;
73590 }
73591 #endif
73592
@@ -73454,11 +73696,11 @@
73696 if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
73697 goto vdbe_return;
73698 }
73699 db->autoCommit = 1;
73700 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73701 p->pc = (int)(pOp - aOp);
73702 db->autoCommit = 0;
73703 p->rc = rc = SQLITE_BUSY;
73704 goto vdbe_return;
73705 }
73706 db->isTransactionSavepoint = 0;
@@ -73513,11 +73755,11 @@
73755 }else{
73756 db->nDeferredCons = pSavepoint->nDeferredCons;
73757 db->nDeferredImmCons = pSavepoint->nDeferredImmCons;
73758 }
73759
73760 if( !isTransaction || p1==SAVEPOINT_ROLLBACK ){
73761 rc = sqlite3VtabSavepoint(db, p1, iSavepoint);
73762 if( rc!=SQLITE_OK ) goto abort_due_to_error;
73763 }
73764 }
73765 }
@@ -73573,11 +73815,11 @@
73815 }else if( (rc = sqlite3VdbeCheckFk(p, 1))!=SQLITE_OK ){
73816 goto vdbe_return;
73817 }else{
73818 db->autoCommit = (u8)desiredAutoCommit;
73819 if( sqlite3VdbeHalt(p)==SQLITE_BUSY ){
73820 p->pc = (int)(pOp - aOp);
73821 db->autoCommit = (u8)(1-desiredAutoCommit);
73822 p->rc = rc = SQLITE_BUSY;
73823 goto vdbe_return;
73824 }
73825 }
@@ -73650,11 +73892,11 @@
73892 pBt = db->aDb[pOp->p1].pBt;
73893
73894 if( pBt ){
73895 rc = sqlite3BtreeBeginTrans(pBt, pOp->p2);
73896 if( rc==SQLITE_BUSY ){
73897 p->pc = (int)(pOp - aOp);
73898 p->rc = rc = SQLITE_BUSY;
73899 goto vdbe_return;
73900 }
73901 if( rc!=SQLITE_OK ){
73902 goto abort_due_to_error;
@@ -73729,11 +73971,11 @@
73971 **
73972 ** There must be a read-lock on the database (either a transaction
73973 ** must be started or there must be an open cursor) before
73974 ** executing this instruction.
73975 */
73976 case OP_ReadCookie: { /* out2 */
73977 int iMeta;
73978 int iDb;
73979 int iCookie;
73980
73981 assert( p->bIsReader );
@@ -73743,10 +73985,11 @@
73985 assert( iDb>=0 && iDb<db->nDb );
73986 assert( db->aDb[iDb].pBt!=0 );
73987 assert( DbMaskTest(p->btreeMask, iDb) );
73988
73989 sqlite3BtreeGetMeta(db->aDb[iDb].pBt, iCookie, (u32 *)&iMeta);
73990 pOut = out2Prerelease(p, pOp);
73991 pOut->u.i = iMeta;
73992 break;
73993 }
73994
73995 /* Opcode: SetCookie P1 P2 P3 * *
@@ -74064,11 +74307,11 @@
74307 VdbeCursor *pC;
74308 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74309 pC = p->apCsr[pOp->p1];
74310 assert( pC->pSorter );
74311 if( (pC->seqCount++)==0 ){
74312 goto jump_to_p2;
74313 }
74314 break;
74315 }
74316
74317 /* Opcode: OpenPseudo P1 P2 P3 * *
@@ -74241,11 +74484,11 @@
74484 ** loss of information, then special processing is required... */
74485 if( (pIn3->flags & MEM_Int)==0 ){
74486 if( (pIn3->flags & MEM_Real)==0 ){
74487 /* If the P3 value cannot be converted into any kind of a number,
74488 ** then the seek is not possible, so jump to P2 */
74489 VdbeBranchTaken(1,2); goto jump_to_p2;
74490 break;
74491 }
74492
74493 /* If the approximation iKey is larger than the actual real search
74494 ** term, substitute >= for > and < for <=. e.g. if the search term
@@ -74332,11 +74575,11 @@
74575 }
74576 }
74577 assert( pOp->p2>0 );
74578 VdbeBranchTaken(res!=0,2);
74579 if( res ){
74580 goto jump_to_p2;
74581 }
74582 break;
74583 }
74584
74585 /* Opcode: Seek P1 P2 * * *
@@ -74426,10 +74669,11 @@
74669 */
74670 case OP_NoConflict: /* jump, in3 */
74671 case OP_NotFound: /* jump, in3 */
74672 case OP_Found: { /* jump, in3 */
74673 int alreadyExists;
74674 int takeJump;
74675 int ii;
74676 VdbeCursor *pC;
74677 int res;
74678 char *pFree;
74679 UnpackedRecord *pIdxKey;
@@ -74448,11 +74692,11 @@
74692 pC->seekOp = pOp->opcode;
74693 #endif
74694 pIn3 = &aMem[pOp->p3];
74695 assert( pC->pCursor!=0 );
74696 assert( pC->isTable==0 );
74697 pFree = 0;
74698 if( pOp->p4.i>0 ){
74699 r.pKeyInfo = pC->pKeyInfo;
74700 r.nField = (u16)pOp->p4.i;
74701 r.aMem = pIn3;
74702 for(ii=0; ii<r.nField; ii++){
@@ -74471,25 +74715,24 @@
74715 assert( pIn3->flags & MEM_Blob );
74716 ExpandBlob(pIn3);
74717 sqlite3VdbeRecordUnpack(pC->pKeyInfo, pIn3->n, pIn3->z, pIdxKey);
74718 }
74719 pIdxKey->default_rc = 0;
74720 takeJump = 0;
74721 if( pOp->opcode==OP_NoConflict ){
74722 /* For the OP_NoConflict opcode, take the jump if any of the
74723 ** input fields are NULL, since any key with a NULL will not
74724 ** conflict */
74725 for(ii=0; ii<pIdxKey->nField; ii++){
74726 if( pIdxKey->aMem[ii].flags & MEM_Null ){
74727 takeJump = 1;
74728 break;
74729 }
74730 }
74731 }
74732 rc = sqlite3BtreeMovetoUnpacked(pC->pCursor, pIdxKey, 0, 0, &res);
74733 sqlite3DbFree(db, pFree);
 
 
74734 if( rc!=SQLITE_OK ){
74735 break;
74736 }
74737 pC->seekResult = res;
74738 alreadyExists = (res==0);
@@ -74496,14 +74739,14 @@
74739 pC->nullRow = 1-alreadyExists;
74740 pC->deferredMoveto = 0;
74741 pC->cacheStatus = CACHE_STALE;
74742 if( pOp->opcode==OP_Found ){
74743 VdbeBranchTaken(alreadyExists!=0,2);
74744 if( alreadyExists ) goto jump_to_p2;
74745 }else{
74746 VdbeBranchTaken(takeJump||alreadyExists==0,2);
74747 if( takeJump || !alreadyExists ) goto jump_to_p2;
74748 }
74749 break;
74750 }
74751
74752 /* Opcode: NotExists P1 P2 P3 * *
@@ -74548,14 +74791,12 @@
74791 pC->movetoTarget = iKey; /* Used by OP_Delete */
74792 pC->nullRow = 0;
74793 pC->cacheStatus = CACHE_STALE;
74794 pC->deferredMoveto = 0;
74795 VdbeBranchTaken(res!=0,2);
 
 
 
74796 pC->seekResult = res;
74797 if( res!=0 ) goto jump_to_p2;
74798 break;
74799 }
74800
74801 /* Opcode: Sequence P1 P2 * * *
74802 ** Synopsis: r[P2]=cursor[P1].ctr++
@@ -74563,13 +74804,14 @@
74804 ** Find the next available sequence number for cursor P1.
74805 ** Write the sequence number into register P2.
74806 ** The sequence number on the cursor is incremented after this
74807 ** instruction.
74808 */
74809 case OP_Sequence: { /* out2 */
74810 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74811 assert( p->apCsr[pOp->p1]!=0 );
74812 pOut = out2Prerelease(p, pOp);
74813 pOut->u.i = p->apCsr[pOp->p1]->seqCount++;
74814 break;
74815 }
74816
74817
@@ -74586,20 +74828,21 @@
74828 ** allowed to be less than this value. When this value reaches its maximum,
74829 ** an SQLITE_FULL error is generated. The P3 register is updated with the '
74830 ** generated record number. This P3 mechanism is used to help implement the
74831 ** AUTOINCREMENT feature.
74832 */
74833 case OP_NewRowid: { /* out2 */
74834 i64 v; /* The new rowid */
74835 VdbeCursor *pC; /* Cursor of table to get the new rowid */
74836 int res; /* Result of an sqlite3BtreeLast() */
74837 int cnt; /* Counter to limit the number of searches */
74838 Mem *pMem; /* Register holding largest rowid for AUTOINCREMENT */
74839 VdbeFrame *pFrame; /* Root frame of VDBE */
74840
74841 v = 0;
74842 res = 0;
74843 pOut = out2Prerelease(p, pOp);
74844 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
74845 pC = p->apCsr[pOp->p1];
74846 assert( pC!=0 );
74847 if( NEVER(pC->pCursor==0) ){
74848 /* The zero initialization above is all that is needed */
@@ -74909,13 +75152,11 @@
75152 pIn3 = &aMem[pOp->p3];
75153 nKeyCol = pOp->p4.i;
75154 res = 0;
75155 rc = sqlite3VdbeSorterCompare(pC, pIn3, nKeyCol, &res);
75156 VdbeBranchTaken(res!=0,2);
75157 if( res ) goto jump_to_p2;
 
 
75158 break;
75159 };
75160
75161 /* Opcode: SorterData P1 P2 P3 * *
75162 ** Synopsis: r[P2]=data
@@ -75040,16 +75281,17 @@
75281 **
75282 ** P1 can be either an ordinary table or a virtual table. There used to
75283 ** be a separate OP_VRowid opcode for use with virtual tables, but this
75284 ** one opcode now works for both table types.
75285 */
75286 case OP_Rowid: { /* out2 */
75287 VdbeCursor *pC;
75288 i64 v;
75289 sqlite3_vtab *pVtab;
75290 const sqlite3_module *pModule;
75291
75292 pOut = out2Prerelease(p, pOp);
75293 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
75294 pC = p->apCsr[pOp->p1];
75295 assert( pC!=0 );
75296 assert( pC->pseudoTableReg==0 || pC->nullRow );
75297 if( pC->nullRow ){
@@ -75098,11 +75340,11 @@
75340 sqlite3BtreeClearCursor(pC->pCursor);
75341 }
75342 break;
75343 }
75344
75345 /* Opcode: Last P1 P2 P3 * *
75346 **
75347 ** The next use of the Rowid or Column or Prev instruction for P1
75348 ** will refer to the last entry in the database table or index.
75349 ** If the table or index is empty and P2>0, then jump immediately to P2.
75350 ** If P2 is 0 or if the table or index is not empty, fall through
@@ -75125,16 +75367,17 @@
75367 assert( pCrsr!=0 );
75368 rc = sqlite3BtreeLast(pCrsr, &res);
75369 pC->nullRow = (u8)res;
75370 pC->deferredMoveto = 0;
75371 pC->cacheStatus = CACHE_STALE;
75372 pC->seekResult = pOp->p3;
75373 #ifdef SQLITE_DEBUG
75374 pC->seekOp = OP_Last;
75375 #endif
75376 if( pOp->p2>0 ){
75377 VdbeBranchTaken(res!=0,2);
75378 if( res ) goto jump_to_p2;
75379 }
75380 break;
75381 }
75382
75383
@@ -75194,13 +75437,11 @@
75437 pC->cacheStatus = CACHE_STALE;
75438 }
75439 pC->nullRow = (u8)res;
75440 assert( pOp->p2>0 && pOp->p2<p->nOp );
75441 VdbeBranchTaken(res!=0,2);
75442 if( res ) goto jump_to_p2;
 
 
75443 break;
75444 }
75445
75446 /* Opcode: Next P1 P2 P3 P4 P5
75447 **
@@ -75307,15 +75548,15 @@
75548 next_tail:
75549 pC->cacheStatus = CACHE_STALE;
75550 VdbeBranchTaken(res==0,2);
75551 if( res==0 ){
75552 pC->nullRow = 0;
 
75553 p->aCounter[pOp->p5]++;
75554 #ifdef SQLITE_TEST
75555 sqlite3_search_count++;
75556 #endif
75557 goto jump_to_p2_and_check_for_interrupt;
75558 }else{
75559 pC->nullRow = 1;
75560 }
75561 goto check_for_interrupt;
75562 }
@@ -75419,15 +75660,16 @@
75660 ** the end of the index key pointed to by cursor P1. This integer should be
75661 ** the rowid of the table entry to which this index entry points.
75662 **
75663 ** See also: Rowid, MakeRecord.
75664 */
75665 case OP_IdxRowid: { /* out2 */
75666 BtCursor *pCrsr;
75667 VdbeCursor *pC;
75668 i64 rowid;
75669
75670 pOut = out2Prerelease(p, pOp);
75671 assert( pOp->p1>=0 && pOp->p1<p->nCursor );
75672 pC = p->apCsr[pOp->p1];
75673 assert( pC!=0 );
75674 pCrsr = pC->pCursor;
75675 assert( pCrsr!=0 );
@@ -75536,13 +75778,11 @@
75778 }else{
75779 assert( pOp->opcode==OP_IdxGE || pOp->opcode==OP_IdxGT );
75780 res++;
75781 }
75782 VdbeBranchTaken(res>0,2);
75783 if( res>0 ) goto jump_to_p2;
 
 
75784 break;
75785 }
75786
75787 /* Opcode: Destroy P1 P2 P3 * *
75788 **
@@ -75562,15 +75802,16 @@
75802 ** the last one in the database) then a zero is stored in register P2.
75803 ** If AUTOVACUUM is disabled then a zero is stored in register P2.
75804 **
75805 ** See also: Clear
75806 */
75807 case OP_Destroy: { /* out2 */
75808 int iMoved;
75809 int iDb;
75810
75811 assert( p->readOnly==0 );
75812 pOut = out2Prerelease(p, pOp);
75813 pOut->flags = MEM_Null;
75814 if( db->nVdbeRead > db->nVDestroy+1 ){
75815 rc = SQLITE_LOCKED;
75816 p->errorAction = OE_Abort;
75817 }else{
@@ -75675,16 +75916,17 @@
75916 ** P1>1. Write the root page number of the new table into
75917 ** register P2.
75918 **
75919 ** See documentation on OP_CreateTable for additional information.
75920 */
75921 case OP_CreateIndex: /* out2 */
75922 case OP_CreateTable: { /* out2 */
75923 int pgno;
75924 int flags;
75925 Db *pDb;
75926
75927 pOut = out2Prerelease(p, pOp);
75928 pgno = 0;
75929 assert( pOp->p1>=0 && pOp->p1<db->nDb );
75930 assert( DbMaskTest(p->btreeMask, pOp->p1) );
75931 assert( p->readOnly==0 );
75932 pDb = &db->aDb[pOp->p1];
@@ -75906,16 +76148,16 @@
76148 if( (pIn1->flags & MEM_RowSet)==0
76149 || sqlite3RowSetNext(pIn1->u.pRowSet, &val)==0
76150 ){
76151 /* The boolean index is empty */
76152 sqlite3VdbeMemSetNull(pIn1);
 
76153 VdbeBranchTaken(1,2);
76154 goto jump_to_p2_and_check_for_interrupt;
76155 }else{
76156 /* A value was pulled from the index */
 
76157 VdbeBranchTaken(0,2);
76158 sqlite3VdbeMemSetInt64(&aMem[pOp->p3], val);
76159 }
76160 goto check_for_interrupt;
76161 }
76162
76163 /* Opcode: RowSetTest P1 P2 P3 P4
@@ -75962,14 +76204,11 @@
76204 assert( pOp->p4type==P4_INT32 );
76205 assert( iSet==-1 || iSet>=0 );
76206 if( iSet ){
76207 exists = sqlite3RowSetTest(pIn1->u.pRowSet, iSet, pIn3->u.i);
76208 VdbeBranchTaken(exists!=0,2);
76209 if( exists ) goto jump_to_p2;
 
 
 
76210 }
76211 if( iSet>=0 ){
76212 sqlite3RowSetInsert(pIn1->u.pRowSet, pIn3->u.i);
76213 }
76214 break;
@@ -76054,11 +76293,11 @@
76293 pRt->u.pFrame = pFrame;
76294
76295 pFrame->v = p;
76296 pFrame->nChildMem = nMem;
76297 pFrame->nChildCsr = pProgram->nCsr;
76298 pFrame->pc = (int)(pOp - aOp);
76299 pFrame->aMem = p->aMem;
76300 pFrame->nMem = p->nMem;
76301 pFrame->apCsr = p->apCsr;
76302 pFrame->nCursor = p->nCursor;
76303 pFrame->aOp = p->aOp;
@@ -76077,11 +76316,11 @@
76316 }
76317 }else{
76318 pFrame = pRt->u.pFrame;
76319 assert( pProgram->nMem+pProgram->nCsr==pFrame->nChildMem );
76320 assert( pProgram->nCsr==pFrame->nChildCsr );
76321 assert( (int)(pOp - aOp)==pFrame->pc );
76322 }
76323
76324 p->nFrame++;
76325 pFrame->pParent = p->pFrame;
76326 pFrame->lastRowid = lastRowid;
@@ -76098,11 +76337,11 @@
76337 p->aOnceFlag = (u8 *)&p->apCsr[p->nCursor];
76338 p->nOnceFlag = pProgram->nOnce;
76339 #ifdef SQLITE_ENABLE_STMT_SCANSTATUS
76340 p->anExec = 0;
76341 #endif
76342 pOp = &aOp[-1];
76343 memset(p->aOnceFlag, 0, p->nOnceFlag);
76344
76345 break;
76346 }
76347
@@ -76116,13 +76355,14 @@
76355 **
76356 ** The address of the cell in the parent frame is determined by adding
76357 ** the value of the P1 argument to the value of the P1 argument to the
76358 ** calling OP_Program instruction.
76359 */
76360 case OP_Param: { /* out2 */
76361 VdbeFrame *pFrame;
76362 Mem *pIn;
76363 pOut = out2Prerelease(p, pOp);
76364 pFrame = p->pFrame;
76365 pIn = &pFrame->aMem[pOp->p1 + pFrame->aOp[pFrame->pc].p1];
76366 sqlite3VdbeMemShallowCopy(pOut, pIn, MEM_Ephem);
76367 break;
76368 }
@@ -76162,14 +76402,14 @@
76402 ** (immediate foreign key constraint violations).
76403 */
76404 case OP_FkIfZero: { /* jump */
76405 if( pOp->p1 ){
76406 VdbeBranchTaken(db->nDeferredCons==0 && db->nDeferredImmCons==0, 2);
76407 if( db->nDeferredCons==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;
76408 }else{
76409 VdbeBranchTaken(p->nFkConstraint==0 && db->nDeferredImmCons==0, 2);
76410 if( p->nFkConstraint==0 && db->nDeferredImmCons==0 ) goto jump_to_p2;
76411 }
76412 break;
76413 }
76414 #endif /* #ifndef SQLITE_OMIT_FOREIGN_KEY */
76415
@@ -76216,13 +76456,11 @@
76456 */
76457 case OP_IfPos: { /* jump, in1 */
76458 pIn1 = &aMem[pOp->p1];
76459 assert( pIn1->flags&MEM_Int );
76460 VdbeBranchTaken( pIn1->u.i>0, 2);
76461 if( pIn1->u.i>0 ) goto jump_to_p2;
 
 
76462 break;
76463 }
76464
76465 /* Opcode: IfNeg P1 P2 P3 * *
76466 ** Synopsis: r[P1]+=P3, if r[P1]<0 goto P2
@@ -76233,13 +76471,11 @@
76471 case OP_IfNeg: { /* jump, in1 */
76472 pIn1 = &aMem[pOp->p1];
76473 assert( pIn1->flags&MEM_Int );
76474 pIn1->u.i += pOp->p3;
76475 VdbeBranchTaken(pIn1->u.i<0, 2);
76476 if( pIn1->u.i<0 ) goto jump_to_p2;
 
 
76477 break;
76478 }
76479
76480 /* Opcode: IfNotZero P1 P2 P3 * *
76481 ** Synopsis: if r[P1]!=0 then r[P1]+=P3, goto P2
@@ -76252,11 +76488,11 @@
76488 pIn1 = &aMem[pOp->p1];
76489 assert( pIn1->flags&MEM_Int );
76490 VdbeBranchTaken(pIn1->u.i<0, 2);
76491 if( pIn1->u.i ){
76492 pIn1->u.i += pOp->p3;
76493 goto jump_to_p2;
76494 }
76495 break;
76496 }
76497
76498 /* Opcode: DecrJumpZero P1 P2 * * *
@@ -76268,13 +76504,11 @@
76504 case OP_DecrJumpZero: { /* jump, in1 */
76505 pIn1 = &aMem[pOp->p1];
76506 assert( pIn1->flags&MEM_Int );
76507 pIn1->u.i--;
76508 VdbeBranchTaken(pIn1->u.i==0, 2);
76509 if( pIn1->u.i==0 ) goto jump_to_p2;
 
 
76510 break;
76511 }
76512
76513
76514 /* Opcode: JumpZeroIncr P1 P2 * * *
@@ -76286,13 +76520,11 @@
76520 */
76521 case OP_JumpZeroIncr: { /* jump, in1 */
76522 pIn1 = &aMem[pOp->p1];
76523 assert( pIn1->flags&MEM_Int );
76524 VdbeBranchTaken(pIn1->u.i==0, 2);
76525 if( (pIn1->u.i++)==0 ) goto jump_to_p2;
 
 
76526 break;
76527 }
76528
76529 /* Opcode: AggStep * P2 P3 P4 P5
76530 ** Synopsis: accum=r[P3] step(r[P2@P5])
@@ -76330,11 +76562,11 @@
76562 pMem->n++;
76563 sqlite3VdbeMemInit(&t, db, MEM_Null);
76564 ctx.pOut = &t;
76565 ctx.isError = 0;
76566 ctx.pVdbe = p;
76567 ctx.iOp = (int)(pOp - aOp);
76568 ctx.skipFlag = 0;
76569 (ctx.pFunc->xStep)(&ctx, n, apVal); /* IMP: R-24505-23230 */
76570 if( ctx.isError ){
76571 sqlite3SetString(&p->zErrMsg, db, "%s", sqlite3_value_text(&t));
76572 rc = ctx.isError;
@@ -76425,19 +76657,20 @@
76657 **
76658 ** If changing into or out of WAL mode the procedure is more complicated.
76659 **
76660 ** Write a string containing the final journal-mode to register P2.
76661 */
76662 case OP_JournalMode: { /* out2 */
76663 Btree *pBt; /* Btree to change journal mode of */
76664 Pager *pPager; /* Pager associated with pBt */
76665 int eNew; /* New journal mode */
76666 int eOld; /* The old journal mode */
76667 #ifndef SQLITE_OMIT_WAL
76668 const char *zFilename; /* Name of database file for pPager */
76669 #endif
76670
76671 pOut = out2Prerelease(p, pOp);
76672 eNew = pOp->p3;
76673 assert( eNew==PAGER_JOURNALMODE_DELETE
76674 || eNew==PAGER_JOURNALMODE_TRUNCATE
76675 || eNew==PAGER_JOURNALMODE_PERSIST
76676 || eNew==PAGER_JOURNALMODE_OFF
@@ -76509,11 +76742,10 @@
76742 if( rc ){
76743 eNew = eOld;
76744 }
76745 eNew = sqlite3PagerSetJournalMode(pPager, eNew);
76746
 
76747 pOut->flags = MEM_Str|MEM_Static|MEM_Term;
76748 pOut->z = (char *)sqlite3JournalModename(eNew);
76749 pOut->n = sqlite3Strlen30(pOut->z);
76750 pOut->enc = SQLITE_UTF8;
76751 sqlite3VdbeChangeEncoding(pOut, encoding);
@@ -76550,12 +76782,12 @@
76782 assert( p->readOnly==0 );
76783 pBt = db->aDb[pOp->p1].pBt;
76784 rc = sqlite3BtreeIncrVacuum(pBt);
76785 VdbeBranchTaken(rc==SQLITE_DONE,2);
76786 if( rc==SQLITE_DONE ){
 
76787 rc = SQLITE_OK;
76788 goto jump_to_p2;
76789 }
76790 break;
76791 }
76792 #endif
76793
@@ -76704,12 +76936,13 @@
76936 pCur = allocateCursor(p, pOp->p1, 0, -1, 0);
76937 if( pCur ){
76938 pCur->pVtabCursor = pVtabCursor;
76939 pVtab->nRef++;
76940 }else{
76941 assert( db->mallocFailed );
76942 pModule->xClose(pVtabCursor);
76943 goto no_mem;
76944 }
76945 }
76946 break;
76947 }
76948 #endif /* SQLITE_OMIT_VIRTUALTABLE */
@@ -76761,29 +76994,23 @@
76994 assert( (pQuery->flags&MEM_Int)!=0 && pArgc->flags==MEM_Int );
76995 nArg = (int)pArgc->u.i;
76996 iQuery = (int)pQuery->u.i;
76997
76998 /* Invoke the xFilter method */
76999 res = 0;
77000 apArg = p->apArg;
77001 for(i = 0; i<nArg; i++){
77002 apArg[i] = &pArgc[i+1];
77003 }
77004 rc = pModule->xFilter(pVtabCursor, iQuery, pOp->p4.z, nArg, apArg);
77005 sqlite3VtabImportErrmsg(p, pVtab);
77006 if( rc==SQLITE_OK ){
77007 res = pModule->xEof(pVtabCursor);
 
 
 
 
 
 
 
77008 }
77009 pCur->nullRow = 0;
77010 VdbeBranchTaken(res!=0,2);
77011 if( res ) goto jump_to_p2;
77012 break;
77013 }
77014 #endif /* SQLITE_OMIT_VIRTUALTABLE */
77015
77016 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -76866,11 +77093,11 @@
77093 res = pModule->xEof(pCur->pVtabCursor);
77094 }
77095 VdbeBranchTaken(!res,2);
77096 if( !res ){
77097 /* If there is data, jump to P2 */
77098 goto jump_to_p2_and_check_for_interrupt;
77099 }
77100 goto check_for_interrupt;
77101 }
77102 #endif /* SQLITE_OMIT_VIRTUALTABLE */
77103
@@ -76989,11 +77216,12 @@
77216 #ifndef SQLITE_OMIT_PAGER_PRAGMAS
77217 /* Opcode: Pagecount P1 P2 * * *
77218 **
77219 ** Write the current number of pages in database P1 to memory cell P2.
77220 */
77221 case OP_Pagecount: { /* out2 */
77222 pOut = out2Prerelease(p, pOp);
77223 pOut->u.i = sqlite3BtreeLastPage(db->aDb[pOp->p1].pBt);
77224 break;
77225 }
77226 #endif
77227
@@ -77005,14 +77233,15 @@
77233 ** Do not let the maximum page count fall below the current page count and
77234 ** do not change the maximum page count value if P3==0.
77235 **
77236 ** Store the maximum page count after the change in register P2.
77237 */
77238 case OP_MaxPgcnt: { /* out2 */
77239 unsigned int newMax;
77240 Btree *pBt;
77241
77242 pOut = out2Prerelease(p, pOp);
77243 pBt = db->aDb[pOp->p1].pBt;
77244 newMax = 0;
77245 if( pOp->p3 ){
77246 newMax = sqlite3BtreeLastPage(pBt);
77247 if( newMax < (unsigned)pOp->p3 ) newMax = (unsigned)pOp->p3;
@@ -77037,13 +77266,10 @@
77266 */
77267 case OP_Init: { /* jump */
77268 char *zTrace;
77269 char *z;
77270
 
 
 
77271 #ifndef SQLITE_OMIT_TRACE
77272 if( db->xTrace
77273 && !p->doingRerun
77274 && (zTrace = (pOp->p4.z ? pOp->p4.z : p->zSql))!=0
77275 ){
@@ -77067,10 +77293,11 @@
77293 ){
77294 sqlite3DebugPrintf("SQL-trace: %s\n", zTrace);
77295 }
77296 #endif /* SQLITE_DEBUG */
77297 #endif /* SQLITE_OMIT_TRACE */
77298 if( pOp->p2 ) goto jump_to_p2;
77299 break;
77300 }
77301
77302
77303 /* Opcode: Noop * * * * *
@@ -77098,31 +77325,31 @@
77325 }
77326
77327 #ifdef VDBE_PROFILE
77328 {
77329 u64 endTime = sqlite3Hwtime();
77330 if( endTime>start ) pOrigOp->cycles += endTime - start;
77331 pOrigOp->cnt++;
77332 }
77333 #endif
77334
77335 /* The following code adds nothing to the actual functionality
77336 ** of the program. It is only here for testing and debugging.
77337 ** On the other hand, it does burn CPU cycles every time through
77338 ** the evaluator loop. So we can leave it out when NDEBUG is defined.
77339 */
77340 #ifndef NDEBUG
77341 assert( pOp>=&aOp[-1] && pOp<&aOp[p->nOp-1] );
77342
77343 #ifdef SQLITE_DEBUG
77344 if( db->flags & SQLITE_VdbeTrace ){
77345 if( rc!=0 ) printf("rc=%d\n",rc);
77346 if( pOrigOp->opflags & (OPFLG_OUT2) ){
77347 registerTrace(pOrigOp->p2, &aMem[pOrigOp->p2]);
77348 }
77349 if( pOrigOp->opflags & OPFLG_OUT3 ){
77350 registerTrace(pOrigOp->p3, &aMem[pOrigOp->p3]);
77351 }
77352 }
77353 #endif /* SQLITE_DEBUG */
77354 #endif /* NDEBUG */
77355 } /* The end of the for(;;) loop the loops through opcodes */
@@ -77133,11 +77360,11 @@
77360 vdbe_error_halt:
77361 assert( rc );
77362 p->rc = rc;
77363 testcase( sqlite3GlobalConfig.xLog!=0 );
77364 sqlite3_log(rc, "statement aborts at %d: [%s] %s",
77365 (int)(pOp - aOp), p->zSql, p->zErrMsg);
77366 sqlite3VdbeHalt(p);
77367 if( rc==SQLITE_IOERR_NOMEM ) db->mallocFailed = 1;
77368 rc = SQLITE_ERROR;
77369 if( resetSchemaOnFault>0 ){
77370 sqlite3ResetOneSchema(db, resetSchemaOnFault-1);
@@ -77296,11 +77523,11 @@
77523 }
77524
77525 /*
77526 ** Open a blob handle.
77527 */
77528 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
77529 sqlite3* db, /* The database connection */
77530 const char *zDb, /* The attached database containing the blob */
77531 const char *zTable, /* The table containing the blob */
77532 const char *zColumn, /* The column containing the blob */
77533 sqlite_int64 iRow, /* The row containing the glob */
@@ -77533,11 +77760,11 @@
77760
77761 /*
77762 ** Close a blob handle that was previously created using
77763 ** sqlite3_blob_open().
77764 */
77765 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *pBlob){
77766 Incrblob *p = (Incrblob *)pBlob;
77767 int rc;
77768 sqlite3 *db;
77769
77770 if( p ){
@@ -77602,28 +77829,28 @@
77829 }
77830
77831 /*
77832 ** Read data from a blob handle.
77833 */
77834 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *pBlob, void *z, int n, int iOffset){
77835 return blobReadWrite(pBlob, z, n, iOffset, sqlite3BtreeData);
77836 }
77837
77838 /*
77839 ** Write data to a blob handle.
77840 */
77841 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *pBlob, const void *z, int n, int iOffset){
77842 return blobReadWrite(pBlob, (void *)z, n, iOffset, sqlite3BtreePutData);
77843 }
77844
77845 /*
77846 ** Query a blob handle for the size of the data.
77847 **
77848 ** The Incrblob.nByte field is fixed for the lifetime of the Incrblob
77849 ** so no mutex is required for access.
77850 */
77851 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *pBlob){
77852 Incrblob *p = (Incrblob *)pBlob;
77853 return (p && p->pStmt) ? p->nByte : 0;
77854 }
77855
77856 /*
@@ -77634,11 +77861,11 @@
77861 ** contain a blob or text value, then an error code is returned and the
77862 ** database handle error code and message set. If this happens, then all
77863 ** subsequent calls to sqlite3_blob_xxx() functions (except blob_close())
77864 ** immediately return SQLITE_ABORT.
77865 */
77866 SQLITE_API int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *pBlob, sqlite3_int64 iRow){
77867 int rc;
77868 Incrblob *p = (Incrblob *)pBlob;
77869 sqlite3 *db;
77870
77871 if( p==0 ) return SQLITE_MISUSE_BKPT;
@@ -77959,20 +78186,23 @@
78186 **
78187 ** In both cases, the effects of the main thread seeing (bDone==0) even
78188 ** after the thread has finished are not dire. So we don't worry about
78189 ** memory barriers and such here.
78190 */
78191 typedef int (*SorterCompare)(SortSubtask*,int*,const void*,int,const void*,int);
78192 struct SortSubtask {
78193 SQLiteThread *pThread; /* Background thread, if any */
78194 int bDone; /* Set if thread is finished but not joined */
78195 VdbeSorter *pSorter; /* Sorter that owns this sub-task */
78196 UnpackedRecord *pUnpacked; /* Space to unpack a record */
78197 SorterList list; /* List for thread to write to a PMA */
78198 int nPMA; /* Number of PMAs currently in file */
78199 SorterCompare xCompare; /* Compare function to use */
78200 SorterFile file; /* Temp file for level-0 PMAs */
78201 SorterFile file2; /* Space for other PMAs */
78202 };
78203
78204
78205 /*
78206 ** Main sorter structure. A single instance of this is allocated for each
78207 ** sorter cursor created by the VDBE.
78208 **
@@ -77996,12 +78226,16 @@
78226 int nMemory; /* Size of list.aMemory allocation in bytes */
78227 u8 bUsePMA; /* True if one or more PMAs created */
78228 u8 bUseThreads; /* True to use background threads */
78229 u8 iPrev; /* Previous thread used to flush PMA */
78230 u8 nTask; /* Size of aTask[] array */
78231 u8 typeMask;
78232 SortSubtask aTask[1]; /* One or more subtasks */
78233 };
78234
78235 #define SORTER_TYPE_INTEGER 0x01
78236 #define SORTER_TYPE_TEXT 0x02
78237
78238 /*
78239 ** An instance of the following object is used to read records out of a
78240 ** PMA, in sorted order. The next key to be read is cached in nKey/aKey.
78241 ** aKey might point into aMap or into aBuffer. If neither of those locations
@@ -78410,35 +78644,165 @@
78644 rc = vdbePmaReaderNext(pReadr);
78645 }
78646 return rc;
78647 }
78648
78649 /*
78650 ** A version of vdbeSorterCompare() that assumes that it has already been
78651 ** determined that the first field of key1 is equal to the first field of
78652 ** key2.
78653 */
78654 static int vdbeSorterCompareTail(
78655 SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78656 int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78657 const void *pKey1, int nKey1, /* Left side of comparison */
78658 const void *pKey2, int nKey2 /* Right side of comparison */
78659 ){
78660 UnpackedRecord *r2 = pTask->pUnpacked;
78661 if( *pbKey2Cached==0 ){
78662 sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);
78663 *pbKey2Cached = 1;
78664 }
78665 return sqlite3VdbeRecordCompareWithSkip(nKey1, pKey1, r2, 1);
78666 }
78667
78668 /*
78669 ** Compare key1 (buffer pKey1, size nKey1 bytes) with key2 (buffer pKey2,
78670 ** size nKey2 bytes). Use (pTask->pKeyInfo) for the collation sequences
78671 ** used by the comparison. Return the result of the comparison.
78672 **
78673 ** If IN/OUT parameter *pbKey2Cached is true when this function is called,
78674 ** it is assumed that (pTask->pUnpacked) contains the unpacked version
78675 ** of key2. If it is false, (pTask->pUnpacked) is populated with the unpacked
78676 ** version of key2 and *pbKey2Cached set to true before returning.
78677 **
78678 ** If an OOM error is encountered, (pTask->pUnpacked->error_rc) is set
78679 ** to SQLITE_NOMEM.
78680 */
78681 static int vdbeSorterCompare(
78682 SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78683 int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78684 const void *pKey1, int nKey1, /* Left side of comparison */
78685 const void *pKey2, int nKey2 /* Right side of comparison */
78686 ){
78687 UnpackedRecord *r2 = pTask->pUnpacked;
78688 if( !*pbKey2Cached ){
78689 sqlite3VdbeRecordUnpack(pTask->pSorter->pKeyInfo, nKey2, pKey2, r2);
78690 *pbKey2Cached = 1;
78691 }
78692 return sqlite3VdbeRecordCompare(nKey1, pKey1, r2);
78693 }
78694
78695 /*
78696 ** A specially optimized version of vdbeSorterCompare() that assumes that
78697 ** the first field of each key is a TEXT value and that the collation
78698 ** sequence to compare them with is BINARY.
78699 */
78700 static int vdbeSorterCompareText(
78701 SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78702 int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78703 const void *pKey1, int nKey1, /* Left side of comparison */
78704 const void *pKey2, int nKey2 /* Right side of comparison */
78705 ){
78706 const u8 * const p1 = (const u8 * const)pKey1;
78707 const u8 * const p2 = (const u8 * const)pKey2;
78708 const u8 * const v1 = &p1[ p1[0] ]; /* Pointer to value 1 */
78709 const u8 * const v2 = &p2[ p2[0] ]; /* Pointer to value 2 */
78710
78711 int n1;
78712 int n2;
78713 int res;
78714
78715 getVarint32(&p1[1], n1); n1 = (n1 - 13) / 2;
78716 getVarint32(&p2[1], n2); n2 = (n2 - 13) / 2;
78717 res = memcmp(v1, v2, MIN(n1, n2));
78718 if( res==0 ){
78719 res = n1 - n2;
78720 }
78721
78722 if( res==0 ){
78723 if( pTask->pSorter->pKeyInfo->nField>1 ){
78724 res = vdbeSorterCompareTail(
78725 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
78726 );
78727 }
78728 }else{
78729 if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
78730 res = res * -1;
78731 }
78732 }
78733
78734 return res;
78735 }
78736
78737 /*
78738 ** A specially optimized version of vdbeSorterCompare() that assumes that
78739 ** the first field of each key is an INTEGER value.
78740 */
78741 static int vdbeSorterCompareInt(
78742 SortSubtask *pTask, /* Subtask context (for pKeyInfo) */
78743 int *pbKey2Cached, /* True if pTask->pUnpacked is pKey2 */
78744 const void *pKey1, int nKey1, /* Left side of comparison */
78745 const void *pKey2, int nKey2 /* Right side of comparison */
78746 ){
78747 const u8 * const p1 = (const u8 * const)pKey1;
78748 const u8 * const p2 = (const u8 * const)pKey2;
78749 const int s1 = p1[1]; /* Left hand serial type */
78750 const int s2 = p2[1]; /* Right hand serial type */
78751 const u8 * const v1 = &p1[ p1[0] ]; /* Pointer to value 1 */
78752 const u8 * const v2 = &p2[ p2[0] ]; /* Pointer to value 2 */
78753 int res; /* Return value */
78754
78755 assert( (s1>0 && s1<7) || s1==8 || s1==9 );
78756 assert( (s2>0 && s2<7) || s2==8 || s2==9 );
78757
78758 if( s1>7 && s2>7 ){
78759 res = s1 - s2;
78760 }else{
78761 if( s1==s2 ){
78762 if( (*v1 ^ *v2) & 0x80 ){
78763 /* The two values have different signs */
78764 res = (*v1 & 0x80) ? -1 : +1;
78765 }else{
78766 /* The two values have the same sign. Compare using memcmp(). */
78767 static const u8 aLen[] = {0, 1, 2, 3, 4, 6, 8 };
78768 int i;
78769 res = 0;
78770 for(i=0; i<aLen[s1]; i++){
78771 if( (res = v1[i] - v2[i]) ) break;
78772 }
78773 }
78774 }else{
78775 if( s2>7 ){
78776 res = +1;
78777 }else if( s1>7 ){
78778 res = -1;
78779 }else{
78780 res = s1 - s2;
78781 }
78782 assert( res!=0 );
78783
78784 if( res>0 ){
78785 if( *v1 & 0x80 ) res = -1;
78786 }else{
78787 if( *v2 & 0x80 ) res = +1;
78788 }
78789 }
78790 }
78791
78792 if( res==0 ){
78793 if( pTask->pSorter->pKeyInfo->nField>1 ){
78794 res = vdbeSorterCompareTail(
78795 pTask, pbKey2Cached, pKey1, nKey1, pKey2, nKey2
78796 );
78797 }
78798 }else if( pTask->pSorter->pKeyInfo->aSortOrder[0] ){
78799 res = res * -1;
78800 }
78801
78802 return res;
78803 }
78804
78805 /*
78806 ** Initialize the temporary index cursor just opened as a sorter cursor.
78807 **
78808 ** Usually, the sorter module uses the value of (pCsr->pKeyInfo->nField)
@@ -78503,13 +78867,17 @@
78867 rc = SQLITE_NOMEM;
78868 }else{
78869 pSorter->pKeyInfo = pKeyInfo = (KeyInfo*)((u8*)pSorter + sz);
78870 memcpy(pKeyInfo, pCsr->pKeyInfo, szKeyInfo);
78871 pKeyInfo->db = 0;
78872 if( nField && nWorker==0 ){
78873 pKeyInfo->nXField += (pKeyInfo->nField - nField);
78874 pKeyInfo->nField = nField;
78875 }
78876 pSorter->pgsz = pgsz = sqlite3BtreeGetPageSize(db->aDb[0].pBt);
78877 pSorter->nTask = nWorker + 1;
78878 pSorter->iPrev = nWorker-1;
78879 pSorter->bUseThreads = (pSorter->nTask>1);
78880 pSorter->db = db;
78881 for(i=0; i<pSorter->nTask; i++){
78882 SortSubtask *pTask = &pSorter->aTask[i];
78883 pTask->pSorter = pSorter;
@@ -78531,10 +78899,16 @@
78899 pSorter->nMemory = pgsz;
78900 pSorter->list.aMemory = (u8*)sqlite3Malloc(pgsz);
78901 if( !pSorter->list.aMemory ) rc = SQLITE_NOMEM;
78902 }
78903 }
78904
78905 if( (pKeyInfo->nField+pKeyInfo->nXField)<13
78906 && (pKeyInfo->aColl[0]==0 || pKeyInfo->aColl[0]==db->pDfltColl)
78907 ){
78908 pSorter->typeMask = SORTER_TYPE_INTEGER | SORTER_TYPE_TEXT;
78909 }
78910 }
78911
78912 return rc;
78913 }
78914 #undef nWorker /* Defined at the top of this function */
@@ -78555,34 +78929,28 @@
78929 ** Free all resources owned by the object indicated by argument pTask. All
78930 ** fields of *pTask are zeroed before returning.
78931 */
78932 static void vdbeSortSubtaskCleanup(sqlite3 *db, SortSubtask *pTask){
78933 sqlite3DbFree(db, pTask->pUnpacked);
 
78934 #if SQLITE_MAX_WORKER_THREADS>0
78935 /* pTask->list.aMemory can only be non-zero if it was handed memory
78936 ** from the main thread. That only occurs SQLITE_MAX_WORKER_THREADS>0 */
78937 if( pTask->list.aMemory ){
78938 sqlite3_free(pTask->list.aMemory);
 
78939 }else
78940 #endif
78941 {
78942 assert( pTask->list.aMemory==0 );
78943 vdbeSorterRecordFree(0, pTask->list.pList);
78944 }
 
78945 if( pTask->file.pFd ){
78946 sqlite3OsCloseFree(pTask->file.pFd);
 
 
78947 }
78948 if( pTask->file2.pFd ){
78949 sqlite3OsCloseFree(pTask->file2.pFd);
 
 
78950 }
78951 memset(pTask, 0, sizeof(SortSubtask));
78952 }
78953
78954 #ifdef SQLITE_DEBUG_SORTER_THREADS
78955 static void vdbeSorterWorkDebug(SortSubtask *pTask, const char *zEvent){
78956 i64 t;
@@ -78758,10 +79126,11 @@
79126 vdbeMergeEngineFree(pSorter->pMerger);
79127 pSorter->pMerger = 0;
79128 for(i=0; i<pSorter->nTask; i++){
79129 SortSubtask *pTask = &pSorter->aTask[i];
79130 vdbeSortSubtaskCleanup(db, pTask);
79131 pTask->pSorter = pSorter;
79132 }
79133 if( pSorter->list.aMemory==0 ){
79134 vdbeSorterRecordFree(0, pSorter->list.pList);
79135 }
79136 pSorter->list.pList = 0;
@@ -78867,31 +79236,45 @@
79236 SorterRecord *p2, /* Second list to merge */
79237 SorterRecord **ppOut /* OUT: Head of merged list */
79238 ){
79239 SorterRecord *pFinal = 0;
79240 SorterRecord **pp = &pFinal;
79241 int bCached = 0;
79242
79243 while( p1 && p2 ){
79244 int res;
79245 res = pTask->xCompare(
79246 pTask, &bCached, SRVAL(p1), p1->nVal, SRVAL(p2), p2->nVal
79247 );
79248
79249 if( res<=0 ){
79250 *pp = p1;
79251 pp = &p1->u.pNext;
79252 p1 = p1->u.pNext;
 
79253 }else{
79254 *pp = p2;
79255 pp = &p2->u.pNext;
79256 p2 = p2->u.pNext;
79257 bCached = 0;
 
79258 }
79259 }
79260 *pp = p1 ? p1 : p2;
79261 *ppOut = pFinal;
79262 }
79263
79264 /*
79265 ** Return the SorterCompare function to compare values collected by the
79266 ** sorter object passed as the only argument.
79267 */
79268 static SorterCompare vdbeSorterGetCompare(VdbeSorter *p){
79269 if( p->typeMask==SORTER_TYPE_INTEGER ){
79270 return vdbeSorterCompareInt;
79271 }else if( p->typeMask==SORTER_TYPE_TEXT ){
79272 return vdbeSorterCompareText;
79273 }
79274 return vdbeSorterCompare;
79275 }
79276
79277 /*
79278 ** Sort the linked list of records headed at pTask->pList. Return
79279 ** SQLITE_OK if successful, or an SQLite error code (i.e. SQLITE_NOMEM) if
79280 ** an error occurs.
@@ -78903,16 +79286,18 @@
79286 int rc;
79287
79288 rc = vdbeSortAllocUnpacked(pTask);
79289 if( rc!=SQLITE_OK ) return rc;
79290
79291 p = pList->pList;
79292 pTask->xCompare = vdbeSorterGetCompare(pTask->pSorter);
79293
79294 aSlot = (SorterRecord **)sqlite3MallocZero(64 * sizeof(SorterRecord *));
79295 if( !aSlot ){
79296 return SQLITE_NOMEM;
79297 }
79298
 
79299 while( p ){
79300 SorterRecord *pNext;
79301 if( pList->aMemory ){
79302 if( (u8*)p==pList->aMemory ){
79303 pNext = 0;
@@ -79122,28 +79507,27 @@
79507 /* Update contents of aTree[] */
79508 if( rc==SQLITE_OK ){
79509 int i; /* Index of aTree[] to recalculate */
79510 PmaReader *pReadr1; /* First PmaReader to compare */
79511 PmaReader *pReadr2; /* Second PmaReader to compare */
79512 int bCached = 0;
79513
79514 /* Find the first two PmaReaders to compare. The one that was just
79515 ** advanced (iPrev) and the one next to it in the array. */
79516 pReadr1 = &pMerger->aReadr[(iPrev & 0xFFFE)];
79517 pReadr2 = &pMerger->aReadr[(iPrev | 0x0001)];
 
79518
79519 for(i=(pMerger->nTree+iPrev)/2; i>0; i=i/2){
79520 /* Compare pReadr1 and pReadr2. Store the result in variable iRes. */
79521 int iRes;
79522 if( pReadr1->pFd==0 ){
79523 iRes = +1;
79524 }else if( pReadr2->pFd==0 ){
79525 iRes = -1;
79526 }else{
79527 iRes = pTask->xCompare(pTask, &bCached,
79528 pReadr1->aKey, pReadr1->nKey, pReadr2->aKey, pReadr2->nKey
79529 );
79530 }
79531
79532 /* If pReadr1 contained the smaller value, set aTree[i] to its index.
79533 ** Then set pReadr2 to the next PmaReader to compare to pReadr1. In this
@@ -79161,13 +79545,13 @@
79545 ** is sorted from oldest to newest, so pReadr1 contains older values
79546 ** than pReadr2 iff (pReadr1<pReadr2). */
79547 if( iRes<0 || (iRes==0 && pReadr1<pReadr2) ){
79548 pMerger->aTree[i] = (int)(pReadr1 - pMerger->aReadr);
79549 pReadr2 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
79550 bCached = 0;
79551 }else{
79552 if( pReadr1->pFd ) bCached = 0;
79553 pMerger->aTree[i] = (int)(pReadr2 - pMerger->aReadr);
79554 pReadr1 = &pMerger->aReadr[ pMerger->aTree[i ^ 0x0001] ];
79555 }
79556 }
79557 *pbEof = (pMerger->aReadr[pMerger->aTree[1]].pFd==0);
@@ -79270,10 +79654,20 @@
79654 SorterRecord *pNew; /* New list element */
79655
79656 int bFlush; /* True to flush contents of memory to PMA */
79657 int nReq; /* Bytes of memory required */
79658 int nPMA; /* Bytes of PMA space required */
79659 int t; /* serial type of first record field */
79660
79661 getVarint32((const u8*)&pVal->z[1], t);
79662 if( t>0 && t<10 && t!=7 ){
79663 pSorter->typeMask &= SORTER_TYPE_INTEGER;
79664 }else if( t>10 && (t & 0x01) ){
79665 pSorter->typeMask &= SORTER_TYPE_TEXT;
79666 }else{
79667 pSorter->typeMask = 0;
79668 }
79669
79670 assert( pSorter );
79671
79672 /* Figure out whether or not the current contents of memory should be
79673 ** flushed to a PMA before continuing. If so, do so.
@@ -79535,14 +79929,16 @@
79929 if( p1->pFd==0 ){
79930 iRes = i2;
79931 }else if( p2->pFd==0 ){
79932 iRes = i1;
79933 }else{
79934 SortSubtask *pTask = pMerger->pTask;
79935 int bCached = 0;
79936 int res;
79937 assert( pTask->pUnpacked!=0 ); /* from vdbeSortSubtaskMain() */
79938 res = pTask->xCompare(
79939 pTask, &bCached, p1->aKey, p1->nKey, p2->aKey, p2->nKey
79940 );
79941 if( res<=0 ){
79942 iRes = i1;
79943 }else{
79944 iRes = i2;
@@ -79562,15 +79958,16 @@
79958 */
79959 #define INCRINIT_NORMAL 0
79960 #define INCRINIT_TASK 1
79961 #define INCRINIT_ROOT 2
79962
79963 /*
79964 ** Forward reference required as the vdbeIncrMergeInit() and
79965 ** vdbePmaReaderIncrInit() routines are called mutually recursively when
79966 ** building a merge tree.
79967 */
79968 static int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode);
79969
79970 /*
79971 ** Initialize the MergeEngine object passed as the second argument. Once this
79972 ** function returns, the first key of merged data may be read from the
79973 ** MergeEngine object in the usual fashion.
@@ -79613,11 +80010,11 @@
80010 ** the main thread to fill its buffer. So calling PmaReaderNext()
80011 ** on this PmaReader before any of the multi-threaded PmaReaders takes
80012 ** better advantage of multi-processor hardware. */
80013 rc = vdbePmaReaderNext(&pMerger->aReadr[nTree-i-1]);
80014 }else{
80015 rc = vdbePmaReaderIncrInit(&pMerger->aReadr[i], INCRINIT_NORMAL);
80016 }
80017 if( rc!=SQLITE_OK ) return rc;
80018 }
80019
80020 for(i=pMerger->nTree-1; i>0; i--){
@@ -79625,21 +80022,19 @@
80022 }
80023 return pTask->pUnpacked->errCode;
80024 }
80025
80026 /*
80027 ** The PmaReader passed as the first argument is guaranteed to be an
80028 ** incremental-reader (pReadr->pIncr!=0). This function serves to open
80029 ** and/or initialize the temp file related fields of the IncrMerge
 
 
80030 ** object at (pReadr->pIncr).
80031 **
80032 ** If argument eMode is set to INCRINIT_NORMAL, then all PmaReaders
80033 ** in the sub-tree headed by pReadr are also initialized. Data is then
80034 ** loaded into the buffers belonging to pReadr and it is set to point to
80035 ** the first key in its range.
80036 **
80037 ** If argument eMode is set to INCRINIT_TASK, then pReadr is guaranteed
80038 ** to be a multi-threaded PmaReader and this function is being called in a
80039 ** background thread. In this case all PmaReaders in the sub-tree are
80040 ** initialized as for INCRINIT_NORMAL and the aFile[1] buffer belonging to
@@ -79662,93 +80057,112 @@
80057 ** SQLITE_OK is returned if successful, or an SQLite error code otherwise.
80058 */
80059 static int vdbePmaReaderIncrMergeInit(PmaReader *pReadr, int eMode){
80060 int rc = SQLITE_OK;
80061 IncrMerger *pIncr = pReadr->pIncr;
80062 SortSubtask *pTask = pIncr->pTask;
80063 sqlite3 *db = pTask->pSorter->db;
80064
80065 /* eMode is always INCRINIT_NORMAL in single-threaded mode */
80066 assert( SQLITE_MAX_WORKER_THREADS>0 || eMode==INCRINIT_NORMAL );
80067
80068 rc = vdbeMergeEngineInit(pTask, pIncr->pMerger, eMode);
80069
80070 /* Set up the required files for pIncr. A multi-theaded IncrMerge object
80071 ** requires two temp files to itself, whereas a single-threaded object
80072 ** only requires a region of pTask->file2. */
80073 if( rc==SQLITE_OK ){
80074 int mxSz = pIncr->mxSz;
80075 #if SQLITE_MAX_WORKER_THREADS>0
80076 if( pIncr->bUseThread ){
80077 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[0].pFd);
80078 if( rc==SQLITE_OK ){
80079 rc = vdbeSorterOpenTempFile(db, mxSz, &pIncr->aFile[1].pFd);
80080 }
80081 }else
80082 #endif
80083 /*if( !pIncr->bUseThread )*/{
80084 if( pTask->file2.pFd==0 ){
80085 assert( pTask->file2.iEof>0 );
80086 rc = vdbeSorterOpenTempFile(db, pTask->file2.iEof, &pTask->file2.pFd);
80087 pTask->file2.iEof = 0;
80088 }
80089 if( rc==SQLITE_OK ){
80090 pIncr->aFile[1].pFd = pTask->file2.pFd;
80091 pIncr->iStartOff = pTask->file2.iEof;
80092 pTask->file2.iEof += mxSz;
80093 }
80094 }
80095 }
80096
80097 #if SQLITE_MAX_WORKER_THREADS>0
80098 if( rc==SQLITE_OK && pIncr->bUseThread ){
80099 /* Use the current thread to populate aFile[1], even though this
80100 ** PmaReader is multi-threaded. If this is an INCRINIT_TASK object,
80101 ** then this function is already running in background thread
80102 ** pIncr->pTask->thread.
80103 **
80104 ** If this is the INCRINIT_ROOT object, then it is running in the
80105 ** main VDBE thread. But that is Ok, as that thread cannot return
80106 ** control to the VDBE or proceed with anything useful until the
80107 ** first results are ready from this merger object anyway.
80108 */
80109 assert( eMode==INCRINIT_ROOT || eMode==INCRINIT_TASK );
80110 rc = vdbeIncrPopulate(pIncr);
80111 }
80112 #endif
80113
80114 if( rc==SQLITE_OK && (SQLITE_MAX_WORKER_THREADS==0 || eMode!=INCRINIT_TASK) ){
80115 rc = vdbePmaReaderNext(pReadr);
80116 }
80117
80118 return rc;
80119 }
80120
80121 #if SQLITE_MAX_WORKER_THREADS>0
80122 /*
80123 ** The main routine for vdbePmaReaderIncrMergeInit() operations run in
80124 ** background threads.
80125 */
80126 static void *vdbePmaReaderBgIncrInit(void *pCtx){
80127 PmaReader *pReader = (PmaReader*)pCtx;
80128 void *pRet = SQLITE_INT_TO_PTR(
80129 vdbePmaReaderIncrMergeInit(pReader,INCRINIT_TASK)
80130 );
80131 pReader->pIncr->pTask->bDone = 1;
80132 return pRet;
80133 }
80134 #endif
80135
80136 /*
80137 ** If the PmaReader passed as the first argument is not an incremental-reader
80138 ** (if pReadr->pIncr==0), then this function is a no-op. Otherwise, it invokes
80139 ** the vdbePmaReaderIncrMergeInit() function with the parameters passed to
80140 ** this routine to initialize the incremental merge.
80141 **
80142 ** If the IncrMerger object is multi-threaded (IncrMerger.bUseThread==1),
80143 ** then a background thread is launched to call vdbePmaReaderIncrMergeInit().
80144 ** Or, if the IncrMerger is single threaded, the same function is called
80145 ** using the current thread.
80146 */
80147 static int vdbePmaReaderIncrInit(PmaReader *pReadr, int eMode){
80148 IncrMerger *pIncr = pReadr->pIncr; /* Incremental merger */
80149 int rc = SQLITE_OK; /* Return code */
80150 if( pIncr ){
80151 #if SQLITE_MAX_WORKER_THREADS>0
80152 assert( pIncr->bUseThread==0 || eMode==INCRINIT_TASK );
80153 if( pIncr->bUseThread ){
80154 void *pCtx = (void*)pReadr;
80155 rc = vdbeSorterCreateThread(pIncr->pTask, vdbePmaReaderBgIncrInit, pCtx);
80156 }else
80157 #endif
80158 {
80159 rc = vdbePmaReaderIncrMergeInit(pReadr, eMode);
80160 }
80161 }
80162 return rc;
80163 }
 
80164
80165 /*
80166 ** Allocate a new MergeEngine object to merge the contents of nPMA level-0
80167 ** PMAs from pTask->file. If no error occurs, set *ppOut to point to
80168 ** the new object and return SQLITE_OK. Or, if an error does occur, set *ppOut
@@ -79956,10 +80370,15 @@
80370 int rc; /* Return code */
80371 SortSubtask *pTask0 = &pSorter->aTask[0];
80372 MergeEngine *pMain = 0;
80373 #if SQLITE_MAX_WORKER_THREADS
80374 sqlite3 *db = pTask0->pSorter->db;
80375 int i;
80376 SorterCompare xCompare = vdbeSorterGetCompare(pSorter);
80377 for(i=0; i<pSorter->nTask; i++){
80378 pSorter->aTask[i].xCompare = xCompare;
80379 }
80380 #endif
80381
80382 rc = vdbeSorterMergeTreeBuild(pSorter, &pMain);
80383 if( rc==SQLITE_OK ){
80384 #if SQLITE_MAX_WORKER_THREADS
@@ -79984,19 +80403,25 @@
80403 vdbeIncrMergerSetThreads(pIncr);
80404 assert( pIncr->pTask!=pLast );
80405 }
80406 }
80407 for(iTask=0; rc==SQLITE_OK && iTask<pSorter->nTask; iTask++){
80408 /* Check that:
80409 **
80410 ** a) The incremental merge object is configured to use the
80411 ** right task, and
80412 ** b) If it is using task (nTask-1), it is configured to run
80413 ** in single-threaded mode. This is important, as the
80414 ** root merge (INCRINIT_ROOT) will be using the same task
80415 ** object.
80416 */
80417 PmaReader *p = &pMain->aReadr[iTask];
80418 assert( p->pIncr==0 || (
80419 (p->pIncr->pTask==&pSorter->aTask[iTask]) /* a */
80420 && (iTask!=pSorter->nTask-1 || p->pIncr->bUseThread==0) /* b */
80421 ));
80422 rc = vdbePmaReaderIncrInit(p, INCRINIT_TASK);
 
 
 
80423 }
80424 }
80425 pMain = 0;
80426 }
80427 if( rc==SQLITE_OK ){
@@ -80947,11 +81372,11 @@
81372 ** Should be transformed into:
81373 **
81374 ** SELECT a+b, c+d FROM t1 ORDER BY (a+b) COLLATE nocase;
81375 **
81376 ** The nSubquery parameter specifies how many levels of subquery the
81377 ** alias is removed from the original expression. The usual value is
81378 ** zero but it might be more if the alias is contained within a subquery
81379 ** of the original expression. The Expr.op2 field of TK_AGG_FUNCTION
81380 ** structures must be increased by the nSubquery amount.
81381 */
81382 static void resolveAlias(
@@ -80967,11 +81392,10 @@
81392 sqlite3 *db; /* The database connection */
81393
81394 assert( iCol>=0 && iCol<pEList->nExpr );
81395 pOrig = pEList->a[iCol].pExpr;
81396 assert( pOrig!=0 );
 
81397 db = pParse->db;
81398 pDup = sqlite3ExprDup(db, pOrig, 0);
81399 if( pDup==0 ) return;
81400 if( pOrig->op!=TK_COLUMN && zType[0]!='G' ){
81401 incrAggFunctionDepth(pDup, nSubquery);
@@ -81861,13 +82285,15 @@
82285 pNew->flags |= EP_IntValue;
82286 pNew->u.iValue = iCol;
82287 if( pItem->pExpr==pE ){
82288 pItem->pExpr = pNew;
82289 }else{
82290 Expr *pParent = pItem->pExpr;
82291 assert( pParent->op==TK_COLLATE );
82292 while( pParent->pLeft->op==TK_COLLATE ) pParent = pParent->pLeft;
82293 assert( pParent->pLeft==pE );
82294 pParent->pLeft = pNew;
82295 }
82296 sqlite3ExprDelete(db, pE);
82297 pItem->u.x.iOrderByCol = (u16)iCol;
82298 pItem->done = 1;
82299 }else{
@@ -82054,10 +82480,24 @@
82480 sNC.pParse = pParse;
82481 if( sqlite3ResolveExprNames(&sNC, p->pLimit) ||
82482 sqlite3ResolveExprNames(&sNC, p->pOffset) ){
82483 return WRC_Abort;
82484 }
82485
82486 /* If the SF_Converted flags is set, then this Select object was
82487 ** was created by the convertCompoundSelectToSubquery() function.
82488 ** In this case the ORDER BY clause (p->pOrderBy) should be resolved
82489 ** as if it were part of the sub-query, not the parent. This block
82490 ** moves the pOrderBy down to the sub-query. It will be moved back
82491 ** after the names have been resolved. */
82492 if( p->selFlags & SF_Converted ){
82493 Select *pSub = p->pSrc->a[0].pSelect;
82494 assert( p->pSrc->nSrc==1 && p->pOrderBy );
82495 assert( pSub->pPrior && pSub->pOrderBy==0 );
82496 pSub->pOrderBy = p->pOrderBy;
82497 p->pOrderBy = 0;
82498 }
82499
82500 /* Recursively resolve names in all subqueries
82501 */
82502 for(i=0; i<p->pSrc->nSrc; i++){
82503 struct SrcList_item *pItem = &p->pSrc->a[i];
@@ -82135,17 +82575,35 @@
82575 /* The ORDER BY and GROUP BY clauses may not refer to terms in
82576 ** outer queries
82577 */
82578 sNC.pNext = 0;
82579 sNC.ncFlags |= NC_AllowAgg;
82580
82581 /* If this is a converted compound query, move the ORDER BY clause from
82582 ** the sub-query back to the parent query. At this point each term
82583 ** within the ORDER BY clause has been transformed to an integer value.
82584 ** These integers will be replaced by copies of the corresponding result
82585 ** set expressions by the call to resolveOrderGroupBy() below. */
82586 if( p->selFlags & SF_Converted ){
82587 Select *pSub = p->pSrc->a[0].pSelect;
82588 p->pOrderBy = pSub->pOrderBy;
82589 pSub->pOrderBy = 0;
82590 }
82591
82592 /* Process the ORDER BY clause for singleton SELECT statements.
82593 ** The ORDER BY clause for compounds SELECT statements is handled
82594 ** below, after all of the result-sets for all of the elements of
82595 ** the compound have been resolved.
82596 **
82597 ** If there is an ORDER BY clause on a term of a compound-select other
82598 ** than the right-most term, then that is a syntax error. But the error
82599 ** is not detected until much later, and so we need to go ahead and
82600 ** resolve those symbols on the incorrect ORDER BY for consistency.
82601 */
82602 if( isCompound<=nCompound /* Defer right-most ORDER BY of a compound */
82603 && resolveOrderGroupBy(&sNC, p, p->pOrderBy, "ORDER")
82604 ){
82605 return WRC_Abort;
82606 }
82607 if( db->mallocFailed ){
82608 return WRC_Abort;
82609 }
@@ -83593,11 +84051,12 @@
84051 SQLITE_PRIVATE u32 sqlite3ExprListFlags(const ExprList *pList){
84052 int i;
84053 u32 m = 0;
84054 if( pList ){
84055 for(i=0; i<pList->nExpr; i++){
84056 Expr *pExpr = pList->a[i].pExpr;
84057 if( ALWAYS(pExpr) ) m |= pExpr->flags;
84058 }
84059 }
84060 return m;
84061 }
84062
@@ -84033,11 +84492,11 @@
84492 /* Check to see if an existing table or index can be used to
84493 ** satisfy the query. This is preferable to generating a new
84494 ** ephemeral table.
84495 */
84496 p = (ExprHasProperty(pX, EP_xIsSelect) ? pX->x.pSelect : 0);
84497 if( pParse->nErr==0 && isCandidateForInOpt(p) ){
84498 sqlite3 *db = pParse->db; /* Database connection */
84499 Table *pTab; /* Table <table>. */
84500 Expr *pExpr; /* Expression <column> */
84501 i16 iCol; /* Index of column <column> */
84502 i16 iDb; /* Database idx for pTab */
@@ -84358,10 +84817,11 @@
84817 }
84818 sqlite3ExprDelete(pParse->db, pSel->pLimit);
84819 pSel->pLimit = sqlite3PExpr(pParse, TK_INTEGER, 0, 0,
84820 &sqlite3IntTokens[1]);
84821 pSel->iLimit = 0;
84822 pSel->selFlags &= ~SF_MultiValue;
84823 if( sqlite3Select(pParse, pSel, &dest) ){
84824 return 0;
84825 }
84826 rReg = dest.iSDParm;
84827 ExprSetVVAProperty(pExpr, EP_NoReduce);
@@ -85723,11 +86183,11 @@
86183 sqlite3TreeViewLine(pView,"AS %Q", pExpr->u.zToken);
86184 sqlite3TreeViewExpr(pView, pExpr->pLeft, 0);
86185 break;
86186 }
86187 case TK_ID: {
86188 sqlite3TreeViewLine(pView,"ID \"%w\"", pExpr->u.zToken);
86189 break;
86190 }
86191 #ifndef SQLITE_OMIT_CAST
86192 case TK_CAST: {
86193 /* Expressions of the form: CAST(pLeft AS token) */
@@ -86358,11 +86818,11 @@
86818 if( ALWAYS((combinedFlags & EP_TokenOnly)==0) ){
86819 if( combinedFlags & EP_xIsSelect ) return 2;
86820 if( sqlite3ExprCompare(pA->pLeft, pB->pLeft, iTab) ) return 2;
86821 if( sqlite3ExprCompare(pA->pRight, pB->pRight, iTab) ) return 2;
86822 if( sqlite3ExprListCompare(pA->x.pList, pB->x.pList, iTab) ) return 2;
86823 if( ALWAYS((combinedFlags & EP_Reduced)==0) && pA->op!=TK_STRING ){
86824 if( pA->iColumn!=pB->iColumn ) return 2;
86825 if( pA->iTable!=pB->iTable
86826 && (pA->iTable!=iTab || NEVER(pB->iTable>=0)) ) return 2;
86827 }
86828 }
@@ -86890,10 +87350,11 @@
87350 do {
87351 z += n;
87352 n = sqlite3GetToken(z, &token);
87353 }while( token==TK_SPACE );
87354
87355 if( token==TK_ILLEGAL ) break;
87356 zParent = sqlite3DbStrNDup(db, (const char *)z, n);
87357 if( zParent==0 ) break;
87358 sqlite3Dequote(zParent);
87359 if( 0==sqlite3StrICmp((const char *)zOld, zParent) ){
87360 char *zOut = sqlite3MPrintf(db, "%s%.*s\"%w\"",
@@ -89116,18 +89577,21 @@
89577 pIndex = sqlite3FindIndex(pInfo->db, argv[1], pInfo->zDatabase);
89578 }
89579 z = argv[2];
89580
89581 if( pIndex ){
89582 tRowcnt *aiRowEst = 0;
89583 int nCol = pIndex->nKeyCol+1;
89584 #ifdef SQLITE_ENABLE_STAT3_OR_STAT4
89585 /* Index.aiRowEst may already be set here if there are duplicate
89586 ** sqlite_stat1 entries for this index. In that case just clobber
89587 ** the old data with the new instead of allocating a new array. */
89588 if( pIndex->aiRowEst==0 ){
89589 pIndex->aiRowEst = (tRowcnt*)sqlite3MallocZero(sizeof(tRowcnt) * nCol);
89590 if( pIndex->aiRowEst==0 ) pInfo->db->mallocFailed = 1;
89591 }
89592 aiRowEst = pIndex->aiRowEst;
89593 #endif
89594 pIndex->bUnordered = 0;
89595 decodeIntArray((char*)z, nCol, aiRowEst, pIndex->aiRowLogEst, pIndex);
89596 if( pIndex->pPartIdxWhere==0 ) pTable->nRowLogEst = pIndex->aiRowLogEst[0];
89597 }else{
@@ -89786,11 +90250,11 @@
90250 }
90251
90252 sqlite3BtreeClose(pDb->pBt);
90253 pDb->pBt = 0;
90254 pDb->pSchema = 0;
90255 sqlite3CollapseDatabaseArray(db);
90256 return;
90257
90258 detach_error:
90259 sqlite3_result_error(context, zErr, -1);
90260 }
@@ -89820,11 +90284,10 @@
90284 if(
90285 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pFilename)) ||
90286 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pDbname)) ||
90287 SQLITE_OK!=(rc = resolveAttachExpr(&sName, pKey))
90288 ){
 
90289 goto attach_end;
90290 }
90291
90292 #ifndef SQLITE_OMIT_AUTHORIZATION
90293 if( pAuthArg ){
@@ -90142,11 +90605,11 @@
90605 ** and attempts to write the column will be ignored.
90606 **
90607 ** Setting the auth function to NULL disables this hook. The default
90608 ** setting of the auth function is NULL.
90609 */
90610 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
90611 sqlite3 *db,
90612 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
90613 void *pArg
90614 ){
90615 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -90479,13 +90942,15 @@
90942 sqlite3 *db;
90943 Vdbe *v;
90944
90945 assert( pParse->pToplevel==0 );
90946 db = pParse->db;
 
90947 if( pParse->nested ) return;
90948 if( db->mallocFailed || pParse->nErr ){
90949 if( pParse->rc==SQLITE_OK ) pParse->rc = SQLITE_ERROR;
90950 return;
90951 }
90952
90953 /* Begin by generating some termination code at the end of the
90954 ** vdbe program
90955 */
90956 v = sqlite3GetVdbe(pParse);
@@ -90563,11 +91028,11 @@
91028 }
91029
91030
91031 /* Get the VDBE program ready for execution
91032 */
91033 if( v && pParse->nErr==0 && !db->mallocFailed ){
91034 assert( pParse->iCacheLevel==0 ); /* Disables and re-enables match */
91035 /* A minimum of one cursor is required if autoincrement is used
91036 * See ticket [a696379c1f08866] */
91037 if( pParse->pAinc!=0 && pParse->nTab==0 ) pParse->nTab = 1;
91038 sqlite3VdbeMakeReady(v, pParse);
@@ -91098,18 +91563,16 @@
91563 sqlite3 *db = pParse->db;
91564
91565 if( ALWAYS(pName2!=0) && pName2->n>0 ){
91566 if( db->init.busy ) {
91567 sqlite3ErrorMsg(pParse, "corrupt database");
 
91568 return -1;
91569 }
91570 *pUnqual = pName2;
91571 iDb = sqlite3FindDb(db, pName1);
91572 if( iDb<0 ){
91573 sqlite3ErrorMsg(pParse, "unknown database %T", pName1);
 
91574 return -1;
91575 }
91576 }else{
91577 assert( db->init.iDb==0 || db->init.busy );
91578 iDb = db->init.iDb;
@@ -91264,11 +91727,11 @@
91727 pTable = sqlite3FindTable(db, zName, zDb);
91728 if( pTable ){
91729 if( !noErr ){
91730 sqlite3ErrorMsg(pParse, "table %T already exists", pName);
91731 }else{
91732 assert( !db->init.busy || CORRUPT_DB );
91733 sqlite3CodeVerifySchema(pParse, iDb);
91734 }
91735 goto begin_table_error;
91736 }
91737 if( sqlite3FindIndex(db, zName, zDb)!=0 ){
@@ -91553,11 +92016,12 @@
92016 Column *pCol;
92017
92018 p = pParse->pNewTable;
92019 if( p==0 || NEVER(p->nCol<1) ) return;
92020 pCol = &p->aCol[p->nCol-1];
92021 assert( pCol->zType==0 || CORRUPT_DB );
92022 sqlite3DbFree(pParse->db, pCol->zType);
92023 pCol->zType = sqlite3NameFromToken(pParse->db, pType);
92024 pCol->affinity = sqlite3AffinityType(pCol->zType, &pCol->szEst);
92025 }
92026
92027 /*
@@ -92787,10 +93251,11 @@
93251 if( db->mallocFailed ){
93252 goto exit_drop_table;
93253 }
93254 assert( pParse->nErr==0 );
93255 assert( pName->nSrc==1 );
93256 if( sqlite3ReadSchema(pParse) ) goto exit_drop_table;
93257 if( noErr ) db->suppressErr++;
93258 pTab = sqlite3LocateTableItem(pParse, isView, &pName->a[0]);
93259 if( noErr ) db->suppressErr--;
93260
93261 if( pTab==0 ){
@@ -93100,11 +93565,12 @@
93565 sqlite3UniqueConstraint(pParse, OE_Abort, pIndex);
93566 }else{
93567 addr2 = sqlite3VdbeCurrentAddr(v);
93568 }
93569 sqlite3VdbeAddOp3(v, OP_SorterData, iSorter, regRecord, iIdx);
93570 sqlite3VdbeAddOp3(v, OP_Last, iIdx, 0, -1);
93571 sqlite3VdbeAddOp3(v, OP_IdxInsert, iIdx, regRecord, 0);
93572 sqlite3VdbeChangeP5(v, OPFLAG_USESEEKRESULT);
93573 sqlite3ReleaseTempReg(pParse, regRecord);
93574 sqlite3VdbeAddOp2(v, OP_SorterNext, iSorter, addr2); VdbeCoverage(v);
93575 sqlite3VdbeJumpHere(v, addr1);
93576
@@ -93193,12 +93659,11 @@
93659 int nExtra = 0; /* Space allocated for zExtra[] */
93660 int nExtraCol; /* Number of extra columns needed */
93661 char *zExtra = 0; /* Extra space after the Index object */
93662 Index *pPk = 0; /* PRIMARY KEY index for WITHOUT ROWID tables */
93663
93664 if( db->mallocFailed || IN_DECLARE_VTAB || pParse->nErr>0 ){
 
93665 goto exit_create_index;
93666 }
93667 if( SQLITE_OK!=sqlite3ReadSchema(pParse) ){
93668 goto exit_create_index;
93669 }
@@ -94113,11 +94578,10 @@
94578 ** operator with A. This routine shifts that operator over to B.
94579 */
94580 SQLITE_PRIVATE void sqlite3SrcListShiftJoinType(SrcList *p){
94581 if( p ){
94582 int i;
 
94583 for(i=p->nSrc-1; i>0; i--){
94584 p->a[i].jointype = p->a[i-1].jointype;
94585 }
94586 p->a[0].jointype = 0;
94587 }
@@ -94360,12 +94824,11 @@
94824 char *zErr;
94825 int j;
94826 StrAccum errMsg;
94827 Table *pTab = pIdx->pTable;
94828
94829 sqlite3StrAccumInit(&errMsg, pParse->db, 0, 0, 200);
 
94830 for(j=0; j<pIdx->nKeyCol; j++){
94831 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
94832 if( j ) sqlite3StrAccumAppend(&errMsg, ", ", 2);
94833 sqlite3StrAccumAppendAll(&errMsg, pTab->zName);
94834 sqlite3StrAccumAppend(&errMsg, ".", 1);
@@ -96190,17 +96653,17 @@
96653 ){
96654 PrintfArguments x;
96655 StrAccum str;
96656 const char *zFormat;
96657 int n;
96658 sqlite3 *db = sqlite3_context_db_handle(context);
96659
96660 if( argc>=1 && (zFormat = (const char*)sqlite3_value_text(argv[0]))!=0 ){
96661 x.nArg = argc-1;
96662 x.nUsed = 0;
96663 x.apArg = argv+1;
96664 sqlite3StrAccumInit(&str, db, 0, 0, db->aLimit[SQLITE_LIMIT_LENGTH]);
 
96665 sqlite3XPrintf(&str, SQLITE_PRINTF_SQLFUNC, zFormat, &x);
96666 n = str.nChar;
96667 sqlite3_result_text(context, sqlite3StrAccumFinish(&str), n,
96668 SQLITE_DYNAMIC);
96669 }
@@ -96346,11 +96809,11 @@
96809 sqlite3_result_double(context, r);
96810 }
96811 #endif
96812
96813 /*
96814 ** Allocate nByte bytes of space using sqlite3Malloc(). If the
96815 ** allocation fails, call sqlite3_result_error_nomem() to notify
96816 ** the database handle that malloc() has failed and return NULL.
96817 ** If nByte is larger than the maximum string or blob length, then
96818 ** raise an SQLITE_TOOBIG exception and return NULL.
96819 */
@@ -96720,11 +97183,11 @@
97183 }
97184
97185 /*
97186 ** The sqlite3_strglob() interface.
97187 */
97188 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlobPattern, const char *zString){
97189 return patternCompare((u8*)zGlobPattern, (u8*)zString, &globInfo, 0)==0;
97190 }
97191
97192 /*
97193 ** Count the number of times that the LIKE operator (or GLOB which is
@@ -97015,11 +97478,11 @@
97478 int argc,
97479 sqlite3_value **argv
97480 ){
97481 unsigned char *z, *zOut;
97482 int i;
97483 zOut = z = sqlite3_malloc64( argc*4+1 );
97484 if( z==0 ){
97485 sqlite3_result_error_nomem(context);
97486 return;
97487 }
97488 for(i=0; i<argc; i++){
@@ -97163,11 +97626,11 @@
97626 sqlite3_result_error_toobig(context);
97627 sqlite3_free(zOut);
97628 return;
97629 }
97630 zOld = zOut;
97631 zOut = sqlite3_realloc64(zOut, (int)nOut);
97632 if( zOut==0 ){
97633 sqlite3_result_error_nomem(context);
97634 sqlite3_free(zOld);
97635 return;
97636 }
@@ -97525,12 +97988,11 @@
97988 if( sqlite3_value_type(argv[0])==SQLITE_NULL ) return;
97989 pAccum = (StrAccum*)sqlite3_aggregate_context(context, sizeof(*pAccum));
97990
97991 if( pAccum ){
97992 sqlite3 *db = sqlite3_context_db_handle(context);
97993 int firstTerm = pAccum->mxAlloc==0;
 
97994 pAccum->mxAlloc = db->aLimit[SQLITE_LIMIT_LENGTH];
97995 if( !firstTerm ){
97996 if( argc==2 ){
97997 zSep = (char*)sqlite3_value_text(argv[1]);
97998 nSep = sqlite3_value_bytes(argv[1]);
@@ -98946,11 +99408,12 @@
99408 int iFromCol; /* Idx of column in child table */
99409 Expr *pEq; /* tFromCol = OLD.tToCol */
99410
99411 iFromCol = aiCol ? aiCol[i] : pFKey->aCol[0].iFrom;
99412 assert( iFromCol>=0 );
99413 assert( pIdx!=0 || (pTab->iPKey>=0 && pTab->iPKey<pTab->nCol) );
99414 tToCol.z = pTab->aCol[pIdx ? pIdx->aiColumn[i] : pTab->iPKey].zName;
99415 tFromCol.z = pFKey->pFrom->aCol[iFromCol].zName;
99416
99417 tToCol.n = sqlite3Strlen30(tToCol.z);
99418 tFromCol.n = sqlite3Strlen30(tFromCol.z);
99419
@@ -98958,14 +99421,14 @@
99421 ** that the "OLD.zToCol" term is on the LHS of the = operator, so
99422 ** that the affinity and collation sequence associated with the
99423 ** parent table are used for the comparison. */
99424 pEq = sqlite3PExpr(pParse, TK_EQ,
99425 sqlite3PExpr(pParse, TK_DOT,
99426 sqlite3ExprAlloc(db, TK_ID, &tOld, 0),
99427 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)
99428 , 0),
99429 sqlite3ExprAlloc(db, TK_ID, &tFromCol, 0)
99430 , 0);
99431 pWhere = sqlite3ExprAnd(db, pWhere, pEq);
99432
99433 /* For ON UPDATE, construct the next term of the WHEN clause.
99434 ** The final WHEN clause will be like this:
@@ -98973,27 +99436,27 @@
99436 ** WHEN NOT(old.col1 IS new.col1 AND ... AND old.colN IS new.colN)
99437 */
99438 if( pChanges ){
99439 pEq = sqlite3PExpr(pParse, TK_IS,
99440 sqlite3PExpr(pParse, TK_DOT,
99441 sqlite3ExprAlloc(db, TK_ID, &tOld, 0),
99442 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0),
99443 0),
99444 sqlite3PExpr(pParse, TK_DOT,
99445 sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
99446 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0),
99447 0),
99448 0);
99449 pWhen = sqlite3ExprAnd(db, pWhen, pEq);
99450 }
99451
99452 if( action!=OE_Restrict && (action!=OE_Cascade || pChanges) ){
99453 Expr *pNew;
99454 if( action==OE_Cascade ){
99455 pNew = sqlite3PExpr(pParse, TK_DOT,
99456 sqlite3ExprAlloc(db, TK_ID, &tNew, 0),
99457 sqlite3ExprAlloc(db, TK_ID, &tToCol, 0)
99458 , 0);
99459 }else if( action==OE_SetDflt ){
99460 Expr *pDflt = pFKey->pFrom->aCol[iFromCol].pDflt;
99461 if( pDflt ){
99462 pNew = sqlite3ExprDup(db, pDflt, 0);
@@ -99036,17 +99499,16 @@
99499 db->lookaside.bEnabled = 0;
99500
99501 pTrigger = (Trigger *)sqlite3DbMallocZero(db,
99502 sizeof(Trigger) + /* struct Trigger */
99503 sizeof(TriggerStep) + /* Single step in trigger program */
99504 nFrom + 1 /* Space for pStep->zTarget */
99505 );
99506 if( pTrigger ){
99507 pStep = pTrigger->step_list = (TriggerStep *)&pTrigger[1];
99508 pStep->zTarget = (char *)&pStep[1];
99509 memcpy((char *)pStep->zTarget, zFrom, nFrom);
 
99510
99511 pStep->pWhere = sqlite3ExprDup(db, pWhere, EXPRDUP_REDUCE);
99512 pStep->pExprList = sqlite3ExprListDup(db, pList, EXPRDUP_REDUCE);
99513 pStep->pSelect = sqlite3SelectDup(db, pSelect, EXPRDUP_REDUCE);
99514 if( pWhen ){
@@ -99507,24 +99969,27 @@
99969 );
99970
99971 /*
99972 ** This routine is called to handle SQL of the following forms:
99973 **
99974 ** insert into TABLE (IDLIST) values(EXPRLIST),(EXPRLIST),...
99975 ** insert into TABLE (IDLIST) select
99976 ** insert into TABLE (IDLIST) default values
99977 **
99978 ** The IDLIST following the table name is always optional. If omitted,
99979 ** then a list of all (non-hidden) columns for the table is substituted.
99980 ** The IDLIST appears in the pColumn parameter. pColumn is NULL if IDLIST
99981 ** is omitted.
99982 **
99983 ** For the pSelect parameter holds the values to be inserted for the
99984 ** first two forms shown above. A VALUES clause is really just short-hand
99985 ** for a SELECT statement that omits the FROM clause and everything else
99986 ** that follows. If the pSelect parameter is NULL, that means that the
99987 ** DEFAULT VALUES form of the INSERT statement is intended.
99988 **
99989 ** The code generated follows one of four templates. For a simple
99990 ** insert with data coming from a single-row VALUES clause, the code executes
99991 ** once straight down through. Pseudo-code follows (we call this
99992 ** the "1st template"):
99993 **
99994 ** open write cursor to <table> and its indices
99995 ** put VALUES clause expressions into registers
@@ -99627,11 +100092,11 @@
100092 int iDb; /* Index of database holding TABLE */
100093 Db *pDb; /* The database containing table being inserted into */
100094 u8 useTempTable = 0; /* Store SELECT results in intermediate table */
100095 u8 appendFlag = 0; /* True if the insert is likely to be an append */
100096 u8 withoutRowid; /* 0 for normal table. 1 for WITHOUT ROWID table */
100097 u8 bIdListInOrder; /* True if IDLIST is in table order */
100098 ExprList *pList = 0; /* List of VALUES() to be inserted */
100099
100100 /* Register allocations */
100101 int regFromSelect = 0;/* Base register for data coming from SELECT */
100102 int regAutoinc = 0; /* Register holding the AUTOINCREMENT counter */
@@ -99652,12 +100117,12 @@
100117 if( pParse->nErr || db->mallocFailed ){
100118 goto insert_cleanup;
100119 }
100120
100121 /* If the Select object is really just a simple VALUES() list with a
100122 ** single row (the common case) then keep that one row of values
100123 ** and discard the other (unused) parts of the pSelect object
100124 */
100125 if( pSelect && (pSelect->selFlags & SF_Values)!=0 && pSelect->pPrior==0 ){
100126 pList = pSelect->pEList;
100127 pSelect->pEList = 0;
100128 sqlite3SelectDelete(db, pSelect);
@@ -99761,10 +100226,11 @@
100226 ** the index into IDLIST of the primary key column. ipkColumn is
100227 ** the index of the primary key as it appears in IDLIST, not as
100228 ** is appears in the original table. (The index of the INTEGER
100229 ** PRIMARY KEY in the original table is pTab->iPKey.)
100230 */
100231 bIdListInOrder = (pTab->tabFlags & TF_OOOHidden)==0;
100232 if( pColumn ){
100233 for(i=0; i<pColumn->nId; i++){
100234 pColumn->a[i].idx = -1;
100235 }
100236 for(i=0; i<pColumn->nId; i++){
@@ -99796,11 +100262,12 @@
100262 ** is coming from a SELECT statement, then generate a co-routine that
100263 ** produces a single row of the SELECT on each invocation. The
100264 ** co-routine is the common header to the 3rd and 4th templates.
100265 */
100266 if( pSelect ){
100267 /* Data is coming from a SELECT or from a multi-row VALUES clause.
100268 ** Generate a co-routine to run the SELECT. */
100269 int regYield; /* Register holding co-routine entry-point */
100270 int addrTop; /* Top of the co-routine */
100271 int rc; /* Result code */
100272
100273 regYield = ++pParse->nMem;
@@ -99809,12 +100276,11 @@
100276 sqlite3SelectDestInit(&dest, SRT_Coroutine, regYield);
100277 dest.iSdst = bIdListInOrder ? regData : 0;
100278 dest.nSdst = pTab->nCol;
100279 rc = sqlite3Select(pParse, pSelect, &dest);
100280 regFromSelect = dest.iSdst;
100281 if( rc || db->mallocFailed || pParse->nErr ) goto insert_cleanup;
 
100282 sqlite3VdbeAddOp1(v, OP_EndCoroutine, regYield);
100283 sqlite3VdbeJumpHere(v, addrTop - 1); /* label B: */
100284 assert( pSelect->pEList );
100285 nColumn = pSelect->pEList->nExpr;
100286
@@ -99858,12 +100324,12 @@
100324 sqlite3VdbeJumpHere(v, addrL);
100325 sqlite3ReleaseTempReg(pParse, regRec);
100326 sqlite3ReleaseTempReg(pParse, regTempRowid);
100327 }
100328 }else{
100329 /* This is the case if the data for the INSERT is coming from a
100330 ** single-row VALUES clause
100331 */
100332 NameContext sNC;
100333 memset(&sNC, 0, sizeof(sNC));
100334 sNC.pParse = pParse;
100335 srcTab = -1;
@@ -100930,10 +101396,11 @@
101396 Table *pDest, /* The table we are inserting into */
101397 Select *pSelect, /* A SELECT statement to use as the data source */
101398 int onError, /* How to handle constraint errors */
101399 int iDbDest /* The database of pDest */
101400 ){
101401 sqlite3 *db = pParse->db;
101402 ExprList *pEList; /* The result set of the SELECT */
101403 Table *pSrc; /* The table in the FROM clause of SELECT */
101404 Index *pSrcIdx, *pDestIdx; /* Source and destination indices */
101405 struct SrcList_item *pItem; /* An element of pSelect->pSrc */
101406 int i; /* Loop counter */
@@ -101077,15 +101544,15 @@
101544 ** But the main beneficiary of the transfer optimization is the VACUUM
101545 ** command, and the VACUUM command disables foreign key constraints. So
101546 ** the extra complication to make this rule less restrictive is probably
101547 ** not worth the effort. Ticket [6284df89debdfa61db8073e062908af0c9b6118e]
101548 */
101549 if( (db->flags & SQLITE_ForeignKeys)!=0 && pDest->pFKey!=0 ){
101550 return 0;
101551 }
101552 #endif
101553 if( (db->flags & SQLITE_CountRows)!=0 ){
101554 return 0; /* xfer opt does not play well with PRAGMA count_changes */
101555 }
101556
101557 /* If we get this far, it means that the xfer optimization is at
101558 ** least a possibility, though it might only work if the destination
@@ -101092,28 +101559,32 @@
101559 ** table (tab1) is initially empty.
101560 */
101561 #ifdef SQLITE_TEST
101562 sqlite3_xferopt_count++;
101563 #endif
101564 iDbSrc = sqlite3SchemaToIndex(db, pSrc->pSchema);
101565 v = sqlite3GetVdbe(pParse);
101566 sqlite3CodeVerifySchema(pParse, iDbSrc);
101567 iSrc = pParse->nTab++;
101568 iDest = pParse->nTab++;
101569 regAutoinc = autoIncBegin(pParse, iDbDest, pDest);
101570 regData = sqlite3GetTempReg(pParse);
101571 regRowid = sqlite3GetTempReg(pParse);
101572 sqlite3OpenTable(pParse, iDest, iDbDest, pDest, OP_OpenWrite);
101573 assert( HasRowid(pDest) || destHasUniqueIdx );
101574 if( (db->flags & SQLITE_Vacuum)==0 && (
101575 (pDest->iPKey<0 && pDest->pIndex!=0) /* (1) */
101576 || destHasUniqueIdx /* (2) */
101577 || (onError!=OE_Abort && onError!=OE_Rollback) /* (3) */
101578 )){
101579 /* In some circumstances, we are able to run the xfer optimization
101580 ** only if the destination table is initially empty. Unless the
101581 ** SQLITE_Vacuum flag is set, this block generates code to make
101582 ** that determination. If SQLITE_Vacuum is set, then the destination
101583 ** table is always empty.
101584 **
101585 ** Conditions under which the destination must be empty:
101586 **
101587 ** (1) There is no INTEGER PRIMARY KEY but there are indices.
101588 ** (If the destination is not initially empty, the rowid fields
101589 ** of index entries might need to change.)
101590 **
@@ -101152,10 +101623,11 @@
101623 }else{
101624 sqlite3TableLock(pParse, iDbDest, pDest->tnum, 1, pDest->zName);
101625 sqlite3TableLock(pParse, iDbSrc, pSrc->tnum, 0, pSrc->zName);
101626 }
101627 for(pDestIdx=pDest->pIndex; pDestIdx; pDestIdx=pDestIdx->pNext){
101628 u8 useSeekResult = 0;
101629 for(pSrcIdx=pSrc->pIndex; ALWAYS(pSrcIdx); pSrcIdx=pSrcIdx->pNext){
101630 if( xferCompatibleIndex(pDestIdx, pSrcIdx) ) break;
101631 }
101632 assert( pSrcIdx );
101633 sqlite3VdbeAddOp3(v, OP_OpenRead, iSrc, pSrcIdx->tnum, iDbSrc);
@@ -101165,11 +101637,37 @@
101637 sqlite3VdbeSetP4KeyInfo(pParse, pDestIdx);
101638 sqlite3VdbeChangeP5(v, OPFLAG_BULKCSR);
101639 VdbeComment((v, "%s", pDestIdx->zName));
101640 addr1 = sqlite3VdbeAddOp2(v, OP_Rewind, iSrc, 0); VdbeCoverage(v);
101641 sqlite3VdbeAddOp2(v, OP_RowKey, iSrc, regData);
101642 if( db->flags & SQLITE_Vacuum ){
101643 /* This INSERT command is part of a VACUUM operation, which guarantees
101644 ** that the destination table is empty. If all indexed columns use
101645 ** collation sequence BINARY, then it can also be assumed that the
101646 ** index will be populated by inserting keys in strictly sorted
101647 ** order. In this case, instead of seeking within the b-tree as part
101648 ** of every OP_IdxInsert opcode, an OP_Last is added before the
101649 ** OP_IdxInsert to seek to the point within the b-tree where each key
101650 ** should be inserted. This is faster.
101651 **
101652 ** If any of the indexed columns use a collation sequence other than
101653 ** BINARY, this optimization is disabled. This is because the user
101654 ** might change the definition of a collation sequence and then run
101655 ** a VACUUM command. In that case keys may not be written in strictly
101656 ** sorted order. */
101657 for(i=0; i<pSrcIdx->nColumn; i++){
101658 char *zColl = pSrcIdx->azColl[i];
101659 assert( zColl!=0 );
101660 if( sqlite3_stricmp("BINARY", zColl) ) break;
101661 }
101662 if( i==pSrcIdx->nColumn ){
101663 useSeekResult = OPFLAG_USESEEKRESULT;
101664 sqlite3VdbeAddOp3(v, OP_Last, iDest, 0, -1);
101665 }
101666 }
101667 sqlite3VdbeAddOp3(v, OP_IdxInsert, iDest, regData, 1);
101668 sqlite3VdbeChangeP5(v, useSeekResult);
101669 sqlite3VdbeAddOp2(v, OP_Next, iSrc, addr1+1); VdbeCoverage(v);
101670 sqlite3VdbeJumpHere(v, addr1);
101671 sqlite3VdbeAddOp2(v, OP_Close, iSrc, 0);
101672 sqlite3VdbeAddOp2(v, OP_Close, iDest, 0);
101673 }
@@ -101215,11 +101713,11 @@
101713 ** If the SQL is a query, then for each row in the query result
101714 ** the xCallback() function is called. pArg becomes the first
101715 ** argument to xCallback(). If xCallback=NULL then no callback
101716 ** is invoked, even for queries.
101717 */
101718 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
101719 sqlite3 *db, /* The database on which the SQL executes */
101720 const char *zSql, /* The SQL to be executed */
101721 sqlite3_callback xCallback, /* Invoke this callback routine */
101722 void *pArg, /* First argument to xCallback() */
101723 char **pzErrMsg /* Write error messages here */
@@ -102284,11 +102782,11 @@
102782 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
102783 char *zErrmsg = 0;
102784 const char *zEntry;
102785 char *zAltEntry = 0;
102786 void **aHandle;
102787 u64 nMsg = 300 + sqlite3Strlen30(zFile);
102788 int ii;
102789
102790 /* Shared library endings to try if zFile cannot be loaded as written */
102791 static const char *azEndings[] = {
102792 #if SQLITE_OS_WIN
@@ -102327,11 +102825,11 @@
102825 sqlite3_free(zAltFile);
102826 }
102827 #endif
102828 if( handle==0 ){
102829 if( pzErrMsg ){
102830 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
102831 if( zErrmsg ){
102832 sqlite3_snprintf(nMsg, zErrmsg,
102833 "unable to open shared library [%s]", zFile);
102834 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102835 }
@@ -102353,11 +102851,11 @@
102851 ** C:/lib/mathfuncs.dll ==> sqlite3_mathfuncs_init
102852 */
102853 if( xInit==0 && zProc==0 ){
102854 int iFile, iEntry, c;
102855 int ncFile = sqlite3Strlen30(zFile);
102856 zAltEntry = sqlite3_malloc64(ncFile+30);
102857 if( zAltEntry==0 ){
102858 sqlite3OsDlClose(pVfs, handle);
102859 return SQLITE_NOMEM;
102860 }
102861 memcpy(zAltEntry, "sqlite3_", 8);
@@ -102375,11 +102873,11 @@
102873 sqlite3OsDlSym(pVfs, handle, zEntry);
102874 }
102875 if( xInit==0 ){
102876 if( pzErrMsg ){
102877 nMsg += sqlite3Strlen30(zEntry);
102878 *pzErrMsg = zErrmsg = sqlite3_malloc64(nMsg);
102879 if( zErrmsg ){
102880 sqlite3_snprintf(nMsg, zErrmsg,
102881 "no entry point [%s] in shared library [%s]", zEntry, zFile);
102882 sqlite3OsDlError(pVfs, nMsg-1, zErrmsg);
102883 }
@@ -102410,11 +102908,11 @@
102908 db->aExtension = aHandle;
102909
102910 db->aExtension[db->nExtension++] = handle;
102911 return SQLITE_OK;
102912 }
102913 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
102914 sqlite3 *db, /* Load the extension into this database connection */
102915 const char *zFile, /* Name of the shared library containing extension */
102916 const char *zProc, /* Entry point. Use "sqlite3_extension_init" if 0 */
102917 char **pzErrMsg /* Put error message here if not 0 */
102918 ){
@@ -102441,11 +102939,11 @@
102939
102940 /*
102941 ** Enable or disable extension loading. Extension loading is disabled by
102942 ** default so as not to open security holes in older applications.
102943 */
102944 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff){
102945 sqlite3_mutex_enter(db->mutex);
102946 if( onoff ){
102947 db->flags |= SQLITE_LoadExtension;
102948 }else{
102949 db->flags &= ~SQLITE_LoadExtension;
@@ -102474,11 +102972,11 @@
102972 ** This list is shared across threads. The SQLITE_MUTEX_STATIC_MASTER
102973 ** mutex must be held while accessing this list.
102974 */
102975 typedef struct sqlite3AutoExtList sqlite3AutoExtList;
102976 static SQLITE_WSD struct sqlite3AutoExtList {
102977 u32 nExt; /* Number of entries in aExt[] */
102978 void (**aExt)(void); /* Pointers to the extension init functions */
102979 } sqlite3Autoext = { 0, 0 };
102980
102981 /* The "wsdAutoext" macro will resolve to the autoextension
102982 ** state vector. If writable static data is unsupported on the target,
@@ -102498,32 +102996,32 @@
102996
102997 /*
102998 ** Register a statically linked extension that is automatically
102999 ** loaded by every new database connection.
103000 */
103001 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xInit)(void)){
103002 int rc = SQLITE_OK;
103003 #ifndef SQLITE_OMIT_AUTOINIT
103004 rc = sqlite3_initialize();
103005 if( rc ){
103006 return rc;
103007 }else
103008 #endif
103009 {
103010 u32 i;
103011 #if SQLITE_THREADSAFE
103012 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
103013 #endif
103014 wsdAutoextInit;
103015 sqlite3_mutex_enter(mutex);
103016 for(i=0; i<wsdAutoext.nExt; i++){
103017 if( wsdAutoext.aExt[i]==xInit ) break;
103018 }
103019 if( i==wsdAutoext.nExt ){
103020 u64 nByte = (wsdAutoext.nExt+1)*sizeof(wsdAutoext.aExt[0]);
103021 void (**aNew)(void);
103022 aNew = sqlite3_realloc64(wsdAutoext.aExt, nByte);
103023 if( aNew==0 ){
103024 rc = SQLITE_NOMEM;
103025 }else{
103026 wsdAutoext.aExt = aNew;
103027 wsdAutoext.aExt[wsdAutoext.nExt] = xInit;
@@ -102543,19 +103041,19 @@
103041 ** routine is a no-op.
103042 **
103043 ** Return 1 if xInit was found on the list and removed. Return 0 if xInit
103044 ** was not on the list.
103045 */
103046 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xInit)(void)){
103047 #if SQLITE_THREADSAFE
103048 sqlite3_mutex *mutex = sqlite3MutexAlloc(SQLITE_MUTEX_STATIC_MASTER);
103049 #endif
103050 int i;
103051 int n = 0;
103052 wsdAutoextInit;
103053 sqlite3_mutex_enter(mutex);
103054 for(i=(int)wsdAutoext.nExt-1; i>=0; i--){
103055 if( wsdAutoext.aExt[i]==xInit ){
103056 wsdAutoext.nExt--;
103057 wsdAutoext.aExt[i] = wsdAutoext.aExt[wsdAutoext.nExt];
103058 n++;
103059 break;
@@ -102566,11 +103064,11 @@
103064 }
103065
103066 /*
103067 ** Reset the automatic extension loading mechanism.
103068 */
103069 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void){
103070 #ifndef SQLITE_OMIT_AUTOINIT
103071 if( sqlite3_initialize()==SQLITE_OK )
103072 #endif
103073 {
103074 #if SQLITE_THREADSAFE
@@ -102589,11 +103087,11 @@
103087 ** Load all automatic extensions.
103088 **
103089 ** If anything goes wrong, set an error in the database connection.
103090 */
103091 SQLITE_PRIVATE void sqlite3AutoLoadExtensions(sqlite3 *db){
103092 u32 i;
103093 int go = 1;
103094 int rc;
103095 int (*xInit)(sqlite3*,char**,const sqlite3_api_routines*);
103096
103097 wsdAutoextInit;
@@ -103253,19 +103751,19 @@
103751 /*
103752 ** Generate code to return a single integer value.
103753 */
103754 static void returnSingleInt(Parse *pParse, const char *zLabel, i64 value){
103755 Vdbe *v = sqlite3GetVdbe(pParse);
103756 int nMem = ++pParse->nMem;
103757 i64 *pI64 = sqlite3DbMallocRaw(pParse->db, sizeof(value));
103758 if( pI64 ){
103759 memcpy(pI64, &value, sizeof(value));
103760 }
103761 sqlite3VdbeAddOp4(v, OP_Int64, 0, nMem, 0, (char*)pI64, P4_INT64);
103762 sqlite3VdbeSetNumCols(v, 1);
103763 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, zLabel, SQLITE_STATIC);
103764 sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
103765 }
103766
103767
103768 /*
103769 ** Set the safety_level and pager flags for pager iDb. Or if iDb<0
@@ -103426,15 +103924,15 @@
103924 aFcntl[3] = 0;
103925 db->busyHandler.nBusy = 0;
103926 rc = sqlite3_file_control(db, zDb, SQLITE_FCNTL_PRAGMA, (void*)aFcntl);
103927 if( rc==SQLITE_OK ){
103928 if( aFcntl[0] ){
103929 int nMem = ++pParse->nMem;
103930 sqlite3VdbeAddOp4(v, OP_String8, 0, nMem, 0, aFcntl[0], 0);
103931 sqlite3VdbeSetNumCols(v, 1);
103932 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "result", SQLITE_STATIC);
103933 sqlite3VdbeAddOp2(v, OP_ResultRow, nMem, 1);
103934 sqlite3_free(aFcntl[0]);
103935 }
103936 goto pragma_out;
103937 }
103938 if( rc!=SQLITE_NOTFOUND ){
@@ -104035,11 +104533,13 @@
104533 }else{
104534 if( !db->autoCommit ){
104535 sqlite3ErrorMsg(pParse,
104536 "Safety level may not be changed inside a transaction");
104537 }else{
104538 int iLevel = (getSafetyLevel(zRight,0,1)+1) & PAGER_SYNCHRONOUS_MASK;
104539 if( iLevel==0 ) iLevel = 1;
104540 pDb->safety_level = iLevel;
104541 setAllPagerFlags(db);
104542 }
104543 }
104544 break;
104545 }
@@ -104130,11 +104630,11 @@
104630 if( (pCol->colFlags & COLFLAG_PRIMKEY)==0 ){
104631 k = 0;
104632 }else if( pPk==0 ){
104633 k = 1;
104634 }else{
104635 for(k=1; k<=pTab->nCol && pPk->aiColumn[k-1]!=i; k++){}
104636 }
104637 sqlite3VdbeAddOp2(v, OP_Integer, k, 6);
104638 sqlite3VdbeAddOp2(v, OP_ResultRow, 1, 6);
104639 }
104640 }
@@ -105136,11 +105636,11 @@
105636
105637 assert( iDb>=0 && iDb<db->nDb );
105638 if( argv==0 ) return 0; /* Might happen if EMPTY_RESULT_CALLBACKS are on */
105639 if( argv[1]==0 ){
105640 corruptSchema(pData, argv[0], 0);
105641 }else if( sqlite3_strnicmp(argv[2],"create ",7)==0 ){
105642 /* Call the parser to process a CREATE TABLE, INDEX or VIEW.
105643 ** But because db->init.busy is set to 1, no VDBE code is generated
105644 ** or executed. All the parser does is build the internal data
105645 ** structures that describe the table, index, or view.
105646 */
@@ -105167,12 +105667,12 @@
105667 corruptSchema(pData, argv[0], sqlite3_errmsg(db));
105668 }
105669 }
105670 }
105671 sqlite3_finalize(pStmt);
105672 }else if( argv[0]==0 || (argv[2]!=0 && argv[2][0]!=0) ){
105673 corruptSchema(pData, argv[0], 0);
105674 }else{
105675 /* If the SQL column is blank it means this is an index that
105676 ** was created to be the PRIMARY KEY or to fulfill a UNIQUE
105677 ** constraint for a CREATE TABLE. The index should have already
105678 ** been created when we processed the CREATE TABLE. All we have
@@ -105846,11 +106346,11 @@
106346 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
106347 ** sqlite3_step(). In the new version, the original SQL text is retained
106348 ** and the statement is automatically recompiled if an schema change
106349 ** occurs.
106350 */
106351 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
106352 sqlite3 *db, /* Database handle. */
106353 const char *zSql, /* UTF-8 encoded SQL statement. */
106354 int nBytes, /* Length of zSql in bytes. */
106355 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
106356 const char **pzTail /* OUT: End of parsed string */
@@ -105858,11 +106358,11 @@
106358 int rc;
106359 rc = sqlite3LockAndPrepare(db,zSql,nBytes,0,0,ppStmt,pzTail);
106360 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
106361 return rc;
106362 }
106363 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
106364 sqlite3 *db, /* Database handle. */
106365 const char *zSql, /* UTF-8 encoded SQL statement. */
106366 int nBytes, /* Length of zSql in bytes. */
106367 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
106368 const char **pzTail /* OUT: End of parsed string */
@@ -105934,11 +106434,11 @@
106434 ** and so if a schema change occurs, SQLITE_SCHEMA is returned by
106435 ** sqlite3_step(). In the new version, the original SQL text is retained
106436 ** and the statement is automatically recompiled if an schema change
106437 ** occurs.
106438 */
106439 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
106440 sqlite3 *db, /* Database handle. */
106441 const void *zSql, /* UTF-16 encoded SQL statement. */
106442 int nBytes, /* Length of zSql in bytes. */
106443 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
106444 const void **pzTail /* OUT: End of parsed string */
@@ -105946,11 +106446,11 @@
106446 int rc;
106447 rc = sqlite3Prepare16(db,zSql,nBytes,0,ppStmt,pzTail);
106448 assert( rc==SQLITE_OK || ppStmt==0 || *ppStmt==0 ); /* VERIFY: F13021 */
106449 return rc;
106450 }
106451 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
106452 sqlite3 *db, /* Database handle. */
106453 const void *zSql, /* UTF-16 encoded SQL statement. */
106454 int nBytes, /* Length of zSql in bytes. */
106455 sqlite3_stmt **ppStmt, /* OUT: A pointer to the prepared statement */
106456 const void **pzTail /* OUT: End of parsed string */
@@ -106075,11 +106575,10 @@
106575 ){
106576 Select *pNew;
106577 Select standin;
106578 sqlite3 *db = pParse->db;
106579 pNew = sqlite3DbMallocZero(db, sizeof(*pNew) );
 
106580 if( pNew==0 ){
106581 assert( db->mallocFailed );
106582 pNew = &standin;
106583 memset(pNew, 0, sizeof(*pNew));
106584 }
@@ -106095,11 +106594,11 @@
106594 pNew->pOrderBy = pOrderBy;
106595 pNew->selFlags = selFlags;
106596 pNew->op = TK_SELECT;
106597 pNew->pLimit = pLimit;
106598 pNew->pOffset = pOffset;
106599 assert( pOffset==0 || pLimit!=0 || pParse->nErr>0 || db->mallocFailed!=0 );
106600 pNew->addrOpenEphm[0] = -1;
106601 pNew->addrOpenEphm[1] = -1;
106602 if( db->mallocFailed ) {
106603 clearSelect(db, pNew, pNew!=&standin);
106604 pNew = 0;
@@ -107345,11 +107844,11 @@
107844 if( pS ){
107845 /* The "table" is actually a sub-select or a view in the FROM clause
107846 ** of the SELECT statement. Return the declaration type and origin
107847 ** data for the result-set column of the sub-select.
107848 */
107849 if( iCol>=0 && iCol<pS->pEList->nExpr ){
107850 /* If iCol is less than zero, then the expression requests the
107851 ** rowid of the sub-select or view. This expression is legal (see
107852 ** test case misc2.2.2) - it always evaluates to NULL.
107853 */
107854 NameContext sNC;
@@ -107665,16 +108164,18 @@
108164 memset(&sNC, 0, sizeof(sNC));
108165 sNC.pSrcList = pSelect->pSrc;
108166 a = pSelect->pEList->a;
108167 for(i=0, pCol=pTab->aCol; i<pTab->nCol; i++, pCol++){
108168 p = a[i].pExpr;
108169 if( pCol->zType==0 ){
108170 pCol->zType = sqlite3DbStrDup(db, columnType(&sNC, p,0,0,0, &pCol->szEst));
108171 }
108172 szAll += pCol->szEst;
108173 pCol->affinity = sqlite3ExprAffinity(p);
108174 if( pCol->affinity==0 ) pCol->affinity = SQLITE_AFF_NONE;
108175 pColl = sqlite3ExprCollSeq(pParse, p);
108176 if( pColl && pCol->zColl==0 ){
108177 pCol->zColl = sqlite3DbStrDup(db, pColl->zName);
108178 }
108179 }
108180 pTab->szTabRow = sqlite3LogEst(szAll*4);
108181 }
@@ -108072,12 +108573,11 @@
108573 ){
108574 Select *pPrior;
108575 int nExpr = p->pEList->nExpr;
108576 int nRow = 1;
108577 int rc = 0;
108578 assert( p->selFlags & SF_MultiValue );
 
108579 do{
108580 assert( p->selFlags & SF_Values );
108581 assert( p->op==TK_ALL || (p->op==TK_SELECT && p->pPrior==0) );
108582 assert( p->pLimit==0 );
108583 assert( p->pOffset==0 );
@@ -108182,11 +108682,11 @@
108682 dest.eDest = SRT_Table;
108683 }
108684
108685 /* Special handling for a compound-select that originates as a VALUES clause.
108686 */
108687 if( p->selFlags & SF_MultiValue ){
108688 rc = multiSelectValues(pParse, p, &dest);
108689 goto multi_select_end;
108690 }
108691
108692 /* Make sure all SELECTs in the statement have the same number of elements
@@ -108567,11 +109067,11 @@
109067 ** then there should be a single item on the stack. Write this
109068 ** item into the set table with bogus data.
109069 */
109070 case SRT_Set: {
109071 int r1;
109072 assert( pIn->nSdst==1 || pParse->nErr>0 );
109073 pDest->affSdst =
109074 sqlite3CompareAffinity(p->pEList->a[0].pExpr, pDest->affSdst);
109075 r1 = sqlite3GetTempReg(pParse);
109076 sqlite3VdbeAddOp4(v, OP_MakeRecord, pIn->iSdst, 1, r1, &pDest->affSdst,1);
109077 sqlite3ExprCacheAffinityChange(pParse, pIn->iSdst, 1);
@@ -108593,11 +109093,11 @@
109093 /* If this is a scalar select that is part of an expression, then
109094 ** store the results in the appropriate memory cell and break out
109095 ** of the scan loop.
109096 */
109097 case SRT_Mem: {
109098 assert( pIn->nSdst==1 || pParse->nErr>0 ); testcase( pIn->nSdst!=1 );
109099 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSDParm, 1);
109100 /* The LIMIT clause will jump out of the loop for us */
109101 break;
109102 }
109103 #endif /* #ifndef SQLITE_OMIT_SUBQUERY */
@@ -108608,11 +109108,11 @@
109108 case SRT_Coroutine: {
109109 if( pDest->iSdst==0 ){
109110 pDest->iSdst = sqlite3GetTempRange(pParse, pIn->nSdst);
109111 pDest->nSdst = pIn->nSdst;
109112 }
109113 sqlite3ExprCodeMove(pParse, pIn->iSdst, pDest->iSdst, pIn->nSdst);
109114 sqlite3VdbeAddOp1(v, OP_Yield, pDest->iSDParm);
109115 break;
109116 }
109117
109118 /* If none of the above, then the result destination must be
@@ -108824,12 +109324,14 @@
109324 */
109325 aPermute = sqlite3DbMallocRaw(db, sizeof(int)*nOrderBy);
109326 if( aPermute ){
109327 struct ExprList_item *pItem;
109328 for(i=0, pItem=pOrderBy->a; i<nOrderBy; i++, pItem++){
109329 assert( pItem->u.x.iOrderByCol>0 );
109330 /* assert( pItem->u.x.iOrderByCol<=p->pEList->nExpr ) is also true
109331 ** but only for well-formed SELECT statements. */
109332 testcase( pItem->u.x.iOrderByCol > p->pEList->nExpr );
109333 aPermute[i] = pItem->u.x.iOrderByCol - 1;
109334 }
109335 pKeyMerge = multiSelectOrderByKeyInfo(pParse, p, 1);
109336 }else{
109337 pKeyMerge = 0;
@@ -109035,11 +109537,11 @@
109537 pPrior->pNext = p;
109538
109539 /*** TBD: Insert subroutine calls to close cursors on incomplete
109540 **** subqueries ****/
109541 explainComposite(pParse, p->op, iSub1, iSub2, 0);
109542 return pParse->nErr!=0;
109543 }
109544 #endif
109545
109546 #if !defined(SQLITE_OMIT_SUBQUERY) || !defined(SQLITE_OMIT_VIEW)
109547 /* Forward Declarations */
@@ -109847,11 +110349,14 @@
110349 pNew->pGroupBy = 0;
110350 pNew->pHaving = 0;
110351 pNew->pOrderBy = 0;
110352 p->pPrior = 0;
110353 p->pNext = 0;
110354 p->pWith = 0;
110355 p->selFlags &= ~SF_Compound;
110356 assert( (p->selFlags & SF_Converted)==0 );
110357 p->selFlags |= SF_Converted;
110358 assert( pNew->pPrior!=0 );
110359 pNew->pPrior->pNext = pNew;
110360 pNew->pLimit = 0;
110361 pNew->pOffset = 0;
110362 return WRC_Continue;
@@ -110383,11 +110888,11 @@
110888 if( pParse->hasCompound ){
110889 w.xSelectCallback = convertCompoundSelectToSubquery;
110890 sqlite3WalkSelect(&w, pSelect);
110891 }
110892 w.xSelectCallback = selectExpander;
110893 if( (pSelect->selFlags & SF_MultiValue)==0 ){
110894 w.xSelectCallback2 = selectPopWith;
110895 }
110896 sqlite3WalkSelect(&w, pSelect);
110897 }
110898
@@ -110569,11 +111074,12 @@
111074 nArg = 0;
111075 regAgg = 0;
111076 }
111077 if( pF->iDistinct>=0 ){
111078 addrNext = sqlite3VdbeMakeLabel(v);
111079 testcase( nArg==0 ); /* Error condition */
111080 testcase( nArg>1 ); /* Also an error */
111081 codeDistinct(pParse, pF->iDistinct, addrNext, 1, regAgg);
111082 }
111083 if( pF->pFunc->funcFlags & SQLITE_FUNC_NEEDCOLL ){
111084 CollSeq *pColl = 0;
111085 struct ExprList_item *pItem;
@@ -111444,14 +111950,13 @@
111950
111951 /* Jump here to skip this query
111952 */
111953 sqlite3VdbeResolveLabel(v, iEnd);
111954
111955 /* The SELECT has been coded. If there is an error in the Parse structure,
111956 ** set the return code to 1. Otherwise 0. */
111957 rc = (pParse->nErr>0);
 
111958
111959 /* Control jumps to here if an error is encountered above, or upon
111960 ** successful coding of the SELECT.
111961 */
111962 select_end:
@@ -111498,11 +112003,11 @@
112003 sqlite3TreeViewLine(pView, "FROM");
112004 for(i=0; i<p->pSrc->nSrc; i++){
112005 struct SrcList_item *pItem = &p->pSrc->a[i];
112006 StrAccum x;
112007 char zLine[100];
112008 sqlite3StrAccumInit(&x, 0, zLine, sizeof(zLine), 0);
112009 sqlite3XPrintf(&x, 0, "{%d,*}", pItem->iCursor);
112010 if( pItem->zDatabase ){
112011 sqlite3XPrintf(&x, 0, " %s.%s", pItem->zDatabase, pItem->zName);
112012 }else if( pItem->zName ){
112013 sqlite3XPrintf(&x, 0, " %s", pItem->zName);
@@ -111657,11 +112162,11 @@
112162 for(i=0; i<nCol; i++){
112163 if( argv[i]==0 ){
112164 z = 0;
112165 }else{
112166 int n = sqlite3Strlen30(argv[i])+1;
112167 z = sqlite3_malloc64( n );
112168 if( z==0 ) goto malloc_failed;
112169 memcpy(z, argv[i], n);
112170 }
112171 p->azResult[p->nData++] = z;
112172 }
@@ -111682,11 +112187,11 @@
112187 ** The result that is written to ***pazResult is held in memory obtained
112188 ** from malloc(). But the caller cannot free this memory directly.
112189 ** Instead, the entire table should be passed to sqlite3_free_table() when
112190 ** the calling procedure is finished using it.
112191 */
112192 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
112193 sqlite3 *db, /* The database on which the SQL executes */
112194 const char *zSql, /* The SQL to be executed */
112195 char ***pazResult, /* Write the result table here */
112196 int *pnRow, /* Write the number of rows in the result here */
112197 int *pnColumn, /* Write the number of columns of result here */
@@ -111706,11 +112211,11 @@
112211 res.nRow = 0;
112212 res.nColumn = 0;
112213 res.nData = 1;
112214 res.nAlloc = 20;
112215 res.rc = SQLITE_OK;
112216 res.azResult = sqlite3_malloc64(sizeof(char*)*res.nAlloc );
112217 if( res.azResult==0 ){
112218 db->errCode = SQLITE_NOMEM;
112219 return SQLITE_NOMEM;
112220 }
112221 res.azResult[0] = 0;
@@ -111734,11 +112239,11 @@
112239 sqlite3_free_table(&res.azResult[1]);
112240 return rc;
112241 }
112242 if( res.nAlloc>res.nData ){
112243 char **azNew;
112244 azNew = sqlite3_realloc64( res.azResult, sizeof(char*)*res.nData );
112245 if( azNew==0 ){
112246 sqlite3_free_table(&res.azResult[1]);
112247 db->errCode = SQLITE_NOMEM;
112248 return SQLITE_NOMEM;
112249 }
@@ -111751,11 +112256,11 @@
112256 }
112257
112258 /*
112259 ** This routine frees the space the sqlite3_get_table() malloced.
112260 */
112261 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(
112262 char **azResult /* Result returned from sqlite3_get_table() */
112263 ){
112264 if( azResult ){
112265 int i, n;
112266 azResult--;
@@ -111962,11 +112467,10 @@
112467 }
112468
112469 /* Do not create a trigger on a system table */
112470 if( sqlite3StrNICmp(pTab->zName, "sqlite_", 7)==0 ){
112471 sqlite3ErrorMsg(pParse, "cannot create trigger on system table");
 
112472 goto trigger_cleanup;
112473 }
112474
112475 /* INSTEAD of triggers are only for views and views only support INSTEAD
112476 ** of triggers.
@@ -112142,16 +112646,16 @@
112646 u8 op, /* Trigger opcode */
112647 Token *pName /* The target name */
112648 ){
112649 TriggerStep *pTriggerStep;
112650
112651 pTriggerStep = sqlite3DbMallocZero(db, sizeof(TriggerStep) + pName->n + 1);
112652 if( pTriggerStep ){
112653 char *z = (char*)&pTriggerStep[1];
112654 memcpy(z, pName->z, pName->n);
112655 sqlite3Dequote(z);
112656 pTriggerStep->zTarget = z;
112657 pTriggerStep->op = op;
112658 }
112659 return pTriggerStep;
112660 }
112661
@@ -112430,11 +112934,11 @@
112934 }
112935 return (mask ? pList : 0);
112936 }
112937
112938 /*
112939 ** Convert the pStep->zTarget string into a SrcList and return a pointer
112940 ** to that SrcList.
112941 **
112942 ** This routine adds a specific database name, if needed, to the target when
112943 ** forming the SrcList. This prevents a trigger in one database from
112944 ** referring to a target in another database. An exception is when the
@@ -112443,21 +112947,21 @@
112947 */
112948 static SrcList *targetSrcList(
112949 Parse *pParse, /* The parsing context */
112950 TriggerStep *pStep /* The trigger containing the target token */
112951 ){
112952 sqlite3 *db = pParse->db;
112953 int iDb; /* Index of the database to use */
112954 SrcList *pSrc; /* SrcList to be returned */
112955
112956 pSrc = sqlite3SrcListAppend(db, 0, 0, 0);
112957 if( pSrc ){
112958 assert( pSrc->nSrc>0 );
112959 pSrc->a[pSrc->nSrc-1].zName = sqlite3DbStrDup(db, pStep->zTarget);
112960 iDb = sqlite3SchemaToIndex(db, pStep->pTrig->pSchema);
112961 if( iDb==0 || iDb>=2 ){
112962 assert( iDb<db->nDb );
 
112963 pSrc->a[pSrc->nSrc-1].zDatabase = sqlite3DbStrDup(db, db->aDb[iDb].zName);
112964 }
112965 }
112966 return pSrc;
112967 }
@@ -112565,10 +113069,11 @@
113069 assert( pFrom->zErrMsg==0 || pFrom->nErr );
113070 assert( pTo->zErrMsg==0 || pTo->nErr );
113071 if( pTo->nErr==0 ){
113072 pTo->zErrMsg = pFrom->zErrMsg;
113073 pTo->nErr = pFrom->nErr;
113074 pTo->rc = pFrom->rc;
113075 }else{
113076 sqlite3DbFree(pFrom->db, pFrom->zErrMsg);
113077 }
113078 }
113079
@@ -113915,17 +114420,21 @@
114420
114421 /* Loop through the tables in the main database. For each, do
114422 ** an "INSERT INTO vacuum_db.xxx SELECT * FROM main.xxx;" to copy
114423 ** the contents to the temporary database.
114424 */
114425 assert( (db->flags & SQLITE_Vacuum)==0 );
114426 db->flags |= SQLITE_Vacuum;
114427 rc = execExecSql(db, pzErrMsg,
114428 "SELECT 'INSERT INTO vacuum_db.' || quote(name) "
114429 "|| ' SELECT * FROM main.' || quote(name) || ';'"
114430 "FROM main.sqlite_master "
114431 "WHERE type = 'table' AND name!='sqlite_sequence' "
114432 " AND coalesce(rootpage,1)>0"
114433 );
114434 assert( (db->flags & SQLITE_Vacuum)!=0 );
114435 db->flags &= ~SQLITE_Vacuum;
114436 if( rc!=SQLITE_OK ) goto end_of_vacuum;
114437
114438 /* Copy over the sequence table
114439 */
114440 rc = execExecSql(db, pzErrMsg,
@@ -114060,10 +114569,12 @@
114569 ** are invoked only from within xCreate and xConnect methods.
114570 */
114571 struct VtabCtx {
114572 VTable *pVTable; /* The virtual table being constructed */
114573 Table *pTab; /* The Table object to which the virtual table belongs */
114574 VtabCtx *pPrior; /* Parent context (if any) */
114575 int bDeclared; /* True after sqlite3_declare_vtab() is called */
114576 };
114577
114578 /*
114579 ** The actual function that does the work of creating a new module.
114580 ** This function implements the sqlite3_create_module() and
@@ -114111,11 +114622,11 @@
114622
114623
114624 /*
114625 ** External API function used to create a new virtual-table module.
114626 */
114627 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
114628 sqlite3 *db, /* Database in which module is registered */
114629 const char *zName, /* Name assigned to this module */
114630 const sqlite3_module *pModule, /* The definition of the module */
114631 void *pAux /* Context pointer for xCreate/xConnect */
114632 ){
@@ -114126,11 +114637,11 @@
114637 }
114638
114639 /*
114640 ** External API function used to create a new virtual-table module.
114641 */
114642 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
114643 sqlite3 *db, /* Database in which module is registered */
114644 const char *zName, /* Name assigned to this module */
114645 const sqlite3_module *pModule, /* The definition of the module */
114646 void *pAux, /* Context pointer for xCreate/xConnect */
114647 void (*xDestroy)(void *) /* Module destructor function */
@@ -114506,11 +115017,11 @@
115017 Token *pArg = &pParse->sArg;
115018 if( pArg->z==0 ){
115019 pArg->z = p->z;
115020 pArg->n = p->n;
115021 }else{
115022 assert(pArg->z <= p->z);
115023 pArg->n = (int)(&p->z[p->n] - pArg->z);
115024 }
115025 }
115026
115027 /*
@@ -114523,19 +115034,31 @@
115034 Table *pTab,
115035 Module *pMod,
115036 int (*xConstruct)(sqlite3*,void*,int,const char*const*,sqlite3_vtab**,char**),
115037 char **pzErr
115038 ){
115039 VtabCtx sCtx;
115040 VTable *pVTable;
115041 int rc;
115042 const char *const*azArg = (const char *const*)pTab->azModuleArg;
115043 int nArg = pTab->nModuleArg;
115044 char *zErr = 0;
115045 char *zModuleName;
115046 int iDb;
115047 VtabCtx *pCtx;
115048
115049 /* Check that the virtual-table is not already being initialized */
115050 for(pCtx=db->pVtabCtx; pCtx; pCtx=pCtx->pPrior){
115051 if( pCtx->pTab==pTab ){
115052 *pzErr = sqlite3MPrintf(db,
115053 "vtable constructor called recursively: %s", pTab->zName
115054 );
115055 return SQLITE_LOCKED;
115056 }
115057 }
115058
115059 zModuleName = sqlite3MPrintf(db, "%s", pTab->zName);
115060 if( !zModuleName ){
115061 return SQLITE_NOMEM;
115062 }
115063
115064 pVTable = sqlite3DbMallocZero(db, sizeof(VTable));
@@ -114552,15 +115075,17 @@
115075 /* Invoke the virtual table constructor */
115076 assert( &db->pVtabCtx );
115077 assert( xConstruct );
115078 sCtx.pTab = pTab;
115079 sCtx.pVTable = pVTable;
115080 sCtx.pPrior = db->pVtabCtx;
115081 sCtx.bDeclared = 0;
115082 db->pVtabCtx = &sCtx;
115083 rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
115084 db->pVtabCtx = sCtx.pPrior;
115085 if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
115086 assert( sCtx.pTab==pTab );
115087
115088 if( SQLITE_OK!=rc ){
115089 if( zErr==0 ){
115090 *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
115091 }else {
@@ -114572,17 +115097,18 @@
115097 /* Justification of ALWAYS(): A correct vtab constructor must allocate
115098 ** the sqlite3_vtab object if successful. */
115099 memset(pVTable->pVtab, 0, sizeof(pVTable->pVtab[0]));
115100 pVTable->pVtab->pModule = pMod->pModule;
115101 pVTable->nRef = 1;
115102 if( sCtx.bDeclared==0 ){
115103 const char *zFormat = "vtable constructor did not declare schema: %s";
115104 *pzErr = sqlite3MPrintf(db, zFormat, pTab->zName);
115105 sqlite3VtabUnlock(pVTable);
115106 rc = SQLITE_ERROR;
115107 }else{
115108 int iCol;
115109 u8 oooHidden = 0;
115110 /* If everything went according to plan, link the new VTable structure
115111 ** into the linked list headed by pTab->pVTable. Then loop through the
115112 ** columns of the table to see if any of them contain the token "hidden".
115113 ** If so, set the Column COLFLAG_HIDDEN flag and remove the token from
115114 ** the type string. */
@@ -114591,11 +115117,14 @@
115117
115118 for(iCol=0; iCol<pTab->nCol; iCol++){
115119 char *zType = pTab->aCol[iCol].zType;
115120 int nType;
115121 int i = 0;
115122 if( !zType ){
115123 pTab->tabFlags |= oooHidden;
115124 continue;
115125 }
115126 nType = sqlite3Strlen30(zType);
115127 if( sqlite3StrNICmp("hidden", zType, 6)||(zType[6] && zType[6]!=' ') ){
115128 for(i=0; i<nType; i++){
115129 if( (0==sqlite3StrNICmp(" hidden", &zType[i], 7))
115130 && (zType[i+7]=='\0' || zType[i+7]==' ')
@@ -114614,10 +115143,13 @@
115143 if( zType[i]=='\0' && i>0 ){
115144 assert(zType[i-1]==' ');
115145 zType[i-1] = '\0';
115146 }
115147 pTab->aCol[iCol].colFlags |= COLFLAG_HIDDEN;
115148 oooHidden = TF_OOOHidden;
115149 }else{
115150 pTab->tabFlags |= oooHidden;
115151 }
115152 }
115153 }
115154 }
115155
@@ -114741,13 +115273,13 @@
115273 /*
115274 ** This function is used to set the schema of a virtual table. It is only
115275 ** valid to call this function from within the xCreate() or xConnect() of a
115276 ** virtual table module.
115277 */
115278 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3 *db, const char *zCreateTable){
115279 VtabCtx *pCtx;
115280 Parse *pParse;
 
115281 int rc = SQLITE_OK;
115282 Table *pTab;
115283 char *zErr = 0;
115284
115285 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -114754,15 +115286,17 @@
115286 if( !sqlite3SafetyCheckOk(db) || zCreateTable==0 ){
115287 return SQLITE_MISUSE_BKPT;
115288 }
115289 #endif
115290 sqlite3_mutex_enter(db->mutex);
115291 pCtx = db->pVtabCtx;
115292 if( !pCtx || pCtx->bDeclared ){
115293 sqlite3Error(db, SQLITE_MISUSE);
115294 sqlite3_mutex_leave(db->mutex);
115295 return SQLITE_MISUSE_BKPT;
115296 }
115297 pTab = pCtx->pTab;
115298 assert( (pTab->tabFlags & TF_Virtual)!=0 );
115299
115300 pParse = sqlite3StackAllocZero(db, sizeof(*pParse));
115301 if( pParse==0 ){
115302 rc = SQLITE_NOMEM;
@@ -114781,11 +115315,11 @@
115315 pTab->aCol = pParse->pNewTable->aCol;
115316 pTab->nCol = pParse->pNewTable->nCol;
115317 pParse->pNewTable->nCol = 0;
115318 pParse->pNewTable->aCol = 0;
115319 }
115320 pCtx->bDeclared = 1;
115321 }else{
115322 sqlite3ErrorWithMsg(db, SQLITE_ERROR, (zErr ? "%s" : 0), zErr);
115323 sqlite3DbFree(db, zErr);
115324 rc = SQLITE_ERROR;
115325 }
@@ -114975,11 +115509,11 @@
115509 */
115510 SQLITE_PRIVATE int sqlite3VtabSavepoint(sqlite3 *db, int op, int iSavepoint){
115511 int rc = SQLITE_OK;
115512
115513 assert( op==SAVEPOINT_RELEASE||op==SAVEPOINT_ROLLBACK||op==SAVEPOINT_BEGIN );
115514 assert( iSavepoint>=-1 );
115515 if( db->aVTrans ){
115516 int i;
115517 for(i=0; rc==SQLITE_OK && i<db->nVTrans; i++){
115518 VTable *pVTab = db->aVTrans[i];
115519 const sqlite3_module *pMod = pVTab->pMod->pModule;
@@ -115093,11 +115627,11 @@
115627 assert( IsVirtual(pTab) );
115628 for(i=0; i<pToplevel->nVtabLock; i++){
115629 if( pTab==pToplevel->apVtabLock[i] ) return;
115630 }
115631 n = (pToplevel->nVtabLock+1)*sizeof(pToplevel->apVtabLock[0]);
115632 apVtabLock = sqlite3_realloc64(pToplevel->apVtabLock, n);
115633 if( apVtabLock ){
115634 pToplevel->apVtabLock = apVtabLock;
115635 pToplevel->apVtabLock[pToplevel->nVtabLock++] = pTab;
115636 }else{
115637 pToplevel->db->mallocFailed = 1;
@@ -115109,11 +115643,11 @@
115643 ** table update operation currently in progress.
115644 **
115645 ** The results of this routine are undefined unless it is called from
115646 ** within an xUpdate method.
115647 */
115648 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *db){
115649 static const unsigned char aMap[] = {
115650 SQLITE_ROLLBACK, SQLITE_ABORT, SQLITE_FAIL, SQLITE_IGNORE, SQLITE_REPLACE
115651 };
115652 #ifdef SQLITE_ENABLE_API_ARMOR
115653 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115127,11 +115661,11 @@
115661 /*
115662 ** Call from within the xCreate() or xConnect() methods to provide
115663 ** the SQLite core with additional information about the behavior
115664 ** of the virtual table being implemented.
115665 */
115666 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3 *db, int op, ...){
115667 va_list ap;
115668 int rc = SQLITE_OK;
115669
115670 #ifdef SQLITE_ENABLE_API_ARMOR
115671 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -115892,17 +116426,18 @@
116426 ** In the previous sentence and in the diagram, "slot[]" refers to
116427 ** the WhereClause.a[] array. The slot[] array grows as needed to contain
116428 ** all terms of the WHERE clause.
116429 */
116430 static void whereSplit(WhereClause *pWC, Expr *pExpr, u8 op){
116431 Expr *pE2 = sqlite3ExprSkipCollate(pExpr);
116432 pWC->op = op;
116433 if( pE2==0 ) return;
116434 if( pE2->op!=op ){
116435 whereClauseInsert(pWC, pExpr, 0);
116436 }else{
116437 whereSplit(pWC, pE2->pLeft, op);
116438 whereSplit(pWC, pE2->pRight, op);
116439 }
116440 }
116441
116442 /*
116443 ** Initialize a WhereMaskSet object
@@ -117169,11 +117704,11 @@
117704 if( p->op==TK_COLUMN
117705 && p->iColumn==pIdx->aiColumn[iCol]
117706 && p->iTable==iBase
117707 ){
117708 CollSeq *pColl = sqlite3ExprCollSeq(pParse, pList->a[i].pExpr);
117709 if( pColl && 0==sqlite3StrICmp(pColl->zName, zColl) ){
117710 return i;
117711 }
117712 }
117713 }
117714
@@ -117443,11 +117978,11 @@
117978 if( (idxCols & cMask)==0 ){
117979 Expr *pX = pTerm->pExpr;
117980 idxCols |= cMask;
117981 pIdx->aiColumn[n] = pTerm->u.leftColumn;
117982 pColl = sqlite3BinaryCompareCollSeq(pParse, pX->pLeft, pX->pRight);
117983 pIdx->azColl[n] = pColl ? pColl->zName : "BINARY";
117984 n++;
117985 }
117986 }
117987 }
117988 assert( (u32)n==pLoop->u.btree.nEq );
@@ -118739,12 +119274,11 @@
119274
119275 isSearch = (flags&(WHERE_BTM_LIMIT|WHERE_TOP_LIMIT))!=0
119276 || ((flags&WHERE_VIRTUALTABLE)==0 && (pLoop->u.btree.nEq>0))
119277 || (wctrlFlags&(WHERE_ORDERBY_MIN|WHERE_ORDERBY_MAX));
119278
119279 sqlite3StrAccumInit(&str, db, zBuf, sizeof(zBuf), SQLITE_MAX_LENGTH);
 
119280 sqlite3StrAccumAppendAll(&str, isSearch ? "SEARCH" : "SCAN");
119281 if( pItem->pSelect ){
119282 sqlite3XPrintf(&str, 0, " SUBQUERY %d", pItem->iSelectId);
119283 }else{
119284 sqlite3XPrintf(&str, 0, " TABLE %s", pItem->zName);
@@ -119939,10 +120473,17 @@
120473 /*
120474 ** Free a WhereInfo structure
120475 */
120476 static void whereInfoFree(sqlite3 *db, WhereInfo *pWInfo){
120477 if( ALWAYS(pWInfo) ){
120478 int i;
120479 for(i=0; i<pWInfo->nLevel; i++){
120480 WhereLevel *pLevel = &pWInfo->a[i];
120481 if( pLevel->pWLoop && (pLevel->pWLoop->wsFlags & WHERE_IN_ABLE) ){
120482 sqlite3DbFree(db, pLevel->u.in.aInLoop);
120483 }
120484 }
120485 whereClauseClear(&pWInfo->sWC);
120486 while( pWInfo->pLoops ){
120487 WhereLoop *p = pWInfo->pLoops;
120488 pWInfo->pLoops = p->pNextLoop;
120489 whereLoopDelete(db, p);
@@ -120418,11 +120959,11 @@
120959 ** changes "x IN (?)" into "x=?". */
120960
120961 }else if( eOp & (WO_EQ) ){
120962 pNew->wsFlags |= WHERE_COLUMN_EQ;
120963 if( iCol<0 || (nInMul==0 && pNew->u.btree.nEq==pProbe->nKeyCol-1) ){
120964 if( iCol>=0 && pProbe->uniqNotNull==0 ){
120965 pNew->wsFlags |= WHERE_UNQ_WANTED;
120966 }else{
120967 pNew->wsFlags |= WHERE_ONEROW;
120968 }
120969 }
@@ -121878,11 +122419,11 @@
122419 pWInfo->nOBSat = pFrom->isOrdered;
122420 if( pWInfo->nOBSat<0 ) pWInfo->nOBSat = 0;
122421 pWInfo->revMask = pFrom->revLoop;
122422 }
122423 if( (pWInfo->wctrlFlags & WHERE_SORTBYGROUP)
122424 && pWInfo->nOBSat==pWInfo->pOrderBy->nExpr && nLoop>0
122425 ){
122426 Bitmask revMask = 0;
122427 int nOrder = wherePathSatisfiesOrderBy(pWInfo, pWInfo->pOrderBy,
122428 pFrom, 0, nLoop-1, pFrom->aLoop[nLoop-1], &revMask
122429 );
@@ -122283,11 +122824,10 @@
122824 if( pParse->nErr || NEVER(db->mallocFailed) ){
122825 goto whereBeginError;
122826 }
122827 #ifdef WHERETRACE_ENABLED /* !=0 */
122828 if( sqlite3WhereTrace ){
 
122829 sqlite3DebugPrintf("---- Solution nRow=%d", pWInfo->nRowOut);
122830 if( pWInfo->nOBSat>0 ){
122831 sqlite3DebugPrintf(" ORDERBY=%d,0x%llx", pWInfo->nOBSat, pWInfo->revMask);
122832 }
122833 switch( pWInfo->eDistinct ){
@@ -122536,11 +123076,10 @@
123076 VdbeCoverage(v);
123077 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_PrevIfOpen);
123078 VdbeCoverageIf(v, pIn->eEndLoopOp==OP_NextIfOpen);
123079 sqlite3VdbeJumpHere(v, pIn->addrInTop-1);
123080 }
 
123081 }
123082 sqlite3VdbeResolveLabel(v, pLevel->addrBrk);
123083 if( pLevel->addrSkip ){
123084 sqlite3VdbeAddOp2(v, OP_Goto, 0, pLevel->addrSkip);
123085 VdbeComment((v, "next skip-scan on %s", pLoop->u.btree.pIndex->zName));
@@ -122747,10 +123286,32 @@
123286 /*
123287 ** An instance of this structure holds the ATTACH key and the key type.
123288 */
123289 struct AttachKey { int type; Token key; };
123290
123291
123292 /*
123293 ** For a compound SELECT statement, make sure p->pPrior->pNext==p for
123294 ** all elements in the list. And make sure list length does not exceed
123295 ** SQLITE_LIMIT_COMPOUND_SELECT.
123296 */
123297 static void parserDoubleLinkSelect(Parse *pParse, Select *p){
123298 if( p->pPrior ){
123299 Select *pNext = 0, *pLoop;
123300 int mxSelect, cnt = 0;
123301 for(pLoop=p; pLoop; pNext=pLoop, pLoop=pLoop->pPrior, cnt++){
123302 pLoop->pNext = pNext;
123303 pLoop->selFlags |= SF_Compound;
123304 }
123305 if( (p->selFlags & SF_MultiValue)==0 &&
123306 (mxSelect = pParse->db->aLimit[SQLITE_LIMIT_COMPOUND_SELECT])>0 &&
123307 cnt>mxSelect
123308 ){
123309 sqlite3ErrorMsg(pParse, "too many terms in compound SELECT");
123310 }
123311 }
123312 }
123313
123314 /* This is a utility routine used to set the ExprSpan.zStart and
123315 ** ExprSpan.zEnd values of pOut so that the span covers the complete
123316 ** range of text beginning with pStart and going to the end of pEnd.
123317 */
@@ -125064,31 +125625,14 @@
125625 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy3);
125626 }
125627 break;
125628 case 112: /* select ::= with selectnowith */
125629 {
125630 Select *p = yymsp[0].minor.yy3;
125631 if( p ){
 
125632 p->pWith = yymsp[-1].minor.yy59;
125633 parserDoubleLinkSelect(pParse, p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125634 }else{
125635 sqlite3WithDelete(pParse->db, yymsp[-1].minor.yy59);
125636 }
125637 yygotominor.yy3 = p;
125638 }
@@ -125102,16 +125646,18 @@
125646 Select *pRhs = yymsp[0].minor.yy3;
125647 if( pRhs && pRhs->pPrior ){
125648 SrcList *pFrom;
125649 Token x;
125650 x.n = 0;
125651 parserDoubleLinkSelect(pParse, pRhs);
125652 pFrom = sqlite3SrcListAppendFromTerm(pParse,0,0,0,&x,pRhs,0,0);
125653 pRhs = sqlite3SelectNew(pParse,0,pFrom,0,0,0,0,0,0,0);
125654 }
125655 if( pRhs ){
125656 pRhs->op = (u8)yymsp[-1].minor.yy328;
125657 pRhs->pPrior = yymsp[-2].minor.yy3;
125658 pRhs->selFlags &= ~SF_MultiValue;
125659 if( yymsp[-1].minor.yy328!=TK_ALL ) pParse->hasCompound = 1;
125660 }else{
125661 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy3);
125662 }
125663 yygotominor.yy3 = pRhs;
@@ -125154,17 +125700,20 @@
125700 yygotominor.yy3 = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values,0,0);
125701 }
125702 break;
125703 case 121: /* values ::= values COMMA LP exprlist RP */
125704 {
125705 Select *pRight, *pLeft = yymsp[-4].minor.yy3;
125706 pRight = sqlite3SelectNew(pParse,yymsp[-1].minor.yy14,0,0,0,0,0,SF_Values|SF_MultiValue,0,0);
125707 if( ALWAYS(pLeft) ) pLeft->selFlags &= ~SF_MultiValue;
125708 if( pRight ){
125709 pRight->op = TK_ALL;
125710 pLeft = yymsp[-4].minor.yy3;
125711 pRight->pPrior = pLeft;
125712 yygotominor.yy3 = pRight;
125713 }else{
125714 yygotominor.yy3 = pLeft;
125715 }
125716 }
125717 break;
125718 case 122: /* distinct ::= DISTINCT */
125719 {yygotominor.yy381 = SF_Distinct;}
@@ -126964,14 +127513,12 @@
127513 goto abort_parse;
127514 }
127515 break;
127516 }
127517 case TK_ILLEGAL: {
127518 sqlite3ErrorMsg(pParse, "unrecognized token: \"%T\"",
 
127519 &pParse->sLastToken);
 
127520 goto abort_parse;
127521 }
127522 case TK_SEMI: {
127523 pParse->zTail = &zSql[i];
127524 /* Fall thru into the default case */
@@ -126985,16 +127532,19 @@
127532 break;
127533 }
127534 }
127535 }
127536 abort_parse:
127537 assert( nErr==0 );
127538 if( zSql[i]==0 && pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
127539 if( lastTokenParsed!=TK_SEMI ){
127540 sqlite3Parser(pEngine, TK_SEMI, pParse->sLastToken, pParse);
127541 pParse->zTail = &zSql[i];
127542 }
127543 if( pParse->rc==SQLITE_OK && db->mallocFailed==0 ){
127544 sqlite3Parser(pEngine, 0, pParse->sLastToken, pParse);
127545 }
127546 }
127547 #ifdef YYTRACKMAXSTACKDEPTH
127548 sqlite3_mutex_enter(sqlite3MallocMutex());
127549 sqlite3StatusSet(SQLITE_STATUS_PARSER_STACK,
127550 sqlite3ParserStackPeak(pEngine)
@@ -127051,13 +127601,11 @@
127601 while( pParse->pZombieTab ){
127602 Table *p = pParse->pZombieTab;
127603 pParse->pZombieTab = p->pNextZombie;
127604 sqlite3DeleteTable(db, p);
127605 }
127606 assert( nErr==0 || pParse->rc!=SQLITE_OK );
 
 
127607 return nErr;
127608 }
127609
127610 /************** End of tokenize.c ********************************************/
127611 /************** Begin file complete.c ****************************************/
@@ -127161,11 +127709,11 @@
127709 **
127710 ** If we compile with SQLITE_OMIT_TRIGGER, all of the computation needed
127711 ** to recognize the end of a trigger can be omitted. All we have to do
127712 ** is look for a semicolon that is not part of an string or comment.
127713 */
127714 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *zSql){
127715 u8 state = 0; /* Current state, using numbers defined in header comment */
127716 u8 token; /* Value of the next token */
127717
127718 #ifndef SQLITE_OMIT_TRIGGER
127719 /* A complex statement machine used to detect the end of a CREATE TRIGGER
@@ -127326,14 +127874,14 @@
127874 /*
127875 ** This routine is the same as the sqlite3_complete() routine described
127876 ** above, except that the parameter is required to be UTF-16 encoded, not
127877 ** UTF-8.
127878 */
127879 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *zSql){
127880 sqlite3_value *pVal;
127881 char const *zSql8;
127882 int rc;
127883
127884 #ifndef SQLITE_OMIT_AUTOINIT
127885 rc = sqlite3_initialize();
127886 if( rc ) return rc;
127887 #endif
@@ -127476,37 +128024,49 @@
128024 #endif
128025
128026 /* IMPLEMENTATION-OF: R-53536-42575 The sqlite3_libversion() function returns
128027 ** a pointer to the to the sqlite3_version[] string constant.
128028 */
128029 SQLITE_API const char *SQLITE_STDCALL sqlite3_libversion(void){ return sqlite3_version; }
128030
128031 /* IMPLEMENTATION-OF: R-63124-39300 The sqlite3_sourceid() function returns a
128032 ** pointer to a string constant whose value is the same as the
128033 ** SQLITE_SOURCE_ID C preprocessor macro.
128034 */
128035 SQLITE_API const char *SQLITE_STDCALL sqlite3_sourceid(void){ return SQLITE_SOURCE_ID; }
128036
128037 /* IMPLEMENTATION-OF: R-35210-63508 The sqlite3_libversion_number() function
128038 ** returns an integer equal to SQLITE_VERSION_NUMBER.
128039 */
128040 SQLITE_API int SQLITE_STDCALL sqlite3_libversion_number(void){ return SQLITE_VERSION_NUMBER; }
128041
128042 /* IMPLEMENTATION-OF: R-20790-14025 The sqlite3_threadsafe() function returns
128043 ** zero if and only if SQLite was compiled with mutexing code omitted due to
128044 ** the SQLITE_THREADSAFE compile-time option being set to 0.
128045 */
128046 SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void){ return SQLITE_THREADSAFE; }
128047
128048 /*
128049 ** When compiling the test fixture or with debugging enabled (on Win32),
128050 ** this variable being set to non-zero will cause OSTRACE macros to emit
128051 ** extra diagnostic information.
128052 */
128053 #ifdef SQLITE_HAVE_OS_TRACE
128054 # ifndef SQLITE_DEBUG_OS_TRACE
128055 # define SQLITE_DEBUG_OS_TRACE 0
128056 # endif
128057 int sqlite3OSTrace = SQLITE_DEBUG_OS_TRACE;
128058 #endif
128059
128060 #if !defined(SQLITE_OMIT_TRACE) && defined(SQLITE_ENABLE_IOTRACE)
128061 /*
128062 ** If the following function pointer is not NULL and if
128063 ** SQLITE_ENABLE_IOTRACE is enabled, then messages describing
128064 ** I/O active are written using this function. These messages
128065 ** are intended for debugging activity only.
128066 */
128067 SQLITE_API void (SQLITE_CDECL *sqlite3IoTrace)(const char*, ...) = 0;
128068 #endif
128069
128070 /*
128071 ** If the following global variable points to a string which is the
128072 ** name of a directory, then that directory will be used to store
@@ -127554,11 +128114,11 @@
128114 ** call by X completes.
128115 **
128116 ** * Recursive calls to this routine from thread X return immediately
128117 ** without blocking.
128118 */
128119 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void){
128120 MUTEX_LOGIC( sqlite3_mutex *pMaster; ) /* The main static mutex */
128121 int rc; /* Result code */
128122 #ifdef SQLITE_EXTRA_INIT
128123 int bRunExtraInit = 0; /* Extra initialization needed */
128124 #endif
@@ -127715,11 +128275,11 @@
128275 ** while any part of SQLite is otherwise in use in any thread. This
128276 ** routine is not threadsafe. But it is safe to invoke this routine
128277 ** on when SQLite is already shut down. If SQLite is already shut down
128278 ** when this routine is invoked, then this routine is a harmless no-op.
128279 */
128280 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void){
128281 #ifdef SQLITE_OMIT_WSD
128282 int rc = sqlite3_wsd_init(4096, 24);
128283 if( rc!=SQLITE_OK ){
128284 return rc;
128285 }
@@ -127769,11 +128329,11 @@
128329 ** This routine should only be called when there are no outstanding
128330 ** database connections or memory allocations. This routine is not
128331 ** threadsafe. Failure to heed these warnings can lead to unpredictable
128332 ** behavior.
128333 */
128334 SQLITE_API int SQLITE_CDECL sqlite3_config(int op, ...){
128335 va_list ap;
128336 int rc = SQLITE_OK;
128337
128338 /* sqlite3_config() shall return SQLITE_MISUSE if it is invoked while
128339 ** the SQLite library is in use. */
@@ -128126,11 +128686,11 @@
128686 }
128687
128688 /*
128689 ** Return the mutex associated with a database connection.
128690 */
128691 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3 *db){
128692 #ifdef SQLITE_ENABLE_API_ARMOR
128693 if( !sqlite3SafetyCheckOk(db) ){
128694 (void)SQLITE_MISUSE_BKPT;
128695 return 0;
128696 }
@@ -128140,11 +128700,11 @@
128700
128701 /*
128702 ** Free up as much memory as we can from the given database
128703 ** connection.
128704 */
128705 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3 *db){
128706 int i;
128707
128708 #ifdef SQLITE_ENABLE_API_ARMOR
128709 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
128710 #endif
@@ -128163,11 +128723,11 @@
128723 }
128724
128725 /*
128726 ** Configuration settings for an individual database connection
128727 */
128728 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3 *db, int op, ...){
128729 va_list ap;
128730 int rc;
128731 va_start(ap, op);
128732 switch( op ){
128733 case SQLITE_DBCONFIG_LOOKASIDE: {
@@ -128282,11 +128842,11 @@
128842 }
128843
128844 /*
128845 ** Return the ROWID of the most recent insert
128846 */
128847 SQLITE_API sqlite_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3 *db){
128848 #ifdef SQLITE_ENABLE_API_ARMOR
128849 if( !sqlite3SafetyCheckOk(db) ){
128850 (void)SQLITE_MISUSE_BKPT;
128851 return 0;
128852 }
@@ -128295,11 +128855,11 @@
128855 }
128856
128857 /*
128858 ** Return the number of changes in the most recent call to sqlite3_exec().
128859 */
128860 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3 *db){
128861 #ifdef SQLITE_ENABLE_API_ARMOR
128862 if( !sqlite3SafetyCheckOk(db) ){
128863 (void)SQLITE_MISUSE_BKPT;
128864 return 0;
128865 }
@@ -128308,11 +128868,11 @@
128868 }
128869
128870 /*
128871 ** Return the number of changes since the database handle was opened.
128872 */
128873 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3 *db){
128874 #ifdef SQLITE_ENABLE_API_ARMOR
128875 if( !sqlite3SafetyCheckOk(db) ){
128876 (void)SQLITE_MISUSE_BKPT;
128877 return 0;
128878 }
@@ -128450,12 +129010,12 @@
129010 ** statements or unfinished sqlite3_backups. The sqlite3_close_v2()
129011 ** version forces the connection to become a zombie if there are
129012 ** unclosed resources, and arranges for deallocation when the last
129013 ** prepare statement or sqlite3_backup closes.
129014 */
129015 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3 *db){ return sqlite3Close(db,0); }
129016 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3 *db){ return sqlite3Close(db,1); }
129017
129018
129019 /*
129020 ** Close the mutex on database connection db.
129021 **
@@ -128634,11 +129194,11 @@
129194
129195 /*
129196 ** Return a static string containing the name corresponding to the error code
129197 ** specified in the argument.
129198 */
129199 #if defined(SQLITE_NEED_ERR_NAME)
129200 SQLITE_PRIVATE const char *sqlite3ErrName(int rc){
129201 const char *zName = 0;
129202 int i, origRc = rc;
129203 for(i=0; i<2 && zName==0; i++, rc &= 0xff){
129204 switch( rc ){
@@ -128858,11 +129418,11 @@
129418
129419 /*
129420 ** This routine sets the busy callback for an Sqlite database to the
129421 ** given callback function with the given argument.
129422 */
129423 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(
129424 sqlite3 *db,
129425 int (*xBusy)(void*,int),
129426 void *pArg
129427 ){
129428 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -128881,11 +129441,11 @@
129441 /*
129442 ** This routine sets the progress callback for an Sqlite database to the
129443 ** given callback function with the given argument. The progress callback will
129444 ** be invoked every nOps opcodes.
129445 */
129446 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(
129447 sqlite3 *db,
129448 int nOps,
129449 int (*xProgress)(void*),
129450 void *pArg
129451 ){
@@ -128912,11 +129472,11 @@
129472
129473 /*
129474 ** This routine installs a default busy handler that waits for the
129475 ** specified number of milliseconds before returning 0.
129476 */
129477 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3 *db, int ms){
129478 #ifdef SQLITE_ENABLE_API_ARMOR
129479 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
129480 #endif
129481 if( ms>0 ){
129482 sqlite3_busy_handler(db, sqliteDefaultBusyCallback, (void*)db);
@@ -128928,11 +129488,11 @@
129488 }
129489
129490 /*
129491 ** Cause any pending operation to stop at its earliest opportunity.
129492 */
129493 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3 *db){
129494 #ifdef SQLITE_ENABLE_API_ARMOR
129495 if( !sqlite3SafetyCheckOk(db) ){
129496 (void)SQLITE_MISUSE_BKPT;
129497 return;
129498 }
@@ -129045,11 +129605,11 @@
129605 }
129606
129607 /*
129608 ** Create new user functions.
129609 */
129610 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
129611 sqlite3 *db,
129612 const char *zFunc,
129613 int nArg,
129614 int enc,
129615 void *p,
@@ -129059,11 +129619,11 @@
129619 ){
129620 return sqlite3_create_function_v2(db, zFunc, nArg, enc, p, xFunc, xStep,
129621 xFinal, 0);
129622 }
129623
129624 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
129625 sqlite3 *db,
129626 const char *zFunc,
129627 int nArg,
129628 int enc,
129629 void *p,
@@ -129102,11 +129662,11 @@
129662 sqlite3_mutex_leave(db->mutex);
129663 return rc;
129664 }
129665
129666 #ifndef SQLITE_OMIT_UTF16
129667 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
129668 sqlite3 *db,
129669 const void *zFunctionName,
129670 int nArg,
129671 int eTextRep,
129672 void *p,
@@ -129142,11 +129702,11 @@
129702 ** When virtual tables intend to provide an overloaded function, they
129703 ** should call this routine to make sure the global function exists.
129704 ** A global function must exist in order for name resolution to work
129705 ** properly.
129706 */
129707 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(
129708 sqlite3 *db,
129709 const char *zName,
129710 int nArg
129711 ){
129712 int nName = sqlite3Strlen30(zName);
@@ -129174,11 +129734,11 @@
129734 **
129735 ** A NULL trace function means that no tracing is executes. A non-NULL
129736 ** trace is a pointer to a function that is invoked at the start of each
129737 ** SQL statement.
129738 */
129739 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3 *db, void (*xTrace)(void*,const char*), void *pArg){
129740 void *pOld;
129741
129742 #ifdef SQLITE_ENABLE_API_ARMOR
129743 if( !sqlite3SafetyCheckOk(db) ){
129744 (void)SQLITE_MISUSE_BKPT;
@@ -129198,11 +129758,11 @@
129758 **
129759 ** A NULL profile function means that no profiling is executes. A non-NULL
129760 ** profile is a pointer to a function that is invoked at the conclusion of
129761 ** each SQL statement that is run.
129762 */
129763 SQLITE_API void *SQLITE_STDCALL sqlite3_profile(
129764 sqlite3 *db,
129765 void (*xProfile)(void*,const char*,sqlite_uint64),
129766 void *pArg
129767 ){
129768 void *pOld;
@@ -129225,11 +129785,11 @@
129785 /*
129786 ** Register a function to be invoked when a transaction commits.
129787 ** If the invoked function returns non-zero, then the commit becomes a
129788 ** rollback.
129789 */
129790 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(
129791 sqlite3 *db, /* Attach the hook to this database */
129792 int (*xCallback)(void*), /* Function to invoke on each commit */
129793 void *pArg /* Argument to the function */
129794 ){
129795 void *pOld;
@@ -129250,11 +129810,11 @@
129810
129811 /*
129812 ** Register a callback to be invoked each time a row is updated,
129813 ** inserted or deleted using this database connection.
129814 */
129815 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
129816 sqlite3 *db, /* Attach the hook to this database */
129817 void (*xCallback)(void*,int,char const *,char const *,sqlite_int64),
129818 void *pArg /* Argument to the function */
129819 ){
129820 void *pRet;
@@ -129275,11 +129835,11 @@
129835
129836 /*
129837 ** Register a callback to be invoked each time a transaction is rolled
129838 ** back by this database connection.
129839 */
129840 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(
129841 sqlite3 *db, /* Attach the hook to this database */
129842 void (*xCallback)(void*), /* Callback function */
129843 void *pArg /* Argument to the function */
129844 ){
129845 void *pRet;
@@ -129329,11 +129889,11 @@
129889 ** The callback registered by this function replaces any existing callback
129890 ** registered using sqlite3_wal_hook(). Likewise, registering a callback
129891 ** using sqlite3_wal_hook() disables the automatic checkpoint mechanism
129892 ** configured by this function.
129893 */
129894 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int nFrame){
129895 #ifdef SQLITE_OMIT_WAL
129896 UNUSED_PARAMETER(db);
129897 UNUSED_PARAMETER(nFrame);
129898 #else
129899 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -129350,11 +129910,11 @@
129910
129911 /*
129912 ** Register a callback to be invoked each time a transaction is written
129913 ** into the write-ahead-log by this database connection.
129914 */
129915 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
129916 sqlite3 *db, /* Attach the hook to this db handle */
129917 int(*xCallback)(void *, sqlite3*, const char*, int),
129918 void *pArg /* First argument passed to xCallback() */
129919 ){
129920 #ifndef SQLITE_OMIT_WAL
@@ -129377,11 +129937,11 @@
129937 }
129938
129939 /*
129940 ** Checkpoint database zDb.
129941 */
129942 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
129943 sqlite3 *db, /* Database handle */
129944 const char *zDb, /* Name of attached database (or NULL) */
129945 int eMode, /* SQLITE_CHECKPOINT_* value */
129946 int *pnLog, /* OUT: Size of WAL log in frames */
129947 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -129432,11 +129992,11 @@
129992 /*
129993 ** Checkpoint database zDb. If zDb is NULL, or if the buffer zDb points
129994 ** to contains a zero-length string, all attached databases are
129995 ** checkpointed.
129996 */
129997 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb){
129998 /* EVIDENCE-OF: R-41613-20553 The sqlite3_wal_checkpoint(D,X) is equivalent to
129999 ** sqlite3_wal_checkpoint_v2(D,X,SQLITE_CHECKPOINT_PASSIVE,0,0). */
130000 return sqlite3_wal_checkpoint_v2(db,zDb,SQLITE_CHECKPOINT_PASSIVE,0,0);
130001 }
130002
@@ -129521,11 +130081,11 @@
130081
130082 /*
130083 ** Return UTF-8 encoded English language explanation of the most recent
130084 ** error.
130085 */
130086 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3 *db){
130087 const char *z;
130088 if( !db ){
130089 return sqlite3ErrStr(SQLITE_NOMEM);
130090 }
130091 if( !sqlite3SafetyCheckSickOrOk(db) ){
@@ -129549,11 +130109,11 @@
130109 #ifndef SQLITE_OMIT_UTF16
130110 /*
130111 ** Return UTF-16 encoded English language explanation of the most recent
130112 ** error.
130113 */
130114 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3 *db){
130115 static const u16 outOfMem[] = {
130116 'o', 'u', 't', ' ', 'o', 'f', ' ', 'm', 'e', 'm', 'o', 'r', 'y', 0
130117 };
130118 static const u16 misuse[] = {
130119 'l', 'i', 'b', 'r', 'a', 'r', 'y', ' ',
@@ -129594,20 +130154,20 @@
130154
130155 /*
130156 ** Return the most recent error code generated by an SQLite routine. If NULL is
130157 ** passed to this function, we assume a malloc() failed during sqlite3_open().
130158 */
130159 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db){
130160 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
130161 return SQLITE_MISUSE_BKPT;
130162 }
130163 if( !db || db->mallocFailed ){
130164 return SQLITE_NOMEM;
130165 }
130166 return db->errCode & db->errMask;
130167 }
130168 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db){
130169 if( db && !sqlite3SafetyCheckSickOrOk(db) ){
130170 return SQLITE_MISUSE_BKPT;
130171 }
130172 if( !db || db->mallocFailed ){
130173 return SQLITE_NOMEM;
@@ -129618,11 +130178,11 @@
130178 /*
130179 ** Return a string that describes the kind of error specified in the
130180 ** argument. For now, this simply calls the internal sqlite3ErrStr()
130181 ** function.
130182 */
130183 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int rc){
130184 return sqlite3ErrStr(rc);
130185 }
130186
130187 /*
130188 ** Create a new collating function for database "db". The name is zName
@@ -129766,11 +130326,11 @@
130326 **
130327 ** A new lower limit does not shrink existing constructs.
130328 ** It merely prevents new constructs that exceed the limit
130329 ** from forming.
130330 */
130331 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3 *db, int limitId, int newLimit){
130332 int oldLimit;
130333
130334 #ifdef SQLITE_ENABLE_API_ARMOR
130335 if( !sqlite3SafetyCheckOk(db) ){
130336 (void)SQLITE_MISUSE_BKPT;
@@ -129859,18 +130419,18 @@
130419 ){
130420 char *zOpt;
130421 int eState; /* Parser state when parsing URI */
130422 int iIn; /* Input character index */
130423 int iOut = 0; /* Output character index */
130424 u64 nByte = nUri+2; /* Bytes of space to allocate */
130425
130426 /* Make sure the SQLITE_OPEN_URI flag is set to indicate to the VFS xOpen
130427 ** method that there may be extra parameters following the file-name. */
130428 flags |= SQLITE_OPEN_URI;
130429
130430 for(iIn=0; iIn<nUri; iIn++) nByte += (zUri[iIn]=='&');
130431 zFile = sqlite3_malloc64(nByte);
130432 if( !zFile ) return SQLITE_NOMEM;
130433
130434 iIn = 5;
130435 #ifdef SQLITE_ALLOW_URI_AUTHORITY
130436 if( strncmp(zUri+5, "///", 3)==0 ){
@@ -130032,11 +130592,11 @@
130592
130593 zOpt = &zVal[nVal+1];
130594 }
130595
130596 }else{
130597 zFile = sqlite3_malloc64(nUri+2);
130598 if( !zFile ) return SQLITE_NOMEM;
130599 memcpy(zFile, zUri, nUri);
130600 zFile[nUri] = '\0';
130601 zFile[nUri+1] = '\0';
130602 flags &= ~SQLITE_OPEN_URI;
@@ -130303,10 +130863,17 @@
130863 #ifdef SQLITE_ENABLE_RTREE
130864 if( !db->mallocFailed && rc==SQLITE_OK){
130865 rc = sqlite3RtreeInit(db);
130866 }
130867 #endif
130868
130869 #ifdef SQLITE_ENABLE_DBSTAT_VTAB
130870 if( !db->mallocFailed && rc==SQLITE_OK){
130871 int sqlite3_dbstat_register(sqlite3*);
130872 rc = sqlite3_dbstat_register(db);
130873 }
130874 #endif
130875
130876 /* -DSQLITE_DEFAULT_LOCKING_MODE=1 makes EXCLUSIVE the default locking
130877 ** mode. -DSQLITE_DEFAULT_LOCKING_MODE=0 make NORMAL the default locking
130878 ** mode. Doing nothing at all also makes NORMAL the default.
130879 */
@@ -130351,18 +130918,18 @@
130918 }
130919
130920 /*
130921 ** Open a new database handle.
130922 */
130923 SQLITE_API int SQLITE_STDCALL sqlite3_open(
130924 const char *zFilename,
130925 sqlite3 **ppDb
130926 ){
130927 return openDatabase(zFilename, ppDb,
130928 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, 0);
130929 }
130930 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
130931 const char *filename, /* Database filename (UTF-8) */
130932 sqlite3 **ppDb, /* OUT: SQLite db handle */
130933 int flags, /* Flags */
130934 const char *zVfs /* Name of VFS module to use */
130935 ){
@@ -130371,11 +130938,11 @@
130938
130939 #ifndef SQLITE_OMIT_UTF16
130940 /*
130941 ** Open a new database handle.
130942 */
130943 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
130944 const void *zFilename,
130945 sqlite3 **ppDb
130946 ){
130947 char const *zFilename8; /* zFilename encoded in UTF-8 instead of UTF-16 */
130948 sqlite3_value *pVal;
@@ -130410,11 +130977,11 @@
130977 #endif /* SQLITE_OMIT_UTF16 */
130978
130979 /*
130980 ** Register a new collation sequence with the database handle db.
130981 */
130982 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
130983 sqlite3* db,
130984 const char *zName,
130985 int enc,
130986 void* pCtx,
130987 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130423,11 +130990,11 @@
130990 }
130991
130992 /*
130993 ** Register a new collation sequence with the database handle db.
130994 */
130995 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
130996 sqlite3* db,
130997 const char *zName,
130998 int enc,
130999 void* pCtx,
131000 int(*xCompare)(void*,int,const void*,int,const void*),
@@ -130448,11 +131015,11 @@
131015
131016 #ifndef SQLITE_OMIT_UTF16
131017 /*
131018 ** Register a new collation sequence with the database handle db.
131019 */
131020 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
131021 sqlite3* db,
131022 const void *zName,
131023 int enc,
131024 void* pCtx,
131025 int(*xCompare)(void*,int,const void*,int,const void*)
@@ -130478,11 +131045,11 @@
131045
131046 /*
131047 ** Register a collation sequence factory callback with the database handle
131048 ** db. Replace any previously installed collation sequence factory.
131049 */
131050 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
131051 sqlite3 *db,
131052 void *pCollNeededArg,
131053 void(*xCollNeeded)(void*,sqlite3*,int eTextRep,const char*)
131054 ){
131055 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -130499,11 +131066,11 @@
131066 #ifndef SQLITE_OMIT_UTF16
131067 /*
131068 ** Register a collation sequence factory callback with the database handle
131069 ** db. Replace any previously installed collation sequence factory.
131070 */
131071 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
131072 sqlite3 *db,
131073 void *pCollNeededArg,
131074 void(*xCollNeeded16)(void*,sqlite3*,int eTextRep,const void*)
131075 ){
131076 #ifdef SQLITE_ENABLE_API_ARMOR
@@ -130521,11 +131088,11 @@
131088 #ifndef SQLITE_OMIT_DEPRECATED
131089 /*
131090 ** This function is now an anachronism. It used to be used to recover from a
131091 ** malloc() failure, but SQLite now does this automatically.
131092 */
131093 SQLITE_API int SQLITE_STDCALL sqlite3_global_recover(void){
131094 return SQLITE_OK;
131095 }
131096 #endif
131097
131098 /*
@@ -130532,11 +131099,11 @@
131099 ** Test to see whether or not the database connection is in autocommit
131100 ** mode. Return TRUE if it is and FALSE if not. Autocommit mode is on
131101 ** by default. Autocommit is disabled by a BEGIN statement and reenabled
131102 ** by the next COMMIT or ROLLBACK.
131103 */
131104 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3 *db){
131105 #ifdef SQLITE_ENABLE_API_ARMOR
131106 if( !sqlite3SafetyCheckOk(db) ){
131107 (void)SQLITE_MISUSE_BKPT;
131108 return 0;
131109 }
@@ -130584,19 +131151,19 @@
131151 ** data for this thread has been deallocated.
131152 **
131153 ** SQLite no longer uses thread-specific data so this routine is now a
131154 ** no-op. It is retained for historical compatibility.
131155 */
131156 SQLITE_API void SQLITE_STDCALL sqlite3_thread_cleanup(void){
131157 }
131158 #endif
131159
131160 /*
131161 ** Return meta information about a specific column of a database table.
131162 ** See comment in sqlite3.h (sqlite.h.in) for details.
131163 */
131164 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
131165 sqlite3 *db, /* Connection handle */
131166 const char *zDbName, /* Database name or NULL */
131167 const char *zTableName, /* Table name */
131168 const char *zColumnName, /* Column name */
131169 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -130710,11 +131277,11 @@
131277 }
131278
131279 /*
131280 ** Sleep for a little while. Return the amount of time slept.
131281 */
131282 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int ms){
131283 sqlite3_vfs *pVfs;
131284 int rc;
131285 pVfs = sqlite3_vfs_find(0);
131286 if( pVfs==0 ) return 0;
131287
@@ -130726,11 +131293,11 @@
131293 }
131294
131295 /*
131296 ** Enable or disable the extended result codes.
131297 */
131298 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3 *db, int onoff){
131299 #ifdef SQLITE_ENABLE_API_ARMOR
131300 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
131301 #endif
131302 sqlite3_mutex_enter(db->mutex);
131303 db->errMask = onoff ? 0xffffffff : 0xff;
@@ -130739,11 +131306,11 @@
131306 }
131307
131308 /*
131309 ** Invoke the xFileControl method on a particular database.
131310 */
131311 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *pArg){
131312 int rc = SQLITE_ERROR;
131313 Btree *pBtree;
131314
131315 #ifdef SQLITE_ENABLE_API_ARMOR
131316 if( !sqlite3SafetyCheckOk(db) ) return SQLITE_MISUSE_BKPT;
@@ -130773,11 +131340,11 @@
131340 }
131341
131342 /*
131343 ** Interface to the testing logic.
131344 */
131345 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...){
131346 int rc = 0;
131347 #ifndef SQLITE_OMIT_BUILTIN_TEST
131348 va_list ap;
131349 va_start(ap, op);
131350 switch( op ){
@@ -131116,11 +131683,11 @@
131683 ** method of a VFS implementation. The zParam argument is the name of the
131684 ** query parameter we seek. This routine returns the value of the zParam
131685 ** parameter if it exists. If the parameter does not exist, this routine
131686 ** returns a NULL pointer.
131687 */
131688 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam){
131689 if( zFilename==0 || zParam==0 ) return 0;
131690 zFilename += sqlite3Strlen30(zFilename) + 1;
131691 while( zFilename[0] ){
131692 int x = strcmp(zFilename, zParam);
131693 zFilename += sqlite3Strlen30(zFilename) + 1;
@@ -131131,20 +131698,20 @@
131698 }
131699
131700 /*
131701 ** Return a boolean value for a query parameter.
131702 */
131703 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFilename, const char *zParam, int bDflt){
131704 const char *z = sqlite3_uri_parameter(zFilename, zParam);
131705 bDflt = bDflt!=0;
131706 return z ? sqlite3GetBoolean(z, bDflt) : bDflt;
131707 }
131708
131709 /*
131710 ** Return a 64-bit integer value for a query parameter.
131711 */
131712 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(
131713 const char *zFilename, /* Filename as passed to xOpen */
131714 const char *zParam, /* URI parameter sought */
131715 sqlite3_int64 bDflt /* return if parameter is missing */
131716 ){
131717 const char *z = sqlite3_uri_parameter(zFilename, zParam);
@@ -131172,11 +131739,11 @@
131739
131740 /*
131741 ** Return the filename of the database associated with a database
131742 ** connection.
131743 */
131744 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName){
131745 Btree *pBt;
131746 #ifdef SQLITE_ENABLE_API_ARMOR
131747 if( !sqlite3SafetyCheckOk(db) ){
131748 (void)SQLITE_MISUSE_BKPT;
131749 return 0;
@@ -131188,11 +131755,11 @@
131755
131756 /*
131757 ** Return 1 if database is read-only or 0 if read/write. Return -1 if
131758 ** no such database exists.
131759 */
131760 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName){
131761 Btree *pBt;
131762 #ifdef SQLITE_ENABLE_API_ARMOR
131763 if( !sqlite3SafetyCheckOk(db) ){
131764 (void)SQLITE_MISUSE_BKPT;
131765 return -1;
@@ -131347,11 +131914,11 @@
131914 **
131915 ** Each call to this routine overrides any prior callbacks registered
131916 ** on the same "db". If xNotify==0 then any prior callbacks are immediately
131917 ** cancelled.
131918 */
131919 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
131920 sqlite3 *db,
131921 void (*xNotify)(void **, int),
131922 void *pArg
131923 ){
131924 int rc = SQLITE_OK;
@@ -132241,10 +132808,15 @@
132808 ** false.
132809 */
132810 #ifdef SQLITE_COVERAGE_TEST
132811 # define ALWAYS(x) (1)
132812 # define NEVER(X) (0)
132813 #elif defined(SQLITE_DEBUG)
132814 # define ALWAYS(x) sqlite3Fts3Always((x)!=0)
132815 # define NEVER(x) sqlite3Fts3Never((x)!=0)
132816 SQLITE_PRIVATE int sqlite3Fts3Always(int b);
132817 SQLITE_PRIVATE int sqlite3Fts3Never(int b);
132818 #else
132819 # define ALWAYS(x) (x)
132820 # define NEVER(x) (x)
132821 #endif
132822
@@ -132641,10 +133213,11 @@
133213 #define fts3GetVarint32(p, piVal) ( \
133214 (*(u8*)(p)&0x80) ? sqlite3Fts3GetVarint32(p, piVal) : (*piVal=*(u8*)(p), 1) \
133215 )
133216
133217 /* fts3.c */
133218 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char**,const char*,...);
133219 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
133220 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
133221 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
133222 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
133223 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
@@ -132729,10 +133302,17 @@
133302
133303 static int fts3EvalNext(Fts3Cursor *pCsr);
133304 static int fts3EvalStart(Fts3Cursor *pCsr);
133305 static int fts3TermSegReaderCursor(
133306 Fts3Cursor *, const char *, int, int, Fts3MultiSegReader **);
133307
133308 #ifndef SQLITE_AMALGAMATION
133309 # if defined(SQLITE_DEBUG)
133310 SQLITE_PRIVATE int sqlite3Fts3Always(int b) { assert( b ); return b; }
133311 SQLITE_PRIVATE int sqlite3Fts3Never(int b) { assert( !b ); return b; }
133312 # endif
133313 #endif
133314
133315 /*
133316 ** Write a 64-bit variable-length integer to memory starting at p[0].
133317 ** The length of data written will be between 1 and FTS3_VARINT_MAX bytes.
133318 ** The number of bytes written is returned.
@@ -132839,11 +133419,11 @@
133419 int iOut = 0; /* Index of next byte to write to output */
133420
133421 /* If the first byte was a '[', then the close-quote character is a ']' */
133422 if( quote=='[' ) quote = ']';
133423
133424 while( z[iIn] ){
133425 if( z[iIn]==quote ){
133426 if( z[iIn+1]!=quote ) break;
133427 z[iOut++] = quote;
133428 iIn += 2;
133429 }else{
@@ -132917,10 +133497,21 @@
133497 p->pTokenizer->pModule->xDestroy(p->pTokenizer);
133498
133499 sqlite3_free(p);
133500 return SQLITE_OK;
133501 }
133502
133503 /*
133504 ** Write an error message into *pzErr
133505 */
133506 SQLITE_PRIVATE void sqlite3Fts3ErrMsg(char **pzErr, const char *zFormat, ...){
133507 va_list ap;
133508 sqlite3_free(*pzErr);
133509 va_start(ap, zFormat);
133510 *pzErr = sqlite3_vmprintf(zFormat, ap);
133511 va_end(ap);
133512 }
133513
133514 /*
133515 ** Construct one or more SQL statements from the format string given
133516 ** and then evaluate those statements. The success code is written
133517 ** into *pRc.
@@ -133436,11 +134027,12 @@
134027 sqlite3 *db, /* Database handle */
134028 const char *zDb, /* Name of db (i.e. "main", "temp" etc.) */
134029 const char *zTbl, /* Name of content table */
134030 const char ***pazCol, /* OUT: Malloc'd array of column names */
134031 int *pnCol, /* OUT: Size of array *pazCol */
134032 int *pnStr, /* OUT: Bytes of string content */
134033 char **pzErr /* OUT: error message */
134034 ){
134035 int rc = SQLITE_OK; /* Return code */
134036 char *zSql; /* "SELECT *" statement on zTbl */
134037 sqlite3_stmt *pStmt = 0; /* Compiled version of zSql */
134038
@@ -133447,10 +134039,13 @@
134039 zSql = sqlite3_mprintf("SELECT * FROM %Q.%Q", zDb, zTbl);
134040 if( !zSql ){
134041 rc = SQLITE_NOMEM;
134042 }else{
134043 rc = sqlite3_prepare(db, zSql, -1, &pStmt, 0);
134044 if( rc!=SQLITE_OK ){
134045 sqlite3Fts3ErrMsg(pzErr, "%s", sqlite3_errmsg(db));
134046 }
134047 }
134048 sqlite3_free(zSql);
134049
134050 if( rc==SQLITE_OK ){
134051 const char **azCol; /* Output array */
@@ -133525,11 +134120,11 @@
134120 int nName; /* Bytes required to hold table name */
134121 int isFts4 = (argv[0][3]=='4'); /* True for FTS4, false for FTS3 */
134122 const char **aCol; /* Array of column names */
134123 sqlite3_tokenizer *pTokenizer = 0; /* Tokenizer for this table */
134124
134125 int nIndex = 0; /* Size of aIndex[] array */
134126 struct Fts3Index *aIndex = 0; /* Array of indexes for this table */
134127
134128 /* The results of parsing supported FTS4 key=value options: */
134129 int bNoDocsize = 0; /* True to omit %_docsize table */
134130 int bDescIdx = 0; /* True to store descending indexes */
@@ -133613,17 +134208,17 @@
134208 if( nKey==pOp->nOpt && !sqlite3_strnicmp(z, pOp->zOpt, pOp->nOpt) ){
134209 break;
134210 }
134211 }
134212 if( iOpt==SizeofArray(aFts4Opt) ){
134213 sqlite3Fts3ErrMsg(pzErr, "unrecognized parameter: %s", z);
134214 rc = SQLITE_ERROR;
134215 }else{
134216 switch( iOpt ){
134217 case 0: /* MATCHINFO */
134218 if( strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "fts3", 4) ){
134219 sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo: %s", zVal);
134220 rc = SQLITE_ERROR;
134221 }
134222 bNoDocsize = 1;
134223 break;
134224
@@ -133647,11 +134242,11 @@
134242
134243 case 4: /* ORDER */
134244 if( (strlen(zVal)!=3 || sqlite3_strnicmp(zVal, "asc", 3))
134245 && (strlen(zVal)!=4 || sqlite3_strnicmp(zVal, "desc", 4))
134246 ){
134247 sqlite3Fts3ErrMsg(pzErr, "unrecognized order: %s", zVal);
134248 rc = SQLITE_ERROR;
134249 }
134250 bDescIdx = (zVal[0]=='d' || zVal[0]=='D');
134251 break;
134252
@@ -133698,11 +134293,11 @@
134293 zCompress = 0;
134294 zUncompress = 0;
134295 if( nCol==0 ){
134296 sqlite3_free((void*)aCol);
134297 aCol = 0;
134298 rc = fts3ContentColumns(db, argv[1], zContent,&aCol,&nCol,&nString,pzErr);
134299
134300 /* If a languageid= option was specified, remove the language id
134301 ** column from the aCol[] array. */
134302 if( rc==SQLITE_OK && zLanguageid ){
134303 int j;
@@ -133733,11 +134328,11 @@
134328 assert( pTokenizer );
134329
134330 rc = fts3PrefixParameter(zPrefix, &nIndex, &aIndex);
134331 if( rc==SQLITE_ERROR ){
134332 assert( zPrefix );
134333 sqlite3Fts3ErrMsg(pzErr, "error parsing prefix parameter: %s", zPrefix);
134334 }
134335 if( rc!=SQLITE_OK ) goto fts3_init_out;
134336
134337 /* Allocate and populate the Fts3Table structure. */
134338 nByte = sizeof(Fts3Table) + /* Fts3Table */
@@ -133815,19 +134410,19 @@
134410 }
134411 }
134412 }
134413 for(i=0; i<nNotindexed; i++){
134414 if( azNotindexed[i] ){
134415 sqlite3Fts3ErrMsg(pzErr, "no such column: %s", azNotindexed[i]);
134416 rc = SQLITE_ERROR;
134417 }
134418 }
134419
134420 if( rc==SQLITE_OK && (zCompress==0)!=(zUncompress==0) ){
134421 char const *zMiss = (zCompress==0 ? "compress" : "uncompress");
134422 rc = SQLITE_ERROR;
134423 sqlite3Fts3ErrMsg(pzErr, "missing %s parameter in fts4 constructor", zMiss);
134424 }
134425 p->zReadExprlist = fts3ReadExprList(p, zUncompress, &rc);
134426 p->zWriteExprlist = fts3WriteExprList(p, zCompress, &rc);
134427 if( rc!=SQLITE_OK ) goto fts3_init_out;
134428
@@ -134919,30 +135514,37 @@
135514 ** parameter bDescDoclist should be false. If they are sorted in ascending
135515 ** order, it should be passed a non-zero value.
135516 **
135517 ** The right-hand input doclist is overwritten by this function.
135518 */
135519 static int fts3DoclistPhraseMerge(
135520 int bDescDoclist, /* True if arguments are desc */
135521 int nDist, /* Distance from left to right (1=adjacent) */
135522 char *aLeft, int nLeft, /* Left doclist */
135523 char **paRight, int *pnRight /* IN/OUT: Right/output doclist */
135524 ){
135525 sqlite3_int64 i1 = 0;
135526 sqlite3_int64 i2 = 0;
135527 sqlite3_int64 iPrev = 0;
135528 char *aRight = *paRight;
135529 char *pEnd1 = &aLeft[nLeft];
135530 char *pEnd2 = &aRight[*pnRight];
135531 char *p1 = aLeft;
135532 char *p2 = aRight;
135533 char *p;
135534 int bFirstOut = 0;
135535 char *aOut;
135536
135537 assert( nDist>0 );
135538 if( bDescDoclist ){
135539 aOut = sqlite3_malloc(*pnRight + FTS3_VARINT_MAX);
135540 if( aOut==0 ) return SQLITE_NOMEM;
135541 }else{
135542 aOut = aRight;
135543 }
135544 p = aOut;
135545
135546 fts3GetDeltaVarint3(&p1, pEnd1, 0, &i1);
135547 fts3GetDeltaVarint3(&p2, pEnd2, 0, &i2);
135548
135549 while( p1 && p2 ){
135550 sqlite3_int64 iDiff = DOCID_CMP(i1, i2);
@@ -134967,10 +135569,16 @@
135569 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
135570 }
135571 }
135572
135573 *pnRight = (int)(p - aOut);
135574 if( bDescDoclist ){
135575 sqlite3_free(aRight);
135576 *paRight = aOut;
135577 }
135578
135579 return SQLITE_OK;
135580 }
135581
135582 /*
135583 ** Argument pList points to a position list nList bytes in size. This
135584 ** function checks to see if the position list contains any entries for
@@ -135091,12 +135699,26 @@
135699 char *aDoclist, /* Pointer to doclist */
135700 int nDoclist /* Size of aDoclist in bytes */
135701 ){
135702 if( pTS->aaOutput[0]==0 ){
135703 /* If this is the first term selected, copy the doclist to the output
135704 ** buffer using memcpy().
135705 **
135706 ** Add FTS3_VARINT_MAX bytes of unused space to the end of the
135707 ** allocation. This is so as to ensure that the buffer is big enough
135708 ** to hold the current doclist AND'd with any other doclist. If the
135709 ** doclists are stored in order=ASC order, this padding would not be
135710 ** required (since the size of [doclistA AND doclistB] is always less
135711 ** than or equal to the size of [doclistA] in that case). But this is
135712 ** not true for order=DESC. For example, a doclist containing (1, -1)
135713 ** may be smaller than (-1), as in the first example the -1 may be stored
135714 ** as a single-byte delta, whereas in the second it must be stored as a
135715 ** FTS3_VARINT_MAX byte varint.
135716 **
135717 ** Similar padding is added in the fts3DoclistOrMerge() function.
135718 */
135719 pTS->aaOutput[0] = sqlite3_malloc(nDoclist + FTS3_VARINT_MAX + 1);
135720 pTS->anOutput[0] = nDoclist;
135721 if( pTS->aaOutput[0] ){
135722 memcpy(pTS->aaOutput[0], aDoclist, nDoclist);
135723 }else{
135724 return SQLITE_NOMEM;
@@ -135189,11 +135811,11 @@
135811 ** Fts3SegReaderPending might segfault, as the data structures used by
135812 ** fts4aux are not completely populated. So it's easiest to filter these
135813 ** calls out here. */
135814 if( iLevel<0 && p->aIndex ){
135815 Fts3SegReader *pSeg = 0;
135816 rc = sqlite3Fts3SegReaderPending(p, iIndex, zTerm, nTerm, isPrefix||isScan, &pSeg);
135817 if( rc==SQLITE_OK && pSeg ){
135818 rc = fts3SegReaderCursorAppend(pCsr, pSeg);
135819 }
135820 }
135821
@@ -135838,15 +136460,35 @@
136460 */
136461 static void fts3ReversePoslist(char *pStart, char **ppPoslist){
136462 char *p = &(*ppPoslist)[-2];
136463 char c = 0;
136464
136465 /* Skip backwards passed any trailing 0x00 bytes added by NearTrim() */
136466 while( p>pStart && (c=*p--)==0 );
136467
136468 /* Search backwards for a varint with value zero (the end of the previous
136469 ** poslist). This is an 0x00 byte preceded by some byte that does not
136470 ** have the 0x80 bit set. */
136471 while( p>pStart && (*p & 0x80) | c ){
136472 c = *p--;
136473 }
136474 assert( p==pStart || c==0 );
136475
136476 /* At this point p points to that preceding byte without the 0x80 bit
136477 ** set. So to find the start of the poslist, skip forward 2 bytes then
136478 ** over a varint.
136479 **
136480 ** Normally. The other case is that p==pStart and the poslist to return
136481 ** is the first in the doclist. In this case do not skip forward 2 bytes.
136482 ** The second part of the if condition (c==0 && *ppPoslist>&p[2])
136483 ** is required for cases where the first byte of a doclist and the
136484 ** doclist is empty. For example, if the first docid is 10, a doclist
136485 ** that begins with:
136486 **
136487 ** 0x0A 0x00 <next docid delta varint>
136488 */
136489 if( p>pStart || (c==0 && *ppPoslist>&p[2]) ){ p = &p[2]; }
136490 while( *p++&0x80 );
136491 *ppPoslist = p;
136492 }
136493
136494 /*
@@ -135913,10 +136555,12 @@
136555 case 3: zEnd = (const char*)sqlite3_value_text(apVal[2]);
136556 case 2: zStart = (const char*)sqlite3_value_text(apVal[1]);
136557 }
136558 if( !zEllipsis || !zEnd || !zStart ){
136559 sqlite3_result_error_nomem(pContext);
136560 }else if( nToken==0 ){
136561 sqlite3_result_text(pContext, "", -1, SQLITE_STATIC);
136562 }else if( SQLITE_OK==fts3CursorSeek(pContext, pCsr) ){
136563 sqlite3Fts3Snippet(pContext, pCsr, zStart, zEnd, zEllipsis, iCol, nToken);
136564 }
136565 }
136566
@@ -136348,18 +136992,21 @@
136992 ** It is merged into the main doclist stored in p->doclist.aAll/nAll.
136993 **
136994 ** This function assumes that pList points to a buffer allocated using
136995 ** sqlite3_malloc(). This function takes responsibility for eventually
136996 ** freeing the buffer.
136997 **
136998 ** SQLITE_OK is returned if successful, or SQLITE_NOMEM if an error occurs.
136999 */
137000 static int fts3EvalPhraseMergeToken(
137001 Fts3Table *pTab, /* FTS Table pointer */
137002 Fts3Phrase *p, /* Phrase to merge pList/nList into */
137003 int iToken, /* Token pList/nList corresponds to */
137004 char *pList, /* Pointer to doclist */
137005 int nList /* Number of bytes in pList */
137006 ){
137007 int rc = SQLITE_OK;
137008 assert( iToken!=p->iDoclistToken );
137009
137010 if( pList==0 ){
137011 sqlite3_free(p->doclist.aAll);
137012 p->doclist.aAll = 0;
@@ -136394,17 +137041,20 @@
137041 pLeft = pList;
137042 nLeft = nList;
137043 nDiff = p->iDoclistToken - iToken;
137044 }
137045
137046 rc = fts3DoclistPhraseMerge(
137047 pTab->bDescIdx, nDiff, pLeft, nLeft, &pRight, &nRight
137048 );
137049 sqlite3_free(pLeft);
137050 p->doclist.aAll = pRight;
137051 p->doclist.nAll = nRight;
137052 }
137053
137054 if( iToken>p->iDoclistToken ) p->iDoclistToken = iToken;
137055 return rc;
137056 }
137057
137058 /*
137059 ** Load the doclist for phrase p into p->doclist.aAll/nAll. The loaded doclist
137060 ** does not take deferred tokens into account.
@@ -136426,11 +137076,11 @@
137076 if( pToken->pSegcsr ){
137077 int nThis = 0;
137078 char *pThis = 0;
137079 rc = fts3TermSelect(pTab, pToken, p->iColumn, &nThis, &pThis);
137080 if( rc==SQLITE_OK ){
137081 rc = fts3EvalPhraseMergeToken(pTab, p, iToken, pThis, nThis);
137082 }
137083 }
137084 assert( pToken->pSegcsr==0 );
137085 }
137086
@@ -136968,16 +137618,18 @@
137618 Fts3Expr *pExpr, /* Expression to initialize phrases in */
137619 int *pRc /* IN/OUT: Error code */
137620 ){
137621 if( pExpr && SQLITE_OK==*pRc ){
137622 if( pExpr->eType==FTSQUERY_PHRASE ){
 
137623 int nToken = pExpr->pPhrase->nToken;
137624 if( nToken ){
137625 int i;
137626 for(i=0; i<nToken; i++){
137627 if( pExpr->pPhrase->aToken[i].pDeferred==0 ) break;
137628 }
137629 pExpr->bDeferred = (i==nToken);
137630 }
 
137631 *pRc = fts3EvalPhraseStart(pCsr, 1, pExpr->pPhrase);
137632 }else{
137633 fts3EvalStartReaders(pCsr, pExpr->pLeft, pRc);
137634 fts3EvalStartReaders(pCsr, pExpr->pRight, pRc);
137635 pExpr->bDeferred = (pExpr->pLeft->bDeferred && pExpr->pRight->bDeferred);
@@ -137228,13 +137880,17 @@
137880 Fts3PhraseToken *pToken = pTC->pToken;
137881 int nList = 0;
137882 char *pList = 0;
137883 rc = fts3TermSelect(pTab, pToken, pTC->iCol, &nList, &pList);
137884 assert( rc==SQLITE_OK || pList==0 );
137885 if( rc==SQLITE_OK ){
137886 rc = fts3EvalPhraseMergeToken(
137887 pTab, pTC->pPhrase, pTC->iToken,pList,nList
137888 );
137889 }
137890 if( rc==SQLITE_OK ){
137891 int nCount;
 
137892 nCount = fts3DoclistCountDocids(
137893 pTC->pPhrase->doclist.aAll, pTC->pPhrase->doclist.nAll
137894 );
137895 if( ii==0 || nCount<nMinEst ) nMinEst = nCount;
137896 }
@@ -138132,11 +138788,12 @@
138788 if( rc!=SQLITE_OK ) return rc;
138789
138790 pIter = pPhrase->pOrPoslist;
138791 iDocid = pPhrase->iOrDocid;
138792 if( pCsr->bDesc==bDescDoclist ){
138793 bEof = !pPhrase->doclist.nAll ||
138794 (pIter >= (pPhrase->doclist.aAll + pPhrase->doclist.nAll));
138795 while( (pIter==0 || DOCID_CMP(iDocid, pCsr->iPrevId)<0 ) && bEof==0 ){
138796 sqlite3Fts3DoclistNext(
138797 bDescDoclist, pPhrase->doclist.aAll, pPhrase->doclist.nAll,
138798 &pIter, &iDocid, &bEof
138799 );
@@ -138213,11 +138870,11 @@
138870 ** Initialize API pointer table, if required.
138871 */
138872 #ifdef _WIN32
138873 __declspec(dllexport)
138874 #endif
138875 SQLITE_API int SQLITE_STDCALL sqlite3_fts3_init(
138876 sqlite3 *db,
138877 char **pzErrMsg,
138878 const sqlite3_api_routines *pApi
138879 ){
138880 SQLITE_EXTENSION_INIT2(pApi)
@@ -138344,11 +139001,11 @@
139001
139002 *ppVtab = (sqlite3_vtab *)p;
139003 return SQLITE_OK;
139004
139005 bad_args:
139006 sqlite3Fts3ErrMsg(pzErr, "invalid arguments to fts4aux constructor");
139007 return SQLITE_ERROR;
139008 }
139009
139010 /*
139011 ** This function does the work for both the xDisconnect and xDestroy methods.
@@ -139802,17 +140459,17 @@
140459
140460 if( rc!=SQLITE_OK ){
140461 sqlite3Fts3ExprFree(*ppExpr);
140462 *ppExpr = 0;
140463 if( rc==SQLITE_TOOBIG ){
140464 sqlite3Fts3ErrMsg(pzErr,
140465 "FTS expression tree is too large (maximum depth %d)",
140466 SQLITE_FTS3_MAX_EXPR_DEPTH
140467 );
140468 rc = SQLITE_ERROR;
140469 }else if( rc==SQLITE_ERROR ){
140470 sqlite3Fts3ErrMsg(pzErr, "malformed MATCH expression: [%s]", z);
140471 }
140472 }
140473
140474 return rc;
140475 }
@@ -141284,11 +141941,11 @@
141941 z[n] = '\0';
141942 sqlite3Fts3Dequote(z);
141943
141944 m = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash,z,(int)strlen(z)+1);
141945 if( !m ){
141946 sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer: %s", z);
141947 rc = SQLITE_ERROR;
141948 }else{
141949 char const **aArg = 0;
141950 int iArg = 0;
141951 z = &z[n+1];
@@ -141307,11 +141964,11 @@
141964 z = &z[n+1];
141965 }
141966 rc = m->xCreate(iArg, aArg, ppTok);
141967 assert( rc!=SQLITE_OK || *ppTok );
141968 if( rc!=SQLITE_OK ){
141969 sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer");
141970 }else{
141971 (*ppTok)->pModule = m;
141972 }
141973 sqlite3_free((void *)aArg);
141974 }
@@ -141391,13 +142048,13 @@
142048
142049 pHash = (Fts3Hash *)sqlite3_user_data(context);
142050 p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
142051
142052 if( !p ){
142053 char *zErr2 = sqlite3_mprintf("unknown tokenizer: %s", zName);
142054 sqlite3_result_error(context, zErr2, -1);
142055 sqlite3_free(zErr2);
142056 return;
142057 }
142058
142059 pRet = Tcl_NewObj();
142060 Tcl_IncrRefCount(pRet);
@@ -141928,11 +142585,11 @@
142585 sqlite3_tokenizer_module *p;
142586 int nName = (int)strlen(zName);
142587
142588 p = (sqlite3_tokenizer_module *)sqlite3Fts3HashFind(pHash, zName, nName+1);
142589 if( !p ){
142590 sqlite3Fts3ErrMsg(pzErr, "unknown tokenizer: %s", zName);
142591 return SQLITE_ERROR;
142592 }
142593
142594 *pp = p;
142595 return SQLITE_OK;
@@ -142625,11 +143282,11 @@
143282 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
143283 /* 24 */ "",
143284 /* 25 */ "",
143285
143286 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
143287 /* 27 */ "SELECT ? UNION SELECT level / (1024 * ?) FROM %Q.'%q_segdir'",
143288
143289 /* This statement is used to determine which level to read the input from
143290 ** when performing an incremental merge. It returns the absolute level number
143291 ** of the oldest level in the db that contains at least ? segments. Or,
143292 ** if no level in the FTS index contains more than ? segments, the statement
@@ -145743,11 +146400,12 @@
146400 sqlite3_stmt *pAllLangid = 0;
146401
146402 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
146403 if( rc==SQLITE_OK ){
146404 int rc2;
146405 sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
146406 sqlite3_bind_int(pAllLangid, 2, p->nIndex);
146407 while( sqlite3_step(pAllLangid)==SQLITE_ROW ){
146408 int i;
146409 int iLangid = sqlite3_column_int(pAllLangid, 0);
146410 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
146411 rc = fts3SegmentMerge(p, iLangid, i, FTS3_SEGCURSOR_ALL);
@@ -147075,11 +147733,11 @@
147733 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
147734
147735 pHint->n = i;
147736 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
147737 i += fts3GetVarint32(&pHint->a[i], pnInput);
147738 if( i!=nHint ) return FTS_CORRUPT_VTAB;
147739
147740 return SQLITE_OK;
147741 }
147742
147743
@@ -147443,11 +148101,12 @@
148101
148102 /* This block calculates the checksum according to the FTS index. */
148103 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
148104 if( rc==SQLITE_OK ){
148105 int rc2;
148106 sqlite3_bind_int(pAllLangid, 1, p->iPrevLangid);
148107 sqlite3_bind_int(pAllLangid, 2, p->nIndex);
148108 while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
148109 int iLangid = sqlite3_column_int(pAllLangid, 0);
148110 int i;
148111 for(i=0; i<p->nIndex; i++){
148112 cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
@@ -147456,11 +148115,10 @@
148115 rc2 = sqlite3_reset(pAllLangid);
148116 if( rc==SQLITE_OK ) rc = rc2;
148117 }
148118
148119 /* This block calculates the checksum according to the %_content table */
 
148120 if( rc==SQLITE_OK ){
148121 sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
148122 sqlite3_stmt *pStmt = 0;
148123 char *zSql;
148124
@@ -147553,11 +148211,11 @@
148211 Fts3Table *p /* FTS3 table handle */
148212 ){
148213 int rc;
148214 int bOk = 0;
148215 rc = fts3IntegrityCheck(p, &bOk);
148216 if( rc==SQLITE_OK && bOk==0 ) rc = FTS_CORRUPT_VTAB;
148217 return rc;
148218 }
148219
148220 /*
148221 ** Handle a 'special' INSERT of the form:
@@ -147991,10 +148649,11 @@
148649 #define FTS3_MATCHINFO_NDOC 'n' /* 1 value */
148650 #define FTS3_MATCHINFO_AVGLENGTH 'a' /* nCol values */
148651 #define FTS3_MATCHINFO_LENGTH 'l' /* nCol values */
148652 #define FTS3_MATCHINFO_LCS 's' /* nCol values */
148653 #define FTS3_MATCHINFO_HITS 'x' /* 3*nCol*nPhrase values */
148654 #define FTS3_MATCHINFO_LHITS 'y' /* nCol*nPhrase values */
148655
148656 /*
148657 ** The default value for the second argument to matchinfo().
148658 */
148659 #define FTS3_MATCHINFO_DEFAULT "pcx"
@@ -148772,10 +149431,55 @@
149431 }
149432 }
149433
149434 return rc;
149435 }
149436
149437 /*
149438 ** fts3ExprIterate() callback used to gather information for the matchinfo
149439 ** directive 'y'.
149440 */
149441 static int fts3ExprLHitsCb(
149442 Fts3Expr *pExpr, /* Phrase expression node */
149443 int iPhrase, /* Phrase number */
149444 void *pCtx /* Pointer to MatchInfo structure */
149445 ){
149446 MatchInfo *p = (MatchInfo *)pCtx;
149447 Fts3Table *pTab = (Fts3Table *)p->pCursor->base.pVtab;
149448 int rc = SQLITE_OK;
149449 int iStart = iPhrase * p->nCol;
149450 Fts3Expr *pEof; /* Ancestor node already at EOF */
149451
149452 /* This must be a phrase */
149453 assert( pExpr->pPhrase );
149454
149455 /* Initialize all output integers to zero. */
149456 memset(&p->aMatchinfo[iStart], 0, sizeof(u32) * p->nCol);
149457
149458 /* Check if this or any parent node is at EOF. If so, then all output
149459 ** values are zero. */
149460 for(pEof=pExpr; pEof && pEof->bEof==0; pEof=pEof->pParent);
149461
149462 if( pEof==0 && pExpr->iDocid==p->pCursor->iPrevId ){
149463 Fts3Phrase *pPhrase = pExpr->pPhrase;
149464 char *pIter = pPhrase->doclist.pList;
149465 int iCol = 0;
149466
149467 while( 1 ){
149468 int nHit = fts3ColumnlistCount(&pIter);
149469 if( (pPhrase->iColumn>=pTab->nColumn || pPhrase->iColumn==iCol) ){
149470 p->aMatchinfo[iStart + iCol] = (u32)nHit;
149471 }
149472 assert( *pIter==0x00 || *pIter==0x01 );
149473 if( *pIter!=0x01 ) break;
149474 pIter++;
149475 pIter += fts3GetVarint32(pIter, &iCol);
149476 }
149477 }
149478
149479 return rc;
149480 }
149481
149482 static int fts3MatchinfoCheck(
149483 Fts3Table *pTab,
149484 char cArg,
149485 char **pzErr
@@ -148785,14 +149489,15 @@
149489 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
149490 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
149491 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
149492 || (cArg==FTS3_MATCHINFO_LCS)
149493 || (cArg==FTS3_MATCHINFO_HITS)
149494 || (cArg==FTS3_MATCHINFO_LHITS)
149495 ){
149496 return SQLITE_OK;
149497 }
149498 sqlite3Fts3ErrMsg(pzErr, "unrecognized matchinfo request: %c", cArg);
149499 return SQLITE_ERROR;
149500 }
149501
149502 static int fts3MatchinfoSize(MatchInfo *pInfo, char cArg){
149503 int nVal; /* Number of integers output by cArg */
@@ -148807,10 +149512,14 @@
149512 case FTS3_MATCHINFO_AVGLENGTH:
149513 case FTS3_MATCHINFO_LENGTH:
149514 case FTS3_MATCHINFO_LCS:
149515 nVal = pInfo->nCol;
149516 break;
149517
149518 case FTS3_MATCHINFO_LHITS:
149519 nVal = pInfo->nCol * pInfo->nPhrase;
149520 break;
149521
149522 default:
149523 assert( cArg==FTS3_MATCHINFO_HITS );
149524 nVal = pInfo->nCol * pInfo->nPhrase * 3;
149525 break;
@@ -149061,10 +149770,14 @@
149770 rc = fts3ExprLoadDoclists(pCsr, 0, 0);
149771 if( rc==SQLITE_OK ){
149772 rc = fts3MatchinfoLcs(pCsr, pInfo);
149773 }
149774 break;
149775
149776 case FTS3_MATCHINFO_LHITS:
149777 (void)fts3ExprIterate(pCsr->pExpr, fts3ExprLHitsCb, (void*)pInfo);
149778 break;
149779
149780 default: {
149781 Fts3Expr *pExpr;
149782 assert( zArg[i]==FTS3_MATCHINFO_HITS );
149783 pExpr = pCsr->pExpr;
@@ -153074,15 +153787,23 @@
153787 ** conflict-handling mode specified by the user.
153788 */
153789 if( nData>1 ){
153790 int ii;
153791
153792 /* Populate the cell.aCoord[] array. The first coordinate is azData[3].
153793 **
153794 ** NB: nData can only be less than nDim*2+3 if the rtree is mis-declared
153795 ** with "column" that are interpreted as table constraints.
153796 ** Example: CREATE VIRTUAL TABLE bad USING rtree(x,y,CHECK(y>5));
153797 ** This problem was discovered after years of use, so we silently ignore
153798 ** these kinds of misdeclared tables to avoid breaking any legacy.
153799 */
153800 assert( nData<=(pRtree->nDim*2 + 3) );
153801
153802 #ifndef SQLITE_RTREE_INT_ONLY
153803 if( pRtree->eCoordType==RTREE_COORD_REAL32 ){
153804 for(ii=0; ii<nData-4; ii+=2){
153805 cell.aCoord[ii].f = rtreeValueDown(azData[ii+3]);
153806 cell.aCoord[ii+1].f = rtreeValueUp(azData[ii+4]);
153807 if( cell.aCoord[ii].f>cell.aCoord[ii+1].f ){
153808 rc = SQLITE_CONSTRAINT;
153809 goto constraint;
@@ -153089,11 +153810,11 @@
153810 }
153811 }
153812 }else
153813 #endif
153814 {
153815 for(ii=0; ii<nData-4; ii+=2){
153816 cell.aCoord[ii].i = sqlite3_value_int(azData[ii+3]);
153817 cell.aCoord[ii+1].i = sqlite3_value_int(azData[ii+4]);
153818 if( cell.aCoord[ii].i>cell.aCoord[ii+1].i ){
153819 rc = SQLITE_CONSTRAINT;
153820 goto constraint;
@@ -153660,11 +154381,11 @@
154381 }
154382
154383 /*
154384 ** Register a new geometry function for use with the r-tree MATCH operator.
154385 */
154386 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
154387 sqlite3 *db, /* Register SQL function on this connection */
154388 const char *zGeom, /* Name of the new SQL function */
154389 int (*xGeom)(sqlite3_rtree_geometry*,int,RtreeDValue*,int*), /* Callback */
154390 void *pContext /* Extra data associated with the callback */
154391 ){
@@ -153684,11 +154405,11 @@
154405
154406 /*
154407 ** Register a new 2nd-generation geometry function for use with the
154408 ** r-tree MATCH operator.
154409 */
154410 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
154411 sqlite3 *db, /* Register SQL function on this connection */
154412 const char *zQueryFunc, /* Name of new SQL function */
154413 int (*xQueryFunc)(sqlite3_rtree_query_info*), /* Callback */
154414 void *pContext, /* Extra data passed into the callback */
154415 void (*xDestructor)(void*) /* Destructor for the extra data */
@@ -153709,11 +154430,11 @@
154430
154431 #if !SQLITE_CORE
154432 #ifdef _WIN32
154433 __declspec(dllexport)
154434 #endif
154435 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_init(
154436 sqlite3 *db,
154437 char **pzErrMsg,
154438 const sqlite3_api_routines *pApi
154439 ){
154440 SQLITE_EXTENSION_INIT2(pApi)
@@ -154214,11 +154935,11 @@
154935
154936 #if !SQLITE_CORE
154937 #ifdef _WIN32
154938 __declspec(dllexport)
154939 #endif
154940 SQLITE_API int SQLITE_STDCALL sqlite3_icu_init(
154941 sqlite3 *db,
154942 char **pzErrMsg,
154943 const sqlite3_api_routines *pApi
154944 ){
154945 SQLITE_EXTENSION_INIT2(pApi)
@@ -154489,5 +155210,656 @@
155210
155211 #endif /* defined(SQLITE_ENABLE_ICU) */
155212 #endif /* !defined(SQLITE_CORE) || defined(SQLITE_ENABLE_FTS3) */
155213
155214 /************** End of fts3_icu.c ********************************************/
155215 /************** Begin file dbstat.c ******************************************/
155216 /*
155217 ** 2010 July 12
155218 **
155219 ** The author disclaims copyright to this source code. In place of
155220 ** a legal notice, here is a blessing:
155221 **
155222 ** May you do good and not evil.
155223 ** May you find forgiveness for yourself and forgive others.
155224 ** May you share freely, never taking more than you give.
155225 **
155226 ******************************************************************************
155227 **
155228 ** This file contains an implementation of the "dbstat" virtual table.
155229 **
155230 ** The dbstat virtual table is used to extract low-level formatting
155231 ** information from an SQLite database in order to implement the
155232 ** "sqlite3_analyzer" utility. See the ../tool/spaceanal.tcl script
155233 ** for an example implementation.
155234 */
155235
155236 #if (defined(SQLITE_ENABLE_DBSTAT_VTAB) || defined(SQLITE_TEST)) \
155237 && !defined(SQLITE_OMIT_VIRTUALTABLE)
155238
155239 /*
155240 ** Page paths:
155241 **
155242 ** The value of the 'path' column describes the path taken from the
155243 ** root-node of the b-tree structure to each page. The value of the
155244 ** root-node path is '/'.
155245 **
155246 ** The value of the path for the left-most child page of the root of
155247 ** a b-tree is '/000/'. (Btrees store content ordered from left to right
155248 ** so the pages to the left have smaller keys than the pages to the right.)
155249 ** The next to left-most child of the root page is
155250 ** '/001', and so on, each sibling page identified by a 3-digit hex
155251 ** value. The children of the 451st left-most sibling have paths such
155252 ** as '/1c2/000/, '/1c2/001/' etc.
155253 **
155254 ** Overflow pages are specified by appending a '+' character and a
155255 ** six-digit hexadecimal value to the path to the cell they are linked
155256 ** from. For example, the three overflow pages in a chain linked from
155257 ** the left-most cell of the 450th child of the root page are identified
155258 ** by the paths:
155259 **
155260 ** '/1c2/000+000000' // First page in overflow chain
155261 ** '/1c2/000+000001' // Second page in overflow chain
155262 ** '/1c2/000+000002' // Third page in overflow chain
155263 **
155264 ** If the paths are sorted using the BINARY collation sequence, then
155265 ** the overflow pages associated with a cell will appear earlier in the
155266 ** sort-order than its child page:
155267 **
155268 ** '/1c2/000/' // Left-most child of 451st child of root
155269 */
155270 #define VTAB_SCHEMA \
155271 "CREATE TABLE xx( " \
155272 " name STRING, /* Name of table or index */" \
155273 " path INTEGER, /* Path to page from root */" \
155274 " pageno INTEGER, /* Page number */" \
155275 " pagetype STRING, /* 'internal', 'leaf' or 'overflow' */" \
155276 " ncell INTEGER, /* Cells on page (0 for overflow) */" \
155277 " payload INTEGER, /* Bytes of payload on this page */" \
155278 " unused INTEGER, /* Bytes of unused space on this page */" \
155279 " mx_payload INTEGER, /* Largest payload size of all cells */" \
155280 " pgoffset INTEGER, /* Offset of page in file */" \
155281 " pgsize INTEGER /* Size of the page */" \
155282 ");"
155283
155284
155285 typedef struct StatTable StatTable;
155286 typedef struct StatCursor StatCursor;
155287 typedef struct StatPage StatPage;
155288 typedef struct StatCell StatCell;
155289
155290 struct StatCell {
155291 int nLocal; /* Bytes of local payload */
155292 u32 iChildPg; /* Child node (or 0 if this is a leaf) */
155293 int nOvfl; /* Entries in aOvfl[] */
155294 u32 *aOvfl; /* Array of overflow page numbers */
155295 int nLastOvfl; /* Bytes of payload on final overflow page */
155296 int iOvfl; /* Iterates through aOvfl[] */
155297 };
155298
155299 struct StatPage {
155300 u32 iPgno;
155301 DbPage *pPg;
155302 int iCell;
155303
155304 char *zPath; /* Path to this page */
155305
155306 /* Variables populated by statDecodePage(): */
155307 u8 flags; /* Copy of flags byte */
155308 int nCell; /* Number of cells on page */
155309 int nUnused; /* Number of unused bytes on page */
155310 StatCell *aCell; /* Array of parsed cells */
155311 u32 iRightChildPg; /* Right-child page number (or 0) */
155312 int nMxPayload; /* Largest payload of any cell on this page */
155313 };
155314
155315 struct StatCursor {
155316 sqlite3_vtab_cursor base;
155317 sqlite3_stmt *pStmt; /* Iterates through set of root pages */
155318 int isEof; /* After pStmt has returned SQLITE_DONE */
155319
155320 StatPage aPage[32];
155321 int iPage; /* Current entry in aPage[] */
155322
155323 /* Values to return. */
155324 char *zName; /* Value of 'name' column */
155325 char *zPath; /* Value of 'path' column */
155326 u32 iPageno; /* Value of 'pageno' column */
155327 char *zPagetype; /* Value of 'pagetype' column */
155328 int nCell; /* Value of 'ncell' column */
155329 int nPayload; /* Value of 'payload' column */
155330 int nUnused; /* Value of 'unused' column */
155331 int nMxPayload; /* Value of 'mx_payload' column */
155332 i64 iOffset; /* Value of 'pgOffset' column */
155333 int szPage; /* Value of 'pgSize' column */
155334 };
155335
155336 struct StatTable {
155337 sqlite3_vtab base;
155338 sqlite3 *db;
155339 int iDb; /* Index of database to analyze */
155340 };
155341
155342 #ifndef get2byte
155343 # define get2byte(x) ((x)[0]<<8 | (x)[1])
155344 #endif
155345
155346 /*
155347 ** Connect to or create a statvfs virtual table.
155348 */
155349 static int statConnect(
155350 sqlite3 *db,
155351 void *pAux,
155352 int argc, const char *const*argv,
155353 sqlite3_vtab **ppVtab,
155354 char **pzErr
155355 ){
155356 StatTable *pTab = 0;
155357 int rc = SQLITE_OK;
155358 int iDb;
155359
155360 if( argc>=4 ){
155361 iDb = sqlite3FindDbName(db, argv[3]);
155362 if( iDb<0 ){
155363 *pzErr = sqlite3_mprintf("no such database: %s", argv[3]);
155364 return SQLITE_ERROR;
155365 }
155366 }else{
155367 iDb = 0;
155368 }
155369 rc = sqlite3_declare_vtab(db, VTAB_SCHEMA);
155370 if( rc==SQLITE_OK ){
155371 pTab = (StatTable *)sqlite3_malloc64(sizeof(StatTable));
155372 if( pTab==0 ) rc = SQLITE_NOMEM;
155373 }
155374
155375 assert( rc==SQLITE_OK || pTab==0 );
155376 if( rc==SQLITE_OK ){
155377 memset(pTab, 0, sizeof(StatTable));
155378 pTab->db = db;
155379 pTab->iDb = iDb;
155380 }
155381
155382 *ppVtab = (sqlite3_vtab*)pTab;
155383 return rc;
155384 }
155385
155386 /*
155387 ** Disconnect from or destroy a statvfs virtual table.
155388 */
155389 static int statDisconnect(sqlite3_vtab *pVtab){
155390 sqlite3_free(pVtab);
155391 return SQLITE_OK;
155392 }
155393
155394 /*
155395 ** There is no "best-index". This virtual table always does a linear
155396 ** scan of the binary VFS log file.
155397 */
155398 static int statBestIndex(sqlite3_vtab *tab, sqlite3_index_info *pIdxInfo){
155399
155400 /* Records are always returned in ascending order of (name, path).
155401 ** If this will satisfy the client, set the orderByConsumed flag so that
155402 ** SQLite does not do an external sort.
155403 */
155404 if( ( pIdxInfo->nOrderBy==1
155405 && pIdxInfo->aOrderBy[0].iColumn==0
155406 && pIdxInfo->aOrderBy[0].desc==0
155407 ) ||
155408 ( pIdxInfo->nOrderBy==2
155409 && pIdxInfo->aOrderBy[0].iColumn==0
155410 && pIdxInfo->aOrderBy[0].desc==0
155411 && pIdxInfo->aOrderBy[1].iColumn==1
155412 && pIdxInfo->aOrderBy[1].desc==0
155413 )
155414 ){
155415 pIdxInfo->orderByConsumed = 1;
155416 }
155417
155418 pIdxInfo->estimatedCost = 10.0;
155419 return SQLITE_OK;
155420 }
155421
155422 /*
155423 ** Open a new statvfs cursor.
155424 */
155425 static int statOpen(sqlite3_vtab *pVTab, sqlite3_vtab_cursor **ppCursor){
155426 StatTable *pTab = (StatTable *)pVTab;
155427 StatCursor *pCsr;
155428 int rc;
155429
155430 pCsr = (StatCursor *)sqlite3_malloc64(sizeof(StatCursor));
155431 if( pCsr==0 ){
155432 rc = SQLITE_NOMEM;
155433 }else{
155434 char *zSql;
155435 memset(pCsr, 0, sizeof(StatCursor));
155436 pCsr->base.pVtab = pVTab;
155437
155438 zSql = sqlite3_mprintf(
155439 "SELECT 'sqlite_master' AS name, 1 AS rootpage, 'table' AS type"
155440 " UNION ALL "
155441 "SELECT name, rootpage, type"
155442 " FROM \"%w\".sqlite_master WHERE rootpage!=0"
155443 " ORDER BY name", pTab->db->aDb[pTab->iDb].zName);
155444 if( zSql==0 ){
155445 rc = SQLITE_NOMEM;
155446 }else{
155447 rc = sqlite3_prepare_v2(pTab->db, zSql, -1, &pCsr->pStmt, 0);
155448 sqlite3_free(zSql);
155449 }
155450 if( rc!=SQLITE_OK ){
155451 sqlite3_free(pCsr);
155452 pCsr = 0;
155453 }
155454 }
155455
155456 *ppCursor = (sqlite3_vtab_cursor *)pCsr;
155457 return rc;
155458 }
155459
155460 static void statClearPage(StatPage *p){
155461 int i;
155462 if( p->aCell ){
155463 for(i=0; i<p->nCell; i++){
155464 sqlite3_free(p->aCell[i].aOvfl);
155465 }
155466 sqlite3_free(p->aCell);
155467 }
155468 sqlite3PagerUnref(p->pPg);
155469 sqlite3_free(p->zPath);
155470 memset(p, 0, sizeof(StatPage));
155471 }
155472
155473 static void statResetCsr(StatCursor *pCsr){
155474 int i;
155475 sqlite3_reset(pCsr->pStmt);
155476 for(i=0; i<ArraySize(pCsr->aPage); i++){
155477 statClearPage(&pCsr->aPage[i]);
155478 }
155479 pCsr->iPage = 0;
155480 sqlite3_free(pCsr->zPath);
155481 pCsr->zPath = 0;
155482 }
155483
155484 /*
155485 ** Close a statvfs cursor.
155486 */
155487 static int statClose(sqlite3_vtab_cursor *pCursor){
155488 StatCursor *pCsr = (StatCursor *)pCursor;
155489 statResetCsr(pCsr);
155490 sqlite3_finalize(pCsr->pStmt);
155491 sqlite3_free(pCsr);
155492 return SQLITE_OK;
155493 }
155494
155495 static void getLocalPayload(
155496 int nUsable, /* Usable bytes per page */
155497 u8 flags, /* Page flags */
155498 int nTotal, /* Total record (payload) size */
155499 int *pnLocal /* OUT: Bytes stored locally */
155500 ){
155501 int nLocal;
155502 int nMinLocal;
155503 int nMaxLocal;
155504
155505 if( flags==0x0D ){ /* Table leaf node */
155506 nMinLocal = (nUsable - 12) * 32 / 255 - 23;
155507 nMaxLocal = nUsable - 35;
155508 }else{ /* Index interior and leaf nodes */
155509 nMinLocal = (nUsable - 12) * 32 / 255 - 23;
155510 nMaxLocal = (nUsable - 12) * 64 / 255 - 23;
155511 }
155512
155513 nLocal = nMinLocal + (nTotal - nMinLocal) % (nUsable - 4);
155514 if( nLocal>nMaxLocal ) nLocal = nMinLocal;
155515 *pnLocal = nLocal;
155516 }
155517
155518 static int statDecodePage(Btree *pBt, StatPage *p){
155519 int nUnused;
155520 int iOff;
155521 int nHdr;
155522 int isLeaf;
155523 int szPage;
155524
155525 u8 *aData = sqlite3PagerGetData(p->pPg);
155526 u8 *aHdr = &aData[p->iPgno==1 ? 100 : 0];
155527
155528 p->flags = aHdr[0];
155529 p->nCell = get2byte(&aHdr[3]);
155530 p->nMxPayload = 0;
155531
155532 isLeaf = (p->flags==0x0A || p->flags==0x0D);
155533 nHdr = 12 - isLeaf*4 + (p->iPgno==1)*100;
155534
155535 nUnused = get2byte(&aHdr[5]) - nHdr - 2*p->nCell;
155536 nUnused += (int)aHdr[7];
155537 iOff = get2byte(&aHdr[1]);
155538 while( iOff ){
155539 nUnused += get2byte(&aData[iOff+2]);
155540 iOff = get2byte(&aData[iOff]);
155541 }
155542 p->nUnused = nUnused;
155543 p->iRightChildPg = isLeaf ? 0 : sqlite3Get4byte(&aHdr[8]);
155544 szPage = sqlite3BtreeGetPageSize(pBt);
155545
155546 if( p->nCell ){
155547 int i; /* Used to iterate through cells */
155548 int nUsable; /* Usable bytes per page */
155549
155550 sqlite3BtreeEnter(pBt);
155551 nUsable = szPage - sqlite3BtreeGetReserveNoMutex(pBt);
155552 sqlite3BtreeLeave(pBt);
155553 p->aCell = sqlite3_malloc64((p->nCell+1) * sizeof(StatCell));
155554 if( p->aCell==0 ) return SQLITE_NOMEM;
155555 memset(p->aCell, 0, (p->nCell+1) * sizeof(StatCell));
155556
155557 for(i=0; i<p->nCell; i++){
155558 StatCell *pCell = &p->aCell[i];
155559
155560 iOff = get2byte(&aData[nHdr+i*2]);
155561 if( !isLeaf ){
155562 pCell->iChildPg = sqlite3Get4byte(&aData[iOff]);
155563 iOff += 4;
155564 }
155565 if( p->flags==0x05 ){
155566 /* A table interior node. nPayload==0. */
155567 }else{
155568 u32 nPayload; /* Bytes of payload total (local+overflow) */
155569 int nLocal; /* Bytes of payload stored locally */
155570 iOff += getVarint32(&aData[iOff], nPayload);
155571 if( p->flags==0x0D ){
155572 u64 dummy;
155573 iOff += sqlite3GetVarint(&aData[iOff], &dummy);
155574 }
155575 if( nPayload>(u32)p->nMxPayload ) p->nMxPayload = nPayload;
155576 getLocalPayload(nUsable, p->flags, nPayload, &nLocal);
155577 pCell->nLocal = nLocal;
155578 assert( nLocal>=0 );
155579 assert( nPayload>=(u32)nLocal );
155580 assert( nLocal<=(nUsable-35) );
155581 if( nPayload>(u32)nLocal ){
155582 int j;
155583 int nOvfl = ((nPayload - nLocal) + nUsable-4 - 1) / (nUsable - 4);
155584 pCell->nLastOvfl = (nPayload-nLocal) - (nOvfl-1) * (nUsable-4);
155585 pCell->nOvfl = nOvfl;
155586 pCell->aOvfl = sqlite3_malloc64(sizeof(u32)*nOvfl);
155587 if( pCell->aOvfl==0 ) return SQLITE_NOMEM;
155588 pCell->aOvfl[0] = sqlite3Get4byte(&aData[iOff+nLocal]);
155589 for(j=1; j<nOvfl; j++){
155590 int rc;
155591 u32 iPrev = pCell->aOvfl[j-1];
155592 DbPage *pPg = 0;
155593 rc = sqlite3PagerGet(sqlite3BtreePager(pBt), iPrev, &pPg);
155594 if( rc!=SQLITE_OK ){
155595 assert( pPg==0 );
155596 return rc;
155597 }
155598 pCell->aOvfl[j] = sqlite3Get4byte(sqlite3PagerGetData(pPg));
155599 sqlite3PagerUnref(pPg);
155600 }
155601 }
155602 }
155603 }
155604 }
155605
155606 return SQLITE_OK;
155607 }
155608
155609 /*
155610 ** Populate the pCsr->iOffset and pCsr->szPage member variables. Based on
155611 ** the current value of pCsr->iPageno.
155612 */
155613 static void statSizeAndOffset(StatCursor *pCsr){
155614 StatTable *pTab = (StatTable *)((sqlite3_vtab_cursor *)pCsr)->pVtab;
155615 Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
155616 Pager *pPager = sqlite3BtreePager(pBt);
155617 sqlite3_file *fd;
155618 sqlite3_int64 x[2];
155619
155620 /* The default page size and offset */
155621 pCsr->szPage = sqlite3BtreeGetPageSize(pBt);
155622 pCsr->iOffset = (i64)pCsr->szPage * (pCsr->iPageno - 1);
155623
155624 /* If connected to a ZIPVFS backend, override the page size and
155625 ** offset with actual values obtained from ZIPVFS.
155626 */
155627 fd = sqlite3PagerFile(pPager);
155628 x[0] = pCsr->iPageno;
155629 if( fd->pMethods!=0 && sqlite3OsFileControl(fd, 230440, &x)==SQLITE_OK ){
155630 pCsr->iOffset = x[0];
155631 pCsr->szPage = (int)x[1];
155632 }
155633 }
155634
155635 /*
155636 ** Move a statvfs cursor to the next entry in the file.
155637 */
155638 static int statNext(sqlite3_vtab_cursor *pCursor){
155639 int rc;
155640 int nPayload;
155641 char *z;
155642 StatCursor *pCsr = (StatCursor *)pCursor;
155643 StatTable *pTab = (StatTable *)pCursor->pVtab;
155644 Btree *pBt = pTab->db->aDb[pTab->iDb].pBt;
155645 Pager *pPager = sqlite3BtreePager(pBt);
155646
155647 sqlite3_free(pCsr->zPath);
155648 pCsr->zPath = 0;
155649
155650 statNextRestart:
155651 if( pCsr->aPage[0].pPg==0 ){
155652 rc = sqlite3_step(pCsr->pStmt);
155653 if( rc==SQLITE_ROW ){
155654 int nPage;
155655 u32 iRoot = (u32)sqlite3_column_int64(pCsr->pStmt, 1);
155656 sqlite3PagerPagecount(pPager, &nPage);
155657 if( nPage==0 ){
155658 pCsr->isEof = 1;
155659 return sqlite3_reset(pCsr->pStmt);
155660 }
155661 rc = sqlite3PagerGet(pPager, iRoot, &pCsr->aPage[0].pPg);
155662 pCsr->aPage[0].iPgno = iRoot;
155663 pCsr->aPage[0].iCell = 0;
155664 pCsr->aPage[0].zPath = z = sqlite3_mprintf("/");
155665 pCsr->iPage = 0;
155666 if( z==0 ) rc = SQLITE_NOMEM;
155667 }else{
155668 pCsr->isEof = 1;
155669 return sqlite3_reset(pCsr->pStmt);
155670 }
155671 }else{
155672
155673 /* Page p itself has already been visited. */
155674 StatPage *p = &pCsr->aPage[pCsr->iPage];
155675
155676 while( p->iCell<p->nCell ){
155677 StatCell *pCell = &p->aCell[p->iCell];
155678 if( pCell->iOvfl<pCell->nOvfl ){
155679 int nUsable;
155680 sqlite3BtreeEnter(pBt);
155681 nUsable = sqlite3BtreeGetPageSize(pBt) -
155682 sqlite3BtreeGetReserveNoMutex(pBt);
155683 sqlite3BtreeLeave(pBt);
155684 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
155685 pCsr->iPageno = pCell->aOvfl[pCell->iOvfl];
155686 pCsr->zPagetype = "overflow";
155687 pCsr->nCell = 0;
155688 pCsr->nMxPayload = 0;
155689 pCsr->zPath = z = sqlite3_mprintf(
155690 "%s%.3x+%.6x", p->zPath, p->iCell, pCell->iOvfl
155691 );
155692 if( pCell->iOvfl<pCell->nOvfl-1 ){
155693 pCsr->nUnused = 0;
155694 pCsr->nPayload = nUsable - 4;
155695 }else{
155696 pCsr->nPayload = pCell->nLastOvfl;
155697 pCsr->nUnused = nUsable - 4 - pCsr->nPayload;
155698 }
155699 pCell->iOvfl++;
155700 statSizeAndOffset(pCsr);
155701 return z==0 ? SQLITE_NOMEM : SQLITE_OK;
155702 }
155703 if( p->iRightChildPg ) break;
155704 p->iCell++;
155705 }
155706
155707 if( !p->iRightChildPg || p->iCell>p->nCell ){
155708 statClearPage(p);
155709 if( pCsr->iPage==0 ) return statNext(pCursor);
155710 pCsr->iPage--;
155711 goto statNextRestart; /* Tail recursion */
155712 }
155713 pCsr->iPage++;
155714 assert( p==&pCsr->aPage[pCsr->iPage-1] );
155715
155716 if( p->iCell==p->nCell ){
155717 p[1].iPgno = p->iRightChildPg;
155718 }else{
155719 p[1].iPgno = p->aCell[p->iCell].iChildPg;
155720 }
155721 rc = sqlite3PagerGet(pPager, p[1].iPgno, &p[1].pPg);
155722 p[1].iCell = 0;
155723 p[1].zPath = z = sqlite3_mprintf("%s%.3x/", p->zPath, p->iCell);
155724 p->iCell++;
155725 if( z==0 ) rc = SQLITE_NOMEM;
155726 }
155727
155728
155729 /* Populate the StatCursor fields with the values to be returned
155730 ** by the xColumn() and xRowid() methods.
155731 */
155732 if( rc==SQLITE_OK ){
155733 int i;
155734 StatPage *p = &pCsr->aPage[pCsr->iPage];
155735 pCsr->zName = (char *)sqlite3_column_text(pCsr->pStmt, 0);
155736 pCsr->iPageno = p->iPgno;
155737
155738 rc = statDecodePage(pBt, p);
155739 if( rc==SQLITE_OK ){
155740 statSizeAndOffset(pCsr);
155741
155742 switch( p->flags ){
155743 case 0x05: /* table internal */
155744 case 0x02: /* index internal */
155745 pCsr->zPagetype = "internal";
155746 break;
155747 case 0x0D: /* table leaf */
155748 case 0x0A: /* index leaf */
155749 pCsr->zPagetype = "leaf";
155750 break;
155751 default:
155752 pCsr->zPagetype = "corrupted";
155753 break;
155754 }
155755 pCsr->nCell = p->nCell;
155756 pCsr->nUnused = p->nUnused;
155757 pCsr->nMxPayload = p->nMxPayload;
155758 pCsr->zPath = z = sqlite3_mprintf("%s", p->zPath);
155759 if( z==0 ) rc = SQLITE_NOMEM;
155760 nPayload = 0;
155761 for(i=0; i<p->nCell; i++){
155762 nPayload += p->aCell[i].nLocal;
155763 }
155764 pCsr->nPayload = nPayload;
155765 }
155766 }
155767
155768 return rc;
155769 }
155770
155771 static int statEof(sqlite3_vtab_cursor *pCursor){
155772 StatCursor *pCsr = (StatCursor *)pCursor;
155773 return pCsr->isEof;
155774 }
155775
155776 static int statFilter(
155777 sqlite3_vtab_cursor *pCursor,
155778 int idxNum, const char *idxStr,
155779 int argc, sqlite3_value **argv
155780 ){
155781 StatCursor *pCsr = (StatCursor *)pCursor;
155782
155783 statResetCsr(pCsr);
155784 return statNext(pCursor);
155785 }
155786
155787 static int statColumn(
155788 sqlite3_vtab_cursor *pCursor,
155789 sqlite3_context *ctx,
155790 int i
155791 ){
155792 StatCursor *pCsr = (StatCursor *)pCursor;
155793 switch( i ){
155794 case 0: /* name */
155795 sqlite3_result_text(ctx, pCsr->zName, -1, SQLITE_TRANSIENT);
155796 break;
155797 case 1: /* path */
155798 sqlite3_result_text(ctx, pCsr->zPath, -1, SQLITE_TRANSIENT);
155799 break;
155800 case 2: /* pageno */
155801 sqlite3_result_int64(ctx, pCsr->iPageno);
155802 break;
155803 case 3: /* pagetype */
155804 sqlite3_result_text(ctx, pCsr->zPagetype, -1, SQLITE_STATIC);
155805 break;
155806 case 4: /* ncell */
155807 sqlite3_result_int(ctx, pCsr->nCell);
155808 break;
155809 case 5: /* payload */
155810 sqlite3_result_int(ctx, pCsr->nPayload);
155811 break;
155812 case 6: /* unused */
155813 sqlite3_result_int(ctx, pCsr->nUnused);
155814 break;
155815 case 7: /* mx_payload */
155816 sqlite3_result_int(ctx, pCsr->nMxPayload);
155817 break;
155818 case 8: /* pgoffset */
155819 sqlite3_result_int64(ctx, pCsr->iOffset);
155820 break;
155821 default: /* pgsize */
155822 assert( i==9 );
155823 sqlite3_result_int(ctx, pCsr->szPage);
155824 break;
155825 }
155826 return SQLITE_OK;
155827 }
155828
155829 static int statRowid(sqlite3_vtab_cursor *pCursor, sqlite_int64 *pRowid){
155830 StatCursor *pCsr = (StatCursor *)pCursor;
155831 *pRowid = pCsr->iPageno;
155832 return SQLITE_OK;
155833 }
155834
155835 /*
155836 ** Invoke this routine to register the "dbstat" virtual table module
155837 */
155838 SQLITE_API int SQLITE_STDCALL sqlite3_dbstat_register(sqlite3 *db){
155839 static sqlite3_module dbstat_module = {
155840 0, /* iVersion */
155841 statConnect, /* xCreate */
155842 statConnect, /* xConnect */
155843 statBestIndex, /* xBestIndex */
155844 statDisconnect, /* xDisconnect */
155845 statDisconnect, /* xDestroy */
155846 statOpen, /* xOpen - open a cursor */
155847 statClose, /* xClose - close a cursor */
155848 statFilter, /* xFilter - configure scan constraints */
155849 statNext, /* xNext - advance a cursor */
155850 statEof, /* xEof - check for end of scan */
155851 statColumn, /* xColumn - read data */
155852 statRowid, /* xRowid - read data */
155853 0, /* xUpdate */
155854 0, /* xBegin */
155855 0, /* xSync */
155856 0, /* xCommit */
155857 0, /* xRollback */
155858 0, /* xFindMethod */
155859 0, /* xRename */
155860 };
155861 return sqlite3_create_module(db, "dbstat", &dbstat_module, 0);
155862 }
155863 #endif /* SQLITE_ENABLE_DBSTAT_VTAB */
155864
155865 /************** End of dbstat.c **********************************************/
155866
+319 -246
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,27 +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
-
56
-
57
-/*
58
-** Add the ability to override 'cdecl'
59
-*/
6054
#ifndef SQLITE_CDECL
6155
# define SQLITE_CDECL
6256
#endif
57
+#ifndef SQLITE_STDCALL
58
+# define SQLITE_STDCALL
59
+#endif
6360
6461
/*
6562
** These no-op macros are used in front of interfaces to mark those
6663
** interfaces as either deprecated or experimental. New applications
6764
** should not use deprecated interfaces - they are supported for backwards
@@ -112,13 +109,13 @@
112109
**
113110
** See also: [sqlite3_libversion()],
114111
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
115112
** [sqlite_version()] and [sqlite_source_id()].
116113
*/
117
-#define SQLITE_VERSION "3.8.9"
118
-#define SQLITE_VERSION_NUMBER 3008009
119
-#define SQLITE_SOURCE_ID "2015-03-24 18:19:39 436314b5728c9413f9ac2d837e1c19364f31be72"
114
+#define SQLITE_VERSION "3.8.10.1"
115
+#define SQLITE_VERSION_NUMBER 3008010
116
+#define SQLITE_SOURCE_ID "2015-05-09 12:14:55 05b4b1f2a937c06c90db70c09890038f6c98ec40"
120117
121118
/*
122119
** CAPI3REF: Run-Time Library Version Numbers
123120
** KEYWORDS: sqlite3_version, sqlite3_sourceid
124121
**
@@ -147,13 +144,13 @@
147144
** [SQLITE_SOURCE_ID] C preprocessor macro.
148145
**
149146
** See also: [sqlite_version()] and [sqlite_source_id()].
150147
*/
151148
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
152
-SQLITE_API const char *sqlite3_libversion(void);
153
-SQLITE_API const char *sqlite3_sourceid(void);
154
-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);
155152
156153
/*
157154
** CAPI3REF: Run-Time Library Compilation Options Diagnostics
158155
**
159156
** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -174,12 +171,12 @@
174171
**
175172
** See also: SQL functions [sqlite_compileoption_used()] and
176173
** [sqlite_compileoption_get()] and the [compile_options pragma].
177174
*/
178175
#ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
179
-SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
180
-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);
181178
#endif
182179
183180
/*
184181
** CAPI3REF: Test To See If The Library Is Threadsafe
185182
**
@@ -214,11 +211,11 @@
214211
** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
215212
** is unchanged by calls to sqlite3_config().)^
216213
**
217214
** See the [threading mode] documentation for additional information.
218215
*/
219
-SQLITE_API int sqlite3_threadsafe(void);
216
+SQLITE_API int SQLITE_STDCALL sqlite3_threadsafe(void);
220217
221218
/*
222219
** CAPI3REF: Database Connection Handle
223220
** KEYWORDS: {database connection} {database connections}
224221
**
@@ -271,10 +268,11 @@
271268
# define double sqlite3_int64
272269
#endif
273270
274271
/*
275272
** CAPI3REF: Closing A Database Connection
273
+** DESTRUCTOR: sqlite3
276274
**
277275
** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
278276
** for the [sqlite3] object.
279277
** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
280278
** the [sqlite3] object is successfully destroyed and all associated
@@ -310,12 +308,12 @@
310308
** from [sqlite3_open()], [sqlite3_open16()], or
311309
** [sqlite3_open_v2()], and not previously closed.
312310
** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
313311
** argument is a harmless no-op.
314312
*/
315
-SQLITE_API int sqlite3_close(sqlite3*);
316
-SQLITE_API int sqlite3_close_v2(sqlite3*);
313
+SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
314
+SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
317315
318316
/*
319317
** The type for a callback function.
320318
** This is legacy and deprecated. It is included for historical
321319
** compatibility and is not documented.
@@ -322,10 +320,11 @@
322320
*/
323321
typedef int (*sqlite3_callback)(void*,int,char**, char**);
324322
325323
/*
326324
** CAPI3REF: One-Step Query Execution Interface
325
+** METHOD: sqlite3
327326
**
328327
** The sqlite3_exec() interface is a convenience wrapper around
329328
** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
330329
** that allows an application to run multiple statements of SQL
331330
** without having to use a lot of C code.
@@ -381,11 +380,11 @@
381380
** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
382381
** <li> The application must not modify the SQL statement text passed into
383382
** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
384383
** </ul>
385384
*/
386
-SQLITE_API int sqlite3_exec(
385
+SQLITE_API int SQLITE_STDCALL sqlite3_exec(
387386
sqlite3*, /* An open database */
388387
const char *sql, /* SQL to be evaluated */
389388
int (*callback)(void*,int,char**,char**), /* Callback function */
390389
void *, /* 1st argument to callback */
391390
char **errmsg /* Error msg written here */
@@ -1341,14 +1340,14 @@
13411340
** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
13421341
** implementation of sqlite3_os_init() or sqlite3_os_end()
13431342
** must return [SQLITE_OK] on success and some other [error code] upon
13441343
** failure.
13451344
*/
1346
-SQLITE_API int sqlite3_initialize(void);
1347
-SQLITE_API int sqlite3_shutdown(void);
1348
-SQLITE_API int sqlite3_os_init(void);
1349
-SQLITE_API int sqlite3_os_end(void);
1345
+SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1346
+SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1347
+SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1348
+SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
13501349
13511350
/*
13521351
** CAPI3REF: Configuring The SQLite Library
13531352
**
13541353
** The sqlite3_config() interface is used to make global configuration
@@ -1375,14 +1374,15 @@
13751374
**
13761375
** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
13771376
** ^If the option is unknown or SQLite is unable to set the option
13781377
** then this routine returns a non-zero [error code].
13791378
*/
1380
-SQLITE_API int sqlite3_config(int, ...);
1379
+SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
13811380
13821381
/*
13831382
** CAPI3REF: Configure database connections
1383
+** METHOD: sqlite3
13841384
**
13851385
** The sqlite3_db_config() interface is used to make configuration
13861386
** changes to a [database connection]. The interface is similar to
13871387
** [sqlite3_config()] except that the changes apply to a single
13881388
** [database connection] (specified in the first argument).
@@ -1393,11 +1393,11 @@
13931393
** Subsequent arguments vary depending on the configuration verb.
13941394
**
13951395
** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
13961396
** the call is considered successful.
13971397
*/
1398
-SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1398
+SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
13991399
14001400
/*
14011401
** CAPI3REF: Memory Allocation Routines
14021402
**
14031403
** An instance of this object defines the interface between SQLite
@@ -1876,19 +1876,21 @@
18761876
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
18771877
18781878
18791879
/*
18801880
** CAPI3REF: Enable Or Disable Extended Result Codes
1881
+** METHOD: sqlite3
18811882
**
18821883
** ^The sqlite3_extended_result_codes() routine enables or disables the
18831884
** [extended result codes] feature of SQLite. ^The extended result
18841885
** codes are disabled by default for historical compatibility.
18851886
*/
1886
-SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1887
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
18871888
18881889
/*
18891890
** CAPI3REF: Last Insert Rowid
1891
+** METHOD: sqlite3
18901892
**
18911893
** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
18921894
** has a unique 64-bit signed
18931895
** integer key called the [ROWID | "rowid"]. ^The rowid is always available
18941896
** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -1932,14 +1934,15 @@
19321934
** function is running and thus changes the last insert [rowid],
19331935
** then the value returned by [sqlite3_last_insert_rowid()] is
19341936
** unpredictable and might not equal either the old or the new
19351937
** last insert [rowid].
19361938
*/
1937
-SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1939
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
19381940
19391941
/*
19401942
** CAPI3REF: Count The Number Of Rows Modified
1943
+** METHOD: sqlite3
19411944
**
19421945
** ^This function returns the number of rows modified, inserted or
19431946
** deleted by the most recently completed INSERT, UPDATE or DELETE
19441947
** statement on the database connection specified by the only parameter.
19451948
** ^Executing any other type of SQL statement does not modify the value
@@ -1984,14 +1987,15 @@
19841987
**
19851988
** If a separate thread makes changes on the same database connection
19861989
** while [sqlite3_changes()] is running then the value returned
19871990
** is unpredictable and not meaningful.
19881991
*/
1989
-SQLITE_API int sqlite3_changes(sqlite3*);
1992
+SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
19901993
19911994
/*
19921995
** CAPI3REF: Total Number Of Rows Modified
1996
+** METHOD: sqlite3
19931997
**
19941998
** ^This function returns the total number of rows inserted, modified or
19951999
** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
19962000
** since the database connection was opened, including those executed as
19972001
** part of trigger programs. ^Executing any other type of SQL statement
@@ -2007,14 +2011,15 @@
20072011
**
20082012
** If a separate thread makes changes on the same database connection
20092013
** while [sqlite3_total_changes()] is running then the value
20102014
** returned is unpredictable and not meaningful.
20112015
*/
2012
-SQLITE_API int sqlite3_total_changes(sqlite3*);
2016
+SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
20132017
20142018
/*
20152019
** CAPI3REF: Interrupt A Long-Running Query
2020
+** METHOD: sqlite3
20162021
**
20172022
** ^This function causes any pending database operation to abort and
20182023
** return at its earliest opportunity. This routine is typically
20192024
** called in response to a user action such as pressing "Cancel"
20202025
** or Ctrl-C where the user wants a long query operation to halt
@@ -2046,11 +2051,11 @@
20462051
** that are started after the sqlite3_interrupt() call returns.
20472052
**
20482053
** If the database connection closes while [sqlite3_interrupt()]
20492054
** is running then bad things will likely happen.
20502055
*/
2051
-SQLITE_API void sqlite3_interrupt(sqlite3*);
2056
+SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
20522057
20532058
/*
20542059
** CAPI3REF: Determine If An SQL Statement Is Complete
20552060
**
20562061
** These routines are useful during command-line input to determine if the
@@ -2081,16 +2086,17 @@
20812086
** UTF-8 string.
20822087
**
20832088
** The input to [sqlite3_complete16()] must be a zero-terminated
20842089
** UTF-16 string in native byte order.
20852090
*/
2086
-SQLITE_API int sqlite3_complete(const char *sql);
2087
-SQLITE_API int sqlite3_complete16(const void *sql);
2091
+SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2092
+SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
20882093
20892094
/*
20902095
** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
20912096
** KEYWORDS: {busy-handler callback} {busy handler}
2097
+** METHOD: sqlite3
20922098
**
20932099
** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
20942100
** that might be invoked with argument P whenever
20952101
** an attempt is made to access a database table associated with
20962102
** [database connection] D when another thread
@@ -2142,14 +2148,15 @@
21422148
** result in undefined behavior.
21432149
**
21442150
** A busy handler must not close the database connection
21452151
** or [prepared statement] that invoked the busy handler.
21462152
*/
2147
-SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2153
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
21482154
21492155
/*
21502156
** CAPI3REF: Set A Busy Timeout
2157
+** METHOD: sqlite3
21512158
**
21522159
** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
21532160
** for a specified amount of time when a table is locked. ^The handler
21542161
** will sleep multiple times until at least "ms" milliseconds of sleeping
21552162
** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2164,14 +2171,15 @@
21642171
** was defined (using [sqlite3_busy_handler()]) prior to calling
21652172
** this routine, that other busy handler is cleared.)^
21662173
**
21672174
** See also: [PRAGMA busy_timeout]
21682175
*/
2169
-SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2176
+SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
21702177
21712178
/*
21722179
** CAPI3REF: Convenience Routines For Running Queries
2180
+** METHOD: sqlite3
21732181
**
21742182
** This is a legacy interface that is preserved for backwards compatibility.
21752183
** Use of this interface is not recommended.
21762184
**
21772185
** Definition: A <b>result table</b> is memory data structure created by the
@@ -2238,19 +2246,19 @@
22382246
** interface defined here. As a consequence, errors that occur in the
22392247
** wrapper layer outside of the internal [sqlite3_exec()] call are not
22402248
** reflected in subsequent calls to [sqlite3_errcode()] or
22412249
** [sqlite3_errmsg()].
22422250
*/
2243
-SQLITE_API int sqlite3_get_table(
2251
+SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
22442252
sqlite3 *db, /* An open database */
22452253
const char *zSql, /* SQL to be evaluated */
22462254
char ***pazResult, /* Results of the query */
22472255
int *pnRow, /* Number of result rows written here */
22482256
int *pnColumn, /* Number of result columns written here */
22492257
char **pzErrmsg /* Error msg written here */
22502258
);
2251
-SQLITE_API void sqlite3_free_table(char **result);
2259
+SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
22522260
22532261
/*
22542262
** CAPI3REF: Formatted String Printing Functions
22552263
**
22562264
** These routines are work-alikes of the "printf()" family of functions
@@ -2352,14 +2360,14 @@
23522360
**
23532361
** ^(The "%z" formatting option works like "%s" but with the
23542362
** addition that after the string has been read and copied into
23552363
** the result, [sqlite3_free()] is called on the input string.)^
23562364
*/
2357
-SQLITE_API char *sqlite3_mprintf(const char*,...);
2358
-SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2359
-SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2360
-SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2365
+SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2366
+SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2367
+SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2368
+SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
23612369
23622370
/*
23632371
** CAPI3REF: Memory Allocation Subsystem
23642372
**
23652373
** The SQLite core uses these three routines for all of its own
@@ -2445,16 +2453,16 @@
24452453
**
24462454
** The application must not read or write any part of
24472455
** a block of memory after it has been released using
24482456
** [sqlite3_free()] or [sqlite3_realloc()].
24492457
*/
2450
-SQLITE_API void *sqlite3_malloc(int);
2451
-SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2452
-SQLITE_API void *sqlite3_realloc(void*, int);
2453
-SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2454
-SQLITE_API void sqlite3_free(void*);
2455
-SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2458
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2459
+SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2460
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2461
+SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2462
+SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2463
+SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
24562464
24572465
/*
24582466
** CAPI3REF: Memory Allocator Statistics
24592467
**
24602468
** SQLite provides these two interfaces for reporting on the status
@@ -2475,12 +2483,12 @@
24752483
** [sqlite3_memory_used()] if and only if the parameter to
24762484
** [sqlite3_memory_highwater()] is true. ^The value returned
24772485
** by [sqlite3_memory_highwater(1)] is the high-water mark
24782486
** prior to the reset.
24792487
*/
2480
-SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2481
-SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2488
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2489
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
24822490
24832491
/*
24842492
** CAPI3REF: Pseudo-Random Number Generator
24852493
**
24862494
** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2499,14 +2507,15 @@
24992507
** ^If the previous call to this routine had an N of 1 or more and a
25002508
** non-NULL P then the pseudo-randomness is generated
25012509
** internally and without recourse to the [sqlite3_vfs] xRandomness
25022510
** method.
25032511
*/
2504
-SQLITE_API void sqlite3_randomness(int N, void *P);
2512
+SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
25052513
25062514
/*
25072515
** CAPI3REF: Compile-Time Authorization Callbacks
2516
+** METHOD: sqlite3
25082517
**
25092518
** ^This routine registers an authorizer callback with a particular
25102519
** [database connection], supplied in the first argument.
25112520
** ^The authorizer callback is invoked as SQL statements are being compiled
25122521
** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2581,11 +2590,11 @@
25812590
** [sqlite3_prepare()] or its variants. Authorization is not
25822591
** performed during statement evaluation in [sqlite3_step()], unless
25832592
** as stated in the previous paragraph, sqlite3_step() invokes
25842593
** sqlite3_prepare_v2() to reprepare a statement after a schema change.
25852594
*/
2586
-SQLITE_API int sqlite3_set_authorizer(
2595
+SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
25872596
sqlite3*,
25882597
int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
25892598
void *pUserData
25902599
);
25912600
@@ -2659,10 +2668,11 @@
26592668
#define SQLITE_COPY 0 /* No longer used */
26602669
#define SQLITE_RECURSIVE 33 /* NULL NULL */
26612670
26622671
/*
26632672
** CAPI3REF: Tracing And Profiling Functions
2673
+** METHOD: sqlite3
26642674
**
26652675
** These routines register callback functions that can be used for
26662676
** tracing and profiling the execution of SQL statements.
26672677
**
26682678
** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2685,16 +2695,17 @@
26852695
** digits in the time are meaningless. Future versions of SQLite
26862696
** might provide greater resolution on the profiler callback. The
26872697
** sqlite3_profile() function is considered experimental and is
26882698
** subject to change in future versions of SQLite.
26892699
*/
2690
-SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2691
-SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2700
+SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2701
+SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
26922702
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
26932703
26942704
/*
26952705
** CAPI3REF: Query Progress Callbacks
2706
+** METHOD: sqlite3
26962707
**
26972708
** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
26982709
** function X to be invoked periodically during long running calls to
26992710
** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
27002711
** database connection D. An example use for this
@@ -2720,14 +2731,15 @@
27202731
** the database connection that invoked the progress handler.
27212732
** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
27222733
** database connections for the meaning of "modify" in this paragraph.
27232734
**
27242735
*/
2725
-SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2736
+SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
27262737
27272738
/*
27282739
** CAPI3REF: Opening A New Database Connection
2740
+** CONSTRUCTOR: sqlite3
27292741
**
27302742
** ^These routines open an SQLite database file as specified by the
27312743
** filename argument. ^The filename argument is interpreted as UTF-8 for
27322744
** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
27332745
** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -2948,19 +2960,19 @@
29482960
** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
29492961
** features that require the use of temporary files may fail.
29502962
**
29512963
** See also: [sqlite3_temp_directory]
29522964
*/
2953
-SQLITE_API int sqlite3_open(
2965
+SQLITE_API int SQLITE_STDCALL sqlite3_open(
29542966
const char *filename, /* Database filename (UTF-8) */
29552967
sqlite3 **ppDb /* OUT: SQLite db handle */
29562968
);
2957
-SQLITE_API int sqlite3_open16(
2969
+SQLITE_API int SQLITE_STDCALL sqlite3_open16(
29582970
const void *filename, /* Database filename (UTF-16) */
29592971
sqlite3 **ppDb /* OUT: SQLite db handle */
29602972
);
2961
-SQLITE_API int sqlite3_open_v2(
2973
+SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
29622974
const char *filename, /* Database filename (UTF-8) */
29632975
sqlite3 **ppDb, /* OUT: SQLite db handle */
29642976
int flags, /* Flags */
29652977
const char *zVfs /* Name of VFS module to use */
29662978
);
@@ -3002,17 +3014,18 @@
30023014
** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
30033015
** is not a database file pathname pointer that SQLite passed into the xOpen
30043016
** VFS method, then the behavior of this routine is undefined and probably
30053017
** undesirable.
30063018
*/
3007
-SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3008
-SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3009
-SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3019
+SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3020
+SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3021
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
30103022
30113023
30123024
/*
30133025
** CAPI3REF: Error Codes And Messages
3026
+** METHOD: sqlite3
30143027
**
30153028
** ^If the most recent sqlite3_* API call associated with
30163029
** [database connection] D failed, then the sqlite3_errcode(D) interface
30173030
** returns the numeric [result code] or [extended result code] for that
30183031
** API call.
@@ -3047,44 +3060,45 @@
30473060
**
30483061
** If an interface fails with SQLITE_MISUSE, that means the interface
30493062
** was invoked incorrectly by the application. In that case, the
30503063
** error code and message may or may not be set.
30513064
*/
3052
-SQLITE_API int sqlite3_errcode(sqlite3 *db);
3053
-SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3054
-SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3055
-SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3056
-SQLITE_API const char *sqlite3_errstr(int);
3065
+SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3066
+SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3067
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3068
+SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3069
+SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
30573070
30583071
/*
3059
-** CAPI3REF: SQL Statement Object
3072
+** CAPI3REF: Prepared Statement Object
30603073
** KEYWORDS: {prepared statement} {prepared statements}
30613074
**
3062
-** An instance of this object represents a single SQL statement.
3063
-** This object is variously known as a "prepared statement" or a
3064
-** "compiled SQL statement" or simply as a "statement".
3075
+** An instance of this object represents a single SQL statement that
3076
+** has been compiled into binary form and is ready to be evaluated.
30653077
**
3066
-** The life of a statement object goes something like this:
3078
+** Think of each SQL statement as a separate computer program. The
3079
+** original SQL text is source code. A prepared statement object
3080
+** is the compiled object code. All SQL must be converted into a
3081
+** prepared statement before it can be run.
3082
+**
3083
+** The life-cycle of a prepared statement object usually goes like this:
30673084
**
30683085
** <ol>
3069
-** <li> Create the object using [sqlite3_prepare_v2()] or a related
3070
-** function.
3071
-** <li> Bind values to [host parameters] using the sqlite3_bind_*()
3086
+** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3087
+** <li> Bind values to [parameters] using the sqlite3_bind_*()
30723088
** interfaces.
30733089
** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3074
-** <li> Reset the statement using [sqlite3_reset()] then go back
3090
+** <li> Reset the prepared statement using [sqlite3_reset()] then go back
30753091
** to step 2. Do this zero or more times.
30763092
** <li> Destroy the object using [sqlite3_finalize()].
30773093
** </ol>
3078
-**
3079
-** Refer to documentation on individual methods above for additional
3080
-** information.
30813094
*/
30823095
typedef struct sqlite3_stmt sqlite3_stmt;
30833096
30843097
/*
30853098
** CAPI3REF: Run-time Limits
3099
+** METHOD: sqlite3
30863100
**
30873101
** ^(This interface allows the size of various constructs to be limited
30883102
** on a connection by connection basis. The first parameter is the
30893103
** [database connection] whose limit is to be set or queried. The
30903104
** second parameter is one of the [limit categories] that define a
@@ -3118,11 +3132,11 @@
31183132
** created by an untrusted script can be contained using the
31193133
** [max_page_count] [PRAGMA].
31203134
**
31213135
** New run-time limit categories may be added in future releases.
31223136
*/
3123
-SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3137
+SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
31243138
31253139
/*
31263140
** CAPI3REF: Run-Time Limit Categories
31273141
** KEYWORDS: {limit category} {*limit categories}
31283142
**
@@ -3192,10 +3206,12 @@
31923206
#define SQLITE_LIMIT_WORKER_THREADS 11
31933207
31943208
/*
31953209
** CAPI3REF: Compiling An SQL Statement
31963210
** KEYWORDS: {SQL statement compiler}
3211
+** METHOD: sqlite3
3212
+** CONSTRUCTOR: sqlite3_stmt
31973213
**
31983214
** To execute an SQL query, it must first be compiled into a byte-code
31993215
** program using one of these routines.
32003216
**
32013217
** The first argument, "db", is a [database connection] obtained from a
@@ -3268,50 +3284,52 @@
32683284
** or [GLOB] operator or if the parameter is compared to an indexed column
32693285
** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
32703286
** </li>
32713287
** </ol>
32723288
*/
3273
-SQLITE_API int sqlite3_prepare(
3289
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
32743290
sqlite3 *db, /* Database handle */
32753291
const char *zSql, /* SQL statement, UTF-8 encoded */
32763292
int nByte, /* Maximum length of zSql in bytes. */
32773293
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32783294
const char **pzTail /* OUT: Pointer to unused portion of zSql */
32793295
);
3280
-SQLITE_API int sqlite3_prepare_v2(
3296
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
32813297
sqlite3 *db, /* Database handle */
32823298
const char *zSql, /* SQL statement, UTF-8 encoded */
32833299
int nByte, /* Maximum length of zSql in bytes. */
32843300
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32853301
const char **pzTail /* OUT: Pointer to unused portion of zSql */
32863302
);
3287
-SQLITE_API int sqlite3_prepare16(
3303
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
32883304
sqlite3 *db, /* Database handle */
32893305
const void *zSql, /* SQL statement, UTF-16 encoded */
32903306
int nByte, /* Maximum length of zSql in bytes. */
32913307
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32923308
const void **pzTail /* OUT: Pointer to unused portion of zSql */
32933309
);
3294
-SQLITE_API int sqlite3_prepare16_v2(
3310
+SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
32953311
sqlite3 *db, /* Database handle */
32963312
const void *zSql, /* SQL statement, UTF-16 encoded */
32973313
int nByte, /* Maximum length of zSql in bytes. */
32983314
sqlite3_stmt **ppStmt, /* OUT: Statement handle */
32993315
const void **pzTail /* OUT: Pointer to unused portion of zSql */
33003316
);
33013317
33023318
/*
33033319
** CAPI3REF: Retrieving Statement SQL
3320
+** METHOD: sqlite3_stmt
33043321
**
33053322
** ^This interface can be used to retrieve a saved copy of the original
33063323
** SQL text used to create a [prepared statement] if that statement was
33073324
** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
33083325
*/
3309
-SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3326
+SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
33103327
33113328
/*
33123329
** CAPI3REF: Determine If An SQL Statement Writes The Database
3330
+** METHOD: sqlite3_stmt
33133331
**
33143332
** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
33153333
** and only if the [prepared statement] X makes no direct changes to
33163334
** the content of the database file.
33173335
**
@@ -3335,14 +3353,15 @@
33353353
** database. ^The [ATTACH] and [DETACH] statements also cause
33363354
** sqlite3_stmt_readonly() to return true since, while those statements
33373355
** change the configuration of a database connection, they do not make
33383356
** changes to the content of the database files on disk.
33393357
*/
3340
-SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3358
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
33413359
33423360
/*
33433361
** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3362
+** METHOD: sqlite3_stmt
33443363
**
33453364
** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
33463365
** [prepared statement] S has been stepped at least once using
33473366
** [sqlite3_step(S)] but has not run to completion and/or has not
33483367
** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3354,11 +3373,11 @@
33543373
** to locate all prepared statements associated with a database
33553374
** connection that are in need of being reset. This can be used,
33563375
** for example, in diagnostic routines to search for prepared
33573376
** statements that are holding a transaction open.
33583377
*/
3359
-SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3378
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
33603379
33613380
/*
33623381
** CAPI3REF: Dynamically Typed Value Object
33633382
** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
33643383
**
@@ -3413,10 +3432,11 @@
34133432
34143433
/*
34153434
** CAPI3REF: Binding Values To Prepared Statements
34163435
** KEYWORDS: {host parameter} {host parameters} {host parameter name}
34173436
** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3437
+** METHOD: sqlite3_stmt
34183438
**
34193439
** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
34203440
** literals may be replaced by a [parameter] that matches one of following
34213441
** templates:
34223442
**
@@ -3515,26 +3535,27 @@
35153535
** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
35163536
**
35173537
** See also: [sqlite3_bind_parameter_count()],
35183538
** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
35193539
*/
3520
-SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3521
-SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3540
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3541
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
35223542
void(*)(void*));
3523
-SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3524
-SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3525
-SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3526
-SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3527
-SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3528
-SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3529
-SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3543
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3544
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3545
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3546
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3547
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3548
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3549
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
35303550
void(*)(void*), unsigned char encoding);
3531
-SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3532
-SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3551
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3552
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
35333553
35343554
/*
35353555
** CAPI3REF: Number Of SQL Parameters
3556
+** METHOD: sqlite3_stmt
35363557
**
35373558
** ^This routine can be used to find the number of [SQL parameters]
35383559
** in a [prepared statement]. SQL parameters are tokens of the
35393560
** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
35403561
** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3547,14 +3568,15 @@
35473568
**
35483569
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35493570
** [sqlite3_bind_parameter_name()], and
35503571
** [sqlite3_bind_parameter_index()].
35513572
*/
3552
-SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3573
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
35533574
35543575
/*
35553576
** CAPI3REF: Name Of A Host Parameter
3577
+** METHOD: sqlite3_stmt
35563578
**
35573579
** ^The sqlite3_bind_parameter_name(P,N) interface returns
35583580
** the name of the N-th [SQL parameter] in the [prepared statement] P.
35593581
** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
35603582
** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3574,14 +3596,15 @@
35743596
**
35753597
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35763598
** [sqlite3_bind_parameter_count()], and
35773599
** [sqlite3_bind_parameter_index()].
35783600
*/
3579
-SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3601
+SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
35803602
35813603
/*
35823604
** CAPI3REF: Index Of A Parameter With A Given Name
3605
+** METHOD: sqlite3_stmt
35833606
**
35843607
** ^Return the index of an SQL parameter given its name. ^The
35853608
** index value returned is suitable for use as the second
35863609
** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
35873610
** is returned if no matching parameter is found. ^The parameter
@@ -3590,34 +3613,37 @@
35903613
**
35913614
** See also: [sqlite3_bind_blob|sqlite3_bind()],
35923615
** [sqlite3_bind_parameter_count()], and
35933616
** [sqlite3_bind_parameter_index()].
35943617
*/
3595
-SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3618
+SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
35963619
35973620
/*
35983621
** CAPI3REF: Reset All Bindings On A Prepared Statement
3622
+** METHOD: sqlite3_stmt
35993623
**
36003624
** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
36013625
** the [sqlite3_bind_blob | bindings] on a [prepared statement].
36023626
** ^Use this routine to reset all host parameters to NULL.
36033627
*/
3604
-SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3628
+SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
36053629
36063630
/*
36073631
** CAPI3REF: Number Of Columns In A Result Set
3632
+** METHOD: sqlite3_stmt
36083633
**
36093634
** ^Return the number of columns in the result set returned by the
36103635
** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
36113636
** statement that does not return data (for example an [UPDATE]).
36123637
**
36133638
** See also: [sqlite3_data_count()]
36143639
*/
3615
-SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3640
+SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
36163641
36173642
/*
36183643
** CAPI3REF: Column Names In A Result Set
3644
+** METHOD: sqlite3_stmt
36193645
**
36203646
** ^These routines return the name assigned to a particular column
36213647
** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
36223648
** interface returns a pointer to a zero-terminated UTF-8 string
36233649
** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3638,15 +3664,16 @@
36383664
** ^The name of a result column is the value of the "AS" clause for
36393665
** that column, if there is an AS clause. If there is no AS clause
36403666
** then the name of the column is unspecified and may change from
36413667
** one release of SQLite to the next.
36423668
*/
3643
-SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3644
-SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3669
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3670
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
36453671
36463672
/*
36473673
** CAPI3REF: Source Of Data In A Query Result
3674
+** METHOD: sqlite3_stmt
36483675
**
36493676
** ^These routines provide a means to determine the database, table, and
36503677
** table column that is the origin of a particular result column in
36513678
** [SELECT] statement.
36523679
** ^The name of the database or table or column can be returned as
@@ -3686,19 +3713,20 @@
36863713
** If two or more threads call one or more
36873714
** [sqlite3_column_database_name | column metadata interfaces]
36883715
** for the same [prepared statement] and result column
36893716
** at the same time then the results are undefined.
36903717
*/
3691
-SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3692
-SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3693
-SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3694
-SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3695
-SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3696
-SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3718
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3719
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3720
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3721
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3722
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3723
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
36973724
36983725
/*
36993726
** CAPI3REF: Declared Datatype Of A Query Result
3727
+** METHOD: sqlite3_stmt
37003728
**
37013729
** ^(The first parameter is a [prepared statement].
37023730
** If this statement is a [SELECT] statement and the Nth column of the
37033731
** returned result set of that [SELECT] is a table column (not an
37043732
** expression or subquery) then the declared type of the table
@@ -3722,15 +3750,16 @@
37223750
** data stored in that column is of the declared type. SQLite is
37233751
** strongly typed, but the typing is dynamic not static. ^Type
37243752
** is associated with individual values, not with the containers
37253753
** used to hold those values.
37263754
*/
3727
-SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3728
-SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3755
+SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3756
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
37293757
37303758
/*
37313759
** CAPI3REF: Evaluate An SQL Statement
3760
+** METHOD: sqlite3_stmt
37323761
**
37333762
** After a [prepared statement] has been prepared using either
37343763
** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
37353764
** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
37363765
** must be called one or more times to evaluate the statement.
@@ -3802,14 +3831,15 @@
38023831
** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
38033832
** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
38043833
** then the more specific [error codes] are returned directly
38053834
** by sqlite3_step(). The use of the "v2" interface is recommended.
38063835
*/
3807
-SQLITE_API int sqlite3_step(sqlite3_stmt*);
3836
+SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
38083837
38093838
/*
38103839
** CAPI3REF: Number of columns in a result set
3840
+** METHOD: sqlite3_stmt
38113841
**
38123842
** ^The sqlite3_data_count(P) interface returns the number of columns in the
38133843
** current row of the result set of [prepared statement] P.
38143844
** ^If prepared statement P does not have results ready to return
38153845
** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -3822,11 +3852,11 @@
38223852
** where it always returns zero since each step of that multi-step
38233853
** pragma returns 0 columns of data.
38243854
**
38253855
** See also: [sqlite3_column_count()]
38263856
*/
3827
-SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3857
+SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
38283858
38293859
/*
38303860
** CAPI3REF: Fundamental Datatypes
38313861
** KEYWORDS: SQLITE_TEXT
38323862
**
@@ -3859,10 +3889,11 @@
38593889
#define SQLITE3_TEXT 3
38603890
38613891
/*
38623892
** CAPI3REF: Result Values From A Query
38633893
** KEYWORDS: {column access functions}
3894
+** METHOD: sqlite3_stmt
38643895
**
38653896
** These routines form the "result set" interface.
38663897
**
38673898
** ^These routines return information about a single column of the current
38683899
** result row of a query. ^In every case the first argument is a pointer
@@ -4018,23 +4049,24 @@
40184049
** of these routines, a default value is returned. The default value
40194050
** is either the integer 0, the floating point number 0.0, or a NULL
40204051
** pointer. Subsequent calls to [sqlite3_errcode()] will return
40214052
** [SQLITE_NOMEM].)^
40224053
*/
4023
-SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4024
-SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4025
-SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4026
-SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4027
-SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4028
-SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4029
-SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4030
-SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4031
-SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4032
-SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4054
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4055
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4056
+SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4057
+SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4058
+SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4059
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4060
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4061
+SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4062
+SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4063
+SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
40334064
40344065
/*
40354066
** CAPI3REF: Destroy A Prepared Statement Object
4067
+** DESTRUCTOR: sqlite3_stmt
40364068
**
40374069
** ^The sqlite3_finalize() function is called to delete a [prepared statement].
40384070
** ^If the most recent evaluation of the statement encountered no errors
40394071
** or if the statement is never been evaluated, then sqlite3_finalize() returns
40404072
** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4054,14 +4086,15 @@
40544086
** resource leaks. It is a grievous error for the application to try to use
40554087
** a prepared statement after it has been finalized. Any use of a prepared
40564088
** statement after it has been finalized can result in undefined and
40574089
** undesirable behavior such as segfaults and heap corruption.
40584090
*/
4059
-SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4091
+SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
40604092
40614093
/*
40624094
** CAPI3REF: Reset A Prepared Statement Object
4095
+** METHOD: sqlite3_stmt
40634096
**
40644097
** The sqlite3_reset() function is called to reset a [prepared statement]
40654098
** object back to its initial state, ready to be re-executed.
40664099
** ^Any SQL statement variables that had values bound to them using
40674100
** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4080,17 +4113,18 @@
40804113
** [sqlite3_reset(S)] returns an appropriate [error code].
40814114
**
40824115
** ^The [sqlite3_reset(S)] interface does not change the values
40834116
** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
40844117
*/
4085
-SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4118
+SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
40864119
40874120
/*
40884121
** CAPI3REF: Create Or Redefine SQL Functions
40894122
** KEYWORDS: {function creation routines}
40904123
** KEYWORDS: {application-defined SQL function}
40914124
** KEYWORDS: {application-defined SQL functions}
4125
+** METHOD: sqlite3
40924126
**
40934127
** ^These functions (collectively known as "function creation routines")
40944128
** are used to add SQL functions or aggregates or to redefine the behavior
40954129
** of existing SQL functions or aggregates. The only differences between
40964130
** these routines are the text encoding expected for
@@ -4179,31 +4213,31 @@
41794213
** ^An application-defined function is permitted to call other
41804214
** SQLite interfaces. However, such calls must not
41814215
** close the database connection nor finalize or reset the prepared
41824216
** statement in which the function is running.
41834217
*/
4184
-SQLITE_API int sqlite3_create_function(
4218
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
41854219
sqlite3 *db,
41864220
const char *zFunctionName,
41874221
int nArg,
41884222
int eTextRep,
41894223
void *pApp,
41904224
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
41914225
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
41924226
void (*xFinal)(sqlite3_context*)
41934227
);
4194
-SQLITE_API int sqlite3_create_function16(
4228
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
41954229
sqlite3 *db,
41964230
const void *zFunctionName,
41974231
int nArg,
41984232
int eTextRep,
41994233
void *pApp,
42004234
void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
42014235
void (*xStep)(sqlite3_context*,int,sqlite3_value**),
42024236
void (*xFinal)(sqlite3_context*)
42034237
);
4204
-SQLITE_API int sqlite3_create_function_v2(
4238
+SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
42054239
sqlite3 *db,
42064240
const char *zFunctionName,
42074241
int nArg,
42084242
int eTextRep,
42094243
void *pApp,
@@ -4245,21 +4279,22 @@
42454279
** to be supported. However, new applications should avoid
42464280
** the use of these functions. To encourage programmers to avoid
42474281
** these functions, we will not explain what they do.
42484282
*/
42494283
#ifndef SQLITE_OMIT_DEPRECATED
4250
-SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4251
-SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4252
-SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4253
-SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4254
-SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4255
-SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4284
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4285
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4286
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4287
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4288
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4289
+SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
42564290
void*,sqlite3_int64);
42574291
#endif
42584292
42594293
/*
42604294
** CAPI3REF: Obtaining SQL Function Parameter Values
4295
+** METHOD: sqlite3_value
42614296
**
42624297
** The C-language implementation of SQL functions and aggregates uses
42634298
** this set of interface routines to access the parameter values on
42644299
** the function or aggregate.
42654300
**
@@ -4299,25 +4334,26 @@
42994334
** or [sqlite3_value_text16()].
43004335
**
43014336
** These routines must be called from the same thread as
43024337
** the SQL function that supplied the [sqlite3_value*] parameters.
43034338
*/
4304
-SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4305
-SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4306
-SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4307
-SQLITE_API double sqlite3_value_double(sqlite3_value*);
4308
-SQLITE_API int sqlite3_value_int(sqlite3_value*);
4309
-SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4310
-SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4311
-SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4312
-SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4313
-SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4314
-SQLITE_API int sqlite3_value_type(sqlite3_value*);
4315
-SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4339
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4340
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4341
+SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4342
+SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4343
+SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4344
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4345
+SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4346
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4347
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4348
+SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4349
+SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4350
+SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
43164351
43174352
/*
43184353
** CAPI3REF: Obtain Aggregate Function Context
4354
+** METHOD: sqlite3_context
43194355
**
43204356
** Implementations of aggregate SQL functions use this
43214357
** routine to allocate memory for storing their state.
43224358
**
43234359
** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4354,14 +4390,15 @@
43544390
** function.
43554391
**
43564392
** This routine must be called from the same thread in which
43574393
** the aggregate SQL function is running.
43584394
*/
4359
-SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4395
+SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
43604396
43614397
/*
43624398
** CAPI3REF: User Data For Functions
4399
+** METHOD: sqlite3_context
43634400
**
43644401
** ^The sqlite3_user_data() interface returns a copy of
43654402
** the pointer that was the pUserData parameter (the 5th parameter)
43664403
** of the [sqlite3_create_function()]
43674404
** and [sqlite3_create_function16()] routines that originally
@@ -4368,25 +4405,27 @@
43684405
** registered the application defined function.
43694406
**
43704407
** This routine must be called from the same thread in which
43714408
** the application-defined function is running.
43724409
*/
4373
-SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4410
+SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
43744411
43754412
/*
43764413
** CAPI3REF: Database Connection For Functions
4414
+** METHOD: sqlite3_context
43774415
**
43784416
** ^The sqlite3_context_db_handle() interface returns a copy of
43794417
** the pointer to the [database connection] (the 1st parameter)
43804418
** of the [sqlite3_create_function()]
43814419
** and [sqlite3_create_function16()] routines that originally
43824420
** registered the application defined function.
43834421
*/
4384
-SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4422
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
43854423
43864424
/*
43874425
** CAPI3REF: Function Auxiliary Data
4426
+** METHOD: sqlite3_context
43884427
**
43894428
** These functions may be used by (non-aggregate) SQL functions to
43904429
** associate metadata with argument values. If the same value is passed to
43914430
** multiple invocations of the same SQL function during query execution, under
43924431
** some circumstances the associated metadata may be preserved. An example
@@ -4431,12 +4470,12 @@
44314470
** values and [parameters] and expressions composed from the same.)^
44324471
**
44334472
** These routines must be called from the same thread in which
44344473
** the SQL function is running.
44354474
*/
4436
-SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4437
-SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4475
+SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4476
+SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
44384477
44394478
44404479
/*
44414480
** CAPI3REF: Constants Defining Special Destructor Behavior
44424481
**
@@ -4455,10 +4494,11 @@
44554494
#define SQLITE_STATIC ((sqlite3_destructor_type)0)
44564495
#define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
44574496
44584497
/*
44594498
** CAPI3REF: Setting The Result Of An SQL Function
4499
+** METHOD: sqlite3_context
44604500
**
44614501
** These routines are used by the xFunc or xFinal callbacks that
44624502
** implement SQL functions and aggregates. See
44634503
** [sqlite3_create_function()] and [sqlite3_create_function16()]
44644504
** for additional information.
@@ -4567,33 +4607,34 @@
45674607
**
45684608
** If these routines are called from within the different thread
45694609
** than the one containing the application-defined function that received
45704610
** the [sqlite3_context] pointer, the results are undefined.
45714611
*/
4572
-SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4573
-SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4612
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4613
+SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
45744614
sqlite3_uint64,void(*)(void*));
4575
-SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4576
-SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4577
-SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4578
-SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4579
-SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4580
-SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4581
-SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4582
-SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4583
-SQLITE_API void sqlite3_result_null(sqlite3_context*);
4584
-SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4585
-SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4615
+SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4616
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4617
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4618
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4619
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4620
+SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4621
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4622
+SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4623
+SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4624
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4625
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
45864626
void(*)(void*), unsigned char encoding);
4587
-SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4588
-SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4589
-SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4590
-SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4591
-SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4627
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4628
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4629
+SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4630
+SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4631
+SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
45924632
45934633
/*
45944634
** CAPI3REF: Define New Collating Sequences
4635
+** METHOD: sqlite3
45954636
**
45964637
** ^These functions add, remove, or modify a [collation] associated
45974638
** with the [database connection] specified as the first argument.
45984639
**
45994640
** ^The name of the collation is a UTF-8 string
@@ -4667,35 +4708,36 @@
46674708
** is unfortunate but cannot be changed without breaking backwards
46684709
** compatibility.
46694710
**
46704711
** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
46714712
*/
4672
-SQLITE_API int sqlite3_create_collation(
4713
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
46734714
sqlite3*,
46744715
const char *zName,
46754716
int eTextRep,
46764717
void *pArg,
46774718
int(*xCompare)(void*,int,const void*,int,const void*)
46784719
);
4679
-SQLITE_API int sqlite3_create_collation_v2(
4720
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
46804721
sqlite3*,
46814722
const char *zName,
46824723
int eTextRep,
46834724
void *pArg,
46844725
int(*xCompare)(void*,int,const void*,int,const void*),
46854726
void(*xDestroy)(void*)
46864727
);
4687
-SQLITE_API int sqlite3_create_collation16(
4728
+SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
46884729
sqlite3*,
46894730
const void *zName,
46904731
int eTextRep,
46914732
void *pArg,
46924733
int(*xCompare)(void*,int,const void*,int,const void*)
46934734
);
46944735
46954736
/*
46964737
** CAPI3REF: Collation Needed Callbacks
4738
+** METHOD: sqlite3
46974739
**
46984740
** ^To avoid having to register all collation sequences before a database
46994741
** can be used, a single callback function may be registered with the
47004742
** [database connection] to be invoked whenever an undefined collation
47014743
** sequence is required.
@@ -4716,16 +4758,16 @@
47164758
**
47174759
** The callback function should register the desired collation using
47184760
** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
47194761
** [sqlite3_create_collation_v2()].
47204762
*/
4721
-SQLITE_API int sqlite3_collation_needed(
4763
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
47224764
sqlite3*,
47234765
void*,
47244766
void(*)(void*,sqlite3*,int eTextRep,const char*)
47254767
);
4726
-SQLITE_API int sqlite3_collation_needed16(
4768
+SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
47274769
sqlite3*,
47284770
void*,
47294771
void(*)(void*,sqlite3*,int eTextRep,const void*)
47304772
);
47314773
@@ -4735,15 +4777,15 @@
47354777
** called right after sqlite3_open().
47364778
**
47374779
** The code to implement this API is not available in the public release
47384780
** of SQLite.
47394781
*/
4740
-SQLITE_API int sqlite3_key(
4782
+SQLITE_API int SQLITE_STDCALL sqlite3_key(
47414783
sqlite3 *db, /* Database to be rekeyed */
47424784
const void *pKey, int nKey /* The key */
47434785
);
4744
-SQLITE_API int sqlite3_key_v2(
4786
+SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
47454787
sqlite3 *db, /* Database to be rekeyed */
47464788
const char *zDbName, /* Name of the database */
47474789
const void *pKey, int nKey /* The key */
47484790
);
47494791
@@ -4753,35 +4795,35 @@
47534795
** database is decrypted.
47544796
**
47554797
** The code to implement this API is not available in the public release
47564798
** of SQLite.
47574799
*/
4758
-SQLITE_API int sqlite3_rekey(
4800
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
47594801
sqlite3 *db, /* Database to be rekeyed */
47604802
const void *pKey, int nKey /* The new key */
47614803
);
4762
-SQLITE_API int sqlite3_rekey_v2(
4804
+SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
47634805
sqlite3 *db, /* Database to be rekeyed */
47644806
const char *zDbName, /* Name of the database */
47654807
const void *pKey, int nKey /* The new key */
47664808
);
47674809
47684810
/*
47694811
** Specify the activation key for a SEE database. Unless
47704812
** activated, none of the SEE routines will work.
47714813
*/
4772
-SQLITE_API void sqlite3_activate_see(
4814
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
47734815
const char *zPassPhrase /* Activation phrase */
47744816
);
47754817
#endif
47764818
47774819
#ifdef SQLITE_ENABLE_CEROD
47784820
/*
47794821
** Specify the activation key for a CEROD database. Unless
47804822
** activated, none of the CEROD routines will work.
47814823
*/
4782
-SQLITE_API void sqlite3_activate_cerod(
4824
+SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
47834825
const char *zPassPhrase /* Activation phrase */
47844826
);
47854827
#endif
47864828
47874829
/*
@@ -4799,11 +4841,11 @@
47994841
** method of the default [sqlite3_vfs] object. If the xSleep() method
48004842
** of the default VFS is not implemented correctly, or not implemented at
48014843
** all, then the behavior of sqlite3_sleep() may deviate from the description
48024844
** in the previous paragraphs.
48034845
*/
4804
-SQLITE_API int sqlite3_sleep(int);
4846
+SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
48054847
48064848
/*
48074849
** CAPI3REF: Name Of The Folder Holding Temporary Files
48084850
**
48094851
** ^(If this global variable is made to point to a string which is
@@ -4899,10 +4941,11 @@
48994941
SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
49004942
49014943
/*
49024944
** CAPI3REF: Test For Auto-Commit Mode
49034945
** KEYWORDS: {autocommit mode}
4946
+** METHOD: sqlite3
49044947
**
49054948
** ^The sqlite3_get_autocommit() interface returns non-zero or
49064949
** zero if the given database connection is or is not in autocommit mode,
49074950
** respectively. ^Autocommit mode is on by default.
49084951
** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -4917,26 +4960,28 @@
49174960
**
49184961
** If another thread changes the autocommit status of the database
49194962
** connection while this routine is running, then the return value
49204963
** is undefined.
49214964
*/
4922
-SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4965
+SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
49234966
49244967
/*
49254968
** CAPI3REF: Find The Database Handle Of A Prepared Statement
4969
+** METHOD: sqlite3_stmt
49264970
**
49274971
** ^The sqlite3_db_handle interface returns the [database connection] handle
49284972
** to which a [prepared statement] belongs. ^The [database connection]
49294973
** returned by sqlite3_db_handle is the same [database connection]
49304974
** that was the first argument
49314975
** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
49324976
** create the statement in the first place.
49334977
*/
4934
-SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4978
+SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
49354979
49364980
/*
49374981
** CAPI3REF: Return The Filename For A Database Connection
4982
+** METHOD: sqlite3
49384983
**
49394984
** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
49404985
** associated with database N of connection D. ^The main database file
49414986
** has the name "main". If there is no attached database N on the database
49424987
** connection D, or if database N is a temporary or in-memory database, then
@@ -4945,23 +4990,25 @@
49454990
** ^The filename returned by this function is the output of the
49464991
** xFullPathname method of the [VFS]. ^In other words, the filename
49474992
** will be an absolute pathname, even if the filename used
49484993
** to open the database originally was a URI or relative pathname.
49494994
*/
4950
-SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4995
+SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
49514996
49524997
/*
49534998
** CAPI3REF: Determine if a database is read-only
4999
+** METHOD: sqlite3
49545000
**
49555001
** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
49565002
** of connection D is read-only, 0 if it is read/write, or -1 if N is not
49575003
** the name of a database on connection D.
49585004
*/
4959
-SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5005
+SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
49605006
49615007
/*
49625008
** CAPI3REF: Find the next prepared statement
5009
+** METHOD: sqlite3
49635010
**
49645011
** ^This interface returns a pointer to the next [prepared statement] after
49655012
** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
49665013
** then this interface returns a pointer to the first prepared statement
49675014
** associated with the database connection pDb. ^If no prepared statement
@@ -4969,14 +5016,15 @@
49695016
**
49705017
** The [database connection] pointer D in a call to
49715018
** [sqlite3_next_stmt(D,S)] must refer to an open database
49725019
** connection and in particular must not be a NULL pointer.
49735020
*/
4974
-SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5021
+SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
49755022
49765023
/*
49775024
** CAPI3REF: Commit And Rollback Notification Callbacks
5025
+** METHOD: sqlite3
49785026
**
49795027
** ^The sqlite3_commit_hook() interface registers a callback
49805028
** function to be invoked whenever a transaction is [COMMIT | committed].
49815029
** ^Any callback set by a previous call to sqlite3_commit_hook()
49825030
** for the same database connection is overridden.
@@ -5017,15 +5065,16 @@
50175065
** ^The rollback callback is not invoked if a transaction is
50185066
** automatically rolled back because the database connection is closed.
50195067
**
50205068
** See also the [sqlite3_update_hook()] interface.
50215069
*/
5022
-SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5023
-SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5070
+SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5071
+SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
50245072
50255073
/*
50265074
** CAPI3REF: Data Change Notification Callbacks
5075
+** METHOD: sqlite3
50275076
**
50285077
** ^The sqlite3_update_hook() interface registers a callback function
50295078
** with the [database connection] identified by the first argument
50305079
** to be invoked whenever a row is updated, inserted or deleted in
50315080
** a rowid table.
@@ -5068,11 +5117,11 @@
50685117
** the first call on D.
50695118
**
50705119
** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
50715120
** interfaces.
50725121
*/
5073
-SQLITE_API void *sqlite3_update_hook(
5122
+SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
50745123
sqlite3*,
50755124
void(*)(void *,int ,char const *,char const *,sqlite3_int64),
50765125
void*
50775126
);
50785127
@@ -5108,11 +5157,11 @@
51085157
** This interface is threadsafe on processors where writing a
51095158
** 32-bit integer is atomic.
51105159
**
51115160
** See Also: [SQLite Shared-Cache Mode]
51125161
*/
5113
-SQLITE_API int sqlite3_enable_shared_cache(int);
5162
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
51145163
51155164
/*
51165165
** CAPI3REF: Attempt To Free Heap Memory
51175166
**
51185167
** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5124,24 +5173,25 @@
51245173
** ^The sqlite3_release_memory() routine is a no-op returning zero
51255174
** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
51265175
**
51275176
** See also: [sqlite3_db_release_memory()]
51285177
*/
5129
-SQLITE_API int sqlite3_release_memory(int);
5178
+SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
51305179
51315180
/*
51325181
** CAPI3REF: Free Memory Used By A Database Connection
5182
+** METHOD: sqlite3
51335183
**
51345184
** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
51355185
** memory as possible from database connection D. Unlike the
51365186
** [sqlite3_release_memory()] interface, this interface is in effect even
51375187
** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
51385188
** omitted.
51395189
**
51405190
** See also: [sqlite3_release_memory()]
51415191
*/
5142
-SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5192
+SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
51435193
51445194
/*
51455195
** CAPI3REF: Impose A Limit On Heap Size
51465196
**
51475197
** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5189,11 +5239,11 @@
51895239
** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
51905240
**
51915241
** The circumstances under which SQLite will enforce the soft heap limit may
51925242
** changes in future releases of SQLite.
51935243
*/
5194
-SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5244
+SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
51955245
51965246
/*
51975247
** CAPI3REF: Deprecated Soft Heap Limit Interface
51985248
** DEPRECATED
51995249
**
@@ -5200,15 +5250,16 @@
52005250
** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
52015251
** interface. This routine is provided for historical compatibility
52025252
** only. All new applications should use the
52035253
** [sqlite3_soft_heap_limit64()] interface rather than this one.
52045254
*/
5205
-SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5255
+SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
52065256
52075257
52085258
/*
52095259
** CAPI3REF: Extract Metadata About A Column Of A Table
5260
+** METHOD: sqlite3
52105261
**
52115262
** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
52125263
** information about column C of table T in database D
52135264
** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
52145265
** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5269,11 +5320,11 @@
52695320
**
52705321
** ^This function causes all database schemas to be read from disk and
52715322
** parsed, if that has not already been done, and returns an error if
52725323
** any errors are encountered while loading the schema.
52735324
*/
5274
-SQLITE_API int sqlite3_table_column_metadata(
5325
+SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
52755326
sqlite3 *db, /* Connection handle */
52765327
const char *zDbName, /* Database name or NULL */
52775328
const char *zTableName, /* Table name */
52785329
const char *zColumnName, /* Column name */
52795330
char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5283,10 +5334,11 @@
52835334
int *pAutoinc /* OUTPUT: True if column is auto-increment */
52845335
);
52855336
52865337
/*
52875338
** CAPI3REF: Load An Extension
5339
+** METHOD: sqlite3
52885340
**
52895341
** ^This interface loads an SQLite extension library from the named file.
52905342
**
52915343
** ^The sqlite3_load_extension() interface attempts to load an
52925344
** [SQLite extension] library contained in the file zFile. If
@@ -5315,19 +5367,20 @@
53155367
** [sqlite3_enable_load_extension()] prior to calling this API,
53165368
** otherwise an error will be returned.
53175369
**
53185370
** See also the [load_extension() SQL function].
53195371
*/
5320
-SQLITE_API int sqlite3_load_extension(
5372
+SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
53215373
sqlite3 *db, /* Load the extension into this database connection */
53225374
const char *zFile, /* Name of the shared library containing extension */
53235375
const char *zProc, /* Entry point. Derived from zFile if 0 */
53245376
char **pzErrMsg /* Put error message here if not 0 */
53255377
);
53265378
53275379
/*
53285380
** CAPI3REF: Enable Or Disable Extension Loading
5381
+** METHOD: sqlite3
53295382
**
53305383
** ^So as not to open security holes in older applications that are
53315384
** unprepared to deal with [extension loading], and as a means of disabling
53325385
** [extension loading] while evaluating user-entered SQL, the following API
53335386
** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5335,11 +5388,11 @@
53355388
** ^Extension loading is off by default.
53365389
** ^Call the sqlite3_enable_load_extension() routine with onoff==1
53375390
** to turn extension loading on and call it with onoff==0 to turn
53385391
** it back off again.
53395392
*/
5340
-SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5393
+SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
53415394
53425395
/*
53435396
** CAPI3REF: Automatically Load Statically Linked Extensions
53445397
**
53455398
** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5373,11 +5426,11 @@
53735426
** will be called more than once for each database connection that is opened.
53745427
**
53755428
** See also: [sqlite3_reset_auto_extension()]
53765429
** and [sqlite3_cancel_auto_extension()]
53775430
*/
5378
-SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5431
+SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
53795432
53805433
/*
53815434
** CAPI3REF: Cancel Automatic Extension Loading
53825435
**
53835436
** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5385,19 +5438,19 @@
53855438
** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
53865439
** routine returns 1 if initialization routine X was successfully
53875440
** unregistered and it returns 0 if X was not on the list of initialization
53885441
** routines.
53895442
*/
5390
-SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5443
+SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
53915444
53925445
/*
53935446
** CAPI3REF: Reset Automatic Extension Loading
53945447
**
53955448
** ^This interface disables all automatic extensions previously
53965449
** registered using [sqlite3_auto_extension()].
53975450
*/
5398
-SQLITE_API void sqlite3_reset_auto_extension(void);
5451
+SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
53995452
54005453
/*
54015454
** The interface to the virtual-table mechanism is currently considered
54025455
** to be experimental. The interface might change in incompatible ways.
54035456
** If this is a problem for you, do not use the interface at this time.
@@ -5573,10 +5626,11 @@
55735626
#define SQLITE_INDEX_CONSTRAINT_GE 32
55745627
#define SQLITE_INDEX_CONSTRAINT_MATCH 64
55755628
55765629
/*
55775630
** CAPI3REF: Register A Virtual Table Implementation
5631
+** METHOD: sqlite3
55785632
**
55795633
** ^These routines are used to register a new [virtual table module] name.
55805634
** ^Module names must be registered before
55815635
** creating a new [virtual table] using the module and before using a
55825636
** preexisting [virtual table] for the module.
@@ -5596,17 +5650,17 @@
55965650
** be invoked if the call to sqlite3_create_module_v2() fails.
55975651
** ^The sqlite3_create_module()
55985652
** interface is equivalent to sqlite3_create_module_v2() with a NULL
55995653
** destructor.
56005654
*/
5601
-SQLITE_API int sqlite3_create_module(
5655
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
56025656
sqlite3 *db, /* SQLite connection to register module with */
56035657
const char *zName, /* Name of the module */
56045658
const sqlite3_module *p, /* Methods for the module */
56055659
void *pClientData /* Client data for xCreate/xConnect */
56065660
);
5607
-SQLITE_API int sqlite3_create_module_v2(
5661
+SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
56085662
sqlite3 *db, /* SQLite connection to register module with */
56095663
const char *zName, /* Name of the module */
56105664
const sqlite3_module *p, /* Methods for the module */
56115665
void *pClientData, /* Client data for xCreate/xConnect */
56125666
void(*xDestroy)(void*) /* Module destructor function */
@@ -5665,14 +5719,15 @@
56655719
** ^The [xCreate] and [xConnect] methods of a
56665720
** [virtual table module] call this interface
56675721
** to declare the format (the names and datatypes of the columns) of
56685722
** the virtual tables they implement.
56695723
*/
5670
-SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5724
+SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
56715725
56725726
/*
56735727
** CAPI3REF: Overload A Function For A Virtual Table
5728
+** METHOD: sqlite3
56745729
**
56755730
** ^(Virtual tables can provide alternative implementations of functions
56765731
** using the [xFindFunction] method of the [virtual table module].
56775732
** But global versions of those functions
56785733
** must exist in order to be overloaded.)^
@@ -5683,11 +5738,11 @@
56835738
** of the new function always causes an exception to be thrown. So
56845739
** the new function is not good for anything by itself. Its only
56855740
** purpose is to be a placeholder function that can be overloaded
56865741
** by a [virtual table].
56875742
*/
5688
-SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5743
+SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
56895744
56905745
/*
56915746
** The interface to the virtual-table mechanism defined above (back up
56925747
** to a comment remarkably similar to this one) is currently considered
56935748
** to be experimental. The interface might change in incompatible ways.
@@ -5711,10 +5766,12 @@
57115766
*/
57125767
typedef struct sqlite3_blob sqlite3_blob;
57135768
57145769
/*
57155770
** CAPI3REF: Open A BLOB For Incremental I/O
5771
+** METHOD: sqlite3
5772
+** CONSTRUCTOR: sqlite3_blob
57165773
**
57175774
** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
57185775
** in row iRow, column zColumn, table zTable in database zDb;
57195776
** in other words, the same BLOB that would be selected by:
57205777
**
@@ -5780,11 +5837,11 @@
57805837
** zero-filled blob to read or write using the incremental-blob interface.
57815838
**
57825839
** To avoid a resource leak, every open [BLOB handle] should eventually
57835840
** be released by a call to [sqlite3_blob_close()].
57845841
*/
5785
-SQLITE_API int sqlite3_blob_open(
5842
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
57865843
sqlite3*,
57875844
const char *zDb,
57885845
const char *zTable,
57895846
const char *zColumn,
57905847
sqlite3_int64 iRow,
@@ -5792,10 +5849,11 @@
57925849
sqlite3_blob **ppBlob
57935850
);
57945851
57955852
/*
57965853
** CAPI3REF: Move a BLOB Handle to a New Row
5854
+** METHOD: sqlite3_blob
57975855
**
57985856
** ^This function is used to move an existing blob handle so that it points
57995857
** to a different row of the same database table. ^The new row is identified
58005858
** by the rowid value passed as the second argument. Only the row can be
58015859
** changed. ^The database, table and column on which the blob handle is open
@@ -5812,14 +5870,15 @@
58125870
** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
58135871
** always returns zero.
58145872
**
58155873
** ^This function sets the database handle error code and message.
58165874
*/
5817
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5875
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
58185876
58195877
/*
58205878
** CAPI3REF: Close A BLOB Handle
5879
+** DESTRUCTOR: sqlite3_blob
58215880
**
58225881
** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
58235882
** unconditionally. Even if this routine returns an error code, the
58245883
** handle is still closed.)^
58255884
**
@@ -5834,14 +5893,15 @@
58345893
** with a null pointer (such as would be returned by a failed call to
58355894
** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
58365895
** is passed a valid open blob handle, the values returned by the
58375896
** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
58385897
*/
5839
-SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5898
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
58405899
58415900
/*
58425901
** CAPI3REF: Return The Size Of An Open BLOB
5902
+** METHOD: sqlite3_blob
58435903
**
58445904
** ^Returns the size in bytes of the BLOB accessible via the
58455905
** successfully opened [BLOB handle] in its only argument. ^The
58465906
** incremental blob I/O routines can only read or overwriting existing
58475907
** blob content; they cannot change the size of a blob.
@@ -5849,14 +5909,15 @@
58495909
** This routine only works on a [BLOB handle] which has been created
58505910
** by a prior successful call to [sqlite3_blob_open()] and which has not
58515911
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
58525912
** to this routine results in undefined and probably undesirable behavior.
58535913
*/
5854
-SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5914
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
58555915
58565916
/*
58575917
** CAPI3REF: Read Data From A BLOB Incrementally
5918
+** METHOD: sqlite3_blob
58585919
**
58595920
** ^(This function is used to read data from an open [BLOB handle] into a
58605921
** caller-supplied buffer. N bytes of data are copied into buffer Z
58615922
** from the open BLOB, starting at offset iOffset.)^
58625923
**
@@ -5877,14 +5938,15 @@
58775938
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
58785939
** to this routine results in undefined and probably undesirable behavior.
58795940
**
58805941
** See also: [sqlite3_blob_write()].
58815942
*/
5882
-SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5943
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
58835944
58845945
/*
58855946
** CAPI3REF: Write Data Into A BLOB Incrementally
5947
+** METHOD: sqlite3_blob
58865948
**
58875949
** ^(This function is used to write data into an open [BLOB handle] from a
58885950
** caller-supplied buffer. N bytes of data are copied from the buffer Z
58895951
** into the open BLOB, starting at offset iOffset.)^
58905952
**
@@ -5918,11 +5980,11 @@
59185980
** been closed by [sqlite3_blob_close()]. Passing any other pointer in
59195981
** to this routine results in undefined and probably undesirable behavior.
59205982
**
59215983
** See also: [sqlite3_blob_read()].
59225984
*/
5923
-SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5985
+SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
59245986
59255987
/*
59265988
** CAPI3REF: Virtual File System Objects
59275989
**
59285990
** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5949,13 +6011,13 @@
59496011
**
59506012
** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
59516013
** ^(If the default VFS is unregistered, another VFS is chosen as
59526014
** the default. The choice for the new VFS is arbitrary.)^
59536015
*/
5954
-SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5955
-SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5956
-SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
6016
+SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6017
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6018
+SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
59576019
59586020
/*
59596021
** CAPI3REF: Mutexes
59606022
**
59616023
** The SQLite core uses these routines for thread
@@ -6064,15 +6126,15 @@
60646126
** sqlite3_mutex_leave() is a NULL pointer, then all three routines
60656127
** behave as no-ops.
60666128
**
60676129
** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
60686130
*/
6069
-SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6070
-SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6071
-SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6072
-SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6073
-SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6131
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6132
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6133
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6134
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6135
+SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
60746136
60756137
/*
60766138
** CAPI3REF: Mutex Methods Object
60776139
**
60786140
** An instance of this structure defines the low-level routines
@@ -6178,12 +6240,12 @@
61786240
** call to sqlite3_mutex_held() to fail, so a non-zero return is
61796241
** the appropriate thing to do. The sqlite3_mutex_notheld()
61806242
** interface should also return 1 when given a NULL pointer.
61816243
*/
61826244
#ifndef NDEBUG
6183
-SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6184
-SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6245
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6246
+SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
61856247
#endif
61866248
61876249
/*
61886250
** CAPI3REF: Mutex Types
61896251
**
@@ -6208,21 +6270,23 @@
62086270
#define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
62096271
#define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
62106272
62116273
/*
62126274
** CAPI3REF: Retrieve the mutex for a database connection
6275
+** METHOD: sqlite3
62136276
**
62146277
** ^This interface returns a pointer the [sqlite3_mutex] object that
62156278
** serializes access to the [database connection] given in the argument
62166279
** when the [threading mode] is Serialized.
62176280
** ^If the [threading mode] is Single-thread or Multi-thread then this
62186281
** routine returns a NULL pointer.
62196282
*/
6220
-SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6283
+SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
62216284
62226285
/*
62236286
** CAPI3REF: Low-Level Control Of Database Files
6287
+** METHOD: sqlite3
62246288
**
62256289
** ^The [sqlite3_file_control()] interface makes a direct call to the
62266290
** xFileControl method for the [sqlite3_io_methods] object associated
62276291
** with a particular database identified by the second argument. ^The
62286292
** name of the database is "main" for the main database or "temp" for the
@@ -6249,11 +6313,11 @@
62496313
** an incorrect zDbName and an SQLITE_ERROR return from the underlying
62506314
** xFileControl method.
62516315
**
62526316
** See also: [SQLITE_FCNTL_LOCKSTATE]
62536317
*/
6254
-SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6318
+SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
62556319
62566320
/*
62576321
** CAPI3REF: Testing Interface
62586322
**
62596323
** ^The sqlite3_test_control() interface is used to read out internal
@@ -6268,11 +6332,11 @@
62686332
** The details of the operation codes, their meanings, the parameters
62696333
** they take, and what they do are all subject to change without notice.
62706334
** Unlike most of the SQLite API, this function is not guaranteed to
62716335
** operate consistently from one release to the next.
62726336
*/
6273
-SQLITE_API int sqlite3_test_control(int op, ...);
6337
+SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
62746338
62756339
/*
62766340
** CAPI3REF: Testing Interface Operation Codes
62776341
**
62786342
** These constants are the valid operation code parameters used
@@ -6331,12 +6395,12 @@
63316395
** be represented by a 32-bit integer, then the values returned by
63326396
** sqlite3_status() are undefined.
63336397
**
63346398
** See also: [sqlite3_db_status()]
63356399
*/
6336
-SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6337
-SQLITE_API int sqlite3_status64(
6400
+SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6401
+SQLITE_API int SQLITE_STDCALL sqlite3_status64(
63386402
int op,
63396403
sqlite3_int64 *pCurrent,
63406404
sqlite3_int64 *pHighwater,
63416405
int resetFlag
63426406
);
@@ -6435,10 +6499,11 @@
64356499
#define SQLITE_STATUS_SCRATCH_SIZE 8
64366500
#define SQLITE_STATUS_MALLOC_COUNT 9
64376501
64386502
/*
64396503
** CAPI3REF: Database Connection Status
6504
+** METHOD: sqlite3
64406505
**
64416506
** ^This interface is used to retrieve runtime status information
64426507
** about a single [database connection]. ^The first argument is the
64436508
** database connection object to be interrogated. ^The second argument
64446509
** is an integer constant, taken from the set of
@@ -6455,11 +6520,11 @@
64556520
** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
64566521
** non-zero [error code] on failure.
64576522
**
64586523
** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
64596524
*/
6460
-SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6525
+SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
64616526
64626527
/*
64636528
** CAPI3REF: Status Parameters for database connections
64646529
** KEYWORDS: {SQLITE_DBSTATUS options}
64656530
**
@@ -6563,10 +6628,11 @@
65636628
#define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
65646629
65656630
65666631
/*
65676632
** CAPI3REF: Prepared Statement Status
6633
+** METHOD: sqlite3_stmt
65686634
**
65696635
** ^(Each prepared statement maintains various
65706636
** [SQLITE_STMTSTATUS counters] that measure the number
65716637
** of times it has performed specific operations.)^ These counters can
65726638
** be used to monitor the performance characteristics of the prepared
@@ -6584,11 +6650,11 @@
65846650
** ^If the resetFlg is true, then the counter is reset to zero after this
65856651
** interface call returns.
65866652
**
65876653
** See also: [sqlite3_status()] and [sqlite3_db_status()].
65886654
*/
6589
-SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6655
+SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
65906656
65916657
/*
65926658
** CAPI3REF: Status Parameters for prepared statements
65936659
** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
65946660
**
@@ -7053,23 +7119,24 @@
70537119
** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
70547120
** APIs are not strictly speaking threadsafe. If they are invoked at the
70557121
** same time as another thread is invoking sqlite3_backup_step() it is
70567122
** possible that they return invalid values.
70577123
*/
7058
-SQLITE_API sqlite3_backup *sqlite3_backup_init(
7124
+SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
70597125
sqlite3 *pDest, /* Destination database handle */
70607126
const char *zDestName, /* Destination database name */
70617127
sqlite3 *pSource, /* Source database handle */
70627128
const char *zSourceName /* Source database name */
70637129
);
7064
-SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7065
-SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7066
-SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7067
-SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7130
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7131
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7132
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7133
+SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
70687134
70697135
/*
70707136
** CAPI3REF: Unlock Notification
7137
+** METHOD: sqlite3
70717138
**
70727139
** ^When running in shared-cache mode, a database operation may fail with
70737140
** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
70747141
** individual tables within the shared-cache cannot be obtained. See
70757142
** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7178,11 +7245,11 @@
71787245
** by an sqlite3_step() call. ^(If there is a blocking connection, then the
71797246
** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
71807247
** the special "DROP TABLE/INDEX" case, the extended error code is just
71817248
** SQLITE_LOCKED.)^
71827249
*/
7183
-SQLITE_API int sqlite3_unlock_notify(
7250
+SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
71847251
sqlite3 *pBlocked, /* Waiting connection */
71857252
void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
71867253
void *pNotifyArg /* Argument to pass to xNotify */
71877254
);
71887255
@@ -7193,12 +7260,12 @@
71937260
** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
71947261
** and extensions to compare the contents of two buffers containing UTF-8
71957262
** strings in a case-independent fashion, using the same definition of "case
71967263
** independence" that SQLite uses internally when comparing identifiers.
71977264
*/
7198
-SQLITE_API int sqlite3_stricmp(const char *, const char *);
7199
-SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7265
+SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7266
+SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
72007267
72017268
/*
72027269
** CAPI3REF: String Globbing
72037270
*
72047271
** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7209,11 +7276,11 @@
72097276
** sensitive.
72107277
**
72117278
** Note that this routine returns zero on a match and non-zero if the strings
72127279
** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
72137280
*/
7214
-SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7281
+SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
72157282
72167283
/*
72177284
** CAPI3REF: Error Logging Interface
72187285
**
72197286
** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7232,14 +7299,15 @@
72327299
** will not use dynamically allocated memory. The log message is stored in
72337300
** a fixed-length buffer on the stack. If the log message is longer than
72347301
** a few hundred characters, it will be truncated to the length of the
72357302
** buffer.
72367303
*/
7237
-SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7304
+SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
72387305
72397306
/*
72407307
** CAPI3REF: Write-Ahead Log Commit Hook
7308
+** METHOD: sqlite3
72417309
**
72427310
** ^The [sqlite3_wal_hook()] function is used to register a callback that
72437311
** is invoked each time data is committed to a database in wal mode.
72447312
**
72457313
** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7267,18 +7335,19 @@
72677335
** previously registered write-ahead log callback. ^Note that the
72687336
** [sqlite3_wal_autocheckpoint()] interface and the
72697337
** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
72707338
** those overwrite any prior [sqlite3_wal_hook()] settings.
72717339
*/
7272
-SQLITE_API void *sqlite3_wal_hook(
7340
+SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
72737341
sqlite3*,
72747342
int(*)(void *,sqlite3*,const char*,int),
72757343
void*
72767344
);
72777345
72787346
/*
72797347
** CAPI3REF: Configure an auto-checkpoint
7348
+** METHOD: sqlite3
72807349
**
72817350
** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
72827351
** [sqlite3_wal_hook()] that causes any database on [database connection] D
72837352
** to automatically [checkpoint]
72847353
** after committing a transaction if there are N or
@@ -7301,14 +7370,15 @@
73017370
** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
73027371
** pages. The use of this interface
73037372
** is only necessary if the default setting is found to be suboptimal
73047373
** for a particular application.
73057374
*/
7306
-SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7375
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
73077376
73087377
/*
73097378
** CAPI3REF: Checkpoint a database
7379
+** METHOD: sqlite3
73107380
**
73117381
** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
73127382
** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
73137383
**
73147384
** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7322,14 +7392,15 @@
73227392
** interface was added. This interface is retained for backwards
73237393
** compatibility and as a convenience for applications that need to manually
73247394
** start a callback but which do not need the full power (and corresponding
73257395
** complication) of [sqlite3_wal_checkpoint_v2()].
73267396
*/
7327
-SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7397
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
73287398
73297399
/*
73307400
** CAPI3REF: Checkpoint a database
7401
+** METHOD: sqlite3
73317402
**
73327403
** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
73337404
** operation on database X of [database connection] D in mode M. Status
73347405
** information is written back into integers pointed to by L and C.)^
73357406
** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7415,11 +7486,11 @@
74157486
** [sqlite3_errcode()] and [sqlite3_errmsg()].
74167487
**
74177488
** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
74187489
** from SQL.
74197490
*/
7420
-SQLITE_API int sqlite3_wal_checkpoint_v2(
7491
+SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
74217492
sqlite3 *db, /* Database handle */
74227493
const char *zDb, /* Name of attached database (or NULL) */
74237494
int eMode, /* SQLITE_CHECKPOINT_* value */
74247495
int *pnLog, /* OUT: Size of WAL log in frames */
74257496
int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7451,11 +7522,11 @@
74517522
**
74527523
** At present, there is only one option that may be configured using
74537524
** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
74547525
** may be added in the future.
74557526
*/
7456
-SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7527
+SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
74577528
74587529
/*
74597530
** CAPI3REF: Virtual Table Configuration Options
74607531
**
74617532
** These macros define the various options to the
@@ -7504,11 +7575,11 @@
75047575
** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
75057576
** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
75067577
** of the SQL statement that triggered the call to the [xUpdate] method of the
75077578
** [virtual table].
75087579
*/
7509
-SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7580
+SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
75107581
75117582
/*
75127583
** CAPI3REF: Conflict resolution modes
75137584
** KEYWORDS: {conflict resolution mode}
75147585
**
@@ -7580,10 +7651,11 @@
75807651
#define SQLITE_SCANSTAT_EXPLAIN 4
75817652
#define SQLITE_SCANSTAT_SELECTID 5
75827653
75837654
/*
75847655
** CAPI3REF: Prepared Statement Scan Status
7656
+** METHOD: sqlite3_stmt
75857657
**
75867658
** This interface returns information about the predicted and measured
75877659
** performance for pStmt. Advanced applications can use this
75887660
** interface to compare the predicted and the measured performance and
75897661
** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7608,26 +7680,27 @@
76087680
** as if the loop did not exist - it returns non-zero and leave the variable
76097681
** that pOut points to unchanged.
76107682
**
76117683
** See also: [sqlite3_stmt_scanstatus_reset()]
76127684
*/
7613
-SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7685
+SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
76147686
sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
76157687
int idx, /* Index of loop to report on */
76167688
int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
76177689
void *pOut /* Result written here */
76187690
);
76197691
76207692
/*
76217693
** CAPI3REF: Zero Scan-Status Counters
7694
+** METHOD: sqlite3_stmt
76227695
**
76237696
** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
76247697
**
76257698
** This API is only available if the library is built with pre-processor
76267699
** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
76277700
*/
7628
-SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7701
+SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
76297702
76307703
76317704
/*
76327705
** Undo the hack that converts floating point types to integer for
76337706
** builds on processors without floating point support.
@@ -7678,11 +7751,11 @@
76787751
** Register a geometry callback named zGeom that can be used as part of an
76797752
** R-Tree geometry query as follows:
76807753
**
76817754
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
76827755
*/
7683
-SQLITE_API int sqlite3_rtree_geometry_callback(
7756
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
76847757
sqlite3 *db,
76857758
const char *zGeom,
76867759
int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
76877760
void *pContext
76887761
);
@@ -7704,11 +7777,11 @@
77047777
** Register a 2nd-generation geometry callback named zScore that can be
77057778
** used as part of an R-Tree geometry query as follows:
77067779
**
77077780
** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
77087781
*/
7709
-SQLITE_API int sqlite3_rtree_query_callback(
7782
+SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
77107783
sqlite3 *db,
77117784
const char *zQueryFunc,
77127785
int (*xQueryFunc)(sqlite3_rtree_query_info*),
77137786
void *pContext,
77147787
void (*xDestructor)(void*)
77157788
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,27 +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 ** Add the ability to override 'cdecl'
59 */
60 #ifndef SQLITE_CDECL
61 # define SQLITE_CDECL
62 #endif
 
 
 
63
64 /*
65 ** These no-op macros are used in front of interfaces to mark those
66 ** interfaces as either deprecated or experimental. New applications
67 ** should not use deprecated interfaces - they are supported for backwards
@@ -112,13 +109,13 @@
112 **
113 ** See also: [sqlite3_libversion()],
114 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
115 ** [sqlite_version()] and [sqlite_source_id()].
116 */
117 #define SQLITE_VERSION "3.8.9"
118 #define SQLITE_VERSION_NUMBER 3008009
119 #define SQLITE_SOURCE_ID "2015-03-24 18:19:39 436314b5728c9413f9ac2d837e1c19364f31be72"
120
121 /*
122 ** CAPI3REF: Run-Time Library Version Numbers
123 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
124 **
@@ -147,13 +144,13 @@
147 ** [SQLITE_SOURCE_ID] C preprocessor macro.
148 **
149 ** See also: [sqlite_version()] and [sqlite_source_id()].
150 */
151 SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
152 SQLITE_API const char *sqlite3_libversion(void);
153 SQLITE_API const char *sqlite3_sourceid(void);
154 SQLITE_API int sqlite3_libversion_number(void);
155
156 /*
157 ** CAPI3REF: Run-Time Library Compilation Options Diagnostics
158 **
159 ** ^The sqlite3_compileoption_used() function returns 0 or 1
@@ -174,12 +171,12 @@
174 **
175 ** See also: SQL functions [sqlite_compileoption_used()] and
176 ** [sqlite_compileoption_get()] and the [compile_options pragma].
177 */
178 #ifndef SQLITE_OMIT_COMPILEOPTION_DIAGS
179 SQLITE_API int sqlite3_compileoption_used(const char *zOptName);
180 SQLITE_API const char *sqlite3_compileoption_get(int N);
181 #endif
182
183 /*
184 ** CAPI3REF: Test To See If The Library Is Threadsafe
185 **
@@ -214,11 +211,11 @@
214 ** sqlite3_config(). In other words, the return value from sqlite3_threadsafe()
215 ** is unchanged by calls to sqlite3_config().)^
216 **
217 ** See the [threading mode] documentation for additional information.
218 */
219 SQLITE_API int sqlite3_threadsafe(void);
220
221 /*
222 ** CAPI3REF: Database Connection Handle
223 ** KEYWORDS: {database connection} {database connections}
224 **
@@ -271,10 +268,11 @@
271 # define double sqlite3_int64
272 #endif
273
274 /*
275 ** CAPI3REF: Closing A Database Connection
 
276 **
277 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
278 ** for the [sqlite3] object.
279 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
280 ** the [sqlite3] object is successfully destroyed and all associated
@@ -310,12 +308,12 @@
310 ** from [sqlite3_open()], [sqlite3_open16()], or
311 ** [sqlite3_open_v2()], and not previously closed.
312 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
313 ** argument is a harmless no-op.
314 */
315 SQLITE_API int sqlite3_close(sqlite3*);
316 SQLITE_API int sqlite3_close_v2(sqlite3*);
317
318 /*
319 ** The type for a callback function.
320 ** This is legacy and deprecated. It is included for historical
321 ** compatibility and is not documented.
@@ -322,10 +320,11 @@
322 */
323 typedef int (*sqlite3_callback)(void*,int,char**, char**);
324
325 /*
326 ** CAPI3REF: One-Step Query Execution Interface
 
327 **
328 ** The sqlite3_exec() interface is a convenience wrapper around
329 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
330 ** that allows an application to run multiple statements of SQL
331 ** without having to use a lot of C code.
@@ -381,11 +380,11 @@
381 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
382 ** <li> The application must not modify the SQL statement text passed into
383 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
384 ** </ul>
385 */
386 SQLITE_API int sqlite3_exec(
387 sqlite3*, /* An open database */
388 const char *sql, /* SQL to be evaluated */
389 int (*callback)(void*,int,char**,char**), /* Callback function */
390 void *, /* 1st argument to callback */
391 char **errmsg /* Error msg written here */
@@ -1341,14 +1340,14 @@
1341 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1342 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1343 ** must return [SQLITE_OK] on success and some other [error code] upon
1344 ** failure.
1345 */
1346 SQLITE_API int sqlite3_initialize(void);
1347 SQLITE_API int sqlite3_shutdown(void);
1348 SQLITE_API int sqlite3_os_init(void);
1349 SQLITE_API int sqlite3_os_end(void);
1350
1351 /*
1352 ** CAPI3REF: Configuring The SQLite Library
1353 **
1354 ** The sqlite3_config() interface is used to make global configuration
@@ -1375,14 +1374,15 @@
1375 **
1376 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1377 ** ^If the option is unknown or SQLite is unable to set the option
1378 ** then this routine returns a non-zero [error code].
1379 */
1380 SQLITE_API int sqlite3_config(int, ...);
1381
1382 /*
1383 ** CAPI3REF: Configure database connections
 
1384 **
1385 ** The sqlite3_db_config() interface is used to make configuration
1386 ** changes to a [database connection]. The interface is similar to
1387 ** [sqlite3_config()] except that the changes apply to a single
1388 ** [database connection] (specified in the first argument).
@@ -1393,11 +1393,11 @@
1393 ** Subsequent arguments vary depending on the configuration verb.
1394 **
1395 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1396 ** the call is considered successful.
1397 */
1398 SQLITE_API int sqlite3_db_config(sqlite3*, int op, ...);
1399
1400 /*
1401 ** CAPI3REF: Memory Allocation Routines
1402 **
1403 ** An instance of this object defines the interface between SQLite
@@ -1876,19 +1876,21 @@
1876 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
1877
1878
1879 /*
1880 ** CAPI3REF: Enable Or Disable Extended Result Codes
 
1881 **
1882 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1883 ** [extended result codes] feature of SQLite. ^The extended result
1884 ** codes are disabled by default for historical compatibility.
1885 */
1886 SQLITE_API int sqlite3_extended_result_codes(sqlite3*, int onoff);
1887
1888 /*
1889 ** CAPI3REF: Last Insert Rowid
 
1890 **
1891 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
1892 ** has a unique 64-bit signed
1893 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1894 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -1932,14 +1934,15 @@
1932 ** function is running and thus changes the last insert [rowid],
1933 ** then the value returned by [sqlite3_last_insert_rowid()] is
1934 ** unpredictable and might not equal either the old or the new
1935 ** last insert [rowid].
1936 */
1937 SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3*);
1938
1939 /*
1940 ** CAPI3REF: Count The Number Of Rows Modified
 
1941 **
1942 ** ^This function returns the number of rows modified, inserted or
1943 ** deleted by the most recently completed INSERT, UPDATE or DELETE
1944 ** statement on the database connection specified by the only parameter.
1945 ** ^Executing any other type of SQL statement does not modify the value
@@ -1984,14 +1987,15 @@
1984 **
1985 ** If a separate thread makes changes on the same database connection
1986 ** while [sqlite3_changes()] is running then the value returned
1987 ** is unpredictable and not meaningful.
1988 */
1989 SQLITE_API int sqlite3_changes(sqlite3*);
1990
1991 /*
1992 ** CAPI3REF: Total Number Of Rows Modified
 
1993 **
1994 ** ^This function returns the total number of rows inserted, modified or
1995 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
1996 ** since the database connection was opened, including those executed as
1997 ** part of trigger programs. ^Executing any other type of SQL statement
@@ -2007,14 +2011,15 @@
2007 **
2008 ** If a separate thread makes changes on the same database connection
2009 ** while [sqlite3_total_changes()] is running then the value
2010 ** returned is unpredictable and not meaningful.
2011 */
2012 SQLITE_API int sqlite3_total_changes(sqlite3*);
2013
2014 /*
2015 ** CAPI3REF: Interrupt A Long-Running Query
 
2016 **
2017 ** ^This function causes any pending database operation to abort and
2018 ** return at its earliest opportunity. This routine is typically
2019 ** called in response to a user action such as pressing "Cancel"
2020 ** or Ctrl-C where the user wants a long query operation to halt
@@ -2046,11 +2051,11 @@
2046 ** that are started after the sqlite3_interrupt() call returns.
2047 **
2048 ** If the database connection closes while [sqlite3_interrupt()]
2049 ** is running then bad things will likely happen.
2050 */
2051 SQLITE_API void sqlite3_interrupt(sqlite3*);
2052
2053 /*
2054 ** CAPI3REF: Determine If An SQL Statement Is Complete
2055 **
2056 ** These routines are useful during command-line input to determine if the
@@ -2081,16 +2086,17 @@
2081 ** UTF-8 string.
2082 **
2083 ** The input to [sqlite3_complete16()] must be a zero-terminated
2084 ** UTF-16 string in native byte order.
2085 */
2086 SQLITE_API int sqlite3_complete(const char *sql);
2087 SQLITE_API int sqlite3_complete16(const void *sql);
2088
2089 /*
2090 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2091 ** KEYWORDS: {busy-handler callback} {busy handler}
 
2092 **
2093 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
2094 ** that might be invoked with argument P whenever
2095 ** an attempt is made to access a database table associated with
2096 ** [database connection] D when another thread
@@ -2142,14 +2148,15 @@
2142 ** result in undefined behavior.
2143 **
2144 ** A busy handler must not close the database connection
2145 ** or [prepared statement] that invoked the busy handler.
2146 */
2147 SQLITE_API int sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2148
2149 /*
2150 ** CAPI3REF: Set A Busy Timeout
 
2151 **
2152 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2153 ** for a specified amount of time when a table is locked. ^The handler
2154 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2155 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2164,14 +2171,15 @@
2164 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2165 ** this routine, that other busy handler is cleared.)^
2166 **
2167 ** See also: [PRAGMA busy_timeout]
2168 */
2169 SQLITE_API int sqlite3_busy_timeout(sqlite3*, int ms);
2170
2171 /*
2172 ** CAPI3REF: Convenience Routines For Running Queries
 
2173 **
2174 ** This is a legacy interface that is preserved for backwards compatibility.
2175 ** Use of this interface is not recommended.
2176 **
2177 ** Definition: A <b>result table</b> is memory data structure created by the
@@ -2238,19 +2246,19 @@
2238 ** interface defined here. As a consequence, errors that occur in the
2239 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2240 ** reflected in subsequent calls to [sqlite3_errcode()] or
2241 ** [sqlite3_errmsg()].
2242 */
2243 SQLITE_API int sqlite3_get_table(
2244 sqlite3 *db, /* An open database */
2245 const char *zSql, /* SQL to be evaluated */
2246 char ***pazResult, /* Results of the query */
2247 int *pnRow, /* Number of result rows written here */
2248 int *pnColumn, /* Number of result columns written here */
2249 char **pzErrmsg /* Error msg written here */
2250 );
2251 SQLITE_API void sqlite3_free_table(char **result);
2252
2253 /*
2254 ** CAPI3REF: Formatted String Printing Functions
2255 **
2256 ** These routines are work-alikes of the "printf()" family of functions
@@ -2352,14 +2360,14 @@
2352 **
2353 ** ^(The "%z" formatting option works like "%s" but with the
2354 ** addition that after the string has been read and copied into
2355 ** the result, [sqlite3_free()] is called on the input string.)^
2356 */
2357 SQLITE_API char *sqlite3_mprintf(const char*,...);
2358 SQLITE_API char *sqlite3_vmprintf(const char*, va_list);
2359 SQLITE_API char *sqlite3_snprintf(int,char*,const char*, ...);
2360 SQLITE_API char *sqlite3_vsnprintf(int,char*,const char*, va_list);
2361
2362 /*
2363 ** CAPI3REF: Memory Allocation Subsystem
2364 **
2365 ** The SQLite core uses these three routines for all of its own
@@ -2445,16 +2453,16 @@
2445 **
2446 ** The application must not read or write any part of
2447 ** a block of memory after it has been released using
2448 ** [sqlite3_free()] or [sqlite3_realloc()].
2449 */
2450 SQLITE_API void *sqlite3_malloc(int);
2451 SQLITE_API void *sqlite3_malloc64(sqlite3_uint64);
2452 SQLITE_API void *sqlite3_realloc(void*, int);
2453 SQLITE_API void *sqlite3_realloc64(void*, sqlite3_uint64);
2454 SQLITE_API void sqlite3_free(void*);
2455 SQLITE_API sqlite3_uint64 sqlite3_msize(void*);
2456
2457 /*
2458 ** CAPI3REF: Memory Allocator Statistics
2459 **
2460 ** SQLite provides these two interfaces for reporting on the status
@@ -2475,12 +2483,12 @@
2475 ** [sqlite3_memory_used()] if and only if the parameter to
2476 ** [sqlite3_memory_highwater()] is true. ^The value returned
2477 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2478 ** prior to the reset.
2479 */
2480 SQLITE_API sqlite3_int64 sqlite3_memory_used(void);
2481 SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag);
2482
2483 /*
2484 ** CAPI3REF: Pseudo-Random Number Generator
2485 **
2486 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2499,14 +2507,15 @@
2499 ** ^If the previous call to this routine had an N of 1 or more and a
2500 ** non-NULL P then the pseudo-randomness is generated
2501 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2502 ** method.
2503 */
2504 SQLITE_API void sqlite3_randomness(int N, void *P);
2505
2506 /*
2507 ** CAPI3REF: Compile-Time Authorization Callbacks
 
2508 **
2509 ** ^This routine registers an authorizer callback with a particular
2510 ** [database connection], supplied in the first argument.
2511 ** ^The authorizer callback is invoked as SQL statements are being compiled
2512 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2581,11 +2590,11 @@
2581 ** [sqlite3_prepare()] or its variants. Authorization is not
2582 ** performed during statement evaluation in [sqlite3_step()], unless
2583 ** as stated in the previous paragraph, sqlite3_step() invokes
2584 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2585 */
2586 SQLITE_API int sqlite3_set_authorizer(
2587 sqlite3*,
2588 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2589 void *pUserData
2590 );
2591
@@ -2659,10 +2668,11 @@
2659 #define SQLITE_COPY 0 /* No longer used */
2660 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2661
2662 /*
2663 ** CAPI3REF: Tracing And Profiling Functions
 
2664 **
2665 ** These routines register callback functions that can be used for
2666 ** tracing and profiling the execution of SQL statements.
2667 **
2668 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2685,16 +2695,17 @@
2685 ** digits in the time are meaningless. Future versions of SQLite
2686 ** might provide greater resolution on the profiler callback. The
2687 ** sqlite3_profile() function is considered experimental and is
2688 ** subject to change in future versions of SQLite.
2689 */
2690 SQLITE_API void *sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2691 SQLITE_API SQLITE_EXPERIMENTAL void *sqlite3_profile(sqlite3*,
2692 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2693
2694 /*
2695 ** CAPI3REF: Query Progress Callbacks
 
2696 **
2697 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
2698 ** function X to be invoked periodically during long running calls to
2699 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2700 ** database connection D. An example use for this
@@ -2720,14 +2731,15 @@
2720 ** the database connection that invoked the progress handler.
2721 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2722 ** database connections for the meaning of "modify" in this paragraph.
2723 **
2724 */
2725 SQLITE_API void sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2726
2727 /*
2728 ** CAPI3REF: Opening A New Database Connection
 
2729 **
2730 ** ^These routines open an SQLite database file as specified by the
2731 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2732 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2733 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -2948,19 +2960,19 @@
2948 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
2949 ** features that require the use of temporary files may fail.
2950 **
2951 ** See also: [sqlite3_temp_directory]
2952 */
2953 SQLITE_API int sqlite3_open(
2954 const char *filename, /* Database filename (UTF-8) */
2955 sqlite3 **ppDb /* OUT: SQLite db handle */
2956 );
2957 SQLITE_API int sqlite3_open16(
2958 const void *filename, /* Database filename (UTF-16) */
2959 sqlite3 **ppDb /* OUT: SQLite db handle */
2960 );
2961 SQLITE_API int sqlite3_open_v2(
2962 const char *filename, /* Database filename (UTF-8) */
2963 sqlite3 **ppDb, /* OUT: SQLite db handle */
2964 int flags, /* Flags */
2965 const char *zVfs /* Name of VFS module to use */
2966 );
@@ -3002,17 +3014,18 @@
3002 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3003 ** is not a database file pathname pointer that SQLite passed into the xOpen
3004 ** VFS method, then the behavior of this routine is undefined and probably
3005 ** undesirable.
3006 */
3007 SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3008 SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3009 SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3010
3011
3012 /*
3013 ** CAPI3REF: Error Codes And Messages
 
3014 **
3015 ** ^If the most recent sqlite3_* API call associated with
3016 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3017 ** returns the numeric [result code] or [extended result code] for that
3018 ** API call.
@@ -3047,44 +3060,45 @@
3047 **
3048 ** If an interface fails with SQLITE_MISUSE, that means the interface
3049 ** was invoked incorrectly by the application. In that case, the
3050 ** error code and message may or may not be set.
3051 */
3052 SQLITE_API int sqlite3_errcode(sqlite3 *db);
3053 SQLITE_API int sqlite3_extended_errcode(sqlite3 *db);
3054 SQLITE_API const char *sqlite3_errmsg(sqlite3*);
3055 SQLITE_API const void *sqlite3_errmsg16(sqlite3*);
3056 SQLITE_API const char *sqlite3_errstr(int);
3057
3058 /*
3059 ** CAPI3REF: SQL Statement Object
3060 ** KEYWORDS: {prepared statement} {prepared statements}
3061 **
3062 ** An instance of this object represents a single SQL statement.
3063 ** This object is variously known as a "prepared statement" or a
3064 ** "compiled SQL statement" or simply as a "statement".
3065 **
3066 ** The life of a statement object goes something like this:
 
 
 
 
 
3067 **
3068 ** <ol>
3069 ** <li> Create the object using [sqlite3_prepare_v2()] or a related
3070 ** function.
3071 ** <li> Bind values to [host parameters] using the sqlite3_bind_*()
3072 ** interfaces.
3073 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3074 ** <li> Reset the statement using [sqlite3_reset()] then go back
3075 ** to step 2. Do this zero or more times.
3076 ** <li> Destroy the object using [sqlite3_finalize()].
3077 ** </ol>
3078 **
3079 ** Refer to documentation on individual methods above for additional
3080 ** information.
3081 */
3082 typedef struct sqlite3_stmt sqlite3_stmt;
3083
3084 /*
3085 ** CAPI3REF: Run-time Limits
 
3086 **
3087 ** ^(This interface allows the size of various constructs to be limited
3088 ** on a connection by connection basis. The first parameter is the
3089 ** [database connection] whose limit is to be set or queried. The
3090 ** second parameter is one of the [limit categories] that define a
@@ -3118,11 +3132,11 @@
3118 ** created by an untrusted script can be contained using the
3119 ** [max_page_count] [PRAGMA].
3120 **
3121 ** New run-time limit categories may be added in future releases.
3122 */
3123 SQLITE_API int sqlite3_limit(sqlite3*, int id, int newVal);
3124
3125 /*
3126 ** CAPI3REF: Run-Time Limit Categories
3127 ** KEYWORDS: {limit category} {*limit categories}
3128 **
@@ -3192,10 +3206,12 @@
3192 #define SQLITE_LIMIT_WORKER_THREADS 11
3193
3194 /*
3195 ** CAPI3REF: Compiling An SQL Statement
3196 ** KEYWORDS: {SQL statement compiler}
 
 
3197 **
3198 ** To execute an SQL query, it must first be compiled into a byte-code
3199 ** program using one of these routines.
3200 **
3201 ** The first argument, "db", is a [database connection] obtained from a
@@ -3268,50 +3284,52 @@
3268 ** or [GLOB] operator or if the parameter is compared to an indexed column
3269 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3270 ** </li>
3271 ** </ol>
3272 */
3273 SQLITE_API int sqlite3_prepare(
3274 sqlite3 *db, /* Database handle */
3275 const char *zSql, /* SQL statement, UTF-8 encoded */
3276 int nByte, /* Maximum length of zSql in bytes. */
3277 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3278 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3279 );
3280 SQLITE_API int sqlite3_prepare_v2(
3281 sqlite3 *db, /* Database handle */
3282 const char *zSql, /* SQL statement, UTF-8 encoded */
3283 int nByte, /* Maximum length of zSql in bytes. */
3284 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3285 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3286 );
3287 SQLITE_API int sqlite3_prepare16(
3288 sqlite3 *db, /* Database handle */
3289 const void *zSql, /* SQL statement, UTF-16 encoded */
3290 int nByte, /* Maximum length of zSql in bytes. */
3291 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3292 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3293 );
3294 SQLITE_API int sqlite3_prepare16_v2(
3295 sqlite3 *db, /* Database handle */
3296 const void *zSql, /* SQL statement, UTF-16 encoded */
3297 int nByte, /* Maximum length of zSql in bytes. */
3298 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3299 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3300 );
3301
3302 /*
3303 ** CAPI3REF: Retrieving Statement SQL
 
3304 **
3305 ** ^This interface can be used to retrieve a saved copy of the original
3306 ** SQL text used to create a [prepared statement] if that statement was
3307 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3308 */
3309 SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt);
3310
3311 /*
3312 ** CAPI3REF: Determine If An SQL Statement Writes The Database
 
3313 **
3314 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3315 ** and only if the [prepared statement] X makes no direct changes to
3316 ** the content of the database file.
3317 **
@@ -3335,14 +3353,15 @@
3335 ** database. ^The [ATTACH] and [DETACH] statements also cause
3336 ** sqlite3_stmt_readonly() to return true since, while those statements
3337 ** change the configuration of a database connection, they do not make
3338 ** changes to the content of the database files on disk.
3339 */
3340 SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3341
3342 /*
3343 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
 
3344 **
3345 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3346 ** [prepared statement] S has been stepped at least once using
3347 ** [sqlite3_step(S)] but has not run to completion and/or has not
3348 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3354,11 +3373,11 @@
3354 ** to locate all prepared statements associated with a database
3355 ** connection that are in need of being reset. This can be used,
3356 ** for example, in diagnostic routines to search for prepared
3357 ** statements that are holding a transaction open.
3358 */
3359 SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt*);
3360
3361 /*
3362 ** CAPI3REF: Dynamically Typed Value Object
3363 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3364 **
@@ -3413,10 +3432,11 @@
3413
3414 /*
3415 ** CAPI3REF: Binding Values To Prepared Statements
3416 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3417 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
 
3418 **
3419 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3420 ** literals may be replaced by a [parameter] that matches one of following
3421 ** templates:
3422 **
@@ -3515,26 +3535,27 @@
3515 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3516 **
3517 ** See also: [sqlite3_bind_parameter_count()],
3518 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3519 */
3520 SQLITE_API int sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3521 SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3522 void(*)(void*));
3523 SQLITE_API int sqlite3_bind_double(sqlite3_stmt*, int, double);
3524 SQLITE_API int sqlite3_bind_int(sqlite3_stmt*, int, int);
3525 SQLITE_API int sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3526 SQLITE_API int sqlite3_bind_null(sqlite3_stmt*, int);
3527 SQLITE_API int sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3528 SQLITE_API int sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3529 SQLITE_API int sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3530 void(*)(void*), unsigned char encoding);
3531 SQLITE_API int sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3532 SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3533
3534 /*
3535 ** CAPI3REF: Number Of SQL Parameters
 
3536 **
3537 ** ^This routine can be used to find the number of [SQL parameters]
3538 ** in a [prepared statement]. SQL parameters are tokens of the
3539 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3540 ** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3547,14 +3568,15 @@
3547 **
3548 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3549 ** [sqlite3_bind_parameter_name()], and
3550 ** [sqlite3_bind_parameter_index()].
3551 */
3552 SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt*);
3553
3554 /*
3555 ** CAPI3REF: Name Of A Host Parameter
 
3556 **
3557 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3558 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3559 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3560 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3574,14 +3596,15 @@
3574 **
3575 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3576 ** [sqlite3_bind_parameter_count()], and
3577 ** [sqlite3_bind_parameter_index()].
3578 */
3579 SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3580
3581 /*
3582 ** CAPI3REF: Index Of A Parameter With A Given Name
 
3583 **
3584 ** ^Return the index of an SQL parameter given its name. ^The
3585 ** index value returned is suitable for use as the second
3586 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3587 ** is returned if no matching parameter is found. ^The parameter
@@ -3590,34 +3613,37 @@
3590 **
3591 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3592 ** [sqlite3_bind_parameter_count()], and
3593 ** [sqlite3_bind_parameter_index()].
3594 */
3595 SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3596
3597 /*
3598 ** CAPI3REF: Reset All Bindings On A Prepared Statement
 
3599 **
3600 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3601 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3602 ** ^Use this routine to reset all host parameters to NULL.
3603 */
3604 SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt*);
3605
3606 /*
3607 ** CAPI3REF: Number Of Columns In A Result Set
 
3608 **
3609 ** ^Return the number of columns in the result set returned by the
3610 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3611 ** statement that does not return data (for example an [UPDATE]).
3612 **
3613 ** See also: [sqlite3_data_count()]
3614 */
3615 SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt);
3616
3617 /*
3618 ** CAPI3REF: Column Names In A Result Set
 
3619 **
3620 ** ^These routines return the name assigned to a particular column
3621 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3622 ** interface returns a pointer to a zero-terminated UTF-8 string
3623 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3638,15 +3664,16 @@
3638 ** ^The name of a result column is the value of the "AS" clause for
3639 ** that column, if there is an AS clause. If there is no AS clause
3640 ** then the name of the column is unspecified and may change from
3641 ** one release of SQLite to the next.
3642 */
3643 SQLITE_API const char *sqlite3_column_name(sqlite3_stmt*, int N);
3644 SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt*, int N);
3645
3646 /*
3647 ** CAPI3REF: Source Of Data In A Query Result
 
3648 **
3649 ** ^These routines provide a means to determine the database, table, and
3650 ** table column that is the origin of a particular result column in
3651 ** [SELECT] statement.
3652 ** ^The name of the database or table or column can be returned as
@@ -3686,19 +3713,20 @@
3686 ** If two or more threads call one or more
3687 ** [sqlite3_column_database_name | column metadata interfaces]
3688 ** for the same [prepared statement] and result column
3689 ** at the same time then the results are undefined.
3690 */
3691 SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt*,int);
3692 SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt*,int);
3693 SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt*,int);
3694 SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt*,int);
3695 SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt*,int);
3696 SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt*,int);
3697
3698 /*
3699 ** CAPI3REF: Declared Datatype Of A Query Result
 
3700 **
3701 ** ^(The first parameter is a [prepared statement].
3702 ** If this statement is a [SELECT] statement and the Nth column of the
3703 ** returned result set of that [SELECT] is a table column (not an
3704 ** expression or subquery) then the declared type of the table
@@ -3722,15 +3750,16 @@
3722 ** data stored in that column is of the declared type. SQLite is
3723 ** strongly typed, but the typing is dynamic not static. ^Type
3724 ** is associated with individual values, not with the containers
3725 ** used to hold those values.
3726 */
3727 SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt*,int);
3728 SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt*,int);
3729
3730 /*
3731 ** CAPI3REF: Evaluate An SQL Statement
 
3732 **
3733 ** After a [prepared statement] has been prepared using either
3734 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3735 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3736 ** must be called one or more times to evaluate the statement.
@@ -3802,14 +3831,15 @@
3802 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3803 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3804 ** then the more specific [error codes] are returned directly
3805 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3806 */
3807 SQLITE_API int sqlite3_step(sqlite3_stmt*);
3808
3809 /*
3810 ** CAPI3REF: Number of columns in a result set
 
3811 **
3812 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
3813 ** current row of the result set of [prepared statement] P.
3814 ** ^If prepared statement P does not have results ready to return
3815 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -3822,11 +3852,11 @@
3822 ** where it always returns zero since each step of that multi-step
3823 ** pragma returns 0 columns of data.
3824 **
3825 ** See also: [sqlite3_column_count()]
3826 */
3827 SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt);
3828
3829 /*
3830 ** CAPI3REF: Fundamental Datatypes
3831 ** KEYWORDS: SQLITE_TEXT
3832 **
@@ -3859,10 +3889,11 @@
3859 #define SQLITE3_TEXT 3
3860
3861 /*
3862 ** CAPI3REF: Result Values From A Query
3863 ** KEYWORDS: {column access functions}
 
3864 **
3865 ** These routines form the "result set" interface.
3866 **
3867 ** ^These routines return information about a single column of the current
3868 ** result row of a query. ^In every case the first argument is a pointer
@@ -4018,23 +4049,24 @@
4018 ** of these routines, a default value is returned. The default value
4019 ** is either the integer 0, the floating point number 0.0, or a NULL
4020 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4021 ** [SQLITE_NOMEM].)^
4022 */
4023 SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt*, int iCol);
4024 SQLITE_API int sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4025 SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4026 SQLITE_API double sqlite3_column_double(sqlite3_stmt*, int iCol);
4027 SQLITE_API int sqlite3_column_int(sqlite3_stmt*, int iCol);
4028 SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt*, int iCol);
4029 SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt*, int iCol);
4030 SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt*, int iCol);
4031 SQLITE_API int sqlite3_column_type(sqlite3_stmt*, int iCol);
4032 SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt*, int iCol);
4033
4034 /*
4035 ** CAPI3REF: Destroy A Prepared Statement Object
 
4036 **
4037 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4038 ** ^If the most recent evaluation of the statement encountered no errors
4039 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4040 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4054,14 +4086,15 @@
4054 ** resource leaks. It is a grievous error for the application to try to use
4055 ** a prepared statement after it has been finalized. Any use of a prepared
4056 ** statement after it has been finalized can result in undefined and
4057 ** undesirable behavior such as segfaults and heap corruption.
4058 */
4059 SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt);
4060
4061 /*
4062 ** CAPI3REF: Reset A Prepared Statement Object
 
4063 **
4064 ** The sqlite3_reset() function is called to reset a [prepared statement]
4065 ** object back to its initial state, ready to be re-executed.
4066 ** ^Any SQL statement variables that had values bound to them using
4067 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4080,17 +4113,18 @@
4080 ** [sqlite3_reset(S)] returns an appropriate [error code].
4081 **
4082 ** ^The [sqlite3_reset(S)] interface does not change the values
4083 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4084 */
4085 SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt);
4086
4087 /*
4088 ** CAPI3REF: Create Or Redefine SQL Functions
4089 ** KEYWORDS: {function creation routines}
4090 ** KEYWORDS: {application-defined SQL function}
4091 ** KEYWORDS: {application-defined SQL functions}
 
4092 **
4093 ** ^These functions (collectively known as "function creation routines")
4094 ** are used to add SQL functions or aggregates or to redefine the behavior
4095 ** of existing SQL functions or aggregates. The only differences between
4096 ** these routines are the text encoding expected for
@@ -4179,31 +4213,31 @@
4179 ** ^An application-defined function is permitted to call other
4180 ** SQLite interfaces. However, such calls must not
4181 ** close the database connection nor finalize or reset the prepared
4182 ** statement in which the function is running.
4183 */
4184 SQLITE_API int sqlite3_create_function(
4185 sqlite3 *db,
4186 const char *zFunctionName,
4187 int nArg,
4188 int eTextRep,
4189 void *pApp,
4190 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4191 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4192 void (*xFinal)(sqlite3_context*)
4193 );
4194 SQLITE_API int sqlite3_create_function16(
4195 sqlite3 *db,
4196 const void *zFunctionName,
4197 int nArg,
4198 int eTextRep,
4199 void *pApp,
4200 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4201 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4202 void (*xFinal)(sqlite3_context*)
4203 );
4204 SQLITE_API int sqlite3_create_function_v2(
4205 sqlite3 *db,
4206 const char *zFunctionName,
4207 int nArg,
4208 int eTextRep,
4209 void *pApp,
@@ -4245,21 +4279,22 @@
4245 ** to be supported. However, new applications should avoid
4246 ** the use of these functions. To encourage programmers to avoid
4247 ** these functions, we will not explain what they do.
4248 */
4249 #ifndef SQLITE_OMIT_DEPRECATED
4250 SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context*);
4251 SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt*);
4252 SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4253 SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void);
4254 SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void);
4255 SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4256 void*,sqlite3_int64);
4257 #endif
4258
4259 /*
4260 ** CAPI3REF: Obtaining SQL Function Parameter Values
 
4261 **
4262 ** The C-language implementation of SQL functions and aggregates uses
4263 ** this set of interface routines to access the parameter values on
4264 ** the function or aggregate.
4265 **
@@ -4299,25 +4334,26 @@
4299 ** or [sqlite3_value_text16()].
4300 **
4301 ** These routines must be called from the same thread as
4302 ** the SQL function that supplied the [sqlite3_value*] parameters.
4303 */
4304 SQLITE_API const void *sqlite3_value_blob(sqlite3_value*);
4305 SQLITE_API int sqlite3_value_bytes(sqlite3_value*);
4306 SQLITE_API int sqlite3_value_bytes16(sqlite3_value*);
4307 SQLITE_API double sqlite3_value_double(sqlite3_value*);
4308 SQLITE_API int sqlite3_value_int(sqlite3_value*);
4309 SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value*);
4310 SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value*);
4311 SQLITE_API const void *sqlite3_value_text16(sqlite3_value*);
4312 SQLITE_API const void *sqlite3_value_text16le(sqlite3_value*);
4313 SQLITE_API const void *sqlite3_value_text16be(sqlite3_value*);
4314 SQLITE_API int sqlite3_value_type(sqlite3_value*);
4315 SQLITE_API int sqlite3_value_numeric_type(sqlite3_value*);
4316
4317 /*
4318 ** CAPI3REF: Obtain Aggregate Function Context
 
4319 **
4320 ** Implementations of aggregate SQL functions use this
4321 ** routine to allocate memory for storing their state.
4322 **
4323 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4354,14 +4390,15 @@
4354 ** function.
4355 **
4356 ** This routine must be called from the same thread in which
4357 ** the aggregate SQL function is running.
4358 */
4359 SQLITE_API void *sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4360
4361 /*
4362 ** CAPI3REF: User Data For Functions
 
4363 **
4364 ** ^The sqlite3_user_data() interface returns a copy of
4365 ** the pointer that was the pUserData parameter (the 5th parameter)
4366 ** of the [sqlite3_create_function()]
4367 ** and [sqlite3_create_function16()] routines that originally
@@ -4368,25 +4405,27 @@
4368 ** registered the application defined function.
4369 **
4370 ** This routine must be called from the same thread in which
4371 ** the application-defined function is running.
4372 */
4373 SQLITE_API void *sqlite3_user_data(sqlite3_context*);
4374
4375 /*
4376 ** CAPI3REF: Database Connection For Functions
 
4377 **
4378 ** ^The sqlite3_context_db_handle() interface returns a copy of
4379 ** the pointer to the [database connection] (the 1st parameter)
4380 ** of the [sqlite3_create_function()]
4381 ** and [sqlite3_create_function16()] routines that originally
4382 ** registered the application defined function.
4383 */
4384 SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context*);
4385
4386 /*
4387 ** CAPI3REF: Function Auxiliary Data
 
4388 **
4389 ** These functions may be used by (non-aggregate) SQL functions to
4390 ** associate metadata with argument values. If the same value is passed to
4391 ** multiple invocations of the same SQL function during query execution, under
4392 ** some circumstances the associated metadata may be preserved. An example
@@ -4431,12 +4470,12 @@
4431 ** values and [parameters] and expressions composed from the same.)^
4432 **
4433 ** These routines must be called from the same thread in which
4434 ** the SQL function is running.
4435 */
4436 SQLITE_API void *sqlite3_get_auxdata(sqlite3_context*, int N);
4437 SQLITE_API void sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4438
4439
4440 /*
4441 ** CAPI3REF: Constants Defining Special Destructor Behavior
4442 **
@@ -4455,10 +4494,11 @@
4455 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4456 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4457
4458 /*
4459 ** CAPI3REF: Setting The Result Of An SQL Function
 
4460 **
4461 ** These routines are used by the xFunc or xFinal callbacks that
4462 ** implement SQL functions and aggregates. See
4463 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4464 ** for additional information.
@@ -4567,33 +4607,34 @@
4567 **
4568 ** If these routines are called from within the different thread
4569 ** than the one containing the application-defined function that received
4570 ** the [sqlite3_context] pointer, the results are undefined.
4571 */
4572 SQLITE_API void sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4573 SQLITE_API void sqlite3_result_blob64(sqlite3_context*,const void*,
4574 sqlite3_uint64,void(*)(void*));
4575 SQLITE_API void sqlite3_result_double(sqlite3_context*, double);
4576 SQLITE_API void sqlite3_result_error(sqlite3_context*, const char*, int);
4577 SQLITE_API void sqlite3_result_error16(sqlite3_context*, const void*, int);
4578 SQLITE_API void sqlite3_result_error_toobig(sqlite3_context*);
4579 SQLITE_API void sqlite3_result_error_nomem(sqlite3_context*);
4580 SQLITE_API void sqlite3_result_error_code(sqlite3_context*, int);
4581 SQLITE_API void sqlite3_result_int(sqlite3_context*, int);
4582 SQLITE_API void sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4583 SQLITE_API void sqlite3_result_null(sqlite3_context*);
4584 SQLITE_API void sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4585 SQLITE_API void sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4586 void(*)(void*), unsigned char encoding);
4587 SQLITE_API void sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4588 SQLITE_API void sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4589 SQLITE_API void sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4590 SQLITE_API void sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4591 SQLITE_API void sqlite3_result_zeroblob(sqlite3_context*, int n);
4592
4593 /*
4594 ** CAPI3REF: Define New Collating Sequences
 
4595 **
4596 ** ^These functions add, remove, or modify a [collation] associated
4597 ** with the [database connection] specified as the first argument.
4598 **
4599 ** ^The name of the collation is a UTF-8 string
@@ -4667,35 +4708,36 @@
4667 ** is unfortunate but cannot be changed without breaking backwards
4668 ** compatibility.
4669 **
4670 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4671 */
4672 SQLITE_API int sqlite3_create_collation(
4673 sqlite3*,
4674 const char *zName,
4675 int eTextRep,
4676 void *pArg,
4677 int(*xCompare)(void*,int,const void*,int,const void*)
4678 );
4679 SQLITE_API int sqlite3_create_collation_v2(
4680 sqlite3*,
4681 const char *zName,
4682 int eTextRep,
4683 void *pArg,
4684 int(*xCompare)(void*,int,const void*,int,const void*),
4685 void(*xDestroy)(void*)
4686 );
4687 SQLITE_API int sqlite3_create_collation16(
4688 sqlite3*,
4689 const void *zName,
4690 int eTextRep,
4691 void *pArg,
4692 int(*xCompare)(void*,int,const void*,int,const void*)
4693 );
4694
4695 /*
4696 ** CAPI3REF: Collation Needed Callbacks
 
4697 **
4698 ** ^To avoid having to register all collation sequences before a database
4699 ** can be used, a single callback function may be registered with the
4700 ** [database connection] to be invoked whenever an undefined collation
4701 ** sequence is required.
@@ -4716,16 +4758,16 @@
4716 **
4717 ** The callback function should register the desired collation using
4718 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4719 ** [sqlite3_create_collation_v2()].
4720 */
4721 SQLITE_API int sqlite3_collation_needed(
4722 sqlite3*,
4723 void*,
4724 void(*)(void*,sqlite3*,int eTextRep,const char*)
4725 );
4726 SQLITE_API int sqlite3_collation_needed16(
4727 sqlite3*,
4728 void*,
4729 void(*)(void*,sqlite3*,int eTextRep,const void*)
4730 );
4731
@@ -4735,15 +4777,15 @@
4735 ** called right after sqlite3_open().
4736 **
4737 ** The code to implement this API is not available in the public release
4738 ** of SQLite.
4739 */
4740 SQLITE_API int sqlite3_key(
4741 sqlite3 *db, /* Database to be rekeyed */
4742 const void *pKey, int nKey /* The key */
4743 );
4744 SQLITE_API int sqlite3_key_v2(
4745 sqlite3 *db, /* Database to be rekeyed */
4746 const char *zDbName, /* Name of the database */
4747 const void *pKey, int nKey /* The key */
4748 );
4749
@@ -4753,35 +4795,35 @@
4753 ** database is decrypted.
4754 **
4755 ** The code to implement this API is not available in the public release
4756 ** of SQLite.
4757 */
4758 SQLITE_API int sqlite3_rekey(
4759 sqlite3 *db, /* Database to be rekeyed */
4760 const void *pKey, int nKey /* The new key */
4761 );
4762 SQLITE_API int sqlite3_rekey_v2(
4763 sqlite3 *db, /* Database to be rekeyed */
4764 const char *zDbName, /* Name of the database */
4765 const void *pKey, int nKey /* The new key */
4766 );
4767
4768 /*
4769 ** Specify the activation key for a SEE database. Unless
4770 ** activated, none of the SEE routines will work.
4771 */
4772 SQLITE_API void sqlite3_activate_see(
4773 const char *zPassPhrase /* Activation phrase */
4774 );
4775 #endif
4776
4777 #ifdef SQLITE_ENABLE_CEROD
4778 /*
4779 ** Specify the activation key for a CEROD database. Unless
4780 ** activated, none of the CEROD routines will work.
4781 */
4782 SQLITE_API void sqlite3_activate_cerod(
4783 const char *zPassPhrase /* Activation phrase */
4784 );
4785 #endif
4786
4787 /*
@@ -4799,11 +4841,11 @@
4799 ** method of the default [sqlite3_vfs] object. If the xSleep() method
4800 ** of the default VFS is not implemented correctly, or not implemented at
4801 ** all, then the behavior of sqlite3_sleep() may deviate from the description
4802 ** in the previous paragraphs.
4803 */
4804 SQLITE_API int sqlite3_sleep(int);
4805
4806 /*
4807 ** CAPI3REF: Name Of The Folder Holding Temporary Files
4808 **
4809 ** ^(If this global variable is made to point to a string which is
@@ -4899,10 +4941,11 @@
4899 SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
4900
4901 /*
4902 ** CAPI3REF: Test For Auto-Commit Mode
4903 ** KEYWORDS: {autocommit mode}
 
4904 **
4905 ** ^The sqlite3_get_autocommit() interface returns non-zero or
4906 ** zero if the given database connection is or is not in autocommit mode,
4907 ** respectively. ^Autocommit mode is on by default.
4908 ** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -4917,26 +4960,28 @@
4917 **
4918 ** If another thread changes the autocommit status of the database
4919 ** connection while this routine is running, then the return value
4920 ** is undefined.
4921 */
4922 SQLITE_API int sqlite3_get_autocommit(sqlite3*);
4923
4924 /*
4925 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
 
4926 **
4927 ** ^The sqlite3_db_handle interface returns the [database connection] handle
4928 ** to which a [prepared statement] belongs. ^The [database connection]
4929 ** returned by sqlite3_db_handle is the same [database connection]
4930 ** that was the first argument
4931 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4932 ** create the statement in the first place.
4933 */
4934 SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt*);
4935
4936 /*
4937 ** CAPI3REF: Return The Filename For A Database Connection
 
4938 **
4939 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
4940 ** associated with database N of connection D. ^The main database file
4941 ** has the name "main". If there is no attached database N on the database
4942 ** connection D, or if database N is a temporary or in-memory database, then
@@ -4945,23 +4990,25 @@
4945 ** ^The filename returned by this function is the output of the
4946 ** xFullPathname method of the [VFS]. ^In other words, the filename
4947 ** will be an absolute pathname, even if the filename used
4948 ** to open the database originally was a URI or relative pathname.
4949 */
4950 SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4951
4952 /*
4953 ** CAPI3REF: Determine if a database is read-only
 
4954 **
4955 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
4956 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
4957 ** the name of a database on connection D.
4958 */
4959 SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
4960
4961 /*
4962 ** CAPI3REF: Find the next prepared statement
 
4963 **
4964 ** ^This interface returns a pointer to the next [prepared statement] after
4965 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
4966 ** then this interface returns a pointer to the first prepared statement
4967 ** associated with the database connection pDb. ^If no prepared statement
@@ -4969,14 +5016,15 @@
4969 **
4970 ** The [database connection] pointer D in a call to
4971 ** [sqlite3_next_stmt(D,S)] must refer to an open database
4972 ** connection and in particular must not be a NULL pointer.
4973 */
4974 SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
4975
4976 /*
4977 ** CAPI3REF: Commit And Rollback Notification Callbacks
 
4978 **
4979 ** ^The sqlite3_commit_hook() interface registers a callback
4980 ** function to be invoked whenever a transaction is [COMMIT | committed].
4981 ** ^Any callback set by a previous call to sqlite3_commit_hook()
4982 ** for the same database connection is overridden.
@@ -5017,15 +5065,16 @@
5017 ** ^The rollback callback is not invoked if a transaction is
5018 ** automatically rolled back because the database connection is closed.
5019 **
5020 ** See also the [sqlite3_update_hook()] interface.
5021 */
5022 SQLITE_API void *sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5023 SQLITE_API void *sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5024
5025 /*
5026 ** CAPI3REF: Data Change Notification Callbacks
 
5027 **
5028 ** ^The sqlite3_update_hook() interface registers a callback function
5029 ** with the [database connection] identified by the first argument
5030 ** to be invoked whenever a row is updated, inserted or deleted in
5031 ** a rowid table.
@@ -5068,11 +5117,11 @@
5068 ** the first call on D.
5069 **
5070 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5071 ** interfaces.
5072 */
5073 SQLITE_API void *sqlite3_update_hook(
5074 sqlite3*,
5075 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5076 void*
5077 );
5078
@@ -5108,11 +5157,11 @@
5108 ** This interface is threadsafe on processors where writing a
5109 ** 32-bit integer is atomic.
5110 **
5111 ** See Also: [SQLite Shared-Cache Mode]
5112 */
5113 SQLITE_API int sqlite3_enable_shared_cache(int);
5114
5115 /*
5116 ** CAPI3REF: Attempt To Free Heap Memory
5117 **
5118 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5124,24 +5173,25 @@
5124 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5125 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5126 **
5127 ** See also: [sqlite3_db_release_memory()]
5128 */
5129 SQLITE_API int sqlite3_release_memory(int);
5130
5131 /*
5132 ** CAPI3REF: Free Memory Used By A Database Connection
 
5133 **
5134 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5135 ** memory as possible from database connection D. Unlike the
5136 ** [sqlite3_release_memory()] interface, this interface is in effect even
5137 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5138 ** omitted.
5139 **
5140 ** See also: [sqlite3_release_memory()]
5141 */
5142 SQLITE_API int sqlite3_db_release_memory(sqlite3*);
5143
5144 /*
5145 ** CAPI3REF: Impose A Limit On Heap Size
5146 **
5147 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5189,11 +5239,11 @@
5189 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5190 **
5191 ** The circumstances under which SQLite will enforce the soft heap limit may
5192 ** changes in future releases of SQLite.
5193 */
5194 SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N);
5195
5196 /*
5197 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5198 ** DEPRECATED
5199 **
@@ -5200,15 +5250,16 @@
5200 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5201 ** interface. This routine is provided for historical compatibility
5202 ** only. All new applications should use the
5203 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5204 */
5205 SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N);
5206
5207
5208 /*
5209 ** CAPI3REF: Extract Metadata About A Column Of A Table
 
5210 **
5211 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5212 ** information about column C of table T in database D
5213 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5214 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5269,11 +5320,11 @@
5269 **
5270 ** ^This function causes all database schemas to be read from disk and
5271 ** parsed, if that has not already been done, and returns an error if
5272 ** any errors are encountered while loading the schema.
5273 */
5274 SQLITE_API int sqlite3_table_column_metadata(
5275 sqlite3 *db, /* Connection handle */
5276 const char *zDbName, /* Database name or NULL */
5277 const char *zTableName, /* Table name */
5278 const char *zColumnName, /* Column name */
5279 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5283,10 +5334,11 @@
5283 int *pAutoinc /* OUTPUT: True if column is auto-increment */
5284 );
5285
5286 /*
5287 ** CAPI3REF: Load An Extension
 
5288 **
5289 ** ^This interface loads an SQLite extension library from the named file.
5290 **
5291 ** ^The sqlite3_load_extension() interface attempts to load an
5292 ** [SQLite extension] library contained in the file zFile. If
@@ -5315,19 +5367,20 @@
5315 ** [sqlite3_enable_load_extension()] prior to calling this API,
5316 ** otherwise an error will be returned.
5317 **
5318 ** See also the [load_extension() SQL function].
5319 */
5320 SQLITE_API int sqlite3_load_extension(
5321 sqlite3 *db, /* Load the extension into this database connection */
5322 const char *zFile, /* Name of the shared library containing extension */
5323 const char *zProc, /* Entry point. Derived from zFile if 0 */
5324 char **pzErrMsg /* Put error message here if not 0 */
5325 );
5326
5327 /*
5328 ** CAPI3REF: Enable Or Disable Extension Loading
 
5329 **
5330 ** ^So as not to open security holes in older applications that are
5331 ** unprepared to deal with [extension loading], and as a means of disabling
5332 ** [extension loading] while evaluating user-entered SQL, the following API
5333 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5335,11 +5388,11 @@
5335 ** ^Extension loading is off by default.
5336 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5337 ** to turn extension loading on and call it with onoff==0 to turn
5338 ** it back off again.
5339 */
5340 SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5341
5342 /*
5343 ** CAPI3REF: Automatically Load Statically Linked Extensions
5344 **
5345 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5373,11 +5426,11 @@
5373 ** will be called more than once for each database connection that is opened.
5374 **
5375 ** See also: [sqlite3_reset_auto_extension()]
5376 ** and [sqlite3_cancel_auto_extension()]
5377 */
5378 SQLITE_API int sqlite3_auto_extension(void (*xEntryPoint)(void));
5379
5380 /*
5381 ** CAPI3REF: Cancel Automatic Extension Loading
5382 **
5383 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5385,19 +5438,19 @@
5385 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5386 ** routine returns 1 if initialization routine X was successfully
5387 ** unregistered and it returns 0 if X was not on the list of initialization
5388 ** routines.
5389 */
5390 SQLITE_API int sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5391
5392 /*
5393 ** CAPI3REF: Reset Automatic Extension Loading
5394 **
5395 ** ^This interface disables all automatic extensions previously
5396 ** registered using [sqlite3_auto_extension()].
5397 */
5398 SQLITE_API void sqlite3_reset_auto_extension(void);
5399
5400 /*
5401 ** The interface to the virtual-table mechanism is currently considered
5402 ** to be experimental. The interface might change in incompatible ways.
5403 ** If this is a problem for you, do not use the interface at this time.
@@ -5573,10 +5626,11 @@
5573 #define SQLITE_INDEX_CONSTRAINT_GE 32
5574 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
5575
5576 /*
5577 ** CAPI3REF: Register A Virtual Table Implementation
 
5578 **
5579 ** ^These routines are used to register a new [virtual table module] name.
5580 ** ^Module names must be registered before
5581 ** creating a new [virtual table] using the module and before using a
5582 ** preexisting [virtual table] for the module.
@@ -5596,17 +5650,17 @@
5596 ** be invoked if the call to sqlite3_create_module_v2() fails.
5597 ** ^The sqlite3_create_module()
5598 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5599 ** destructor.
5600 */
5601 SQLITE_API int sqlite3_create_module(
5602 sqlite3 *db, /* SQLite connection to register module with */
5603 const char *zName, /* Name of the module */
5604 const sqlite3_module *p, /* Methods for the module */
5605 void *pClientData /* Client data for xCreate/xConnect */
5606 );
5607 SQLITE_API int sqlite3_create_module_v2(
5608 sqlite3 *db, /* SQLite connection to register module with */
5609 const char *zName, /* Name of the module */
5610 const sqlite3_module *p, /* Methods for the module */
5611 void *pClientData, /* Client data for xCreate/xConnect */
5612 void(*xDestroy)(void*) /* Module destructor function */
@@ -5665,14 +5719,15 @@
5665 ** ^The [xCreate] and [xConnect] methods of a
5666 ** [virtual table module] call this interface
5667 ** to declare the format (the names and datatypes of the columns) of
5668 ** the virtual tables they implement.
5669 */
5670 SQLITE_API int sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5671
5672 /*
5673 ** CAPI3REF: Overload A Function For A Virtual Table
 
5674 **
5675 ** ^(Virtual tables can provide alternative implementations of functions
5676 ** using the [xFindFunction] method of the [virtual table module].
5677 ** But global versions of those functions
5678 ** must exist in order to be overloaded.)^
@@ -5683,11 +5738,11 @@
5683 ** of the new function always causes an exception to be thrown. So
5684 ** the new function is not good for anything by itself. Its only
5685 ** purpose is to be a placeholder function that can be overloaded
5686 ** by a [virtual table].
5687 */
5688 SQLITE_API int sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5689
5690 /*
5691 ** The interface to the virtual-table mechanism defined above (back up
5692 ** to a comment remarkably similar to this one) is currently considered
5693 ** to be experimental. The interface might change in incompatible ways.
@@ -5711,10 +5766,12 @@
5711 */
5712 typedef struct sqlite3_blob sqlite3_blob;
5713
5714 /*
5715 ** CAPI3REF: Open A BLOB For Incremental I/O
 
 
5716 **
5717 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
5718 ** in row iRow, column zColumn, table zTable in database zDb;
5719 ** in other words, the same BLOB that would be selected by:
5720 **
@@ -5780,11 +5837,11 @@
5780 ** zero-filled blob to read or write using the incremental-blob interface.
5781 **
5782 ** To avoid a resource leak, every open [BLOB handle] should eventually
5783 ** be released by a call to [sqlite3_blob_close()].
5784 */
5785 SQLITE_API int sqlite3_blob_open(
5786 sqlite3*,
5787 const char *zDb,
5788 const char *zTable,
5789 const char *zColumn,
5790 sqlite3_int64 iRow,
@@ -5792,10 +5849,11 @@
5792 sqlite3_blob **ppBlob
5793 );
5794
5795 /*
5796 ** CAPI3REF: Move a BLOB Handle to a New Row
 
5797 **
5798 ** ^This function is used to move an existing blob handle so that it points
5799 ** to a different row of the same database table. ^The new row is identified
5800 ** by the rowid value passed as the second argument. Only the row can be
5801 ** changed. ^The database, table and column on which the blob handle is open
@@ -5812,14 +5870,15 @@
5812 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5813 ** always returns zero.
5814 **
5815 ** ^This function sets the database handle error code and message.
5816 */
5817 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5818
5819 /*
5820 ** CAPI3REF: Close A BLOB Handle
 
5821 **
5822 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
5823 ** unconditionally. Even if this routine returns an error code, the
5824 ** handle is still closed.)^
5825 **
@@ -5834,14 +5893,15 @@
5834 ** with a null pointer (such as would be returned by a failed call to
5835 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
5836 ** is passed a valid open blob handle, the values returned by the
5837 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
5838 */
5839 SQLITE_API int sqlite3_blob_close(sqlite3_blob *);
5840
5841 /*
5842 ** CAPI3REF: Return The Size Of An Open BLOB
 
5843 **
5844 ** ^Returns the size in bytes of the BLOB accessible via the
5845 ** successfully opened [BLOB handle] in its only argument. ^The
5846 ** incremental blob I/O routines can only read or overwriting existing
5847 ** blob content; they cannot change the size of a blob.
@@ -5849,14 +5909,15 @@
5849 ** This routine only works on a [BLOB handle] which has been created
5850 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5851 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5852 ** to this routine results in undefined and probably undesirable behavior.
5853 */
5854 SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *);
5855
5856 /*
5857 ** CAPI3REF: Read Data From A BLOB Incrementally
 
5858 **
5859 ** ^(This function is used to read data from an open [BLOB handle] into a
5860 ** caller-supplied buffer. N bytes of data are copied into buffer Z
5861 ** from the open BLOB, starting at offset iOffset.)^
5862 **
@@ -5877,14 +5938,15 @@
5877 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5878 ** to this routine results in undefined and probably undesirable behavior.
5879 **
5880 ** See also: [sqlite3_blob_write()].
5881 */
5882 SQLITE_API int sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5883
5884 /*
5885 ** CAPI3REF: Write Data Into A BLOB Incrementally
 
5886 **
5887 ** ^(This function is used to write data into an open [BLOB handle] from a
5888 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
5889 ** into the open BLOB, starting at offset iOffset.)^
5890 **
@@ -5918,11 +5980,11 @@
5918 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5919 ** to this routine results in undefined and probably undesirable behavior.
5920 **
5921 ** See also: [sqlite3_blob_read()].
5922 */
5923 SQLITE_API int sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5924
5925 /*
5926 ** CAPI3REF: Virtual File System Objects
5927 **
5928 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5949,13 +6011,13 @@
5949 **
5950 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
5951 ** ^(If the default VFS is unregistered, another VFS is chosen as
5952 ** the default. The choice for the new VFS is arbitrary.)^
5953 */
5954 SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName);
5955 SQLITE_API int sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
5956 SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs*);
5957
5958 /*
5959 ** CAPI3REF: Mutexes
5960 **
5961 ** The SQLite core uses these routines for thread
@@ -6064,15 +6126,15 @@
6064 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6065 ** behave as no-ops.
6066 **
6067 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6068 */
6069 SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int);
6070 SQLITE_API void sqlite3_mutex_free(sqlite3_mutex*);
6071 SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex*);
6072 SQLITE_API int sqlite3_mutex_try(sqlite3_mutex*);
6073 SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex*);
6074
6075 /*
6076 ** CAPI3REF: Mutex Methods Object
6077 **
6078 ** An instance of this structure defines the low-level routines
@@ -6178,12 +6240,12 @@
6178 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6179 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6180 ** interface should also return 1 when given a NULL pointer.
6181 */
6182 #ifndef NDEBUG
6183 SQLITE_API int sqlite3_mutex_held(sqlite3_mutex*);
6184 SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex*);
6185 #endif
6186
6187 /*
6188 ** CAPI3REF: Mutex Types
6189 **
@@ -6208,21 +6270,23 @@
6208 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6209 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6210
6211 /*
6212 ** CAPI3REF: Retrieve the mutex for a database connection
 
6213 **
6214 ** ^This interface returns a pointer the [sqlite3_mutex] object that
6215 ** serializes access to the [database connection] given in the argument
6216 ** when the [threading mode] is Serialized.
6217 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6218 ** routine returns a NULL pointer.
6219 */
6220 SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3*);
6221
6222 /*
6223 ** CAPI3REF: Low-Level Control Of Database Files
 
6224 **
6225 ** ^The [sqlite3_file_control()] interface makes a direct call to the
6226 ** xFileControl method for the [sqlite3_io_methods] object associated
6227 ** with a particular database identified by the second argument. ^The
6228 ** name of the database is "main" for the main database or "temp" for the
@@ -6249,11 +6313,11 @@
6249 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6250 ** xFileControl method.
6251 **
6252 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6253 */
6254 SQLITE_API int sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6255
6256 /*
6257 ** CAPI3REF: Testing Interface
6258 **
6259 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6268,11 +6332,11 @@
6268 ** The details of the operation codes, their meanings, the parameters
6269 ** they take, and what they do are all subject to change without notice.
6270 ** Unlike most of the SQLite API, this function is not guaranteed to
6271 ** operate consistently from one release to the next.
6272 */
6273 SQLITE_API int sqlite3_test_control(int op, ...);
6274
6275 /*
6276 ** CAPI3REF: Testing Interface Operation Codes
6277 **
6278 ** These constants are the valid operation code parameters used
@@ -6331,12 +6395,12 @@
6331 ** be represented by a 32-bit integer, then the values returned by
6332 ** sqlite3_status() are undefined.
6333 **
6334 ** See also: [sqlite3_db_status()]
6335 */
6336 SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6337 SQLITE_API int sqlite3_status64(
6338 int op,
6339 sqlite3_int64 *pCurrent,
6340 sqlite3_int64 *pHighwater,
6341 int resetFlag
6342 );
@@ -6435,10 +6499,11 @@
6435 #define SQLITE_STATUS_SCRATCH_SIZE 8
6436 #define SQLITE_STATUS_MALLOC_COUNT 9
6437
6438 /*
6439 ** CAPI3REF: Database Connection Status
 
6440 **
6441 ** ^This interface is used to retrieve runtime status information
6442 ** about a single [database connection]. ^The first argument is the
6443 ** database connection object to be interrogated. ^The second argument
6444 ** is an integer constant, taken from the set of
@@ -6455,11 +6520,11 @@
6455 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6456 ** non-zero [error code] on failure.
6457 **
6458 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6459 */
6460 SQLITE_API int sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6461
6462 /*
6463 ** CAPI3REF: Status Parameters for database connections
6464 ** KEYWORDS: {SQLITE_DBSTATUS options}
6465 **
@@ -6563,10 +6628,11 @@
6563 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6564
6565
6566 /*
6567 ** CAPI3REF: Prepared Statement Status
 
6568 **
6569 ** ^(Each prepared statement maintains various
6570 ** [SQLITE_STMTSTATUS counters] that measure the number
6571 ** of times it has performed specific operations.)^ These counters can
6572 ** be used to monitor the performance characteristics of the prepared
@@ -6584,11 +6650,11 @@
6584 ** ^If the resetFlg is true, then the counter is reset to zero after this
6585 ** interface call returns.
6586 **
6587 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6588 */
6589 SQLITE_API int sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6590
6591 /*
6592 ** CAPI3REF: Status Parameters for prepared statements
6593 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6594 **
@@ -7053,23 +7119,24 @@
7053 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7054 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7055 ** same time as another thread is invoking sqlite3_backup_step() it is
7056 ** possible that they return invalid values.
7057 */
7058 SQLITE_API sqlite3_backup *sqlite3_backup_init(
7059 sqlite3 *pDest, /* Destination database handle */
7060 const char *zDestName, /* Destination database name */
7061 sqlite3 *pSource, /* Source database handle */
7062 const char *zSourceName /* Source database name */
7063 );
7064 SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage);
7065 SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p);
7066 SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p);
7067 SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p);
7068
7069 /*
7070 ** CAPI3REF: Unlock Notification
 
7071 **
7072 ** ^When running in shared-cache mode, a database operation may fail with
7073 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
7074 ** individual tables within the shared-cache cannot be obtained. See
7075 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7178,11 +7245,11 @@
7178 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7179 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7180 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7181 ** SQLITE_LOCKED.)^
7182 */
7183 SQLITE_API int sqlite3_unlock_notify(
7184 sqlite3 *pBlocked, /* Waiting connection */
7185 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7186 void *pNotifyArg /* Argument to pass to xNotify */
7187 );
7188
@@ -7193,12 +7260,12 @@
7193 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7194 ** and extensions to compare the contents of two buffers containing UTF-8
7195 ** strings in a case-independent fashion, using the same definition of "case
7196 ** independence" that SQLite uses internally when comparing identifiers.
7197 */
7198 SQLITE_API int sqlite3_stricmp(const char *, const char *);
7199 SQLITE_API int sqlite3_strnicmp(const char *, const char *, int);
7200
7201 /*
7202 ** CAPI3REF: String Globbing
7203 *
7204 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7209,11 +7276,11 @@
7209 ** sensitive.
7210 **
7211 ** Note that this routine returns zero on a match and non-zero if the strings
7212 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7213 */
7214 SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr);
7215
7216 /*
7217 ** CAPI3REF: Error Logging Interface
7218 **
7219 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7232,14 +7299,15 @@
7232 ** will not use dynamically allocated memory. The log message is stored in
7233 ** a fixed-length buffer on the stack. If the log message is longer than
7234 ** a few hundred characters, it will be truncated to the length of the
7235 ** buffer.
7236 */
7237 SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...);
7238
7239 /*
7240 ** CAPI3REF: Write-Ahead Log Commit Hook
 
7241 **
7242 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
7243 ** is invoked each time data is committed to a database in wal mode.
7244 **
7245 ** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7267,18 +7335,19 @@
7267 ** previously registered write-ahead log callback. ^Note that the
7268 ** [sqlite3_wal_autocheckpoint()] interface and the
7269 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7270 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7271 */
7272 SQLITE_API void *sqlite3_wal_hook(
7273 sqlite3*,
7274 int(*)(void *,sqlite3*,const char*,int),
7275 void*
7276 );
7277
7278 /*
7279 ** CAPI3REF: Configure an auto-checkpoint
 
7280 **
7281 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
7282 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7283 ** to automatically [checkpoint]
7284 ** after committing a transaction if there are N or
@@ -7301,14 +7370,15 @@
7301 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7302 ** pages. The use of this interface
7303 ** is only necessary if the default setting is found to be suboptimal
7304 ** for a particular application.
7305 */
7306 SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7307
7308 /*
7309 ** CAPI3REF: Checkpoint a database
 
7310 **
7311 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
7312 ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
7313 **
7314 ** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7322,14 +7392,15 @@
7322 ** interface was added. This interface is retained for backwards
7323 ** compatibility and as a convenience for applications that need to manually
7324 ** start a callback but which do not need the full power (and corresponding
7325 ** complication) of [sqlite3_wal_checkpoint_v2()].
7326 */
7327 SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7328
7329 /*
7330 ** CAPI3REF: Checkpoint a database
 
7331 **
7332 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
7333 ** operation on database X of [database connection] D in mode M. Status
7334 ** information is written back into integers pointed to by L and C.)^
7335 ** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7415,11 +7486,11 @@
7415 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7416 **
7417 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7418 ** from SQL.
7419 */
7420 SQLITE_API int sqlite3_wal_checkpoint_v2(
7421 sqlite3 *db, /* Database handle */
7422 const char *zDb, /* Name of attached database (or NULL) */
7423 int eMode, /* SQLITE_CHECKPOINT_* value */
7424 int *pnLog, /* OUT: Size of WAL log in frames */
7425 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7451,11 +7522,11 @@
7451 **
7452 ** At present, there is only one option that may be configured using
7453 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7454 ** may be added in the future.
7455 */
7456 SQLITE_API int sqlite3_vtab_config(sqlite3*, int op, ...);
7457
7458 /*
7459 ** CAPI3REF: Virtual Table Configuration Options
7460 **
7461 ** These macros define the various options to the
@@ -7504,11 +7575,11 @@
7504 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7505 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7506 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7507 ** [virtual table].
7508 */
7509 SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *);
7510
7511 /*
7512 ** CAPI3REF: Conflict resolution modes
7513 ** KEYWORDS: {conflict resolution mode}
7514 **
@@ -7580,10 +7651,11 @@
7580 #define SQLITE_SCANSTAT_EXPLAIN 4
7581 #define SQLITE_SCANSTAT_SELECTID 5
7582
7583 /*
7584 ** CAPI3REF: Prepared Statement Scan Status
 
7585 **
7586 ** This interface returns information about the predicted and measured
7587 ** performance for pStmt. Advanced applications can use this
7588 ** interface to compare the predicted and the measured performance and
7589 ** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7608,26 +7680,27 @@
7608 ** as if the loop did not exist - it returns non-zero and leave the variable
7609 ** that pOut points to unchanged.
7610 **
7611 ** See also: [sqlite3_stmt_scanstatus_reset()]
7612 */
7613 SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_stmt_scanstatus(
7614 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7615 int idx, /* Index of loop to report on */
7616 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7617 void *pOut /* Result written here */
7618 );
7619
7620 /*
7621 ** CAPI3REF: Zero Scan-Status Counters
 
7622 **
7623 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7624 **
7625 ** This API is only available if the library is built with pre-processor
7626 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7627 */
7628 SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7629
7630
7631 /*
7632 ** Undo the hack that converts floating point types to integer for
7633 ** builds on processors without floating point support.
@@ -7678,11 +7751,11 @@
7678 ** Register a geometry callback named zGeom that can be used as part of an
7679 ** R-Tree geometry query as follows:
7680 **
7681 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7682 */
7683 SQLITE_API int sqlite3_rtree_geometry_callback(
7684 sqlite3 *db,
7685 const char *zGeom,
7686 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7687 void *pContext
7688 );
@@ -7704,11 +7777,11 @@
7704 ** Register a 2nd-generation geometry callback named zScore that can be
7705 ** used as part of an R-Tree geometry query as follows:
7706 **
7707 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7708 */
7709 SQLITE_API int sqlite3_rtree_query_callback(
7710 sqlite3 *db,
7711 const char *zQueryFunc,
7712 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7713 void *pContext,
7714 void (*xDestructor)(void*)
7715
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -41,27 +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
@@ -112,13 +109,13 @@
109 **
110 ** See also: [sqlite3_libversion()],
111 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
112 ** [sqlite_version()] and [sqlite_source_id()].
113 */
114 #define SQLITE_VERSION "3.8.10.1"
115 #define SQLITE_VERSION_NUMBER 3008010
116 #define SQLITE_SOURCE_ID "2015-05-09 12:14:55 05b4b1f2a937c06c90db70c09890038f6c98ec40"
117
118 /*
119 ** CAPI3REF: Run-Time Library Version Numbers
120 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
121 **
@@ -147,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
@@ -174,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 **
@@ -214,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 **
@@ -271,10 +268,11 @@
268 # define double sqlite3_int64
269 #endif
270
271 /*
272 ** CAPI3REF: Closing A Database Connection
273 ** DESTRUCTOR: sqlite3
274 **
275 ** ^The sqlite3_close() and sqlite3_close_v2() routines are destructors
276 ** for the [sqlite3] object.
277 ** ^Calls to sqlite3_close() and sqlite3_close_v2() return [SQLITE_OK] if
278 ** the [sqlite3] object is successfully destroyed and all associated
@@ -310,12 +308,12 @@
308 ** from [sqlite3_open()], [sqlite3_open16()], or
309 ** [sqlite3_open_v2()], and not previously closed.
310 ** ^Calling sqlite3_close() or sqlite3_close_v2() with a NULL pointer
311 ** argument is a harmless no-op.
312 */
313 SQLITE_API int SQLITE_STDCALL sqlite3_close(sqlite3*);
314 SQLITE_API int SQLITE_STDCALL sqlite3_close_v2(sqlite3*);
315
316 /*
317 ** The type for a callback function.
318 ** This is legacy and deprecated. It is included for historical
319 ** compatibility and is not documented.
@@ -322,10 +320,11 @@
320 */
321 typedef int (*sqlite3_callback)(void*,int,char**, char**);
322
323 /*
324 ** CAPI3REF: One-Step Query Execution Interface
325 ** METHOD: sqlite3
326 **
327 ** The sqlite3_exec() interface is a convenience wrapper around
328 ** [sqlite3_prepare_v2()], [sqlite3_step()], and [sqlite3_finalize()],
329 ** that allows an application to run multiple statements of SQL
330 ** without having to use a lot of C code.
@@ -381,11 +380,11 @@
380 ** the 1st parameter to sqlite3_exec() while sqlite3_exec() is running.
381 ** <li> The application must not modify the SQL statement text passed into
382 ** the 2nd parameter of sqlite3_exec() while sqlite3_exec() is running.
383 ** </ul>
384 */
385 SQLITE_API int SQLITE_STDCALL sqlite3_exec(
386 sqlite3*, /* An open database */
387 const char *sql, /* SQL to be evaluated */
388 int (*callback)(void*,int,char**,char**), /* Callback function */
389 void *, /* 1st argument to callback */
390 char **errmsg /* Error msg written here */
@@ -1341,14 +1340,14 @@
1340 ** sqlite3_os_init() and sqlite3_os_end(). An application-supplied
1341 ** implementation of sqlite3_os_init() or sqlite3_os_end()
1342 ** must return [SQLITE_OK] on success and some other [error code] upon
1343 ** failure.
1344 */
1345 SQLITE_API int SQLITE_STDCALL sqlite3_initialize(void);
1346 SQLITE_API int SQLITE_STDCALL sqlite3_shutdown(void);
1347 SQLITE_API int SQLITE_STDCALL sqlite3_os_init(void);
1348 SQLITE_API int SQLITE_STDCALL sqlite3_os_end(void);
1349
1350 /*
1351 ** CAPI3REF: Configuring The SQLite Library
1352 **
1353 ** The sqlite3_config() interface is used to make global configuration
@@ -1375,14 +1374,15 @@
1374 **
1375 ** ^When a configuration option is set, sqlite3_config() returns [SQLITE_OK].
1376 ** ^If the option is unknown or SQLite is unable to set the option
1377 ** then this routine returns a non-zero [error code].
1378 */
1379 SQLITE_API int SQLITE_CDECL sqlite3_config(int, ...);
1380
1381 /*
1382 ** CAPI3REF: Configure database connections
1383 ** METHOD: sqlite3
1384 **
1385 ** The sqlite3_db_config() interface is used to make configuration
1386 ** changes to a [database connection]. The interface is similar to
1387 ** [sqlite3_config()] except that the changes apply to a single
1388 ** [database connection] (specified in the first argument).
@@ -1393,11 +1393,11 @@
1393 ** Subsequent arguments vary depending on the configuration verb.
1394 **
1395 ** ^Calls to sqlite3_db_config() return SQLITE_OK if and only if
1396 ** the call is considered successful.
1397 */
1398 SQLITE_API int SQLITE_CDECL sqlite3_db_config(sqlite3*, int op, ...);
1399
1400 /*
1401 ** CAPI3REF: Memory Allocation Routines
1402 **
1403 ** An instance of this object defines the interface between SQLite
@@ -1876,19 +1876,21 @@
1876 #define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
1877
1878
1879 /*
1880 ** CAPI3REF: Enable Or Disable Extended Result Codes
1881 ** METHOD: sqlite3
1882 **
1883 ** ^The sqlite3_extended_result_codes() routine enables or disables the
1884 ** [extended result codes] feature of SQLite. ^The extended result
1885 ** codes are disabled by default for historical compatibility.
1886 */
1887 SQLITE_API int SQLITE_STDCALL sqlite3_extended_result_codes(sqlite3*, int onoff);
1888
1889 /*
1890 ** CAPI3REF: Last Insert Rowid
1891 ** METHOD: sqlite3
1892 **
1893 ** ^Each entry in most SQLite tables (except for [WITHOUT ROWID] tables)
1894 ** has a unique 64-bit signed
1895 ** integer key called the [ROWID | "rowid"]. ^The rowid is always available
1896 ** as an undeclared column named ROWID, OID, or _ROWID_ as long as those
@@ -1932,14 +1934,15 @@
1934 ** function is running and thus changes the last insert [rowid],
1935 ** then the value returned by [sqlite3_last_insert_rowid()] is
1936 ** unpredictable and might not equal either the old or the new
1937 ** last insert [rowid].
1938 */
1939 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_last_insert_rowid(sqlite3*);
1940
1941 /*
1942 ** CAPI3REF: Count The Number Of Rows Modified
1943 ** METHOD: sqlite3
1944 **
1945 ** ^This function returns the number of rows modified, inserted or
1946 ** deleted by the most recently completed INSERT, UPDATE or DELETE
1947 ** statement on the database connection specified by the only parameter.
1948 ** ^Executing any other type of SQL statement does not modify the value
@@ -1984,14 +1987,15 @@
1987 **
1988 ** If a separate thread makes changes on the same database connection
1989 ** while [sqlite3_changes()] is running then the value returned
1990 ** is unpredictable and not meaningful.
1991 */
1992 SQLITE_API int SQLITE_STDCALL sqlite3_changes(sqlite3*);
1993
1994 /*
1995 ** CAPI3REF: Total Number Of Rows Modified
1996 ** METHOD: sqlite3
1997 **
1998 ** ^This function returns the total number of rows inserted, modified or
1999 ** deleted by all [INSERT], [UPDATE] or [DELETE] statements completed
2000 ** since the database connection was opened, including those executed as
2001 ** part of trigger programs. ^Executing any other type of SQL statement
@@ -2007,14 +2011,15 @@
2011 **
2012 ** If a separate thread makes changes on the same database connection
2013 ** while [sqlite3_total_changes()] is running then the value
2014 ** returned is unpredictable and not meaningful.
2015 */
2016 SQLITE_API int SQLITE_STDCALL sqlite3_total_changes(sqlite3*);
2017
2018 /*
2019 ** CAPI3REF: Interrupt A Long-Running Query
2020 ** METHOD: sqlite3
2021 **
2022 ** ^This function causes any pending database operation to abort and
2023 ** return at its earliest opportunity. This routine is typically
2024 ** called in response to a user action such as pressing "Cancel"
2025 ** or Ctrl-C where the user wants a long query operation to halt
@@ -2046,11 +2051,11 @@
2051 ** that are started after the sqlite3_interrupt() call returns.
2052 **
2053 ** If the database connection closes while [sqlite3_interrupt()]
2054 ** is running then bad things will likely happen.
2055 */
2056 SQLITE_API void SQLITE_STDCALL sqlite3_interrupt(sqlite3*);
2057
2058 /*
2059 ** CAPI3REF: Determine If An SQL Statement Is Complete
2060 **
2061 ** These routines are useful during command-line input to determine if the
@@ -2081,16 +2086,17 @@
2086 ** UTF-8 string.
2087 **
2088 ** The input to [sqlite3_complete16()] must be a zero-terminated
2089 ** UTF-16 string in native byte order.
2090 */
2091 SQLITE_API int SQLITE_STDCALL sqlite3_complete(const char *sql);
2092 SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
2093
2094 /*
2095 ** CAPI3REF: Register A Callback To Handle SQLITE_BUSY Errors
2096 ** KEYWORDS: {busy-handler callback} {busy handler}
2097 ** METHOD: sqlite3
2098 **
2099 ** ^The sqlite3_busy_handler(D,X,P) routine sets a callback function X
2100 ** that might be invoked with argument P whenever
2101 ** an attempt is made to access a database table associated with
2102 ** [database connection] D when another thread
@@ -2142,14 +2148,15 @@
2148 ** result in undefined behavior.
2149 **
2150 ** A busy handler must not close the database connection
2151 ** or [prepared statement] that invoked the busy handler.
2152 */
2153 SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*, int(*)(void*,int), void*);
2154
2155 /*
2156 ** CAPI3REF: Set A Busy Timeout
2157 ** METHOD: sqlite3
2158 **
2159 ** ^This routine sets a [sqlite3_busy_handler | busy handler] that sleeps
2160 ** for a specified amount of time when a table is locked. ^The handler
2161 ** will sleep multiple times until at least "ms" milliseconds of sleeping
2162 ** have accumulated. ^After at least "ms" milliseconds of sleeping,
@@ -2164,14 +2171,15 @@
2171 ** was defined (using [sqlite3_busy_handler()]) prior to calling
2172 ** this routine, that other busy handler is cleared.)^
2173 **
2174 ** See also: [PRAGMA busy_timeout]
2175 */
2176 SQLITE_API int SQLITE_STDCALL sqlite3_busy_timeout(sqlite3*, int ms);
2177
2178 /*
2179 ** CAPI3REF: Convenience Routines For Running Queries
2180 ** METHOD: sqlite3
2181 **
2182 ** This is a legacy interface that is preserved for backwards compatibility.
2183 ** Use of this interface is not recommended.
2184 **
2185 ** Definition: A <b>result table</b> is memory data structure created by the
@@ -2238,19 +2246,19 @@
2246 ** interface defined here. As a consequence, errors that occur in the
2247 ** wrapper layer outside of the internal [sqlite3_exec()] call are not
2248 ** reflected in subsequent calls to [sqlite3_errcode()] or
2249 ** [sqlite3_errmsg()].
2250 */
2251 SQLITE_API int SQLITE_STDCALL sqlite3_get_table(
2252 sqlite3 *db, /* An open database */
2253 const char *zSql, /* SQL to be evaluated */
2254 char ***pazResult, /* Results of the query */
2255 int *pnRow, /* Number of result rows written here */
2256 int *pnColumn, /* Number of result columns written here */
2257 char **pzErrmsg /* Error msg written here */
2258 );
2259 SQLITE_API void SQLITE_STDCALL sqlite3_free_table(char **result);
2260
2261 /*
2262 ** CAPI3REF: Formatted String Printing Functions
2263 **
2264 ** These routines are work-alikes of the "printf()" family of functions
@@ -2352,14 +2360,14 @@
2360 **
2361 ** ^(The "%z" formatting option works like "%s" but with the
2362 ** addition that after the string has been read and copied into
2363 ** the result, [sqlite3_free()] is called on the input string.)^
2364 */
2365 SQLITE_API char *SQLITE_CDECL sqlite3_mprintf(const char*,...);
2366 SQLITE_API char *SQLITE_STDCALL sqlite3_vmprintf(const char*, va_list);
2367 SQLITE_API char *SQLITE_CDECL sqlite3_snprintf(int,char*,const char*, ...);
2368 SQLITE_API char *SQLITE_STDCALL sqlite3_vsnprintf(int,char*,const char*, va_list);
2369
2370 /*
2371 ** CAPI3REF: Memory Allocation Subsystem
2372 **
2373 ** The SQLite core uses these three routines for all of its own
@@ -2445,16 +2453,16 @@
2453 **
2454 ** The application must not read or write any part of
2455 ** a block of memory after it has been released using
2456 ** [sqlite3_free()] or [sqlite3_realloc()].
2457 */
2458 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc(int);
2459 SQLITE_API void *SQLITE_STDCALL sqlite3_malloc64(sqlite3_uint64);
2460 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc(void*, int);
2461 SQLITE_API void *SQLITE_STDCALL sqlite3_realloc64(void*, sqlite3_uint64);
2462 SQLITE_API void SQLITE_STDCALL sqlite3_free(void*);
2463 SQLITE_API sqlite3_uint64 SQLITE_STDCALL sqlite3_msize(void*);
2464
2465 /*
2466 ** CAPI3REF: Memory Allocator Statistics
2467 **
2468 ** SQLite provides these two interfaces for reporting on the status
@@ -2475,12 +2483,12 @@
2483 ** [sqlite3_memory_used()] if and only if the parameter to
2484 ** [sqlite3_memory_highwater()] is true. ^The value returned
2485 ** by [sqlite3_memory_highwater(1)] is the high-water mark
2486 ** prior to the reset.
2487 */
2488 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_used(void);
2489 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_memory_highwater(int resetFlag);
2490
2491 /*
2492 ** CAPI3REF: Pseudo-Random Number Generator
2493 **
2494 ** SQLite contains a high-quality pseudo-random number generator (PRNG) used to
@@ -2499,14 +2507,15 @@
2507 ** ^If the previous call to this routine had an N of 1 or more and a
2508 ** non-NULL P then the pseudo-randomness is generated
2509 ** internally and without recourse to the [sqlite3_vfs] xRandomness
2510 ** method.
2511 */
2512 SQLITE_API void SQLITE_STDCALL sqlite3_randomness(int N, void *P);
2513
2514 /*
2515 ** CAPI3REF: Compile-Time Authorization Callbacks
2516 ** METHOD: sqlite3
2517 **
2518 ** ^This routine registers an authorizer callback with a particular
2519 ** [database connection], supplied in the first argument.
2520 ** ^The authorizer callback is invoked as SQL statements are being compiled
2521 ** by [sqlite3_prepare()] or its variants [sqlite3_prepare_v2()],
@@ -2581,11 +2590,11 @@
2590 ** [sqlite3_prepare()] or its variants. Authorization is not
2591 ** performed during statement evaluation in [sqlite3_step()], unless
2592 ** as stated in the previous paragraph, sqlite3_step() invokes
2593 ** sqlite3_prepare_v2() to reprepare a statement after a schema change.
2594 */
2595 SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
2596 sqlite3*,
2597 int (*xAuth)(void*,int,const char*,const char*,const char*,const char*),
2598 void *pUserData
2599 );
2600
@@ -2659,10 +2668,11 @@
2668 #define SQLITE_COPY 0 /* No longer used */
2669 #define SQLITE_RECURSIVE 33 /* NULL NULL */
2670
2671 /*
2672 ** CAPI3REF: Tracing And Profiling Functions
2673 ** METHOD: sqlite3
2674 **
2675 ** These routines register callback functions that can be used for
2676 ** tracing and profiling the execution of SQL statements.
2677 **
2678 ** ^The callback function registered by sqlite3_trace() is invoked at
@@ -2685,16 +2695,17 @@
2695 ** digits in the time are meaningless. Future versions of SQLite
2696 ** might provide greater resolution on the profiler callback. The
2697 ** sqlite3_profile() function is considered experimental and is
2698 ** subject to change in future versions of SQLite.
2699 */
2700 SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*, void(*xTrace)(void*,const char*), void*);
2701 SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
2702 void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
2703
2704 /*
2705 ** CAPI3REF: Query Progress Callbacks
2706 ** METHOD: sqlite3
2707 **
2708 ** ^The sqlite3_progress_handler(D,N,X,P) interface causes the callback
2709 ** function X to be invoked periodically during long running calls to
2710 ** [sqlite3_exec()], [sqlite3_step()] and [sqlite3_get_table()] for
2711 ** database connection D. An example use for this
@@ -2720,14 +2731,15 @@
2731 ** the database connection that invoked the progress handler.
2732 ** Note that [sqlite3_prepare_v2()] and [sqlite3_step()] both modify their
2733 ** database connections for the meaning of "modify" in this paragraph.
2734 **
2735 */
2736 SQLITE_API void SQLITE_STDCALL sqlite3_progress_handler(sqlite3*, int, int(*)(void*), void*);
2737
2738 /*
2739 ** CAPI3REF: Opening A New Database Connection
2740 ** CONSTRUCTOR: sqlite3
2741 **
2742 ** ^These routines open an SQLite database file as specified by the
2743 ** filename argument. ^The filename argument is interpreted as UTF-8 for
2744 ** sqlite3_open() and sqlite3_open_v2() and as UTF-16 in the native byte
2745 ** order for sqlite3_open16(). ^(A [database connection] handle is usually
@@ -2948,19 +2960,19 @@
2960 ** prior to calling sqlite3_open() or sqlite3_open_v2(). Otherwise, various
2961 ** features that require the use of temporary files may fail.
2962 **
2963 ** See also: [sqlite3_temp_directory]
2964 */
2965 SQLITE_API int SQLITE_STDCALL sqlite3_open(
2966 const char *filename, /* Database filename (UTF-8) */
2967 sqlite3 **ppDb /* OUT: SQLite db handle */
2968 );
2969 SQLITE_API int SQLITE_STDCALL sqlite3_open16(
2970 const void *filename, /* Database filename (UTF-16) */
2971 sqlite3 **ppDb /* OUT: SQLite db handle */
2972 );
2973 SQLITE_API int SQLITE_STDCALL sqlite3_open_v2(
2974 const char *filename, /* Database filename (UTF-8) */
2975 sqlite3 **ppDb, /* OUT: SQLite db handle */
2976 int flags, /* Flags */
2977 const char *zVfs /* Name of VFS module to use */
2978 );
@@ -3002,17 +3014,18 @@
3014 ** sqlite3_uri_boolean(F,P,B) returns B. If F is not a NULL pointer and
3015 ** is not a database file pathname pointer that SQLite passed into the xOpen
3016 ** VFS method, then the behavior of this routine is undefined and probably
3017 ** undesirable.
3018 */
3019 SQLITE_API const char *SQLITE_STDCALL sqlite3_uri_parameter(const char *zFilename, const char *zParam);
3020 SQLITE_API int SQLITE_STDCALL sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault);
3021 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_uri_int64(const char*, const char*, sqlite3_int64);
3022
3023
3024 /*
3025 ** CAPI3REF: Error Codes And Messages
3026 ** METHOD: sqlite3
3027 **
3028 ** ^If the most recent sqlite3_* API call associated with
3029 ** [database connection] D failed, then the sqlite3_errcode(D) interface
3030 ** returns the numeric [result code] or [extended result code] for that
3031 ** API call.
@@ -3047,44 +3060,45 @@
3060 **
3061 ** If an interface fails with SQLITE_MISUSE, that means the interface
3062 ** was invoked incorrectly by the application. In that case, the
3063 ** error code and message may or may not be set.
3064 */
3065 SQLITE_API int SQLITE_STDCALL sqlite3_errcode(sqlite3 *db);
3066 SQLITE_API int SQLITE_STDCALL sqlite3_extended_errcode(sqlite3 *db);
3067 SQLITE_API const char *SQLITE_STDCALL sqlite3_errmsg(sqlite3*);
3068 SQLITE_API const void *SQLITE_STDCALL sqlite3_errmsg16(sqlite3*);
3069 SQLITE_API const char *SQLITE_STDCALL sqlite3_errstr(int);
3070
3071 /*
3072 ** CAPI3REF: Prepared Statement Object
3073 ** KEYWORDS: {prepared statement} {prepared statements}
3074 **
3075 ** An instance of this object represents a single SQL statement that
3076 ** has been compiled into binary form and is ready to be evaluated.
 
3077 **
3078 ** Think of each SQL statement as a separate computer program. The
3079 ** original SQL text is source code. A prepared statement object
3080 ** is the compiled object code. All SQL must be converted into a
3081 ** prepared statement before it can be run.
3082 **
3083 ** The life-cycle of a prepared statement object usually goes like this:
3084 **
3085 ** <ol>
3086 ** <li> Create the prepared statement object using [sqlite3_prepare_v2()].
3087 ** <li> Bind values to [parameters] using the sqlite3_bind_*()
 
3088 ** interfaces.
3089 ** <li> Run the SQL by calling [sqlite3_step()] one or more times.
3090 ** <li> Reset the prepared statement using [sqlite3_reset()] then go back
3091 ** to step 2. Do this zero or more times.
3092 ** <li> Destroy the object using [sqlite3_finalize()].
3093 ** </ol>
 
 
 
3094 */
3095 typedef struct sqlite3_stmt sqlite3_stmt;
3096
3097 /*
3098 ** CAPI3REF: Run-time Limits
3099 ** METHOD: sqlite3
3100 **
3101 ** ^(This interface allows the size of various constructs to be limited
3102 ** on a connection by connection basis. The first parameter is the
3103 ** [database connection] whose limit is to be set or queried. The
3104 ** second parameter is one of the [limit categories] that define a
@@ -3118,11 +3132,11 @@
3132 ** created by an untrusted script can be contained using the
3133 ** [max_page_count] [PRAGMA].
3134 **
3135 ** New run-time limit categories may be added in future releases.
3136 */
3137 SQLITE_API int SQLITE_STDCALL sqlite3_limit(sqlite3*, int id, int newVal);
3138
3139 /*
3140 ** CAPI3REF: Run-Time Limit Categories
3141 ** KEYWORDS: {limit category} {*limit categories}
3142 **
@@ -3192,10 +3206,12 @@
3206 #define SQLITE_LIMIT_WORKER_THREADS 11
3207
3208 /*
3209 ** CAPI3REF: Compiling An SQL Statement
3210 ** KEYWORDS: {SQL statement compiler}
3211 ** METHOD: sqlite3
3212 ** CONSTRUCTOR: sqlite3_stmt
3213 **
3214 ** To execute an SQL query, it must first be compiled into a byte-code
3215 ** program using one of these routines.
3216 **
3217 ** The first argument, "db", is a [database connection] obtained from a
@@ -3268,50 +3284,52 @@
3284 ** or [GLOB] operator or if the parameter is compared to an indexed column
3285 ** and the [SQLITE_ENABLE_STAT3] compile-time option is enabled.
3286 ** </li>
3287 ** </ol>
3288 */
3289 SQLITE_API int SQLITE_STDCALL sqlite3_prepare(
3290 sqlite3 *db, /* Database handle */
3291 const char *zSql, /* SQL statement, UTF-8 encoded */
3292 int nByte, /* Maximum length of zSql in bytes. */
3293 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3294 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3295 );
3296 SQLITE_API int SQLITE_STDCALL sqlite3_prepare_v2(
3297 sqlite3 *db, /* Database handle */
3298 const char *zSql, /* SQL statement, UTF-8 encoded */
3299 int nByte, /* Maximum length of zSql in bytes. */
3300 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3301 const char **pzTail /* OUT: Pointer to unused portion of zSql */
3302 );
3303 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16(
3304 sqlite3 *db, /* Database handle */
3305 const void *zSql, /* SQL statement, UTF-16 encoded */
3306 int nByte, /* Maximum length of zSql in bytes. */
3307 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3308 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3309 );
3310 SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
3311 sqlite3 *db, /* Database handle */
3312 const void *zSql, /* SQL statement, UTF-16 encoded */
3313 int nByte, /* Maximum length of zSql in bytes. */
3314 sqlite3_stmt **ppStmt, /* OUT: Statement handle */
3315 const void **pzTail /* OUT: Pointer to unused portion of zSql */
3316 );
3317
3318 /*
3319 ** CAPI3REF: Retrieving Statement SQL
3320 ** METHOD: sqlite3_stmt
3321 **
3322 ** ^This interface can be used to retrieve a saved copy of the original
3323 ** SQL text used to create a [prepared statement] if that statement was
3324 ** compiled using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
3325 */
3326 SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
3327
3328 /*
3329 ** CAPI3REF: Determine If An SQL Statement Writes The Database
3330 ** METHOD: sqlite3_stmt
3331 **
3332 ** ^The sqlite3_stmt_readonly(X) interface returns true (non-zero) if
3333 ** and only if the [prepared statement] X makes no direct changes to
3334 ** the content of the database file.
3335 **
@@ -3335,14 +3353,15 @@
3353 ** database. ^The [ATTACH] and [DETACH] statements also cause
3354 ** sqlite3_stmt_readonly() to return true since, while those statements
3355 ** change the configuration of a database connection, they do not make
3356 ** changes to the content of the database files on disk.
3357 */
3358 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_readonly(sqlite3_stmt *pStmt);
3359
3360 /*
3361 ** CAPI3REF: Determine If A Prepared Statement Has Been Reset
3362 ** METHOD: sqlite3_stmt
3363 **
3364 ** ^The sqlite3_stmt_busy(S) interface returns true (non-zero) if the
3365 ** [prepared statement] S has been stepped at least once using
3366 ** [sqlite3_step(S)] but has not run to completion and/or has not
3367 ** been reset using [sqlite3_reset(S)]. ^The sqlite3_stmt_busy(S)
@@ -3354,11 +3373,11 @@
3373 ** to locate all prepared statements associated with a database
3374 ** connection that are in need of being reset. This can be used,
3375 ** for example, in diagnostic routines to search for prepared
3376 ** statements that are holding a transaction open.
3377 */
3378 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_busy(sqlite3_stmt*);
3379
3380 /*
3381 ** CAPI3REF: Dynamically Typed Value Object
3382 ** KEYWORDS: {protected sqlite3_value} {unprotected sqlite3_value}
3383 **
@@ -3413,10 +3432,11 @@
3432
3433 /*
3434 ** CAPI3REF: Binding Values To Prepared Statements
3435 ** KEYWORDS: {host parameter} {host parameters} {host parameter name}
3436 ** KEYWORDS: {SQL parameter} {SQL parameters} {parameter binding}
3437 ** METHOD: sqlite3_stmt
3438 **
3439 ** ^(In the SQL statement text input to [sqlite3_prepare_v2()] and its variants,
3440 ** literals may be replaced by a [parameter] that matches one of following
3441 ** templates:
3442 **
@@ -3515,26 +3535,27 @@
3535 ** index is out of range. ^[SQLITE_NOMEM] is returned if malloc() fails.
3536 **
3537 ** See also: [sqlite3_bind_parameter_count()],
3538 ** [sqlite3_bind_parameter_name()], and [sqlite3_bind_parameter_index()].
3539 */
3540 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob(sqlite3_stmt*, int, const void*, int n, void(*)(void*));
3541 SQLITE_API int SQLITE_STDCALL sqlite3_bind_blob64(sqlite3_stmt*, int, const void*, sqlite3_uint64,
3542 void(*)(void*));
3543 SQLITE_API int SQLITE_STDCALL sqlite3_bind_double(sqlite3_stmt*, int, double);
3544 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int(sqlite3_stmt*, int, int);
3545 SQLITE_API int SQLITE_STDCALL sqlite3_bind_int64(sqlite3_stmt*, int, sqlite3_int64);
3546 SQLITE_API int SQLITE_STDCALL sqlite3_bind_null(sqlite3_stmt*, int);
3547 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text(sqlite3_stmt*,int,const char*,int,void(*)(void*));
3548 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text16(sqlite3_stmt*, int, const void*, int, void(*)(void*));
3549 SQLITE_API int SQLITE_STDCALL sqlite3_bind_text64(sqlite3_stmt*, int, const char*, sqlite3_uint64,
3550 void(*)(void*), unsigned char encoding);
3551 SQLITE_API int SQLITE_STDCALL sqlite3_bind_value(sqlite3_stmt*, int, const sqlite3_value*);
3552 SQLITE_API int SQLITE_STDCALL sqlite3_bind_zeroblob(sqlite3_stmt*, int, int n);
3553
3554 /*
3555 ** CAPI3REF: Number Of SQL Parameters
3556 ** METHOD: sqlite3_stmt
3557 **
3558 ** ^This routine can be used to find the number of [SQL parameters]
3559 ** in a [prepared statement]. SQL parameters are tokens of the
3560 ** form "?", "?NNN", ":AAA", "$AAA", or "@AAA" that serve as
3561 ** placeholders for values that are [sqlite3_bind_blob | bound]
@@ -3547,14 +3568,15 @@
3568 **
3569 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3570 ** [sqlite3_bind_parameter_name()], and
3571 ** [sqlite3_bind_parameter_index()].
3572 */
3573 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_count(sqlite3_stmt*);
3574
3575 /*
3576 ** CAPI3REF: Name Of A Host Parameter
3577 ** METHOD: sqlite3_stmt
3578 **
3579 ** ^The sqlite3_bind_parameter_name(P,N) interface returns
3580 ** the name of the N-th [SQL parameter] in the [prepared statement] P.
3581 ** ^(SQL parameters of the form "?NNN" or ":AAA" or "@AAA" or "$AAA"
3582 ** have a name which is the string "?NNN" or ":AAA" or "@AAA" or "$AAA"
@@ -3574,14 +3596,15 @@
3596 **
3597 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3598 ** [sqlite3_bind_parameter_count()], and
3599 ** [sqlite3_bind_parameter_index()].
3600 */
3601 SQLITE_API const char *SQLITE_STDCALL sqlite3_bind_parameter_name(sqlite3_stmt*, int);
3602
3603 /*
3604 ** CAPI3REF: Index Of A Parameter With A Given Name
3605 ** METHOD: sqlite3_stmt
3606 **
3607 ** ^Return the index of an SQL parameter given its name. ^The
3608 ** index value returned is suitable for use as the second
3609 ** parameter to [sqlite3_bind_blob|sqlite3_bind()]. ^A zero
3610 ** is returned if no matching parameter is found. ^The parameter
@@ -3590,34 +3613,37 @@
3613 **
3614 ** See also: [sqlite3_bind_blob|sqlite3_bind()],
3615 ** [sqlite3_bind_parameter_count()], and
3616 ** [sqlite3_bind_parameter_index()].
3617 */
3618 SQLITE_API int SQLITE_STDCALL sqlite3_bind_parameter_index(sqlite3_stmt*, const char *zName);
3619
3620 /*
3621 ** CAPI3REF: Reset All Bindings On A Prepared Statement
3622 ** METHOD: sqlite3_stmt
3623 **
3624 ** ^Contrary to the intuition of many, [sqlite3_reset()] does not reset
3625 ** the [sqlite3_bind_blob | bindings] on a [prepared statement].
3626 ** ^Use this routine to reset all host parameters to NULL.
3627 */
3628 SQLITE_API int SQLITE_STDCALL sqlite3_clear_bindings(sqlite3_stmt*);
3629
3630 /*
3631 ** CAPI3REF: Number Of Columns In A Result Set
3632 ** METHOD: sqlite3_stmt
3633 **
3634 ** ^Return the number of columns in the result set returned by the
3635 ** [prepared statement]. ^This routine returns 0 if pStmt is an SQL
3636 ** statement that does not return data (for example an [UPDATE]).
3637 **
3638 ** See also: [sqlite3_data_count()]
3639 */
3640 SQLITE_API int SQLITE_STDCALL sqlite3_column_count(sqlite3_stmt *pStmt);
3641
3642 /*
3643 ** CAPI3REF: Column Names In A Result Set
3644 ** METHOD: sqlite3_stmt
3645 **
3646 ** ^These routines return the name assigned to a particular column
3647 ** in the result set of a [SELECT] statement. ^The sqlite3_column_name()
3648 ** interface returns a pointer to a zero-terminated UTF-8 string
3649 ** and sqlite3_column_name16() returns a pointer to a zero-terminated
@@ -3638,15 +3664,16 @@
3664 ** ^The name of a result column is the value of the "AS" clause for
3665 ** that column, if there is an AS clause. If there is no AS clause
3666 ** then the name of the column is unspecified and may change from
3667 ** one release of SQLite to the next.
3668 */
3669 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_name(sqlite3_stmt*, int N);
3670 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_name16(sqlite3_stmt*, int N);
3671
3672 /*
3673 ** CAPI3REF: Source Of Data In A Query Result
3674 ** METHOD: sqlite3_stmt
3675 **
3676 ** ^These routines provide a means to determine the database, table, and
3677 ** table column that is the origin of a particular result column in
3678 ** [SELECT] statement.
3679 ** ^The name of the database or table or column can be returned as
@@ -3686,19 +3713,20 @@
3713 ** If two or more threads call one or more
3714 ** [sqlite3_column_database_name | column metadata interfaces]
3715 ** for the same [prepared statement] and result column
3716 ** at the same time then the results are undefined.
3717 */
3718 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_database_name(sqlite3_stmt*,int);
3719 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_database_name16(sqlite3_stmt*,int);
3720 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_table_name(sqlite3_stmt*,int);
3721 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_table_name16(sqlite3_stmt*,int);
3722 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_origin_name(sqlite3_stmt*,int);
3723 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_origin_name16(sqlite3_stmt*,int);
3724
3725 /*
3726 ** CAPI3REF: Declared Datatype Of A Query Result
3727 ** METHOD: sqlite3_stmt
3728 **
3729 ** ^(The first parameter is a [prepared statement].
3730 ** If this statement is a [SELECT] statement and the Nth column of the
3731 ** returned result set of that [SELECT] is a table column (not an
3732 ** expression or subquery) then the declared type of the table
@@ -3722,15 +3750,16 @@
3750 ** data stored in that column is of the declared type. SQLite is
3751 ** strongly typed, but the typing is dynamic not static. ^Type
3752 ** is associated with individual values, not with the containers
3753 ** used to hold those values.
3754 */
3755 SQLITE_API const char *SQLITE_STDCALL sqlite3_column_decltype(sqlite3_stmt*,int);
3756 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_decltype16(sqlite3_stmt*,int);
3757
3758 /*
3759 ** CAPI3REF: Evaluate An SQL Statement
3760 ** METHOD: sqlite3_stmt
3761 **
3762 ** After a [prepared statement] has been prepared using either
3763 ** [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] or one of the legacy
3764 ** interfaces [sqlite3_prepare()] or [sqlite3_prepare16()], this function
3765 ** must be called one or more times to evaluate the statement.
@@ -3802,14 +3831,15 @@
3831 ** using either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()] instead
3832 ** of the legacy [sqlite3_prepare()] and [sqlite3_prepare16()] interfaces,
3833 ** then the more specific [error codes] are returned directly
3834 ** by sqlite3_step(). The use of the "v2" interface is recommended.
3835 */
3836 SQLITE_API int SQLITE_STDCALL sqlite3_step(sqlite3_stmt*);
3837
3838 /*
3839 ** CAPI3REF: Number of columns in a result set
3840 ** METHOD: sqlite3_stmt
3841 **
3842 ** ^The sqlite3_data_count(P) interface returns the number of columns in the
3843 ** current row of the result set of [prepared statement] P.
3844 ** ^If prepared statement P does not have results ready to return
3845 ** (via calls to the [sqlite3_column_int | sqlite3_column_*()] of
@@ -3822,11 +3852,11 @@
3852 ** where it always returns zero since each step of that multi-step
3853 ** pragma returns 0 columns of data.
3854 **
3855 ** See also: [sqlite3_column_count()]
3856 */
3857 SQLITE_API int SQLITE_STDCALL sqlite3_data_count(sqlite3_stmt *pStmt);
3858
3859 /*
3860 ** CAPI3REF: Fundamental Datatypes
3861 ** KEYWORDS: SQLITE_TEXT
3862 **
@@ -3859,10 +3889,11 @@
3889 #define SQLITE3_TEXT 3
3890
3891 /*
3892 ** CAPI3REF: Result Values From A Query
3893 ** KEYWORDS: {column access functions}
3894 ** METHOD: sqlite3_stmt
3895 **
3896 ** These routines form the "result set" interface.
3897 **
3898 ** ^These routines return information about a single column of the current
3899 ** result row of a query. ^In every case the first argument is a pointer
@@ -4018,23 +4049,24 @@
4049 ** of these routines, a default value is returned. The default value
4050 ** is either the integer 0, the floating point number 0.0, or a NULL
4051 ** pointer. Subsequent calls to [sqlite3_errcode()] will return
4052 ** [SQLITE_NOMEM].)^
4053 */
4054 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_blob(sqlite3_stmt*, int iCol);
4055 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes(sqlite3_stmt*, int iCol);
4056 SQLITE_API int SQLITE_STDCALL sqlite3_column_bytes16(sqlite3_stmt*, int iCol);
4057 SQLITE_API double SQLITE_STDCALL sqlite3_column_double(sqlite3_stmt*, int iCol);
4058 SQLITE_API int SQLITE_STDCALL sqlite3_column_int(sqlite3_stmt*, int iCol);
4059 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_column_int64(sqlite3_stmt*, int iCol);
4060 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_column_text(sqlite3_stmt*, int iCol);
4061 SQLITE_API const void *SQLITE_STDCALL sqlite3_column_text16(sqlite3_stmt*, int iCol);
4062 SQLITE_API int SQLITE_STDCALL sqlite3_column_type(sqlite3_stmt*, int iCol);
4063 SQLITE_API sqlite3_value *SQLITE_STDCALL sqlite3_column_value(sqlite3_stmt*, int iCol);
4064
4065 /*
4066 ** CAPI3REF: Destroy A Prepared Statement Object
4067 ** DESTRUCTOR: sqlite3_stmt
4068 **
4069 ** ^The sqlite3_finalize() function is called to delete a [prepared statement].
4070 ** ^If the most recent evaluation of the statement encountered no errors
4071 ** or if the statement is never been evaluated, then sqlite3_finalize() returns
4072 ** SQLITE_OK. ^If the most recent evaluation of statement S failed, then
@@ -4054,14 +4086,15 @@
4086 ** resource leaks. It is a grievous error for the application to try to use
4087 ** a prepared statement after it has been finalized. Any use of a prepared
4088 ** statement after it has been finalized can result in undefined and
4089 ** undesirable behavior such as segfaults and heap corruption.
4090 */
4091 SQLITE_API int SQLITE_STDCALL sqlite3_finalize(sqlite3_stmt *pStmt);
4092
4093 /*
4094 ** CAPI3REF: Reset A Prepared Statement Object
4095 ** METHOD: sqlite3_stmt
4096 **
4097 ** The sqlite3_reset() function is called to reset a [prepared statement]
4098 ** object back to its initial state, ready to be re-executed.
4099 ** ^Any SQL statement variables that had values bound to them using
4100 ** the [sqlite3_bind_blob | sqlite3_bind_*() API] retain their values.
@@ -4080,17 +4113,18 @@
4113 ** [sqlite3_reset(S)] returns an appropriate [error code].
4114 **
4115 ** ^The [sqlite3_reset(S)] interface does not change the values
4116 ** of any [sqlite3_bind_blob|bindings] on the [prepared statement] S.
4117 */
4118 SQLITE_API int SQLITE_STDCALL sqlite3_reset(sqlite3_stmt *pStmt);
4119
4120 /*
4121 ** CAPI3REF: Create Or Redefine SQL Functions
4122 ** KEYWORDS: {function creation routines}
4123 ** KEYWORDS: {application-defined SQL function}
4124 ** KEYWORDS: {application-defined SQL functions}
4125 ** METHOD: sqlite3
4126 **
4127 ** ^These functions (collectively known as "function creation routines")
4128 ** are used to add SQL functions or aggregates or to redefine the behavior
4129 ** of existing SQL functions or aggregates. The only differences between
4130 ** these routines are the text encoding expected for
@@ -4179,31 +4213,31 @@
4213 ** ^An application-defined function is permitted to call other
4214 ** SQLite interfaces. However, such calls must not
4215 ** close the database connection nor finalize or reset the prepared
4216 ** statement in which the function is running.
4217 */
4218 SQLITE_API int SQLITE_STDCALL sqlite3_create_function(
4219 sqlite3 *db,
4220 const char *zFunctionName,
4221 int nArg,
4222 int eTextRep,
4223 void *pApp,
4224 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4225 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4226 void (*xFinal)(sqlite3_context*)
4227 );
4228 SQLITE_API int SQLITE_STDCALL sqlite3_create_function16(
4229 sqlite3 *db,
4230 const void *zFunctionName,
4231 int nArg,
4232 int eTextRep,
4233 void *pApp,
4234 void (*xFunc)(sqlite3_context*,int,sqlite3_value**),
4235 void (*xStep)(sqlite3_context*,int,sqlite3_value**),
4236 void (*xFinal)(sqlite3_context*)
4237 );
4238 SQLITE_API int SQLITE_STDCALL sqlite3_create_function_v2(
4239 sqlite3 *db,
4240 const char *zFunctionName,
4241 int nArg,
4242 int eTextRep,
4243 void *pApp,
@@ -4245,21 +4279,22 @@
4279 ** to be supported. However, new applications should avoid
4280 ** the use of these functions. To encourage programmers to avoid
4281 ** these functions, we will not explain what they do.
4282 */
4283 #ifndef SQLITE_OMIT_DEPRECATED
4284 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_aggregate_count(sqlite3_context*);
4285 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_expired(sqlite3_stmt*);
4286 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_transfer_bindings(sqlite3_stmt*, sqlite3_stmt*);
4287 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_global_recover(void);
4288 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_thread_cleanup(void);
4289 SQLITE_API SQLITE_DEPRECATED int SQLITE_STDCALL sqlite3_memory_alarm(void(*)(void*,sqlite3_int64,int),
4290 void*,sqlite3_int64);
4291 #endif
4292
4293 /*
4294 ** CAPI3REF: Obtaining SQL Function Parameter Values
4295 ** METHOD: sqlite3_value
4296 **
4297 ** The C-language implementation of SQL functions and aggregates uses
4298 ** this set of interface routines to access the parameter values on
4299 ** the function or aggregate.
4300 **
@@ -4299,25 +4334,26 @@
4334 ** or [sqlite3_value_text16()].
4335 **
4336 ** These routines must be called from the same thread as
4337 ** the SQL function that supplied the [sqlite3_value*] parameters.
4338 */
4339 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_blob(sqlite3_value*);
4340 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes(sqlite3_value*);
4341 SQLITE_API int SQLITE_STDCALL sqlite3_value_bytes16(sqlite3_value*);
4342 SQLITE_API double SQLITE_STDCALL sqlite3_value_double(sqlite3_value*);
4343 SQLITE_API int SQLITE_STDCALL sqlite3_value_int(sqlite3_value*);
4344 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_value_int64(sqlite3_value*);
4345 SQLITE_API const unsigned char *SQLITE_STDCALL sqlite3_value_text(sqlite3_value*);
4346 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16(sqlite3_value*);
4347 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16le(sqlite3_value*);
4348 SQLITE_API const void *SQLITE_STDCALL sqlite3_value_text16be(sqlite3_value*);
4349 SQLITE_API int SQLITE_STDCALL sqlite3_value_type(sqlite3_value*);
4350 SQLITE_API int SQLITE_STDCALL sqlite3_value_numeric_type(sqlite3_value*);
4351
4352 /*
4353 ** CAPI3REF: Obtain Aggregate Function Context
4354 ** METHOD: sqlite3_context
4355 **
4356 ** Implementations of aggregate SQL functions use this
4357 ** routine to allocate memory for storing their state.
4358 **
4359 ** ^The first time the sqlite3_aggregate_context(C,N) routine is called
@@ -4354,14 +4390,15 @@
4390 ** function.
4391 **
4392 ** This routine must be called from the same thread in which
4393 ** the aggregate SQL function is running.
4394 */
4395 SQLITE_API void *SQLITE_STDCALL sqlite3_aggregate_context(sqlite3_context*, int nBytes);
4396
4397 /*
4398 ** CAPI3REF: User Data For Functions
4399 ** METHOD: sqlite3_context
4400 **
4401 ** ^The sqlite3_user_data() interface returns a copy of
4402 ** the pointer that was the pUserData parameter (the 5th parameter)
4403 ** of the [sqlite3_create_function()]
4404 ** and [sqlite3_create_function16()] routines that originally
@@ -4368,25 +4405,27 @@
4405 ** registered the application defined function.
4406 **
4407 ** This routine must be called from the same thread in which
4408 ** the application-defined function is running.
4409 */
4410 SQLITE_API void *SQLITE_STDCALL sqlite3_user_data(sqlite3_context*);
4411
4412 /*
4413 ** CAPI3REF: Database Connection For Functions
4414 ** METHOD: sqlite3_context
4415 **
4416 ** ^The sqlite3_context_db_handle() interface returns a copy of
4417 ** the pointer to the [database connection] (the 1st parameter)
4418 ** of the [sqlite3_create_function()]
4419 ** and [sqlite3_create_function16()] routines that originally
4420 ** registered the application defined function.
4421 */
4422 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
4423
4424 /*
4425 ** CAPI3REF: Function Auxiliary Data
4426 ** METHOD: sqlite3_context
4427 **
4428 ** These functions may be used by (non-aggregate) SQL functions to
4429 ** associate metadata with argument values. If the same value is passed to
4430 ** multiple invocations of the same SQL function during query execution, under
4431 ** some circumstances the associated metadata may be preserved. An example
@@ -4431,12 +4470,12 @@
4470 ** values and [parameters] and expressions composed from the same.)^
4471 **
4472 ** These routines must be called from the same thread in which
4473 ** the SQL function is running.
4474 */
4475 SQLITE_API void *SQLITE_STDCALL sqlite3_get_auxdata(sqlite3_context*, int N);
4476 SQLITE_API void SQLITE_STDCALL sqlite3_set_auxdata(sqlite3_context*, int N, void*, void (*)(void*));
4477
4478
4479 /*
4480 ** CAPI3REF: Constants Defining Special Destructor Behavior
4481 **
@@ -4455,10 +4494,11 @@
4494 #define SQLITE_STATIC ((sqlite3_destructor_type)0)
4495 #define SQLITE_TRANSIENT ((sqlite3_destructor_type)-1)
4496
4497 /*
4498 ** CAPI3REF: Setting The Result Of An SQL Function
4499 ** METHOD: sqlite3_context
4500 **
4501 ** These routines are used by the xFunc or xFinal callbacks that
4502 ** implement SQL functions and aggregates. See
4503 ** [sqlite3_create_function()] and [sqlite3_create_function16()]
4504 ** for additional information.
@@ -4567,33 +4607,34 @@
4607 **
4608 ** If these routines are called from within the different thread
4609 ** than the one containing the application-defined function that received
4610 ** the [sqlite3_context] pointer, the results are undefined.
4611 */
4612 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob(sqlite3_context*, const void*, int, void(*)(void*));
4613 SQLITE_API void SQLITE_STDCALL sqlite3_result_blob64(sqlite3_context*,const void*,
4614 sqlite3_uint64,void(*)(void*));
4615 SQLITE_API void SQLITE_STDCALL sqlite3_result_double(sqlite3_context*, double);
4616 SQLITE_API void SQLITE_STDCALL sqlite3_result_error(sqlite3_context*, const char*, int);
4617 SQLITE_API void SQLITE_STDCALL sqlite3_result_error16(sqlite3_context*, const void*, int);
4618 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_toobig(sqlite3_context*);
4619 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_nomem(sqlite3_context*);
4620 SQLITE_API void SQLITE_STDCALL sqlite3_result_error_code(sqlite3_context*, int);
4621 SQLITE_API void SQLITE_STDCALL sqlite3_result_int(sqlite3_context*, int);
4622 SQLITE_API void SQLITE_STDCALL sqlite3_result_int64(sqlite3_context*, sqlite3_int64);
4623 SQLITE_API void SQLITE_STDCALL sqlite3_result_null(sqlite3_context*);
4624 SQLITE_API void SQLITE_STDCALL sqlite3_result_text(sqlite3_context*, const char*, int, void(*)(void*));
4625 SQLITE_API void SQLITE_STDCALL sqlite3_result_text64(sqlite3_context*, const char*,sqlite3_uint64,
4626 void(*)(void*), unsigned char encoding);
4627 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16(sqlite3_context*, const void*, int, void(*)(void*));
4628 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16le(sqlite3_context*, const void*, int,void(*)(void*));
4629 SQLITE_API void SQLITE_STDCALL sqlite3_result_text16be(sqlite3_context*, const void*, int,void(*)(void*));
4630 SQLITE_API void SQLITE_STDCALL sqlite3_result_value(sqlite3_context*, sqlite3_value*);
4631 SQLITE_API void SQLITE_STDCALL sqlite3_result_zeroblob(sqlite3_context*, int n);
4632
4633 /*
4634 ** CAPI3REF: Define New Collating Sequences
4635 ** METHOD: sqlite3
4636 **
4637 ** ^These functions add, remove, or modify a [collation] associated
4638 ** with the [database connection] specified as the first argument.
4639 **
4640 ** ^The name of the collation is a UTF-8 string
@@ -4667,35 +4708,36 @@
4708 ** is unfortunate but cannot be changed without breaking backwards
4709 ** compatibility.
4710 **
4711 ** See also: [sqlite3_collation_needed()] and [sqlite3_collation_needed16()].
4712 */
4713 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation(
4714 sqlite3*,
4715 const char *zName,
4716 int eTextRep,
4717 void *pArg,
4718 int(*xCompare)(void*,int,const void*,int,const void*)
4719 );
4720 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation_v2(
4721 sqlite3*,
4722 const char *zName,
4723 int eTextRep,
4724 void *pArg,
4725 int(*xCompare)(void*,int,const void*,int,const void*),
4726 void(*xDestroy)(void*)
4727 );
4728 SQLITE_API int SQLITE_STDCALL sqlite3_create_collation16(
4729 sqlite3*,
4730 const void *zName,
4731 int eTextRep,
4732 void *pArg,
4733 int(*xCompare)(void*,int,const void*,int,const void*)
4734 );
4735
4736 /*
4737 ** CAPI3REF: Collation Needed Callbacks
4738 ** METHOD: sqlite3
4739 **
4740 ** ^To avoid having to register all collation sequences before a database
4741 ** can be used, a single callback function may be registered with the
4742 ** [database connection] to be invoked whenever an undefined collation
4743 ** sequence is required.
@@ -4716,16 +4758,16 @@
4758 **
4759 ** The callback function should register the desired collation using
4760 ** [sqlite3_create_collation()], [sqlite3_create_collation16()], or
4761 ** [sqlite3_create_collation_v2()].
4762 */
4763 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed(
4764 sqlite3*,
4765 void*,
4766 void(*)(void*,sqlite3*,int eTextRep,const char*)
4767 );
4768 SQLITE_API int SQLITE_STDCALL sqlite3_collation_needed16(
4769 sqlite3*,
4770 void*,
4771 void(*)(void*,sqlite3*,int eTextRep,const void*)
4772 );
4773
@@ -4735,15 +4777,15 @@
4777 ** called right after sqlite3_open().
4778 **
4779 ** The code to implement this API is not available in the public release
4780 ** of SQLite.
4781 */
4782 SQLITE_API int SQLITE_STDCALL sqlite3_key(
4783 sqlite3 *db, /* Database to be rekeyed */
4784 const void *pKey, int nKey /* The key */
4785 );
4786 SQLITE_API int SQLITE_STDCALL sqlite3_key_v2(
4787 sqlite3 *db, /* Database to be rekeyed */
4788 const char *zDbName, /* Name of the database */
4789 const void *pKey, int nKey /* The key */
4790 );
4791
@@ -4753,35 +4795,35 @@
4795 ** database is decrypted.
4796 **
4797 ** The code to implement this API is not available in the public release
4798 ** of SQLite.
4799 */
4800 SQLITE_API int SQLITE_STDCALL sqlite3_rekey(
4801 sqlite3 *db, /* Database to be rekeyed */
4802 const void *pKey, int nKey /* The new key */
4803 );
4804 SQLITE_API int SQLITE_STDCALL sqlite3_rekey_v2(
4805 sqlite3 *db, /* Database to be rekeyed */
4806 const char *zDbName, /* Name of the database */
4807 const void *pKey, int nKey /* The new key */
4808 );
4809
4810 /*
4811 ** Specify the activation key for a SEE database. Unless
4812 ** activated, none of the SEE routines will work.
4813 */
4814 SQLITE_API void SQLITE_STDCALL sqlite3_activate_see(
4815 const char *zPassPhrase /* Activation phrase */
4816 );
4817 #endif
4818
4819 #ifdef SQLITE_ENABLE_CEROD
4820 /*
4821 ** Specify the activation key for a CEROD database. Unless
4822 ** activated, none of the CEROD routines will work.
4823 */
4824 SQLITE_API void SQLITE_STDCALL sqlite3_activate_cerod(
4825 const char *zPassPhrase /* Activation phrase */
4826 );
4827 #endif
4828
4829 /*
@@ -4799,11 +4841,11 @@
4841 ** method of the default [sqlite3_vfs] object. If the xSleep() method
4842 ** of the default VFS is not implemented correctly, or not implemented at
4843 ** all, then the behavior of sqlite3_sleep() may deviate from the description
4844 ** in the previous paragraphs.
4845 */
4846 SQLITE_API int SQLITE_STDCALL sqlite3_sleep(int);
4847
4848 /*
4849 ** CAPI3REF: Name Of The Folder Holding Temporary Files
4850 **
4851 ** ^(If this global variable is made to point to a string which is
@@ -4899,10 +4941,11 @@
4941 SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
4942
4943 /*
4944 ** CAPI3REF: Test For Auto-Commit Mode
4945 ** KEYWORDS: {autocommit mode}
4946 ** METHOD: sqlite3
4947 **
4948 ** ^The sqlite3_get_autocommit() interface returns non-zero or
4949 ** zero if the given database connection is or is not in autocommit mode,
4950 ** respectively. ^Autocommit mode is on by default.
4951 ** ^Autocommit mode is disabled by a [BEGIN] statement.
@@ -4917,26 +4960,28 @@
4960 **
4961 ** If another thread changes the autocommit status of the database
4962 ** connection while this routine is running, then the return value
4963 ** is undefined.
4964 */
4965 SQLITE_API int SQLITE_STDCALL sqlite3_get_autocommit(sqlite3*);
4966
4967 /*
4968 ** CAPI3REF: Find The Database Handle Of A Prepared Statement
4969 ** METHOD: sqlite3_stmt
4970 **
4971 ** ^The sqlite3_db_handle interface returns the [database connection] handle
4972 ** to which a [prepared statement] belongs. ^The [database connection]
4973 ** returned by sqlite3_db_handle is the same [database connection]
4974 ** that was the first argument
4975 ** to the [sqlite3_prepare_v2()] call (or its variants) that was used to
4976 ** create the statement in the first place.
4977 */
4978 SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_db_handle(sqlite3_stmt*);
4979
4980 /*
4981 ** CAPI3REF: Return The Filename For A Database Connection
4982 ** METHOD: sqlite3
4983 **
4984 ** ^The sqlite3_db_filename(D,N) interface returns a pointer to a filename
4985 ** associated with database N of connection D. ^The main database file
4986 ** has the name "main". If there is no attached database N on the database
4987 ** connection D, or if database N is a temporary or in-memory database, then
@@ -4945,23 +4990,25 @@
4990 ** ^The filename returned by this function is the output of the
4991 ** xFullPathname method of the [VFS]. ^In other words, the filename
4992 ** will be an absolute pathname, even if the filename used
4993 ** to open the database originally was a URI or relative pathname.
4994 */
4995 SQLITE_API const char *SQLITE_STDCALL sqlite3_db_filename(sqlite3 *db, const char *zDbName);
4996
4997 /*
4998 ** CAPI3REF: Determine if a database is read-only
4999 ** METHOD: sqlite3
5000 **
5001 ** ^The sqlite3_db_readonly(D,N) interface returns 1 if the database N
5002 ** of connection D is read-only, 0 if it is read/write, or -1 if N is not
5003 ** the name of a database on connection D.
5004 */
5005 SQLITE_API int SQLITE_STDCALL sqlite3_db_readonly(sqlite3 *db, const char *zDbName);
5006
5007 /*
5008 ** CAPI3REF: Find the next prepared statement
5009 ** METHOD: sqlite3
5010 **
5011 ** ^This interface returns a pointer to the next [prepared statement] after
5012 ** pStmt associated with the [database connection] pDb. ^If pStmt is NULL
5013 ** then this interface returns a pointer to the first prepared statement
5014 ** associated with the database connection pDb. ^If no prepared statement
@@ -4969,14 +5016,15 @@
5016 **
5017 ** The [database connection] pointer D in a call to
5018 ** [sqlite3_next_stmt(D,S)] must refer to an open database
5019 ** connection and in particular must not be a NULL pointer.
5020 */
5021 SQLITE_API sqlite3_stmt *SQLITE_STDCALL sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt);
5022
5023 /*
5024 ** CAPI3REF: Commit And Rollback Notification Callbacks
5025 ** METHOD: sqlite3
5026 **
5027 ** ^The sqlite3_commit_hook() interface registers a callback
5028 ** function to be invoked whenever a transaction is [COMMIT | committed].
5029 ** ^Any callback set by a previous call to sqlite3_commit_hook()
5030 ** for the same database connection is overridden.
@@ -5017,15 +5065,16 @@
5065 ** ^The rollback callback is not invoked if a transaction is
5066 ** automatically rolled back because the database connection is closed.
5067 **
5068 ** See also the [sqlite3_update_hook()] interface.
5069 */
5070 SQLITE_API void *SQLITE_STDCALL sqlite3_commit_hook(sqlite3*, int(*)(void*), void*);
5071 SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *), void*);
5072
5073 /*
5074 ** CAPI3REF: Data Change Notification Callbacks
5075 ** METHOD: sqlite3
5076 **
5077 ** ^The sqlite3_update_hook() interface registers a callback function
5078 ** with the [database connection] identified by the first argument
5079 ** to be invoked whenever a row is updated, inserted or deleted in
5080 ** a rowid table.
@@ -5068,11 +5117,11 @@
5117 ** the first call on D.
5118 **
5119 ** See also the [sqlite3_commit_hook()] and [sqlite3_rollback_hook()]
5120 ** interfaces.
5121 */
5122 SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
5123 sqlite3*,
5124 void(*)(void *,int ,char const *,char const *,sqlite3_int64),
5125 void*
5126 );
5127
@@ -5108,11 +5157,11 @@
5157 ** This interface is threadsafe on processors where writing a
5158 ** 32-bit integer is atomic.
5159 **
5160 ** See Also: [SQLite Shared-Cache Mode]
5161 */
5162 SQLITE_API int SQLITE_STDCALL sqlite3_enable_shared_cache(int);
5163
5164 /*
5165 ** CAPI3REF: Attempt To Free Heap Memory
5166 **
5167 ** ^The sqlite3_release_memory() interface attempts to free N bytes
@@ -5124,24 +5173,25 @@
5173 ** ^The sqlite3_release_memory() routine is a no-op returning zero
5174 ** if SQLite is not compiled with [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5175 **
5176 ** See also: [sqlite3_db_release_memory()]
5177 */
5178 SQLITE_API int SQLITE_STDCALL sqlite3_release_memory(int);
5179
5180 /*
5181 ** CAPI3REF: Free Memory Used By A Database Connection
5182 ** METHOD: sqlite3
5183 **
5184 ** ^The sqlite3_db_release_memory(D) interface attempts to free as much heap
5185 ** memory as possible from database connection D. Unlike the
5186 ** [sqlite3_release_memory()] interface, this interface is in effect even
5187 ** when the [SQLITE_ENABLE_MEMORY_MANAGEMENT] compile-time option is
5188 ** omitted.
5189 **
5190 ** See also: [sqlite3_release_memory()]
5191 */
5192 SQLITE_API int SQLITE_STDCALL sqlite3_db_release_memory(sqlite3*);
5193
5194 /*
5195 ** CAPI3REF: Impose A Limit On Heap Size
5196 **
5197 ** ^The sqlite3_soft_heap_limit64() interface sets and/or queries the
@@ -5189,11 +5239,11 @@
5239 ** the use of [SQLITE_ENABLE_MEMORY_MANAGEMENT].
5240 **
5241 ** The circumstances under which SQLite will enforce the soft heap limit may
5242 ** changes in future releases of SQLite.
5243 */
5244 SQLITE_API sqlite3_int64 SQLITE_STDCALL sqlite3_soft_heap_limit64(sqlite3_int64 N);
5245
5246 /*
5247 ** CAPI3REF: Deprecated Soft Heap Limit Interface
5248 ** DEPRECATED
5249 **
@@ -5200,15 +5250,16 @@
5250 ** This is a deprecated version of the [sqlite3_soft_heap_limit64()]
5251 ** interface. This routine is provided for historical compatibility
5252 ** only. All new applications should use the
5253 ** [sqlite3_soft_heap_limit64()] interface rather than this one.
5254 */
5255 SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
5256
5257
5258 /*
5259 ** CAPI3REF: Extract Metadata About A Column Of A Table
5260 ** METHOD: sqlite3
5261 **
5262 ** ^(The sqlite3_table_column_metadata(X,D,T,C,....) routine returns
5263 ** information about column C of table T in database D
5264 ** on [database connection] X.)^ ^The sqlite3_table_column_metadata()
5265 ** interface returns SQLITE_OK and fills in the non-NULL pointers in
@@ -5269,11 +5320,11 @@
5320 **
5321 ** ^This function causes all database schemas to be read from disk and
5322 ** parsed, if that has not already been done, and returns an error if
5323 ** any errors are encountered while loading the schema.
5324 */
5325 SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
5326 sqlite3 *db, /* Connection handle */
5327 const char *zDbName, /* Database name or NULL */
5328 const char *zTableName, /* Table name */
5329 const char *zColumnName, /* Column name */
5330 char const **pzDataType, /* OUTPUT: Declared data type */
@@ -5283,10 +5334,11 @@
5334 int *pAutoinc /* OUTPUT: True if column is auto-increment */
5335 );
5336
5337 /*
5338 ** CAPI3REF: Load An Extension
5339 ** METHOD: sqlite3
5340 **
5341 ** ^This interface loads an SQLite extension library from the named file.
5342 **
5343 ** ^The sqlite3_load_extension() interface attempts to load an
5344 ** [SQLite extension] library contained in the file zFile. If
@@ -5315,19 +5367,20 @@
5367 ** [sqlite3_enable_load_extension()] prior to calling this API,
5368 ** otherwise an error will be returned.
5369 **
5370 ** See also the [load_extension() SQL function].
5371 */
5372 SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
5373 sqlite3 *db, /* Load the extension into this database connection */
5374 const char *zFile, /* Name of the shared library containing extension */
5375 const char *zProc, /* Entry point. Derived from zFile if 0 */
5376 char **pzErrMsg /* Put error message here if not 0 */
5377 );
5378
5379 /*
5380 ** CAPI3REF: Enable Or Disable Extension Loading
5381 ** METHOD: sqlite3
5382 **
5383 ** ^So as not to open security holes in older applications that are
5384 ** unprepared to deal with [extension loading], and as a means of disabling
5385 ** [extension loading] while evaluating user-entered SQL, the following API
5386 ** is provided to turn the [sqlite3_load_extension()] mechanism on and off.
@@ -5335,11 +5388,11 @@
5388 ** ^Extension loading is off by default.
5389 ** ^Call the sqlite3_enable_load_extension() routine with onoff==1
5390 ** to turn extension loading on and call it with onoff==0 to turn
5391 ** it back off again.
5392 */
5393 SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
5394
5395 /*
5396 ** CAPI3REF: Automatically Load Statically Linked Extensions
5397 **
5398 ** ^This interface causes the xEntryPoint() function to be invoked for
@@ -5373,11 +5426,11 @@
5426 ** will be called more than once for each database connection that is opened.
5427 **
5428 ** See also: [sqlite3_reset_auto_extension()]
5429 ** and [sqlite3_cancel_auto_extension()]
5430 */
5431 SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
5432
5433 /*
5434 ** CAPI3REF: Cancel Automatic Extension Loading
5435 **
5436 ** ^The [sqlite3_cancel_auto_extension(X)] interface unregisters the
@@ -5385,19 +5438,19 @@
5438 ** [sqlite3_auto_extension(X)]. ^The [sqlite3_cancel_auto_extension(X)]
5439 ** routine returns 1 if initialization routine X was successfully
5440 ** unregistered and it returns 0 if X was not on the list of initialization
5441 ** routines.
5442 */
5443 SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void (*xEntryPoint)(void));
5444
5445 /*
5446 ** CAPI3REF: Reset Automatic Extension Loading
5447 **
5448 ** ^This interface disables all automatic extensions previously
5449 ** registered using [sqlite3_auto_extension()].
5450 */
5451 SQLITE_API void SQLITE_STDCALL sqlite3_reset_auto_extension(void);
5452
5453 /*
5454 ** The interface to the virtual-table mechanism is currently considered
5455 ** to be experimental. The interface might change in incompatible ways.
5456 ** If this is a problem for you, do not use the interface at this time.
@@ -5573,10 +5626,11 @@
5626 #define SQLITE_INDEX_CONSTRAINT_GE 32
5627 #define SQLITE_INDEX_CONSTRAINT_MATCH 64
5628
5629 /*
5630 ** CAPI3REF: Register A Virtual Table Implementation
5631 ** METHOD: sqlite3
5632 **
5633 ** ^These routines are used to register a new [virtual table module] name.
5634 ** ^Module names must be registered before
5635 ** creating a new [virtual table] using the module and before using a
5636 ** preexisting [virtual table] for the module.
@@ -5596,17 +5650,17 @@
5650 ** be invoked if the call to sqlite3_create_module_v2() fails.
5651 ** ^The sqlite3_create_module()
5652 ** interface is equivalent to sqlite3_create_module_v2() with a NULL
5653 ** destructor.
5654 */
5655 SQLITE_API int SQLITE_STDCALL sqlite3_create_module(
5656 sqlite3 *db, /* SQLite connection to register module with */
5657 const char *zName, /* Name of the module */
5658 const sqlite3_module *p, /* Methods for the module */
5659 void *pClientData /* Client data for xCreate/xConnect */
5660 );
5661 SQLITE_API int SQLITE_STDCALL sqlite3_create_module_v2(
5662 sqlite3 *db, /* SQLite connection to register module with */
5663 const char *zName, /* Name of the module */
5664 const sqlite3_module *p, /* Methods for the module */
5665 void *pClientData, /* Client data for xCreate/xConnect */
5666 void(*xDestroy)(void*) /* Module destructor function */
@@ -5665,14 +5719,15 @@
5719 ** ^The [xCreate] and [xConnect] methods of a
5720 ** [virtual table module] call this interface
5721 ** to declare the format (the names and datatypes of the columns) of
5722 ** the virtual tables they implement.
5723 */
5724 SQLITE_API int SQLITE_STDCALL sqlite3_declare_vtab(sqlite3*, const char *zSQL);
5725
5726 /*
5727 ** CAPI3REF: Overload A Function For A Virtual Table
5728 ** METHOD: sqlite3
5729 **
5730 ** ^(Virtual tables can provide alternative implementations of functions
5731 ** using the [xFindFunction] method of the [virtual table module].
5732 ** But global versions of those functions
5733 ** must exist in order to be overloaded.)^
@@ -5683,11 +5738,11 @@
5738 ** of the new function always causes an exception to be thrown. So
5739 ** the new function is not good for anything by itself. Its only
5740 ** purpose is to be a placeholder function that can be overloaded
5741 ** by a [virtual table].
5742 */
5743 SQLITE_API int SQLITE_STDCALL sqlite3_overload_function(sqlite3*, const char *zFuncName, int nArg);
5744
5745 /*
5746 ** The interface to the virtual-table mechanism defined above (back up
5747 ** to a comment remarkably similar to this one) is currently considered
5748 ** to be experimental. The interface might change in incompatible ways.
@@ -5711,10 +5766,12 @@
5766 */
5767 typedef struct sqlite3_blob sqlite3_blob;
5768
5769 /*
5770 ** CAPI3REF: Open A BLOB For Incremental I/O
5771 ** METHOD: sqlite3
5772 ** CONSTRUCTOR: sqlite3_blob
5773 **
5774 ** ^(This interfaces opens a [BLOB handle | handle] to the BLOB located
5775 ** in row iRow, column zColumn, table zTable in database zDb;
5776 ** in other words, the same BLOB that would be selected by:
5777 **
@@ -5780,11 +5837,11 @@
5837 ** zero-filled blob to read or write using the incremental-blob interface.
5838 **
5839 ** To avoid a resource leak, every open [BLOB handle] should eventually
5840 ** be released by a call to [sqlite3_blob_close()].
5841 */
5842 SQLITE_API int SQLITE_STDCALL sqlite3_blob_open(
5843 sqlite3*,
5844 const char *zDb,
5845 const char *zTable,
5846 const char *zColumn,
5847 sqlite3_int64 iRow,
@@ -5792,10 +5849,11 @@
5849 sqlite3_blob **ppBlob
5850 );
5851
5852 /*
5853 ** CAPI3REF: Move a BLOB Handle to a New Row
5854 ** METHOD: sqlite3_blob
5855 **
5856 ** ^This function is used to move an existing blob handle so that it points
5857 ** to a different row of the same database table. ^The new row is identified
5858 ** by the rowid value passed as the second argument. Only the row can be
5859 ** changed. ^The database, table and column on which the blob handle is open
@@ -5812,14 +5870,15 @@
5870 ** SQLITE_ABORT. ^Calling [sqlite3_blob_bytes()] on an aborted blob handle
5871 ** always returns zero.
5872 **
5873 ** ^This function sets the database handle error code and message.
5874 */
5875 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_blob_reopen(sqlite3_blob *, sqlite3_int64);
5876
5877 /*
5878 ** CAPI3REF: Close A BLOB Handle
5879 ** DESTRUCTOR: sqlite3_blob
5880 **
5881 ** ^This function closes an open [BLOB handle]. ^(The BLOB handle is closed
5882 ** unconditionally. Even if this routine returns an error code, the
5883 ** handle is still closed.)^
5884 **
@@ -5834,14 +5893,15 @@
5893 ** with a null pointer (such as would be returned by a failed call to
5894 ** [sqlite3_blob_open()]) is a harmless no-op. ^Otherwise, if this function
5895 ** is passed a valid open blob handle, the values returned by the
5896 ** sqlite3_errcode() and sqlite3_errmsg() functions are set before returning.
5897 */
5898 SQLITE_API int SQLITE_STDCALL sqlite3_blob_close(sqlite3_blob *);
5899
5900 /*
5901 ** CAPI3REF: Return The Size Of An Open BLOB
5902 ** METHOD: sqlite3_blob
5903 **
5904 ** ^Returns the size in bytes of the BLOB accessible via the
5905 ** successfully opened [BLOB handle] in its only argument. ^The
5906 ** incremental blob I/O routines can only read or overwriting existing
5907 ** blob content; they cannot change the size of a blob.
@@ -5849,14 +5909,15 @@
5909 ** This routine only works on a [BLOB handle] which has been created
5910 ** by a prior successful call to [sqlite3_blob_open()] and which has not
5911 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5912 ** to this routine results in undefined and probably undesirable behavior.
5913 */
5914 SQLITE_API int SQLITE_STDCALL sqlite3_blob_bytes(sqlite3_blob *);
5915
5916 /*
5917 ** CAPI3REF: Read Data From A BLOB Incrementally
5918 ** METHOD: sqlite3_blob
5919 **
5920 ** ^(This function is used to read data from an open [BLOB handle] into a
5921 ** caller-supplied buffer. N bytes of data are copied into buffer Z
5922 ** from the open BLOB, starting at offset iOffset.)^
5923 **
@@ -5877,14 +5938,15 @@
5938 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5939 ** to this routine results in undefined and probably undesirable behavior.
5940 **
5941 ** See also: [sqlite3_blob_write()].
5942 */
5943 SQLITE_API int SQLITE_STDCALL sqlite3_blob_read(sqlite3_blob *, void *Z, int N, int iOffset);
5944
5945 /*
5946 ** CAPI3REF: Write Data Into A BLOB Incrementally
5947 ** METHOD: sqlite3_blob
5948 **
5949 ** ^(This function is used to write data into an open [BLOB handle] from a
5950 ** caller-supplied buffer. N bytes of data are copied from the buffer Z
5951 ** into the open BLOB, starting at offset iOffset.)^
5952 **
@@ -5918,11 +5980,11 @@
5980 ** been closed by [sqlite3_blob_close()]. Passing any other pointer in
5981 ** to this routine results in undefined and probably undesirable behavior.
5982 **
5983 ** See also: [sqlite3_blob_read()].
5984 */
5985 SQLITE_API int SQLITE_STDCALL sqlite3_blob_write(sqlite3_blob *, const void *z, int n, int iOffset);
5986
5987 /*
5988 ** CAPI3REF: Virtual File System Objects
5989 **
5990 ** A virtual filesystem (VFS) is an [sqlite3_vfs] object
@@ -5949,13 +6011,13 @@
6011 **
6012 ** ^Unregister a VFS with the sqlite3_vfs_unregister() interface.
6013 ** ^(If the default VFS is unregistered, another VFS is chosen as
6014 ** the default. The choice for the new VFS is arbitrary.)^
6015 */
6016 SQLITE_API sqlite3_vfs *SQLITE_STDCALL sqlite3_vfs_find(const char *zVfsName);
6017 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_register(sqlite3_vfs*, int makeDflt);
6018 SQLITE_API int SQLITE_STDCALL sqlite3_vfs_unregister(sqlite3_vfs*);
6019
6020 /*
6021 ** CAPI3REF: Mutexes
6022 **
6023 ** The SQLite core uses these routines for thread
@@ -6064,15 +6126,15 @@
6126 ** sqlite3_mutex_leave() is a NULL pointer, then all three routines
6127 ** behave as no-ops.
6128 **
6129 ** See also: [sqlite3_mutex_held()] and [sqlite3_mutex_notheld()].
6130 */
6131 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_mutex_alloc(int);
6132 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_free(sqlite3_mutex*);
6133 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_enter(sqlite3_mutex*);
6134 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_try(sqlite3_mutex*);
6135 SQLITE_API void SQLITE_STDCALL sqlite3_mutex_leave(sqlite3_mutex*);
6136
6137 /*
6138 ** CAPI3REF: Mutex Methods Object
6139 **
6140 ** An instance of this structure defines the low-level routines
@@ -6178,12 +6240,12 @@
6240 ** call to sqlite3_mutex_held() to fail, so a non-zero return is
6241 ** the appropriate thing to do. The sqlite3_mutex_notheld()
6242 ** interface should also return 1 when given a NULL pointer.
6243 */
6244 #ifndef NDEBUG
6245 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_held(sqlite3_mutex*);
6246 SQLITE_API int SQLITE_STDCALL sqlite3_mutex_notheld(sqlite3_mutex*);
6247 #endif
6248
6249 /*
6250 ** CAPI3REF: Mutex Types
6251 **
@@ -6208,21 +6270,23 @@
6270 #define SQLITE_MUTEX_STATIC_APP2 9 /* For use by application */
6271 #define SQLITE_MUTEX_STATIC_APP3 10 /* For use by application */
6272
6273 /*
6274 ** CAPI3REF: Retrieve the mutex for a database connection
6275 ** METHOD: sqlite3
6276 **
6277 ** ^This interface returns a pointer the [sqlite3_mutex] object that
6278 ** serializes access to the [database connection] given in the argument
6279 ** when the [threading mode] is Serialized.
6280 ** ^If the [threading mode] is Single-thread or Multi-thread then this
6281 ** routine returns a NULL pointer.
6282 */
6283 SQLITE_API sqlite3_mutex *SQLITE_STDCALL sqlite3_db_mutex(sqlite3*);
6284
6285 /*
6286 ** CAPI3REF: Low-Level Control Of Database Files
6287 ** METHOD: sqlite3
6288 **
6289 ** ^The [sqlite3_file_control()] interface makes a direct call to the
6290 ** xFileControl method for the [sqlite3_io_methods] object associated
6291 ** with a particular database identified by the second argument. ^The
6292 ** name of the database is "main" for the main database or "temp" for the
@@ -6249,11 +6313,11 @@
6313 ** an incorrect zDbName and an SQLITE_ERROR return from the underlying
6314 ** xFileControl method.
6315 **
6316 ** See also: [SQLITE_FCNTL_LOCKSTATE]
6317 */
6318 SQLITE_API int SQLITE_STDCALL sqlite3_file_control(sqlite3*, const char *zDbName, int op, void*);
6319
6320 /*
6321 ** CAPI3REF: Testing Interface
6322 **
6323 ** ^The sqlite3_test_control() interface is used to read out internal
@@ -6268,11 +6332,11 @@
6332 ** The details of the operation codes, their meanings, the parameters
6333 ** they take, and what they do are all subject to change without notice.
6334 ** Unlike most of the SQLite API, this function is not guaranteed to
6335 ** operate consistently from one release to the next.
6336 */
6337 SQLITE_API int SQLITE_CDECL sqlite3_test_control(int op, ...);
6338
6339 /*
6340 ** CAPI3REF: Testing Interface Operation Codes
6341 **
6342 ** These constants are the valid operation code parameters used
@@ -6331,12 +6395,12 @@
6395 ** be represented by a 32-bit integer, then the values returned by
6396 ** sqlite3_status() are undefined.
6397 **
6398 ** See also: [sqlite3_db_status()]
6399 */
6400 SQLITE_API int SQLITE_STDCALL sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag);
6401 SQLITE_API int SQLITE_STDCALL sqlite3_status64(
6402 int op,
6403 sqlite3_int64 *pCurrent,
6404 sqlite3_int64 *pHighwater,
6405 int resetFlag
6406 );
@@ -6435,10 +6499,11 @@
6499 #define SQLITE_STATUS_SCRATCH_SIZE 8
6500 #define SQLITE_STATUS_MALLOC_COUNT 9
6501
6502 /*
6503 ** CAPI3REF: Database Connection Status
6504 ** METHOD: sqlite3
6505 **
6506 ** ^This interface is used to retrieve runtime status information
6507 ** about a single [database connection]. ^The first argument is the
6508 ** database connection object to be interrogated. ^The second argument
6509 ** is an integer constant, taken from the set of
@@ -6455,11 +6520,11 @@
6520 ** ^The sqlite3_db_status() routine returns SQLITE_OK on success and a
6521 ** non-zero [error code] on failure.
6522 **
6523 ** See also: [sqlite3_status()] and [sqlite3_stmt_status()].
6524 */
6525 SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int *pHiwtr, int resetFlg);
6526
6527 /*
6528 ** CAPI3REF: Status Parameters for database connections
6529 ** KEYWORDS: {SQLITE_DBSTATUS options}
6530 **
@@ -6563,10 +6628,11 @@
6628 #define SQLITE_DBSTATUS_MAX 10 /* Largest defined DBSTATUS */
6629
6630
6631 /*
6632 ** CAPI3REF: Prepared Statement Status
6633 ** METHOD: sqlite3_stmt
6634 **
6635 ** ^(Each prepared statement maintains various
6636 ** [SQLITE_STMTSTATUS counters] that measure the number
6637 ** of times it has performed specific operations.)^ These counters can
6638 ** be used to monitor the performance characteristics of the prepared
@@ -6584,11 +6650,11 @@
6650 ** ^If the resetFlg is true, then the counter is reset to zero after this
6651 ** interface call returns.
6652 **
6653 ** See also: [sqlite3_status()] and [sqlite3_db_status()].
6654 */
6655 SQLITE_API int SQLITE_STDCALL sqlite3_stmt_status(sqlite3_stmt*, int op,int resetFlg);
6656
6657 /*
6658 ** CAPI3REF: Status Parameters for prepared statements
6659 ** KEYWORDS: {SQLITE_STMTSTATUS counter} {SQLITE_STMTSTATUS counters}
6660 **
@@ -7053,23 +7119,24 @@
7119 ** However, the sqlite3_backup_remaining() and sqlite3_backup_pagecount()
7120 ** APIs are not strictly speaking threadsafe. If they are invoked at the
7121 ** same time as another thread is invoking sqlite3_backup_step() it is
7122 ** possible that they return invalid values.
7123 */
7124 SQLITE_API sqlite3_backup *SQLITE_STDCALL sqlite3_backup_init(
7125 sqlite3 *pDest, /* Destination database handle */
7126 const char *zDestName, /* Destination database name */
7127 sqlite3 *pSource, /* Source database handle */
7128 const char *zSourceName /* Source database name */
7129 );
7130 SQLITE_API int SQLITE_STDCALL sqlite3_backup_step(sqlite3_backup *p, int nPage);
7131 SQLITE_API int SQLITE_STDCALL sqlite3_backup_finish(sqlite3_backup *p);
7132 SQLITE_API int SQLITE_STDCALL sqlite3_backup_remaining(sqlite3_backup *p);
7133 SQLITE_API int SQLITE_STDCALL sqlite3_backup_pagecount(sqlite3_backup *p);
7134
7135 /*
7136 ** CAPI3REF: Unlock Notification
7137 ** METHOD: sqlite3
7138 **
7139 ** ^When running in shared-cache mode, a database operation may fail with
7140 ** an [SQLITE_LOCKED] error if the required locks on the shared-cache or
7141 ** individual tables within the shared-cache cannot be obtained. See
7142 ** [SQLite Shared-Cache Mode] for a description of shared-cache locking.
@@ -7178,11 +7245,11 @@
7245 ** by an sqlite3_step() call. ^(If there is a blocking connection, then the
7246 ** extended error code is set to SQLITE_LOCKED_SHAREDCACHE. Otherwise, in
7247 ** the special "DROP TABLE/INDEX" case, the extended error code is just
7248 ** SQLITE_LOCKED.)^
7249 */
7250 SQLITE_API int SQLITE_STDCALL sqlite3_unlock_notify(
7251 sqlite3 *pBlocked, /* Waiting connection */
7252 void (*xNotify)(void **apArg, int nArg), /* Callback function to invoke */
7253 void *pNotifyArg /* Argument to pass to xNotify */
7254 );
7255
@@ -7193,12 +7260,12 @@
7260 ** ^The [sqlite3_stricmp()] and [sqlite3_strnicmp()] APIs allow applications
7261 ** and extensions to compare the contents of two buffers containing UTF-8
7262 ** strings in a case-independent fashion, using the same definition of "case
7263 ** independence" that SQLite uses internally when comparing identifiers.
7264 */
7265 SQLITE_API int SQLITE_STDCALL sqlite3_stricmp(const char *, const char *);
7266 SQLITE_API int SQLITE_STDCALL sqlite3_strnicmp(const char *, const char *, int);
7267
7268 /*
7269 ** CAPI3REF: String Globbing
7270 *
7271 ** ^The [sqlite3_strglob(P,X)] interface returns zero if string X matches
@@ -7209,11 +7276,11 @@
7276 ** sensitive.
7277 **
7278 ** Note that this routine returns zero on a match and non-zero if the strings
7279 ** do not match, the same as [sqlite3_stricmp()] and [sqlite3_strnicmp()].
7280 */
7281 SQLITE_API int SQLITE_STDCALL sqlite3_strglob(const char *zGlob, const char *zStr);
7282
7283 /*
7284 ** CAPI3REF: Error Logging Interface
7285 **
7286 ** ^The [sqlite3_log()] interface writes a message into the [error log]
@@ -7232,14 +7299,15 @@
7299 ** will not use dynamically allocated memory. The log message is stored in
7300 ** a fixed-length buffer on the stack. If the log message is longer than
7301 ** a few hundred characters, it will be truncated to the length of the
7302 ** buffer.
7303 */
7304 SQLITE_API void SQLITE_CDECL sqlite3_log(int iErrCode, const char *zFormat, ...);
7305
7306 /*
7307 ** CAPI3REF: Write-Ahead Log Commit Hook
7308 ** METHOD: sqlite3
7309 **
7310 ** ^The [sqlite3_wal_hook()] function is used to register a callback that
7311 ** is invoked each time data is committed to a database in wal mode.
7312 **
7313 ** ^(The callback is invoked by SQLite after the commit has taken place and
@@ -7267,18 +7335,19 @@
7335 ** previously registered write-ahead log callback. ^Note that the
7336 ** [sqlite3_wal_autocheckpoint()] interface and the
7337 ** [wal_autocheckpoint pragma] both invoke [sqlite3_wal_hook()] and will
7338 ** those overwrite any prior [sqlite3_wal_hook()] settings.
7339 */
7340 SQLITE_API void *SQLITE_STDCALL sqlite3_wal_hook(
7341 sqlite3*,
7342 int(*)(void *,sqlite3*,const char*,int),
7343 void*
7344 );
7345
7346 /*
7347 ** CAPI3REF: Configure an auto-checkpoint
7348 ** METHOD: sqlite3
7349 **
7350 ** ^The [sqlite3_wal_autocheckpoint(D,N)] is a wrapper around
7351 ** [sqlite3_wal_hook()] that causes any database on [database connection] D
7352 ** to automatically [checkpoint]
7353 ** after committing a transaction if there are N or
@@ -7301,14 +7370,15 @@
7370 ** enabled with a threshold of 1000 or [SQLITE_DEFAULT_WAL_AUTOCHECKPOINT]
7371 ** pages. The use of this interface
7372 ** is only necessary if the default setting is found to be suboptimal
7373 ** for a particular application.
7374 */
7375 SQLITE_API int SQLITE_STDCALL sqlite3_wal_autocheckpoint(sqlite3 *db, int N);
7376
7377 /*
7378 ** CAPI3REF: Checkpoint a database
7379 ** METHOD: sqlite3
7380 **
7381 ** ^(The sqlite3_wal_checkpoint(D,X) is equivalent to
7382 ** [sqlite3_wal_checkpoint_v2](D,X,[SQLITE_CHECKPOINT_PASSIVE],0,0).)^
7383 **
7384 ** In brief, sqlite3_wal_checkpoint(D,X) causes the content in the
@@ -7322,14 +7392,15 @@
7392 ** interface was added. This interface is retained for backwards
7393 ** compatibility and as a convenience for applications that need to manually
7394 ** start a callback but which do not need the full power (and corresponding
7395 ** complication) of [sqlite3_wal_checkpoint_v2()].
7396 */
7397 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb);
7398
7399 /*
7400 ** CAPI3REF: Checkpoint a database
7401 ** METHOD: sqlite3
7402 **
7403 ** ^(The sqlite3_wal_checkpoint_v2(D,X,M,L,C) interface runs a checkpoint
7404 ** operation on database X of [database connection] D in mode M. Status
7405 ** information is written back into integers pointed to by L and C.)^
7406 ** ^(The M parameter must be a valid [checkpoint mode]:)^
@@ -7415,11 +7486,11 @@
7486 ** [sqlite3_errcode()] and [sqlite3_errmsg()].
7487 **
7488 ** ^The [PRAGMA wal_checkpoint] command can be used to invoke this interface
7489 ** from SQL.
7490 */
7491 SQLITE_API int SQLITE_STDCALL sqlite3_wal_checkpoint_v2(
7492 sqlite3 *db, /* Database handle */
7493 const char *zDb, /* Name of attached database (or NULL) */
7494 int eMode, /* SQLITE_CHECKPOINT_* value */
7495 int *pnLog, /* OUT: Size of WAL log in frames */
7496 int *pnCkpt /* OUT: Total number of frames checkpointed */
@@ -7451,11 +7522,11 @@
7522 **
7523 ** At present, there is only one option that may be configured using
7524 ** this function. (See [SQLITE_VTAB_CONSTRAINT_SUPPORT].) Further options
7525 ** may be added in the future.
7526 */
7527 SQLITE_API int SQLITE_CDECL sqlite3_vtab_config(sqlite3*, int op, ...);
7528
7529 /*
7530 ** CAPI3REF: Virtual Table Configuration Options
7531 **
7532 ** These macros define the various options to the
@@ -7504,11 +7575,11 @@
7575 ** value returned is one of [SQLITE_ROLLBACK], [SQLITE_IGNORE], [SQLITE_FAIL],
7576 ** [SQLITE_ABORT], or [SQLITE_REPLACE], according to the [ON CONFLICT] mode
7577 ** of the SQL statement that triggered the call to the [xUpdate] method of the
7578 ** [virtual table].
7579 */
7580 SQLITE_API int SQLITE_STDCALL sqlite3_vtab_on_conflict(sqlite3 *);
7581
7582 /*
7583 ** CAPI3REF: Conflict resolution modes
7584 ** KEYWORDS: {conflict resolution mode}
7585 **
@@ -7580,10 +7651,11 @@
7651 #define SQLITE_SCANSTAT_EXPLAIN 4
7652 #define SQLITE_SCANSTAT_SELECTID 5
7653
7654 /*
7655 ** CAPI3REF: Prepared Statement Scan Status
7656 ** METHOD: sqlite3_stmt
7657 **
7658 ** This interface returns information about the predicted and measured
7659 ** performance for pStmt. Advanced applications can use this
7660 ** interface to compare the predicted and the measured performance and
7661 ** issue warnings and/or rerun [ANALYZE] if discrepancies are found.
@@ -7608,26 +7680,27 @@
7680 ** as if the loop did not exist - it returns non-zero and leave the variable
7681 ** that pOut points to unchanged.
7682 **
7683 ** See also: [sqlite3_stmt_scanstatus_reset()]
7684 */
7685 SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_stmt_scanstatus(
7686 sqlite3_stmt *pStmt, /* Prepared statement for which info desired */
7687 int idx, /* Index of loop to report on */
7688 int iScanStatusOp, /* Information desired. SQLITE_SCANSTAT_* */
7689 void *pOut /* Result written here */
7690 );
7691
7692 /*
7693 ** CAPI3REF: Zero Scan-Status Counters
7694 ** METHOD: sqlite3_stmt
7695 **
7696 ** ^Zero all [sqlite3_stmt_scanstatus()] related event counters.
7697 **
7698 ** This API is only available if the library is built with pre-processor
7699 ** symbol [SQLITE_ENABLE_STMT_SCANSTATUS] defined.
7700 */
7701 SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
7702
7703
7704 /*
7705 ** Undo the hack that converts floating point types to integer for
7706 ** builds on processors without floating point support.
@@ -7678,11 +7751,11 @@
7751 ** Register a geometry callback named zGeom that can be used as part of an
7752 ** R-Tree geometry query as follows:
7753 **
7754 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zGeom(... params ...)
7755 */
7756 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_geometry_callback(
7757 sqlite3 *db,
7758 const char *zGeom,
7759 int (*xGeom)(sqlite3_rtree_geometry*, int, sqlite3_rtree_dbl*,int*),
7760 void *pContext
7761 );
@@ -7704,11 +7777,11 @@
7777 ** Register a 2nd-generation geometry callback named zScore that can be
7778 ** used as part of an R-Tree geometry query as follows:
7779 **
7780 ** SELECT ... FROM <rtree> WHERE <rtree col> MATCH $zQueryFunc(... params ...)
7781 */
7782 SQLITE_API int SQLITE_STDCALL sqlite3_rtree_query_callback(
7783 sqlite3 *db,
7784 const char *zQueryFunc,
7785 int (*xQueryFunc)(sqlite3_rtree_query_info*),
7786 void *pContext,
7787 void (*xDestructor)(void*)
7788
+92
--- src/stat.c
+++ src/stat.c
@@ -36,10 +36,25 @@
3636
}else{
3737
sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
3838
v, (double)v/1000000000.0);
3939
}
4040
}
41
+
42
+/*
43
+** Return the approximate size as KB, MB, GB, or TB.
44
+*/
45
+void approxSizeName(int nOut, char *zOut, sqlite3_int64 v){
46
+ if( v<1000 ){
47
+ sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
48
+ }else if( v<1000000 ){
49
+ sqlite3_snprintf(nOut, zOut, "%.1fKB", (double)v/1000.0);
50
+ }else if( v<1000000000 ){
51
+ sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0);
52
+ }else{
53
+ sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0);
54
+ }
55
+}
4156
4257
/*
4358
** WEBPAGE: stat
4459
**
4560
** Show statistics and global information about the repository.
@@ -63,10 +78,13 @@
6378
style_submenu_element("Schema", "Repository Schema", "repo_schema");
6479
style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
6580
}
6681
style_submenu_element("Activity Reports", 0, "reports");
6782
style_submenu_element("SHA1 Collisions", 0, "hash-collisions");
83
+ if( sqlite3_libversion_number()>=3008010 ){
84
+ style_submenu_element("Table Sizes", 0, "repo-tabsize");
85
+ }
6886
@ <table class="label-value">
6987
@ <tr><th>Repository&nbsp;Size:</th><td>
7088
fsize = file_size(g.zRepositoryName);
7189
bigSizeName(sizeof(zBuf), zBuf, fsize);
7290
@ %s(zBuf)
@@ -355,5 +373,79 @@
355373
}
356374
@ </pre>
357375
db_finalize(&q);
358376
style_footer();
359377
}
378
+
379
+/*
380
+** WEBPAGE: repo-tabsize
381
+**
382
+** Show relative sizes of tables in the repository database.
383
+*/
384
+void repo_tabsize_page(void){
385
+ int nPageFree;
386
+ sqlite3_int64 fsize;
387
+ char zBuf[100];
388
+
389
+ login_check_credentials();
390
+ if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
391
+ style_header("Repository Table Sizes");
392
+ style_adunit_config(ADUNIT_RIGHT_OK);
393
+ style_submenu_element("Stat", "Repository Stats", "stat");
394
+ db_multi_exec(
395
+ "CREATE VIRTUAL TABLE temp.dbx USING dbstat(%s);"
396
+ "CREATE TEMP TABLE trans(name TEXT PRIMARY KEY, tabname TEXT)WITHOUT ROWID;"
397
+ "INSERT INTO trans(name,tabname)"
398
+ " SELECT name, tbl_name FROM %s.sqlite_master;"
399
+ "CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
400
+ "INSERT INTO piechart(amt,label)"
401
+ " SELECT count(*), "
402
+ " coalesce((SELECT tabname FROM trans WHERE trans.name=dbx.name),name)"
403
+ " FROM dbx"
404
+ " GROUP BY 2 ORDER BY 2;",
405
+ db_name("repository"), db_name("repository")
406
+ );
407
+ nPageFree = db_int(0, "PRAGMA \"%w\".freelist_count", db_name("repository"));
408
+ if( nPageFree>0 ){
409
+ db_multi_exec(
410
+ "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
411
+ nPageFree
412
+ );
413
+ }
414
+ fsize = file_size(g.zRepositoryName);
415
+ approxSizeName(sizeof(zBuf), zBuf, fsize);
416
+ @ <h2>Repository Size: %s(zBuf)</h2>
417
+ @ <center><svg width='800' height='500'>
418
+ piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
419
+ @ </svg></center>
420
+
421
+ if( g.localOpen ){
422
+ db_multi_exec(
423
+ "DROP TABLE temp.dbx;"
424
+ "CREATE VIRTUAL TABLE temp.dbx USING dbstat(%s);"
425
+ "DELETE FROM trans;"
426
+ "INSERT INTO trans(name,tabname)"
427
+ " SELECT name, tbl_name FROM %s.sqlite_master;"
428
+ "DELETE FROM piechart;"
429
+ "INSERT INTO piechart(amt,label)"
430
+ " SELECT count(*), "
431
+ " coalesce((SELECT tabname FROM trans WHERE trans.name=dbx.name),name)"
432
+ " FROM dbx"
433
+ " GROUP BY 2 ORDER BY 2;",
434
+ db_name("localdb"), db_name("localdb")
435
+ );
436
+ nPageFree = db_int(0, "PRAGMA \"%s\".freelist_count", db_name("localdb"));
437
+ if( nPageFree>0 ){
438
+ db_multi_exec(
439
+ "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
440
+ nPageFree
441
+ );
442
+ }
443
+ fsize = file_size(g.zLocalDbName);
444
+ approxSizeName(sizeof(zBuf), zBuf, fsize);
445
+ @ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2>
446
+ @ <center><svg width='800' height='500'>
447
+ piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
448
+ @ </svg></center>
449
+ }
450
+ style_footer();
451
+}
360452
--- src/stat.c
+++ src/stat.c
@@ -36,10 +36,25 @@
36 }else{
37 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
38 v, (double)v/1000000000.0);
39 }
40 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42 /*
43 ** WEBPAGE: stat
44 **
45 ** Show statistics and global information about the repository.
@@ -63,10 +78,13 @@
63 style_submenu_element("Schema", "Repository Schema", "repo_schema");
64 style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
65 }
66 style_submenu_element("Activity Reports", 0, "reports");
67 style_submenu_element("SHA1 Collisions", 0, "hash-collisions");
 
 
 
68 @ <table class="label-value">
69 @ <tr><th>Repository&nbsp;Size:</th><td>
70 fsize = file_size(g.zRepositoryName);
71 bigSizeName(sizeof(zBuf), zBuf, fsize);
72 @ %s(zBuf)
@@ -355,5 +373,79 @@
355 }
356 @ </pre>
357 db_finalize(&q);
358 style_footer();
359 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
360
--- src/stat.c
+++ src/stat.c
@@ -36,10 +36,25 @@
36 }else{
37 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
38 v, (double)v/1000000000.0);
39 }
40 }
41
42 /*
43 ** Return the approximate size as KB, MB, GB, or TB.
44 */
45 void approxSizeName(int nOut, char *zOut, sqlite3_int64 v){
46 if( v<1000 ){
47 sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
48 }else if( v<1000000 ){
49 sqlite3_snprintf(nOut, zOut, "%.1fKB", (double)v/1000.0);
50 }else if( v<1000000000 ){
51 sqlite3_snprintf(nOut, zOut, "%.1fMB", (double)v/1000000.0);
52 }else{
53 sqlite3_snprintf(nOut, zOut, "%.1fGB", (double)v/1000000000.0);
54 }
55 }
56
57 /*
58 ** WEBPAGE: stat
59 **
60 ** Show statistics and global information about the repository.
@@ -63,10 +78,13 @@
78 style_submenu_element("Schema", "Repository Schema", "repo_schema");
79 style_submenu_element("Web-Cache", "Web-Cache Stats", "cachestat");
80 }
81 style_submenu_element("Activity Reports", 0, "reports");
82 style_submenu_element("SHA1 Collisions", 0, "hash-collisions");
83 if( sqlite3_libversion_number()>=3008010 ){
84 style_submenu_element("Table Sizes", 0, "repo-tabsize");
85 }
86 @ <table class="label-value">
87 @ <tr><th>Repository&nbsp;Size:</th><td>
88 fsize = file_size(g.zRepositoryName);
89 bigSizeName(sizeof(zBuf), zBuf, fsize);
90 @ %s(zBuf)
@@ -355,5 +373,79 @@
373 }
374 @ </pre>
375 db_finalize(&q);
376 style_footer();
377 }
378
379 /*
380 ** WEBPAGE: repo-tabsize
381 **
382 ** Show relative sizes of tables in the repository database.
383 */
384 void repo_tabsize_page(void){
385 int nPageFree;
386 sqlite3_int64 fsize;
387 char zBuf[100];
388
389 login_check_credentials();
390 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
391 style_header("Repository Table Sizes");
392 style_adunit_config(ADUNIT_RIGHT_OK);
393 style_submenu_element("Stat", "Repository Stats", "stat");
394 db_multi_exec(
395 "CREATE VIRTUAL TABLE temp.dbx USING dbstat(%s);"
396 "CREATE TEMP TABLE trans(name TEXT PRIMARY KEY, tabname TEXT)WITHOUT ROWID;"
397 "INSERT INTO trans(name,tabname)"
398 " SELECT name, tbl_name FROM %s.sqlite_master;"
399 "CREATE TEMP TABLE piechart(amt REAL, label TEXT);"
400 "INSERT INTO piechart(amt,label)"
401 " SELECT count(*), "
402 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbx.name),name)"
403 " FROM dbx"
404 " GROUP BY 2 ORDER BY 2;",
405 db_name("repository"), db_name("repository")
406 );
407 nPageFree = db_int(0, "PRAGMA \"%w\".freelist_count", db_name("repository"));
408 if( nPageFree>0 ){
409 db_multi_exec(
410 "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
411 nPageFree
412 );
413 }
414 fsize = file_size(g.zRepositoryName);
415 approxSizeName(sizeof(zBuf), zBuf, fsize);
416 @ <h2>Repository Size: %s(zBuf)</h2>
417 @ <center><svg width='800' height='500'>
418 piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
419 @ </svg></center>
420
421 if( g.localOpen ){
422 db_multi_exec(
423 "DROP TABLE temp.dbx;"
424 "CREATE VIRTUAL TABLE temp.dbx USING dbstat(%s);"
425 "DELETE FROM trans;"
426 "INSERT INTO trans(name,tabname)"
427 " SELECT name, tbl_name FROM %s.sqlite_master;"
428 "DELETE FROM piechart;"
429 "INSERT INTO piechart(amt,label)"
430 " SELECT count(*), "
431 " coalesce((SELECT tabname FROM trans WHERE trans.name=dbx.name),name)"
432 " FROM dbx"
433 " GROUP BY 2 ORDER BY 2;",
434 db_name("localdb"), db_name("localdb")
435 );
436 nPageFree = db_int(0, "PRAGMA \"%s\".freelist_count", db_name("localdb"));
437 if( nPageFree>0 ){
438 db_multi_exec(
439 "INSERT INTO piechart(amt,label) VALUES(%d,'freelist')",
440 nPageFree
441 );
442 }
443 fsize = file_size(g.zLocalDbName);
444 approxSizeName(sizeof(zBuf), zBuf, fsize);
445 @ <h2>%h(file_tail(g.zLocalDbName)) Size: %s(zBuf)</h2>
446 @ <center><svg width='800' height='500'>
447 piechart_render(800,500,PIE_OTHER|PIE_PERCENT);
448 @ </svg></center>
449 }
450 style_footer();
451 }
452
+29 -6
--- src/statrep.c
+++ src/statrep.c
@@ -404,24 +404,34 @@
404404
row colors */
405405
int nMaxEvents = 1; /* max number of events for
406406
all rows. */
407407
stats_report_init_view();
408408
stats_report_event_types_menu("byuser", NULL);
409
- db_prepare(&query,
410
- "SELECT user, "
411
- "COUNT(*) AS eventCount "
412
- "FROM v_reports "
413
- "GROUP BY user ORDER BY eventCount DESC");
414409
@ <h1>Timeline Events
415410
@ (%s(stats_report_label_for_type())) by User</h1>
411
+ db_multi_exec(
412
+ "CREATE TEMP TABLE piechart(amt,label);"
413
+ "INSERT INTO piechart SELECT count(*), user FROM v_reports"
414
+ " GROUP BY user ORDER BY count(*) DESC;"
415
+ );
416
+ if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
417
+ @ <center><svg width=700 height=400>
418
+ piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
419
+ @ </svg></centre><hr/>
420
+ }
416421
@ <table class='statistics-report-table-events' border='0'
417422
@ cellpadding='2' cellspacing='0' id='statsTable'>
418423
@ <thead><tr>
419424
@ <th>User</th>
420425
@ <th>Events</th>
421426
@ <th width='90%%'><!-- relative commits graph --></th>
422427
@ </tr></thead><tbody>
428
+ db_prepare(&query,
429
+ "SELECT user, "
430
+ "COUNT(*) AS eventCount "
431
+ "FROM v_reports "
432
+ "GROUP BY user ORDER BY eventCount DESC");
423433
while( SQLITE_ROW == db_step(&query) ){
424434
const int nCount = db_column_int(&query, 1);
425435
if(nCount>nMaxEvents){
426436
nMaxEvents = nCount;
427437
}
@@ -468,11 +478,11 @@
468478
"CREATE TEMP TABLE statrep(filename, cnt);"
469479
"INSERT INTO statrep(filename, cnt)"
470480
" SELECT filename.name, count(distinct mlink.mid)"
471481
" FROM filename, mlink"
472482
" WHERE filename.fnid=mlink.fnid"
473
- " GROUP BY 1"
483
+ " GROUP BY 1;"
474484
);
475485
db_prepare(&query,
476486
"SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
477487
);
478488
mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
@@ -528,10 +538,23 @@
528538
"COUNT(*) AS eventCount "
529539
"FROM v_reports "
530540
"GROUP BY dow ORDER BY dow");
531541
@ <h1>Timeline Events
532542
@ (%s(stats_report_label_for_type())) by Day of the Week</h1>
543
+ db_multi_exec(
544
+ "CREATE TEMP TABLE piechart(amt,label);"
545
+ "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports"
546
+ " GROUP BY 2 ORDER BY 2;"
547
+ "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'"
548
+ " WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'"
549
+ " WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;"
550
+ );
551
+ if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
552
+ @ <center><svg width=700 height=400>
553
+ piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
554
+ @ </svg></centre><hr/>
555
+ }
533556
@ <table class='statistics-report-table-events' border='0'
534557
@ cellpadding='2' cellspacing='0' id='statsTable'>
535558
@ <thead><tr>
536559
@ <th>DoW</th>
537560
@ <th>Day</th>
538561
--- src/statrep.c
+++ src/statrep.c
@@ -404,24 +404,34 @@
404 row colors */
405 int nMaxEvents = 1; /* max number of events for
406 all rows. */
407 stats_report_init_view();
408 stats_report_event_types_menu("byuser", NULL);
409 db_prepare(&query,
410 "SELECT user, "
411 "COUNT(*) AS eventCount "
412 "FROM v_reports "
413 "GROUP BY user ORDER BY eventCount DESC");
414 @ <h1>Timeline Events
415 @ (%s(stats_report_label_for_type())) by User</h1>
 
 
 
 
 
 
 
 
 
 
416 @ <table class='statistics-report-table-events' border='0'
417 @ cellpadding='2' cellspacing='0' id='statsTable'>
418 @ <thead><tr>
419 @ <th>User</th>
420 @ <th>Events</th>
421 @ <th width='90%%'><!-- relative commits graph --></th>
422 @ </tr></thead><tbody>
 
 
 
 
 
423 while( SQLITE_ROW == db_step(&query) ){
424 const int nCount = db_column_int(&query, 1);
425 if(nCount>nMaxEvents){
426 nMaxEvents = nCount;
427 }
@@ -468,11 +478,11 @@
468 "CREATE TEMP TABLE statrep(filename, cnt);"
469 "INSERT INTO statrep(filename, cnt)"
470 " SELECT filename.name, count(distinct mlink.mid)"
471 " FROM filename, mlink"
472 " WHERE filename.fnid=mlink.fnid"
473 " GROUP BY 1"
474 );
475 db_prepare(&query,
476 "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
477 );
478 mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
@@ -528,10 +538,23 @@
528 "COUNT(*) AS eventCount "
529 "FROM v_reports "
530 "GROUP BY dow ORDER BY dow");
531 @ <h1>Timeline Events
532 @ (%s(stats_report_label_for_type())) by Day of the Week</h1>
 
 
 
 
 
 
 
 
 
 
 
 
 
533 @ <table class='statistics-report-table-events' border='0'
534 @ cellpadding='2' cellspacing='0' id='statsTable'>
535 @ <thead><tr>
536 @ <th>DoW</th>
537 @ <th>Day</th>
538
--- src/statrep.c
+++ src/statrep.c
@@ -404,24 +404,34 @@
404 row colors */
405 int nMaxEvents = 1; /* max number of events for
406 all rows. */
407 stats_report_init_view();
408 stats_report_event_types_menu("byuser", NULL);
 
 
 
 
 
409 @ <h1>Timeline Events
410 @ (%s(stats_report_label_for_type())) by User</h1>
411 db_multi_exec(
412 "CREATE TEMP TABLE piechart(amt,label);"
413 "INSERT INTO piechart SELECT count(*), user FROM v_reports"
414 " GROUP BY user ORDER BY count(*) DESC;"
415 );
416 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
417 @ <center><svg width=700 height=400>
418 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
419 @ </svg></centre><hr/>
420 }
421 @ <table class='statistics-report-table-events' border='0'
422 @ cellpadding='2' cellspacing='0' id='statsTable'>
423 @ <thead><tr>
424 @ <th>User</th>
425 @ <th>Events</th>
426 @ <th width='90%%'><!-- relative commits graph --></th>
427 @ </tr></thead><tbody>
428 db_prepare(&query,
429 "SELECT user, "
430 "COUNT(*) AS eventCount "
431 "FROM v_reports "
432 "GROUP BY user ORDER BY eventCount DESC");
433 while( SQLITE_ROW == db_step(&query) ){
434 const int nCount = db_column_int(&query, 1);
435 if(nCount>nMaxEvents){
436 nMaxEvents = nCount;
437 }
@@ -468,11 +478,11 @@
478 "CREATE TEMP TABLE statrep(filename, cnt);"
479 "INSERT INTO statrep(filename, cnt)"
480 " SELECT filename.name, count(distinct mlink.mid)"
481 " FROM filename, mlink"
482 " WHERE filename.fnid=mlink.fnid"
483 " GROUP BY 1;"
484 );
485 db_prepare(&query,
486 "SELECT filename, cnt FROM statrep ORDER BY cnt DESC, filename /*sort*/"
487 );
488 mxEvent = db_int(1, "SELECT max(cnt) FROM statrep");
@@ -528,10 +538,23 @@
538 "COUNT(*) AS eventCount "
539 "FROM v_reports "
540 "GROUP BY dow ORDER BY dow");
541 @ <h1>Timeline Events
542 @ (%s(stats_report_label_for_type())) by Day of the Week</h1>
543 db_multi_exec(
544 "CREATE TEMP TABLE piechart(amt,label);"
545 "INSERT INTO piechart SELECT count(*), cast(mtime %% 7 AS INT) FROM v_reports"
546 " GROUP BY 2 ORDER BY 2;"
547 "UPDATE piechart SET label = CASE label WHEN 0 THEN 'Monday' WHEN 1 THEN 'Tuesday'"
548 " WHEN 2 THEN 'Wednesday' WHEN 3 THEN 'Thursday' WHEN 4 THEN 'Friday'"
549 " WHEN 5 THEN 'Saturday' ELSE 'Sunday' END;"
550 );
551 if( db_int(0, "SELECT count(*) FROM piechart")>=2 ){
552 @ <center><svg width=700 height=400>
553 piechart_render(700, 400, PIE_OTHER|PIE_PERCENT);
554 @ </svg></centre><hr/>
555 }
556 @ <table class='statistics-report-table-events' border='0'
557 @ cellpadding='2' cellspacing='0' id='statsTable'>
558 @ <thead><tr>
559 @ <th>DoW</th>
560 @ <th>Day</th>
561
+131 -18
--- src/style.c
+++ src/style.c
@@ -701,15 +701,108 @@
701701
@ vertical-align: top;
702702
@ text-align: right;
703703
@ white-space: nowrap;
704704
},
705705
{ "td.timelineGraph",
706
- "the format for the grap placeholder cells in timelines",
706
+ "the format for the graph placeholder cells in timelines",
707707
@ width: 20px;
708708
@ text-align: left;
709709
@ vertical-align: top;
710710
},
711
+ { ".tl-canvas",
712
+ "timeline graph canvas",
713
+ @ margin: 0 6px 0 10px;
714
+ },
715
+ { ".tl-rail",
716
+ "maximum rail spacing",
717
+ @ width: 18px;
718
+ },
719
+ { ".tl-mergeoffset",
720
+ "maximum spacing between merge risers and primary child risers",
721
+ @ width: 2px;
722
+ },
723
+ { ".tl-nodemark",
724
+ "adjusts the vertical position of graph nodes",
725
+ @ margin-top: 5px;
726
+ },
727
+ { ".tl-node",
728
+ "commit node",
729
+ @ width: 10px;
730
+ @ height: 10px;
731
+ @ border: 1px solid #000;
732
+ @ background: #fff;
733
+ @ cursor: pointer;
734
+ },
735
+ { ".tl-node.leaf:after",
736
+ "leaf commit marker",
737
+ @ content: '';
738
+ @ position: absolute;
739
+ @ top: 3px;
740
+ @ left: 3px;
741
+ @ width: 4px;
742
+ @ height: 4px;
743
+ @ background: #000;
744
+ },
745
+ { ".tl-node.sel:after",
746
+ "selected commit node marker",
747
+ @ content: '';
748
+ @ position: absolute;
749
+ @ top: 2px;
750
+ @ left: 2px;
751
+ @ width: 6px;
752
+ @ height: 6px;
753
+ @ background: red;
754
+ },
755
+ { ".tl-arrow",
756
+ "arrow",
757
+ @ width: 0;
758
+ @ height: 0;
759
+ @ transform: scale(.999);
760
+ @ border: 0 solid transparent;
761
+ },
762
+ { ".tl-arrow.u",
763
+ "up arrow",
764
+ @ margin-top: -1px;
765
+ @ border-width: 0 3px;
766
+ @ border-bottom: 7px solid #000;
767
+ },
768
+ { ".tl-arrow.u.sm",
769
+ "small up arrow",
770
+ @ border-bottom: 5px solid #000;
771
+ },
772
+ { ".tl-line",
773
+ "line",
774
+ @ background: #000;
775
+ @ width: 2px;
776
+ },
777
+ { ".tl-arrow.merge",
778
+ "merge arrow",
779
+ @ height: 1px;
780
+ @ border-width: 2px 0;
781
+ },
782
+ { ".tl-arrow.merge.l",
783
+ "left merge arrow",
784
+ @ border-right: 3px solid #000;
785
+ },
786
+ { ".tl-arrow.merge.r",
787
+ "right merge arrow",
788
+ @ border-left: 3px solid #000;
789
+ },
790
+ { ".tl-line.merge",
791
+ "merge line",
792
+ @ width: 1px;
793
+ },
794
+ { ".tl-arrow.warp",
795
+ "timewarp arrow",
796
+ @ margin-left: 1px;
797
+ @ border-width: 3px 0;
798
+ @ border-left: 7px solid #600000;
799
+ },
800
+ { ".tl-line.warp",
801
+ "timewarp line",
802
+ @ background: #600000;
803
+ },
711804
{ "a.tagLink",
712805
"the format for the tag links",
713806
@
714807
},
715808
{ "span.tagDsp",
@@ -1226,14 +1319,10 @@
12261319
},
12271320
{ "#usetupEditCapability",
12281321
"format for capabilities string, mentioned on the user edit page",
12291322
@ font-weight: bold;
12301323
},
1231
- { "#canvas", "timeline graph node colors",
1232
- @ color: black;
1233
- @ background-color: white;
1234
- },
12351324
{ "table.adminLogTable",
12361325
"Class for the /admin_log table",
12371326
@ text-align: left;
12381327
},
12391328
{ ".adminLogTable .adminTime",
@@ -1336,34 +1425,56 @@
13361425
}
13371426
}
13381427
}
13391428
13401429
/*
1341
-** Search string zHaystack for zNeedle. zNeedle must be an isolated
1342
-** word with space or punctuation on either size.
1430
+** Search string zCss for zSelector.
13431431
**
13441432
** Return true if found. Return false if not found
13451433
*/
1346
-static int containsString(const char *zHaystack, const char *zNeedle){
1347
- char *z;
1434
+static int containsSelector(const char *zCss, const char *zSelector){
1435
+ const char *z;
13481436
int n;
1437
+ int selectorLen = (int)strlen(zSelector);
13491438
1350
- while( zHaystack[0] ){
1351
- z = strstr(zHaystack, zNeedle);
1439
+ for(z=zCss; *z; z+=selectorLen){
1440
+ z = strstr(z, zSelector);
13521441
if( z==0 ) return 0;
1353
- n = (int)strlen(zNeedle);
1354
- if( (z==zHaystack || !fossil_isalnum(z[-1])) && !fossil_isalnum(z[n]) ){
1355
- return 1;
1442
+ if( z!=zCss ){
1443
+ for( n=-1; z+n!=zCss && fossil_isspace(z[n]); n--);
1444
+ if( z+n!=zCss && z[n]!=',' && z[n]!= '}' && z[n]!='/' ) continue;
13561445
}
1357
- zHaystack = z + n;
1446
+ for( n=selectorLen; z[n] && fossil_isspace(z[n]); n++ );
1447
+ if( z[n]==',' || z[n]=='{' || z[n]=='/' ) return 1;
13581448
}
13591449
return 0;
13601450
}
1451
+
1452
+/*
1453
+** COMMAND: test-contains-selector
1454
+**
1455
+** Usage: %fossil test-contains-selector FILENAME SELECTOR
1456
+**
1457
+** Determine if the CSS stylesheet FILENAME contains SELECTOR.
1458
+*/
1459
+void contains_selector_cmd(void){
1460
+ int found;
1461
+ char *zSelector;
1462
+ Blob css;
1463
+ if( g.argc!=4 ) usage("FILENAME SELECTOR");
1464
+ blob_read_from_file(&css, g.argv[2]);
1465
+ zSelector = g.argv[3];
1466
+ found = containsSelector(blob_str(&css), zSelector);
1467
+ fossil_print("%s %s\n", zSelector, found ? "found" : "not found");
1468
+ blob_reset(&css);
1469
+}
13611470
13621471
13631472
/*
13641473
** WEBPAGE: style.css
1474
+**
1475
+** Return the style sheet.
13651476
*/
13661477
void page_style_css(void){
13671478
Blob css;
13681479
int i;
13691480
@@ -1371,11 +1482,11 @@
13711482
blob_init(&css,skin_get("css"),-1);
13721483
13731484
/* add special missing definitions */
13741485
for(i=1; cssDefaultList[i].elementClass; i++){
13751486
char *z = blob_str(&css);
1376
- if( !containsString(z, cssDefaultList[i].elementClass) ){
1487
+ if( !containsSelector(z, cssDefaultList[i].elementClass) ){
13771488
blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
13781489
cssDefaultList[i].comment,
13791490
cssDefaultList[i].elementClass,
13801491
cssDefaultList[i].value);
13811492
}
@@ -1395,10 +1506,13 @@
13951506
g.isConst = 1;
13961507
}
13971508
13981509
/*
13991510
** WEBPAGE: test_env
1511
+**
1512
+** Display CGI-variables and other aspects of the run-time
1513
+** environment, for debugging and trouble-shooting purposes.
14001514
*/
14011515
void page_test_env(void){
14021516
char c;
14031517
int i;
14041518
int showAll;
@@ -1466,13 +1580,12 @@
14661580
style_footer();
14671581
if( g.perm.Admin && P("err") ) fossil_fatal("%s", P("err"));
14681582
}
14691583
14701584
/*
1471
-** This page is a honeypot for spiders and bots.
1472
-**
14731585
** WEBPAGE: honeypot
1586
+** This page is a honeypot for spiders and bots.
14741587
*/
14751588
void honeypot_page(void){
14761589
cgi_set_status(403, "Forbidden");
14771590
@ <p>Please enable javascript or log in to see this content</p>
14781591
}
14791592
--- src/style.c
+++ src/style.c
@@ -701,15 +701,108 @@
701 @ vertical-align: top;
702 @ text-align: right;
703 @ white-space: nowrap;
704 },
705 { "td.timelineGraph",
706 "the format for the grap placeholder cells in timelines",
707 @ width: 20px;
708 @ text-align: left;
709 @ vertical-align: top;
710 },
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
711 { "a.tagLink",
712 "the format for the tag links",
713 @
714 },
715 { "span.tagDsp",
@@ -1226,14 +1319,10 @@
1226 },
1227 { "#usetupEditCapability",
1228 "format for capabilities string, mentioned on the user edit page",
1229 @ font-weight: bold;
1230 },
1231 { "#canvas", "timeline graph node colors",
1232 @ color: black;
1233 @ background-color: white;
1234 },
1235 { "table.adminLogTable",
1236 "Class for the /admin_log table",
1237 @ text-align: left;
1238 },
1239 { ".adminLogTable .adminTime",
@@ -1336,34 +1425,56 @@
1336 }
1337 }
1338 }
1339
1340 /*
1341 ** Search string zHaystack for zNeedle. zNeedle must be an isolated
1342 ** word with space or punctuation on either size.
1343 **
1344 ** Return true if found. Return false if not found
1345 */
1346 static int containsString(const char *zHaystack, const char *zNeedle){
1347 char *z;
1348 int n;
 
1349
1350 while( zHaystack[0] ){
1351 z = strstr(zHaystack, zNeedle);
1352 if( z==0 ) return 0;
1353 n = (int)strlen(zNeedle);
1354 if( (z==zHaystack || !fossil_isalnum(z[-1])) && !fossil_isalnum(z[n]) ){
1355 return 1;
1356 }
1357 zHaystack = z + n;
 
1358 }
1359 return 0;
1360 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1361
1362
1363 /*
1364 ** WEBPAGE: style.css
 
 
1365 */
1366 void page_style_css(void){
1367 Blob css;
1368 int i;
1369
@@ -1371,11 +1482,11 @@
1371 blob_init(&css,skin_get("css"),-1);
1372
1373 /* add special missing definitions */
1374 for(i=1; cssDefaultList[i].elementClass; i++){
1375 char *z = blob_str(&css);
1376 if( !containsString(z, cssDefaultList[i].elementClass) ){
1377 blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
1378 cssDefaultList[i].comment,
1379 cssDefaultList[i].elementClass,
1380 cssDefaultList[i].value);
1381 }
@@ -1395,10 +1506,13 @@
1395 g.isConst = 1;
1396 }
1397
1398 /*
1399 ** WEBPAGE: test_env
 
 
 
1400 */
1401 void page_test_env(void){
1402 char c;
1403 int i;
1404 int showAll;
@@ -1466,13 +1580,12 @@
1466 style_footer();
1467 if( g.perm.Admin && P("err") ) fossil_fatal("%s", P("err"));
1468 }
1469
1470 /*
1471 ** This page is a honeypot for spiders and bots.
1472 **
1473 ** WEBPAGE: honeypot
 
1474 */
1475 void honeypot_page(void){
1476 cgi_set_status(403, "Forbidden");
1477 @ <p>Please enable javascript or log in to see this content</p>
1478 }
1479
--- src/style.c
+++ src/style.c
@@ -701,15 +701,108 @@
701 @ vertical-align: top;
702 @ text-align: right;
703 @ white-space: nowrap;
704 },
705 { "td.timelineGraph",
706 "the format for the graph placeholder cells in timelines",
707 @ width: 20px;
708 @ text-align: left;
709 @ vertical-align: top;
710 },
711 { ".tl-canvas",
712 "timeline graph canvas",
713 @ margin: 0 6px 0 10px;
714 },
715 { ".tl-rail",
716 "maximum rail spacing",
717 @ width: 18px;
718 },
719 { ".tl-mergeoffset",
720 "maximum spacing between merge risers and primary child risers",
721 @ width: 2px;
722 },
723 { ".tl-nodemark",
724 "adjusts the vertical position of graph nodes",
725 @ margin-top: 5px;
726 },
727 { ".tl-node",
728 "commit node",
729 @ width: 10px;
730 @ height: 10px;
731 @ border: 1px solid #000;
732 @ background: #fff;
733 @ cursor: pointer;
734 },
735 { ".tl-node.leaf:after",
736 "leaf commit marker",
737 @ content: '';
738 @ position: absolute;
739 @ top: 3px;
740 @ left: 3px;
741 @ width: 4px;
742 @ height: 4px;
743 @ background: #000;
744 },
745 { ".tl-node.sel:after",
746 "selected commit node marker",
747 @ content: '';
748 @ position: absolute;
749 @ top: 2px;
750 @ left: 2px;
751 @ width: 6px;
752 @ height: 6px;
753 @ background: red;
754 },
755 { ".tl-arrow",
756 "arrow",
757 @ width: 0;
758 @ height: 0;
759 @ transform: scale(.999);
760 @ border: 0 solid transparent;
761 },
762 { ".tl-arrow.u",
763 "up arrow",
764 @ margin-top: -1px;
765 @ border-width: 0 3px;
766 @ border-bottom: 7px solid #000;
767 },
768 { ".tl-arrow.u.sm",
769 "small up arrow",
770 @ border-bottom: 5px solid #000;
771 },
772 { ".tl-line",
773 "line",
774 @ background: #000;
775 @ width: 2px;
776 },
777 { ".tl-arrow.merge",
778 "merge arrow",
779 @ height: 1px;
780 @ border-width: 2px 0;
781 },
782 { ".tl-arrow.merge.l",
783 "left merge arrow",
784 @ border-right: 3px solid #000;
785 },
786 { ".tl-arrow.merge.r",
787 "right merge arrow",
788 @ border-left: 3px solid #000;
789 },
790 { ".tl-line.merge",
791 "merge line",
792 @ width: 1px;
793 },
794 { ".tl-arrow.warp",
795 "timewarp arrow",
796 @ margin-left: 1px;
797 @ border-width: 3px 0;
798 @ border-left: 7px solid #600000;
799 },
800 { ".tl-line.warp",
801 "timewarp line",
802 @ background: #600000;
803 },
804 { "a.tagLink",
805 "the format for the tag links",
806 @
807 },
808 { "span.tagDsp",
@@ -1226,14 +1319,10 @@
1319 },
1320 { "#usetupEditCapability",
1321 "format for capabilities string, mentioned on the user edit page",
1322 @ font-weight: bold;
1323 },
 
 
 
 
1324 { "table.adminLogTable",
1325 "Class for the /admin_log table",
1326 @ text-align: left;
1327 },
1328 { ".adminLogTable .adminTime",
@@ -1336,34 +1425,56 @@
1425 }
1426 }
1427 }
1428
1429 /*
1430 ** Search string zCss for zSelector.
 
1431 **
1432 ** Return true if found. Return false if not found
1433 */
1434 static int containsSelector(const char *zCss, const char *zSelector){
1435 const char *z;
1436 int n;
1437 int selectorLen = (int)strlen(zSelector);
1438
1439 for(z=zCss; *z; z+=selectorLen){
1440 z = strstr(z, zSelector);
1441 if( z==0 ) return 0;
1442 if( z!=zCss ){
1443 for( n=-1; z+n!=zCss && fossil_isspace(z[n]); n--);
1444 if( z+n!=zCss && z[n]!=',' && z[n]!= '}' && z[n]!='/' ) continue;
1445 }
1446 for( n=selectorLen; z[n] && fossil_isspace(z[n]); n++ );
1447 if( z[n]==',' || z[n]=='{' || z[n]=='/' ) return 1;
1448 }
1449 return 0;
1450 }
1451
1452 /*
1453 ** COMMAND: test-contains-selector
1454 **
1455 ** Usage: %fossil test-contains-selector FILENAME SELECTOR
1456 **
1457 ** Determine if the CSS stylesheet FILENAME contains SELECTOR.
1458 */
1459 void contains_selector_cmd(void){
1460 int found;
1461 char *zSelector;
1462 Blob css;
1463 if( g.argc!=4 ) usage("FILENAME SELECTOR");
1464 blob_read_from_file(&css, g.argv[2]);
1465 zSelector = g.argv[3];
1466 found = containsSelector(blob_str(&css), zSelector);
1467 fossil_print("%s %s\n", zSelector, found ? "found" : "not found");
1468 blob_reset(&css);
1469 }
1470
1471
1472 /*
1473 ** WEBPAGE: style.css
1474 **
1475 ** Return the style sheet.
1476 */
1477 void page_style_css(void){
1478 Blob css;
1479 int i;
1480
@@ -1371,11 +1482,11 @@
1482 blob_init(&css,skin_get("css"),-1);
1483
1484 /* add special missing definitions */
1485 for(i=1; cssDefaultList[i].elementClass; i++){
1486 char *z = blob_str(&css);
1487 if( !containsSelector(z, cssDefaultList[i].elementClass) ){
1488 blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
1489 cssDefaultList[i].comment,
1490 cssDefaultList[i].elementClass,
1491 cssDefaultList[i].value);
1492 }
@@ -1395,10 +1506,13 @@
1506 g.isConst = 1;
1507 }
1508
1509 /*
1510 ** WEBPAGE: test_env
1511 **
1512 ** Display CGI-variables and other aspects of the run-time
1513 ** environment, for debugging and trouble-shooting purposes.
1514 */
1515 void page_test_env(void){
1516 char c;
1517 int i;
1518 int showAll;
@@ -1466,13 +1580,12 @@
1580 style_footer();
1581 if( g.perm.Admin && P("err") ) fossil_fatal("%s", P("err"));
1582 }
1583
1584 /*
 
 
1585 ** WEBPAGE: honeypot
1586 ** This page is a honeypot for spiders and bots.
1587 */
1588 void honeypot_page(void){
1589 cgi_set_status(403, "Forbidden");
1590 @ <p>Please enable javascript or log in to see this content</p>
1591 }
1592
+5
--- src/tag.c
+++ src/tag.c
@@ -536,10 +536,12 @@
536536
usage("add|cancel|find|list ...");
537537
}
538538
539539
/*
540540
** WEBPAGE: taglist
541
+**
542
+** List all non-propagating symbolic tags.
541543
*/
542544
void taglist_page(void){
543545
Stmt q;
544546
545547
login_check_credentials();
@@ -575,10 +577,13 @@
575577
style_footer();
576578
}
577579
578580
/*
579581
** WEBPAGE: /tagtimeline
582
+**
583
+** Render a timeline with all check-ins that contain non-propagating
584
+** symbolic tags.
580585
*/
581586
void tagtimeline_page(void){
582587
Stmt q;
583588
584589
login_check_credentials();
585590
--- src/tag.c
+++ src/tag.c
@@ -536,10 +536,12 @@
536 usage("add|cancel|find|list ...");
537 }
538
539 /*
540 ** WEBPAGE: taglist
 
 
541 */
542 void taglist_page(void){
543 Stmt q;
544
545 login_check_credentials();
@@ -575,10 +577,13 @@
575 style_footer();
576 }
577
578 /*
579 ** WEBPAGE: /tagtimeline
 
 
 
580 */
581 void tagtimeline_page(void){
582 Stmt q;
583
584 login_check_credentials();
585
--- src/tag.c
+++ src/tag.c
@@ -536,10 +536,12 @@
536 usage("add|cancel|find|list ...");
537 }
538
539 /*
540 ** WEBPAGE: taglist
541 **
542 ** List all non-propagating symbolic tags.
543 */
544 void taglist_page(void){
545 Stmt q;
546
547 login_check_credentials();
@@ -575,10 +577,13 @@
577 style_footer();
578 }
579
580 /*
581 ** WEBPAGE: /tagtimeline
582 **
583 ** Render a timeline with all check-ins that contain non-propagating
584 ** symbolic tags.
585 */
586 void tagtimeline_page(void){
587 Stmt q;
588
589 login_check_credentials();
590
+99 -24
--- src/th.c
+++ src/th.c
@@ -7,13 +7,14 @@
77
#include "config.h"
88
#include "th.h"
99
#include <string.h>
1010
#include <assert.h>
1111
12
-typedef struct Th_Command Th_Command;
13
-typedef struct Th_Frame Th_Frame;
14
-typedef struct Th_Variable Th_Variable;
12
+typedef struct Th_Command Th_Command;
13
+typedef struct Th_Frame Th_Frame;
14
+typedef struct Th_Variable Th_Variable;
15
+typedef struct Th_InterpAndList Th_InterpAndList;
1516
1617
/*
1718
** Interpreter structure.
1819
*/
1920
struct Th_Interp {
@@ -87,10 +88,21 @@
8788
int nRef; /* Number of references to this structure */
8889
int nData; /* Number of bytes at Th_Variable.zData */
8990
char *zData; /* Data for scalar variables */
9091
Th_Hash *pHash; /* Data for array variables */
9192
};
93
+
94
+/*
95
+** This structure is used to pass complete context information to the
96
+** hash iteration callback functions that need a Th_Interp and a list
97
+** to operate on, e.g. thListAppendHashKey().
98
+*/
99
+struct Th_InterpAndList {
100
+ Th_Interp *interp; /* Associated interpreter context */
101
+ char **pzList; /* IN/OUT: Ptr to ptr to list */
102
+ int *pnList; /* IN/OUT: Current length of *pzList */
103
+};
92104
93105
/*
94106
** Hash table API:
95107
*/
96108
#define TH_HASHSIZE 257
@@ -298,10 +310,25 @@
298310
}
299311
Th_Free((Th_Interp *)pContext, pEntry->pData);
300312
pEntry->pData = 0;
301313
return 1;
302314
}
315
+
316
+/*
317
+** Argument pEntry points to an entry in a hash table. The key is
318
+** the list element to be added.
319
+**
320
+** Argument pContext is a pointer to the Th_InterpAndList structure.
321
+**
322
+** Always returns non-zero.
323
+*/
324
+static int thListAppendHashKey(Th_HashEntry *pEntry, void *pContext){
325
+ Th_InterpAndList *pInterpAndList = (Th_InterpAndList *)pContext;
326
+ Th_ListAppend(pInterpAndList->interp, pInterpAndList->pzList,
327
+ pInterpAndList->pnList, pEntry->zKey, pEntry->nKey);
328
+ return 1;
329
+}
303330
304331
/*
305332
** Push a new frame onto the stack.
306333
*/
307334
static int thPushFrame(Th_Interp *interp, Th_Frame *pFrame){
@@ -2227,18 +2254,29 @@
22272254
default: {
22282255
int j;
22292256
const char *zOp;
22302257
for(j=0; (zOp=aOperator[j].zOp); j++){
22312258
int nOp = aOperator[j].nOp;
2259
+ int nRemain = nExpr - i;
22322260
int isMatch = 0;
2233
- if( (nExpr-i)>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
2261
+ if( nRemain>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
22342262
isMatch = 1;
22352263
}
2236
- if( isMatch && aOperator[j].eOp==OP_OPEN_BRACKET ){
2237
- nNest++;
2238
- }else if( isMatch && aOperator[j].eOp==OP_CLOSE_BRACKET ){
2239
- nNest--;
2264
+ if( isMatch ){
2265
+ if( aOperator[j].eOp==OP_CLOSE_BRACKET ){
2266
+ nNest--;
2267
+ }else if( nRemain>nOp ){
2268
+ if( aOperator[j].eOp==OP_OPEN_BRACKET ){
2269
+ nNest++;
2270
+ }
2271
+ }else{
2272
+ /*
2273
+ ** This is not really a match because this operator cannot
2274
+ ** legally appear at the end of the string.
2275
+ */
2276
+ isMatch = 0;
2277
+ }
22402278
}
22412279
if( nToken>0 && aOperator[j].iPrecedence==1 ){
22422280
Expr *pPrev = apToken[nToken-1];
22432281
if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
22442282
continue;
@@ -2646,28 +2684,26 @@
26462684
26472685
if( n<0 ){
26482686
n = th_strlen(z);
26492687
}
26502688
2651
- if( n>0 && (z[0]=='-' || z[0]=='+') ){
2689
+ if( n>1 && (z[0]=='-' || z[0]=='+') ){
26522690
i = 1;
26532691
}
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
- }
2692
+ if( (n-i)>2 && z[i]=='0' ){
2693
+ if( z[i+1]=='x' || z[i+1]=='X' ){
2694
+ i += 2;
2695
+ base = 16;
2696
+ isdigit = th_ishexdig;
2697
+ }else if( z[i+1]=='o' || z[i+1]=='O' ){
2698
+ i += 2;
2699
+ base = 8;
2700
+ isdigit = th_isoctdig;
2701
+ }else if( z[i+1]=='b' || z[i+1]=='B' ){
2702
+ i += 2;
2703
+ base = 2;
2704
+ isdigit = th_isbindig;
26692705
}
26702706
}
26712707
for(; i<n; i++){
26722708
char c = z[i];
26732709
if( !isdigit(c) ){
@@ -2823,5 +2859,44 @@
28232859
}
28242860
28252861
*z = '\0';
28262862
return Th_SetResult(interp, zBuf, -1);
28272863
}
2864
+
2865
+/*
2866
+** Appends all currently registered command names to the specified list
2867
+** and returns TH_OK upon success. Any other return value indicates an
2868
+** error.
2869
+*/
2870
+int Th_ListAppendCommands(Th_Interp *interp, char **pzList, int *pnList){
2871
+ Th_InterpAndList *p = (Th_InterpAndList *)Th_Malloc(
2872
+ interp, sizeof(Th_InterpAndList)
2873
+ );
2874
+ p->interp = interp;
2875
+ p->pzList = pzList;
2876
+ p->pnList = pnList;
2877
+ Th_HashIterate(interp, interp->paCmd, thListAppendHashKey, p);
2878
+ Th_Free(interp, p);
2879
+ return TH_OK;
2880
+}
2881
+
2882
+/*
2883
+** Appends all variable names for the current frame to the specified list
2884
+** and returns TH_OK upon success. Any other return value indicates an
2885
+** error. If the current frame cannot be obtained, TH_ERROR is returned.
2886
+*/
2887
+int Th_ListAppendVariables(Th_Interp *interp, char **pzList, int *pnList){
2888
+ Th_Frame *pFrame = getFrame(interp, 0);
2889
+ if( pFrame ){
2890
+ Th_InterpAndList *p = (Th_InterpAndList *)Th_Malloc(
2891
+ interp, sizeof(Th_InterpAndList)
2892
+ );
2893
+ p->interp = interp;
2894
+ p->pzList = pzList;
2895
+ p->pnList = pnList;
2896
+ Th_HashIterate(interp, pFrame->paVar, thListAppendHashKey, p);
2897
+ Th_Free(interp, p);
2898
+ return TH_OK;
2899
+ }else{
2900
+ return TH_ERROR;
2901
+ }
2902
+}
28282903
--- src/th.c
+++ src/th.c
@@ -7,13 +7,14 @@
7 #include "config.h"
8 #include "th.h"
9 #include <string.h>
10 #include <assert.h>
11
12 typedef struct Th_Command Th_Command;
13 typedef struct Th_Frame Th_Frame;
14 typedef struct Th_Variable Th_Variable;
 
15
16 /*
17 ** Interpreter structure.
18 */
19 struct Th_Interp {
@@ -87,10 +88,21 @@
87 int nRef; /* Number of references to this structure */
88 int nData; /* Number of bytes at Th_Variable.zData */
89 char *zData; /* Data for scalar variables */
90 Th_Hash *pHash; /* Data for array variables */
91 };
 
 
 
 
 
 
 
 
 
 
 
92
93 /*
94 ** Hash table API:
95 */
96 #define TH_HASHSIZE 257
@@ -298,10 +310,25 @@
298 }
299 Th_Free((Th_Interp *)pContext, pEntry->pData);
300 pEntry->pData = 0;
301 return 1;
302 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
304 /*
305 ** Push a new frame onto the stack.
306 */
307 static int thPushFrame(Th_Interp *interp, Th_Frame *pFrame){
@@ -2227,18 +2254,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 +2684,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) ){
@@ -2823,5 +2859,44 @@
2823 }
2824
2825 *z = '\0';
2826 return Th_SetResult(interp, zBuf, -1);
2827 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2828
--- src/th.c
+++ src/th.c
@@ -7,13 +7,14 @@
7 #include "config.h"
8 #include "th.h"
9 #include <string.h>
10 #include <assert.h>
11
12 typedef struct Th_Command Th_Command;
13 typedef struct Th_Frame Th_Frame;
14 typedef struct Th_Variable Th_Variable;
15 typedef struct Th_InterpAndList Th_InterpAndList;
16
17 /*
18 ** Interpreter structure.
19 */
20 struct Th_Interp {
@@ -87,10 +88,21 @@
88 int nRef; /* Number of references to this structure */
89 int nData; /* Number of bytes at Th_Variable.zData */
90 char *zData; /* Data for scalar variables */
91 Th_Hash *pHash; /* Data for array variables */
92 };
93
94 /*
95 ** This structure is used to pass complete context information to the
96 ** hash iteration callback functions that need a Th_Interp and a list
97 ** to operate on, e.g. thListAppendHashKey().
98 */
99 struct Th_InterpAndList {
100 Th_Interp *interp; /* Associated interpreter context */
101 char **pzList; /* IN/OUT: Ptr to ptr to list */
102 int *pnList; /* IN/OUT: Current length of *pzList */
103 };
104
105 /*
106 ** Hash table API:
107 */
108 #define TH_HASHSIZE 257
@@ -298,10 +310,25 @@
310 }
311 Th_Free((Th_Interp *)pContext, pEntry->pData);
312 pEntry->pData = 0;
313 return 1;
314 }
315
316 /*
317 ** Argument pEntry points to an entry in a hash table. The key is
318 ** the list element to be added.
319 **
320 ** Argument pContext is a pointer to the Th_InterpAndList structure.
321 **
322 ** Always returns non-zero.
323 */
324 static int thListAppendHashKey(Th_HashEntry *pEntry, void *pContext){
325 Th_InterpAndList *pInterpAndList = (Th_InterpAndList *)pContext;
326 Th_ListAppend(pInterpAndList->interp, pInterpAndList->pzList,
327 pInterpAndList->pnList, pEntry->zKey, pEntry->nKey);
328 return 1;
329 }
330
331 /*
332 ** Push a new frame onto the stack.
333 */
334 static int thPushFrame(Th_Interp *interp, Th_Frame *pFrame){
@@ -2227,18 +2254,29 @@
2254 default: {
2255 int j;
2256 const char *zOp;
2257 for(j=0; (zOp=aOperator[j].zOp); j++){
2258 int nOp = aOperator[j].nOp;
2259 int nRemain = nExpr - i;
2260 int isMatch = 0;
2261 if( nRemain>=nOp && 0==memcmp(zOp, &zExpr[i], nOp) ){
2262 isMatch = 1;
2263 }
2264 if( isMatch ){
2265 if( aOperator[j].eOp==OP_CLOSE_BRACKET ){
2266 nNest--;
2267 }else if( nRemain>nOp ){
2268 if( aOperator[j].eOp==OP_OPEN_BRACKET ){
2269 nNest++;
2270 }
2271 }else{
2272 /*
2273 ** This is not really a match because this operator cannot
2274 ** legally appear at the end of the string.
2275 */
2276 isMatch = 0;
2277 }
2278 }
2279 if( nToken>0 && aOperator[j].iPrecedence==1 ){
2280 Expr *pPrev = apToken[nToken-1];
2281 if( !pPrev->pOp || pPrev->pOp->eOp==OP_CLOSE_BRACKET ){
2282 continue;
@@ -2646,28 +2684,26 @@
2684
2685 if( n<0 ){
2686 n = th_strlen(z);
2687 }
2688
2689 if( n>1 && (z[0]=='-' || z[0]=='+') ){
2690 i = 1;
2691 }
2692 if( (n-i)>2 && z[i]=='0' ){
2693 if( z[i+1]=='x' || z[i+1]=='X' ){
2694 i += 2;
2695 base = 16;
2696 isdigit = th_ishexdig;
2697 }else if( z[i+1]=='o' || z[i+1]=='O' ){
2698 i += 2;
2699 base = 8;
2700 isdigit = th_isoctdig;
2701 }else if( z[i+1]=='b' || z[i+1]=='B' ){
2702 i += 2;
2703 base = 2;
2704 isdigit = th_isbindig;
 
 
2705 }
2706 }
2707 for(; i<n; i++){
2708 char c = z[i];
2709 if( !isdigit(c) ){
@@ -2823,5 +2859,44 @@
2859 }
2860
2861 *z = '\0';
2862 return Th_SetResult(interp, zBuf, -1);
2863 }
2864
2865 /*
2866 ** Appends all currently registered command names to the specified list
2867 ** and returns TH_OK upon success. Any other return value indicates an
2868 ** error.
2869 */
2870 int Th_ListAppendCommands(Th_Interp *interp, char **pzList, int *pnList){
2871 Th_InterpAndList *p = (Th_InterpAndList *)Th_Malloc(
2872 interp, sizeof(Th_InterpAndList)
2873 );
2874 p->interp = interp;
2875 p->pzList = pzList;
2876 p->pnList = pnList;
2877 Th_HashIterate(interp, interp->paCmd, thListAppendHashKey, p);
2878 Th_Free(interp, p);
2879 return TH_OK;
2880 }
2881
2882 /*
2883 ** Appends all variable names for the current frame to the specified list
2884 ** and returns TH_OK upon success. Any other return value indicates an
2885 ** error. If the current frame cannot be obtained, TH_ERROR is returned.
2886 */
2887 int Th_ListAppendVariables(Th_Interp *interp, char **pzList, int *pnList){
2888 Th_Frame *pFrame = getFrame(interp, 0);
2889 if( pFrame ){
2890 Th_InterpAndList *p = (Th_InterpAndList *)Th_Malloc(
2891 interp, sizeof(Th_InterpAndList)
2892 );
2893 p->interp = interp;
2894 p->pzList = pzList;
2895 p->pnList = pnList;
2896 Th_HashIterate(interp, pFrame->paVar, thListAppendHashKey, p);
2897 Th_Free(interp, p);
2898 return TH_OK;
2899 }else{
2900 return TH_ERROR;
2901 }
2902 }
2903
+6
--- src/th.h
+++ src/th.h
@@ -138,10 +138,16 @@
138138
int Th_ToInt(Th_Interp *, const char *, int, int *);
139139
int Th_ToDouble(Th_Interp *, const char *, int, double *);
140140
int Th_SetResultInt(Th_Interp *, int);
141141
int Th_SetResultDouble(Th_Interp *, double);
142142
143
+/*
144
+** Functions for handling command and variable introspection.
145
+*/
146
+int Th_ListAppendCommands(Th_Interp *, char **, int *);
147
+int Th_ListAppendVariables(Th_Interp *, char **, int *);
148
+
143149
/*
144150
** Drop in replacements for the corresponding standard library functions.
145151
*/
146152
int th_strlen(const char *);
147153
int th_isdigit(char);
148154
--- src/th.h
+++ src/th.h
@@ -138,10 +138,16 @@
138 int Th_ToInt(Th_Interp *, const char *, int, int *);
139 int Th_ToDouble(Th_Interp *, const char *, int, double *);
140 int Th_SetResultInt(Th_Interp *, int);
141 int Th_SetResultDouble(Th_Interp *, double);
142
 
 
 
 
 
 
143 /*
144 ** Drop in replacements for the corresponding standard library functions.
145 */
146 int th_strlen(const char *);
147 int th_isdigit(char);
148
--- src/th.h
+++ src/th.h
@@ -138,10 +138,16 @@
138 int Th_ToInt(Th_Interp *, const char *, int, int *);
139 int Th_ToDouble(Th_Interp *, const char *, int, double *);
140 int Th_SetResultInt(Th_Interp *, int);
141 int Th_SetResultDouble(Th_Interp *, double);
142
143 /*
144 ** Functions for handling command and variable introspection.
145 */
146 int Th_ListAppendCommands(Th_Interp *, char **, int *);
147 int Th_ListAppendVariables(Th_Interp *, char **, int *);
148
149 /*
150 ** Drop in replacements for the corresponding standard library functions.
151 */
152 int th_strlen(const char *);
153 int th_isdigit(char);
154
+52 -2
--- src/th_lang.c
+++ src/th_lang.c
@@ -848,11 +848,11 @@
848848
}
849849
850850
/*
851851
** TH Syntax:
852852
**
853
-** info exists VAR
853
+** info exists VARNAME
854854
*/
855855
static int info_exists_command(
856856
Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
857857
){
858858
int rc;
@@ -862,10 +862,56 @@
862862
}
863863
rc = Th_ExistsVar(interp, argv[2], argl[2]);
864864
Th_SetResultInt(interp, rc);
865865
return TH_OK;
866866
}
867
+
868
+/*
869
+** TH Syntax:
870
+**
871
+** info commands
872
+*/
873
+static int info_commands_command(
874
+ Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
875
+){
876
+ int rc;
877
+ char *zElem = 0;
878
+ int nElem = 0;
879
+
880
+ if( argc!=2 ){
881
+ return Th_WrongNumArgs(interp, "info commands");
882
+ }
883
+ rc = Th_ListAppendCommands(interp, &zElem, &nElem);
884
+ if( rc!=TH_OK ){
885
+ return rc;
886
+ }
887
+ Th_SetResult(interp, zElem, nElem);
888
+ return TH_OK;
889
+}
890
+
891
+/*
892
+** TH Syntax:
893
+**
894
+** info vars
895
+*/
896
+static int info_vars_command(
897
+ Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
898
+){
899
+ int rc;
900
+ char *zElem = 0;
901
+ int nElem = 0;
902
+
903
+ if( argc!=2 ){
904
+ return Th_WrongNumArgs(interp, "info vars");
905
+ }
906
+ rc = Th_ListAppendVariables(interp, &zElem, &nElem);
907
+ if( rc!=TH_OK ){
908
+ return rc;
909
+ }
910
+ Th_SetResult(interp, zElem, nElem);
911
+ return TH_OK;
912
+}
867913
868914
/*
869915
** TH Syntax:
870916
**
871917
** unset VAR
@@ -943,21 +989,25 @@
943989
}
944990
945991
/*
946992
** TH Syntax:
947993
**
994
+** info commands
948995
** info exists VARNAME
996
+** info vars
949997
*/
950998
static int info_command(
951999
Th_Interp *interp,
9521000
void *ctx,
9531001
int argc,
9541002
const char **argv,
9551003
int *argl
9561004
){
9571005
static const Th_SubCommand aSub[] = {
958
- { "exists", info_exists_command },
1006
+ { "commands", info_commands_command },
1007
+ { "exists", info_exists_command },
1008
+ { "vars", info_vars_command },
9591009
{ 0, 0 }
9601010
};
9611011
return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
9621012
}
9631013
9641014
--- src/th_lang.c
+++ src/th_lang.c
@@ -848,11 +848,11 @@
848 }
849
850 /*
851 ** TH Syntax:
852 **
853 ** info exists VAR
854 */
855 static int info_exists_command(
856 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
857 ){
858 int rc;
@@ -862,10 +862,56 @@
862 }
863 rc = Th_ExistsVar(interp, argv[2], argl[2]);
864 Th_SetResultInt(interp, rc);
865 return TH_OK;
866 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
867
868 /*
869 ** TH Syntax:
870 **
871 ** unset VAR
@@ -943,21 +989,25 @@
943 }
944
945 /*
946 ** TH Syntax:
947 **
 
948 ** info exists VARNAME
 
949 */
950 static int info_command(
951 Th_Interp *interp,
952 void *ctx,
953 int argc,
954 const char **argv,
955 int *argl
956 ){
957 static const Th_SubCommand aSub[] = {
958 { "exists", info_exists_command },
 
 
959 { 0, 0 }
960 };
961 return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
962 }
963
964
--- src/th_lang.c
+++ src/th_lang.c
@@ -848,11 +848,11 @@
848 }
849
850 /*
851 ** TH Syntax:
852 **
853 ** info exists VARNAME
854 */
855 static int info_exists_command(
856 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
857 ){
858 int rc;
@@ -862,10 +862,56 @@
862 }
863 rc = Th_ExistsVar(interp, argv[2], argl[2]);
864 Th_SetResultInt(interp, rc);
865 return TH_OK;
866 }
867
868 /*
869 ** TH Syntax:
870 **
871 ** info commands
872 */
873 static int info_commands_command(
874 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
875 ){
876 int rc;
877 char *zElem = 0;
878 int nElem = 0;
879
880 if( argc!=2 ){
881 return Th_WrongNumArgs(interp, "info commands");
882 }
883 rc = Th_ListAppendCommands(interp, &zElem, &nElem);
884 if( rc!=TH_OK ){
885 return rc;
886 }
887 Th_SetResult(interp, zElem, nElem);
888 return TH_OK;
889 }
890
891 /*
892 ** TH Syntax:
893 **
894 ** info vars
895 */
896 static int info_vars_command(
897 Th_Interp *interp, void *ctx, int argc, const char **argv, int *argl
898 ){
899 int rc;
900 char *zElem = 0;
901 int nElem = 0;
902
903 if( argc!=2 ){
904 return Th_WrongNumArgs(interp, "info vars");
905 }
906 rc = Th_ListAppendVariables(interp, &zElem, &nElem);
907 if( rc!=TH_OK ){
908 return rc;
909 }
910 Th_SetResult(interp, zElem, nElem);
911 return TH_OK;
912 }
913
914 /*
915 ** TH Syntax:
916 **
917 ** unset VAR
@@ -943,21 +989,25 @@
989 }
990
991 /*
992 ** TH Syntax:
993 **
994 ** info commands
995 ** info exists VARNAME
996 ** info vars
997 */
998 static int info_command(
999 Th_Interp *interp,
1000 void *ctx,
1001 int argc,
1002 const char **argv,
1003 int *argl
1004 ){
1005 static const Th_SubCommand aSub[] = {
1006 { "commands", info_commands_command },
1007 { "exists", info_exists_command },
1008 { "vars", info_vars_command },
1009 { 0, 0 }
1010 };
1011 return Th_CallSubCommand(interp, ctx, argc, argv, argl, aSub);
1012 }
1013
1014
+10 -2
--- src/th_main.c
+++ src/th_main.c
@@ -174,11 +174,11 @@
174174
static int enableOutput = 1;
175175
176176
/*
177177
** TH1 command: enable_output BOOLEAN
178178
**
179
-** Enable or disable the puts and hputs commands.
179
+** Enable or disable the puts and wiki commands.
180180
*/
181181
static int enableOutputCmd(
182182
Th_Interp *interp,
183183
void *p,
184184
int argc,
@@ -339,13 +339,15 @@
339339
sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
340340
return TH_OK;
341341
}
342342
343343
/*
344
+** TH1 command: decorate STRING
344345
** TH1 command: wiki STRING
345346
**
346
-** Render the input string as wiki.
347
+** Render the input string as wiki. For the decorate command, only links
348
+** are handled.
347349
*/
348350
static int wikiCmd(
349351
Th_Interp *interp,
350352
void *p,
351353
int argc,
@@ -505,10 +507,11 @@
505507
**
506508
** Return true if the fossil binary has the given compile-time feature
507509
** enabled. The set of features includes:
508510
**
509511
** "ssl" = FOSSIL_ENABLE_SSL
512
+** "legacyMvRm" = FOSSIL_ENABLE_LEGACY_MV_RM
510513
** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS
511514
** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS
512515
** "tcl" = FOSSIL_ENABLE_TCL
513516
** "useTclStubs" = USE_TCL_STUBS
514517
** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS
@@ -536,10 +539,15 @@
536539
}
537540
#if defined(FOSSIL_ENABLE_SSL)
538541
else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
539542
rc = 1;
540543
}
544
+#endif
545
+#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
546
+ else if( 0 == fossil_strnicmp( zArg, "legacyMvRm\0", 11 ) ){
547
+ rc = 1;
548
+ }
541549
#endif
542550
#if defined(FOSSIL_ENABLE_TH1_DOCS)
543551
else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){
544552
rc = 1;
545553
}
546554
--- src/th_main.c
+++ src/th_main.c
@@ -174,11 +174,11 @@
174 static int enableOutput = 1;
175
176 /*
177 ** TH1 command: enable_output BOOLEAN
178 **
179 ** Enable or disable the puts and hputs commands.
180 */
181 static int enableOutputCmd(
182 Th_Interp *interp,
183 void *p,
184 int argc,
@@ -339,13 +339,15 @@
339 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
340 return TH_OK;
341 }
342
343 /*
 
344 ** TH1 command: wiki STRING
345 **
346 ** Render the input string as wiki.
 
347 */
348 static int wikiCmd(
349 Th_Interp *interp,
350 void *p,
351 int argc,
@@ -505,10 +507,11 @@
505 **
506 ** Return true if the fossil binary has the given compile-time feature
507 ** enabled. The set of features includes:
508 **
509 ** "ssl" = FOSSIL_ENABLE_SSL
 
510 ** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS
511 ** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS
512 ** "tcl" = FOSSIL_ENABLE_TCL
513 ** "useTclStubs" = USE_TCL_STUBS
514 ** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS
@@ -536,10 +539,15 @@
536 }
537 #if defined(FOSSIL_ENABLE_SSL)
538 else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
539 rc = 1;
540 }
 
 
 
 
 
541 #endif
542 #if defined(FOSSIL_ENABLE_TH1_DOCS)
543 else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){
544 rc = 1;
545 }
546
--- src/th_main.c
+++ src/th_main.c
@@ -174,11 +174,11 @@
174 static int enableOutput = 1;
175
176 /*
177 ** TH1 command: enable_output BOOLEAN
178 **
179 ** Enable or disable the puts and wiki commands.
180 */
181 static int enableOutputCmd(
182 Th_Interp *interp,
183 void *p,
184 int argc,
@@ -339,13 +339,15 @@
339 sendText((char*)argv[1], argl[1], *(unsigned int*)pConvert);
340 return TH_OK;
341 }
342
343 /*
344 ** TH1 command: decorate STRING
345 ** TH1 command: wiki STRING
346 **
347 ** Render the input string as wiki. For the decorate command, only links
348 ** are handled.
349 */
350 static int wikiCmd(
351 Th_Interp *interp,
352 void *p,
353 int argc,
@@ -505,10 +507,11 @@
507 **
508 ** Return true if the fossil binary has the given compile-time feature
509 ** enabled. The set of features includes:
510 **
511 ** "ssl" = FOSSIL_ENABLE_SSL
512 ** "legacyMvRm" = FOSSIL_ENABLE_LEGACY_MV_RM
513 ** "th1Docs" = FOSSIL_ENABLE_TH1_DOCS
514 ** "th1Hooks" = FOSSIL_ENABLE_TH1_HOOKS
515 ** "tcl" = FOSSIL_ENABLE_TCL
516 ** "useTclStubs" = USE_TCL_STUBS
517 ** "tclStubs" = FOSSIL_ENABLE_TCL_STUBS
@@ -536,10 +539,15 @@
539 }
540 #if defined(FOSSIL_ENABLE_SSL)
541 else if( 0 == fossil_strnicmp( zArg, "ssl\0", 4 ) ){
542 rc = 1;
543 }
544 #endif
545 #if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
546 else if( 0 == fossil_strnicmp( zArg, "legacyMvRm\0", 11 ) ){
547 rc = 1;
548 }
549 #endif
550 #if defined(FOSSIL_ENABLE_TH1_DOCS)
551 else if( 0 == fossil_strnicmp( zArg, "th1Docs\0", 8 ) ){
552 rc = 1;
553 }
554
+61 -16
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -250,10 +250,44 @@
250250
** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
251251
** by the caller. This must be declared here because quite a few functions in
252252
** this file need to use it before it can be defined.
253253
*/
254254
static int createTclInterp(Th_Interp *interp, void *pContext);
255
+
256
+/*
257
+** Returns the TH1 return code corresponding to the specified Tcl
258
+** return code.
259
+*/
260
+static int getTh1ReturnCode(
261
+ int rc /* The Tcl return code value to convert. */
262
+){
263
+ switch( rc ){
264
+ case /*0*/ TCL_OK: return /*0*/ TH_OK;
265
+ case /*1*/ TCL_ERROR: return /*1*/ TH_ERROR;
266
+ case /*2*/ TCL_RETURN: return /*3*/ TH_RETURN;
267
+ case /*3*/ TCL_BREAK: return /*2*/ TH_BREAK;
268
+ case /*4*/ TCL_CONTINUE: return /*4*/ TH_CONTINUE;
269
+ default /*?*/: return /*?*/ rc;
270
+ }
271
+}
272
+
273
+/*
274
+** Returns the Tcl return code corresponding to the specified TH1
275
+** return code.
276
+*/
277
+static int getTclReturnCode(
278
+ int rc /* The TH1 return code value to convert. */
279
+){
280
+ switch( rc ){
281
+ case /*0*/ TH_OK: return /*0*/ TCL_OK;
282
+ case /*1*/ TH_ERROR: return /*1*/ TCL_ERROR;
283
+ case /*2*/ TH_BREAK: return /*3*/ TCL_BREAK;
284
+ case /*3*/ TH_RETURN: return /*2*/ TCL_RETURN;
285
+ case /*4*/ TH_CONTINUE: return /*4*/ TCL_CONTINUE;
286
+ default /*?*/: return /*?*/ rc;
287
+ }
288
+}
255289
256290
/*
257291
** Returns a name for a Tcl return code.
258292
*/
259293
static const char *getTclReturnCodeName(
@@ -263,12 +297,12 @@
263297
static char zRc[32];
264298
265299
switch( rc ){
266300
case TCL_OK: return nullIfOk ? 0 : "TCL_OK";
267301
case TCL_ERROR: return "TCL_ERROR";
268
- case TCL_BREAK: return "TCL_BREAK";
269302
case TCL_RETURN: return "TCL_RETURN";
303
+ case TCL_BREAK: return "TCL_BREAK";
270304
case TCL_CONTINUE: return "TCL_CONTINUE";
271305
default: {
272306
sqlite3_snprintf(sizeof(zRc), zRc, "Tcl return code %d", rc);
273307
}
274308
}
@@ -350,13 +384,15 @@
350384
}
351385
return rc;
352386
}
353387
354388
/*
355
-** Syntax:
389
+** TH1 command: tclEval arg ?arg ...?
356390
**
357
-** tclEval arg ?arg ...?
391
+** Evaluates the Tcl script and returns its result verbatim. If a Tcl script
392
+** error is generated, it will be transformed into a TH1 script error. A Tcl
393
+** interpreter will be created automatically if it has not been already.
358394
*/
359395
static int tclEval_command(
360396
Th_Interp *interp,
361397
void *ctx,
362398
int argc,
@@ -400,18 +436,21 @@
400436
FREE_ARGV_TO_OBJV();
401437
}
402438
zResult = getTclResult(tclInterp, &nResult);
403439
Th_SetResult(interp, zResult, nResult);
404440
Tcl_Release((ClientData)tclInterp);
405
- rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
441
+ rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
442
+ getTh1ReturnCode(rc));
406443
return rc;
407444
}
408445
409446
/*
410
-** Syntax:
447
+** TH1 command: tclExpr arg ?arg ...?
411448
**
412
-** tclExpr arg ?arg ...?
449
+** Evaluates the Tcl expression and returns its result verbatim. If a Tcl
450
+** script error is generated, it will be transformed into a TH1 script error.
451
+** A Tcl interpreter will be created automatically if it has not been already.
413452
*/
414453
static int tclExpr_command(
415454
Th_Interp *interp,
416455
void *ctx,
417456
int argc,
@@ -461,18 +500,21 @@
461500
zResult = getTclResult(tclInterp, &nResult);
462501
}
463502
Th_SetResult(interp, zResult, nResult);
464503
if( rc==TCL_OK ) Tcl_DecrRefCount(resultObjPtr);
465504
Tcl_Release((ClientData)tclInterp);
466
- rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
505
+ rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
506
+ getTh1ReturnCode(rc));
467507
return rc;
468508
}
469509
470510
/*
471
-** Syntax:
511
+** TH1 command: tclInvoke command ?arg ...?
472512
**
473
-** tclInvoke command ?arg ...?
513
+** Invokes the Tcl command using the supplied arguments. No additional
514
+** substitutions are performed on the arguments. A Tcl interpreter will
515
+** be created automatically if it has not been already.
474516
*/
475517
static int tclInvoke_command(
476518
Th_Interp *interp,
477519
void *ctx,
478520
int argc,
@@ -533,18 +575,20 @@
533575
FREE_ARGV_TO_OBJV();
534576
}
535577
zResult = getTclResult(tclInterp, &nResult);
536578
Th_SetResult(interp, zResult, nResult);
537579
Tcl_Release((ClientData)tclInterp);
538
- rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
580
+ rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
581
+ getTh1ReturnCode(rc));
539582
return rc;
540583
}
541584
542585
/*
543
-** Syntax:
586
+** Tcl command: th1Eval arg
544587
**
545
-** th1Eval arg
588
+** Evaluates the TH1 script and returns its result verbatim. If a TH1 script
589
+** error is generated, it will be transformed into a Tcl script error.
546590
*/
547591
static int Th1EvalObjCmd(
548592
ClientData clientData,
549593
Tcl_Interp *interp,
550594
int objc,
@@ -566,17 +610,18 @@
566610
}
567611
arg = Tcl_GetStringFromObj(objv[1], &nArg);
568612
rc = Th_Eval(th1Interp, 0, arg, nArg);
569613
arg = Th_GetResult(th1Interp, &nArg);
570614
Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
571
- return rc;
615
+ return getTclReturnCode(rc);
572616
}
573617
574618
/*
575
-** Syntax:
619
+** Tcl command: th1Expr arg
576620
**
577
-** th1Expr arg
621
+** Evaluates the TH1 expression and returns its result verbatim. If a TH1
622
+** script error is generated, it will be transformed into a Tcl script error.
578623
*/
579624
static int Th1ExprObjCmd(
580625
ClientData clientData,
581626
Tcl_Interp *interp,
582627
int objc,
@@ -598,11 +643,11 @@
598643
}
599644
arg = Tcl_GetStringFromObj(objv[1], &nArg);
600645
rc = Th_Expr(th1Interp, arg, nArg);
601646
arg = Th_GetResult(th1Interp, &nArg);
602647
Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
603
- return rc;
648
+ return getTclReturnCode(rc);
604649
}
605650
606651
/*
607652
** Array of Tcl integration commands. Used when adding or removing the Tcl
608653
** integration commands from TH1.
609654
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -250,10 +250,44 @@
250 ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
251 ** by the caller. This must be declared here because quite a few functions in
252 ** this file need to use it before it can be defined.
253 */
254 static int createTclInterp(Th_Interp *interp, void *pContext);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
255
256 /*
257 ** Returns a name for a Tcl return code.
258 */
259 static const char *getTclReturnCodeName(
@@ -263,12 +297,12 @@
263 static char zRc[32];
264
265 switch( rc ){
266 case TCL_OK: return nullIfOk ? 0 : "TCL_OK";
267 case TCL_ERROR: return "TCL_ERROR";
268 case TCL_BREAK: return "TCL_BREAK";
269 case TCL_RETURN: return "TCL_RETURN";
 
270 case TCL_CONTINUE: return "TCL_CONTINUE";
271 default: {
272 sqlite3_snprintf(sizeof(zRc), zRc, "Tcl return code %d", rc);
273 }
274 }
@@ -350,13 +384,15 @@
350 }
351 return rc;
352 }
353
354 /*
355 ** Syntax:
356 **
357 ** tclEval arg ?arg ...?
 
 
358 */
359 static int tclEval_command(
360 Th_Interp *interp,
361 void *ctx,
362 int argc,
@@ -400,18 +436,21 @@
400 FREE_ARGV_TO_OBJV();
401 }
402 zResult = getTclResult(tclInterp, &nResult);
403 Th_SetResult(interp, zResult, nResult);
404 Tcl_Release((ClientData)tclInterp);
405 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
 
406 return rc;
407 }
408
409 /*
410 ** Syntax:
411 **
412 ** tclExpr arg ?arg ...?
 
 
413 */
414 static int tclExpr_command(
415 Th_Interp *interp,
416 void *ctx,
417 int argc,
@@ -461,18 +500,21 @@
461 zResult = getTclResult(tclInterp, &nResult);
462 }
463 Th_SetResult(interp, zResult, nResult);
464 if( rc==TCL_OK ) Tcl_DecrRefCount(resultObjPtr);
465 Tcl_Release((ClientData)tclInterp);
466 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
 
467 return rc;
468 }
469
470 /*
471 ** Syntax:
472 **
473 ** tclInvoke command ?arg ...?
 
 
474 */
475 static int tclInvoke_command(
476 Th_Interp *interp,
477 void *ctx,
478 int argc,
@@ -533,18 +575,20 @@
533 FREE_ARGV_TO_OBJV();
534 }
535 zResult = getTclResult(tclInterp, &nResult);
536 Th_SetResult(interp, zResult, nResult);
537 Tcl_Release((ClientData)tclInterp);
538 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl, rc);
 
539 return rc;
540 }
541
542 /*
543 ** Syntax:
544 **
545 ** th1Eval arg
 
546 */
547 static int Th1EvalObjCmd(
548 ClientData clientData,
549 Tcl_Interp *interp,
550 int objc,
@@ -566,17 +610,18 @@
566 }
567 arg = Tcl_GetStringFromObj(objv[1], &nArg);
568 rc = Th_Eval(th1Interp, 0, arg, nArg);
569 arg = Th_GetResult(th1Interp, &nArg);
570 Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
571 return rc;
572 }
573
574 /*
575 ** Syntax:
576 **
577 ** th1Expr arg
 
578 */
579 static int Th1ExprObjCmd(
580 ClientData clientData,
581 Tcl_Interp *interp,
582 int objc,
@@ -598,11 +643,11 @@
598 }
599 arg = Tcl_GetStringFromObj(objv[1], &nArg);
600 rc = Th_Expr(th1Interp, arg, nArg);
601 arg = Th_GetResult(th1Interp, &nArg);
602 Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
603 return rc;
604 }
605
606 /*
607 ** Array of Tcl integration commands. Used when adding or removing the Tcl
608 ** integration commands from TH1.
609
--- src/th_tcl.c
+++ src/th_tcl.c
@@ -250,10 +250,44 @@
250 ** interpreter. Stores the created Tcl interpreter in the Tcl context supplied
251 ** by the caller. This must be declared here because quite a few functions in
252 ** this file need to use it before it can be defined.
253 */
254 static int createTclInterp(Th_Interp *interp, void *pContext);
255
256 /*
257 ** Returns the TH1 return code corresponding to the specified Tcl
258 ** return code.
259 */
260 static int getTh1ReturnCode(
261 int rc /* The Tcl return code value to convert. */
262 ){
263 switch( rc ){
264 case /*0*/ TCL_OK: return /*0*/ TH_OK;
265 case /*1*/ TCL_ERROR: return /*1*/ TH_ERROR;
266 case /*2*/ TCL_RETURN: return /*3*/ TH_RETURN;
267 case /*3*/ TCL_BREAK: return /*2*/ TH_BREAK;
268 case /*4*/ TCL_CONTINUE: return /*4*/ TH_CONTINUE;
269 default /*?*/: return /*?*/ rc;
270 }
271 }
272
273 /*
274 ** Returns the Tcl return code corresponding to the specified TH1
275 ** return code.
276 */
277 static int getTclReturnCode(
278 int rc /* The TH1 return code value to convert. */
279 ){
280 switch( rc ){
281 case /*0*/ TH_OK: return /*0*/ TCL_OK;
282 case /*1*/ TH_ERROR: return /*1*/ TCL_ERROR;
283 case /*2*/ TH_BREAK: return /*3*/ TCL_BREAK;
284 case /*3*/ TH_RETURN: return /*2*/ TCL_RETURN;
285 case /*4*/ TH_CONTINUE: return /*4*/ TCL_CONTINUE;
286 default /*?*/: return /*?*/ rc;
287 }
288 }
289
290 /*
291 ** Returns a name for a Tcl return code.
292 */
293 static const char *getTclReturnCodeName(
@@ -263,12 +297,12 @@
297 static char zRc[32];
298
299 switch( rc ){
300 case TCL_OK: return nullIfOk ? 0 : "TCL_OK";
301 case TCL_ERROR: return "TCL_ERROR";
 
302 case TCL_RETURN: return "TCL_RETURN";
303 case TCL_BREAK: return "TCL_BREAK";
304 case TCL_CONTINUE: return "TCL_CONTINUE";
305 default: {
306 sqlite3_snprintf(sizeof(zRc), zRc, "Tcl return code %d", rc);
307 }
308 }
@@ -350,13 +384,15 @@
384 }
385 return rc;
386 }
387
388 /*
389 ** TH1 command: tclEval arg ?arg ...?
390 **
391 ** Evaluates the Tcl script and returns its result verbatim. If a Tcl script
392 ** error is generated, it will be transformed into a TH1 script error. A Tcl
393 ** interpreter will be created automatically if it has not been already.
394 */
395 static int tclEval_command(
396 Th_Interp *interp,
397 void *ctx,
398 int argc,
@@ -400,18 +436,21 @@
436 FREE_ARGV_TO_OBJV();
437 }
438 zResult = getTclResult(tclInterp, &nResult);
439 Th_SetResult(interp, zResult, nResult);
440 Tcl_Release((ClientData)tclInterp);
441 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
442 getTh1ReturnCode(rc));
443 return rc;
444 }
445
446 /*
447 ** TH1 command: tclExpr arg ?arg ...?
448 **
449 ** Evaluates the Tcl expression and returns its result verbatim. If a Tcl
450 ** script error is generated, it will be transformed into a TH1 script error.
451 ** A Tcl interpreter will be created automatically if it has not been already.
452 */
453 static int tclExpr_command(
454 Th_Interp *interp,
455 void *ctx,
456 int argc,
@@ -461,18 +500,21 @@
500 zResult = getTclResult(tclInterp, &nResult);
501 }
502 Th_SetResult(interp, zResult, nResult);
503 if( rc==TCL_OK ) Tcl_DecrRefCount(resultObjPtr);
504 Tcl_Release((ClientData)tclInterp);
505 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
506 getTh1ReturnCode(rc));
507 return rc;
508 }
509
510 /*
511 ** TH1 command: tclInvoke command ?arg ...?
512 **
513 ** Invokes the Tcl command using the supplied arguments. No additional
514 ** substitutions are performed on the arguments. A Tcl interpreter will
515 ** be created automatically if it has not been already.
516 */
517 static int tclInvoke_command(
518 Th_Interp *interp,
519 void *ctx,
520 int argc,
@@ -533,18 +575,20 @@
575 FREE_ARGV_TO_OBJV();
576 }
577 zResult = getTclResult(tclInterp, &nResult);
578 Th_SetResult(interp, zResult, nResult);
579 Tcl_Release((ClientData)tclInterp);
580 rc = notifyPreOrPostEval(1, interp, ctx, argc, argv, argl,
581 getTh1ReturnCode(rc));
582 return rc;
583 }
584
585 /*
586 ** Tcl command: th1Eval arg
587 **
588 ** Evaluates the TH1 script and returns its result verbatim. If a TH1 script
589 ** error is generated, it will be transformed into a Tcl script error.
590 */
591 static int Th1EvalObjCmd(
592 ClientData clientData,
593 Tcl_Interp *interp,
594 int objc,
@@ -566,17 +610,18 @@
610 }
611 arg = Tcl_GetStringFromObj(objv[1], &nArg);
612 rc = Th_Eval(th1Interp, 0, arg, nArg);
613 arg = Th_GetResult(th1Interp, &nArg);
614 Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
615 return getTclReturnCode(rc);
616 }
617
618 /*
619 ** Tcl command: th1Expr arg
620 **
621 ** Evaluates the TH1 expression and returns its result verbatim. If a TH1
622 ** script error is generated, it will be transformed into a Tcl script error.
623 */
624 static int Th1ExprObjCmd(
625 ClientData clientData,
626 Tcl_Interp *interp,
627 int objc,
@@ -598,11 +643,11 @@
643 }
644 arg = Tcl_GetStringFromObj(objv[1], &nArg);
645 rc = Th_Expr(th1Interp, arg, nArg);
646 arg = Th_GetResult(th1Interp, &nArg);
647 Tcl_SetObjResult(interp, Tcl_NewStringObj(arg, nArg));
648 return getTclReturnCode(rc);
649 }
650
651 /*
652 ** Array of Tcl integration commands. Used when adding or removing the Tcl
653 ** integration commands from TH1.
654
+334 -269
--- 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;
@@ -163,11 +163,10 @@
163163
void test_hash_color_page(void){
164164
const char *zBr;
165165
char zNm[10];
166166
int i, cnt;
167167
login_check_credentials();
168
- if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
169168
170169
style_header("Hash Color Test");
171170
for(i=cnt=0; i<10; i++){
172171
sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i);
173172
zBr = P(zNm);
@@ -242,23 +241,17 @@
242241
dateFormat = db_get_int("timeline-date-format", 0);
243242
zDateFmt = P("datefmt");
244243
if( zDateFmt ) dateFormat = atoi(zDateFmt);
245244
if( tmFlags & TIMELINE_GRAPH ){
246245
pGraph = graph_init();
247
- /* style is not moved to css, because this is
248
- ** a technical div for the timeline graph
249
- */
250
- @ <div id="canvas" style="position:relative;height:0px;width:0px;"
251
- @ onclick="clickOnGraph(event)"></div>
252246
}
253247
db_static_prepare(&qbranch,
254248
"SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
255249
TAG_BRANCH
256250
);
257251
258
- @ <table id="timelineTable" class="timelineTable"
259
- @ onclick="clickOnGraph(event)">
252
+ @ <table id="timelineTable" class="timelineTable">
260253
blob_zero(&comment);
261254
while( db_step(pQuery)==SQLITE_ROW ){
262255
int rid = db_column_int(pQuery, 0);
263256
const char *zUuid = db_column_text(pQuery, 1);
264257
int isLeaf = db_column_int(pQuery, 5);
@@ -270,10 +263,11 @@
270263
int tagid = db_column_int(pQuery, 9);
271264
const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
272265
const char *zBr = 0; /* Branch */
273266
int commentColumn = 3; /* Column containing comment text */
274267
int modPending; /* Pending moderation */
268
+ char *zDateLink; /* URL for the link on the timestamp */
275269
char zTime[20];
276270
277271
if( zDate==0 ){
278272
zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
279273
}
@@ -351,11 +345,12 @@
351345
}else if( rid==vid ){
352346
@ <tr class="timelineCurrent">
353347
}else {
354348
@ <tr>
355349
}
356
- @ <td class="timelineTime">%s(zTime)</td>
350
+ zDateLink = href("%R/timeline?c=%!S&unhide", zUuid);
351
+ @ <td class="timelineTime">%z(zDateLink)%s(zTime)</a></td>
357352
@ <td class="timelineGraph">
358353
if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
359354
if( zType[0]=='c'
360355
&& (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
361356
){
@@ -390,11 +385,11 @@
390385
}
391386
db_reset(&qparent);
392387
gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr,
393388
zUuid, isLeaf);
394389
db_reset(&qbranch);
395
- @ <div id="m%d(gidx)"></div>
390
+ @ <div id="m%d(gidx)" class="tl-nodemark"></div>
396391
}
397392
@</td>
398393
if( zBgClr && zBgClr[0] && rid!=selectedRid ){
399394
@ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
400395
}else{
@@ -498,11 +493,11 @@
498493
&& zType[0]=='c' && g.perm.Hyperlink
499494
){
500495
int inUl = 0;
501496
if( !fchngQueryInit ){
502497
db_prepare(&fchngQuery,
503
- "SELECT (pid==0) AS isnew,"
498
+ "SELECT pid,"
504499
" fid,"
505500
" (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
506501
" (SELECT uuid FROM blob WHERE rid=fid),"
507502
" (SELECT uuid FROM blob WHERE rid=pid),"
508503
" (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
@@ -516,11 +511,12 @@
516511
fchngQueryInit = 1;
517512
}
518513
db_bind_int(&fchngQuery, ":mid", rid);
519514
while( db_step(&fchngQuery)==SQLITE_ROW ){
520515
const char *zFilename = db_column_text(&fchngQuery, 2);
521
- int isNew = db_column_int(&fchngQuery, 0);
516
+ int isNew = db_column_int(&fchngQuery, 0)<=0;
517
+ int isMergeNew = db_column_int(&fchngQuery, 0)<0;
522518
int fid = db_column_int(&fchngQuery, 1);
523519
int isDel = fid==0;
524520
const char *zOldName = db_column_text(&fchngQuery, 5);
525521
const char *zOld = db_column_text(&fchngQuery, 4);
526522
const char *zNew = db_column_text(&fchngQuery, 3);
@@ -545,12 +541,17 @@
545541
zA = href("%R/artifact/%!S",fid?zNew:zOld);
546542
if( content_is_private(fid) ){
547543
zUnpub = UNPUB_TAG;
548544
}
549545
if( isNew ){
550
- @ <li> %s(zA)%h(zFilename)</a>%s(zId) %s(zUnpub) (new file) &nbsp;
551
- @ %z(href("%R/artifact/%!S",zNew))[view]</a></li>
546
+ @ <li> %s(zA)%h(zFilename)</a>%s(zId) %s(zUnpub)
547
+ if( isMergeNew ){
548
+ @ (added by merge)
549
+ }else{
550
+ @ (new file)
551
+ }
552
+ @ &nbsp; %z(href("%R/artifact/%!S",zNew))[view]</a></li>
552553
}else if( isDel ){
553554
@ <li> %s(zA)%h(zFilename)</a> (deleted)</li>
554555
}else if( fossil_strcmp(zOld,zNew)==0 && zOldName!=0 ){
555556
@ <li> %h(zOldName) &rarr; %s(zA)%h(zFilename)</a>%s(zId)
556557
@ %s(zUnpub) %z(href("%R/artifact/%!S",zNew))[view]</a></li>
@@ -582,24 +583,48 @@
582583
graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
583584
if( pGraph->nErr ){
584585
graph_free(pGraph);
585586
pGraph = 0;
586587
}else{
587
- int w;
588
- /* style is not moved to css, because this is
589
- ** a technical div for the timeline graph
590
- */
591
- w = pGraph->mxRail*pGraph->iRailPitch + 28;
592
- @ <tr><td></td><td>
593
- @ <div id="grbtm" style="width:%d(w)px;"></div>
594
- @ </td><td></td></tr>
588
+ @ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
595589
}
596590
}
597591
@ </table>
598592
if( fchngQueryInit ) db_finalize(&fchngQuery);
599593
timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
600594
}
595
+
596
+/*
597
+** Change the RGB background color given in the argument in a foreground
598
+** color with the same hue.
599
+*/
600
+static const char *bg_to_fg(const char *zIn){
601
+ int i;
602
+ unsigned int x[3];
603
+ unsigned int mx = 0;
604
+ static int whiteFg = -1;
605
+ static char zRes[10];
606
+ if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
607
+ zIn++;
608
+ for(i=0; i<3; i++){
609
+ x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
610
+ zIn += 2;
611
+ if( x[i]>mx ) mx = x[i];
612
+ }
613
+ if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
614
+ if( whiteFg ){
615
+ /* Make the color lighter */
616
+ static const unsigned int t = 215;
617
+ if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
618
+ }else{
619
+ /* Make the color darker */
620
+ static const unsigned int t = 128;
621
+ if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
622
+ }
623
+ sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
624
+ return zRes;
625
+}
601626
602627
/*
603628
** Generate all of the necessary javascript to generate a timeline
604629
** graph.
605630
*/
@@ -610,24 +635,34 @@
610635
){
611636
if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
612637
GraphRow *pRow;
613638
int i;
614639
char cSep;
615
- int mergeOffset; /* Pixel offset from rail to merge riser */
616640
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
- */
623
- mergeOffset = iRailPitch>=14 ? 4 : iRailPitch>=13 ? 3 : 0;
624
- if( PB("nomo") ) mergeOffset = 0;
625
-
626
- @ <script>
627
- @ var railPitch=%d(iRailPitch);
628
-
641
+ int showArrowheads; /* True to draw arrowheads. False to omit. */
642
+ int circleNodes; /* True for circle nodes. False for square nodes */
643
+ int colorGraph; /* Use colors for graph lines */
644
+
645
+ iRailPitch = atoi(PD("railpitch","0"));
646
+ showArrowheads = skin_detail_boolean("timeline-arrowheads");
647
+ circleNodes = skin_detail_boolean("timeline-circle-nodes");
648
+ colorGraph = skin_detail_boolean("timeline-color-graph-lines");
649
+
650
+ @ <script>(function(){
651
+ @ "use strict";
652
+ @ var css = "";
653
+ if( circleNodes ){
654
+ @ css += ".tl-node, .tl-node:after { border-radius: 50%%; }";
655
+ }
656
+ if( !showArrowheads ){
657
+ @ css += ".tl-arrow.u { display: none; }";
658
+ }
659
+ @ if( css!=="" ){
660
+ @ var style = document.createElement("style");
661
+ @ style.textContent = css;
662
+ @ document.querySelector("head").appendChild(style);
663
+ @ }
629664
/* the rowinfo[] array contains all the information needed to generate
630665
** the graph. Each entry contains information for a single row:
631666
**
632667
** id: The id of the <div> element for the row. This is an integer.
633668
** to get an actual id, prepend "m" to the integer. The top node
@@ -635,13 +670,13 @@
635670
** bg: The background color for this row
636671
** r: The "rail" that the node for this row sits on. The left-most
637672
** rail is 0 and the number increases to the right.
638673
** d: True if there is a "descender" - an arrow coming from the bottom
639674
** of the page straight up to this node.
640
- ** mo: "merge-out". If non-zero, this is one more than the x-coordinate
675
+ ** mo: "merge-out". If non-negative, this is the rail position
641676
** for the upward portion of a merge arrow. The merge arrow goes up
642
- ** to the row identified by mu:. If this value is zero then
677
+ ** to the row identified by mu:. If this value is negative then
643678
** node has no merge children and no merge-out line is drawn.
644679
** mu: The id of the row which is the top of the merge-out arrow.
645680
** u: Draw a thick child-line out of the top of this node and up to
646681
** the node with an id equal to this value. 0 if it is straight to
647682
** the top of the page, -1 if there is no thick-line riser.
@@ -648,37 +683,25 @@
648683
** f: 0x01: a leaf node.
649684
** au: An array of integers that define thick-line risers for branches.
650685
** The integers are in pairs. For each pair, the first integer is
651686
** is the rail on which the riser should run and the second integer
652687
** is the id of the node upto which the riser should run.
653
- ** mi: "merge-in". An array of integer x-coordinates from which
688
+ ** mi: "merge-in". An array of integer rail positions from which
654689
** merge arrows should be drawn into this node. If the value is
655
- ** negative, then the x-coordinate is the absolute value of mi[]
690
+ ** negative, then the rail position is the absolute value of mi[]
656691
** and a thin merge-arrow descender is drawn to the bottom of
657692
** the screen.
658693
** h: The SHA1 hash of the object being graphed
659694
*/
660695
cgi_printf("var rowinfo = [\n");
661696
for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
662
- int mo = pRow->mergeOut;
663
- if( mo<0 ){
664
- mo = 0;
665
- }else{
666
- int x = (mo/4)*iRailPitch;
667
- switch( mo&3 ){
668
- case 0: x -= mergeOffset-2; break;
669
- case 1: x += 1; break;
670
- case 2: x += mergeOffset+1; break;
671
- }
672
- mo = x;
673
- }
674697
cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
675698
pRow->idx, /* id */
676699
pRow->zBgClr, /* bg */
677700
pRow->iRail, /* r */
678701
pRow->bDescender, /* d */
679
- mo, /* mo */
702
+ pRow->mergeOut, /* mo */
680703
pRow->mergeUpto, /* mu */
681704
pRow->aiRiser[pRow->iRail], /* u */
682705
pRow->isLeaf ? 1 : 0 /* f */
683706
);
684707
/* u */
@@ -689,18 +712,20 @@
689712
cgi_printf("%c%d,%d", cSep, i, pRow->aiRiser[i]);
690713
cSep = ',';
691714
}
692715
}
693716
if( cSep=='[' ) cgi_printf("[");
694
- cgi_printf("],mi:");
717
+ cgi_printf("],");
718
+ if( colorGraph && pRow->zBgClr[0]=='#' ){
719
+ cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
720
+ }
695721
/* mi */
722
+ cgi_printf("mi:");
696723
cSep = '[';
697724
for(i=0; i<GR_MAX_RAIL; i++){
698725
if( pRow->mergeIn[i] ){
699
- int mi = i*iRailPitch;
700
- if( pRow->mergeIn[i]==1 ) mi -= mergeOffset-1;
701
- if( pRow->mergeIn[i]==3 ) mi += mergeOffset;
726
+ int mi = i;
702727
if( pRow->mergeDown & (1<<i) ) mi = -mi;
703728
cgi_printf("%c%d", cSep, mi);
704729
cSep = ',';
705730
}
706731
}
@@ -707,233 +732,238 @@
707732
if( cSep=='[' ) cgi_printf("[");
708733
cgi_printf("],h:\"%s\"}%s", pRow->zUuid, pRow->pNext ? ",\n" : "];\n");
709734
}
710735
cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
711736
graph_free(pGraph);
712
- @ var cDiv = gebi("canvas");
713
- @ var csty = window.getComputedStyle && window.getComputedStyle(cDiv,null);
714
- @ var lineClr = (csty && csty.getPropertyValue('color')) || 'black';
715
- @ var bgClr = (csty && csty.getPropertyValue('background-color')) ||'white';
716
- @ if( bgClr=='transparent' ) bgClr = 'white';
717
- @ var boxColor = lineClr;
718
- @ function drawBox(color,x0,y0,x1,y1){
737
+ @ var canvasDiv;
738
+ @ var railPitch;
739
+ @ var mergeOffset;
740
+ @ var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;
741
+ @ function initGraph(){
742
+ @ var parent = gebi("timelineTable").rows[0].cells[1];
743
+ @ parent.style.verticalAlign = "top";
744
+ @ canvasDiv = document.createElement("div");
745
+ @ canvasDiv.className = "tl-canvas";
746
+ @ canvasDiv.style.position = "absolute";
747
+ @ parent.appendChild(canvasDiv);
748
+ @
749
+ @ var elems = {};
750
+ @ var elemClasses = [
751
+ @ "rail", "mergeoffset", "node", "arrow u", "arrow u sm", "line",
752
+ @ "arrow merge r", "line merge", "arrow warp", "line warp"
753
+ @ ];
754
+ @ for( var i=0; i<elemClasses.length; i++ ){
755
+ @ var cls = elemClasses[i];
756
+ @ var elem = document.createElement("div");
757
+ @ elem.className = "tl-" + cls;
758
+ @ if( cls.indexOf("line")==0 ) elem.className += " v";
759
+ @ canvasDiv.appendChild(elem);
760
+ @ var k = cls.replace(/\s/g, "_");
761
+ @ var r = elem.getBoundingClientRect();
762
+ @ var w = Math.round(r.right - r.left);
763
+ @ var h = Math.round(r.bottom - r.top);
764
+ @ elems[k] = {w: w, h: h, cls: cls};
765
+ @ }
766
+ @ node = elems.node;
767
+ @ arrow = elems.arrow_u;
768
+ @ arrowSmall = elems.arrow_u_sm;
769
+ @ line = elems.line;
770
+ @ mArrow = elems.arrow_merge_r;
771
+ @ mLine = elems.line_merge;
772
+ @ wArrow = elems.arrow_warp;
773
+ @ wLine = elems.line_warp;
774
+ @
775
+ @ var minRailPitch = Math.ceil((node.w+line.w)/2 + mArrow.w + 1);
776
+ if( iRailPitch ){
777
+ @ railPitch = %d(iRailPitch);
778
+ }else{
779
+ @ railPitch = elems.rail.w;
780
+ @ railPitch -= Math.floor((nrail-1)*(railPitch-minRailPitch)/21);
781
+ }
782
+ @ railPitch = Math.max(railPitch, minRailPitch);
783
+ @
784
+ if( PB("nomo") ){
785
+ @ mergeOffset = 0;
786
+ }else{
787
+ @ mergeOffset = railPitch-minRailPitch-mLine.w;
788
+ @ mergeOffset = Math.min(mergeOffset, elems.mergeoffset.w);
789
+ @ mergeOffset = mergeOffset>0 ? mergeOffset + line.w/2 : 0;
790
+ }
791
+ @
792
+ @ var canvasWidth = (nrail-1)*railPitch + node.w;
793
+ @ canvasDiv.style.width = canvasWidth + "px";
794
+ @ canvasDiv.style.position = "relative";
795
+ @ }
796
+ @ function drawBox(cls,color,x0,y0,x1,y1){
719797
@ var n = document.createElement("div");
798
+ @ x0 = Math.floor(x0);
799
+ @ y0 = Math.floor(y0);
800
+ @ x1 = x1 || x1===0 ? Math.floor(x1) : x0;
801
+ @ y1 = y1 || y1===0 ? Math.floor(y1) : y0;
720802
@ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
721803
@ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
722
- @ var w = x1-x0+1;
723
- @ var h = y1-y0+1;
804
+ @ var w = x1-x0;
805
+ @ var h = y1-y0;
724806
@ n.style.position = "absolute";
725
- @ n.style.overflow = "hidden";
726807
@ n.style.left = x0+"px";
727808
@ n.style.top = y0+"px";
728
- @ n.style.width = w+"px";
729
- @ n.style.height = h+"px";
730
- @ n.style.backgroundColor = color;
731
- @ cDiv.appendChild(n);
809
+ @ if( w ) n.style.width = w+"px";
810
+ @ if( h ) n.style.height = h+"px";
811
+ @ if( color ) n.style.backgroundColor = color;
812
+ @ n.className = "tl-"+cls;
813
+ @ canvasDiv.appendChild(n);
732814
@ return n;
733815
@ }
734
- @ function absoluteY(id){
735
- @ var obj = gebi(id);
736
- @ if( !obj ) return;
816
+ @ function absoluteY(obj){
737817
@ var top = 0;
738818
@ if( obj.offsetParent ){
739819
@ do{
740820
@ top += obj.offsetTop;
741821
@ }while( obj = obj.offsetParent );
742822
@ }
743823
@ return top;
744824
@ }
745
- @ function absoluteX(id){
746
- @ var obj = gebi(id);
747
- @ if( !obj ) return;
748
- @ var left = 0;
749
- @ if( obj.offsetParent ){
750
- @ do{
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";
785
- @ n.style.width = 0;
786
- @ n.style.height = "1px";
787
- @ n.style.transform = "scale(.999)";
788
- @ n.style.borderWidth = 0;
789
- @ n.style.borderStyle = "solid";
790
- @ n.style.borderColor = "transparent";
791
- @ n.style.borderTopWidth = "2px";
792
- @ n.style.borderBottomWidth = "2px";
793
- @ if( xFrom<xTo ){
794
- @ drawBox(lineClr,xFrom,y,xTo-3,y);
795
- @ n.style.left = xTo-3+"px";
796
- @ n.style.borderLeftWidth = "3px";
797
- @ n.style.borderLeftColor = lineClr;
798
- @ }else{
799
- @ drawBox(lineClr,xTo+3,y,xFrom,y);
800
- @ n.style.left = xTo+1+"px";
801
- @ n.style.borderRightWidth = "3px";
802
- @ n.style.borderRightColor = lineClr;
803
- @ }
804
- @ cDiv.appendChild(n);
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;
825
- @ var u = rowinfo[p.mu-1];
826
- @ var y0 = u.y+5;
827
- @ if( x1>=p.x-5 && x1<=p.x+5 ){
828
- @ y1 = p.y-5;
829
- @ }else{
830
- @ drawThinLine(x0,y1,x1,y1);
831
- @ }
832
- if( mergeOffset==0 ) cgi_printf("if( p.mo!=p.u-1 ) ");
833
- @ drawThinLine(x1,y0,x1,y1);
834
- @ }
835
- @ var n = p.au.length;
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"),
848
- @ t = u.y-2,
849
- @ l = u.x-11;
850
- @ n.style.position = "absolute";
851
- @ n.style.top = t+"px";
852
- @ n.style.left = l+"px";
853
- @ n.style.width = 0;
854
- @ n.style.height = 0;
855
- @ n.style.transform = "scale(.999)";
856
- @ n.style.borderWidth = 0;
857
- @ n.style.borderStyle = "solid";
858
- @ n.style.borderColor = "transparent";
859
- @ n.style.borderTopWidth = "3px";
860
- @ n.style.borderBottomWidth = "3px";
861
- @ n.style.borderLeftWidth = "7px";
862
- @ n.style.borderLeftColor = "#600000";
863
- @ cDiv.appendChild(n);
864
- @ }
865
- @ }
866
- @ for(var j in p.mi){
867
- @ var y0 = p.y+5;
868
- @ var mx = p.mi[j];
869
- @ if( mx<0 ){
870
- @ mx = left-mx;
871
- @ drawThinLine(mx,y0,mx,btm);
872
- @ }else{
873
- @ mx += left;
874
- @ }
875
- @ if( mx>p.x ){
876
- @ drawThinArrow(y0,mx,p.x+6);
877
- @ }else{
878
- @ drawThinArrow(y0,mx,p.x-5);
879
- @ }
880
- @ }
881
- @ }
882
- @ var selBox = null;
883
- @ var selRow = null;
884
- @ function renderGraph(){
885
- @ var canvasDiv = gebi("canvas");
886
- @ while( canvasDiv.hasChildNodes() ){
887
- @ canvasDiv.removeChild(canvasDiv.firstChild);
888
- @ }
889
- @ var canvasY = absoluteY("timelineTable");
890
- @ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15;
891
- @ for(var i in rowinfo){
892
- @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY;
893
- @ rowinfo[i].x = left + rowinfo[i].r*railPitch;
894
- @ }
895
- @ var btm = absoluteY("grbtm") + 10 - canvasY;
896
- @ for(var i in rowinfo){
897
- @ drawNode(rowinfo[i], left, btm);
898
- @ }
899
- @ if( selRow!=null ) clickOnRow(selRow);
900
- @ }
901
- @ function clickOnGraph(event){
902
- @ var x=event.clientX-absoluteX("canvas");
903
- @ var y=event.clientY-absoluteY("canvas");
904
- @ if(window.pageXOffset!=null){
905
- @ x += window.pageXOffset;
906
- @ y += window.pageYOffset;
907
- @ }else{
908
- @ var d = window.document.documentElement;
909
- @ if(document.compatMode!="CSS1Compat") d = d.body;
910
- @ x += d.scrollLeft;
911
- @ y += d.scrollTop;
912
- @ }
913
- if( P("clicktest")!=0 ){
914
- @ alert("click at "+x+","+y)
915
- }
916
- @ for(var i in rowinfo){
917
- @ p = rowinfo[i];
918
- @ if( p.y<y-11 ) continue;
919
- @ if( p.y>y+9 ) break;
920
- @ if( p.x>x-11 && p.x<x+9 ){
921
- @ clickOnRow(p);
922
- @ break;
923
- @ }
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
- @ selRow = null;
825
+ @ function miLineY(p){
826
+ @ return p.y + node.h - mLine.w - 1;
827
+ @ }
828
+ @ function drawLine(elem,color,x0,y0,x1,y1){
829
+ @ var cls = elem.cls + " ";
830
+ @ if( x1===null ){
831
+ @ x1 = x0+elem.w;
832
+ @ cls += "v";
833
+ @ }else{
834
+ @ y1 = y0+elem.w;
835
+ @ cls += "h";
836
+ @ }
837
+ @ drawBox(cls,color,x0,y0,x1,y1);
838
+ @ }
839
+ @ function drawUpArrow(from,to,color){
840
+ @ var y = to.y + node.h;
841
+ @ var arrowSpace = from.y - y + (!from.id || from.r!=to.r ? node.h/2 : 0);
842
+ @ var arw = arrowSpace < arrow.h*1.5 ? arrowSmall : arrow;
843
+ @ var x = to.x + (node.w-line.w)/2;
844
+ @ var y0 = from.y + node.h/2;
845
+ @ var y1 = Math.ceil(to.y + node.h + arw.h/2);
846
+ @ drawLine(line,color,x,y0,null,y1);
847
+ @ x = to.x + (node.w-arw.w)/2;
848
+ @ var n = drawBox(arw.cls,null,x,y);
849
+ @ n.style.borderBottomColor = color;
850
+ @ }
851
+ @ function drawMergeLine(x0,y0,x1,y1){
852
+ @ drawLine(mLine,null,x0,y0,x1,y1);
853
+ @ }
854
+ @ function drawMergeArrow(p,rail){
855
+ @ var x0 = rail*railPitch + node.w/2;
856
+ @ if( rail in mergeLines ){
857
+ @ x0 += mergeLines[rail];
858
+ @ if( p.r<rail ) x0 += mLine.w;
859
+ @ }else{
860
+ @ x0 += (p.r<rail ? -1 : 1)*line.w/2;
861
+ @ }
862
+ @ var x1 = mArrow.w ? mArrow.w/2 : -node.w/2;
863
+ @ x1 = p.x + (p.r<rail ? node.w + Math.ceil(x1) : -x1);
864
+ @ var y = miLineY(p);
865
+ @ drawMergeLine(x0,y,x1,null);
866
+ @ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
867
+ @ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
868
+ @ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
869
+ @ }
870
+ @ function drawNode(p, btm){
871
+ @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-1],p.fg);
872
+ @ var cls = node.cls;
873
+ @ if( p.mi.length ) cls += " merge";
874
+ @ if( p.f&1 ) cls += " leaf";
875
+ @ var n = drawBox(cls,p.bg,p.x,p.y);
876
+ @ n.id = "tln"+p.id;
877
+ @ n.onclick = clickOnNode;
878
+ @ n.style.zIndex = 10;
879
+ if( !omitDescenders ){
880
+ @ if( p.u==0 ) drawUpArrow(p,{x: p.x, y: -node.h},p.fg);
881
+ @ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
882
+ }
883
+ @ if( p.mo>=0 ){
884
+ @ var x0 = p.x + node.w/2;
885
+ @ var x1 = p.mo*railPitch + node.w/2;
886
+ @ var u = rowinfo[p.mu-1];
887
+ @ var y1 = miLineY(u);
888
+ @ if( p.u<0 || p.mo!=p.r ){
889
+ @ x1 += mergeLines[p.mo] = -mLine.w/2;
890
+ @ var y0 = p.y+2;
891
+ @ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
892
+ @ drawMergeLine(x1,y0+mLine.w,null,y1);
893
+ @ }else if( mergeOffset ){
894
+ @ mergeLines[p.mo] = u.r<p.r ? -mergeOffset-mLine.w : mergeOffset;
895
+ @ x1 += mergeLines[p.mo];
896
+ @ drawMergeLine(x1,p.y+node.h/2,null,y1);
897
+ @ }else{
898
+ @ delete mergeLines[p.mo];
899
+ @ }
900
+ @ }
901
+ @ for( var i=0; i<p.au.length; i+=2 ){
902
+ @ var rail = p.au[i];
903
+ @ var x0 = p.x + node.w/2;
904
+ @ var x1 = rail*railPitch + (node.w-line.w)/2;
905
+ @ if( x0<x1 ){
906
+ @ x0 = Math.ceil(x0);
907
+ @ x1 += line.w;
908
+ @ }
909
+ @ var y0 = p.y + (node.h-line.w)/2;
910
+ @ var u = rowinfo[p.au[i+1]-1];
911
+ @ if( u.id<p.id ){
912
+ @ drawLine(line,u.fg,x0,y0,x1,null);
913
+ @ drawUpArrow(p,u,u.fg);
914
+ @ }else{
915
+ @ var y1 = u.y + (node.h-line.w)/2;
916
+ @ drawLine(wLine,u.fg,x0,y0,x1,null);
917
+ @ drawLine(wLine,u.fg,x1-line.w,y0,null,y1+line.w);
918
+ @ drawLine(wLine,u.fg,x1,y1,u.x-wArrow.w/2,null);
919
+ @ var x = u.x-wArrow.w;
920
+ @ var y = u.y+(node.h-wArrow.h)/2;
921
+ @ var n = drawBox(wArrow.cls,null,x,y);
922
+ @ if( u.fg ) n.style.borderLeftColor = u.fg;
923
+ @ }
924
+ @ }
925
+ @ for( var i=0; i<p.mi.length; i++ ){
926
+ @ var rail = p.mi[i];
927
+ @ if( rail<0 ){
928
+ @ rail = -rail;
929
+ @ mergeLines[rail] = -mLine.w/2;
930
+ @ var x = rail*railPitch + (node.w-mLine.w)/2;
931
+ @ drawMergeLine(x,miLineY(p),null,btm);
932
+ @ }
933
+ @ drawMergeArrow(p,rail);
934
+ @ }
935
+ @ }
936
+ @ var mergeLines;
937
+ @ function renderGraph(){
938
+ @ mergeLines = {};
939
+ @ canvasDiv.innerHTML = "";
940
+ @ var canvasY = absoluteY(canvasDiv);
941
+ @ for( var i=0; i<rowinfo.length; i++ ){
942
+ @ rowinfo[i].y = absoluteY(gebi("m"+rowinfo[i].id)) - canvasY;
943
+ @ rowinfo[i].x = rowinfo[i].r*railPitch;
944
+ @ }
945
+ @ var tlBtm = document.querySelector(".timelineBottom");
946
+ @ if( tlBtm.offsetHeight<node.h ){
947
+ @ tlBtm.style.height = node.h + "px";
948
+ @ }
949
+ @ var btm = absoluteY(tlBtm) - canvasY + tlBtm.offsetHeight;
950
+ @ for( var i=rowinfo.length-1; i>=0; i-- ){
951
+ @ drawNode(rowinfo[i], btm);
952
+ @ }
953
+ @ }
954
+ @ var selRow;
955
+ @ function clickOnNode(){
956
+ @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-1];
957
+ @ if( !selRow ){
958
+ @ selRow = p;
959
+ @ this.className += " sel";
960
+ @ canvasDiv.className += " sel";
961
+ @ }else if( selRow==p ){
962
+ @ selRow = null;
963
+ @ this.className = this.className.replace(" sel", "");
964
+ @ canvasDiv.className = canvasDiv.className.replace(" sel", "");
935965
@ }else{
936966
if( fileDiff ){
937967
@ location.href="%R/fdiff?v1="+selRow.h+"&v2="+p.h+"&sbs=1";
938968
}else{
939969
if( db_get_boolean("show-version-diffs", 0)==0 ){
@@ -942,22 +972,23 @@
942972
@ location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=1";
943973
}
944974
}
945975
@ }
946976
@ }
947
- @ var lastId = "m"+rowinfo[rowinfo.length-1].id;
977
+ @ var lastRow = gebi("m"+rowinfo[rowinfo.length-1].id);
948978
@ var lastY = 0;
949979
@ function checkHeight(){
950
- @ var h = absoluteY(lastId);
980
+ @ var h = absoluteY(lastRow);
951981
@ if( h!=lastY ){
952982
@ renderGraph();
953983
@ lastY = h;
954984
@ }
955
- @ setTimeout("checkHeight();", 1000);
985
+ @ setTimeout(checkHeight, 1000);
956986
@ }
987
+ @ initGraph();
957988
@ checkHeight();
958
- @ </script>
989
+ @ }())</script>
959990
}
960991
}
961992
962993
/*
963994
** Create a temporary table suitable for storing timeline data.
@@ -1160,10 +1191,11 @@
11601191
** shortest ... show only the shortest path
11611192
** uf=FUUID Show only check-ins that use given file version
11621193
** brbg Background color from branch name
11631194
** ubg Background color from user
11641195
** namechng Show only check-ins that filename changes
1196
+** forks Show only forks and their children
11651197
** ym=YYYY-MM Shown only events for the given year/month.
11661198
** datefmt=N Override the date format
11671199
**
11681200
** p= and d= can appear individually or together. If either p= or d=
11691201
** appear, then u=, y=, a=, and b= are ignored.
@@ -1193,10 +1225,11 @@
11931225
const char *zUses = P("uf"); /* Only show check-ins hold this file */
11941226
const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
11951227
const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
11961228
int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
11971229
int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
1230
+ int forkOnly = PB("forks"); /* Show only forks and their children */
11981231
int tagid; /* Tag ID */
11991232
int tmFlags = 0; /* Timeline flags */
12001233
const char *zThisTag = 0; /* Suppress links to this tag */
12011234
const char *zThisUser = 0; /* Suppress links to this user */
12021235
HQuery url; /* URL for various branch links */
@@ -1299,10 +1332,30 @@
12991332
"CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
13001333
"INSERT OR IGNORE INTO rnfile"
13011334
" SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
13021335
);
13031336
disableY = 1;
1337
+ }
1338
+ if( forkOnly ){
1339
+ db_multi_exec(
1340
+ "CREATE TEMP TABLE rnfork(rid INTEGER PRIMARY KEY);\n"
1341
+ "INSERT OR IGNORE INTO rnfork(rid)\n"
1342
+ " SELECT pid FROM plink\n"
1343
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
1344
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1345
+ " GROUP BY pid"
1346
+ " HAVING count(*)>1;\n"
1347
+ "INSERT OR IGNORE INTO rnfork(rid)"
1348
+ " SELECT cid FROM plink\n"
1349
+ " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
1350
+ " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1351
+ " AND pid IN rnfork;",
1352
+ TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
1353
+ );
1354
+ tmFlags |= TIMELINE_UNHIDE;
1355
+ zType = "ci";
1356
+ disableY = 1;
13041357
}
13051358
13061359
style_header("Timeline");
13071360
login_anonymous_available();
13081361
timeline_temp_table();
@@ -1429,10 +1482,13 @@
14291482
blob_append_sql(&sql, " AND event.objid IN usesfile ");
14301483
}
14311484
if( renameOnly ){
14321485
blob_append_sql(&sql, " AND event.objid IN rnfile ");
14331486
}
1487
+ if( forkOnly ){
1488
+ blob_append_sql(&sql, " AND event.objid IN rnfork ");
1489
+ }
14341490
if( zYearMonth ){
14351491
blob_append_sql(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
14361492
zYearMonth);
14371493
}
14381494
else if( zYearWeek ){
@@ -1601,10 +1657,14 @@
16011657
}
16021658
if( renameOnly ){
16031659
blob_appendf(&desc, " that contain filename changes");
16041660
tmFlags |= TIMELINE_DISJOINT|TIMELINE_FRENAMES;
16051661
}
1662
+ if( forkOnly ){
1663
+ blob_appendf(&desc, " associated with forks");
1664
+ tmFlags |= TIMELINE_DISJOINT;
1665
+ }
16061666
if( zUser ){
16071667
blob_appendf(&desc, " by user %h", zUser);
16081668
tmFlags |= TIMELINE_DISJOINT;
16091669
}
16101670
if( zTagName ){
@@ -1788,11 +1848,11 @@
17881848
fossil_free(zFree);
17891849
17901850
if(verboseFlag){
17911851
if( !fchngQueryInit ){
17921852
db_prepare(&fchngQuery,
1793
- "SELECT (pid==0) AS isnew,"
1853
+ "SELECT (pid<=0) AS isnew,"
17941854
" (fid==0) AS isdel,"
17951855
" (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
17961856
" (SELECT uuid FROM blob WHERE rid=fid),"
17971857
" (SELECT uuid FROM blob WHERE rid=pid)"
17981858
" FROM mlink"
@@ -2149,10 +2209,15 @@
21492209
db_finalize(&q);
21502210
}
21512211
21522212
/*
21532213
** WEBPAGE: test_timewarps
2214
+**
2215
+** Show all check-ins that are "timewarps". A timewarp is a
2216
+** check-in that occurs before its parent, according to the
2217
+** timestamp information on the check-in. This can only actually
2218
+** happen, of course, if a users system clock is set incorrectly.
21542219
*/
21552220
void test_timewarp_page(void){
21562221
Stmt q;
21572222
21582223
login_check_credentials();
21592224
--- 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;
@@ -163,11 +163,10 @@
163 void test_hash_color_page(void){
164 const char *zBr;
165 char zNm[10];
166 int i, cnt;
167 login_check_credentials();
168 if( !g.perm.Read ){ login_needed(g.anon.Read); return; }
169
170 style_header("Hash Color Test");
171 for(i=cnt=0; i<10; i++){
172 sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i);
173 zBr = P(zNm);
@@ -242,23 +241,17 @@
242 dateFormat = db_get_int("timeline-date-format", 0);
243 zDateFmt = P("datefmt");
244 if( zDateFmt ) dateFormat = atoi(zDateFmt);
245 if( tmFlags & TIMELINE_GRAPH ){
246 pGraph = graph_init();
247 /* style is not moved to css, because this is
248 ** a technical div for the timeline graph
249 */
250 @ <div id="canvas" style="position:relative;height:0px;width:0px;"
251 @ onclick="clickOnGraph(event)"></div>
252 }
253 db_static_prepare(&qbranch,
254 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
255 TAG_BRANCH
256 );
257
258 @ <table id="timelineTable" class="timelineTable"
259 @ onclick="clickOnGraph(event)">
260 blob_zero(&comment);
261 while( db_step(pQuery)==SQLITE_ROW ){
262 int rid = db_column_int(pQuery, 0);
263 const char *zUuid = db_column_text(pQuery, 1);
264 int isLeaf = db_column_int(pQuery, 5);
@@ -270,10 +263,11 @@
270 int tagid = db_column_int(pQuery, 9);
271 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
272 const char *zBr = 0; /* Branch */
273 int commentColumn = 3; /* Column containing comment text */
274 int modPending; /* Pending moderation */
 
275 char zTime[20];
276
277 if( zDate==0 ){
278 zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
279 }
@@ -351,11 +345,12 @@
351 }else if( rid==vid ){
352 @ <tr class="timelineCurrent">
353 }else {
354 @ <tr>
355 }
356 @ <td class="timelineTime">%s(zTime)</td>
 
357 @ <td class="timelineGraph">
358 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
359 if( zType[0]=='c'
360 && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
361 ){
@@ -390,11 +385,11 @@
390 }
391 db_reset(&qparent);
392 gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr,
393 zUuid, isLeaf);
394 db_reset(&qbranch);
395 @ <div id="m%d(gidx)"></div>
396 }
397 @</td>
398 if( zBgClr && zBgClr[0] && rid!=selectedRid ){
399 @ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
400 }else{
@@ -498,11 +493,11 @@
498 && zType[0]=='c' && g.perm.Hyperlink
499 ){
500 int inUl = 0;
501 if( !fchngQueryInit ){
502 db_prepare(&fchngQuery,
503 "SELECT (pid==0) AS isnew,"
504 " fid,"
505 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
506 " (SELECT uuid FROM blob WHERE rid=fid),"
507 " (SELECT uuid FROM blob WHERE rid=pid),"
508 " (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
@@ -516,11 +511,12 @@
516 fchngQueryInit = 1;
517 }
518 db_bind_int(&fchngQuery, ":mid", rid);
519 while( db_step(&fchngQuery)==SQLITE_ROW ){
520 const char *zFilename = db_column_text(&fchngQuery, 2);
521 int isNew = db_column_int(&fchngQuery, 0);
 
522 int fid = db_column_int(&fchngQuery, 1);
523 int isDel = fid==0;
524 const char *zOldName = db_column_text(&fchngQuery, 5);
525 const char *zOld = db_column_text(&fchngQuery, 4);
526 const char *zNew = db_column_text(&fchngQuery, 3);
@@ -545,12 +541,17 @@
545 zA = href("%R/artifact/%!S",fid?zNew:zOld);
546 if( content_is_private(fid) ){
547 zUnpub = UNPUB_TAG;
548 }
549 if( isNew ){
550 @ <li> %s(zA)%h(zFilename)</a>%s(zId) %s(zUnpub) (new file) &nbsp;
551 @ %z(href("%R/artifact/%!S",zNew))[view]</a></li>
 
 
 
 
 
552 }else if( isDel ){
553 @ <li> %s(zA)%h(zFilename)</a> (deleted)</li>
554 }else if( fossil_strcmp(zOld,zNew)==0 && zOldName!=0 ){
555 @ <li> %h(zOldName) &rarr; %s(zA)%h(zFilename)</a>%s(zId)
556 @ %s(zUnpub) %z(href("%R/artifact/%!S",zNew))[view]</a></li>
@@ -582,24 +583,48 @@
582 graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
583 if( pGraph->nErr ){
584 graph_free(pGraph);
585 pGraph = 0;
586 }else{
587 int w;
588 /* style is not moved to css, because this is
589 ** a technical div for the timeline graph
590 */
591 w = pGraph->mxRail*pGraph->iRailPitch + 28;
592 @ <tr><td></td><td>
593 @ <div id="grbtm" style="width:%d(w)px;"></div>
594 @ </td><td></td></tr>
595 }
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 */
@@ -610,24 +635,34 @@
610 ){
611 if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
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 */
623 mergeOffset = iRailPitch>=14 ? 4 : iRailPitch>=13 ? 3 : 0;
624 if( PB("nomo") ) mergeOffset = 0;
625
626 @ <script>
627 @ var railPitch=%d(iRailPitch);
628
 
 
 
 
 
 
 
 
 
 
 
629 /* the rowinfo[] array contains all the information needed to generate
630 ** the graph. Each entry contains information for a single row:
631 **
632 ** id: The id of the <div> element for the row. This is an integer.
633 ** to get an actual id, prepend "m" to the integer. The top node
@@ -635,13 +670,13 @@
635 ** bg: The background color for this row
636 ** r: The "rail" that the node for this row sits on. The left-most
637 ** rail is 0 and the number increases to the right.
638 ** d: True if there is a "descender" - an arrow coming from the bottom
639 ** of the page straight up to this node.
640 ** mo: "merge-out". If non-zero, this is one more than the x-coordinate
641 ** for the upward portion of a merge arrow. The merge arrow goes up
642 ** to the row identified by mu:. If this value is zero then
643 ** node has no merge children and no merge-out line is drawn.
644 ** mu: The id of the row which is the top of the merge-out arrow.
645 ** u: Draw a thick child-line out of the top of this node and up to
646 ** the node with an id equal to this value. 0 if it is straight to
647 ** the top of the page, -1 if there is no thick-line riser.
@@ -648,37 +683,25 @@
648 ** f: 0x01: a leaf node.
649 ** au: An array of integers that define thick-line risers for branches.
650 ** The integers are in pairs. For each pair, the first integer is
651 ** is the rail on which the riser should run and the second integer
652 ** is the id of the node upto which the riser should run.
653 ** mi: "merge-in". An array of integer x-coordinates from which
654 ** merge arrows should be drawn into this node. If the value is
655 ** negative, then the x-coordinate is the absolute value of mi[]
656 ** and a thin merge-arrow descender is drawn to the bottom of
657 ** the screen.
658 ** h: The SHA1 hash of the object being graphed
659 */
660 cgi_printf("var rowinfo = [\n");
661 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
662 int mo = pRow->mergeOut;
663 if( mo<0 ){
664 mo = 0;
665 }else{
666 int x = (mo/4)*iRailPitch;
667 switch( mo&3 ){
668 case 0: x -= mergeOffset-2; break;
669 case 1: x += 1; break;
670 case 2: x += mergeOffset+1; break;
671 }
672 mo = x;
673 }
674 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
675 pRow->idx, /* id */
676 pRow->zBgClr, /* bg */
677 pRow->iRail, /* r */
678 pRow->bDescender, /* d */
679 mo, /* mo */
680 pRow->mergeUpto, /* mu */
681 pRow->aiRiser[pRow->iRail], /* u */
682 pRow->isLeaf ? 1 : 0 /* f */
683 );
684 /* u */
@@ -689,18 +712,20 @@
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;
701 if( pRow->mergeIn[i]==3 ) mi += mergeOffset;
702 if( pRow->mergeDown & (1<<i) ) mi = -mi;
703 cgi_printf("%c%d", cSep, mi);
704 cSep = ',';
705 }
706 }
@@ -707,233 +732,238 @@
707 if( cSep=='[' ) cgi_printf("[");
708 cgi_printf("],h:\"%s\"}%s", pRow->zUuid, pRow->pNext ? ",\n" : "];\n");
709 }
710 cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
711 graph_free(pGraph);
712 @ var cDiv = gebi("canvas");
713 @ var csty = window.getComputedStyle && window.getComputedStyle(cDiv,null);
714 @ var lineClr = (csty && csty.getPropertyValue('color')) || 'black';
715 @ var bgClr = (csty && csty.getPropertyValue('background-color')) ||'white';
716 @ if( bgClr=='transparent' ) bgClr = 'white';
717 @ var boxColor = lineClr;
718 @ function drawBox(color,x0,y0,x1,y1){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
719 @ var n = document.createElement("div");
 
 
 
 
720 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
721 @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
722 @ var w = x1-x0+1;
723 @ var h = y1-y0+1;
724 @ n.style.position = "absolute";
725 @ n.style.overflow = "hidden";
726 @ n.style.left = x0+"px";
727 @ n.style.top = y0+"px";
728 @ n.style.width = w+"px";
729 @ n.style.height = h+"px";
730 @ n.style.backgroundColor = color;
731 @ cDiv.appendChild(n);
 
732 @ return n;
733 @ }
734 @ function absoluteY(id){
735 @ var obj = gebi(id);
736 @ if( !obj ) return;
737 @ var top = 0;
738 @ if( obj.offsetParent ){
739 @ do{
740 @ top += obj.offsetTop;
741 @ }while( obj = obj.offsetParent );
742 @ }
743 @ return top;
744 @ }
745 @ function absoluteX(id){
746 @ var obj = gebi(id);
747 @ if( !obj ) return;
748 @ var left = 0;
749 @ if( obj.offsetParent ){
750 @ do{
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";
785 @ n.style.width = 0;
786 @ n.style.height = "1px";
787 @ n.style.transform = "scale(.999)";
788 @ n.style.borderWidth = 0;
789 @ n.style.borderStyle = "solid";
790 @ n.style.borderColor = "transparent";
791 @ n.style.borderTopWidth = "2px";
792 @ n.style.borderBottomWidth = "2px";
793 @ if( xFrom<xTo ){
794 @ drawBox(lineClr,xFrom,y,xTo-3,y);
795 @ n.style.left = xTo-3+"px";
796 @ n.style.borderLeftWidth = "3px";
797 @ n.style.borderLeftColor = lineClr;
798 @ }else{
799 @ drawBox(lineClr,xTo+3,y,xFrom,y);
800 @ n.style.left = xTo+1+"px";
801 @ n.style.borderRightWidth = "3px";
802 @ n.style.borderRightColor = lineClr;
803 @ }
804 @ cDiv.appendChild(n);
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;
825 @ var u = rowinfo[p.mu-1];
826 @ var y0 = u.y+5;
827 @ if( x1>=p.x-5 && x1<=p.x+5 ){
828 @ y1 = p.y-5;
829 @ }else{
830 @ drawThinLine(x0,y1,x1,y1);
831 @ }
832 if( mergeOffset==0 ) cgi_printf("if( p.mo!=p.u-1 ) ");
833 @ drawThinLine(x1,y0,x1,y1);
834 @ }
835 @ var n = p.au.length;
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"),
848 @ t = u.y-2,
849 @ l = u.x-11;
850 @ n.style.position = "absolute";
851 @ n.style.top = t+"px";
852 @ n.style.left = l+"px";
853 @ n.style.width = 0;
854 @ n.style.height = 0;
855 @ n.style.transform = "scale(.999)";
856 @ n.style.borderWidth = 0;
857 @ n.style.borderStyle = "solid";
858 @ n.style.borderColor = "transparent";
859 @ n.style.borderTopWidth = "3px";
860 @ n.style.borderBottomWidth = "3px";
861 @ n.style.borderLeftWidth = "7px";
862 @ n.style.borderLeftColor = "#600000";
863 @ cDiv.appendChild(n);
864 @ }
865 @ }
866 @ for(var j in p.mi){
867 @ var y0 = p.y+5;
868 @ var mx = p.mi[j];
869 @ if( mx<0 ){
870 @ mx = left-mx;
871 @ drawThinLine(mx,y0,mx,btm);
872 @ }else{
873 @ mx += left;
874 @ }
875 @ if( mx>p.x ){
876 @ drawThinArrow(y0,mx,p.x+6);
877 @ }else{
878 @ drawThinArrow(y0,mx,p.x-5);
879 @ }
880 @ }
881 @ }
882 @ var selBox = null;
883 @ var selRow = null;
884 @ function renderGraph(){
885 @ var canvasDiv = gebi("canvas");
886 @ while( canvasDiv.hasChildNodes() ){
887 @ canvasDiv.removeChild(canvasDiv.firstChild);
888 @ }
889 @ var canvasY = absoluteY("timelineTable");
890 @ var left = absoluteX("m"+rowinfo[0].id) - absoluteX("canvas") + 15;
891 @ for(var i in rowinfo){
892 @ rowinfo[i].y = absoluteY("m"+rowinfo[i].id) + 10 - canvasY;
893 @ rowinfo[i].x = left + rowinfo[i].r*railPitch;
894 @ }
895 @ var btm = absoluteY("grbtm") + 10 - canvasY;
896 @ for(var i in rowinfo){
897 @ drawNode(rowinfo[i], left, btm);
898 @ }
899 @ if( selRow!=null ) clickOnRow(selRow);
900 @ }
901 @ function clickOnGraph(event){
902 @ var x=event.clientX-absoluteX("canvas");
903 @ var y=event.clientY-absoluteY("canvas");
904 @ if(window.pageXOffset!=null){
905 @ x += window.pageXOffset;
906 @ y += window.pageYOffset;
907 @ }else{
908 @ var d = window.document.documentElement;
909 @ if(document.compatMode!="CSS1Compat") d = d.body;
910 @ x += d.scrollLeft;
911 @ y += d.scrollTop;
912 @ }
913 if( P("clicktest")!=0 ){
914 @ alert("click at "+x+","+y)
915 }
916 @ for(var i in rowinfo){
917 @ p = rowinfo[i];
918 @ if( p.y<y-11 ) continue;
919 @ if( p.y>y+9 ) break;
920 @ if( p.x>x-11 && p.x<x+9 ){
921 @ clickOnRow(p);
922 @ break;
923 @ }
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 @ selRow = null;
935 @ }else{
936 if( fileDiff ){
937 @ location.href="%R/fdiff?v1="+selRow.h+"&v2="+p.h+"&sbs=1";
938 }else{
939 if( db_get_boolean("show-version-diffs", 0)==0 ){
@@ -942,22 +972,23 @@
942 @ location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=1";
943 }
944 }
945 @ }
946 @ }
947 @ var lastId = "m"+rowinfo[rowinfo.length-1].id;
948 @ var lastY = 0;
949 @ function checkHeight(){
950 @ var h = absoluteY(lastId);
951 @ if( h!=lastY ){
952 @ renderGraph();
953 @ lastY = h;
954 @ }
955 @ setTimeout("checkHeight();", 1000);
956 @ }
 
957 @ checkHeight();
958 @ </script>
959 }
960 }
961
962 /*
963 ** Create a temporary table suitable for storing timeline data.
@@ -1160,10 +1191,11 @@
1160 ** shortest ... show only the shortest path
1161 ** uf=FUUID Show only check-ins that use given file version
1162 ** brbg Background color from branch name
1163 ** ubg Background color from user
1164 ** namechng Show only check-ins that filename changes
 
1165 ** ym=YYYY-MM Shown only events for the given year/month.
1166 ** datefmt=N Override the date format
1167 **
1168 ** p= and d= can appear individually or together. If either p= or d=
1169 ** appear, then u=, y=, a=, and b= are ignored.
@@ -1193,10 +1225,11 @@
1193 const char *zUses = P("uf"); /* Only show check-ins hold this file */
1194 const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
1195 const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
1196 int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
1197 int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
 
1198 int tagid; /* Tag ID */
1199 int tmFlags = 0; /* Timeline flags */
1200 const char *zThisTag = 0; /* Suppress links to this tag */
1201 const char *zThisUser = 0; /* Suppress links to this user */
1202 HQuery url; /* URL for various branch links */
@@ -1299,10 +1332,30 @@
1299 "CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
1300 "INSERT OR IGNORE INTO rnfile"
1301 " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
1302 );
1303 disableY = 1;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1304 }
1305
1306 style_header("Timeline");
1307 login_anonymous_available();
1308 timeline_temp_table();
@@ -1429,10 +1482,13 @@
1429 blob_append_sql(&sql, " AND event.objid IN usesfile ");
1430 }
1431 if( renameOnly ){
1432 blob_append_sql(&sql, " AND event.objid IN rnfile ");
1433 }
 
 
 
1434 if( zYearMonth ){
1435 blob_append_sql(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
1436 zYearMonth);
1437 }
1438 else if( zYearWeek ){
@@ -1601,10 +1657,14 @@
1601 }
1602 if( renameOnly ){
1603 blob_appendf(&desc, " that contain filename changes");
1604 tmFlags |= TIMELINE_DISJOINT|TIMELINE_FRENAMES;
1605 }
 
 
 
 
1606 if( zUser ){
1607 blob_appendf(&desc, " by user %h", zUser);
1608 tmFlags |= TIMELINE_DISJOINT;
1609 }
1610 if( zTagName ){
@@ -1788,11 +1848,11 @@
1788 fossil_free(zFree);
1789
1790 if(verboseFlag){
1791 if( !fchngQueryInit ){
1792 db_prepare(&fchngQuery,
1793 "SELECT (pid==0) AS isnew,"
1794 " (fid==0) AS isdel,"
1795 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
1796 " (SELECT uuid FROM blob WHERE rid=fid),"
1797 " (SELECT uuid FROM blob WHERE rid=pid)"
1798 " FROM mlink"
@@ -2149,10 +2209,15 @@
2149 db_finalize(&q);
2150 }
2151
2152 /*
2153 ** WEBPAGE: test_timewarps
 
 
 
 
 
2154 */
2155 void test_timewarp_page(void){
2156 Stmt q;
2157
2158 login_check_credentials();
2159
--- 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;
@@ -163,11 +163,10 @@
163 void test_hash_color_page(void){
164 const char *zBr;
165 char zNm[10];
166 int i, cnt;
167 login_check_credentials();
 
168
169 style_header("Hash Color Test");
170 for(i=cnt=0; i<10; i++){
171 sqlite3_snprintf(sizeof(zNm),zNm,"b%d",i);
172 zBr = P(zNm);
@@ -242,23 +241,17 @@
241 dateFormat = db_get_int("timeline-date-format", 0);
242 zDateFmt = P("datefmt");
243 if( zDateFmt ) dateFormat = atoi(zDateFmt);
244 if( tmFlags & TIMELINE_GRAPH ){
245 pGraph = graph_init();
 
 
 
 
 
246 }
247 db_static_prepare(&qbranch,
248 "SELECT value FROM tagxref WHERE tagid=%d AND tagtype>0 AND rid=:rid",
249 TAG_BRANCH
250 );
251
252 @ <table id="timelineTable" class="timelineTable">
 
253 blob_zero(&comment);
254 while( db_step(pQuery)==SQLITE_ROW ){
255 int rid = db_column_int(pQuery, 0);
256 const char *zUuid = db_column_text(pQuery, 1);
257 int isLeaf = db_column_int(pQuery, 5);
@@ -270,10 +263,11 @@
263 int tagid = db_column_int(pQuery, 9);
264 const char *zDispUser = zUser && zUser[0] ? zUser : "anonymous";
265 const char *zBr = 0; /* Branch */
266 int commentColumn = 3; /* Column containing comment text */
267 int modPending; /* Pending moderation */
268 char *zDateLink; /* URL for the link on the timestamp */
269 char zTime[20];
270
271 if( zDate==0 ){
272 zDate = "YYYY-MM-DD HH:MM:SS"; /* Something wrong with the repo */
273 }
@@ -351,11 +345,12 @@
345 }else if( rid==vid ){
346 @ <tr class="timelineCurrent">
347 }else {
348 @ <tr>
349 }
350 zDateLink = href("%R/timeline?c=%!S&unhide", zUuid);
351 @ <td class="timelineTime">%z(zDateLink)%s(zTime)</a></td>
352 @ <td class="timelineGraph">
353 if( tmFlags & TIMELINE_UCOLOR ) zBgClr = zUser ? hash_color(zUser) : 0;
354 if( zType[0]=='c'
355 && (pGraph || zBgClr==0 || (tmFlags & TIMELINE_BRCOLOR)!=0)
356 ){
@@ -390,11 +385,11 @@
385 }
386 db_reset(&qparent);
387 gidx = graph_add_row(pGraph, rid, nParent, aParent, zBr, zBgClr,
388 zUuid, isLeaf);
389 db_reset(&qbranch);
390 @ <div id="m%d(gidx)" class="tl-nodemark"></div>
391 }
392 @</td>
393 if( zBgClr && zBgClr[0] && rid!=selectedRid ){
394 @ <td class="timelineTableCell" style="background-color: %h(zBgClr);">
395 }else{
@@ -498,11 +493,11 @@
493 && zType[0]=='c' && g.perm.Hyperlink
494 ){
495 int inUl = 0;
496 if( !fchngQueryInit ){
497 db_prepare(&fchngQuery,
498 "SELECT pid,"
499 " fid,"
500 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
501 " (SELECT uuid FROM blob WHERE rid=fid),"
502 " (SELECT uuid FROM blob WHERE rid=pid),"
503 " (SELECT name FROM filename WHERE fnid=mlink.pfnid) AS oldnm"
@@ -516,11 +511,12 @@
511 fchngQueryInit = 1;
512 }
513 db_bind_int(&fchngQuery, ":mid", rid);
514 while( db_step(&fchngQuery)==SQLITE_ROW ){
515 const char *zFilename = db_column_text(&fchngQuery, 2);
516 int isNew = db_column_int(&fchngQuery, 0)<=0;
517 int isMergeNew = db_column_int(&fchngQuery, 0)<0;
518 int fid = db_column_int(&fchngQuery, 1);
519 int isDel = fid==0;
520 const char *zOldName = db_column_text(&fchngQuery, 5);
521 const char *zOld = db_column_text(&fchngQuery, 4);
522 const char *zNew = db_column_text(&fchngQuery, 3);
@@ -545,12 +541,17 @@
541 zA = href("%R/artifact/%!S",fid?zNew:zOld);
542 if( content_is_private(fid) ){
543 zUnpub = UNPUB_TAG;
544 }
545 if( isNew ){
546 @ <li> %s(zA)%h(zFilename)</a>%s(zId) %s(zUnpub)
547 if( isMergeNew ){
548 @ (added by merge)
549 }else{
550 @ (new file)
551 }
552 @ &nbsp; %z(href("%R/artifact/%!S",zNew))[view]</a></li>
553 }else if( isDel ){
554 @ <li> %s(zA)%h(zFilename)</a> (deleted)</li>
555 }else if( fossil_strcmp(zOld,zNew)==0 && zOldName!=0 ){
556 @ <li> %h(zOldName) &rarr; %s(zA)%h(zFilename)</a>%s(zId)
557 @ %s(zUnpub) %z(href("%R/artifact/%!S",zNew))[view]</a></li>
@@ -582,24 +583,48 @@
583 graph_finish(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0);
584 if( pGraph->nErr ){
585 graph_free(pGraph);
586 pGraph = 0;
587 }else{
588 @ <tr class="timelineBottom"><td></td><td></td><td></td></tr>
 
 
 
 
 
 
 
589 }
590 }
591 @ </table>
592 if( fchngQueryInit ) db_finalize(&fchngQuery);
593 timeline_output_graph_javascript(pGraph, (tmFlags & TIMELINE_DISJOINT)!=0, 0);
594 }
595
596 /*
597 ** Change the RGB background color given in the argument in a foreground
598 ** color with the same hue.
599 */
600 static const char *bg_to_fg(const char *zIn){
601 int i;
602 unsigned int x[3];
603 unsigned int mx = 0;
604 static int whiteFg = -1;
605 static char zRes[10];
606 if( strlen(zIn)!=7 || zIn[0]!='#' ) return zIn;
607 zIn++;
608 for(i=0; i<3; i++){
609 x[i] = hex_digit_value(zIn[0])*16 + hex_digit_value(zIn[1]);
610 zIn += 2;
611 if( x[i]>mx ) mx = x[i];
612 }
613 if( whiteFg<0 ) whiteFg = skin_detail_boolean("white-foreground");
614 if( whiteFg ){
615 /* Make the color lighter */
616 static const unsigned int t = 215;
617 if( mx<t ) for(i=0; i<3; i++) x[i] += t - mx;
618 }else{
619 /* Make the color darker */
620 static const unsigned int t = 128;
621 if( mx>t ) for(i=0; i<3; i++) x[i] -= mx - t;
622 }
623 sqlite3_snprintf(sizeof(zRes),zRes,"#%02x%02x%02x",x[0],x[1],x[2]);
624 return zRes;
625 }
626
627 /*
628 ** Generate all of the necessary javascript to generate a timeline
629 ** graph.
630 */
@@ -610,24 +635,34 @@
635 ){
636 if( pGraph && pGraph->nErr==0 && pGraph->nRow>0 ){
637 GraphRow *pRow;
638 int i;
639 char cSep;
 
640 int iRailPitch; /* Pixels between consecutive rails */
641 int showArrowheads; /* True to draw arrowheads. False to omit. */
642 int circleNodes; /* True for circle nodes. False for square nodes */
643 int colorGraph; /* Use colors for graph lines */
644
645 iRailPitch = atoi(PD("railpitch","0"));
646 showArrowheads = skin_detail_boolean("timeline-arrowheads");
647 circleNodes = skin_detail_boolean("timeline-circle-nodes");
648 colorGraph = skin_detail_boolean("timeline-color-graph-lines");
649
650 @ <script>(function(){
651 @ "use strict";
652 @ var css = "";
653 if( circleNodes ){
654 @ css += ".tl-node, .tl-node:after { border-radius: 50%%; }";
655 }
656 if( !showArrowheads ){
657 @ css += ".tl-arrow.u { display: none; }";
658 }
659 @ if( css!=="" ){
660 @ var style = document.createElement("style");
661 @ style.textContent = css;
662 @ document.querySelector("head").appendChild(style);
663 @ }
664 /* the rowinfo[] array contains all the information needed to generate
665 ** the graph. Each entry contains information for a single row:
666 **
667 ** id: The id of the <div> element for the row. This is an integer.
668 ** to get an actual id, prepend "m" to the integer. The top node
@@ -635,13 +670,13 @@
670 ** bg: The background color for this row
671 ** r: The "rail" that the node for this row sits on. The left-most
672 ** rail is 0 and the number increases to the right.
673 ** d: True if there is a "descender" - an arrow coming from the bottom
674 ** of the page straight up to this node.
675 ** mo: "merge-out". If non-negative, this is the rail position
676 ** for the upward portion of a merge arrow. The merge arrow goes up
677 ** to the row identified by mu:. If this value is negative then
678 ** node has no merge children and no merge-out line is drawn.
679 ** mu: The id of the row which is the top of the merge-out arrow.
680 ** u: Draw a thick child-line out of the top of this node and up to
681 ** the node with an id equal to this value. 0 if it is straight to
682 ** the top of the page, -1 if there is no thick-line riser.
@@ -648,37 +683,25 @@
683 ** f: 0x01: a leaf node.
684 ** au: An array of integers that define thick-line risers for branches.
685 ** The integers are in pairs. For each pair, the first integer is
686 ** is the rail on which the riser should run and the second integer
687 ** is the id of the node upto which the riser should run.
688 ** mi: "merge-in". An array of integer rail positions from which
689 ** merge arrows should be drawn into this node. If the value is
690 ** negative, then the rail position is the absolute value of mi[]
691 ** and a thin merge-arrow descender is drawn to the bottom of
692 ** the screen.
693 ** h: The SHA1 hash of the object being graphed
694 */
695 cgi_printf("var rowinfo = [\n");
696 for(pRow=pGraph->pFirst; pRow; pRow=pRow->pNext){
 
 
 
 
 
 
 
 
 
 
 
 
697 cgi_printf("{id:%d,bg:\"%s\",r:%d,d:%d,mo:%d,mu:%d,u:%d,f:%d,au:",
698 pRow->idx, /* id */
699 pRow->zBgClr, /* bg */
700 pRow->iRail, /* r */
701 pRow->bDescender, /* d */
702 pRow->mergeOut, /* mo */
703 pRow->mergeUpto, /* mu */
704 pRow->aiRiser[pRow->iRail], /* u */
705 pRow->isLeaf ? 1 : 0 /* f */
706 );
707 /* u */
@@ -689,18 +712,20 @@
712 cgi_printf("%c%d,%d", cSep, i, pRow->aiRiser[i]);
713 cSep = ',';
714 }
715 }
716 if( cSep=='[' ) cgi_printf("[");
717 cgi_printf("],");
718 if( colorGraph && pRow->zBgClr[0]=='#' ){
719 cgi_printf("fg:\"%s\",", bg_to_fg(pRow->zBgClr));
720 }
721 /* mi */
722 cgi_printf("mi:");
723 cSep = '[';
724 for(i=0; i<GR_MAX_RAIL; i++){
725 if( pRow->mergeIn[i] ){
726 int mi = i;
 
 
727 if( pRow->mergeDown & (1<<i) ) mi = -mi;
728 cgi_printf("%c%d", cSep, mi);
729 cSep = ',';
730 }
731 }
@@ -707,233 +732,238 @@
732 if( cSep=='[' ) cgi_printf("[");
733 cgi_printf("],h:\"%s\"}%s", pRow->zUuid, pRow->pNext ? ",\n" : "];\n");
734 }
735 cgi_printf("var nrail = %d\n", pGraph->mxRail+1);
736 graph_free(pGraph);
737 @ var canvasDiv;
738 @ var railPitch;
739 @ var mergeOffset;
740 @ var node, arrow, arrowSmall, line, mArrow, mLine, wArrow, wLine;
741 @ function initGraph(){
742 @ var parent = gebi("timelineTable").rows[0].cells[1];
743 @ parent.style.verticalAlign = "top";
744 @ canvasDiv = document.createElement("div");
745 @ canvasDiv.className = "tl-canvas";
746 @ canvasDiv.style.position = "absolute";
747 @ parent.appendChild(canvasDiv);
748 @
749 @ var elems = {};
750 @ var elemClasses = [
751 @ "rail", "mergeoffset", "node", "arrow u", "arrow u sm", "line",
752 @ "arrow merge r", "line merge", "arrow warp", "line warp"
753 @ ];
754 @ for( var i=0; i<elemClasses.length; i++ ){
755 @ var cls = elemClasses[i];
756 @ var elem = document.createElement("div");
757 @ elem.className = "tl-" + cls;
758 @ if( cls.indexOf("line")==0 ) elem.className += " v";
759 @ canvasDiv.appendChild(elem);
760 @ var k = cls.replace(/\s/g, "_");
761 @ var r = elem.getBoundingClientRect();
762 @ var w = Math.round(r.right - r.left);
763 @ var h = Math.round(r.bottom - r.top);
764 @ elems[k] = {w: w, h: h, cls: cls};
765 @ }
766 @ node = elems.node;
767 @ arrow = elems.arrow_u;
768 @ arrowSmall = elems.arrow_u_sm;
769 @ line = elems.line;
770 @ mArrow = elems.arrow_merge_r;
771 @ mLine = elems.line_merge;
772 @ wArrow = elems.arrow_warp;
773 @ wLine = elems.line_warp;
774 @
775 @ var minRailPitch = Math.ceil((node.w+line.w)/2 + mArrow.w + 1);
776 if( iRailPitch ){
777 @ railPitch = %d(iRailPitch);
778 }else{
779 @ railPitch = elems.rail.w;
780 @ railPitch -= Math.floor((nrail-1)*(railPitch-minRailPitch)/21);
781 }
782 @ railPitch = Math.max(railPitch, minRailPitch);
783 @
784 if( PB("nomo") ){
785 @ mergeOffset = 0;
786 }else{
787 @ mergeOffset = railPitch-minRailPitch-mLine.w;
788 @ mergeOffset = Math.min(mergeOffset, elems.mergeoffset.w);
789 @ mergeOffset = mergeOffset>0 ? mergeOffset + line.w/2 : 0;
790 }
791 @
792 @ var canvasWidth = (nrail-1)*railPitch + node.w;
793 @ canvasDiv.style.width = canvasWidth + "px";
794 @ canvasDiv.style.position = "relative";
795 @ }
796 @ function drawBox(cls,color,x0,y0,x1,y1){
797 @ var n = document.createElement("div");
798 @ x0 = Math.floor(x0);
799 @ y0 = Math.floor(y0);
800 @ x1 = x1 || x1===0 ? Math.floor(x1) : x0;
801 @ y1 = y1 || y1===0 ? Math.floor(y1) : y0;
802 @ if( x0>x1 ){ var t=x0; x0=x1; x1=t; }
803 @ if( y0>y1 ){ var t=y0; y0=y1; y1=t; }
804 @ var w = x1-x0;
805 @ var h = y1-y0;
806 @ n.style.position = "absolute";
 
807 @ n.style.left = x0+"px";
808 @ n.style.top = y0+"px";
809 @ if( w ) n.style.width = w+"px";
810 @ if( h ) n.style.height = h+"px";
811 @ if( color ) n.style.backgroundColor = color;
812 @ n.className = "tl-"+cls;
813 @ canvasDiv.appendChild(n);
814 @ return n;
815 @ }
816 @ function absoluteY(obj){
 
 
817 @ var top = 0;
818 @ if( obj.offsetParent ){
819 @ do{
820 @ top += obj.offsetTop;
821 @ }while( obj = obj.offsetParent );
822 @ }
823 @ return top;
824 @ }
825 @ function miLineY(p){
826 @ return p.y + node.h - mLine.w - 1;
827 @ }
828 @ function drawLine(elem,color,x0,y0,x1,y1){
829 @ var cls = elem.cls + " ";
830 @ if( x1===null ){
831 @ x1 = x0+elem.w;
832 @ cls += "v";
833 @ }else{
834 @ y1 = y0+elem.w;
835 @ cls += "h";
836 @ }
837 @ drawBox(cls,color,x0,y0,x1,y1);
838 @ }
839 @ function drawUpArrow(from,to,color){
840 @ var y = to.y + node.h;
841 @ var arrowSpace = from.y - y + (!from.id || from.r!=to.r ? node.h/2 : 0);
842 @ var arw = arrowSpace < arrow.h*1.5 ? arrowSmall : arrow;
843 @ var x = to.x + (node.w-line.w)/2;
844 @ var y0 = from.y + node.h/2;
845 @ var y1 = Math.ceil(to.y + node.h + arw.h/2);
846 @ drawLine(line,color,x,y0,null,y1);
847 @ x = to.x + (node.w-arw.w)/2;
848 @ var n = drawBox(arw.cls,null,x,y);
849 @ n.style.borderBottomColor = color;
850 @ }
851 @ function drawMergeLine(x0,y0,x1,y1){
852 @ drawLine(mLine,null,x0,y0,x1,y1);
853 @ }
854 @ function drawMergeArrow(p,rail){
855 @ var x0 = rail*railPitch + node.w/2;
856 @ if( rail in mergeLines ){
857 @ x0 += mergeLines[rail];
858 @ if( p.r<rail ) x0 += mLine.w;
859 @ }else{
860 @ x0 += (p.r<rail ? -1 : 1)*line.w/2;
861 @ }
862 @ var x1 = mArrow.w ? mArrow.w/2 : -node.w/2;
863 @ x1 = p.x + (p.r<rail ? node.w + Math.ceil(x1) : -x1);
864 @ var y = miLineY(p);
865 @ drawMergeLine(x0,y,x1,null);
866 @ var x = p.x + (p.r<rail ? node.w : -mArrow.w);
867 @ var cls = "arrow merge " + (p.r<rail ? "l" : "r");
868 @ drawBox(cls,null,x,y+(mLine.w-mArrow.h)/2);
869 @ }
870 @ function drawNode(p, btm){
871 @ if( p.u>0 ) drawUpArrow(p,rowinfo[p.u-1],p.fg);
872 @ var cls = node.cls;
873 @ if( p.mi.length ) cls += " merge";
874 @ if( p.f&1 ) cls += " leaf";
875 @ var n = drawBox(cls,p.bg,p.x,p.y);
876 @ n.id = "tln"+p.id;
877 @ n.onclick = clickOnNode;
878 @ n.style.zIndex = 10;
879 if( !omitDescenders ){
880 @ if( p.u==0 ) drawUpArrow(p,{x: p.x, y: -node.h},p.fg);
881 @ if( p.d ) drawUpArrow({x: p.x, y: btm-node.h/2},p,p.fg);
882 }
883 @ if( p.mo>=0 ){
884 @ var x0 = p.x + node.w/2;
885 @ var x1 = p.mo*railPitch + node.w/2;
886 @ var u = rowinfo[p.mu-1];
887 @ var y1 = miLineY(u);
888 @ if( p.u<0 || p.mo!=p.r ){
889 @ x1 += mergeLines[p.mo] = -mLine.w/2;
890 @ var y0 = p.y+2;
891 @ if( p.r!=p.mo ) drawMergeLine(x0,y0,x1+(x0<x1 ? mLine.w : 0),null);
892 @ drawMergeLine(x1,y0+mLine.w,null,y1);
893 @ }else if( mergeOffset ){
894 @ mergeLines[p.mo] = u.r<p.r ? -mergeOffset-mLine.w : mergeOffset;
895 @ x1 += mergeLines[p.mo];
896 @ drawMergeLine(x1,p.y+node.h/2,null,y1);
897 @ }else{
898 @ delete mergeLines[p.mo];
899 @ }
900 @ }
901 @ for( var i=0; i<p.au.length; i+=2 ){
902 @ var rail = p.au[i];
903 @ var x0 = p.x + node.w/2;
904 @ var x1 = rail*railPitch + (node.w-line.w)/2;
905 @ if( x0<x1 ){
906 @ x0 = Math.ceil(x0);
907 @ x1 += line.w;
908 @ }
909 @ var y0 = p.y + (node.h-line.w)/2;
910 @ var u = rowinfo[p.au[i+1]-1];
911 @ if( u.id<p.id ){
912 @ drawLine(line,u.fg,x0,y0,x1,null);
913 @ drawUpArrow(p,u,u.fg);
914 @ }else{
915 @ var y1 = u.y + (node.h-line.w)/2;
916 @ drawLine(wLine,u.fg,x0,y0,x1,null);
917 @ drawLine(wLine,u.fg,x1-line.w,y0,null,y1+line.w);
918 @ drawLine(wLine,u.fg,x1,y1,u.x-wArrow.w/2,null);
919 @ var x = u.x-wArrow.w;
920 @ var y = u.y+(node.h-wArrow.h)/2;
921 @ var n = drawBox(wArrow.cls,null,x,y);
922 @ if( u.fg ) n.style.borderLeftColor = u.fg;
923 @ }
924 @ }
925 @ for( var i=0; i<p.mi.length; i++ ){
926 @ var rail = p.mi[i];
927 @ if( rail<0 ){
928 @ rail = -rail;
929 @ mergeLines[rail] = -mLine.w/2;
930 @ var x = rail*railPitch + (node.w-mLine.w)/2;
931 @ drawMergeLine(x,miLineY(p),null,btm);
932 @ }
933 @ drawMergeArrow(p,rail);
934 @ }
935 @ }
936 @ var mergeLines;
937 @ function renderGraph(){
938 @ mergeLines = {};
939 @ canvasDiv.innerHTML = "";
940 @ var canvasY = absoluteY(canvasDiv);
941 @ for( var i=0; i<rowinfo.length; i++ ){
942 @ rowinfo[i].y = absoluteY(gebi("m"+rowinfo[i].id)) - canvasY;
943 @ rowinfo[i].x = rowinfo[i].r*railPitch;
944 @ }
945 @ var tlBtm = document.querySelector(".timelineBottom");
946 @ if( tlBtm.offsetHeight<node.h ){
947 @ tlBtm.style.height = node.h + "px";
948 @ }
949 @ var btm = absoluteY(tlBtm) - canvasY + tlBtm.offsetHeight;
950 @ for( var i=rowinfo.length-1; i>=0; i-- ){
951 @ drawNode(rowinfo[i], btm);
952 @ }
953 @ }
954 @ var selRow;
955 @ function clickOnNode(){
956 @ var p = rowinfo[parseInt(this.id.match(/\d+$/)[0], 10)-1];
957 @ if( !selRow ){
958 @ selRow = p;
959 @ this.className += " sel";
960 @ canvasDiv.className += " sel";
961 @ }else if( selRow==p ){
962 @ selRow = null;
963 @ this.className = this.className.replace(" sel", "");
964 @ canvasDiv.className = canvasDiv.className.replace(" sel", "");
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
965 @ }else{
966 if( fileDiff ){
967 @ location.href="%R/fdiff?v1="+selRow.h+"&v2="+p.h+"&sbs=1";
968 }else{
969 if( db_get_boolean("show-version-diffs", 0)==0 ){
@@ -942,22 +972,23 @@
972 @ location.href="%R/vdiff?from="+selRow.h+"&to="+p.h+"&sbs=1";
973 }
974 }
975 @ }
976 @ }
977 @ var lastRow = gebi("m"+rowinfo[rowinfo.length-1].id);
978 @ var lastY = 0;
979 @ function checkHeight(){
980 @ var h = absoluteY(lastRow);
981 @ if( h!=lastY ){
982 @ renderGraph();
983 @ lastY = h;
984 @ }
985 @ setTimeout(checkHeight, 1000);
986 @ }
987 @ initGraph();
988 @ checkHeight();
989 @ }())</script>
990 }
991 }
992
993 /*
994 ** Create a temporary table suitable for storing timeline data.
@@ -1160,10 +1191,11 @@
1191 ** shortest ... show only the shortest path
1192 ** uf=FUUID Show only check-ins that use given file version
1193 ** brbg Background color from branch name
1194 ** ubg Background color from user
1195 ** namechng Show only check-ins that filename changes
1196 ** forks Show only forks and their children
1197 ** ym=YYYY-MM Shown only events for the given year/month.
1198 ** datefmt=N Override the date format
1199 **
1200 ** p= and d= can appear individually or together. If either p= or d=
1201 ** appear, then u=, y=, a=, and b= are ignored.
@@ -1193,10 +1225,11 @@
1225 const char *zUses = P("uf"); /* Only show check-ins hold this file */
1226 const char *zYearMonth = P("ym"); /* Show check-ins for the given YYYY-MM */
1227 const char *zYearWeek = P("yw"); /* Check-ins for YYYY-WW (week-of-year) */
1228 int useDividers = P("nd")==0; /* Show dividers if "nd" is missing */
1229 int renameOnly = P("namechng")!=0; /* Show only check-ins that rename files */
1230 int forkOnly = PB("forks"); /* Show only forks and their children */
1231 int tagid; /* Tag ID */
1232 int tmFlags = 0; /* Timeline flags */
1233 const char *zThisTag = 0; /* Suppress links to this tag */
1234 const char *zThisUser = 0; /* Suppress links to this user */
1235 HQuery url; /* URL for various branch links */
@@ -1299,10 +1332,30 @@
1332 "CREATE TEMP TABLE rnfile(rid INTEGER PRIMARY KEY);"
1333 "INSERT OR IGNORE INTO rnfile"
1334 " SELECT mid FROM mlink WHERE pfnid>0 AND pfnid!=fnid;"
1335 );
1336 disableY = 1;
1337 }
1338 if( forkOnly ){
1339 db_multi_exec(
1340 "CREATE TEMP TABLE rnfork(rid INTEGER PRIMARY KEY);\n"
1341 "INSERT OR IGNORE INTO rnfork(rid)\n"
1342 " SELECT pid FROM plink\n"
1343 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
1344 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1345 " GROUP BY pid"
1346 " HAVING count(*)>1;\n"
1347 "INSERT OR IGNORE INTO rnfork(rid)"
1348 " SELECT cid FROM plink\n"
1349 " WHERE (SELECT value FROM tagxref WHERE tagid=%d AND rid=cid)=="
1350 " (SELECT value FROM tagxref WHERE tagid=%d AND rid=pid)\n"
1351 " AND pid IN rnfork;",
1352 TAG_BRANCH, TAG_BRANCH, TAG_BRANCH, TAG_BRANCH
1353 );
1354 tmFlags |= TIMELINE_UNHIDE;
1355 zType = "ci";
1356 disableY = 1;
1357 }
1358
1359 style_header("Timeline");
1360 login_anonymous_available();
1361 timeline_temp_table();
@@ -1429,10 +1482,13 @@
1482 blob_append_sql(&sql, " AND event.objid IN usesfile ");
1483 }
1484 if( renameOnly ){
1485 blob_append_sql(&sql, " AND event.objid IN rnfile ");
1486 }
1487 if( forkOnly ){
1488 blob_append_sql(&sql, " AND event.objid IN rnfork ");
1489 }
1490 if( zYearMonth ){
1491 blob_append_sql(&sql, " AND %Q=strftime('%%Y-%%m',event.mtime) ",
1492 zYearMonth);
1493 }
1494 else if( zYearWeek ){
@@ -1601,10 +1657,14 @@
1657 }
1658 if( renameOnly ){
1659 blob_appendf(&desc, " that contain filename changes");
1660 tmFlags |= TIMELINE_DISJOINT|TIMELINE_FRENAMES;
1661 }
1662 if( forkOnly ){
1663 blob_appendf(&desc, " associated with forks");
1664 tmFlags |= TIMELINE_DISJOINT;
1665 }
1666 if( zUser ){
1667 blob_appendf(&desc, " by user %h", zUser);
1668 tmFlags |= TIMELINE_DISJOINT;
1669 }
1670 if( zTagName ){
@@ -1788,11 +1848,11 @@
1848 fossil_free(zFree);
1849
1850 if(verboseFlag){
1851 if( !fchngQueryInit ){
1852 db_prepare(&fchngQuery,
1853 "SELECT (pid<=0) AS isnew,"
1854 " (fid==0) AS isdel,"
1855 " (SELECT name FROM filename WHERE fnid=mlink.fnid) AS name,"
1856 " (SELECT uuid FROM blob WHERE rid=fid),"
1857 " (SELECT uuid FROM blob WHERE rid=pid)"
1858 " FROM mlink"
@@ -2149,10 +2209,15 @@
2209 db_finalize(&q);
2210 }
2211
2212 /*
2213 ** WEBPAGE: test_timewarps
2214 **
2215 ** Show all check-ins that are "timewarps". A timewarp is a
2216 ** check-in that occurs before its parent, according to the
2217 ** timestamp information on the check-in. This can only actually
2218 ** happen, of course, if a users system clock is set incorrectly.
2219 */
2220 void test_timewarp_page(void){
2221 Stmt q;
2222
2223 login_check_credentials();
2224
+1 -1
--- src/tkt.c
+++ src/tkt.c
@@ -441,11 +441,11 @@
441441
442442
/*
443443
** WEBPAGE: tktview
444444
** URL: tktview?name=UUID
445445
**
446
-** View a ticket.
446
+** View a ticket identified by the name= query parameter.
447447
*/
448448
void tktview_page(void){
449449
const char *zScript;
450450
char *zFullName;
451451
const char *zUuid = PD("name","");
452452
--- src/tkt.c
+++ src/tkt.c
@@ -441,11 +441,11 @@
441
442 /*
443 ** WEBPAGE: tktview
444 ** URL: tktview?name=UUID
445 **
446 ** View a ticket.
447 */
448 void tktview_page(void){
449 const char *zScript;
450 char *zFullName;
451 const char *zUuid = PD("name","");
452
--- src/tkt.c
+++ src/tkt.c
@@ -441,11 +441,11 @@
441
442 /*
443 ** WEBPAGE: tktview
444 ** URL: tktview?name=UUID
445 **
446 ** View a ticket identified by the name= query parameter.
447 */
448 void tktview_page(void){
449 const char *zScript;
450 char *zFullName;
451 const char *zUuid = PD("name","");
452
+24 -1
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -21,12 +21,12 @@
2121
#include "config.h"
2222
#include "tktsetup.h"
2323
#include <assert.h>
2424
2525
/*
26
-** Main sub-menu for configuring the ticketing system.
2726
** WEBPAGE: tktsetup
27
+** Main sub-menu for configuring the ticketing system.
2828
*/
2929
void tktsetup_page(void){
3030
login_check_credentials();
3131
if( !g.perm.Setup ){
3232
login_needed(0);
@@ -167,10 +167,12 @@
167167
style_footer();
168168
}
169169
170170
/*
171171
** WEBPAGE: tktsetup_tab
172
+** Administrative page for defining the "ticket" table used
173
+** to hold ticket information.
172174
*/
173175
void tktsetup_tab_page(void){
174176
static const char zDesc[] =
175177
@ Enter a valid CREATE TABLE statement for the "ticket" table. The
176178
@ table must contain columns named "tkt_id", "tkt_uuid", and "tkt_mtime"
@@ -243,10 +245,12 @@
243245
return db_get("ticket-common", (char*)zDefaultTicketCommon);
244246
}
245247
246248
/*
247249
** WEBPAGE: tktsetup_com
250
+** Administrative page used to define TH1 script that is
251
+** common to all ticket screens.
248252
*/
249253
void tktsetup_com_page(void){
250254
static const char zDesc[] =
251255
@ Enter TH1 script that initializes variables prior to generating
252256
@ any of the ticket view, edit, or creation pages.
@@ -273,10 +277,12 @@
273277
return db_get("ticket-change", (char*)zDefaultTicketChange);
274278
}
275279
276280
/*
277281
** WEBPAGE: tktsetup_change
282
+** Adminstrative screen used to view or edit the TH1 script
283
+** that shows ticket changes.
278284
*/
279285
void tktsetup_change_page(void){
280286
static const char zDesc[] =
281287
@ Enter TH1 script that runs after processing the ticket editing
282288
@ and creation pages.
@@ -416,10 +422,12 @@
416422
return db_get("ticket-newpage", (char*)zDefaultNew);
417423
}
418424
419425
/*
420426
** WEBPAGE: tktsetup_newpage
427
+** Administrative page used to view or edit the TH1 script used
428
+** to enter new tickets.
421429
*/
422430
void tktsetup_newpage_page(void){
423431
static const char zDesc[] =
424432
@ Enter HTML with embedded TH1 script that will render the "new ticket"
425433
@ page
@@ -555,10 +563,12 @@
555563
return db_get("ticket-viewpage", (char*)zDefaultView);
556564
}
557565
558566
/*
559567
** WEBPAGE: tktsetup_viewpage
568
+** Administrative page used to view or edit the TH1 script that
569
+** displays individual tickets.
560570
*/
561571
void tktsetup_viewpage_page(void){
562572
static const char zDesc[] =
563573
@ Enter HTML with embedded TH1 script that will render the "view ticket" page
564574
;
@@ -694,10 +704,12 @@
694704
return db_get("ticket-editpage", (char*)zDefaultEdit);
695705
}
696706
697707
/*
698708
** WEBPAGE: tktsetup_editpage
709
+** Administrative page for viewing or editing the TH1 script that
710
+** drives the ticket editing page.
699711
*/
700712
void tktsetup_editpage_page(void){
701713
static const char zDesc[] =
702714
@ Enter HTML with embedded TH1 script that will render the "edit ticket" page
703715
;
@@ -748,10 +760,12 @@
748760
return db_get("ticket-reportlist", (char*)zDefaultReportList);
749761
}
750762
751763
/*
752764
** WEBPAGE: tktsetup_reportlist
765
+** Administrative page used to view or edit the TH1 script that
766
+** defines the "report list" page.
753767
*/
754768
void tktsetup_reportlist(void){
755769
static const char zDesc[] =
756770
@ Enter HTML with embedded TH1 script that will render the "report list" page
757771
;
@@ -795,10 +809,13 @@
795809
return db_get("ticket-report-template", zDefaultReport);
796810
}
797811
798812
/*
799813
** WEBPAGE: tktsetup_rpttplt
814
+**
815
+** Administrative page used to view or edit the ticket report
816
+** template.
800817
*/
801818
void tktsetup_rpttplt_page(void){
802819
static const char zDesc[] =
803820
@ Enter the default ticket report format template. This is the
804821
@ template report format that initially appears when creating a
@@ -836,10 +853,13 @@
836853
return db_get("ticket-key-template", (char*)zDefaultKey);
837854
}
838855
839856
/*
840857
** WEBPAGE: tktsetup_keytplt
858
+**
859
+** Administrative page used to view or edit the Key template
860
+** for tickets.
841861
*/
842862
void tktsetup_keytplt_page(void){
843863
static const char zDesc[] =
844864
@ Enter the default ticket report color-key template. This is the
845865
@ the color-key that initially appears when creating a
@@ -856,10 +876,13 @@
856876
);
857877
}
858878
859879
/*
860880
** WEBPAGE: tktsetup_timeline
881
+**
882
+** Administrative page used ot configure how tickets are
883
+** rendered on timeline views.
861884
*/
862885
void tktsetup_timeline_page(void){
863886
login_check_credentials();
864887
if( !g.perm.Setup ){
865888
login_needed(0);
866889
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -21,12 +21,12 @@
21 #include "config.h"
22 #include "tktsetup.h"
23 #include <assert.h>
24
25 /*
26 ** Main sub-menu for configuring the ticketing system.
27 ** WEBPAGE: tktsetup
 
28 */
29 void tktsetup_page(void){
30 login_check_credentials();
31 if( !g.perm.Setup ){
32 login_needed(0);
@@ -167,10 +167,12 @@
167 style_footer();
168 }
169
170 /*
171 ** WEBPAGE: tktsetup_tab
 
 
172 */
173 void tktsetup_tab_page(void){
174 static const char zDesc[] =
175 @ Enter a valid CREATE TABLE statement for the "ticket" table. The
176 @ table must contain columns named "tkt_id", "tkt_uuid", and "tkt_mtime"
@@ -243,10 +245,12 @@
243 return db_get("ticket-common", (char*)zDefaultTicketCommon);
244 }
245
246 /*
247 ** WEBPAGE: tktsetup_com
 
 
248 */
249 void tktsetup_com_page(void){
250 static const char zDesc[] =
251 @ Enter TH1 script that initializes variables prior to generating
252 @ any of the ticket view, edit, or creation pages.
@@ -273,10 +277,12 @@
273 return db_get("ticket-change", (char*)zDefaultTicketChange);
274 }
275
276 /*
277 ** WEBPAGE: tktsetup_change
 
 
278 */
279 void tktsetup_change_page(void){
280 static const char zDesc[] =
281 @ Enter TH1 script that runs after processing the ticket editing
282 @ and creation pages.
@@ -416,10 +422,12 @@
416 return db_get("ticket-newpage", (char*)zDefaultNew);
417 }
418
419 /*
420 ** WEBPAGE: tktsetup_newpage
 
 
421 */
422 void tktsetup_newpage_page(void){
423 static const char zDesc[] =
424 @ Enter HTML with embedded TH1 script that will render the "new ticket"
425 @ page
@@ -555,10 +563,12 @@
555 return db_get("ticket-viewpage", (char*)zDefaultView);
556 }
557
558 /*
559 ** WEBPAGE: tktsetup_viewpage
 
 
560 */
561 void tktsetup_viewpage_page(void){
562 static const char zDesc[] =
563 @ Enter HTML with embedded TH1 script that will render the "view ticket" page
564 ;
@@ -694,10 +704,12 @@
694 return db_get("ticket-editpage", (char*)zDefaultEdit);
695 }
696
697 /*
698 ** WEBPAGE: tktsetup_editpage
 
 
699 */
700 void tktsetup_editpage_page(void){
701 static const char zDesc[] =
702 @ Enter HTML with embedded TH1 script that will render the "edit ticket" page
703 ;
@@ -748,10 +760,12 @@
748 return db_get("ticket-reportlist", (char*)zDefaultReportList);
749 }
750
751 /*
752 ** WEBPAGE: tktsetup_reportlist
 
 
753 */
754 void tktsetup_reportlist(void){
755 static const char zDesc[] =
756 @ Enter HTML with embedded TH1 script that will render the "report list" page
757 ;
@@ -795,10 +809,13 @@
795 return db_get("ticket-report-template", zDefaultReport);
796 }
797
798 /*
799 ** WEBPAGE: tktsetup_rpttplt
 
 
 
800 */
801 void tktsetup_rpttplt_page(void){
802 static const char zDesc[] =
803 @ Enter the default ticket report format template. This is the
804 @ template report format that initially appears when creating a
@@ -836,10 +853,13 @@
836 return db_get("ticket-key-template", (char*)zDefaultKey);
837 }
838
839 /*
840 ** WEBPAGE: tktsetup_keytplt
 
 
 
841 */
842 void tktsetup_keytplt_page(void){
843 static const char zDesc[] =
844 @ Enter the default ticket report color-key template. This is the
845 @ the color-key that initially appears when creating a
@@ -856,10 +876,13 @@
856 );
857 }
858
859 /*
860 ** WEBPAGE: tktsetup_timeline
 
 
 
861 */
862 void tktsetup_timeline_page(void){
863 login_check_credentials();
864 if( !g.perm.Setup ){
865 login_needed(0);
866
--- src/tktsetup.c
+++ src/tktsetup.c
@@ -21,12 +21,12 @@
21 #include "config.h"
22 #include "tktsetup.h"
23 #include <assert.h>
24
25 /*
 
26 ** WEBPAGE: tktsetup
27 ** Main sub-menu for configuring the ticketing system.
28 */
29 void tktsetup_page(void){
30 login_check_credentials();
31 if( !g.perm.Setup ){
32 login_needed(0);
@@ -167,10 +167,12 @@
167 style_footer();
168 }
169
170 /*
171 ** WEBPAGE: tktsetup_tab
172 ** Administrative page for defining the "ticket" table used
173 ** to hold ticket information.
174 */
175 void tktsetup_tab_page(void){
176 static const char zDesc[] =
177 @ Enter a valid CREATE TABLE statement for the "ticket" table. The
178 @ table must contain columns named "tkt_id", "tkt_uuid", and "tkt_mtime"
@@ -243,10 +245,12 @@
245 return db_get("ticket-common", (char*)zDefaultTicketCommon);
246 }
247
248 /*
249 ** WEBPAGE: tktsetup_com
250 ** Administrative page used to define TH1 script that is
251 ** common to all ticket screens.
252 */
253 void tktsetup_com_page(void){
254 static const char zDesc[] =
255 @ Enter TH1 script that initializes variables prior to generating
256 @ any of the ticket view, edit, or creation pages.
@@ -273,10 +277,12 @@
277 return db_get("ticket-change", (char*)zDefaultTicketChange);
278 }
279
280 /*
281 ** WEBPAGE: tktsetup_change
282 ** Adminstrative screen used to view or edit the TH1 script
283 ** that shows ticket changes.
284 */
285 void tktsetup_change_page(void){
286 static const char zDesc[] =
287 @ Enter TH1 script that runs after processing the ticket editing
288 @ and creation pages.
@@ -416,10 +422,12 @@
422 return db_get("ticket-newpage", (char*)zDefaultNew);
423 }
424
425 /*
426 ** WEBPAGE: tktsetup_newpage
427 ** Administrative page used to view or edit the TH1 script used
428 ** to enter new tickets.
429 */
430 void tktsetup_newpage_page(void){
431 static const char zDesc[] =
432 @ Enter HTML with embedded TH1 script that will render the "new ticket"
433 @ page
@@ -555,10 +563,12 @@
563 return db_get("ticket-viewpage", (char*)zDefaultView);
564 }
565
566 /*
567 ** WEBPAGE: tktsetup_viewpage
568 ** Administrative page used to view or edit the TH1 script that
569 ** displays individual tickets.
570 */
571 void tktsetup_viewpage_page(void){
572 static const char zDesc[] =
573 @ Enter HTML with embedded TH1 script that will render the "view ticket" page
574 ;
@@ -694,10 +704,12 @@
704 return db_get("ticket-editpage", (char*)zDefaultEdit);
705 }
706
707 /*
708 ** WEBPAGE: tktsetup_editpage
709 ** Administrative page for viewing or editing the TH1 script that
710 ** drives the ticket editing page.
711 */
712 void tktsetup_editpage_page(void){
713 static const char zDesc[] =
714 @ Enter HTML with embedded TH1 script that will render the "edit ticket" page
715 ;
@@ -748,10 +760,12 @@
760 return db_get("ticket-reportlist", (char*)zDefaultReportList);
761 }
762
763 /*
764 ** WEBPAGE: tktsetup_reportlist
765 ** Administrative page used to view or edit the TH1 script that
766 ** defines the "report list" page.
767 */
768 void tktsetup_reportlist(void){
769 static const char zDesc[] =
770 @ Enter HTML with embedded TH1 script that will render the "report list" page
771 ;
@@ -795,10 +809,13 @@
809 return db_get("ticket-report-template", zDefaultReport);
810 }
811
812 /*
813 ** WEBPAGE: tktsetup_rpttplt
814 **
815 ** Administrative page used to view or edit the ticket report
816 ** template.
817 */
818 void tktsetup_rpttplt_page(void){
819 static const char zDesc[] =
820 @ Enter the default ticket report format template. This is the
821 @ template report format that initially appears when creating a
@@ -836,10 +853,13 @@
853 return db_get("ticket-key-template", (char*)zDefaultKey);
854 }
855
856 /*
857 ** WEBPAGE: tktsetup_keytplt
858 **
859 ** Administrative page used to view or edit the Key template
860 ** for tickets.
861 */
862 void tktsetup_keytplt_page(void){
863 static const char zDesc[] =
864 @ Enter the default ticket report color-key template. This is the
865 @ the color-key that initially appears when creating a
@@ -856,10 +876,13 @@
876 );
877 }
878
879 /*
880 ** WEBPAGE: tktsetup_timeline
881 **
882 ** Administrative page used ot configure how tickets are
883 ** rendered on timeline views.
884 */
885 void tktsetup_timeline_page(void){
886 login_check_credentials();
887 if( !g.perm.Setup ){
888 login_needed(0);
889
+4 -5
--- src/update.c
+++ src/update.c
@@ -175,14 +175,12 @@
175175
** target as if VERSION were omitted and the --latest flag is present.
176176
*/
177177
latestFlag = 1;
178178
}else{
179179
tid = name_to_typed_rid(g.argv[2],"ci");
180
- if( tid==0 ){
181
- fossil_fatal("no such version: %s", g.argv[2]);
182
- }else if( !is_a_version(tid) ){
183
- fossil_fatal("no such version: %s", g.argv[2]);
180
+ if( tid==0 || !is_a_version(tid) ){
181
+ fossil_fatal("no such check-in: %s", g.argv[2]);
184182
}
185183
}
186184
}
187185
188186
/* If no VERSION is specified on the command-line, then look for a
@@ -544,10 +542,11 @@
544542
fossil_warning("uncommitted %s against %S.",
545543
zLabel, db_column_text(&q, 0));
546544
nMerge++;
547545
}
548546
db_finalize(&q);
547
+ leaf_ambiguity_warning(tid, tid);
549548
550549
if( nConflict ){
551550
if( internalUpdate ){
552551
internalConflictCnt = nConflict;
553552
nConflict = 0;
@@ -651,11 +650,11 @@
651650
const char *file, /* Full treename of the file */
652651
Blob *content, /* Put the content here */
653652
int *pIsLink, /* Set to true if file is link. */
654653
int *pIsExe, /* Set to true if file is executable */
655654
int *pIsBin, /* Set to true if file is binary */
656
- int errCode /* Error code if file not found. Panic if 0. */
655
+ int errCode /* Error code if file not found. Panic if <= 0. */
657656
){
658657
Manifest *pManifest;
659658
ManifestFile *pFile;
660659
int rid=0;
661660
662661
--- src/update.c
+++ src/update.c
@@ -175,14 +175,12 @@
175 ** target as if VERSION were omitted and the --latest flag is present.
176 */
177 latestFlag = 1;
178 }else{
179 tid = name_to_typed_rid(g.argv[2],"ci");
180 if( tid==0 ){
181 fossil_fatal("no such version: %s", g.argv[2]);
182 }else if( !is_a_version(tid) ){
183 fossil_fatal("no such version: %s", g.argv[2]);
184 }
185 }
186 }
187
188 /* If no VERSION is specified on the command-line, then look for a
@@ -544,10 +542,11 @@
544 fossil_warning("uncommitted %s against %S.",
545 zLabel, db_column_text(&q, 0));
546 nMerge++;
547 }
548 db_finalize(&q);
 
549
550 if( nConflict ){
551 if( internalUpdate ){
552 internalConflictCnt = nConflict;
553 nConflict = 0;
@@ -651,11 +650,11 @@
651 const char *file, /* Full treename of the file */
652 Blob *content, /* Put the content here */
653 int *pIsLink, /* Set to true if file is link. */
654 int *pIsExe, /* Set to true if file is executable */
655 int *pIsBin, /* Set to true if file is binary */
656 int errCode /* Error code if file not found. Panic if 0. */
657 ){
658 Manifest *pManifest;
659 ManifestFile *pFile;
660 int rid=0;
661
662
--- src/update.c
+++ src/update.c
@@ -175,14 +175,12 @@
175 ** target as if VERSION were omitted and the --latest flag is present.
176 */
177 latestFlag = 1;
178 }else{
179 tid = name_to_typed_rid(g.argv[2],"ci");
180 if( tid==0 || !is_a_version(tid) ){
181 fossil_fatal("no such check-in: %s", g.argv[2]);
 
 
182 }
183 }
184 }
185
186 /* If no VERSION is specified on the command-line, then look for a
@@ -544,10 +542,11 @@
542 fossil_warning("uncommitted %s against %S.",
543 zLabel, db_column_text(&q, 0));
544 nMerge++;
545 }
546 db_finalize(&q);
547 leaf_ambiguity_warning(tid, tid);
548
549 if( nConflict ){
550 if( internalUpdate ){
551 internalConflictCnt = nConflict;
552 nConflict = 0;
@@ -651,11 +650,11 @@
650 const char *file, /* Full treename of the file */
651 Blob *content, /* Put the content here */
652 int *pIsLink, /* Set to true if file is link. */
653 int *pIsExe, /* Set to true if file is executable */
654 int *pIsBin, /* Set to true if file is binary */
655 int errCode /* Error code if file not found. Panic if <= 0. */
656 ){
657 Manifest *pManifest;
658 ManifestFile *pFile;
659 int rid=0;
660
661
+6 -4
--- src/url.c
+++ src/url.c
@@ -454,12 +454,12 @@
454454
** Resets the given URL object, deallocating any memory
455455
** it uses.
456456
*/
457457
void url_reset(HQuery *p){
458458
blob_reset(&p->url);
459
- fossil_free(p->azName);
460
- fossil_free(p->azValue);
459
+ fossil_free((void *)p->azName);
460
+ fossil_free((void *)p->azValue);
461461
url_initialize(p, p->zBase);
462462
}
463463
464464
/*
465465
** Add a fixed parameter to an HQuery. Or remove the parameters if zValue==0.
@@ -480,12 +480,14 @@
480480
}
481481
assert( i==p->nParam );
482482
if( zValue==0 ) return;
483483
if( i>=p->nAlloc ){
484484
p->nAlloc = p->nAlloc*2 + 10;
485
- p->azName = fossil_realloc(p->azName, sizeof(p->azName[0])*p->nAlloc);
486
- p->azValue = fossil_realloc(p->azValue, sizeof(p->azValue[0])*p->nAlloc);
485
+ p->azName = fossil_realloc((void *)p->azName,
486
+ sizeof(p->azName[0])*p->nAlloc);
487
+ p->azValue = fossil_realloc((void *)p->azValue,
488
+ sizeof(p->azValue[0])*p->nAlloc);
487489
}
488490
p->azName[i] = zName;
489491
p->azValue[i] = zValue;
490492
p->nParam++;
491493
}
492494
--- src/url.c
+++ src/url.c
@@ -454,12 +454,12 @@
454 ** Resets the given URL object, deallocating any memory
455 ** it uses.
456 */
457 void url_reset(HQuery *p){
458 blob_reset(&p->url);
459 fossil_free(p->azName);
460 fossil_free(p->azValue);
461 url_initialize(p, p->zBase);
462 }
463
464 /*
465 ** Add a fixed parameter to an HQuery. Or remove the parameters if zValue==0.
@@ -480,12 +480,14 @@
480 }
481 assert( i==p->nParam );
482 if( zValue==0 ) return;
483 if( i>=p->nAlloc ){
484 p->nAlloc = p->nAlloc*2 + 10;
485 p->azName = fossil_realloc(p->azName, sizeof(p->azName[0])*p->nAlloc);
486 p->azValue = fossil_realloc(p->azValue, sizeof(p->azValue[0])*p->nAlloc);
 
 
487 }
488 p->azName[i] = zName;
489 p->azValue[i] = zValue;
490 p->nParam++;
491 }
492
--- src/url.c
+++ src/url.c
@@ -454,12 +454,12 @@
454 ** Resets the given URL object, deallocating any memory
455 ** it uses.
456 */
457 void url_reset(HQuery *p){
458 blob_reset(&p->url);
459 fossil_free((void *)p->azName);
460 fossil_free((void *)p->azValue);
461 url_initialize(p, p->zBase);
462 }
463
464 /*
465 ** Add a fixed parameter to an HQuery. Or remove the parameters if zValue==0.
@@ -480,12 +480,14 @@
480 }
481 assert( i==p->nParam );
482 if( zValue==0 ) return;
483 if( i>=p->nAlloc ){
484 p->nAlloc = p->nAlloc*2 + 10;
485 p->azName = fossil_realloc((void *)p->azName,
486 sizeof(p->azName[0])*p->nAlloc);
487 p->azValue = fossil_realloc((void *)p->azValue,
488 sizeof(p->azValue[0])*p->nAlloc);
489 }
490 p->azName[i] = zName;
491 p->azValue[i] = zValue;
492 p->nParam++;
493 }
494
+9 -4
--- src/user.c
+++ src/user.c
@@ -410,17 +410,22 @@
410410
}
411411
412412
/*
413413
** WEBPAGE: access_log
414414
**
415
-** y=N 1: success only. 2: failure only. 3: both
416
-** n=N Number of entries to show
417
-** o=N Skip this many entries
415
+** Show login attempts, including timestamp and IP address.
416
+** Requires Admin privileges.
417
+**
418
+** Query parameters:
419
+**
420
+** y=N 1: success only. 2: failure only. 3: both (default: 3)
421
+** n=N Number of entries to show (default: 200)
422
+** o=N Skip this many entries (default: 0)
418423
*/
419424
void access_log_page(void){
420425
int y = atoi(PD("y","3"));
421
- int n = atoi(PD("n","50"));
426
+ int n = atoi(PD("n","200"));
422427
int skip = atoi(PD("o","0"));
423428
Blob sql;
424429
Stmt q;
425430
int cnt = 0;
426431
int rc;
427432
--- src/user.c
+++ src/user.c
@@ -410,17 +410,22 @@
410 }
411
412 /*
413 ** WEBPAGE: access_log
414 **
415 ** y=N 1: success only. 2: failure only. 3: both
416 ** n=N Number of entries to show
417 ** o=N Skip this many entries
 
 
 
 
 
418 */
419 void access_log_page(void){
420 int y = atoi(PD("y","3"));
421 int n = atoi(PD("n","50"));
422 int skip = atoi(PD("o","0"));
423 Blob sql;
424 Stmt q;
425 int cnt = 0;
426 int rc;
427
--- src/user.c
+++ src/user.c
@@ -410,17 +410,22 @@
410 }
411
412 /*
413 ** WEBPAGE: access_log
414 **
415 ** Show login attempts, including timestamp and IP address.
416 ** Requires Admin privileges.
417 **
418 ** Query parameters:
419 **
420 ** y=N 1: success only. 2: failure only. 3: both (default: 3)
421 ** n=N Number of entries to show (default: 200)
422 ** o=N Skip this many entries (default: 0)
423 */
424 void access_log_page(void){
425 int y = atoi(PD("y","3"));
426 int n = atoi(PD("n","200"));
427 int skip = atoi(PD("o","0"));
428 Blob sql;
429 Stmt q;
430 int cnt = 0;
431 int rc;
432
+1 -1
--- src/utf8.c
+++ src/utf8.c
@@ -323,11 +323,11 @@
323323
}
324324
325325
/* If blob to be written to the Windows console is not
326326
* UTF-8, convert it to UTF-8 first.
327327
*/
328
- blob_init(&blob, zUtf8, nByte);
328
+ blob_init(&blob, zUtf8, nByte);
329329
blob_to_utf8_no_bom(&blob, 1);
330330
nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
331331
blob_size(&blob), NULL, 0);
332332
zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
333333
if( zUnicode==0 ){
334334
--- src/utf8.c
+++ src/utf8.c
@@ -323,11 +323,11 @@
323 }
324
325 /* If blob to be written to the Windows console is not
326 * UTF-8, convert it to UTF-8 first.
327 */
328 blob_init(&blob, zUtf8, nByte);
329 blob_to_utf8_no_bom(&blob, 1);
330 nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
331 blob_size(&blob), NULL, 0);
332 zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
333 if( zUnicode==0 ){
334
--- src/utf8.c
+++ src/utf8.c
@@ -323,11 +323,11 @@
323 }
324
325 /* If blob to be written to the Windows console is not
326 * UTF-8, convert it to UTF-8 first.
327 */
328 blob_init(&blob, zUtf8, nByte);
329 blob_to_utf8_no_bom(&blob, 1);
330 nChar = MultiByteToWideChar(CP_UTF8, 0, blob_buffer(&blob),
331 blob_size(&blob), NULL, 0);
332 zUnicode = malloc( (nChar + 1) *sizeof(zUnicode[0]) );
333 if( zUnicode==0 ){
334
+9 -7
--- src/vfile.c
+++ src/vfile.c
@@ -546,12 +546,11 @@
546546
int vfile_dir_scan(
547547
Blob *pPath, /* Base directory to be scanned */
548548
int nPrefix, /* Number of bytes in base directory name */
549549
unsigned scanFlags, /* Zero or more SCAN_xxx flags */
550550
Glob *pIgnore1, /* Do not add directories that match this GLOB */
551
- Glob *pIgnore2, /* Omit directories matching this GLOB too */
552
- Glob *pIgnore3 /* Omit directories matching this GLOB too */
551
+ Glob *pIgnore2 /* Omit directories matching this GLOB too */
553552
){
554553
int result = 0;
555554
DIR *d;
556555
int origSize;
557556
struct dirent *pEntry;
@@ -560,15 +559,14 @@
560559
static Stmt upd;
561560
static int depth = 0;
562561
void *zNative;
563562
564563
origSize = blob_size(pPath);
565
- if( pIgnore1 || pIgnore2 || pIgnore3 ){
564
+ if( pIgnore1 || pIgnore2 ){
566565
blob_appendf(pPath, "/");
567566
if( glob_match(pIgnore1, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
568567
if( glob_match(pIgnore2, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
569
- if( glob_match(pIgnore3, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
570568
blob_resize(pPath, origSize);
571569
}
572570
if( skipAll ) return result;
573571
574572
if( depth==0 ){
@@ -604,12 +602,11 @@
604602
zOrigPath = mprintf("%s", blob_str(pPath));
605603
zUtf8 = fossil_filename_to_utf8(pEntry->d_name);
606604
blob_appendf(pPath, "/%s", zUtf8);
607605
zPath = blob_str(pPath);
608606
if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
609
- glob_match(pIgnore2, &zPath[nPrefix+1]) ||
610
- glob_match(pIgnore3, &zPath[nPrefix+1]) ){
607
+ glob_match(pIgnore2, &zPath[nPrefix+1]) ){
611608
/* do nothing */
612609
#ifdef _DIRENT_HAVE_D_TYPE
613610
}else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
614611
? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
615612
#else
@@ -616,11 +613,11 @@
616613
}else if( file_wd_isdir(zPath)==1 ){
617614
#endif
618615
if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
619616
char *zSavePath = mprintf("%s", zPath);
620617
int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
621
- pIgnore2, pIgnore3);
618
+ pIgnore2);
622619
db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
623620
db_bind_int(&ins, ":count", count);
624621
db_step(&ins);
625622
db_reset(&ins);
626623
fossil_free(zSavePath);
@@ -916,10 +913,15 @@
916913
md5sum_finish(pOut);
917914
}
918915
919916
/*
920917
** COMMAND: test-agg-cksum
918
+**
919
+** Display the aggregate checksum for content computed in several
920
+** different ways. The aggregate checksum is used during "fossil commit"
921
+** to double-check that the information about to be committed to the
922
+** repository exactly matches the information currently in the check-out.
921923
*/
922924
void test_agg_cksum_cmd(void){
923925
int vid;
924926
Blob hash, hash2;
925927
db_must_be_within_tree();
926928
--- src/vfile.c
+++ src/vfile.c
@@ -546,12 +546,11 @@
546 int vfile_dir_scan(
547 Blob *pPath, /* Base directory to be scanned */
548 int nPrefix, /* Number of bytes in base directory name */
549 unsigned scanFlags, /* Zero or more SCAN_xxx flags */
550 Glob *pIgnore1, /* Do not add directories that match this GLOB */
551 Glob *pIgnore2, /* Omit directories matching this GLOB too */
552 Glob *pIgnore3 /* Omit directories matching this GLOB too */
553 ){
554 int result = 0;
555 DIR *d;
556 int origSize;
557 struct dirent *pEntry;
@@ -560,15 +559,14 @@
560 static Stmt upd;
561 static int depth = 0;
562 void *zNative;
563
564 origSize = blob_size(pPath);
565 if( pIgnore1 || pIgnore2 || pIgnore3 ){
566 blob_appendf(pPath, "/");
567 if( glob_match(pIgnore1, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
568 if( glob_match(pIgnore2, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
569 if( glob_match(pIgnore3, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
570 blob_resize(pPath, origSize);
571 }
572 if( skipAll ) return result;
573
574 if( depth==0 ){
@@ -604,12 +602,11 @@
604 zOrigPath = mprintf("%s", blob_str(pPath));
605 zUtf8 = fossil_filename_to_utf8(pEntry->d_name);
606 blob_appendf(pPath, "/%s", zUtf8);
607 zPath = blob_str(pPath);
608 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
609 glob_match(pIgnore2, &zPath[nPrefix+1]) ||
610 glob_match(pIgnore3, &zPath[nPrefix+1]) ){
611 /* do nothing */
612 #ifdef _DIRENT_HAVE_D_TYPE
613 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
614 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
615 #else
@@ -616,11 +613,11 @@
616 }else if( file_wd_isdir(zPath)==1 ){
617 #endif
618 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
619 char *zSavePath = mprintf("%s", zPath);
620 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
621 pIgnore2, pIgnore3);
622 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
623 db_bind_int(&ins, ":count", count);
624 db_step(&ins);
625 db_reset(&ins);
626 fossil_free(zSavePath);
@@ -916,10 +913,15 @@
916 md5sum_finish(pOut);
917 }
918
919 /*
920 ** COMMAND: test-agg-cksum
 
 
 
 
 
921 */
922 void test_agg_cksum_cmd(void){
923 int vid;
924 Blob hash, hash2;
925 db_must_be_within_tree();
926
--- src/vfile.c
+++ src/vfile.c
@@ -546,12 +546,11 @@
546 int vfile_dir_scan(
547 Blob *pPath, /* Base directory to be scanned */
548 int nPrefix, /* Number of bytes in base directory name */
549 unsigned scanFlags, /* Zero or more SCAN_xxx flags */
550 Glob *pIgnore1, /* Do not add directories that match this GLOB */
551 Glob *pIgnore2 /* Omit directories matching this GLOB too */
 
552 ){
553 int result = 0;
554 DIR *d;
555 int origSize;
556 struct dirent *pEntry;
@@ -560,15 +559,14 @@
559 static Stmt upd;
560 static int depth = 0;
561 void *zNative;
562
563 origSize = blob_size(pPath);
564 if( pIgnore1 || pIgnore2 ){
565 blob_appendf(pPath, "/");
566 if( glob_match(pIgnore1, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
567 if( glob_match(pIgnore2, &blob_str(pPath)[nPrefix+1]) ) skipAll = 1;
 
568 blob_resize(pPath, origSize);
569 }
570 if( skipAll ) return result;
571
572 if( depth==0 ){
@@ -604,12 +602,11 @@
602 zOrigPath = mprintf("%s", blob_str(pPath));
603 zUtf8 = fossil_filename_to_utf8(pEntry->d_name);
604 blob_appendf(pPath, "/%s", zUtf8);
605 zPath = blob_str(pPath);
606 if( glob_match(pIgnore1, &zPath[nPrefix+1]) ||
607 glob_match(pIgnore2, &zPath[nPrefix+1]) ){
 
608 /* do nothing */
609 #ifdef _DIRENT_HAVE_D_TYPE
610 }else if( (pEntry->d_type==DT_UNKNOWN || pEntry->d_type==DT_LNK)
611 ? (file_wd_isdir(zPath)==1) : (pEntry->d_type==DT_DIR) ){
612 #else
@@ -616,11 +613,11 @@
613 }else if( file_wd_isdir(zPath)==1 ){
614 #endif
615 if( (scanFlags & SCAN_NESTED) || !vfile_top_of_checkout(zPath) ){
616 char *zSavePath = mprintf("%s", zPath);
617 int count = vfile_dir_scan(pPath, nPrefix, scanFlags, pIgnore1,
618 pIgnore2);
619 db_bind_text(&ins, ":file", &zSavePath[nPrefix+1]);
620 db_bind_int(&ins, ":count", count);
621 db_step(&ins);
622 db_reset(&ins);
623 fossil_free(zSavePath);
@@ -916,10 +913,15 @@
913 md5sum_finish(pOut);
914 }
915
916 /*
917 ** COMMAND: test-agg-cksum
918 **
919 ** Display the aggregate checksum for content computed in several
920 ** different ways. The aggregate checksum is used during "fossil commit"
921 ** to double-check that the information about to be committed to the
922 ** repository exactly matches the information currently in the check-out.
923 */
924 void test_agg_cksum_cmd(void){
925 int vid;
926 Blob hash, hash2;
927 db_must_be_within_tree();
928
+9
--- src/wiki.c
+++ src/wiki.c
@@ -76,10 +76,13 @@
7676
7777
/*
7878
** WEBPAGE: home
7979
** WEBPAGE: index
8080
** WEBPAGE: not_found
81
+**
82
+** The /home, /index, and /not_found pages all redirect to the homepage
83
+** configured by the administrator.
8184
*/
8285
void home_page(void){
8386
char *zPageName = db_get("project-name",0);
8487
char *zIndexPage = db_get("index-page",0);
8588
login_check_credentials();
@@ -458,10 +461,12 @@
458461
}
459462
460463
/*
461464
** WEBPAGE: wikiedit
462465
** URL: /wikiedit?name=PAGENAME
466
+**
467
+** Edit a wiki page.
463468
*/
464469
void wikiedit_page(void){
465470
char *zTag;
466471
int rid = 0;
467472
int isSandbox;
@@ -704,10 +709,12 @@
704709
}
705710
706711
/*
707712
** WEBPAGE: wikiappend
708713
** URL: /wikiappend?name=PAGENAME&mimetype=MIMETYPE
714
+**
715
+** Append text to the end of a wiki page.
709716
*/
710717
void wikiappend_page(void){
711718
char *zTag;
712719
int rid = 0;
713720
int isSandbox;
@@ -995,10 +1002,12 @@
9951002
style_footer();
9961003
}
9971004
9981005
/*
9991006
** WEBPAGE: wiki_rules
1007
+**
1008
+** Show the formatting rules for Fossil wiki.
10001009
*/
10011010
void wikirules_page(void){
10021011
style_header("Wiki Formatting Rules");
10031012
@ <h2>Formatting Rule Summary</h2>
10041013
@ <ol>
10051014
--- src/wiki.c
+++ src/wiki.c
@@ -76,10 +76,13 @@
76
77 /*
78 ** WEBPAGE: home
79 ** WEBPAGE: index
80 ** WEBPAGE: not_found
 
 
 
81 */
82 void home_page(void){
83 char *zPageName = db_get("project-name",0);
84 char *zIndexPage = db_get("index-page",0);
85 login_check_credentials();
@@ -458,10 +461,12 @@
458 }
459
460 /*
461 ** WEBPAGE: wikiedit
462 ** URL: /wikiedit?name=PAGENAME
 
 
463 */
464 void wikiedit_page(void){
465 char *zTag;
466 int rid = 0;
467 int isSandbox;
@@ -704,10 +709,12 @@
704 }
705
706 /*
707 ** WEBPAGE: wikiappend
708 ** URL: /wikiappend?name=PAGENAME&mimetype=MIMETYPE
 
 
709 */
710 void wikiappend_page(void){
711 char *zTag;
712 int rid = 0;
713 int isSandbox;
@@ -995,10 +1002,12 @@
995 style_footer();
996 }
997
998 /*
999 ** WEBPAGE: wiki_rules
 
 
1000 */
1001 void wikirules_page(void){
1002 style_header("Wiki Formatting Rules");
1003 @ <h2>Formatting Rule Summary</h2>
1004 @ <ol>
1005
--- src/wiki.c
+++ src/wiki.c
@@ -76,10 +76,13 @@
76
77 /*
78 ** WEBPAGE: home
79 ** WEBPAGE: index
80 ** WEBPAGE: not_found
81 **
82 ** The /home, /index, and /not_found pages all redirect to the homepage
83 ** configured by the administrator.
84 */
85 void home_page(void){
86 char *zPageName = db_get("project-name",0);
87 char *zIndexPage = db_get("index-page",0);
88 login_check_credentials();
@@ -458,10 +461,12 @@
461 }
462
463 /*
464 ** WEBPAGE: wikiedit
465 ** URL: /wikiedit?name=PAGENAME
466 **
467 ** Edit a wiki page.
468 */
469 void wikiedit_page(void){
470 char *zTag;
471 int rid = 0;
472 int isSandbox;
@@ -704,10 +709,12 @@
709 }
710
711 /*
712 ** WEBPAGE: wikiappend
713 ** URL: /wikiappend?name=PAGENAME&mimetype=MIMETYPE
714 **
715 ** Append text to the end of a wiki page.
716 */
717 void wikiappend_page(void){
718 char *zTag;
719 int rid = 0;
720 int isSandbox;
@@ -995,10 +1002,12 @@
1002 style_footer();
1003 }
1004
1005 /*
1006 ** WEBPAGE: wiki_rules
1007 **
1008 ** Show the formatting rules for Fossil wiki.
1009 */
1010 void wikirules_page(void){
1011 style_header("Wiki Formatting Rules");
1012 @ <h2>Formatting Rule Summary</h2>
1013 @ <ol>
1014
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -2094,10 +2094,13 @@
20942094
if( iCur ) blob_append(pOut, "\n", 1);
20952095
}
20962096
20972097
/*
20982098
** COMMAND: test-html-tidy
2099
+**
2100
+** Run the htmlTidy() routine on the content of all files named on
2101
+** the command-line and write the results to standard output.
20992102
*/
21002103
void test_html_tidy(void){
21012104
Blob in, out;
21022105
int i;
21032106
@@ -2212,10 +2215,19 @@
22122215
if( nNL==0 ) blob_append(pOut, "\n", 1);
22132216
}
22142217
22152218
/*
22162219
** COMMAND: test-html-to-text
2220
+**
2221
+** Usage: %fossil test-html-to-text FILE ...
2222
+**
2223
+** Read all files named on the command-line. Convert the file
2224
+** content from HTML to text and write the results on standard
2225
+** output.
2226
+**
2227
+** This command is intended as a test and debug interface for
2228
+** the html_to_plaintext() routine.
22172229
*/
22182230
void test_html_to_text(void){
22192231
Blob in, out;
22202232
int i;
22212233
22222234
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -2094,10 +2094,13 @@
2094 if( iCur ) blob_append(pOut, "\n", 1);
2095 }
2096
2097 /*
2098 ** COMMAND: test-html-tidy
 
 
 
2099 */
2100 void test_html_tidy(void){
2101 Blob in, out;
2102 int i;
2103
@@ -2212,10 +2215,19 @@
2212 if( nNL==0 ) blob_append(pOut, "\n", 1);
2213 }
2214
2215 /*
2216 ** COMMAND: test-html-to-text
 
 
 
 
 
 
 
 
 
2217 */
2218 void test_html_to_text(void){
2219 Blob in, out;
2220 int i;
2221
2222
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -2094,10 +2094,13 @@
2094 if( iCur ) blob_append(pOut, "\n", 1);
2095 }
2096
2097 /*
2098 ** COMMAND: test-html-tidy
2099 **
2100 ** Run the htmlTidy() routine on the content of all files named on
2101 ** the command-line and write the results to standard output.
2102 */
2103 void test_html_tidy(void){
2104 Blob in, out;
2105 int i;
2106
@@ -2212,10 +2215,19 @@
2215 if( nNL==0 ) blob_append(pOut, "\n", 1);
2216 }
2217
2218 /*
2219 ** COMMAND: test-html-to-text
2220 **
2221 ** Usage: %fossil test-html-to-text FILE ...
2222 **
2223 ** Read all files named on the command-line. Convert the file
2224 ** content from HTML to text and write the results on standard
2225 ** output.
2226 **
2227 ** This command is intended as a test and debug interface for
2228 ** the html_to_plaintext() routine.
2229 */
2230 void test_html_to_text(void){
2231 Blob in, out;
2232 int i;
2233
2234
+4 -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);
@@ -1975,8 +1971,12 @@
19751971
if( nErr && go==2 ){
19761972
db_multi_exec("DROP TABLE onremote");
19771973
manifest_crosslink_end(MC_PERMIT_HOOKS);
19781974
content_enable_dephantomize(1);
19791975
db_end_transaction(0);
1976
+ }
1977
+ if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){
1978
+ fossil_warning("***** WARNING: a fork has occurred *****\n"
1979
+ "use \"fossil leaves -multiple\" for more details.");
19801980
}
19811981
return nErr;
19821982
}
19831983
--- 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);
@@ -1975,8 +1971,12 @@
1975 if( nErr && go==2 ){
1976 db_multi_exec("DROP TABLE onremote");
1977 manifest_crosslink_end(MC_PERMIT_HOOKS);
1978 content_enable_dephantomize(1);
1979 db_end_transaction(0);
 
 
 
 
1980 }
1981 return nErr;
1982 }
1983
--- 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);
@@ -1975,8 +1971,12 @@
1971 if( nErr && go==2 ){
1972 db_multi_exec("DROP TABLE onremote");
1973 manifest_crosslink_end(MC_PERMIT_HOOKS);
1974 content_enable_dephantomize(1);
1975 db_end_transaction(0);
1976 }
1977 if( (syncFlags & SYNC_CLONE)==0 && g.rcvid && fossil_any_has_fork(g.rcvid) ){
1978 fossil_warning("***** WARNING: a fork has occurred *****\n"
1979 "use \"fossil leaves -multiple\" for more details.");
1980 }
1981 return nErr;
1982 }
1983
+8 -1
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -21,12 +21,12 @@
2121
#include "config.h"
2222
#include "xfersetup.h"
2323
#include <assert.h>
2424
2525
/*
26
-** Main sub-menu for configuring the transfer system.
2726
** WEBPAGE: xfersetup
27
+** Main sub-menu for configuring the transfer system.
2828
*/
2929
void xfersetup_page(void){
3030
login_check_credentials();
3131
if( !g.perm.Setup ){
3232
login_needed(0);
@@ -157,10 +157,12 @@
157157
158158
static const char *zDefaultXferCommon = 0;
159159
160160
/*
161161
** WEBPAGE: xfersetup_com
162
+** View or edit the TH1 script that runs prior to receiving a
163
+** transfer.
162164
*/
163165
void xfersetup_com_page(void){
164166
static const char zDesc[] =
165167
@ Enter TH1 script that initializes variables prior to running
166168
@ any of the transfer request scripts.
@@ -178,10 +180,11 @@
178180
179181
static const char *zDefaultXferPush = 0;
180182
181183
/*
182184
** WEBPAGE: xfersetup_push
185
+** View or edit the TH1 script that runs after receiving a "push".
183186
*/
184187
void xfersetup_push_page(void){
185188
static const char zDesc[] =
186189
@ Enter TH1 script that runs after processing <strong>push</strong>
187190
@ transfer requests.
@@ -199,10 +202,12 @@
199202
200203
static const char *zDefaultXferCommit = 0;
201204
202205
/*
203206
** WEBPAGE: xfersetup_commit
207
+** View or edit the TH1 script that runs when a transfer commit
208
+** is processed.
204209
*/
205210
void xfersetup_commit_page(void){
206211
static const char zDesc[] =
207212
@ Enter TH1 script that runs when a commit is processed.
208213
;
@@ -219,10 +224,12 @@
219224
220225
static const char *zDefaultXferTicket = 0;
221226
222227
/*
223228
** WEBPAGE: xfersetup_ticket
229
+** View or edit the TH1 script that runs when a ticket change artifact
230
+** is processed during a transfer.
224231
*/
225232
void xfersetup_ticket_page(void){
226233
static const char zDesc[] =
227234
@ Enter TH1 script that runs when a ticket change is processed.
228235
;
229236
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -21,12 +21,12 @@
21 #include "config.h"
22 #include "xfersetup.h"
23 #include <assert.h>
24
25 /*
26 ** Main sub-menu for configuring the transfer system.
27 ** WEBPAGE: xfersetup
 
28 */
29 void xfersetup_page(void){
30 login_check_credentials();
31 if( !g.perm.Setup ){
32 login_needed(0);
@@ -157,10 +157,12 @@
157
158 static const char *zDefaultXferCommon = 0;
159
160 /*
161 ** WEBPAGE: xfersetup_com
 
 
162 */
163 void xfersetup_com_page(void){
164 static const char zDesc[] =
165 @ Enter TH1 script that initializes variables prior to running
166 @ any of the transfer request scripts.
@@ -178,10 +180,11 @@
178
179 static const char *zDefaultXferPush = 0;
180
181 /*
182 ** WEBPAGE: xfersetup_push
 
183 */
184 void xfersetup_push_page(void){
185 static const char zDesc[] =
186 @ Enter TH1 script that runs after processing <strong>push</strong>
187 @ transfer requests.
@@ -199,10 +202,12 @@
199
200 static const char *zDefaultXferCommit = 0;
201
202 /*
203 ** WEBPAGE: xfersetup_commit
 
 
204 */
205 void xfersetup_commit_page(void){
206 static const char zDesc[] =
207 @ Enter TH1 script that runs when a commit is processed.
208 ;
@@ -219,10 +224,12 @@
219
220 static const char *zDefaultXferTicket = 0;
221
222 /*
223 ** WEBPAGE: xfersetup_ticket
 
 
224 */
225 void xfersetup_ticket_page(void){
226 static const char zDesc[] =
227 @ Enter TH1 script that runs when a ticket change is processed.
228 ;
229
--- src/xfersetup.c
+++ src/xfersetup.c
@@ -21,12 +21,12 @@
21 #include "config.h"
22 #include "xfersetup.h"
23 #include <assert.h>
24
25 /*
 
26 ** WEBPAGE: xfersetup
27 ** Main sub-menu for configuring the transfer system.
28 */
29 void xfersetup_page(void){
30 login_check_credentials();
31 if( !g.perm.Setup ){
32 login_needed(0);
@@ -157,10 +157,12 @@
157
158 static const char *zDefaultXferCommon = 0;
159
160 /*
161 ** WEBPAGE: xfersetup_com
162 ** View or edit the TH1 script that runs prior to receiving a
163 ** transfer.
164 */
165 void xfersetup_com_page(void){
166 static const char zDesc[] =
167 @ Enter TH1 script that initializes variables prior to running
168 @ any of the transfer request scripts.
@@ -178,10 +180,11 @@
180
181 static const char *zDefaultXferPush = 0;
182
183 /*
184 ** WEBPAGE: xfersetup_push
185 ** View or edit the TH1 script that runs after receiving a "push".
186 */
187 void xfersetup_push_page(void){
188 static const char zDesc[] =
189 @ Enter TH1 script that runs after processing <strong>push</strong>
190 @ transfer requests.
@@ -199,10 +202,12 @@
202
203 static const char *zDefaultXferCommit = 0;
204
205 /*
206 ** WEBPAGE: xfersetup_commit
207 ** View or edit the TH1 script that runs when a transfer commit
208 ** is processed.
209 */
210 void xfersetup_commit_page(void){
211 static const char zDesc[] =
212 @ Enter TH1 script that runs when a commit is processed.
213 ;
@@ -219,10 +224,12 @@
224
225 static const char *zDefaultXferTicket = 0;
226
227 /*
228 ** WEBPAGE: xfersetup_ticket
229 ** View or edit the TH1 script that runs when a ticket change artifact
230 ** is processed during a transfer.
231 */
232 void xfersetup_ticket_page(void){
233 static const char zDesc[] =
234 @ Enter TH1 script that runs when a ticket change is processed.
235 ;
236
+1 -1
--- src/zip.c
+++ src/zip.c
@@ -399,11 +399,11 @@
399399
int rid;
400400
Blob zip;
401401
const char *zName;
402402
zName = find_option("name", 0, 1);
403403
db_find_and_open_repository(0, 0);
404
-
404
+
405405
/* We should be done with options.. */
406406
verify_all_options();
407407
408408
if( g.argc!=4 ){
409409
usage("VERSION OUTPUTFILE");
410410
411411
ADDED test/contains-selector.test
--- src/zip.c
+++ src/zip.c
@@ -399,11 +399,11 @@
399 int rid;
400 Blob zip;
401 const char *zName;
402 zName = find_option("name", 0, 1);
403 db_find_and_open_repository(0, 0);
404
405 /* We should be done with options.. */
406 verify_all_options();
407
408 if( g.argc!=4 ){
409 usage("VERSION OUTPUTFILE");
410
411 DDED test/contains-selector.test
--- src/zip.c
+++ src/zip.c
@@ -399,11 +399,11 @@
399 int rid;
400 Blob zip;
401 const char *zName;
402 zName = find_option("name", 0, 1);
403 db_find_and_open_repository(0, 0);
404
405 /* We should be done with options.. */
406 verify_all_options();
407
408 if( g.argc!=4 ){
409 usage("VERSION OUTPUTFILE");
410
411 DDED test/contains-selector.test
--- a/test/contains-selector.test
+++ b/test/contains-selector.test
@@ -0,0 +1,43 @@
1
+#
2
+# Copyright (c) 2015 D. Richard Hipp
3
+#
4
+# This program is free software; you can redistribute it and/or
5
+# modify it under the terms of the Simplified BSD License (also
6
+# known as the "2-Clause License" or "FreeBSD License".)
7
+#
8
+# This program is distributed in the hope that it will be useful,
9
+# but without any warranty; without even the implied warranty of
10
+# merchantability or fitness for a particular purpose.
11
+#
12
+# Author contact information:
13
+# [email protected]
14
+# http://www.hwaci.com/drh/
15
+#
16
+############################################################################
17
+#
18
+# Test containsSelector() proc contains-selector {testId css selectorResultMap} {
19
+ set css [string trim $css]
20
+ set filename [file join $::tempPath compare-selector.css]
21
+ set fh [open $filename w]
22
+ puts -nonewline $fh $css
23
+ close $fh
24
+ foreach {selector found} $selectorResultMap {
25
+ set expected "$selector [expr {$found ? "found" : "not found"}]"
26
+ set result [fossil test-contains-selector $filename $selector]
27
+ test "contains-selector $testId $selector" {$result eq $expected}
28
+ }
29
+ file delete $filename
30
+}
31
+
32
+contains-selector 1 {
33
+ .a.b {}
34
+ .c .de {}
35
+ /* comment */
36
+ .c .d, .e /* comment */ {}
37
+} {
38
+ .a 0
39
+ .b 0
40
+ .a.b 1
41
+ .c 0
42
+ .d 0
43
+ {.c
--- a/test/contains-selector.test
+++ b/test/contains-selector.test
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/test/contains-selector.test
+++ b/test/contains-selector.test
@@ -0,0 +1,43 @@
1 #
2 # Copyright (c) 2015 D. Richard Hipp
3 #
4 # This program is free software; you can redistribute it and/or
5 # modify it under the terms of the Simplified BSD License (also
6 # known as the "2-Clause License" or "FreeBSD License".)
7 #
8 # This program is distributed in the hope that it will be useful,
9 # but without any warranty; without even the implied warranty of
10 # merchantability or fitness for a particular purpose.
11 #
12 # Author contact information:
13 # [email protected]
14 # http://www.hwaci.com/drh/
15 #
16 ############################################################################
17 #
18 # Test containsSelector() proc contains-selector {testId css selectorResultMap} {
19 set css [string trim $css]
20 set filename [file join $::tempPath compare-selector.css]
21 set fh [open $filename w]
22 puts -nonewline $fh $css
23 close $fh
24 foreach {selector found} $selectorResultMap {
25 set expected "$selector [expr {$found ? "found" : "not found"}]"
26 set result [fossil test-contains-selector $filename $selector]
27 test "contains-selector $testId $selector" {$result eq $expected}
28 }
29 file delete $filename
30 }
31
32 contains-selector 1 {
33 .a.b {}
34 .c .de {}
35 /* comment */
36 .c .d, .e /* comment */ {}
37 } {
38 .a 0
39 .b 0
40 .a.b 1
41 .c 0
42 .d 0
43 {.c
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -3,11 +3,11 @@
33
This file describes the testing procedures for Fossil prior to an
44
official release.
55
66
<ol>
77
<li><p>
8
-From a private directory (not the source tree) run
8
+From a private directory (not the source tree) run
99
"<b>tclsh $SRC/test/tester.tcl $FOSSIL</b>" where $FOSSIL is the
1010
name of the executable under test and $SRC is the source tree.
1111
Verify that there are no errors.
1212
1313
<li><p>
1414
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -3,11 +3,11 @@
3 This file describes the testing procedures for Fossil prior to an
4 official release.
5
6 <ol>
7 <li><p>
8 From a private directory (not the source tree) run
9 "<b>tclsh $SRC/test/tester.tcl $FOSSIL</b>" where $FOSSIL is the
10 name of the executable under test and $SRC is the source tree.
11 Verify that there are no errors.
12
13 <li><p>
14
--- test/release-checklist.wiki
+++ test/release-checklist.wiki
@@ -3,11 +3,11 @@
3 This file describes the testing procedures for Fossil prior to an
4 official release.
5
6 <ol>
7 <li><p>
8 From a private directory (not the source tree) run
9 "<b>tclsh $SRC/test/tester.tcl $FOSSIL</b>" where $FOSSIL is the
10 name of the executable under test and $SRC is the source tree.
11 Verify that there are no errors.
12
13 <li><p>
14
+82 -2
--- test/th1.test
+++ test/th1.test
@@ -42,16 +42,16 @@
4242
test th1-setting-4 {$RESULT eq {TH_ERROR: no value for setting "abc"}}
4343
4444
###############################################################################
4545
4646
fossil test-th-eval --open-config "setting autosync"
47
-test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1}
47
+test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"}
4848
4949
###############################################################################
5050
5151
fossil test-th-eval --open-config "setting -strict autosync"
52
-test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1}
52
+test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"}
5353
5454
###############################################################################
5555
5656
fossil test-th-eval --open-config "setting --"
5757
test th1-setting-7 {$RESULT eq \
@@ -510,10 +510,50 @@
510510
fossil test-th-eval "expr (((1)*2)*2)"
511511
test th1-expr-41 {$RESULT eq {4}}
512512
513513
###############################################################################
514514
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
+
515555
fossil test-th-eval "checkout 1"; # NOTE: Assumes running "in tree".
516556
test th1-checkout-1 {[string length $RESULT] > 0}
517557
518558
###############################################################################
519559
@@ -808,5 +848,45 @@
808848
809849
###############################################################################
810850
811851
fossil test-th-eval "reinitialize 1; globalState configuration"
812852
test th1-reinitialize-2 {$RESULT ne ""}
853
+
854
+###############################################################################
855
+
856
+#
857
+# NOTE: This test may fail if the command names do not always come
858
+# out in a deterministic order from TH1.
859
+#
860
+fossil test-th-eval "info commands"
861
+test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
862
+enable_output uplevel http expr utime styleFooter catch if tclReady\
863
+searchable reinitialize combobox lindex query html anoncap randhex\
864
+llength for set break regexp styleHeader puts return checkout decorate\
865
+artifact trace wiki proc hascap globalState continue getParameter\
866
+hasfeature setting breakpoint upvar render repository string unset\
867
+setParameter list error info rename anycap httpize}}
868
+
869
+###############################################################################
870
+
871
+fossil test-th-eval "info vars"
872
+test th1-info-vars-1 {$RESULT eq ""}
873
+
874
+###############################################################################
875
+
876
+fossil test-th-eval "set x 1; info vars"
877
+test th1-info-vars-2 {$RESULT eq "x"}
878
+
879
+###############################################################################
880
+
881
+fossil test-th-eval "set x 1; unset x; info vars"
882
+test th1-info-vars-3 {$RESULT eq ""}
883
+
884
+###############################################################################
885
+
886
+fossil test-th-eval "proc foo {} {set x 1; info vars}; foo"
887
+test th1-info-vars-4 {$RESULT eq "x"}
888
+
889
+###############################################################################
890
+
891
+fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
892
+test th1-info-vars-5 {$RESULT eq "y"}
813893
--- test/th1.test
+++ test/th1.test
@@ -42,16 +42,16 @@
42 test th1-setting-4 {$RESULT eq {TH_ERROR: no value for setting "abc"}}
43
44 ###############################################################################
45
46 fossil test-th-eval --open-config "setting autosync"
47 test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1}
48
49 ###############################################################################
50
51 fossil test-th-eval --open-config "setting -strict autosync"
52 test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1}
53
54 ###############################################################################
55
56 fossil test-th-eval --open-config "setting --"
57 test th1-setting-7 {$RESULT eq \
@@ -510,10 +510,50 @@
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
518 ###############################################################################
519
@@ -808,5 +848,45 @@
808
809 ###############################################################################
810
811 fossil test-th-eval "reinitialize 1; globalState configuration"
812 test th1-reinitialize-2 {$RESULT ne ""}
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
--- test/th1.test
+++ test/th1.test
@@ -42,16 +42,16 @@
42 test th1-setting-4 {$RESULT eq {TH_ERROR: no value for setting "abc"}}
43
44 ###############################################################################
45
46 fossil test-th-eval --open-config "setting autosync"
47 test th1-setting-5 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"}
48
49 ###############################################################################
50
51 fossil test-th-eval --open-config "setting -strict autosync"
52 test th1-setting-6 {$RESULT eq 0 || $RESULT eq 1 || $RESULT eq "on"}
53
54 ###############################################################################
55
56 fossil test-th-eval --open-config "setting --"
57 test th1-setting-7 {$RESULT eq \
@@ -510,10 +510,50 @@
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
558 ###############################################################################
559
@@ -808,5 +848,45 @@
848
849 ###############################################################################
850
851 fossil test-th-eval "reinitialize 1; globalState configuration"
852 test th1-reinitialize-2 {$RESULT ne ""}
853
854 ###############################################################################
855
856 #
857 # NOTE: This test may fail if the command names do not always come
858 # out in a deterministic order from TH1.
859 #
860 fossil test-th-eval "info commands"
861 test th1-info-commands-1 {$RESULT eq {linecount htmlize date stime\
862 enable_output uplevel http expr utime styleFooter catch if tclReady\
863 searchable reinitialize combobox lindex query html anoncap randhex\
864 llength for set break regexp styleHeader puts return checkout decorate\
865 artifact trace wiki proc hascap globalState continue getParameter\
866 hasfeature setting breakpoint upvar render repository string unset\
867 setParameter list error info rename anycap httpize}}
868
869 ###############################################################################
870
871 fossil test-th-eval "info vars"
872 test th1-info-vars-1 {$RESULT eq ""}
873
874 ###############################################################################
875
876 fossil test-th-eval "set x 1; info vars"
877 test th1-info-vars-2 {$RESULT eq "x"}
878
879 ###############################################################################
880
881 fossil test-th-eval "set x 1; unset x; info vars"
882 test th1-info-vars-3 {$RESULT eq ""}
883
884 ###############################################################################
885
886 fossil test-th-eval "proc foo {} {set x 1; info vars}; foo"
887 test th1-info-vars-4 {$RESULT eq "x"}
888
889 ###############################################################################
890
891 fossil test-th-eval "set y 1; proc foo {} {set x 1; uplevel 1 {info vars}}; foo"
892 test th1-info-vars-5 {$RESULT eq "y"}
893
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
8383
8484
# define the SQLite files, which need special flags on compile
8585
SQLITESRC=sqlite3.c
8686
ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
8787
SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88
-SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_WIN32_NO_ANSI
88
+SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_WIN32_NO_ANSI
8989
9090
# define the SQLite shell files, which need special flags on compile
9191
SQLITESHELLSRC=shell.c
9292
ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
9393
SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
9494
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
83
84 # define the SQLite files, which need special flags on compile
85 SQLITESRC=sqlite3.c
86 ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
87 SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88 SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_WIN32_NO_ANSI
89
90 # define the SQLite shell files, which need special flags on compile
91 SQLITESHELLSRC=shell.c
92 ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
93 SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
94
--- win/Makefile.PellesCGMake
+++ win/Makefile.PellesCGMake
@@ -83,11 +83,11 @@
83
84 # define the SQLite files, which need special flags on compile
85 SQLITESRC=sqlite3.c
86 ORIGSQLITESRC=$(foreach sf,$(SQLITESRC),$(SRCDIR)$(sf))
87 SQLITEOBJ=$(foreach sf,$(SQLITESRC),$(sf:.c=.obj))
88 SQLITEDEFINES=-DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB -DSQLITE_WIN32_NO_ANSI
89
90 # define the SQLite shell files, which need special flags on compile
91 SQLITESHELLSRC=shell.c
92 ORIGSQLITESHELLSRC=$(foreach sf,$(SQLITESHELLSRC),$(SRCDIR)$(sf))
93 SQLITESHELLOBJ=$(foreach sf,$(SQLITESHELLSRC),$(sf:.c=.obj))
94
+11 -5
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,17 +24,17 @@
2424
CFLAGS = -o
2525
BCC = $(DMDIR)\bin\dmc $(CFLAGS)
2626
TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
2727
LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
2828
29
-SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS
29
+SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB
3030
3131
SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
3232
33
-SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
33
+SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
3434
35
-OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
35
+OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
3636
3737
3838
RC=$(DMDIR)\bin\rcc
3939
RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
4040
@@ -49,11 +49,11 @@
4949
5050
$(OBJDIR)\fossil.res: $B\win\fossil.rc
5151
$(RC) $(RCFLAGS) -o$@ $**
5252
5353
$(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54
- +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf publish purge rebuild regexp report rss schema search setup sha1 shun sitemap skins sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
54
+ +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp report rss schema search setup sha1 shun sitemap skins sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
5555
+echo fossil >> $@
5656
+echo fossil >> $@
5757
+echo $(LIBS) >> $@
5858
+echo. >> $@
5959
+echo fossil >> $@
@@ -554,10 +554,16 @@
554554
$(OBJDIR)\path$O : path_.c path.h
555555
$(TCC) -o$@ -c path_.c
556556
557557
path_.c : $(SRCDIR)\path.c
558558
+translate$E $** > $@
559
+
560
+$(OBJDIR)\piechart$O : piechart_.c piechart.h
561
+ $(TCC) -o$@ -c piechart_.c
562
+
563
+piechart_.c : $(SRCDIR)\piechart.c
564
+ +translate$E $** > $@
559565
560566
$(OBJDIR)\pivot$O : pivot_.c pivot.h
561567
$(TCC) -o$@ -c pivot_.c
562568
563569
pivot_.c : $(SRCDIR)\pivot.c
@@ -832,7 +838,7 @@
832838
833839
zip_.c : $(SRCDIR)\zip.c
834840
+translate$E $** > $@
835841
836842
headers: makeheaders$E page_index.h builtin_data.h VERSION.h
837
- +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
843
+ +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
838844
@copy /Y nul: headers
839845
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,17 +24,17 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS
30
31 SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35 OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
36
37
38 RC=$(DMDIR)\bin\rcc
39 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
40
@@ -49,11 +49,11 @@
49
50 $(OBJDIR)\fossil.res: $B\win\fossil.rc
51 $(RC) $(RCFLAGS) -o$@ $**
52
53 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54 +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path pivot popen pqueue printf publish purge rebuild regexp report rss schema search setup sha1 shun sitemap skins sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
55 +echo fossil >> $@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
@@ -554,10 +554,16 @@
554 $(OBJDIR)\path$O : path_.c path.h
555 $(TCC) -o$@ -c path_.c
556
557 path_.c : $(SRCDIR)\path.c
558 +translate$E $** > $@
 
 
 
 
 
 
559
560 $(OBJDIR)\pivot$O : pivot_.c pivot.h
561 $(TCC) -o$@ -c pivot_.c
562
563 pivot_.c : $(SRCDIR)\pivot.c
@@ -832,7 +838,7 @@
832
833 zip_.c : $(SRCDIR)\zip.c
834 +translate$E $** > $@
835
836 headers: makeheaders$E page_index.h builtin_data.h VERSION.h
837 +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
838 @copy /Y nul: headers
839
--- win/Makefile.dmc
+++ win/Makefile.dmc
@@ -24,17 +24,17 @@
24 CFLAGS = -o
25 BCC = $(DMDIR)\bin\dmc $(CFLAGS)
26 TCC = $(DMDIR)\bin\dmc $(CFLAGS) $(DMCDEF) $(SSL) $(INCL)
27 LIBS = $(DMDIR)\extra\lib\ zlib wsock32 advapi32
28
29 SQLITE_OPTIONS = -DNDEBUG=1 -DSQLITE_OMIT_LOAD_EXTENSION=1 -DSQLITE_ENABLE_LOCKING_STYLE=0 -DSQLITE_THREADSAFE=0 -DSQLITE_DEFAULT_FILE_FORMAT=4 -DSQLITE_OMIT_DEPRECATED -DSQLITE_ENABLE_EXPLAIN_COMMENTS -DSQLITE_ENABLE_FTS4 -DSQLITE_ENABLE_FTS3_PARENTHESIS -DSQLITE_ENABLE_DBSTAT_VTAB
30
31 SHELL_OPTIONS = -Dmain=sqlite3_shell -DSQLITE_OMIT_LOAD_EXTENSION=1 -DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) -DSQLITE_SHELL_DBNAME_PROC=fossil_open -Daccess=file_access -Dsystem=fossil_system -Dgetenv=fossil_getenv -Dfopen=fossil_fopen
32
33 SRC = add_.c allrepo_.c attach_.c bag_.c bisect_.c blob_.c branch_.c browse_.c builtin_.c bundle_.c cache_.c captcha_.c cgi_.c checkin_.c checkout_.c clearsign_.c clone_.c comformat_.c configure_.c content_.c db_.c delta_.c deltacmd_.c descendants_.c diff_.c diffcmd_.c doc_.c encode_.c event_.c export_.c file_.c finfo_.c foci_.c fusefs_.c glob_.c graph_.c gzip_.c http_.c http_socket_.c http_ssl_.c http_transport_.c import_.c info_.c json_.c json_artifact_.c json_branch_.c json_config_.c json_diff_.c json_dir_.c json_finfo_.c json_login_.c json_query_.c json_report_.c json_status_.c json_tag_.c json_timeline_.c json_user_.c json_wiki_.c leaf_.c loadctrl_.c login_.c lookslike_.c main_.c manifest_.c markdown_.c markdown_html_.c md5_.c merge_.c merge3_.c moderate_.c name_.c path_.c piechart_.c pivot_.c popen_.c pqueue_.c printf_.c publish_.c purge_.c rebuild_.c regexp_.c report_.c rss_.c schema_.c search_.c setup_.c sha1_.c shun_.c sitemap_.c skins_.c sqlcmd_.c stash_.c stat_.c statrep_.c style_.c sync_.c tag_.c tar_.c th_main_.c timeline_.c tkt_.c tktsetup_.c undo_.c unicode_.c update_.c url_.c user_.c utf8_.c util_.c verify_.c vfile_.c wiki_.c wikiformat_.c winfile_.c winhttp_.c wysiwyg_.c xfer_.c xfersetup_.c zip_.c
34
35 OBJ = $(OBJDIR)\add$O $(OBJDIR)\allrepo$O $(OBJDIR)\attach$O $(OBJDIR)\bag$O $(OBJDIR)\bisect$O $(OBJDIR)\blob$O $(OBJDIR)\branch$O $(OBJDIR)\browse$O $(OBJDIR)\builtin$O $(OBJDIR)\bundle$O $(OBJDIR)\cache$O $(OBJDIR)\captcha$O $(OBJDIR)\cgi$O $(OBJDIR)\checkin$O $(OBJDIR)\checkout$O $(OBJDIR)\clearsign$O $(OBJDIR)\clone$O $(OBJDIR)\comformat$O $(OBJDIR)\configure$O $(OBJDIR)\content$O $(OBJDIR)\db$O $(OBJDIR)\delta$O $(OBJDIR)\deltacmd$O $(OBJDIR)\descendants$O $(OBJDIR)\diff$O $(OBJDIR)\diffcmd$O $(OBJDIR)\doc$O $(OBJDIR)\encode$O $(OBJDIR)\event$O $(OBJDIR)\export$O $(OBJDIR)\file$O $(OBJDIR)\finfo$O $(OBJDIR)\foci$O $(OBJDIR)\fusefs$O $(OBJDIR)\glob$O $(OBJDIR)\graph$O $(OBJDIR)\gzip$O $(OBJDIR)\http$O $(OBJDIR)\http_socket$O $(OBJDIR)\http_ssl$O $(OBJDIR)\http_transport$O $(OBJDIR)\import$O $(OBJDIR)\info$O $(OBJDIR)\json$O $(OBJDIR)\json_artifact$O $(OBJDIR)\json_branch$O $(OBJDIR)\json_config$O $(OBJDIR)\json_diff$O $(OBJDIR)\json_dir$O $(OBJDIR)\json_finfo$O $(OBJDIR)\json_login$O $(OBJDIR)\json_query$O $(OBJDIR)\json_report$O $(OBJDIR)\json_status$O $(OBJDIR)\json_tag$O $(OBJDIR)\json_timeline$O $(OBJDIR)\json_user$O $(OBJDIR)\json_wiki$O $(OBJDIR)\leaf$O $(OBJDIR)\loadctrl$O $(OBJDIR)\login$O $(OBJDIR)\lookslike$O $(OBJDIR)\main$O $(OBJDIR)\manifest$O $(OBJDIR)\markdown$O $(OBJDIR)\markdown_html$O $(OBJDIR)\md5$O $(OBJDIR)\merge$O $(OBJDIR)\merge3$O $(OBJDIR)\moderate$O $(OBJDIR)\name$O $(OBJDIR)\path$O $(OBJDIR)\piechart$O $(OBJDIR)\pivot$O $(OBJDIR)\popen$O $(OBJDIR)\pqueue$O $(OBJDIR)\printf$O $(OBJDIR)\publish$O $(OBJDIR)\purge$O $(OBJDIR)\rebuild$O $(OBJDIR)\regexp$O $(OBJDIR)\report$O $(OBJDIR)\rss$O $(OBJDIR)\schema$O $(OBJDIR)\search$O $(OBJDIR)\setup$O $(OBJDIR)\sha1$O $(OBJDIR)\shun$O $(OBJDIR)\sitemap$O $(OBJDIR)\skins$O $(OBJDIR)\sqlcmd$O $(OBJDIR)\stash$O $(OBJDIR)\stat$O $(OBJDIR)\statrep$O $(OBJDIR)\style$O $(OBJDIR)\sync$O $(OBJDIR)\tag$O $(OBJDIR)\tar$O $(OBJDIR)\th_main$O $(OBJDIR)\timeline$O $(OBJDIR)\tkt$O $(OBJDIR)\tktsetup$O $(OBJDIR)\undo$O $(OBJDIR)\unicode$O $(OBJDIR)\update$O $(OBJDIR)\url$O $(OBJDIR)\user$O $(OBJDIR)\utf8$O $(OBJDIR)\util$O $(OBJDIR)\verify$O $(OBJDIR)\vfile$O $(OBJDIR)\wiki$O $(OBJDIR)\wikiformat$O $(OBJDIR)\winfile$O $(OBJDIR)\winhttp$O $(OBJDIR)\wysiwyg$O $(OBJDIR)\xfer$O $(OBJDIR)\xfersetup$O $(OBJDIR)\zip$O $(OBJDIR)\shell$O $(OBJDIR)\sqlite3$O $(OBJDIR)\th$O $(OBJDIR)\th_lang$O
36
37
38 RC=$(DMDIR)\bin\rcc
39 RCFLAGS=-32 -w1 -I$(SRCDIR) /D__DMC__
40
@@ -49,11 +49,11 @@
49
50 $(OBJDIR)\fossil.res: $B\win\fossil.rc
51 $(RC) $(RCFLAGS) -o$@ $**
52
53 $(OBJDIR)\link: $B\win\Makefile.dmc $(OBJDIR)\fossil.res
54 +echo add allrepo attach bag bisect blob branch browse builtin bundle cache captcha cgi checkin checkout clearsign clone comformat configure content db delta deltacmd descendants diff diffcmd doc encode event export file finfo foci fusefs glob graph gzip http http_socket http_ssl http_transport import info json json_artifact json_branch json_config json_diff json_dir json_finfo json_login json_query json_report json_status json_tag json_timeline json_user json_wiki leaf loadctrl login lookslike main manifest markdown markdown_html md5 merge merge3 moderate name path piechart pivot popen pqueue printf publish purge rebuild regexp report rss schema search setup sha1 shun sitemap skins sqlcmd stash stat statrep style sync tag tar th_main timeline tkt tktsetup undo unicode update url user utf8 util verify vfile wiki wikiformat winfile winhttp wysiwyg xfer xfersetup zip shell sqlite3 th th_lang > $@
55 +echo fossil >> $@
56 +echo fossil >> $@
57 +echo $(LIBS) >> $@
58 +echo. >> $@
59 +echo fossil >> $@
@@ -554,10 +554,16 @@
554 $(OBJDIR)\path$O : path_.c path.h
555 $(TCC) -o$@ -c path_.c
556
557 path_.c : $(SRCDIR)\path.c
558 +translate$E $** > $@
559
560 $(OBJDIR)\piechart$O : piechart_.c piechart.h
561 $(TCC) -o$@ -c piechart_.c
562
563 piechart_.c : $(SRCDIR)\piechart.c
564 +translate$E $** > $@
565
566 $(OBJDIR)\pivot$O : pivot_.c pivot.h
567 $(TCC) -o$@ -c pivot_.c
568
569 pivot_.c : $(SRCDIR)\pivot.c
@@ -832,7 +838,7 @@
838
839 zip_.c : $(SRCDIR)\zip.c
840 +translate$E $** > $@
841
842 headers: makeheaders$E page_index.h builtin_data.h VERSION.h
843 +makeheaders$E add_.c:add.h allrepo_.c:allrepo.h attach_.c:attach.h bag_.c:bag.h bisect_.c:bisect.h blob_.c:blob.h branch_.c:branch.h browse_.c:browse.h builtin_.c:builtin.h bundle_.c:bundle.h cache_.c:cache.h captcha_.c:captcha.h cgi_.c:cgi.h checkin_.c:checkin.h checkout_.c:checkout.h clearsign_.c:clearsign.h clone_.c:clone.h comformat_.c:comformat.h configure_.c:configure.h content_.c:content.h db_.c:db.h delta_.c:delta.h deltacmd_.c:deltacmd.h descendants_.c:descendants.h diff_.c:diff.h diffcmd_.c:diffcmd.h doc_.c:doc.h encode_.c:encode.h event_.c:event.h export_.c:export.h file_.c:file.h finfo_.c:finfo.h foci_.c:foci.h fusefs_.c:fusefs.h glob_.c:glob.h graph_.c:graph.h gzip_.c:gzip.h http_.c:http.h http_socket_.c:http_socket.h http_ssl_.c:http_ssl.h http_transport_.c:http_transport.h import_.c:import.h info_.c:info.h json_.c:json.h json_artifact_.c:json_artifact.h json_branch_.c:json_branch.h json_config_.c:json_config.h json_diff_.c:json_diff.h json_dir_.c:json_dir.h json_finfo_.c:json_finfo.h json_login_.c:json_login.h json_query_.c:json_query.h json_report_.c:json_report.h json_status_.c:json_status.h json_tag_.c:json_tag.h json_timeline_.c:json_timeline.h json_user_.c:json_user.h json_wiki_.c:json_wiki.h leaf_.c:leaf.h loadctrl_.c:loadctrl.h login_.c:login.h lookslike_.c:lookslike.h main_.c:main.h manifest_.c:manifest.h markdown_.c:markdown.h markdown_html_.c:markdown_html.h md5_.c:md5.h merge_.c:merge.h merge3_.c:merge3.h moderate_.c:moderate.h name_.c:name.h path_.c:path.h piechart_.c:piechart.h pivot_.c:pivot.h popen_.c:popen.h pqueue_.c:pqueue.h printf_.c:printf.h publish_.c:publish.h purge_.c:purge.h rebuild_.c:rebuild.h regexp_.c:regexp.h report_.c:report.h rss_.c:rss.h schema_.c:schema.h search_.c:search.h setup_.c:setup.h sha1_.c:sha1.h shun_.c:shun.h sitemap_.c:sitemap.h skins_.c:skins.h sqlcmd_.c:sqlcmd.h stash_.c:stash.h stat_.c:stat.h statrep_.c:statrep.h style_.c:style.h sync_.c:sync.h tag_.c:tag.h tar_.c:tar.h th_main_.c:th_main.h timeline_.c:timeline.h tkt_.c:tkt.h tktsetup_.c:tktsetup.h undo_.c:undo.h unicode_.c:unicode.h update_.c:update.h url_.c:url.h user_.c:user.h utf8_.c:utf8.h util_.c:util.h verify_.c:verify.h vfile_.c:vfile.h wiki_.c:wiki.h wikiformat_.c:wikiformat.h winfile_.c:winfile.h winhttp_.c:winhttp.h wysiwyg_.c:wysiwyg.h xfer_.c:xfer.h xfersetup_.c:xfersetup.h zip_.c:zip.h $(SRCDIR)\sqlite3.h $(SRCDIR)\th.h VERSION.h $(SRCDIR)\cson_amalgamation.h
844 @copy /Y nul: headers
845
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -52,10 +52,14 @@
5252
5353
#### Automatically build OpenSSL when building Fossil (causes rebuild
5454
# issues when building incrementally).
5555
#
5656
# FOSSIL_BUILD_SSL = 1
57
+
58
+#### Enable legacy treatment of mv/rm (skip checkout files)
59
+#
60
+# FOSSIL_ENABLE_LEGACY_MV_RM = 1
5761
5862
#### Enable TH1 scripts in embedded documentation files
5963
#
6064
# FOSSIL_ENABLE_TH1_DOCS = 1
6165
@@ -251,10 +255,16 @@
251255
# With HTTPS support
252256
ifdef FOSSIL_ENABLE_SSL
253257
TCC += -DFOSSIL_ENABLE_SSL=1
254258
RCC += -DFOSSIL_ENABLE_SSL=1
255259
endif
260
+
261
+# With legacy treatment of mv/rm
262
+ifdef FOSSIL_ENABLE_LEGACY_MV_RM
263
+TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
264
+RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
265
+endif
256266
257267
# With TH1 embedded docs support
258268
ifdef FOSSIL_ENABLE_TH1_DOCS
259269
TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
260270
RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
437447
$(SRCDIR)/merge.c \
438448
$(SRCDIR)/merge3.c \
439449
$(SRCDIR)/moderate.c \
440450
$(SRCDIR)/name.c \
441451
$(SRCDIR)/path.c \
452
+ $(SRCDIR)/piechart.c \
442453
$(SRCDIR)/pivot.c \
443454
$(SRCDIR)/popen.c \
444455
$(SRCDIR)/pqueue.c \
445456
$(SRCDIR)/printf.c \
446457
$(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
485496
$(SRCDIR)/xfer.c \
486497
$(SRCDIR)/xfersetup.c \
487498
$(SRCDIR)/zip.c
488499
489500
EXTRA_FILES = \
501
+ $(SRCDIR)/../skins/aht/details.txt \
490502
$(SRCDIR)/../skins/black_and_white/css.txt \
503
+ $(SRCDIR)/../skins/black_and_white/details.txt \
491504
$(SRCDIR)/../skins/black_and_white/footer.txt \
492505
$(SRCDIR)/../skins/black_and_white/header.txt \
493506
$(SRCDIR)/../skins/blitz/css.txt \
507
+ $(SRCDIR)/../skins/blitz/details.txt \
494508
$(SRCDIR)/../skins/blitz/footer.txt \
495509
$(SRCDIR)/../skins/blitz/header.txt \
496510
$(SRCDIR)/../skins/blitz/ticket.txt \
497511
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
512
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
498513
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
499514
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
500515
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
501516
$(SRCDIR)/../skins/default/css.txt \
517
+ $(SRCDIR)/../skins/default/details.txt \
502518
$(SRCDIR)/../skins/default/footer.txt \
503519
$(SRCDIR)/../skins/default/header.txt \
504520
$(SRCDIR)/../skins/eagle/css.txt \
521
+ $(SRCDIR)/../skins/eagle/details.txt \
505522
$(SRCDIR)/../skins/eagle/footer.txt \
506523
$(SRCDIR)/../skins/eagle/header.txt \
507524
$(SRCDIR)/../skins/enhanced1/css.txt \
525
+ $(SRCDIR)/../skins/enhanced1/details.txt \
508526
$(SRCDIR)/../skins/enhanced1/footer.txt \
509527
$(SRCDIR)/../skins/enhanced1/header.txt \
510528
$(SRCDIR)/../skins/khaki/css.txt \
529
+ $(SRCDIR)/../skins/khaki/details.txt \
511530
$(SRCDIR)/../skins/khaki/footer.txt \
512531
$(SRCDIR)/../skins/khaki/header.txt \
513532
$(SRCDIR)/../skins/original/css.txt \
533
+ $(SRCDIR)/../skins/original/details.txt \
514534
$(SRCDIR)/../skins/original/footer.txt \
515535
$(SRCDIR)/../skins/original/header.txt \
516536
$(SRCDIR)/../skins/plain_gray/css.txt \
537
+ $(SRCDIR)/../skins/plain_gray/details.txt \
517538
$(SRCDIR)/../skins/plain_gray/footer.txt \
518539
$(SRCDIR)/../skins/plain_gray/header.txt \
519540
$(SRCDIR)/../skins/rounded1/css.txt \
541
+ $(SRCDIR)/../skins/rounded1/details.txt \
520542
$(SRCDIR)/../skins/rounded1/footer.txt \
521543
$(SRCDIR)/../skins/rounded1/header.txt \
522544
$(SRCDIR)/../skins/xekri/css.txt \
545
+ $(SRCDIR)/../skins/xekri/details.txt \
523546
$(SRCDIR)/../skins/xekri/footer.txt \
524547
$(SRCDIR)/../skins/xekri/header.txt \
525548
$(SRCDIR)/diff.tcl \
526549
$(SRCDIR)/markdown.md
527550
@@ -596,10 +619,11 @@
596619
$(OBJDIR)/merge_.c \
597620
$(OBJDIR)/merge3_.c \
598621
$(OBJDIR)/moderate_.c \
599622
$(OBJDIR)/name_.c \
600623
$(OBJDIR)/path_.c \
624
+ $(OBJDIR)/piechart_.c \
601625
$(OBJDIR)/pivot_.c \
602626
$(OBJDIR)/popen_.c \
603627
$(OBJDIR)/pqueue_.c \
604628
$(OBJDIR)/printf_.c \
605629
$(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
716740
$(OBJDIR)/merge.o \
717741
$(OBJDIR)/merge3.o \
718742
$(OBJDIR)/moderate.o \
719743
$(OBJDIR)/name.o \
720744
$(OBJDIR)/path.o \
745
+ $(OBJDIR)/piechart.o \
721746
$(OBJDIR)/pivot.o \
722747
$(OBJDIR)/popen.o \
723748
$(OBJDIR)/pqueue.o \
724749
$(OBJDIR)/printf.o \
725750
$(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
10291054
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
10301055
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
10311056
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
10321057
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
10331058
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
1059
+ $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
10341060
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
10351061
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
10361062
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
10371063
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
10381064
$(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
16591685
16601686
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
16611687
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
16621688
16631689
$(OBJDIR)/path.h: $(OBJDIR)/headers
1690
+
1691
+$(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(TRANSLATE)
1692
+ $(TRANSLATE) $(SRCDIR)/piechart.c >$@
1693
+
1694
+$(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1695
+ $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1696
+
1697
+$(OBJDIR)/piechart.h: $(OBJDIR)/headers
16641698
16651699
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
16661700
$(TRANSLATE) $(SRCDIR)/pivot.c >$@
16671701
16681702
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
20372071
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
20382072
-DSQLITE_OMIT_DEPRECATED \
20392073
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
20402074
-DSQLITE_ENABLE_FTS4 \
20412075
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
2076
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
20422077
-DSQLITE_WIN32_NO_ANSI \
20432078
-D_HAVE__MINGW_H \
20442079
-DSQLITE_USE_MALLOC_H \
20452080
-DSQLITE_USE_MSIZE
20462081
20472082
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -52,10 +52,14 @@
52
53 #### Automatically build OpenSSL when building Fossil (causes rebuild
54 # issues when building incrementally).
55 #
56 # FOSSIL_BUILD_SSL = 1
 
 
 
 
57
58 #### Enable TH1 scripts in embedded documentation files
59 #
60 # FOSSIL_ENABLE_TH1_DOCS = 1
61
@@ -251,10 +255,16 @@
251 # With HTTPS support
252 ifdef FOSSIL_ENABLE_SSL
253 TCC += -DFOSSIL_ENABLE_SSL=1
254 RCC += -DFOSSIL_ENABLE_SSL=1
255 endif
 
 
 
 
 
 
256
257 # With TH1 embedded docs support
258 ifdef FOSSIL_ENABLE_TH1_DOCS
259 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
260 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
437 $(SRCDIR)/merge.c \
438 $(SRCDIR)/merge3.c \
439 $(SRCDIR)/moderate.c \
440 $(SRCDIR)/name.c \
441 $(SRCDIR)/path.c \
 
442 $(SRCDIR)/pivot.c \
443 $(SRCDIR)/popen.c \
444 $(SRCDIR)/pqueue.c \
445 $(SRCDIR)/printf.c \
446 $(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
485 $(SRCDIR)/xfer.c \
486 $(SRCDIR)/xfersetup.c \
487 $(SRCDIR)/zip.c
488
489 EXTRA_FILES = \
 
490 $(SRCDIR)/../skins/black_and_white/css.txt \
 
491 $(SRCDIR)/../skins/black_and_white/footer.txt \
492 $(SRCDIR)/../skins/black_and_white/header.txt \
493 $(SRCDIR)/../skins/blitz/css.txt \
 
494 $(SRCDIR)/../skins/blitz/footer.txt \
495 $(SRCDIR)/../skins/blitz/header.txt \
496 $(SRCDIR)/../skins/blitz/ticket.txt \
497 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
498 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
499 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
500 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
501 $(SRCDIR)/../skins/default/css.txt \
 
502 $(SRCDIR)/../skins/default/footer.txt \
503 $(SRCDIR)/../skins/default/header.txt \
504 $(SRCDIR)/../skins/eagle/css.txt \
 
505 $(SRCDIR)/../skins/eagle/footer.txt \
506 $(SRCDIR)/../skins/eagle/header.txt \
507 $(SRCDIR)/../skins/enhanced1/css.txt \
 
508 $(SRCDIR)/../skins/enhanced1/footer.txt \
509 $(SRCDIR)/../skins/enhanced1/header.txt \
510 $(SRCDIR)/../skins/khaki/css.txt \
 
511 $(SRCDIR)/../skins/khaki/footer.txt \
512 $(SRCDIR)/../skins/khaki/header.txt \
513 $(SRCDIR)/../skins/original/css.txt \
 
514 $(SRCDIR)/../skins/original/footer.txt \
515 $(SRCDIR)/../skins/original/header.txt \
516 $(SRCDIR)/../skins/plain_gray/css.txt \
 
517 $(SRCDIR)/../skins/plain_gray/footer.txt \
518 $(SRCDIR)/../skins/plain_gray/header.txt \
519 $(SRCDIR)/../skins/rounded1/css.txt \
 
520 $(SRCDIR)/../skins/rounded1/footer.txt \
521 $(SRCDIR)/../skins/rounded1/header.txt \
522 $(SRCDIR)/../skins/xekri/css.txt \
 
523 $(SRCDIR)/../skins/xekri/footer.txt \
524 $(SRCDIR)/../skins/xekri/header.txt \
525 $(SRCDIR)/diff.tcl \
526 $(SRCDIR)/markdown.md
527
@@ -596,10 +619,11 @@
596 $(OBJDIR)/merge_.c \
597 $(OBJDIR)/merge3_.c \
598 $(OBJDIR)/moderate_.c \
599 $(OBJDIR)/name_.c \
600 $(OBJDIR)/path_.c \
 
601 $(OBJDIR)/pivot_.c \
602 $(OBJDIR)/popen_.c \
603 $(OBJDIR)/pqueue_.c \
604 $(OBJDIR)/printf_.c \
605 $(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
716 $(OBJDIR)/merge.o \
717 $(OBJDIR)/merge3.o \
718 $(OBJDIR)/moderate.o \
719 $(OBJDIR)/name.o \
720 $(OBJDIR)/path.o \
 
721 $(OBJDIR)/pivot.o \
722 $(OBJDIR)/popen.o \
723 $(OBJDIR)/pqueue.o \
724 $(OBJDIR)/printf.o \
725 $(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
1029 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1030 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1031 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1032 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
1033 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
 
1034 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
1035 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
1036 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
1037 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1038 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
1659
1660 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1661 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1662
1663 $(OBJDIR)/path.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
1664
1665 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
1666 $(TRANSLATE) $(SRCDIR)/pivot.c >$@
1667
1668 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
2037 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2038 -DSQLITE_OMIT_DEPRECATED \
2039 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2040 -DSQLITE_ENABLE_FTS4 \
2041 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
 
2042 -DSQLITE_WIN32_NO_ANSI \
2043 -D_HAVE__MINGW_H \
2044 -DSQLITE_USE_MALLOC_H \
2045 -DSQLITE_USE_MSIZE
2046
2047
--- win/Makefile.mingw
+++ win/Makefile.mingw
@@ -52,10 +52,14 @@
52
53 #### Automatically build OpenSSL when building Fossil (causes rebuild
54 # issues when building incrementally).
55 #
56 # FOSSIL_BUILD_SSL = 1
57
58 #### Enable legacy treatment of mv/rm (skip checkout files)
59 #
60 # FOSSIL_ENABLE_LEGACY_MV_RM = 1
61
62 #### Enable TH1 scripts in embedded documentation files
63 #
64 # FOSSIL_ENABLE_TH1_DOCS = 1
65
@@ -251,10 +255,16 @@
255 # With HTTPS support
256 ifdef FOSSIL_ENABLE_SSL
257 TCC += -DFOSSIL_ENABLE_SSL=1
258 RCC += -DFOSSIL_ENABLE_SSL=1
259 endif
260
261 # With legacy treatment of mv/rm
262 ifdef FOSSIL_ENABLE_LEGACY_MV_RM
263 TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
264 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
265 endif
266
267 # With TH1 embedded docs support
268 ifdef FOSSIL_ENABLE_TH1_DOCS
269 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
270 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
447 $(SRCDIR)/merge.c \
448 $(SRCDIR)/merge3.c \
449 $(SRCDIR)/moderate.c \
450 $(SRCDIR)/name.c \
451 $(SRCDIR)/path.c \
452 $(SRCDIR)/piechart.c \
453 $(SRCDIR)/pivot.c \
454 $(SRCDIR)/popen.c \
455 $(SRCDIR)/pqueue.c \
456 $(SRCDIR)/printf.c \
457 $(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
496 $(SRCDIR)/xfer.c \
497 $(SRCDIR)/xfersetup.c \
498 $(SRCDIR)/zip.c
499
500 EXTRA_FILES = \
501 $(SRCDIR)/../skins/aht/details.txt \
502 $(SRCDIR)/../skins/black_and_white/css.txt \
503 $(SRCDIR)/../skins/black_and_white/details.txt \
504 $(SRCDIR)/../skins/black_and_white/footer.txt \
505 $(SRCDIR)/../skins/black_and_white/header.txt \
506 $(SRCDIR)/../skins/blitz/css.txt \
507 $(SRCDIR)/../skins/blitz/details.txt \
508 $(SRCDIR)/../skins/blitz/footer.txt \
509 $(SRCDIR)/../skins/blitz/header.txt \
510 $(SRCDIR)/../skins/blitz/ticket.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
515 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
516 $(SRCDIR)/../skins/default/css.txt \
517 $(SRCDIR)/../skins/default/details.txt \
518 $(SRCDIR)/../skins/default/footer.txt \
519 $(SRCDIR)/../skins/default/header.txt \
520 $(SRCDIR)/../skins/eagle/css.txt \
521 $(SRCDIR)/../skins/eagle/details.txt \
522 $(SRCDIR)/../skins/eagle/footer.txt \
523 $(SRCDIR)/../skins/eagle/header.txt \
524 $(SRCDIR)/../skins/enhanced1/css.txt \
525 $(SRCDIR)/../skins/enhanced1/details.txt \
526 $(SRCDIR)/../skins/enhanced1/footer.txt \
527 $(SRCDIR)/../skins/enhanced1/header.txt \
528 $(SRCDIR)/../skins/khaki/css.txt \
529 $(SRCDIR)/../skins/khaki/details.txt \
530 $(SRCDIR)/../skins/khaki/footer.txt \
531 $(SRCDIR)/../skins/khaki/header.txt \
532 $(SRCDIR)/../skins/original/css.txt \
533 $(SRCDIR)/../skins/original/details.txt \
534 $(SRCDIR)/../skins/original/footer.txt \
535 $(SRCDIR)/../skins/original/header.txt \
536 $(SRCDIR)/../skins/plain_gray/css.txt \
537 $(SRCDIR)/../skins/plain_gray/details.txt \
538 $(SRCDIR)/../skins/plain_gray/footer.txt \
539 $(SRCDIR)/../skins/plain_gray/header.txt \
540 $(SRCDIR)/../skins/rounded1/css.txt \
541 $(SRCDIR)/../skins/rounded1/details.txt \
542 $(SRCDIR)/../skins/rounded1/footer.txt \
543 $(SRCDIR)/../skins/rounded1/header.txt \
544 $(SRCDIR)/../skins/xekri/css.txt \
545 $(SRCDIR)/../skins/xekri/details.txt \
546 $(SRCDIR)/../skins/xekri/footer.txt \
547 $(SRCDIR)/../skins/xekri/header.txt \
548 $(SRCDIR)/diff.tcl \
549 $(SRCDIR)/markdown.md
550
@@ -596,10 +619,11 @@
619 $(OBJDIR)/merge_.c \
620 $(OBJDIR)/merge3_.c \
621 $(OBJDIR)/moderate_.c \
622 $(OBJDIR)/name_.c \
623 $(OBJDIR)/path_.c \
624 $(OBJDIR)/piechart_.c \
625 $(OBJDIR)/pivot_.c \
626 $(OBJDIR)/popen_.c \
627 $(OBJDIR)/pqueue_.c \
628 $(OBJDIR)/printf_.c \
629 $(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
740 $(OBJDIR)/merge.o \
741 $(OBJDIR)/merge3.o \
742 $(OBJDIR)/moderate.o \
743 $(OBJDIR)/name.o \
744 $(OBJDIR)/path.o \
745 $(OBJDIR)/piechart.o \
746 $(OBJDIR)/pivot.o \
747 $(OBJDIR)/popen.o \
748 $(OBJDIR)/pqueue.o \
749 $(OBJDIR)/printf.o \
750 $(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
1054 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1055 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1056 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1057 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
1058 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
1059 $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
1060 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
1061 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
1062 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
1063 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1064 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
1685
1686 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1687 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1688
1689 $(OBJDIR)/path.h: $(OBJDIR)/headers
1690
1691 $(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(TRANSLATE)
1692 $(TRANSLATE) $(SRCDIR)/piechart.c >$@
1693
1694 $(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1695 $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1696
1697 $(OBJDIR)/piechart.h: $(OBJDIR)/headers
1698
1699 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
1700 $(TRANSLATE) $(SRCDIR)/pivot.c >$@
1701
1702 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
2071 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2072 -DSQLITE_OMIT_DEPRECATED \
2073 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2074 -DSQLITE_ENABLE_FTS4 \
2075 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2076 -DSQLITE_ENABLE_DBSTAT_VTAB \
2077 -DSQLITE_WIN32_NO_ANSI \
2078 -D_HAVE__MINGW_H \
2079 -DSQLITE_USE_MALLOC_H \
2080 -DSQLITE_USE_MSIZE
2081
2082
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -52,10 +52,14 @@
5252
5353
#### Automatically build OpenSSL when building Fossil (causes rebuild
5454
# issues when building incrementally).
5555
#
5656
# FOSSIL_BUILD_SSL = 1
57
+
58
+#### Enable legacy treatment of mv/rm (skip checkout files)
59
+#
60
+FOSSIL_ENABLE_LEGACY_MV_RM = 1
5761
5862
#### Enable TH1 scripts in embedded documentation files
5963
#
6064
FOSSIL_ENABLE_TH1_DOCS = 1
6165
@@ -251,10 +255,16 @@
251255
# With HTTPS support
252256
ifdef FOSSIL_ENABLE_SSL
253257
TCC += -DFOSSIL_ENABLE_SSL=1
254258
RCC += -DFOSSIL_ENABLE_SSL=1
255259
endif
260
+
261
+# With legacy treatment of mv/rm
262
+ifdef FOSSIL_ENABLE_LEGACY_MV_RM
263
+TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
264
+RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
265
+endif
256266
257267
# With TH1 embedded docs support
258268
ifdef FOSSIL_ENABLE_TH1_DOCS
259269
TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
260270
RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
437447
$(SRCDIR)/merge.c \
438448
$(SRCDIR)/merge3.c \
439449
$(SRCDIR)/moderate.c \
440450
$(SRCDIR)/name.c \
441451
$(SRCDIR)/path.c \
452
+ $(SRCDIR)/piechart.c \
442453
$(SRCDIR)/pivot.c \
443454
$(SRCDIR)/popen.c \
444455
$(SRCDIR)/pqueue.c \
445456
$(SRCDIR)/printf.c \
446457
$(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
485496
$(SRCDIR)/xfer.c \
486497
$(SRCDIR)/xfersetup.c \
487498
$(SRCDIR)/zip.c
488499
489500
EXTRA_FILES = \
501
+ $(SRCDIR)/../skins/aht/details.txt \
490502
$(SRCDIR)/../skins/black_and_white/css.txt \
503
+ $(SRCDIR)/../skins/black_and_white/details.txt \
491504
$(SRCDIR)/../skins/black_and_white/footer.txt \
492505
$(SRCDIR)/../skins/black_and_white/header.txt \
493506
$(SRCDIR)/../skins/blitz/css.txt \
507
+ $(SRCDIR)/../skins/blitz/details.txt \
494508
$(SRCDIR)/../skins/blitz/footer.txt \
495509
$(SRCDIR)/../skins/blitz/header.txt \
496510
$(SRCDIR)/../skins/blitz/ticket.txt \
497511
$(SRCDIR)/../skins/blitz_no_logo/css.txt \
512
+ $(SRCDIR)/../skins/blitz_no_logo/details.txt \
498513
$(SRCDIR)/../skins/blitz_no_logo/footer.txt \
499514
$(SRCDIR)/../skins/blitz_no_logo/header.txt \
500515
$(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
501516
$(SRCDIR)/../skins/default/css.txt \
517
+ $(SRCDIR)/../skins/default/details.txt \
502518
$(SRCDIR)/../skins/default/footer.txt \
503519
$(SRCDIR)/../skins/default/header.txt \
504520
$(SRCDIR)/../skins/eagle/css.txt \
521
+ $(SRCDIR)/../skins/eagle/details.txt \
505522
$(SRCDIR)/../skins/eagle/footer.txt \
506523
$(SRCDIR)/../skins/eagle/header.txt \
507524
$(SRCDIR)/../skins/enhanced1/css.txt \
525
+ $(SRCDIR)/../skins/enhanced1/details.txt \
508526
$(SRCDIR)/../skins/enhanced1/footer.txt \
509527
$(SRCDIR)/../skins/enhanced1/header.txt \
510528
$(SRCDIR)/../skins/khaki/css.txt \
529
+ $(SRCDIR)/../skins/khaki/details.txt \
511530
$(SRCDIR)/../skins/khaki/footer.txt \
512531
$(SRCDIR)/../skins/khaki/header.txt \
513532
$(SRCDIR)/../skins/original/css.txt \
533
+ $(SRCDIR)/../skins/original/details.txt \
514534
$(SRCDIR)/../skins/original/footer.txt \
515535
$(SRCDIR)/../skins/original/header.txt \
516536
$(SRCDIR)/../skins/plain_gray/css.txt \
537
+ $(SRCDIR)/../skins/plain_gray/details.txt \
517538
$(SRCDIR)/../skins/plain_gray/footer.txt \
518539
$(SRCDIR)/../skins/plain_gray/header.txt \
519540
$(SRCDIR)/../skins/rounded1/css.txt \
541
+ $(SRCDIR)/../skins/rounded1/details.txt \
520542
$(SRCDIR)/../skins/rounded1/footer.txt \
521543
$(SRCDIR)/../skins/rounded1/header.txt \
522544
$(SRCDIR)/../skins/xekri/css.txt \
545
+ $(SRCDIR)/../skins/xekri/details.txt \
523546
$(SRCDIR)/../skins/xekri/footer.txt \
524547
$(SRCDIR)/../skins/xekri/header.txt \
525548
$(SRCDIR)/diff.tcl \
526549
$(SRCDIR)/markdown.md
527550
@@ -596,10 +619,11 @@
596619
$(OBJDIR)/merge_.c \
597620
$(OBJDIR)/merge3_.c \
598621
$(OBJDIR)/moderate_.c \
599622
$(OBJDIR)/name_.c \
600623
$(OBJDIR)/path_.c \
624
+ $(OBJDIR)/piechart_.c \
601625
$(OBJDIR)/pivot_.c \
602626
$(OBJDIR)/popen_.c \
603627
$(OBJDIR)/pqueue_.c \
604628
$(OBJDIR)/printf_.c \
605629
$(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
716740
$(OBJDIR)/merge.o \
717741
$(OBJDIR)/merge3.o \
718742
$(OBJDIR)/moderate.o \
719743
$(OBJDIR)/name.o \
720744
$(OBJDIR)/path.o \
745
+ $(OBJDIR)/piechart.o \
721746
$(OBJDIR)/pivot.o \
722747
$(OBJDIR)/popen.o \
723748
$(OBJDIR)/pqueue.o \
724749
$(OBJDIR)/printf.o \
725750
$(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
10291054
$(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
10301055
$(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
10311056
$(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
10321057
$(OBJDIR)/name_.c:$(OBJDIR)/name.h \
10331058
$(OBJDIR)/path_.c:$(OBJDIR)/path.h \
1059
+ $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
10341060
$(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
10351061
$(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
10361062
$(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
10371063
$(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
10381064
$(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
16591685
16601686
$(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
16611687
$(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
16621688
16631689
$(OBJDIR)/path.h: $(OBJDIR)/headers
1690
+
1691
+$(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(TRANSLATE)
1692
+ $(TRANSLATE) $(SRCDIR)/piechart.c >$@
1693
+
1694
+$(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1695
+ $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1696
+
1697
+$(OBJDIR)/piechart.h: $(OBJDIR)/headers
16641698
16651699
$(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
16661700
$(TRANSLATE) $(SRCDIR)/pivot.c >$@
16671701
16681702
$(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
20372071
-DSQLITE_DEFAULT_FILE_FORMAT=4 \
20382072
-DSQLITE_OMIT_DEPRECATED \
20392073
-DSQLITE_ENABLE_EXPLAIN_COMMENTS \
20402074
-DSQLITE_ENABLE_FTS4 \
20412075
-DSQLITE_ENABLE_FTS3_PARENTHESIS \
2076
+ -DSQLITE_ENABLE_DBSTAT_VTAB \
20422077
-DSQLITE_WIN32_NO_ANSI \
20432078
-D_HAVE__MINGW_H \
20442079
-DSQLITE_USE_MALLOC_H \
20452080
-DSQLITE_USE_MSIZE
20462081
20472082
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -52,10 +52,14 @@
52
53 #### Automatically build OpenSSL when building Fossil (causes rebuild
54 # issues when building incrementally).
55 #
56 # FOSSIL_BUILD_SSL = 1
 
 
 
 
57
58 #### Enable TH1 scripts in embedded documentation files
59 #
60 FOSSIL_ENABLE_TH1_DOCS = 1
61
@@ -251,10 +255,16 @@
251 # With HTTPS support
252 ifdef FOSSIL_ENABLE_SSL
253 TCC += -DFOSSIL_ENABLE_SSL=1
254 RCC += -DFOSSIL_ENABLE_SSL=1
255 endif
 
 
 
 
 
 
256
257 # With TH1 embedded docs support
258 ifdef FOSSIL_ENABLE_TH1_DOCS
259 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
260 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
437 $(SRCDIR)/merge.c \
438 $(SRCDIR)/merge3.c \
439 $(SRCDIR)/moderate.c \
440 $(SRCDIR)/name.c \
441 $(SRCDIR)/path.c \
 
442 $(SRCDIR)/pivot.c \
443 $(SRCDIR)/popen.c \
444 $(SRCDIR)/pqueue.c \
445 $(SRCDIR)/printf.c \
446 $(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
485 $(SRCDIR)/xfer.c \
486 $(SRCDIR)/xfersetup.c \
487 $(SRCDIR)/zip.c
488
489 EXTRA_FILES = \
 
490 $(SRCDIR)/../skins/black_and_white/css.txt \
 
491 $(SRCDIR)/../skins/black_and_white/footer.txt \
492 $(SRCDIR)/../skins/black_and_white/header.txt \
493 $(SRCDIR)/../skins/blitz/css.txt \
 
494 $(SRCDIR)/../skins/blitz/footer.txt \
495 $(SRCDIR)/../skins/blitz/header.txt \
496 $(SRCDIR)/../skins/blitz/ticket.txt \
497 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
 
498 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
499 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
500 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
501 $(SRCDIR)/../skins/default/css.txt \
 
502 $(SRCDIR)/../skins/default/footer.txt \
503 $(SRCDIR)/../skins/default/header.txt \
504 $(SRCDIR)/../skins/eagle/css.txt \
 
505 $(SRCDIR)/../skins/eagle/footer.txt \
506 $(SRCDIR)/../skins/eagle/header.txt \
507 $(SRCDIR)/../skins/enhanced1/css.txt \
 
508 $(SRCDIR)/../skins/enhanced1/footer.txt \
509 $(SRCDIR)/../skins/enhanced1/header.txt \
510 $(SRCDIR)/../skins/khaki/css.txt \
 
511 $(SRCDIR)/../skins/khaki/footer.txt \
512 $(SRCDIR)/../skins/khaki/header.txt \
513 $(SRCDIR)/../skins/original/css.txt \
 
514 $(SRCDIR)/../skins/original/footer.txt \
515 $(SRCDIR)/../skins/original/header.txt \
516 $(SRCDIR)/../skins/plain_gray/css.txt \
 
517 $(SRCDIR)/../skins/plain_gray/footer.txt \
518 $(SRCDIR)/../skins/plain_gray/header.txt \
519 $(SRCDIR)/../skins/rounded1/css.txt \
 
520 $(SRCDIR)/../skins/rounded1/footer.txt \
521 $(SRCDIR)/../skins/rounded1/header.txt \
522 $(SRCDIR)/../skins/xekri/css.txt \
 
523 $(SRCDIR)/../skins/xekri/footer.txt \
524 $(SRCDIR)/../skins/xekri/header.txt \
525 $(SRCDIR)/diff.tcl \
526 $(SRCDIR)/markdown.md
527
@@ -596,10 +619,11 @@
596 $(OBJDIR)/merge_.c \
597 $(OBJDIR)/merge3_.c \
598 $(OBJDIR)/moderate_.c \
599 $(OBJDIR)/name_.c \
600 $(OBJDIR)/path_.c \
 
601 $(OBJDIR)/pivot_.c \
602 $(OBJDIR)/popen_.c \
603 $(OBJDIR)/pqueue_.c \
604 $(OBJDIR)/printf_.c \
605 $(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
716 $(OBJDIR)/merge.o \
717 $(OBJDIR)/merge3.o \
718 $(OBJDIR)/moderate.o \
719 $(OBJDIR)/name.o \
720 $(OBJDIR)/path.o \
 
721 $(OBJDIR)/pivot.o \
722 $(OBJDIR)/popen.o \
723 $(OBJDIR)/pqueue.o \
724 $(OBJDIR)/printf.o \
725 $(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
1029 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1030 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1031 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1032 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
1033 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
 
1034 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
1035 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
1036 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
1037 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1038 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
1659
1660 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1661 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1662
1663 $(OBJDIR)/path.h: $(OBJDIR)/headers
 
 
 
 
 
 
 
 
1664
1665 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
1666 $(TRANSLATE) $(SRCDIR)/pivot.c >$@
1667
1668 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
2037 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2038 -DSQLITE_OMIT_DEPRECATED \
2039 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2040 -DSQLITE_ENABLE_FTS4 \
2041 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
 
2042 -DSQLITE_WIN32_NO_ANSI \
2043 -D_HAVE__MINGW_H \
2044 -DSQLITE_USE_MALLOC_H \
2045 -DSQLITE_USE_MSIZE
2046
2047
--- win/Makefile.mingw.mistachkin
+++ win/Makefile.mingw.mistachkin
@@ -52,10 +52,14 @@
52
53 #### Automatically build OpenSSL when building Fossil (causes rebuild
54 # issues when building incrementally).
55 #
56 # FOSSIL_BUILD_SSL = 1
57
58 #### Enable legacy treatment of mv/rm (skip checkout files)
59 #
60 FOSSIL_ENABLE_LEGACY_MV_RM = 1
61
62 #### Enable TH1 scripts in embedded documentation files
63 #
64 FOSSIL_ENABLE_TH1_DOCS = 1
65
@@ -251,10 +255,16 @@
255 # With HTTPS support
256 ifdef FOSSIL_ENABLE_SSL
257 TCC += -DFOSSIL_ENABLE_SSL=1
258 RCC += -DFOSSIL_ENABLE_SSL=1
259 endif
260
261 # With legacy treatment of mv/rm
262 ifdef FOSSIL_ENABLE_LEGACY_MV_RM
263 TCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
264 RCC += -DFOSSIL_ENABLE_LEGACY_MV_RM=1
265 endif
266
267 # With TH1 embedded docs support
268 ifdef FOSSIL_ENABLE_TH1_DOCS
269 TCC += -DFOSSIL_ENABLE_TH1_DOCS=1
270 RCC += -DFOSSIL_ENABLE_TH1_DOCS=1
@@ -437,10 +447,11 @@
447 $(SRCDIR)/merge.c \
448 $(SRCDIR)/merge3.c \
449 $(SRCDIR)/moderate.c \
450 $(SRCDIR)/name.c \
451 $(SRCDIR)/path.c \
452 $(SRCDIR)/piechart.c \
453 $(SRCDIR)/pivot.c \
454 $(SRCDIR)/popen.c \
455 $(SRCDIR)/pqueue.c \
456 $(SRCDIR)/printf.c \
457 $(SRCDIR)/publish.c \
@@ -485,43 +496,55 @@
496 $(SRCDIR)/xfer.c \
497 $(SRCDIR)/xfersetup.c \
498 $(SRCDIR)/zip.c
499
500 EXTRA_FILES = \
501 $(SRCDIR)/../skins/aht/details.txt \
502 $(SRCDIR)/../skins/black_and_white/css.txt \
503 $(SRCDIR)/../skins/black_and_white/details.txt \
504 $(SRCDIR)/../skins/black_and_white/footer.txt \
505 $(SRCDIR)/../skins/black_and_white/header.txt \
506 $(SRCDIR)/../skins/blitz/css.txt \
507 $(SRCDIR)/../skins/blitz/details.txt \
508 $(SRCDIR)/../skins/blitz/footer.txt \
509 $(SRCDIR)/../skins/blitz/header.txt \
510 $(SRCDIR)/../skins/blitz/ticket.txt \
511 $(SRCDIR)/../skins/blitz_no_logo/css.txt \
512 $(SRCDIR)/../skins/blitz_no_logo/details.txt \
513 $(SRCDIR)/../skins/blitz_no_logo/footer.txt \
514 $(SRCDIR)/../skins/blitz_no_logo/header.txt \
515 $(SRCDIR)/../skins/blitz_no_logo/ticket.txt \
516 $(SRCDIR)/../skins/default/css.txt \
517 $(SRCDIR)/../skins/default/details.txt \
518 $(SRCDIR)/../skins/default/footer.txt \
519 $(SRCDIR)/../skins/default/header.txt \
520 $(SRCDIR)/../skins/eagle/css.txt \
521 $(SRCDIR)/../skins/eagle/details.txt \
522 $(SRCDIR)/../skins/eagle/footer.txt \
523 $(SRCDIR)/../skins/eagle/header.txt \
524 $(SRCDIR)/../skins/enhanced1/css.txt \
525 $(SRCDIR)/../skins/enhanced1/details.txt \
526 $(SRCDIR)/../skins/enhanced1/footer.txt \
527 $(SRCDIR)/../skins/enhanced1/header.txt \
528 $(SRCDIR)/../skins/khaki/css.txt \
529 $(SRCDIR)/../skins/khaki/details.txt \
530 $(SRCDIR)/../skins/khaki/footer.txt \
531 $(SRCDIR)/../skins/khaki/header.txt \
532 $(SRCDIR)/../skins/original/css.txt \
533 $(SRCDIR)/../skins/original/details.txt \
534 $(SRCDIR)/../skins/original/footer.txt \
535 $(SRCDIR)/../skins/original/header.txt \
536 $(SRCDIR)/../skins/plain_gray/css.txt \
537 $(SRCDIR)/../skins/plain_gray/details.txt \
538 $(SRCDIR)/../skins/plain_gray/footer.txt \
539 $(SRCDIR)/../skins/plain_gray/header.txt \
540 $(SRCDIR)/../skins/rounded1/css.txt \
541 $(SRCDIR)/../skins/rounded1/details.txt \
542 $(SRCDIR)/../skins/rounded1/footer.txt \
543 $(SRCDIR)/../skins/rounded1/header.txt \
544 $(SRCDIR)/../skins/xekri/css.txt \
545 $(SRCDIR)/../skins/xekri/details.txt \
546 $(SRCDIR)/../skins/xekri/footer.txt \
547 $(SRCDIR)/../skins/xekri/header.txt \
548 $(SRCDIR)/diff.tcl \
549 $(SRCDIR)/markdown.md
550
@@ -596,10 +619,11 @@
619 $(OBJDIR)/merge_.c \
620 $(OBJDIR)/merge3_.c \
621 $(OBJDIR)/moderate_.c \
622 $(OBJDIR)/name_.c \
623 $(OBJDIR)/path_.c \
624 $(OBJDIR)/piechart_.c \
625 $(OBJDIR)/pivot_.c \
626 $(OBJDIR)/popen_.c \
627 $(OBJDIR)/pqueue_.c \
628 $(OBJDIR)/printf_.c \
629 $(OBJDIR)/publish_.c \
@@ -716,10 +740,11 @@
740 $(OBJDIR)/merge.o \
741 $(OBJDIR)/merge3.o \
742 $(OBJDIR)/moderate.o \
743 $(OBJDIR)/name.o \
744 $(OBJDIR)/path.o \
745 $(OBJDIR)/piechart.o \
746 $(OBJDIR)/pivot.o \
747 $(OBJDIR)/popen.o \
748 $(OBJDIR)/pqueue.o \
749 $(OBJDIR)/printf.o \
750 $(OBJDIR)/publish.o \
@@ -1029,10 +1054,11 @@
1054 $(OBJDIR)/merge_.c:$(OBJDIR)/merge.h \
1055 $(OBJDIR)/merge3_.c:$(OBJDIR)/merge3.h \
1056 $(OBJDIR)/moderate_.c:$(OBJDIR)/moderate.h \
1057 $(OBJDIR)/name_.c:$(OBJDIR)/name.h \
1058 $(OBJDIR)/path_.c:$(OBJDIR)/path.h \
1059 $(OBJDIR)/piechart_.c:$(OBJDIR)/piechart.h \
1060 $(OBJDIR)/pivot_.c:$(OBJDIR)/pivot.h \
1061 $(OBJDIR)/popen_.c:$(OBJDIR)/popen.h \
1062 $(OBJDIR)/pqueue_.c:$(OBJDIR)/pqueue.h \
1063 $(OBJDIR)/printf_.c:$(OBJDIR)/printf.h \
1064 $(OBJDIR)/publish_.c:$(OBJDIR)/publish.h \
@@ -1659,10 +1685,18 @@
1685
1686 $(OBJDIR)/path.o: $(OBJDIR)/path_.c $(OBJDIR)/path.h $(SRCDIR)/config.h
1687 $(XTCC) -o $(OBJDIR)/path.o -c $(OBJDIR)/path_.c
1688
1689 $(OBJDIR)/path.h: $(OBJDIR)/headers
1690
1691 $(OBJDIR)/piechart_.c: $(SRCDIR)/piechart.c $(TRANSLATE)
1692 $(TRANSLATE) $(SRCDIR)/piechart.c >$@
1693
1694 $(OBJDIR)/piechart.o: $(OBJDIR)/piechart_.c $(OBJDIR)/piechart.h $(SRCDIR)/config.h
1695 $(XTCC) -o $(OBJDIR)/piechart.o -c $(OBJDIR)/piechart_.c
1696
1697 $(OBJDIR)/piechart.h: $(OBJDIR)/headers
1698
1699 $(OBJDIR)/pivot_.c: $(SRCDIR)/pivot.c $(TRANSLATE)
1700 $(TRANSLATE) $(SRCDIR)/pivot.c >$@
1701
1702 $(OBJDIR)/pivot.o: $(OBJDIR)/pivot_.c $(OBJDIR)/pivot.h $(SRCDIR)/config.h
@@ -2037,10 +2071,11 @@
2071 -DSQLITE_DEFAULT_FILE_FORMAT=4 \
2072 -DSQLITE_OMIT_DEPRECATED \
2073 -DSQLITE_ENABLE_EXPLAIN_COMMENTS \
2074 -DSQLITE_ENABLE_FTS4 \
2075 -DSQLITE_ENABLE_FTS3_PARENTHESIS \
2076 -DSQLITE_ENABLE_DBSTAT_VTAB \
2077 -DSQLITE_WIN32_NO_ANSI \
2078 -D_HAVE__MINGW_H \
2079 -DSQLITE_USE_MALLOC_H \
2080 -DSQLITE_USE_MSIZE
2081
2082
+32 -1
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -44,10 +44,13 @@
4444
# Uncomment to enable SSL support
4545
# FOSSIL_ENABLE_SSL = 1
4646
4747
# Uncomment to build SSL libraries
4848
# FOSSIL_BUILD_SSL = 1
49
+
50
+# Uncomment to enable legacy treatment of mv/rm
51
+# FOSSIL_ENABLE_LEGACY_MV_RM = 1
4952
5053
# Uncomment to enable TH1 scripts in embedded documentation files
5154
# FOSSIL_ENABLE_TH1_DOCS = 1
5255
5356
# Uncomment to enable TH1 hooks
@@ -160,10 +163,15 @@
160163
TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
161164
RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
162165
LIBS = $(LIBS) $(SSLLIB)
163166
LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
164167
!endif
168
+
169
+!ifdef FOSSIL_ENABLE_LEGACY_MV_RM
170
+TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
171
+RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
172
+!endif
165173
166174
!ifdef FOSSIL_ENABLE_TH1_DOCS
167175
TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
168176
RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
169177
!endif
@@ -191,10 +199,11 @@
191199
/DSQLITE_DEFAULT_FILE_FORMAT=4 \
192200
/DSQLITE_OMIT_DEPRECATED \
193201
/DSQLITE_ENABLE_EXPLAIN_COMMENTS \
194202
/DSQLITE_ENABLE_FTS4 \
195203
/DSQLITE_ENABLE_FTS3_PARENTHESIS \
204
+ /DSQLITE_ENABLE_DBSTAT_VTAB \
196205
/DSQLITE_WIN32_NO_ANSI
197206
198207
SHELL_OPTIONS = /Dmain=sqlite3_shell \
199208
/DSQLITE_OMIT_LOAD_EXTENSION=1 \
200209
/DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -278,10 +287,11 @@
278287
merge_.c \
279288
merge3_.c \
280289
moderate_.c \
281290
name_.c \
282291
path_.c \
292
+ piechart_.c \
283293
pivot_.c \
284294
popen_.c \
285295
pqueue_.c \
286296
printf_.c \
287297
publish_.c \
@@ -325,43 +335,55 @@
325335
wysiwyg_.c \
326336
xfer_.c \
327337
xfersetup_.c \
328338
zip_.c
329339
330
-EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
340
+EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
341
+ $(SRCDIR)\../skins/black_and_white/css.txt \
342
+ $(SRCDIR)\../skins/black_and_white/details.txt \
331343
$(SRCDIR)\../skins/black_and_white/footer.txt \
332344
$(SRCDIR)\../skins/black_and_white/header.txt \
333345
$(SRCDIR)\../skins/blitz/css.txt \
346
+ $(SRCDIR)\../skins/blitz/details.txt \
334347
$(SRCDIR)\../skins/blitz/footer.txt \
335348
$(SRCDIR)\../skins/blitz/header.txt \
336349
$(SRCDIR)\../skins/blitz/ticket.txt \
337350
$(SRCDIR)\../skins/blitz_no_logo/css.txt \
351
+ $(SRCDIR)\../skins/blitz_no_logo/details.txt \
338352
$(SRCDIR)\../skins/blitz_no_logo/footer.txt \
339353
$(SRCDIR)\../skins/blitz_no_logo/header.txt \
340354
$(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
341355
$(SRCDIR)\../skins/default/css.txt \
356
+ $(SRCDIR)\../skins/default/details.txt \
342357
$(SRCDIR)\../skins/default/footer.txt \
343358
$(SRCDIR)\../skins/default/header.txt \
344359
$(SRCDIR)\../skins/eagle/css.txt \
360
+ $(SRCDIR)\../skins/eagle/details.txt \
345361
$(SRCDIR)\../skins/eagle/footer.txt \
346362
$(SRCDIR)\../skins/eagle/header.txt \
347363
$(SRCDIR)\../skins/enhanced1/css.txt \
364
+ $(SRCDIR)\../skins/enhanced1/details.txt \
348365
$(SRCDIR)\../skins/enhanced1/footer.txt \
349366
$(SRCDIR)\../skins/enhanced1/header.txt \
350367
$(SRCDIR)\../skins/khaki/css.txt \
368
+ $(SRCDIR)\../skins/khaki/details.txt \
351369
$(SRCDIR)\../skins/khaki/footer.txt \
352370
$(SRCDIR)\../skins/khaki/header.txt \
353371
$(SRCDIR)\../skins/original/css.txt \
372
+ $(SRCDIR)\../skins/original/details.txt \
354373
$(SRCDIR)\../skins/original/footer.txt \
355374
$(SRCDIR)\../skins/original/header.txt \
356375
$(SRCDIR)\../skins/plain_gray/css.txt \
376
+ $(SRCDIR)\../skins/plain_gray/details.txt \
357377
$(SRCDIR)\../skins/plain_gray/footer.txt \
358378
$(SRCDIR)\../skins/plain_gray/header.txt \
359379
$(SRCDIR)\../skins/rounded1/css.txt \
380
+ $(SRCDIR)\../skins/rounded1/details.txt \
360381
$(SRCDIR)\../skins/rounded1/footer.txt \
361382
$(SRCDIR)\../skins/rounded1/header.txt \
362383
$(SRCDIR)\../skins/xekri/css.txt \
384
+ $(SRCDIR)\../skins/xekri/details.txt \
363385
$(SRCDIR)\../skins/xekri/footer.txt \
364386
$(SRCDIR)\../skins/xekri/header.txt \
365387
$(SRCDIR)\diff.tcl \
366388
$(SRCDIR)\markdown.md
367389
@@ -436,10 +458,11 @@
436458
$(OX)\merge$O \
437459
$(OX)\merge3$O \
438460
$(OX)\moderate$O \
439461
$(OX)\name$O \
440462
$(OX)\path$O \
463
+ $(OX)\piechart$O \
441464
$(OX)\pivot$O \
442465
$(OX)\popen$O \
443466
$(OX)\pqueue$O \
444467
$(OX)\printf$O \
445468
$(OX)\publish$O \
@@ -611,10 +634,11 @@
611634
echo $(OX)\merge.obj >> $@
612635
echo $(OX)\merge3.obj >> $@
613636
echo $(OX)\moderate.obj >> $@
614637
echo $(OX)\name.obj >> $@
615638
echo $(OX)\path.obj >> $@
639
+ echo $(OX)\piechart.obj >> $@
616640
echo $(OX)\pivot.obj >> $@
617641
echo $(OX)\popen.obj >> $@
618642
echo $(OX)\pqueue.obj >> $@
619643
echo $(OX)\printf.obj >> $@
620644
echo $(OX)\publish.obj >> $@
@@ -1192,10 +1216,16 @@
11921216
$(OX)\path$O : path_.c path.h
11931217
$(TCC) /Fo$@ -c path_.c
11941218
11951219
path_.c : $(SRCDIR)\path.c
11961220
translate$E $** > $@
1221
+
1222
+$(OX)\piechart$O : piechart_.c piechart.h
1223
+ $(TCC) /Fo$@ -c piechart_.c
1224
+
1225
+piechart_.c : $(SRCDIR)\piechart.c
1226
+ translate$E $** > $@
11971227
11981228
$(OX)\pivot$O : pivot_.c pivot.h
11991229
$(TCC) /Fo$@ -c pivot_.c
12001230
12011231
pivot_.c : $(SRCDIR)\pivot.c
@@ -1545,10 +1575,11 @@
15451575
merge_.c:merge.h \
15461576
merge3_.c:merge3.h \
15471577
moderate_.c:moderate.h \
15481578
name_.c:name.h \
15491579
path_.c:path.h \
1580
+ piechart_.c:piechart.h \
15501581
pivot_.c:pivot.h \
15511582
popen_.c:popen.h \
15521583
pqueue_.c:pqueue.h \
15531584
printf_.c:printf.h \
15541585
publish_.c:publish.h \
15551586
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -44,10 +44,13 @@
44 # Uncomment to enable SSL support
45 # FOSSIL_ENABLE_SSL = 1
46
47 # Uncomment to build SSL libraries
48 # FOSSIL_BUILD_SSL = 1
 
 
 
49
50 # Uncomment to enable TH1 scripts in embedded documentation files
51 # FOSSIL_ENABLE_TH1_DOCS = 1
52
53 # Uncomment to enable TH1 hooks
@@ -160,10 +163,15 @@
160 TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
161 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
162 LIBS = $(LIBS) $(SSLLIB)
163 LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
164 !endif
 
 
 
 
 
165
166 !ifdef FOSSIL_ENABLE_TH1_DOCS
167 TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
168 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
169 !endif
@@ -191,10 +199,11 @@
191 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
192 /DSQLITE_OMIT_DEPRECATED \
193 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
194 /DSQLITE_ENABLE_FTS4 \
195 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
 
196 /DSQLITE_WIN32_NO_ANSI
197
198 SHELL_OPTIONS = /Dmain=sqlite3_shell \
199 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
200 /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -278,10 +287,11 @@
278 merge_.c \
279 merge3_.c \
280 moderate_.c \
281 name_.c \
282 path_.c \
 
283 pivot_.c \
284 popen_.c \
285 pqueue_.c \
286 printf_.c \
287 publish_.c \
@@ -325,43 +335,55 @@
325 wysiwyg_.c \
326 xfer_.c \
327 xfersetup_.c \
328 zip_.c
329
330 EXTRA_FILES = $(SRCDIR)\../skins/black_and_white/css.txt \
 
 
331 $(SRCDIR)\../skins/black_and_white/footer.txt \
332 $(SRCDIR)\../skins/black_and_white/header.txt \
333 $(SRCDIR)\../skins/blitz/css.txt \
 
334 $(SRCDIR)\../skins/blitz/footer.txt \
335 $(SRCDIR)\../skins/blitz/header.txt \
336 $(SRCDIR)\../skins/blitz/ticket.txt \
337 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
 
338 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
339 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
340 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
341 $(SRCDIR)\../skins/default/css.txt \
 
342 $(SRCDIR)\../skins/default/footer.txt \
343 $(SRCDIR)\../skins/default/header.txt \
344 $(SRCDIR)\../skins/eagle/css.txt \
 
345 $(SRCDIR)\../skins/eagle/footer.txt \
346 $(SRCDIR)\../skins/eagle/header.txt \
347 $(SRCDIR)\../skins/enhanced1/css.txt \
 
348 $(SRCDIR)\../skins/enhanced1/footer.txt \
349 $(SRCDIR)\../skins/enhanced1/header.txt \
350 $(SRCDIR)\../skins/khaki/css.txt \
 
351 $(SRCDIR)\../skins/khaki/footer.txt \
352 $(SRCDIR)\../skins/khaki/header.txt \
353 $(SRCDIR)\../skins/original/css.txt \
 
354 $(SRCDIR)\../skins/original/footer.txt \
355 $(SRCDIR)\../skins/original/header.txt \
356 $(SRCDIR)\../skins/plain_gray/css.txt \
 
357 $(SRCDIR)\../skins/plain_gray/footer.txt \
358 $(SRCDIR)\../skins/plain_gray/header.txt \
359 $(SRCDIR)\../skins/rounded1/css.txt \
 
360 $(SRCDIR)\../skins/rounded1/footer.txt \
361 $(SRCDIR)\../skins/rounded1/header.txt \
362 $(SRCDIR)\../skins/xekri/css.txt \
 
363 $(SRCDIR)\../skins/xekri/footer.txt \
364 $(SRCDIR)\../skins/xekri/header.txt \
365 $(SRCDIR)\diff.tcl \
366 $(SRCDIR)\markdown.md
367
@@ -436,10 +458,11 @@
436 $(OX)\merge$O \
437 $(OX)\merge3$O \
438 $(OX)\moderate$O \
439 $(OX)\name$O \
440 $(OX)\path$O \
 
441 $(OX)\pivot$O \
442 $(OX)\popen$O \
443 $(OX)\pqueue$O \
444 $(OX)\printf$O \
445 $(OX)\publish$O \
@@ -611,10 +634,11 @@
611 echo $(OX)\merge.obj >> $@
612 echo $(OX)\merge3.obj >> $@
613 echo $(OX)\moderate.obj >> $@
614 echo $(OX)\name.obj >> $@
615 echo $(OX)\path.obj >> $@
 
616 echo $(OX)\pivot.obj >> $@
617 echo $(OX)\popen.obj >> $@
618 echo $(OX)\pqueue.obj >> $@
619 echo $(OX)\printf.obj >> $@
620 echo $(OX)\publish.obj >> $@
@@ -1192,10 +1216,16 @@
1192 $(OX)\path$O : path_.c path.h
1193 $(TCC) /Fo$@ -c path_.c
1194
1195 path_.c : $(SRCDIR)\path.c
1196 translate$E $** > $@
 
 
 
 
 
 
1197
1198 $(OX)\pivot$O : pivot_.c pivot.h
1199 $(TCC) /Fo$@ -c pivot_.c
1200
1201 pivot_.c : $(SRCDIR)\pivot.c
@@ -1545,10 +1575,11 @@
1545 merge_.c:merge.h \
1546 merge3_.c:merge3.h \
1547 moderate_.c:moderate.h \
1548 name_.c:name.h \
1549 path_.c:path.h \
 
1550 pivot_.c:pivot.h \
1551 popen_.c:popen.h \
1552 pqueue_.c:pqueue.h \
1553 printf_.c:printf.h \
1554 publish_.c:publish.h \
1555
--- win/Makefile.msc
+++ win/Makefile.msc
@@ -44,10 +44,13 @@
44 # Uncomment to enable SSL support
45 # FOSSIL_ENABLE_SSL = 1
46
47 # Uncomment to build SSL libraries
48 # FOSSIL_BUILD_SSL = 1
49
50 # Uncomment to enable legacy treatment of mv/rm
51 # FOSSIL_ENABLE_LEGACY_MV_RM = 1
52
53 # Uncomment to enable TH1 scripts in embedded documentation files
54 # FOSSIL_ENABLE_TH1_DOCS = 1
55
56 # Uncomment to enable TH1 hooks
@@ -160,10 +163,15 @@
163 TCC = $(TCC) /DFOSSIL_ENABLE_SSL=1
164 RCC = $(RCC) /DFOSSIL_ENABLE_SSL=1
165 LIBS = $(LIBS) $(SSLLIB)
166 LIBDIR = $(LIBDIR) /LIBPATH:$(SSLLIBDIR)
167 !endif
168
169 !ifdef FOSSIL_ENABLE_LEGACY_MV_RM
170 TCC = $(TCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
171 RCC = $(RCC) /DFOSSIL_ENABLE_LEGACY_MV_RM=1
172 !endif
173
174 !ifdef FOSSIL_ENABLE_TH1_DOCS
175 TCC = $(TCC) /DFOSSIL_ENABLE_TH1_DOCS=1
176 RCC = $(RCC) /DFOSSIL_ENABLE_TH1_DOCS=1
177 !endif
@@ -191,10 +199,11 @@
199 /DSQLITE_DEFAULT_FILE_FORMAT=4 \
200 /DSQLITE_OMIT_DEPRECATED \
201 /DSQLITE_ENABLE_EXPLAIN_COMMENTS \
202 /DSQLITE_ENABLE_FTS4 \
203 /DSQLITE_ENABLE_FTS3_PARENTHESIS \
204 /DSQLITE_ENABLE_DBSTAT_VTAB \
205 /DSQLITE_WIN32_NO_ANSI
206
207 SHELL_OPTIONS = /Dmain=sqlite3_shell \
208 /DSQLITE_OMIT_LOAD_EXTENSION=1 \
209 /DUSE_SYSTEM_SQLITE=$(USE_SYSTEM_SQLITE) \
@@ -278,10 +287,11 @@
287 merge_.c \
288 merge3_.c \
289 moderate_.c \
290 name_.c \
291 path_.c \
292 piechart_.c \
293 pivot_.c \
294 popen_.c \
295 pqueue_.c \
296 printf_.c \
297 publish_.c \
@@ -325,43 +335,55 @@
335 wysiwyg_.c \
336 xfer_.c \
337 xfersetup_.c \
338 zip_.c
339
340 EXTRA_FILES = $(SRCDIR)\../skins/aht/details.txt \
341 $(SRCDIR)\../skins/black_and_white/css.txt \
342 $(SRCDIR)\../skins/black_and_white/details.txt \
343 $(SRCDIR)\../skins/black_and_white/footer.txt \
344 $(SRCDIR)\../skins/black_and_white/header.txt \
345 $(SRCDIR)\../skins/blitz/css.txt \
346 $(SRCDIR)\../skins/blitz/details.txt \
347 $(SRCDIR)\../skins/blitz/footer.txt \
348 $(SRCDIR)\../skins/blitz/header.txt \
349 $(SRCDIR)\../skins/blitz/ticket.txt \
350 $(SRCDIR)\../skins/blitz_no_logo/css.txt \
351 $(SRCDIR)\../skins/blitz_no_logo/details.txt \
352 $(SRCDIR)\../skins/blitz_no_logo/footer.txt \
353 $(SRCDIR)\../skins/blitz_no_logo/header.txt \
354 $(SRCDIR)\../skins/blitz_no_logo/ticket.txt \
355 $(SRCDIR)\../skins/default/css.txt \
356 $(SRCDIR)\../skins/default/details.txt \
357 $(SRCDIR)\../skins/default/footer.txt \
358 $(SRCDIR)\../skins/default/header.txt \
359 $(SRCDIR)\../skins/eagle/css.txt \
360 $(SRCDIR)\../skins/eagle/details.txt \
361 $(SRCDIR)\../skins/eagle/footer.txt \
362 $(SRCDIR)\../skins/eagle/header.txt \
363 $(SRCDIR)\../skins/enhanced1/css.txt \
364 $(SRCDIR)\../skins/enhanced1/details.txt \
365 $(SRCDIR)\../skins/enhanced1/footer.txt \
366 $(SRCDIR)\../skins/enhanced1/header.txt \
367 $(SRCDIR)\../skins/khaki/css.txt \
368 $(SRCDIR)\../skins/khaki/details.txt \
369 $(SRCDIR)\../skins/khaki/footer.txt \
370 $(SRCDIR)\../skins/khaki/header.txt \
371 $(SRCDIR)\../skins/original/css.txt \
372 $(SRCDIR)\../skins/original/details.txt \
373 $(SRCDIR)\../skins/original/footer.txt \
374 $(SRCDIR)\../skins/original/header.txt \
375 $(SRCDIR)\../skins/plain_gray/css.txt \
376 $(SRCDIR)\../skins/plain_gray/details.txt \
377 $(SRCDIR)\../skins/plain_gray/footer.txt \
378 $(SRCDIR)\../skins/plain_gray/header.txt \
379 $(SRCDIR)\../skins/rounded1/css.txt \
380 $(SRCDIR)\../skins/rounded1/details.txt \
381 $(SRCDIR)\../skins/rounded1/footer.txt \
382 $(SRCDIR)\../skins/rounded1/header.txt \
383 $(SRCDIR)\../skins/xekri/css.txt \
384 $(SRCDIR)\../skins/xekri/details.txt \
385 $(SRCDIR)\../skins/xekri/footer.txt \
386 $(SRCDIR)\../skins/xekri/header.txt \
387 $(SRCDIR)\diff.tcl \
388 $(SRCDIR)\markdown.md
389
@@ -436,10 +458,11 @@
458 $(OX)\merge$O \
459 $(OX)\merge3$O \
460 $(OX)\moderate$O \
461 $(OX)\name$O \
462 $(OX)\path$O \
463 $(OX)\piechart$O \
464 $(OX)\pivot$O \
465 $(OX)\popen$O \
466 $(OX)\pqueue$O \
467 $(OX)\printf$O \
468 $(OX)\publish$O \
@@ -611,10 +634,11 @@
634 echo $(OX)\merge.obj >> $@
635 echo $(OX)\merge3.obj >> $@
636 echo $(OX)\moderate.obj >> $@
637 echo $(OX)\name.obj >> $@
638 echo $(OX)\path.obj >> $@
639 echo $(OX)\piechart.obj >> $@
640 echo $(OX)\pivot.obj >> $@
641 echo $(OX)\popen.obj >> $@
642 echo $(OX)\pqueue.obj >> $@
643 echo $(OX)\printf.obj >> $@
644 echo $(OX)\publish.obj >> $@
@@ -1192,10 +1216,16 @@
1216 $(OX)\path$O : path_.c path.h
1217 $(TCC) /Fo$@ -c path_.c
1218
1219 path_.c : $(SRCDIR)\path.c
1220 translate$E $** > $@
1221
1222 $(OX)\piechart$O : piechart_.c piechart.h
1223 $(TCC) /Fo$@ -c piechart_.c
1224
1225 piechart_.c : $(SRCDIR)\piechart.c
1226 translate$E $** > $@
1227
1228 $(OX)\pivot$O : pivot_.c pivot.h
1229 $(TCC) /Fo$@ -c pivot_.c
1230
1231 pivot_.c : $(SRCDIR)\pivot.c
@@ -1545,10 +1575,11 @@
1575 merge_.c:merge.h \
1576 merge3_.c:merge3.h \
1577 moderate_.c:moderate.h \
1578 name_.c:name.h \
1579 path_.c:path.h \
1580 piechart_.c:piechart.h \
1581 pivot_.c:pivot.h \
1582 popen_.c:popen.h \
1583 pqueue_.c:pqueue.h \
1584 printf_.c:printf.h \
1585 publish_.c:publish.h \
1586
--- win/fossil.rc
+++ win/fossil.rc
@@ -115,10 +115,15 @@
115115
VALUE "CommandLineIsUnicode", "Yes\0"
116116
#endif /* defined(BROKEN_MINGW_CMDLINE) */
117117
#if defined(FOSSIL_ENABLE_SSL)
118118
VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
119119
#endif /* defined(FOSSIL_ENABLE_SSL) */
120
+#if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
121
+ VALUE "LegacyMvRm", "Yes\0"
122
+#else
123
+ VALUE "LegacyMvRm", "No\0"
124
+#endif /* defined(FOSSIL_ENABLE_LEGACY_MV_RM) */
120125
#if defined(FOSSIL_ENABLE_TH1_DOCS)
121126
VALUE "Th1Docs", "Yes\0"
122127
#else
123128
VALUE "Th1Docs", "No\0"
124129
#endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */
125130
--- win/fossil.rc
+++ win/fossil.rc
@@ -115,10 +115,15 @@
115 VALUE "CommandLineIsUnicode", "Yes\0"
116 #endif /* defined(BROKEN_MINGW_CMDLINE) */
117 #if defined(FOSSIL_ENABLE_SSL)
118 VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
119 #endif /* defined(FOSSIL_ENABLE_SSL) */
 
 
 
 
 
120 #if defined(FOSSIL_ENABLE_TH1_DOCS)
121 VALUE "Th1Docs", "Yes\0"
122 #else
123 VALUE "Th1Docs", "No\0"
124 #endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */
125
--- win/fossil.rc
+++ win/fossil.rc
@@ -115,10 +115,15 @@
115 VALUE "CommandLineIsUnicode", "Yes\0"
116 #endif /* defined(BROKEN_MINGW_CMDLINE) */
117 #if defined(FOSSIL_ENABLE_SSL)
118 VALUE "SslEnabled", "Yes, " OPENSSL_VERSION_TEXT "\0"
119 #endif /* defined(FOSSIL_ENABLE_SSL) */
120 #if defined(FOSSIL_ENABLE_LEGACY_MV_RM)
121 VALUE "LegacyMvRm", "Yes\0"
122 #else
123 VALUE "LegacyMvRm", "No\0"
124 #endif /* defined(FOSSIL_ENABLE_LEGACY_MV_RM) */
125 #if defined(FOSSIL_ENABLE_TH1_DOCS)
126 VALUE "Th1Docs", "Yes\0"
127 #else
128 VALUE "Th1Docs", "No\0"
129 #endif /* defined(FOSSIL_ENABLE_TH1_DOCS) */
130
+33 -14
--- www/build.wiki
+++ www/build.wiki
@@ -26,39 +26,39 @@
2626
<p><hr>
2727
2828
<h2>1.0 Obtaining The Source Code</h2>
2929
3030
<p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball
31
-containing a snapshot of the <em>latest</em> version directly from
32
-Fossil's own fossil repository. Additionally, source archives of
31
+containing a snapshot of the <em>latest</em> version directly from
32
+Fossil's own fossil repository. Additionally, source archives of
3333
<em>released</em> versions of
3434
fossil are available from the <a href="http://www.fossil-scm.org/download.html">downloads page</a>.
3535
To obtain a development version of fossil, follow these steps:</p>
3636
3737
<ol>
3838
<li><p>Point your web browser to
3939
<a href="http://www.fossil-scm.org/">
4040
http://www.fossil-scm.org/</a>.</p></li>
4141
42
-<li><p>Click on the
43
-<a href="http://www.fossil-scm.org/fossil/timeline">Timeline</a>
42
+<li><p>Click on the
43
+<a href="http://www.fossil-scm.org/fossil/timeline">Timeline</a>
4444
link at the top of the page.</p></li>
4545
4646
<li><p>Select a version of of Fossil you want to download. The latest
4747
version on the trunk branch is usually a good choice. Click on its
4848
link.</p></li>
4949
5050
<li><p>Finally, click on one of the
5151
"Zip Archive" or "Tarball" links, according to your preference.
52
-These link will build a ZIP archive or a gzip-compressed tarball of the
52
+These link will build a ZIP archive or a gzip-compressed tarball of the
5353
complete source code and download it to your computer.
5454
</ol>
5555
5656
<h2>Aside: Is it really safe to use an unreleased development version of
5757
the Fossil source code?</h2>
5858
59
-Yes! Any check-in on the
59
+Yes! Any check-in on the
6060
[/timeline?t=trunk | trunk branch] of the Fossil
6161
[http://fossil-scm.org/fossil/timeline | Fossil self-hosting repository]
6262
will work fine. (Dodgy code is always on a branch.) In the unlikely
6363
event that you pick a version with a serious bug, it still won't
6464
clobber your files. Fossil uses several
@@ -90,10 +90,14 @@
9090
9191
<li><p>
9292
To build a statically linked binary (suitable for use inside a chroot
9393
jail) add the <b>--static</b> option.
9494
95
+<li><p>
96
+To enable the native [./th1.md#tclEval | Tcl integration feature] feature,
97
+add the <b>--with-tcl=1</b> and <b>--with-tcl-private-stubs=1</b> options.
98
+
9599
<li><p>
96100
Other configuration options can be seen by running
97101
<b>./configure --help</b>
98102
</ol>
99103
@@ -102,20 +106,26 @@
102106
103107
<ol type="a">
104108
<li><p><i>Unix</i> → the configure-generated Makefile should work on
105109
all Unix and Unix-like systems. Simply type "<b>make</b>".
106110
107
-<li><p><i>Unix without running "configure"</i> → if you prefer to avoid running configure, you
108
-can also use: <b>make -f Makefile.classic</b>. You may want to make minor
109
-edits to Makefile.classic to configure the build for your system.
111
+<li><p><i>Unix without running "configure"</i> → if you prefer to avoid
112
+running configure, you can also use: <b>make -f Makefile.classic</b>. You may
113
+want to make minor edits to Makefile.classic to configure the build for your
114
+system.
110115
111116
<li><p><i>MinGW3.x (not 4.0)/MinGW-w64</i> → Use the mingw makefile:
112117
"<b>make -f win/Makefile.mingw</b>". On a Windows box you will
113118
need either Cygwin or Msys as build environment. On Cygwin, Linux
114119
or Darwin you may want to make minor edits to win/Makefile.mingw
115120
to configure the cross-compile environment.
116121
122
+To enable the native [./th1.md#tclEval | Tcl integration feature], use a
123
+command line like the following (all on one line):
124
+
125
+<b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
126
+
117127
Hint: don't use MinGW-4.0, it will compile but fossil won't work correctly, see
118128
<a href="https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c">https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c</a>.
119129
120130
<li><p><i>MSVC</i> → Use the MSVC makefile. First
121131
change to the "win/" subdirectory ("<b>cd win</b>") then run
@@ -134,10 +144,19 @@
134144
nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
135145
</pre></blockquote>
136146
<blockquote><pre>
137147
buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
138148
</pre></blockquote>
149
+To enable the optional native [./th1.md#tclEval | Tcl integration feature],
150
+run one of the following commands or add the &quot;FOSSIL_ENABLE_TCL=1&quot;
151
+argument to one of the other NMAKE command lines:
152
+<blockquote><pre>
153
+nmake /f Makefile.msc FOSSIL_ENABLE_TCL=1
154
+</pre></blockquote>
155
+<blockquote><pre>
156
+buildmsvc.bat FOSSIL_ENABLE_TCL=1
157
+</pre></blockquote>
139158
140159
<li><p><i>Cygwin</i> → The same as other Unix-like systems. It is
141160
recommended to configure using: "<b>configure --disable-internal-sqlite</b>",
142161
making sure you have the "libsqlite3-devel" , "zlib-devel" and
143162
"openssl-devel" packages installed first.
@@ -146,12 +165,12 @@
146165
147166
<h2>3.0 Installing</h2>
148167
149168
<ol>
150169
<li value="8">
151
-<p>The finished binary is named "fossil" (or "fossil.exe" on Windows).
152
-Put this binary in a
170
+<p>The finished binary is named "fossil" (or "fossil.exe" on Windows).
171
+Put this binary in a
153172
directory that is somewhere on your PATH environment variable.
154173
It does not matter where.</p>
155174
156175
<li>
157176
<p><b>(Optional:)</b>
@@ -167,14 +186,14 @@
167186
Fossil manually, then refer to the
168187
[./makefile.wiki | Fossil Build Process] document which describes
169188
in detail what the makefiles do behind the scenes.
170189
171190
<li><p>
172
- The fossil executable is self-contained and stand-alone and usually
173
- requires no special libraries or other software to be installed. However,
191
+ The fossil executable is self-contained and stand-alone and usually
192
+ requires no special libraries or other software to be installed. However,
174193
the "--tk" option to the [/help/diff|diff command] requires that Tcl/Tk
175
- be installed on the local machine. You can get Tcl/Tk from
194
+ be installed on the local machine. You can get Tcl/Tk from
176195
[http://www.activestate.com/activetcl|ActiveState].
177196
178197
<li><p>
179198
To build on older Macs (circa 2002, MacOS 10.2) edit the Makefile
180199
generated by configure to add the following lines:
181200
--- www/build.wiki
+++ www/build.wiki
@@ -26,39 +26,39 @@
26 <p><hr>
27
28 <h2>1.0 Obtaining The Source Code</h2>
29
30 <p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball
31 containing a snapshot of the <em>latest</em> version directly from
32 Fossil's own fossil repository. Additionally, source archives of
33 <em>released</em> versions of
34 fossil are available from the <a href="http://www.fossil-scm.org/download.html">downloads page</a>.
35 To obtain a development version of fossil, follow these steps:</p>
36
37 <ol>
38 <li><p>Point your web browser to
39 <a href="http://www.fossil-scm.org/">
40 http://www.fossil-scm.org/</a>.</p></li>
41
42 <li><p>Click on the
43 <a href="http://www.fossil-scm.org/fossil/timeline">Timeline</a>
44 link at the top of the page.</p></li>
45
46 <li><p>Select a version of of Fossil you want to download. The latest
47 version on the trunk branch is usually a good choice. Click on its
48 link.</p></li>
49
50 <li><p>Finally, click on one of the
51 "Zip Archive" or "Tarball" links, according to your preference.
52 These link will build a ZIP archive or a gzip-compressed tarball of the
53 complete source code and download it to your computer.
54 </ol>
55
56 <h2>Aside: Is it really safe to use an unreleased development version of
57 the Fossil source code?</h2>
58
59 Yes! Any check-in on the
60 [/timeline?t=trunk | trunk branch] of the Fossil
61 [http://fossil-scm.org/fossil/timeline | Fossil self-hosting repository]
62 will work fine. (Dodgy code is always on a branch.) In the unlikely
63 event that you pick a version with a serious bug, it still won't
64 clobber your files. Fossil uses several
@@ -90,10 +90,14 @@
90
91 <li><p>
92 To build a statically linked binary (suitable for use inside a chroot
93 jail) add the <b>--static</b> option.
94
 
 
 
 
95 <li><p>
96 Other configuration options can be seen by running
97 <b>./configure --help</b>
98 </ol>
99
@@ -102,20 +106,26 @@
102
103 <ol type="a">
104 <li><p><i>Unix</i> → the configure-generated Makefile should work on
105 all Unix and Unix-like systems. Simply type "<b>make</b>".
106
107 <li><p><i>Unix without running "configure"</i> → if you prefer to avoid running configure, you
108 can also use: <b>make -f Makefile.classic</b>. You may want to make minor
109 edits to Makefile.classic to configure the build for your system.
 
110
111 <li><p><i>MinGW3.x (not 4.0)/MinGW-w64</i> → Use the mingw makefile:
112 "<b>make -f win/Makefile.mingw</b>". On a Windows box you will
113 need either Cygwin or Msys as build environment. On Cygwin, Linux
114 or Darwin you may want to make minor edits to win/Makefile.mingw
115 to configure the cross-compile environment.
116
 
 
 
 
 
117 Hint: don't use MinGW-4.0, it will compile but fossil won't work correctly, see
118 <a href="https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c">https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c</a>.
119
120 <li><p><i>MSVC</i> → Use the MSVC makefile. First
121 change to the "win/" subdirectory ("<b>cd win</b>") then run
@@ -134,10 +144,19 @@
134 nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
135 </pre></blockquote>
136 <blockquote><pre>
137 buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
138 </pre></blockquote>
 
 
 
 
 
 
 
 
 
139
140 <li><p><i>Cygwin</i> → The same as other Unix-like systems. It is
141 recommended to configure using: "<b>configure --disable-internal-sqlite</b>",
142 making sure you have the "libsqlite3-devel" , "zlib-devel" and
143 "openssl-devel" packages installed first.
@@ -146,12 +165,12 @@
146
147 <h2>3.0 Installing</h2>
148
149 <ol>
150 <li value="8">
151 <p>The finished binary is named "fossil" (or "fossil.exe" on Windows).
152 Put this binary in a
153 directory that is somewhere on your PATH environment variable.
154 It does not matter where.</p>
155
156 <li>
157 <p><b>(Optional:)</b>
@@ -167,14 +186,14 @@
167 Fossil manually, then refer to the
168 [./makefile.wiki | Fossil Build Process] document which describes
169 in detail what the makefiles do behind the scenes.
170
171 <li><p>
172 The fossil executable is self-contained and stand-alone and usually
173 requires no special libraries or other software to be installed. However,
174 the "--tk" option to the [/help/diff|diff command] requires that Tcl/Tk
175 be installed on the local machine. You can get Tcl/Tk from
176 [http://www.activestate.com/activetcl|ActiveState].
177
178 <li><p>
179 To build on older Macs (circa 2002, MacOS 10.2) edit the Makefile
180 generated by configure to add the following lines:
181
--- www/build.wiki
+++ www/build.wiki
@@ -26,39 +26,39 @@
26 <p><hr>
27
28 <h2>1.0 Obtaining The Source Code</h2>
29
30 <p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball
31 containing a snapshot of the <em>latest</em> version directly from
32 Fossil's own fossil repository. Additionally, source archives of
33 <em>released</em> versions of
34 fossil are available from the <a href="http://www.fossil-scm.org/download.html">downloads page</a>.
35 To obtain a development version of fossil, follow these steps:</p>
36
37 <ol>
38 <li><p>Point your web browser to
39 <a href="http://www.fossil-scm.org/">
40 http://www.fossil-scm.org/</a>.</p></li>
41
42 <li><p>Click on the
43 <a href="http://www.fossil-scm.org/fossil/timeline">Timeline</a>
44 link at the top of the page.</p></li>
45
46 <li><p>Select a version of of Fossil you want to download. The latest
47 version on the trunk branch is usually a good choice. Click on its
48 link.</p></li>
49
50 <li><p>Finally, click on one of the
51 "Zip Archive" or "Tarball" links, according to your preference.
52 These link will build a ZIP archive or a gzip-compressed tarball of the
53 complete source code and download it to your computer.
54 </ol>
55
56 <h2>Aside: Is it really safe to use an unreleased development version of
57 the Fossil source code?</h2>
58
59 Yes! Any check-in on the
60 [/timeline?t=trunk | trunk branch] of the Fossil
61 [http://fossil-scm.org/fossil/timeline | Fossil self-hosting repository]
62 will work fine. (Dodgy code is always on a branch.) In the unlikely
63 event that you pick a version with a serious bug, it still won't
64 clobber your files. Fossil uses several
@@ -90,10 +90,14 @@
90
91 <li><p>
92 To build a statically linked binary (suitable for use inside a chroot
93 jail) add the <b>--static</b> option.
94
95 <li><p>
96 To enable the native [./th1.md#tclEval | Tcl integration feature] feature,
97 add the <b>--with-tcl=1</b> and <b>--with-tcl-private-stubs=1</b> options.
98
99 <li><p>
100 Other configuration options can be seen by running
101 <b>./configure --help</b>
102 </ol>
103
@@ -102,20 +106,26 @@
106
107 <ol type="a">
108 <li><p><i>Unix</i> → the configure-generated Makefile should work on
109 all Unix and Unix-like systems. Simply type "<b>make</b>".
110
111 <li><p><i>Unix without running "configure"</i> → if you prefer to avoid
112 running configure, you can also use: <b>make -f Makefile.classic</b>. You may
113 want to make minor edits to Makefile.classic to configure the build for your
114 system.
115
116 <li><p><i>MinGW3.x (not 4.0)/MinGW-w64</i> → Use the mingw makefile:
117 "<b>make -f win/Makefile.mingw</b>". On a Windows box you will
118 need either Cygwin or Msys as build environment. On Cygwin, Linux
119 or Darwin you may want to make minor edits to win/Makefile.mingw
120 to configure the cross-compile environment.
121
122 To enable the native [./th1.md#tclEval | Tcl integration feature], use a
123 command line like the following (all on one line):
124
125 <b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b>
126
127 Hint: don't use MinGW-4.0, it will compile but fossil won't work correctly, see
128 <a href="https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c">https://www.fossil-scm.org/index.html/tktview/18cff45a4e210430e24c</a>.
129
130 <li><p><i>MSVC</i> → Use the MSVC makefile. First
131 change to the "win/" subdirectory ("<b>cd win</b>") then run
@@ -134,10 +144,19 @@
144 nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
145 </pre></blockquote>
146 <blockquote><pre>
147 buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin
148 </pre></blockquote>
149 To enable the optional native [./th1.md#tclEval | Tcl integration feature],
150 run one of the following commands or add the &quot;FOSSIL_ENABLE_TCL=1&quot;
151 argument to one of the other NMAKE command lines:
152 <blockquote><pre>
153 nmake /f Makefile.msc FOSSIL_ENABLE_TCL=1
154 </pre></blockquote>
155 <blockquote><pre>
156 buildmsvc.bat FOSSIL_ENABLE_TCL=1
157 </pre></blockquote>
158
159 <li><p><i>Cygwin</i> → The same as other Unix-like systems. It is
160 recommended to configure using: "<b>configure --disable-internal-sqlite</b>",
161 making sure you have the "libsqlite3-devel" , "zlib-devel" and
162 "openssl-devel" packages installed first.
@@ -146,12 +165,12 @@
165
166 <h2>3.0 Installing</h2>
167
168 <ol>
169 <li value="8">
170 <p>The finished binary is named "fossil" (or "fossil.exe" on Windows).
171 Put this binary in a
172 directory that is somewhere on your PATH environment variable.
173 It does not matter where.</p>
174
175 <li>
176 <p><b>(Optional:)</b>
@@ -167,14 +186,14 @@
186 Fossil manually, then refer to the
187 [./makefile.wiki | Fossil Build Process] document which describes
188 in detail what the makefiles do behind the scenes.
189
190 <li><p>
191 The fossil executable is self-contained and stand-alone and usually
192 requires no special libraries or other software to be installed. However,
193 the "--tk" option to the [/help/diff|diff command] requires that Tcl/Tk
194 be installed on the local machine. You can get Tcl/Tk from
195 [http://www.activestate.com/activetcl|ActiveState].
196
197 <li><p>
198 To build on older Macs (circa 2002, MacOS 10.2) edit the Makefile
199 generated by configure to add the following lines:
200
+36 -5
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,43 @@
11
<title>Change Log</title>
22
33
<h2>Changes for Version 1.33 (not released yet)</h2>
4
+ * Improved fork detection on [/help?cmd=update|fossil update],
5
+ [/help?cmd=status|fossil status] and related commands.
6
+ * Change the default skin to what used to be called "San Francisco Modern".
7
+ * Add the [/repo-tabsize] web page
48
* Add [/help?cmd=import|fossil import --svn], for importing a subversion
59
repository into fossil which was exported using "svnadmin dump".
10
+ * Add the "--compress-only" option to [/help?cmd=rebuild|fossil rebuild].
11
+ * Use a pie chart on the [/reports?view=byuser] page.
12
+ * Enhanced [/help?cmd=clean|fossil clean --verily] so that it ignores
13
+ keep-glob and ignore-glob settings. Added the -x alias for --verily.
14
+ * Add the --soft and --hard options to [/help?cmd=rm|fossil rm] and
15
+ [/help?cmd=mv|fossil mv]. The default is still --soft, but that is
16
+ now configurable at compile-time or by the mv-rm-files setting.
17
+ * Improved ability to [./customgraph.md|customize the timelime graph].
18
+ * Improvements to the [/sitemap] page.
19
+ * Automatically adjust the [/help?cmd=timeline|CLI timeline] to the terminal
20
+ width on Linux.
21
+ * Added <nowiki>[info commands] and [info vars]</nowiki> commands to TH1.
22
+ These commands perform the same function as their Tcl counterparts,
23
+ except they do not accept a pattern argument.
24
+ * Fix some obscure issues with TH1 expression processing.
25
+ * Fix titles in search results for documents that are not wiki, markdown,
26
+ or HTML.
27
+ * Formally translate TH1 to Tcl return codes and vice-versa, where
28
+ necessary, in the Tcl integration subsystem.
29
+ * Add [/help?cmd=leaves|fossil leaves -multiple], for finding multiple
30
+ leaves on the same branch.
31
+ * Added the "Blitz" skin option.
32
+ * Removed the ".fossil-settings/keep-glob" file. It should not have been
33
+ checked into the repository.
34
+ * Update the built-in SQLite to version 3.8.10.1.
35
+ * Made [/help?cmd=open|fossil open] honor ".fossil-settings/allow-symlinks".
36
+ * Allow [/help?cmd=add|fossil add] to be used on symlinks to nonexistent or
37
+ unreadable files in the same way as [/help?cmd=addremove|fossil addremove].
38
+ * Added fork warning to be issued if sync produced a fork
639
740
<h2>Changes for Version 1.32 (2015-03-14)</h2>
841
* When creating a new repository using [/help?cmd=init|fossil init], ensure
942
that the new repository is fully compatible with historical versions of
1043
Fossil by having a valid manifest as RID 1.
@@ -15,11 +48,11 @@
1548
* Add the --repolist option to server commands such as
1649
[/help?cmd=server|fossil server] or [/help?cmd=http|fossil http].
1750
* Added the "Xekri" skin.
1851
* Enhance the "ln=" query parameter on artifact displays to accept multiple
1952
ranges, separate by spaces (or "+" when URL-encoded).
20
- * Added [/help?cmd=forget|fossil forget] as an alias for
53
+ * Added [/help?cmd=forget|fossil forget] as an alias for
2154
[/help?cmd=rm|fossil rm].
2255
2356
<h2>Changes For Version 1.31 (2015-02-23)</h2>
2457
* Change the auxiliary schema by adding columns MLINK.ISAUX and MLINK.PMID
2558
columns to the schema, to support better drawing of file change graphs.
@@ -33,14 +66,12 @@
3366
enhancements to the search capabilities in subsequent releases.
3467
* Added form elements to some submenus (in particular the /timeline)
3568
for easier operation.
3669
* Added the --ifneeded option to [/help?cmd=rebuild|fossil rebuild].
3770
* Added "override skins" using the "skin:" line of the CGI script or
38
- using the --skin LABEL option on the
39
- [/help?cmd=server|server],
40
- [/help?cmd=ui|ui], or
41
- [/help?cmd=http|http] commands.
71
+ using the --skin LABEL option on the [/help?cmd=server|server],
72
+ [/help?cmd=ui|ui], or [/help?cmd=http|http] commands.
4273
* Embedded html documents that begin with
4374
&lt;doc class="fossil-doc"&gt; are displayed with standard
4475
headers and footers added.
4576
* Allow &lt;div style='...'&gt; markup in [/wiki_rules|wiki].
4677
* Renamed "Events" to "Technical Notes", while updating the technote
4778
4879
ADDED www/customgraph.md
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,43 @@
1 <title>Change Log</title>
2
3 <h2>Changes for Version 1.33 (not released yet)</h2>
 
 
 
 
4 * Add [/help?cmd=import|fossil import --svn], for importing a subversion
5 repository into fossil which was exported using "svnadmin dump".
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6
7 <h2>Changes for Version 1.32 (2015-03-14)</h2>
8 * When creating a new repository using [/help?cmd=init|fossil init], ensure
9 that the new repository is fully compatible with historical versions of
10 Fossil by having a valid manifest as RID 1.
@@ -15,11 +48,11 @@
15 * Add the --repolist option to server commands such as
16 [/help?cmd=server|fossil server] or [/help?cmd=http|fossil http].
17 * Added the "Xekri" skin.
18 * Enhance the "ln=" query parameter on artifact displays to accept multiple
19 ranges, separate by spaces (or "+" when URL-encoded).
20 * Added [/help?cmd=forget|fossil forget] as an alias for
21 [/help?cmd=rm|fossil rm].
22
23 <h2>Changes For Version 1.31 (2015-02-23)</h2>
24 * Change the auxiliary schema by adding columns MLINK.ISAUX and MLINK.PMID
25 columns to the schema, to support better drawing of file change graphs.
@@ -33,14 +66,12 @@
33 enhancements to the search capabilities in subsequent releases.
34 * Added form elements to some submenus (in particular the /timeline)
35 for easier operation.
36 * Added the --ifneeded option to [/help?cmd=rebuild|fossil rebuild].
37 * Added "override skins" using the "skin:" line of the CGI script or
38 using the --skin LABEL option on the
39 [/help?cmd=server|server],
40 [/help?cmd=ui|ui], or
41 [/help?cmd=http|http] commands.
42 * Embedded html documents that begin with
43 &lt;doc class="fossil-doc"&gt; are displayed with standard
44 headers and footers added.
45 * Allow &lt;div style='...'&gt; markup in [/wiki_rules|wiki].
46 * Renamed "Events" to "Technical Notes", while updating the technote
47
48 DDED www/customgraph.md
--- www/changes.wiki
+++ www/changes.wiki
@@ -1,10 +1,43 @@
1 <title>Change Log</title>
2
3 <h2>Changes for Version 1.33 (not released yet)</h2>
4 * Improved fork detection on [/help?cmd=update|fossil update],
5 [/help?cmd=status|fossil status] and related commands.
6 * Change the default skin to what used to be called "San Francisco Modern".
7 * Add the [/repo-tabsize] web page
8 * Add [/help?cmd=import|fossil import --svn], for importing a subversion
9 repository into fossil which was exported using "svnadmin dump".
10 * Add the "--compress-only" option to [/help?cmd=rebuild|fossil rebuild].
11 * Use a pie chart on the [/reports?view=byuser] page.
12 * Enhanced [/help?cmd=clean|fossil clean --verily] so that it ignores
13 keep-glob and ignore-glob settings. Added the -x alias for --verily.
14 * Add the --soft and --hard options to [/help?cmd=rm|fossil rm] and
15 [/help?cmd=mv|fossil mv]. The default is still --soft, but that is
16 now configurable at compile-time or by the mv-rm-files setting.
17 * Improved ability to [./customgraph.md|customize the timelime graph].
18 * Improvements to the [/sitemap] page.
19 * Automatically adjust the [/help?cmd=timeline|CLI timeline] to the terminal
20 width on Linux.
21 * Added <nowiki>[info commands] and [info vars]</nowiki> commands to TH1.
22 These commands perform the same function as their Tcl counterparts,
23 except they do not accept a pattern argument.
24 * Fix some obscure issues with TH1 expression processing.
25 * Fix titles in search results for documents that are not wiki, markdown,
26 or HTML.
27 * Formally translate TH1 to Tcl return codes and vice-versa, where
28 necessary, in the Tcl integration subsystem.
29 * Add [/help?cmd=leaves|fossil leaves -multiple], for finding multiple
30 leaves on the same branch.
31 * Added the "Blitz" skin option.
32 * Removed the ".fossil-settings/keep-glob" file. It should not have been
33 checked into the repository.
34 * Update the built-in SQLite to version 3.8.10.1.
35 * Made [/help?cmd=open|fossil open] honor ".fossil-settings/allow-symlinks".
36 * Allow [/help?cmd=add|fossil add] to be used on symlinks to nonexistent or
37 unreadable files in the same way as [/help?cmd=addremove|fossil addremove].
38 * Added fork warning to be issued if sync produced a fork
39
40 <h2>Changes for Version 1.32 (2015-03-14)</h2>
41 * When creating a new repository using [/help?cmd=init|fossil init], ensure
42 that the new repository is fully compatible with historical versions of
43 Fossil by having a valid manifest as RID 1.
@@ -15,11 +48,11 @@
48 * Add the --repolist option to server commands such as
49 [/help?cmd=server|fossil server] or [/help?cmd=http|fossil http].
50 * Added the "Xekri" skin.
51 * Enhance the "ln=" query parameter on artifact displays to accept multiple
52 ranges, separate by spaces (or "+" when URL-encoded).
53 * Added [/help?cmd=forget|fossil forget] as an alias for
54 [/help?cmd=rm|fossil rm].
55
56 <h2>Changes For Version 1.31 (2015-02-23)</h2>
57 * Change the auxiliary schema by adding columns MLINK.ISAUX and MLINK.PMID
58 columns to the schema, to support better drawing of file change graphs.
@@ -33,14 +66,12 @@
66 enhancements to the search capabilities in subsequent releases.
67 * Added form elements to some submenus (in particular the /timeline)
68 for easier operation.
69 * Added the --ifneeded option to [/help?cmd=rebuild|fossil rebuild].
70 * Added "override skins" using the "skin:" line of the CGI script or
71 using the --skin LABEL option on the [/help?cmd=server|server],
72 [/help?cmd=ui|ui], or [/help?cmd=http|http] commands.
 
 
73 * Embedded html documents that begin with
74 &lt;doc class="fossil-doc"&gt; are displayed with standard
75 headers and footers added.
76 * Allow &lt;div style='...'&gt; markup in [/wiki_rules|wiki].
77 * Renamed "Events" to "Technical Notes", while updating the technote
78
79 DDED www/customgraph.md
--- a/www/customgraph.md
+++ b/www/customgraph.md
@@ -0,0 +1,144 @@
1
+# Customizing the Timeline Graph
2
+
3
+Beginning with version 1.33, Fossil gives users and skin authors significantly
4
+more control over the look and feel of the timeline graph.
5
+
6
+## <a id="basic-style"></a>Basic Style Options
7
+
8
+Fossil includes several options for changing the graph's style without having
9
+to delve into CSS. These can be found in the details.txt file of your skin or
10
+under Admin/Skins/D###`timeline-arrowheads`
11
+
12
+ Set this to `0` to hide arrowheads on primary child lines.
13
+
14
+* ### Set this to `node s`**
15
+
16
+ Set this to `1` to### `timeline-color-graph-line`
17
+
18
+ Set this to `1` to colorize### `white-foreground`
19
+
20
+ Set this to `round`**
21
+
22
+ Seses white (or any light color) text.
23
+ This tells Fossil to generate darker background colors for branches.
24
+
25
+
26
+## <a id="adv-style"></a>Advanced Styling
27
+
28
+If the above options aren't enough for you, it's time to get your hands dirty
29
+with CSS. To get started, I recommend first copying all the [graph-related CSS
30
+rules](#default-css) to your stylesheet. Then it's simply a matter of making
31
+the necessary changes to achieve the look you want. So, next, let's look at the
32
+various graph elements and what purpose they serve.
33
+
34
+Each element used to construct the timeline graph falls into one of two
35
+categories: visible elements and positioning elements. We'll start with the
36
+latter, less obvious type.
37
+
38
+## <a id="pos-elems"></a>Positioning Elements
39
+
40
+These elements aren't intended to be seen. They're only used to h### <a id="
41
+
42
+ Set the left and right margins on this class to give the desired amount
43
+ of space between tunt
44
+ of space between the graph and its adjacent columns in the timeline.
45
+
46
+ #### Ad ditional Classes
47
+ **Additional Classes**
48
+
49
+ * `.sel`: See [`.tl-node`](#tl-node) ### <a id="tl-rail"></a>`.tl-rail`tl-rail"></a>**`.tl-rail`**
50
+
51
+ Think of rails as invisibl Think of rails as invisible vertical lines o placed. The more simultaneous branches in a graph, the more rails required
52
+ to draw it. Setting the `width` property on this class determines the
53
+ maximum spacing between rails. This spacing is automatically reduced as
54
+ the number of rails increases. If you change the `width` of `.tl-node`
55
+ elements, you'll probably need to ch###ing the Timeline Graph
56
+
57
+Begi# Customizing theoreground`**
58
+
59
+ Set this to `1` if your skin uses white (or any light color) text.
60
+ T`
61
+
62
+ Set this to `round`**
63
+
64
+ Set this to `1` if your skin uses white (or any light color) text.
65
+ This tells Fossil to generate darker background colors for branches.
66
+
67
+
68
+## <a id="adv-style"></a>Advanced Styling
69
+
70
+If the above options aren't enough for you, it's time to get your hands dirty
71
+with CSS. To get started, I recommend first copying all the [graph-related CSS
72
+rules](#default-css) to yourcessary changes to achieve the look you want. So, next, let's look at the
73
+various graph elements and what purpose they serve.
74
+
75
+Each element used to construct the timeline graph falls into one of two
76
+categories: visible elements and positioning elements. We'll start with the
77
+latter, less obvious type.
78
+
79
+## <a id="pos-elems"></a>Positioning Elements
80
+
81
+These elements aren't intended to be seen. They're only used to h### <a id="
82
+
83
+ Set the left and right margins on this class to give the desired amount
84
+ of space between the graph and its adjaidth` of `.tl-node`
85
+ elements, you'll probably need to ch###ing the Timeline Graph
86
+
87
+Begi# Customizing theoreground`**
88
+
89
+ Set this to ` Think of rails as invisibl node`](#tl-node) ### <a id="tl-rail"></a>`.tl-rail`tl-rail"></a>**`.tl-rail`**
90
+
91
+ Thin more simultaneous branches in a graph, the more rails required
92
+ to draw it. Setting the `width` property on this class determines the
93
+ maximum spacing between rails. This spacing is automatically reduced as
94
+ the number of rails increases. If you change the `width` of `.tl-node`
95
+ elements, you'll probably need to ch###ing the Timeline Graph
96
+
97
+Begi# Customizing theoreground`**
98
+
99
+ Set this to `1` if your skin uses white (or any light color) text.
100
+ T`
101
+
102
+ Set this to `round`**
103
+
104
+ Set this to `1` if your skin uses white (or any light color) text.
105
+ This tells Fossil to generate darker background colors for branches.
106
+
107
+
108
+## <a id="adv-style"></a>Advanced Styling
109
+
110
+If the above options ar round: transparent;
111
+ border: 0 dotted #000;
112
+ }
113
+ . d #000;
114
+ }
115
+ .tl-line.merge.h {
116
+ border-top-width: 1px;
117
+ -#### Additional Classesl-node) for more infasses**
118
+
119
+ * `.merge`: A merge line.
120
+
121
+ * skin authors significantly
122
+more# Customizing the Timeline Graph
123
+
124
+Beginning with version 1.33, Fossil gives users and skin authors significantly
125
+more control over the look and feel of the timeline graph.
126
+
127
+## <a id="basic-style"></a>Basic Sty skin authors significantly
128
+more control over the look and feel of the timeline graph.
129
+
130
+## <a id="basic-style"></a>Basic Style Options
131
+
132
+Fossil includes several options for changing the graph's style without having
133
+to delve into CSS. These can be found in the details.txt file of your skin or
134
+under Admin/Skins/D###`timeline-arrowheads`
135
+
136
+ Set this to `0` to hide arrowheads on primary child lines.
137
+
138
+* ### Set this to `nodes`**
139
+
140
+ Set this to `1` to### `timeline-color-graph-line`
141
+
142
+ Set this to `1` to colorize### `white-foreground`
143
+
144
+ Set this to `round`**
--- a/www/customgraph.md
+++ b/www/customgraph.md
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
--- a/www/customgraph.md
+++ b/www/customgraph.md
@@ -0,0 +1,144 @@
1 # Customizing the Timeline Graph
2
3 Beginning with version 1.33, Fossil gives users and skin authors significantly
4 more control over the look and feel of the timeline graph.
5
6 ## <a id="basic-style"></a>Basic Style Options
7
8 Fossil includes several options for changing the graph's style without having
9 to delve into CSS. These can be found in the details.txt file of your skin or
10 under Admin/Skins/D###`timeline-arrowheads`
11
12 Set this to `0` to hide arrowheads on primary child lines.
13
14 * ### Set this to `node s`**
15
16 Set this to `1` to### `timeline-color-graph-line`
17
18 Set this to `1` to colorize### `white-foreground`
19
20 Set this to `round`**
21
22 Seses white (or any light color) text.
23 This tells Fossil to generate darker background colors for branches.
24
25
26 ## <a id="adv-style"></a>Advanced Styling
27
28 If the above options aren't enough for you, it's time to get your hands dirty
29 with CSS. To get started, I recommend first copying all the [graph-related CSS
30 rules](#default-css) to your stylesheet. Then it's simply a matter of making
31 the necessary changes to achieve the look you want. So, next, let's look at the
32 various graph elements and what purpose they serve.
33
34 Each element used to construct the timeline graph falls into one of two
35 categories: visible elements and positioning elements. We'll start with the
36 latter, less obvious type.
37
38 ## <a id="pos-elems"></a>Positioning Elements
39
40 These elements aren't intended to be seen. They're only used to h### <a id="
41
42 Set the left and right margins on this class to give the desired amount
43 of space between tunt
44 of space between the graph and its adjacent columns in the timeline.
45
46 #### Ad ditional Classes
47 **Additional Classes**
48
49 * `.sel`: See [`.tl-node`](#tl-node) ### <a id="tl-rail"></a>`.tl-rail`tl-rail"></a>**`.tl-rail`**
50
51 Think of rails as invisibl Think of rails as invisible vertical lines o placed. The more simultaneous branches in a graph, the more rails required
52 to draw it. Setting the `width` property on this class determines the
53 maximum spacing between rails. This spacing is automatically reduced as
54 the number of rails increases. If you change the `width` of `.tl-node`
55 elements, you'll probably need to ch###ing the Timeline Graph
56
57 Begi# Customizing theoreground`**
58
59 Set this to `1` if your skin uses white (or any light color) text.
60 T`
61
62 Set this to `round`**
63
64 Set this to `1` if your skin uses white (or any light color) text.
65 This tells Fossil to generate darker background colors for branches.
66
67
68 ## <a id="adv-style"></a>Advanced Styling
69
70 If the above options aren't enough for you, it's time to get your hands dirty
71 with CSS. To get started, I recommend first copying all the [graph-related CSS
72 rules](#default-css) to yourcessary changes to achieve the look you want. So, next, let's look at the
73 various graph elements and what purpose they serve.
74
75 Each element used to construct the timeline graph falls into one of two
76 categories: visible elements and positioning elements. We'll start with the
77 latter, less obvious type.
78
79 ## <a id="pos-elems"></a>Positioning Elements
80
81 These elements aren't intended to be seen. They're only used to h### <a id="
82
83 Set the left and right margins on this class to give the desired amount
84 of space between the graph and its adjaidth` of `.tl-node`
85 elements, you'll probably need to ch###ing the Timeline Graph
86
87 Begi# Customizing theoreground`**
88
89 Set this to ` Think of rails as invisibl node`](#tl-node) ### <a id="tl-rail"></a>`.tl-rail`tl-rail"></a>**`.tl-rail`**
90
91 Thin more simultaneous branches in a graph, the more rails required
92 to draw it. Setting the `width` property on this class determines the
93 maximum spacing between rails. This spacing is automatically reduced as
94 the number of rails increases. If you change the `width` of `.tl-node`
95 elements, you'll probably need to ch###ing the Timeline Graph
96
97 Begi# Customizing theoreground`**
98
99 Set this to `1` if your skin uses white (or any light color) text.
100 T`
101
102 Set this to `round`**
103
104 Set this to `1` if your skin uses white (or any light color) text.
105 This tells Fossil to generate darker background colors for branches.
106
107
108 ## <a id="adv-style"></a>Advanced Styling
109
110 If the above options ar round: transparent;
111 border: 0 dotted #000;
112 }
113 . d #000;
114 }
115 .tl-line.merge.h {
116 border-top-width: 1px;
117 -#### Additional Classesl-node) for more infasses**
118
119 * `.merge`: A merge line.
120
121 * skin authors significantly
122 more# Customizing the Timeline Graph
123
124 Beginning with version 1.33, Fossil gives users and skin authors significantly
125 more control over the look and feel of the timeline graph.
126
127 ## <a id="basic-style"></a>Basic Sty skin authors significantly
128 more control over the look and feel of the timeline graph.
129
130 ## <a id="basic-style"></a>Basic Style Options
131
132 Fossil includes several options for changing the graph's style without having
133 to delve into CSS. These can be found in the details.txt file of your skin or
134 under Admin/Skins/D###`timeline-arrowheads`
135
136 Set this to `0` to hide arrowheads on primary child lines.
137
138 * ### Set this to `nodes`**
139
140 Set this to `1` to### `timeline-color-graph-line`
141
142 Set this to `1` to colorize### `white-foreground`
143
144 Set this to `round`**
--- 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,18 @@
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.
237
+
238
+See Also
239
+--------
240
+
241
+* [Customizing the Timeline Graph](customgraph.md)
233242
--- 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,18 @@
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,18 @@
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
238 See Also
239 --------
240
241 * [Customizing the Timeline Graph](customgraph.md)
242
+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
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -17,10 +17,11 @@
1717
checkin.wiki {Check-in Checklist}
1818
changes.wiki {Fossil Changelog}
1919
copyright-release.html {Contributor License Agreement}
2020
concepts.wiki {Fossil Core Concepts}
2121
contribute.wiki {Contributing Code or Documentation To The Fossil Project}
22
+ customgraph.md {Theming: Customizing the Timeline Graph}
2223
customskin.md {Theming: Customizing The Appearance of Web Pages}
2324
custom_ticket.wiki {Customizing The Ticket System}
2425
delta_encoder_algorithm.wiki {Fossil Delta Encoding Algorithm}
2526
delta_format.wiki {Fossil Delta Format}
2627
embeddeddoc.wiki {Embedded Project Documentation}
2728
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -17,10 +17,11 @@
17 checkin.wiki {Check-in Checklist}
18 changes.wiki {Fossil Changelog}
19 copyright-release.html {Contributor License Agreement}
20 concepts.wiki {Fossil Core Concepts}
21 contribute.wiki {Contributing Code or Documentation To The Fossil Project}
 
22 customskin.md {Theming: Customizing The Appearance of Web Pages}
23 custom_ticket.wiki {Customizing The Ticket System}
24 delta_encoder_algorithm.wiki {Fossil Delta Encoding Algorithm}
25 delta_format.wiki {Fossil Delta Format}
26 embeddeddoc.wiki {Embedded Project Documentation}
27
--- www/mkindex.tcl
+++ www/mkindex.tcl
@@ -17,10 +17,11 @@
17 checkin.wiki {Check-in Checklist}
18 changes.wiki {Fossil Changelog}
19 copyright-release.html {Contributor License Agreement}
20 concepts.wiki {Fossil Core Concepts}
21 contribute.wiki {Contributing Code or Documentation To The Fossil Project}
22 customgraph.md {Theming: Customizing the Timeline Graph}
23 customskin.md {Theming: Customizing The Appearance of Web Pages}
24 custom_ticket.wiki {Customizing The Ticket System}
25 delta_encoder_algorithm.wiki {Fossil Delta Encoding Algorithm}
26 delta_format.wiki {Fossil Delta Format}
27 embeddeddoc.wiki {Embedded Project Documentation}
28
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -34,12 +34,12 @@
3434
<li><a href="private.wiki">Branches &mdash; Creating, Syncing, and Deleting Private</a></li>
3535
<li><a href="branching.wiki">Branching, Forking, Merging, and Tagging</a></li>
3636
<li><a href="bugtheory.wiki">Bug Tracking In Fossil</a></li>
3737
<li><a href="makefile.wiki">Build Process &mdash; The Fossil</a></li>
3838
<li><a href="changes.wiki">Changelog &mdash; Fossil</a></li>
39
-<li><a href="checkin.wiki">Check-in Checklist</a></li>
4039
<li><a href="checkin_names.wiki">Check-in And Version Names</a></li>
40
+<li><a href="checkin.wiki">Check-in Checklist</a></li>
4141
<li><a href="checkin.wiki">Checklist &mdash; Check-in</a></li>
4242
<li><a href="../test/release-checklist.wiki">Checklist &mdash; Pre-Release Testing</a></li>
4343
<li><a href="foss-cklist.wiki">Checklist For Successful Open-Source Projects</a></li>
4444
<li><a href="selfcheck.wiki">Checks &mdash; Fossil Repository Integrity Self</a></li>
4545
<li><a href="contribute.wiki">Code or Documentation To The Fossil Project &mdash; Contributing</a></li>
@@ -54,10 +54,11 @@
5454
<li><a href="newrepo.wiki">Create A New Fossil Repository &mdash; How To</a></li>
5555
<li><a href="private.wiki">Creating, Syncing, and Deleting Private Branches</a></li>
5656
<li><a href="qandc.wiki">Criticisms &mdash; Questions And</a></li>
5757
<li><a href="customskin.md">Customizing The Appearance of Web Pages &mdash; Theming:</a></li>
5858
<li><a href="custom_ticket.wiki">Customizing The Ticket System</a></li>
59
+<li><a href="customgraph.md">Customizing the Timeline Graph &mdash; Theming:</a></li>
5960
<li><a href="tech_overview.wiki">Databases Used By Fossil &mdash; SQLite</a></li>
6061
<li><a href="antibot.wiki">Defense against Spiders and Bots</a></li>
6162
<li><a href="shunning.wiki">Deleting Content From Fossil &mdash; Shunning:</a></li>
6263
<li><a href="private.wiki">Deleting Private Branches &mdash; Creating, Syncing, and</a></li>
6364
<li><a href="delta_encoder_algorithm.wiki">Delta Encoding Algorithm &mdash; Fossil</a></li>
@@ -95,10 +96,11 @@
9596
<li><a href="inout.wiki">From Git &mdash; Import And Export To And</a></li>
9697
<li><a href="quotes.wiki">General &mdash; Quotes: What People Are Saying About Fossil, Git, and DVCSes in</a></li>
9798
<li><a href="fossil-v-git.wiki">Git &mdash; Fossil Versus</a></li>
9899
<li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
99100
<li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
101
+<li><a href="customgraph.md">Graph &mdash; Theming: Customizing the Timeline</a></li>
100102
<li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
101103
<li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
102104
<li><a href="hacker-howto.wiki">Hacker How-To</a></li>
103105
<li><a href="adding_code.wiki">Hacking Fossil</a></li>
104106
<li><a href="hints.wiki">Hints &mdash; Fossil Tips And Usage</a></li>
@@ -176,13 +178,15 @@
176178
<li><a href="sync.wiki">The Fossil Sync Protocol</a></li>
177179
<li><a href="tickets.wiki">The Fossil Ticket System</a></li>
178180
<li><a href="webui.wiki">The Fossil Web Interface</a></li>
179181
<li><a href="th1.md">The TH1 Scripting Language</a></li>
180182
<li><a href="customskin.md">Theming: Customizing The Appearance of Web Pages</a></li>
183
+<li><a href="customgraph.md">Theming: Customizing the Timeline Graph</a></li>
181184
<li><a href="theory1.wiki">Thoughts On The Design Of The Fossil DVCS</a></li>
182185
<li><a href="custom_ticket.wiki">Ticket System &mdash; Customizing The</a></li>
183186
<li><a href="tickets.wiki">Ticket System &mdash; The Fossil</a></li>
187
+<li><a href="customgraph.md">Timeline Graph &mdash; Theming: Customizing the</a></li>
184188
<li><a href="hints.wiki">Tips And Usage Hints &mdash; Fossil</a></li>
185189
<li><a href="bugtheory.wiki">Tracking In Fossil &mdash; Bug</a></li>
186190
<li><a href="fiveminutes.wiki">Update and Running in 5 Minutes as a Single User</a></li>
187191
<li><a href="hints.wiki">Usage Hints &mdash; Fossil Tips And</a></li>
188192
<li><a href="fiveminutes.wiki">User &mdash; Update and Running in 5 Minutes as a Single</a></li>
189193
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -34,12 +34,12 @@
34 <li><a href="private.wiki">Branches &mdash; Creating, Syncing, and Deleting Private</a></li>
35 <li><a href="branching.wiki">Branching, Forking, Merging, and Tagging</a></li>
36 <li><a href="bugtheory.wiki">Bug Tracking In Fossil</a></li>
37 <li><a href="makefile.wiki">Build Process &mdash; The Fossil</a></li>
38 <li><a href="changes.wiki">Changelog &mdash; Fossil</a></li>
39 <li><a href="checkin.wiki">Check-in Checklist</a></li>
40 <li><a href="checkin_names.wiki">Check-in And Version Names</a></li>
 
41 <li><a href="checkin.wiki">Checklist &mdash; Check-in</a></li>
42 <li><a href="../test/release-checklist.wiki">Checklist &mdash; Pre-Release Testing</a></li>
43 <li><a href="foss-cklist.wiki">Checklist For Successful Open-Source Projects</a></li>
44 <li><a href="selfcheck.wiki">Checks &mdash; Fossil Repository Integrity Self</a></li>
45 <li><a href="contribute.wiki">Code or Documentation To The Fossil Project &mdash; Contributing</a></li>
@@ -54,10 +54,11 @@
54 <li><a href="newrepo.wiki">Create A New Fossil Repository &mdash; How To</a></li>
55 <li><a href="private.wiki">Creating, Syncing, and Deleting Private Branches</a></li>
56 <li><a href="qandc.wiki">Criticisms &mdash; Questions And</a></li>
57 <li><a href="customskin.md">Customizing The Appearance of Web Pages &mdash; Theming:</a></li>
58 <li><a href="custom_ticket.wiki">Customizing The Ticket System</a></li>
 
59 <li><a href="tech_overview.wiki">Databases Used By Fossil &mdash; SQLite</a></li>
60 <li><a href="antibot.wiki">Defense against Spiders and Bots</a></li>
61 <li><a href="shunning.wiki">Deleting Content From Fossil &mdash; Shunning:</a></li>
62 <li><a href="private.wiki">Deleting Private Branches &mdash; Creating, Syncing, and</a></li>
63 <li><a href="delta_encoder_algorithm.wiki">Delta Encoding Algorithm &mdash; Fossil</a></li>
@@ -95,10 +96,11 @@
95 <li><a href="inout.wiki">From Git &mdash; Import And Export To And</a></li>
96 <li><a href="quotes.wiki">General &mdash; Quotes: What People Are Saying About Fossil, Git, and DVCSes in</a></li>
97 <li><a href="fossil-v-git.wiki">Git &mdash; Fossil Versus</a></li>
98 <li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
99 <li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
 
100 <li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
101 <li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
102 <li><a href="hacker-howto.wiki">Hacker How-To</a></li>
103 <li><a href="adding_code.wiki">Hacking Fossil</a></li>
104 <li><a href="hints.wiki">Hints &mdash; Fossil Tips And Usage</a></li>
@@ -176,13 +178,15 @@
176 <li><a href="sync.wiki">The Fossil Sync Protocol</a></li>
177 <li><a href="tickets.wiki">The Fossil Ticket System</a></li>
178 <li><a href="webui.wiki">The Fossil Web Interface</a></li>
179 <li><a href="th1.md">The TH1 Scripting Language</a></li>
180 <li><a href="customskin.md">Theming: Customizing The Appearance of Web Pages</a></li>
 
181 <li><a href="theory1.wiki">Thoughts On The Design Of The Fossil DVCS</a></li>
182 <li><a href="custom_ticket.wiki">Ticket System &mdash; Customizing The</a></li>
183 <li><a href="tickets.wiki">Ticket System &mdash; The Fossil</a></li>
 
184 <li><a href="hints.wiki">Tips And Usage Hints &mdash; Fossil</a></li>
185 <li><a href="bugtheory.wiki">Tracking In Fossil &mdash; Bug</a></li>
186 <li><a href="fiveminutes.wiki">Update and Running in 5 Minutes as a Single User</a></li>
187 <li><a href="hints.wiki">Usage Hints &mdash; Fossil Tips And</a></li>
188 <li><a href="fiveminutes.wiki">User &mdash; Update and Running in 5 Minutes as a Single</a></li>
189
--- www/permutedindex.html
+++ www/permutedindex.html
@@ -34,12 +34,12 @@
34 <li><a href="private.wiki">Branches &mdash; Creating, Syncing, and Deleting Private</a></li>
35 <li><a href="branching.wiki">Branching, Forking, Merging, and Tagging</a></li>
36 <li><a href="bugtheory.wiki">Bug Tracking In Fossil</a></li>
37 <li><a href="makefile.wiki">Build Process &mdash; The Fossil</a></li>
38 <li><a href="changes.wiki">Changelog &mdash; Fossil</a></li>
 
39 <li><a href="checkin_names.wiki">Check-in And Version Names</a></li>
40 <li><a href="checkin.wiki">Check-in Checklist</a></li>
41 <li><a href="checkin.wiki">Checklist &mdash; Check-in</a></li>
42 <li><a href="../test/release-checklist.wiki">Checklist &mdash; Pre-Release Testing</a></li>
43 <li><a href="foss-cklist.wiki">Checklist For Successful Open-Source Projects</a></li>
44 <li><a href="selfcheck.wiki">Checks &mdash; Fossil Repository Integrity Self</a></li>
45 <li><a href="contribute.wiki">Code or Documentation To The Fossil Project &mdash; Contributing</a></li>
@@ -54,10 +54,11 @@
54 <li><a href="newrepo.wiki">Create A New Fossil Repository &mdash; How To</a></li>
55 <li><a href="private.wiki">Creating, Syncing, and Deleting Private Branches</a></li>
56 <li><a href="qandc.wiki">Criticisms &mdash; Questions And</a></li>
57 <li><a href="customskin.md">Customizing The Appearance of Web Pages &mdash; Theming:</a></li>
58 <li><a href="custom_ticket.wiki">Customizing The Ticket System</a></li>
59 <li><a href="customgraph.md">Customizing the Timeline Graph &mdash; Theming:</a></li>
60 <li><a href="tech_overview.wiki">Databases Used By Fossil &mdash; SQLite</a></li>
61 <li><a href="antibot.wiki">Defense against Spiders and Bots</a></li>
62 <li><a href="shunning.wiki">Deleting Content From Fossil &mdash; Shunning:</a></li>
63 <li><a href="private.wiki">Deleting Private Branches &mdash; Creating, Syncing, and</a></li>
64 <li><a href="delta_encoder_algorithm.wiki">Delta Encoding Algorithm &mdash; Fossil</a></li>
@@ -95,10 +96,11 @@
96 <li><a href="inout.wiki">From Git &mdash; Import And Export To And</a></li>
97 <li><a href="quotes.wiki">General &mdash; Quotes: What People Are Saying About Fossil, Git, and DVCSes in</a></li>
98 <li><a href="fossil-v-git.wiki">Git &mdash; Fossil Versus</a></li>
99 <li><a href="inout.wiki">Git &mdash; Import And Export To And From</a></li>
100 <li><a href="quotes.wiki">Git, and DVCSes in General &mdash; Quotes: What People Are Saying About Fossil,</a></li>
101 <li><a href="customgraph.md">Graph &mdash; Theming: Customizing the Timeline</a></li>
102 <li><a href="quickstart.wiki">Guide &mdash; Fossil Quick Start</a></li>
103 <li><a href="style.wiki">Guidelines &mdash; Source Code Style</a></li>
104 <li><a href="hacker-howto.wiki">Hacker How-To</a></li>
105 <li><a href="adding_code.wiki">Hacking Fossil</a></li>
106 <li><a href="hints.wiki">Hints &mdash; Fossil Tips And Usage</a></li>
@@ -176,13 +178,15 @@
178 <li><a href="sync.wiki">The Fossil Sync Protocol</a></li>
179 <li><a href="tickets.wiki">The Fossil Ticket System</a></li>
180 <li><a href="webui.wiki">The Fossil Web Interface</a></li>
181 <li><a href="th1.md">The TH1 Scripting Language</a></li>
182 <li><a href="customskin.md">Theming: Customizing The Appearance of Web Pages</a></li>
183 <li><a href="customgraph.md">Theming: Customizing the Timeline Graph</a></li>
184 <li><a href="theory1.wiki">Thoughts On The Design Of The Fossil DVCS</a></li>
185 <li><a href="custom_ticket.wiki">Ticket System &mdash; Customizing The</a></li>
186 <li><a href="tickets.wiki">Ticket System &mdash; The Fossil</a></li>
187 <li><a href="customgraph.md">Timeline Graph &mdash; Theming: Customizing the</a></li>
188 <li><a href="hints.wiki">Tips And Usage Hints &mdash; Fossil</a></li>
189 <li><a href="bugtheory.wiki">Tracking In Fossil &mdash; Bug</a></li>
190 <li><a href="fiveminutes.wiki">Update and Running in 5 Minutes as a Single User</a></li>
191 <li><a href="hints.wiki">Usage Hints &mdash; Fossil Tips And</a></li>
192 <li><a href="fiveminutes.wiki">User &mdash; Update and Running in 5 Minutes as a Single</a></li>
193
+414 -11
--- www/th1.md
+++ www/th1.md
@@ -5,22 +5,22 @@
55
content in Fossil.
66
77
Origins
88
-------
99
10
-TH1 began as a minimalist re-implementation of the TCL scripting language.
10
+TH1 began as a minimalist re-implementation of the Tcl scripting language.
1111
There was a need to test the SQLite library on Symbian phones, but at that
1212
time all of the test cases for SQLite were written in Tcl and Tcl could not
1313
be easily compiled on the SymbianOS. So TH1 was developed as a cut-down
14
-version of TCL that would facilitate running the SQLite test scripts on
14
+version of Tcl that would facilitate running the SQLite test scripts on
1515
SymbianOS.
1616
1717
The testing of SQLite on SymbianOS was eventually accomplished by other
18
-means. But Fossil was first being designed at about the same time.
19
-Early prototypes of Fossil were written in pure TCL. But as the development
20
-shifted toward the use of C-code, the need arose to have a TCL-like
21
-scripting language to help with code generation. TH1 was small and
18
+means. But Fossil was first being designed at about the same time.
19
+Early prototypes of Fossil were written in pure Tcl. But as the development
20
+shifted toward the use of C-code, the need arose to have a Tcl-like
21
+scripting language to help with code generation. TH1 was small and
2222
light-weight and used minimal resources and seemed ideally suited for the
2323
task.
2424
2525
The name "TH1" stands "Test Harness 1", since that was its original purpose.
2626
@@ -78,11 +78,11 @@
7878
just a single command.
7979
8080
Summary of Core TH1 Commands
8181
----------------------------
8282
83
-The original TCL language after when TH1 is modeled has a very rich
83
+The original Tcl language after when TH1 is modeled has a very rich
8484
repertoire of commands. TH1, as it is designed to be minimalist and
8585
embedded has a greatly reduced command set. The following bullets
8686
summarize the commands available in TH1:
8787
8888
* break
@@ -90,11 +90,13 @@
9090
* continue
9191
* error ?STRING?
9292
* expr EXPR
9393
* for INIT-SCRIPT TEST-EXPR NEXT-SCRIPT BODY-SCRIPT
9494
* if EXPR SCRIPT (elseif EXPR SCRIPT)* ?else SCRIPT?
95
+ * info commands
9596
* info exists VARNAME
97
+ * info vars
9698
* lindex LIST INDEX
9799
* list ARG ...
98100
* llength LIST
99101
* proc NAME ARG-LIST BODY-SCRIPT
100102
* rename OLD NEW
@@ -109,12 +111,12 @@
109111
* string repeat STRING COUNT
110112
* unset VARNAME
111113
* uplevel ?LEVEL? SCRIPT
112114
* upvar ?FRAME? OTHERVAR MYVAR ?OTHERVAR MYVAR?
113115
114
-All of the above commands works as in the original TCL. Refer to the
115
-TCL documentation for details.
116
+All of the above commands works as in the original Tcl. Refer to the
117
+Tcl documentation for details.
116118
117119
TH1 Extended Commands
118120
---------------------
119121
120122
There are many new commands added to TH1 and used to access the special
@@ -128,16 +130,16 @@
128130
* date
129131
* decorate
130132
* enable_output
131133
* getParameter
132134
* globalState
133
- * httpize
134135
* hascap
135136
* hasfeature
136137
* html
137138
* htmlize
138139
* http
140
+ * httpize
139141
* linecount
140142
* puts
141143
* query
142144
* randhex
143145
* regexp
@@ -147,20 +149,421 @@
147149
* searchable
148150
* setParameter
149151
* setting
150152
* styleHeader
151153
* styleFooter
154
+ * tclEval
155
+ * tclExpr
156
+ * tclInvoke
152157
* tclReady
153158
* trace
154159
* stime
155160
* utime
156161
* wiki
157162
158163
Each of the commands above is documented by a block comment above their
159
-implementation in the th_main.c source file.
164
+implementation in the th\_main.c or th\_tcl.c source files.
165
+
166
+All commands starting with "tcl", with the exception of "tclReady",
167
+require the Tcl integration subsystem be included at compile-time.
168
+Additionally, the "tcl" repository setting must be enabled at runtime
169
+in order to successfully make use of these commands.
170
+
171
+<a name="anoncap"></a>TH1 anoncap Command
172
+-----------------------------------------
173
+
174
+ * anoncap STRING...
175
+
176
+Returns true if the anonymous user has all of the capabilities listed
177
+in STRING.
178
+
179
+<a name="anycap"></a>TH1 anycap Command
180
+---------------------------------------
181
+
182
+ * anycap STRING
183
+
184
+Returns true if the current user user has any one of the capabilities
185
+listed in STRING.
186
+
187
+<a name="artifact"></a>TH1 artifact Command
188
+-------------------------------------------
189
+
190
+ * artifact ID ?FILENAME?
191
+
192
+Attempts to locate the specified artifact and return its contents. An
193
+error is generated if the repository is not open or the artifact cannot
194
+be found.
195
+
196
+<a name="checkout"></a>TH1 checkout Command
197
+-------------------------------------------
198
+
199
+ * checkout ?BOOLEAN?
200
+
201
+Return the fully qualified directory name of the current checkout or an
202
+empty string if it is not available. Optionally, it will attempt to find
203
+the current checkout, opening the configuration ("user") database and the
204
+repository as necessary, if the boolean argument is non-zero.
205
+
206
+<a name="combobox"></a>TH1 combobox Command
207
+-------------------------------------------
208
+
209
+ * combobox NAME TEXT-LIST NUMLINES
210
+
211
+Generates and emits an HTML combobox. NAME is both the name of the
212
+CGI parameter and the name of a variable that contains the currently
213
+selected value. TEXT-LIST is a list of possible values for the
214
+combobox. NUMLINES is 1 for a true combobox. If NUMLINES is greater
215
+than one then the display is a listbox with the number of lines given.
216
+
217
+<a name="date"></a>TH1 date Command
218
+-----------------------------------
219
+
220
+ * date ?-local?
221
+
222
+Return a strings which is the current time and date. If the -local
223
+option is used, the date appears using localtime instead of UTC.
224
+
225
+<a name="decorate"></a>TH1 decorate Command
226
+-------------------------------------------
227
+
228
+ * decorate STRING
229
+
230
+Renders STRING as wiki content; however, only links are handled. No
231
+other markup is processed.
232
+
233
+<a name="enable_output"></a>TH1 enable_output Command
234
+-----------------------------------------------------
235
+
236
+ * enable_output BOOLEAN
237
+
238
+Enable or disable sending output when the combobox, puts, or wiki
239
+commands are used.
240
+
241
+<a name="getParameter"></a>TH1 getParameter Command
242
+---------------------------------------------------
243
+
244
+ * getParameter NAME ?DEFAULT?
245
+
246
+Returns the value of the specified query parameter or the specified
247
+default value when there is no matching query parameter.
248
+
249
+<a name="globalState"></a>TH1 globalState Command
250
+-------------------------------------------------
251
+
252
+ * globalState NAME ?DEFAULT?
253
+
254
+Returns a string containing the value of the specified global state
255
+variable -OR- the specified default value. The supported items are:
256
+
257
+ 1. **checkout** -- _Active local checkout directory, if any._
258
+ 1. **configuration** -- _Active configuration database file name, if any._
259
+ 1. **executable** -- _Fully qualified executable file name._
260
+ 1. **flags** -- _TH1 initialization flags._
261
+ 1. **log** -- _Error log file name, if any._
262
+ 1. **repository** -- _Active local repository file name, if any._
263
+ 1. **top** -- _Base path for the active server instance, if applicable._
264
+ 1. **user** -- _Active user name, if any._
265
+ 1. **vfs** -- _SQLite VFS in use, if overridden._
266
+
267
+Attempts to query for unsupported global state variables will result
268
+in a script error. Additional global state variables may be exposed
269
+in the future.
270
+
271
+<a name="hascap"></a>TH1 hascap Command
272
+---------------------------------------
273
+
274
+ * hascap STRING...
275
+
276
+Returns true if the current user has all of the capabilities listed
277
+in STRING.
278
+
279
+<a name="hasfeature"></a>TH1 hasfeature Command
280
+-----------------------------------------------
281
+
282
+ * hasfeature STRING
283
+
284
+Returns true if the binary has the given compile-time feature enabled.
285
+The possible features are:
286
+
287
+ 1. **ssl** -- _Support for the HTTPS transport._
288
+ 1. **legacyMvRm** -- _Support for legacy mv/rm command behavior._
289
+ 1. **th1Docs** -- _Support for TH1 in embedded documentation._
290
+ 1. **th1Hooks** -- _Support for TH1 command and web page hooks._
291
+ 1. **tcl** -- _Support for Tcl integration._
292
+ 1. **useTclStubs** -- _Tcl stubs enabled in the Tcl headers._
293
+ 1. **tclStubs** -- _Uses Tcl stubs (i.e. linking with stubs library)._
294
+ 1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
295
+ 1. **json** -- _Support for the JSON APIs._
296
+ 1. **markdown** -- _Support for Markdown documentation format._
297
+ 1. **unicodeCmdLine** -- _The command line arguments are Unicode._
298
+
299
+<a name="html"></a>TH1 html Command
300
+-----------------------------------
301
+
302
+ * html STRING
303
+
304
+Outputs the STRING escaped for HTML.
305
+
306
+<a name="htmlize"></a>TH1 htmlize Command
307
+-----------------------------------------
308
+
309
+ * htmlize STRING
310
+
311
+Escape all characters of STRING which have special meaning in HTML.
312
+Returns the escaped string.
313
+
314
+<a name="http"></a>TH1 http Command
315
+-----------------------------------
316
+
317
+ * http ?-asynchronous? ?--? url ?payload?
318
+
319
+Performs an HTTP or HTTPS request for the specified URL. If a
320
+payload is present, it will be interpreted as text/plain and
321
+the POST method will be used; otherwise, the GET method will
322
+be used. Upon success, if the -asynchronous option is used, an
323
+empty string is returned as the result; otherwise, the response
324
+from the server is returned as the result. Synchronous requests
325
+are not currently implemented.
326
+
327
+<a name="httpize"></a>TH1 httpize Command
328
+-----------------------------------------
329
+
330
+ * httpize STRING
331
+
332
+Escape all characters of STRING which have special meaning in URI
333
+components. Returns the escaped string.
334
+
335
+<a name="linecount"></a>TH1 linecount Command
336
+---------------------------------------------
337
+
338
+ * linecount STRING MAX MIN
339
+
340
+Returns one more than the number of \n characters in STRING. But
341
+never returns less than MIN or more than MAX.
342
+
343
+<a name="puts"></a>TH1 puts Command
344
+-----------------------------------
345
+
346
+ * puts STRING
347
+
348
+Outputs the STRING unchanged.
349
+
350
+<a name="query"></a>TH1 query Command
351
+-------------------------------------
352
+
353
+ * query SQL CODE
354
+
355
+Runs the SQL query given by the SQL argument. For each row in the result
356
+set, run CODE.
357
+
358
+In SQL, parameters such as $var are filled in using the value of variable
359
+"var". Result values are stored in variables with the column name prior
360
+to each invocation of CODE.
361
+
362
+<a name="randhex"></a>TH1 randhex Command
363
+-----------------------------------------
364
+
365
+ * randhex N
366
+
367
+Returns a string of N*2 random hexadecimal digits with N<50. If N is
368
+omitted, use a value of 10.
369
+
370
+<a name="regexp"></a>TH1 regexp Command
371
+---------------------------------------
372
+
373
+ * regexp ?-nocase? ?--? exp string
374
+
375
+Checks the string against the specified regular expression and returns
376
+non-zero if it matches. If the regular expression is invalid or cannot
377
+be compiled, an error will be generated.
378
+
379
+<a name="reinitialize"></a>TH1 reinitialize Command
380
+---------------------------------------------------
381
+
382
+ * reinitialize ?FLAGS?
383
+
384
+Reinitializes the TH1 interpreter using the specified flags.
385
+
386
+<a name="render"></a>TH1 render Command
387
+---------------------------------------
388
+
389
+ * render STRING
390
+
391
+Renders the TH1 template and writes the results.
392
+
393
+<a name="repository"></a>TH1 repository Command
394
+-----------------------------------------------
395
+
396
+ * repository ?BOOLEAN?
397
+
398
+Returns the fully qualified file name of the open repository or an empty
399
+string if one is not currently open. Optionally, it will attempt to open
400
+the repository if the boolean argument is non-zero.
401
+
402
+<a name="searchable"></a>TH1 searchable Command
403
+-----------------------------------------------
404
+
405
+ * searchable STRING...
406
+
407
+Return true if searching in any of the document classes identified
408
+by STRING is enabled for the repository and user has the necessary
409
+capabilities to perform the search. The possible document classes
410
+are:
411
+
412
+ 1. **c** -- _Check-in comments_
413
+ 1. **d** -- _Embedded documentation_
414
+ 1. **t** -- _Tickets_
415
+ 1. **w** -- _Wiki_
416
+
417
+To be clear, only one of the document classes identified by each STRING
418
+needs to be searchable in order for that argument to be true. But all
419
+arguments must be true for this routine to return true. Hence, to see
420
+if ALL document classes are searchable:
421
+
422
+ if {[searchable c d t w]} {...}
423
+
424
+But to see if ANY document class is searchable:
425
+
426
+ if {[searchable cdtw]} {...}
427
+
428
+This command is useful for enabling or disabling a "Search" entry on the
429
+menu bar.
430
+
431
+<a name="setParameter"></a>TH1 setParameter Command
432
+---------------------------------------------------
433
+
434
+ * setParameter NAME VALUE
435
+
436
+Sets the value of the specified query parameter.
437
+
438
+<a name="setting"></a>TH1 setting Command
439
+-----------------------------------------
440
+
441
+ * setting name
442
+
443
+Gets and returns the value of the specified setting.
444
+
445
+<a name="styleHeader"></a>TH1 styleHeader Command
446
+-------------------------------------------------
447
+
448
+ * styleHeader TITLE
449
+
450
+Render the configured style header.
451
+
452
+<a name="styleFooter"></a>TH1 styleFooter Command
453
+-------------------------------------------------
454
+
455
+ * styleFooter
456
+
457
+Render the configured style footer.
458
+
459
+<a name="tclEval"></a>TH1 tclEval Command
460
+-----------------------------------------
461
+
462
+**This command requires the Tcl integration feature.**
463
+
464
+ * tclEval arg ?arg ...?
465
+
466
+Evaluates the Tcl script and returns its result verbatim. If a Tcl script
467
+error is generated, it will be transformed into a TH1 script error. A Tcl
468
+interpreter will be created automatically if it has not been already.
469
+
470
+<a name="tclExpr"></a>TH1 tclExpr Command
471
+-----------------------------------------
472
+
473
+**This command requires the Tcl integration feature.**
474
+
475
+ * tclExpr arg ?arg ...?
476
+
477
+Evaluates the Tcl expression and returns its result verbatim. If a Tcl
478
+script error is generated, it will be transformed into a TH1 script error.
479
+A Tcl interpreter will be created automatically if it has not been already.
480
+
481
+<a name="tclInvoke"></a>TH1 tclInvoke Command
482
+---------------------------------------------
483
+
484
+**This command requires the Tcl integration feature.**
485
+
486
+ * tclInvoke command ?arg ...?
487
+
488
+Invokes the Tcl command using the supplied arguments. No additional
489
+substitutions are performed on the arguments. A Tcl interpreter will
490
+be created automatically if it has not been already.
491
+
492
+<a name="tclReady"></a>TH1 tclReady Command
493
+-------------------------------------------
494
+
495
+ * tclReady
496
+
497
+Returns true if the binary has the Tcl integration feature enabled and it
498
+is currently available for use by TH1 scripts.
499
+
500
+<a name="trace"></a>TH1 trace Command
501
+-------------------------------------
502
+
503
+ * trace STRING
504
+
505
+Generates a TH1 trace message if TH1 tracing is enabled.
506
+
507
+<a name="stime"></a>TH1 stime Command
508
+-------------------------------------
509
+
510
+ * stime
511
+
512
+Returns the number of microseconds of CPU time consumed by the current
513
+process in system space.
514
+
515
+<a name="utime"></a>TH1 utime Command
516
+-------------------------------------
517
+
518
+ * utime
519
+
520
+Returns the number of microseconds of CPU time consumed by the current
521
+process in user space.
522
+
523
+<a name="wiki"></a>TH1 wiki Command
524
+-----------------------------------
525
+
526
+ * wiki STRING
527
+
528
+Renders STRING as wiki content.
529
+
530
+Tcl Integration Commands
531
+------------------------
532
+
533
+When the Tcl integration subsystem is enabled, several commands are added
534
+to the Tcl interpreter. They are used to allow Tcl scripts access to the
535
+Fossil functionality provided via TH1. The following is a summary of the
536
+Tcl commands:
537
+
538
+ * th1Eval
539
+ * th1Expr
540
+
541
+<a name="th1Eval"></a>Tcl th1Eval Command
542
+-----------------------------------------
543
+
544
+**This command requires the Tcl integration feature.**
545
+
546
+ * th1Eval arg
547
+
548
+Evaluates the TH1 script and returns its result verbatim. If a TH1 script
549
+error is generated, it will be transformed into a Tcl script error.
550
+
551
+<a name="th1Expr"></a>Tcl th1Expr Command
552
+-----------------------------------------
553
+
554
+**This command requires the Tcl integration feature.**
555
+
556
+ * th1Expr arg
557
+
558
+Evaluates the TH1 expression and returns its result verbatim. If a TH1
559
+script error is generated, it will be transformed into a Tcl script error.
560
+
561
+Further Notes
562
+-------------
160563
161564
**To Do:** We would like to have a community volunteer go through and
162565
copy the documentation for each of these commands (with appropriate
163566
format changes and spelling and grammar corrections) into subsequent
164567
sections of this document. It is suggested that the list of extension
165568
commands be left intact - as a quick reference. But it would be really
166569
nice to also have the details of what each command does.
167570
--- www/th1.md
+++ www/th1.md
@@ -5,22 +5,22 @@
5 content in Fossil.
6
7 Origins
8 -------
9
10 TH1 began as a minimalist re-implementation of the TCL scripting language.
11 There was a need to test the SQLite library on Symbian phones, but at that
12 time all of the test cases for SQLite were written in Tcl and Tcl could not
13 be easily compiled on the SymbianOS. So TH1 was developed as a cut-down
14 version of TCL that would facilitate running the SQLite test scripts on
15 SymbianOS.
16
17 The testing of SQLite on SymbianOS was eventually accomplished by other
18 means. But Fossil was first being designed at about the same time.
19 Early prototypes of Fossil were written in pure TCL. But as the development
20 shifted toward the use of C-code, the need arose to have a TCL-like
21 scripting language to help with code generation. TH1 was small and
22 light-weight and used minimal resources and seemed ideally suited for the
23 task.
24
25 The name "TH1" stands "Test Harness 1", since that was its original purpose.
26
@@ -78,11 +78,11 @@
78 just a single command.
79
80 Summary of Core TH1 Commands
81 ----------------------------
82
83 The original TCL language after when TH1 is modeled has a very rich
84 repertoire of commands. TH1, as it is designed to be minimalist and
85 embedded has a greatly reduced command set. The following bullets
86 summarize the commands available in TH1:
87
88 * break
@@ -90,11 +90,13 @@
90 * continue
91 * error ?STRING?
92 * expr EXPR
93 * for INIT-SCRIPT TEST-EXPR NEXT-SCRIPT BODY-SCRIPT
94 * if EXPR SCRIPT (elseif EXPR SCRIPT)* ?else SCRIPT?
 
95 * info exists VARNAME
 
96 * lindex LIST INDEX
97 * list ARG ...
98 * llength LIST
99 * proc NAME ARG-LIST BODY-SCRIPT
100 * rename OLD NEW
@@ -109,12 +111,12 @@
109 * string repeat STRING COUNT
110 * unset VARNAME
111 * uplevel ?LEVEL? SCRIPT
112 * upvar ?FRAME? OTHERVAR MYVAR ?OTHERVAR MYVAR?
113
114 All of the above commands works as in the original TCL. Refer to the
115 TCL documentation for details.
116
117 TH1 Extended Commands
118 ---------------------
119
120 There are many new commands added to TH1 and used to access the special
@@ -128,16 +130,16 @@
128 * date
129 * decorate
130 * enable_output
131 * getParameter
132 * globalState
133 * httpize
134 * hascap
135 * hasfeature
136 * html
137 * htmlize
138 * http
 
139 * linecount
140 * puts
141 * query
142 * randhex
143 * regexp
@@ -147,20 +149,421 @@
147 * searchable
148 * setParameter
149 * setting
150 * styleHeader
151 * styleFooter
 
 
 
152 * tclReady
153 * trace
154 * stime
155 * utime
156 * wiki
157
158 Each of the commands above is documented by a block comment above their
159 implementation in the th_main.c source file.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
161 **To Do:** We would like to have a community volunteer go through and
162 copy the documentation for each of these commands (with appropriate
163 format changes and spelling and grammar corrections) into subsequent
164 sections of this document. It is suggested that the list of extension
165 commands be left intact - as a quick reference. But it would be really
166 nice to also have the details of what each command does.
167
--- www/th1.md
+++ www/th1.md
@@ -5,22 +5,22 @@
5 content in Fossil.
6
7 Origins
8 -------
9
10 TH1 began as a minimalist re-implementation of the Tcl scripting language.
11 There was a need to test the SQLite library on Symbian phones, but at that
12 time all of the test cases for SQLite were written in Tcl and Tcl could not
13 be easily compiled on the SymbianOS. So TH1 was developed as a cut-down
14 version of Tcl that would facilitate running the SQLite test scripts on
15 SymbianOS.
16
17 The testing of SQLite on SymbianOS was eventually accomplished by other
18 means. But Fossil was first being designed at about the same time.
19 Early prototypes of Fossil were written in pure Tcl. But as the development
20 shifted toward the use of C-code, the need arose to have a Tcl-like
21 scripting language to help with code generation. TH1 was small and
22 light-weight and used minimal resources and seemed ideally suited for the
23 task.
24
25 The name "TH1" stands "Test Harness 1", since that was its original purpose.
26
@@ -78,11 +78,11 @@
78 just a single command.
79
80 Summary of Core TH1 Commands
81 ----------------------------
82
83 The original Tcl language after when TH1 is modeled has a very rich
84 repertoire of commands. TH1, as it is designed to be minimalist and
85 embedded has a greatly reduced command set. The following bullets
86 summarize the commands available in TH1:
87
88 * break
@@ -90,11 +90,13 @@
90 * continue
91 * error ?STRING?
92 * expr EXPR
93 * for INIT-SCRIPT TEST-EXPR NEXT-SCRIPT BODY-SCRIPT
94 * if EXPR SCRIPT (elseif EXPR SCRIPT)* ?else SCRIPT?
95 * info commands
96 * info exists VARNAME
97 * info vars
98 * lindex LIST INDEX
99 * list ARG ...
100 * llength LIST
101 * proc NAME ARG-LIST BODY-SCRIPT
102 * rename OLD NEW
@@ -109,12 +111,12 @@
111 * string repeat STRING COUNT
112 * unset VARNAME
113 * uplevel ?LEVEL? SCRIPT
114 * upvar ?FRAME? OTHERVAR MYVAR ?OTHERVAR MYVAR?
115
116 All of the above commands works as in the original Tcl. Refer to the
117 Tcl documentation for details.
118
119 TH1 Extended Commands
120 ---------------------
121
122 There are many new commands added to TH1 and used to access the special
@@ -128,16 +130,16 @@
130 * date
131 * decorate
132 * enable_output
133 * getParameter
134 * globalState
 
135 * hascap
136 * hasfeature
137 * html
138 * htmlize
139 * http
140 * httpize
141 * linecount
142 * puts
143 * query
144 * randhex
145 * regexp
@@ -147,20 +149,421 @@
149 * searchable
150 * setParameter
151 * setting
152 * styleHeader
153 * styleFooter
154 * tclEval
155 * tclExpr
156 * tclInvoke
157 * tclReady
158 * trace
159 * stime
160 * utime
161 * wiki
162
163 Each of the commands above is documented by a block comment above their
164 implementation in the th\_main.c or th\_tcl.c source files.
165
166 All commands starting with "tcl", with the exception of "tclReady",
167 require the Tcl integration subsystem be included at compile-time.
168 Additionally, the "tcl" repository setting must be enabled at runtime
169 in order to successfully make use of these commands.
170
171 <a name="anoncap"></a>TH1 anoncap Command
172 -----------------------------------------
173
174 * anoncap STRING...
175
176 Returns true if the anonymous user has all of the capabilities listed
177 in STRING.
178
179 <a name="anycap"></a>TH1 anycap Command
180 ---------------------------------------
181
182 * anycap STRING
183
184 Returns true if the current user user has any one of the capabilities
185 listed in STRING.
186
187 <a name="artifact"></a>TH1 artifact Command
188 -------------------------------------------
189
190 * artifact ID ?FILENAME?
191
192 Attempts to locate the specified artifact and return its contents. An
193 error is generated if the repository is not open or the artifact cannot
194 be found.
195
196 <a name="checkout"></a>TH1 checkout Command
197 -------------------------------------------
198
199 * checkout ?BOOLEAN?
200
201 Return the fully qualified directory name of the current checkout or an
202 empty string if it is not available. Optionally, it will attempt to find
203 the current checkout, opening the configuration ("user") database and the
204 repository as necessary, if the boolean argument is non-zero.
205
206 <a name="combobox"></a>TH1 combobox Command
207 -------------------------------------------
208
209 * combobox NAME TEXT-LIST NUMLINES
210
211 Generates and emits an HTML combobox. NAME is both the name of the
212 CGI parameter and the name of a variable that contains the currently
213 selected value. TEXT-LIST is a list of possible values for the
214 combobox. NUMLINES is 1 for a true combobox. If NUMLINES is greater
215 than one then the display is a listbox with the number of lines given.
216
217 <a name="date"></a>TH1 date Command
218 -----------------------------------
219
220 * date ?-local?
221
222 Return a strings which is the current time and date. If the -local
223 option is used, the date appears using localtime instead of UTC.
224
225 <a name="decorate"></a>TH1 decorate Command
226 -------------------------------------------
227
228 * decorate STRING
229
230 Renders STRING as wiki content; however, only links are handled. No
231 other markup is processed.
232
233 <a name="enable_output"></a>TH1 enable_output Command
234 -----------------------------------------------------
235
236 * enable_output BOOLEAN
237
238 Enable or disable sending output when the combobox, puts, or wiki
239 commands are used.
240
241 <a name="getParameter"></a>TH1 getParameter Command
242 ---------------------------------------------------
243
244 * getParameter NAME ?DEFAULT?
245
246 Returns the value of the specified query parameter or the specified
247 default value when there is no matching query parameter.
248
249 <a name="globalState"></a>TH1 globalState Command
250 -------------------------------------------------
251
252 * globalState NAME ?DEFAULT?
253
254 Returns a string containing the value of the specified global state
255 variable -OR- the specified default value. The supported items are:
256
257 1. **checkout** -- _Active local checkout directory, if any._
258 1. **configuration** -- _Active configuration database file name, if any._
259 1. **executable** -- _Fully qualified executable file name._
260 1. **flags** -- _TH1 initialization flags._
261 1. **log** -- _Error log file name, if any._
262 1. **repository** -- _Active local repository file name, if any._
263 1. **top** -- _Base path for the active server instance, if applicable._
264 1. **user** -- _Active user name, if any._
265 1. **vfs** -- _SQLite VFS in use, if overridden._
266
267 Attempts to query for unsupported global state variables will result
268 in a script error. Additional global state variables may be exposed
269 in the future.
270
271 <a name="hascap"></a>TH1 hascap Command
272 ---------------------------------------
273
274 * hascap STRING...
275
276 Returns true if the current user has all of the capabilities listed
277 in STRING.
278
279 <a name="hasfeature"></a>TH1 hasfeature Command
280 -----------------------------------------------
281
282 * hasfeature STRING
283
284 Returns true if the binary has the given compile-time feature enabled.
285 The possible features are:
286
287 1. **ssl** -- _Support for the HTTPS transport._
288 1. **legacyMvRm** -- _Support for legacy mv/rm command behavior._
289 1. **th1Docs** -- _Support for TH1 in embedded documentation._
290 1. **th1Hooks** -- _Support for TH1 command and web page hooks._
291 1. **tcl** -- _Support for Tcl integration._
292 1. **useTclStubs** -- _Tcl stubs enabled in the Tcl headers._
293 1. **tclStubs** -- _Uses Tcl stubs (i.e. linking with stubs library)._
294 1. **tclPrivateStubs** -- _Uses Tcl private stubs (i.e. header-only)._
295 1. **json** -- _Support for the JSON APIs._
296 1. **markdown** -- _Support for Markdown documentation format._
297 1. **unicodeCmdLine** -- _The command line arguments are Unicode._
298
299 <a name="html"></a>TH1 html Command
300 -----------------------------------
301
302 * html STRING
303
304 Outputs the STRING escaped for HTML.
305
306 <a name="htmlize"></a>TH1 htmlize Command
307 -----------------------------------------
308
309 * htmlize STRING
310
311 Escape all characters of STRING which have special meaning in HTML.
312 Returns the escaped string.
313
314 <a name="http"></a>TH1 http Command
315 -----------------------------------
316
317 * http ?-asynchronous? ?--? url ?payload?
318
319 Performs an HTTP or HTTPS request for the specified URL. If a
320 payload is present, it will be interpreted as text/plain and
321 the POST method will be used; otherwise, the GET method will
322 be used. Upon success, if the -asynchronous option is used, an
323 empty string is returned as the result; otherwise, the response
324 from the server is returned as the result. Synchronous requests
325 are not currently implemented.
326
327 <a name="httpize"></a>TH1 httpize Command
328 -----------------------------------------
329
330 * httpize STRING
331
332 Escape all characters of STRING which have special meaning in URI
333 components. Returns the escaped string.
334
335 <a name="linecount"></a>TH1 linecount Command
336 ---------------------------------------------
337
338 * linecount STRING MAX MIN
339
340 Returns one more than the number of \n characters in STRING. But
341 never returns less than MIN or more than MAX.
342
343 <a name="puts"></a>TH1 puts Command
344 -----------------------------------
345
346 * puts STRING
347
348 Outputs the STRING unchanged.
349
350 <a name="query"></a>TH1 query Command
351 -------------------------------------
352
353 * query SQL CODE
354
355 Runs the SQL query given by the SQL argument. For each row in the result
356 set, run CODE.
357
358 In SQL, parameters such as $var are filled in using the value of variable
359 "var". Result values are stored in variables with the column name prior
360 to each invocation of CODE.
361
362 <a name="randhex"></a>TH1 randhex Command
363 -----------------------------------------
364
365 * randhex N
366
367 Returns a string of N*2 random hexadecimal digits with N<50. If N is
368 omitted, use a value of 10.
369
370 <a name="regexp"></a>TH1 regexp Command
371 ---------------------------------------
372
373 * regexp ?-nocase? ?--? exp string
374
375 Checks the string against the specified regular expression and returns
376 non-zero if it matches. If the regular expression is invalid or cannot
377 be compiled, an error will be generated.
378
379 <a name="reinitialize"></a>TH1 reinitialize Command
380 ---------------------------------------------------
381
382 * reinitialize ?FLAGS?
383
384 Reinitializes the TH1 interpreter using the specified flags.
385
386 <a name="render"></a>TH1 render Command
387 ---------------------------------------
388
389 * render STRING
390
391 Renders the TH1 template and writes the results.
392
393 <a name="repository"></a>TH1 repository Command
394 -----------------------------------------------
395
396 * repository ?BOOLEAN?
397
398 Returns the fully qualified file name of the open repository or an empty
399 string if one is not currently open. Optionally, it will attempt to open
400 the repository if the boolean argument is non-zero.
401
402 <a name="searchable"></a>TH1 searchable Command
403 -----------------------------------------------
404
405 * searchable STRING...
406
407 Return true if searching in any of the document classes identified
408 by STRING is enabled for the repository and user has the necessary
409 capabilities to perform the search. The possible document classes
410 are:
411
412 1. **c** -- _Check-in comments_
413 1. **d** -- _Embedded documentation_
414 1. **t** -- _Tickets_
415 1. **w** -- _Wiki_
416
417 To be clear, only one of the document classes identified by each STRING
418 needs to be searchable in order for that argument to be true. But all
419 arguments must be true for this routine to return true. Hence, to see
420 if ALL document classes are searchable:
421
422 if {[searchable c d t w]} {...}
423
424 But to see if ANY document class is searchable:
425
426 if {[searchable cdtw]} {...}
427
428 This command is useful for enabling or disabling a "Search" entry on the
429 menu bar.
430
431 <a name="setParameter"></a>TH1 setParameter Command
432 ---------------------------------------------------
433
434 * setParameter NAME VALUE
435
436 Sets the value of the specified query parameter.
437
438 <a name="setting"></a>TH1 setting Command
439 -----------------------------------------
440
441 * setting name
442
443 Gets and returns the value of the specified setting.
444
445 <a name="styleHeader"></a>TH1 styleHeader Command
446 -------------------------------------------------
447
448 * styleHeader TITLE
449
450 Render the configured style header.
451
452 <a name="styleFooter"></a>TH1 styleFooter Command
453 -------------------------------------------------
454
455 * styleFooter
456
457 Render the configured style footer.
458
459 <a name="tclEval"></a>TH1 tclEval Command
460 -----------------------------------------
461
462 **This command requires the Tcl integration feature.**
463
464 * tclEval arg ?arg ...?
465
466 Evaluates the Tcl script and returns its result verbatim. If a Tcl script
467 error is generated, it will be transformed into a TH1 script error. A Tcl
468 interpreter will be created automatically if it has not been already.
469
470 <a name="tclExpr"></a>TH1 tclExpr Command
471 -----------------------------------------
472
473 **This command requires the Tcl integration feature.**
474
475 * tclExpr arg ?arg ...?
476
477 Evaluates the Tcl expression and returns its result verbatim. If a Tcl
478 script error is generated, it will be transformed into a TH1 script error.
479 A Tcl interpreter will be created automatically if it has not been already.
480
481 <a name="tclInvoke"></a>TH1 tclInvoke Command
482 ---------------------------------------------
483
484 **This command requires the Tcl integration feature.**
485
486 * tclInvoke command ?arg ...?
487
488 Invokes the Tcl command using the supplied arguments. No additional
489 substitutions are performed on the arguments. A Tcl interpreter will
490 be created automatically if it has not been already.
491
492 <a name="tclReady"></a>TH1 tclReady Command
493 -------------------------------------------
494
495 * tclReady
496
497 Returns true if the binary has the Tcl integration feature enabled and it
498 is currently available for use by TH1 scripts.
499
500 <a name="trace"></a>TH1 trace Command
501 -------------------------------------
502
503 * trace STRING
504
505 Generates a TH1 trace message if TH1 tracing is enabled.
506
507 <a name="stime"></a>TH1 stime Command
508 -------------------------------------
509
510 * stime
511
512 Returns the number of microseconds of CPU time consumed by the current
513 process in system space.
514
515 <a name="utime"></a>TH1 utime Command
516 -------------------------------------
517
518 * utime
519
520 Returns the number of microseconds of CPU time consumed by the current
521 process in user space.
522
523 <a name="wiki"></a>TH1 wiki Command
524 -----------------------------------
525
526 * wiki STRING
527
528 Renders STRING as wiki content.
529
530 Tcl Integration Commands
531 ------------------------
532
533 When the Tcl integration subsystem is enabled, several commands are added
534 to the Tcl interpreter. They are used to allow Tcl scripts access to the
535 Fossil functionality provided via TH1. The following is a summary of the
536 Tcl commands:
537
538 * th1Eval
539 * th1Expr
540
541 <a name="th1Eval"></a>Tcl th1Eval Command
542 -----------------------------------------
543
544 **This command requires the Tcl integration feature.**
545
546 * th1Eval arg
547
548 Evaluates the TH1 script and returns its result verbatim. If a TH1 script
549 error is generated, it will be transformed into a Tcl script error.
550
551 <a name="th1Expr"></a>Tcl th1Expr Command
552 -----------------------------------------
553
554 **This command requires the Tcl integration feature.**
555
556 * th1Expr arg
557
558 Evaluates the TH1 expression and returns its result verbatim. If a TH1
559 script error is generated, it will be transformed into a Tcl script error.
560
561 Further Notes
562 -------------
563
564 **To Do:** We would like to have a community volunteer go through and
565 copy the documentation for each of these commands (with appropriate
566 format changes and spelling and grammar corrections) into subsequent
567 sections of this document. It is suggested that the list of extension
568 commands be left intact - as a quick reference. But it would be really
569 nice to also have the details of what each command does.
570

Keyboard Shortcuts

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