poppler 3.0.8-x86-mingw32 → 3.0.9-x86-mingw32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -1
- data/ext/poppler/extconf.rb +1 -1
- data/ext/poppler/rbpoppler-page.c +9 -9
- data/lib/2.2/poppler.so +0 -0
- data/lib/2.3/poppler.so +0 -0
- data/sample/pdf2.rb +1 -1
- data/test/run-test.rb +5 -3
- data/test/test_page.rb +9 -0
- data/vendor/local/bin/libpoppler-59.dll +0 -0
- data/vendor/local/bin/libsqlite3-0.dll +0 -0
- data/vendor/local/bin/pdfdetach.exe +0 -0
- data/vendor/local/bin/pdffonts.exe +0 -0
- data/vendor/local/bin/pdfinfo.exe +0 -0
- data/vendor/local/bin/pdfseparate.exe +0 -0
- data/vendor/local/bin/pdftocairo.exe +0 -0
- data/vendor/local/bin/pdftohtml.exe +0 -0
- data/vendor/local/bin/sqlite3.exe +0 -0
- data/vendor/local/include/sqlite3.h +1655 -46
- data/vendor/local/include/sqlite3ext.h +19 -5
- data/vendor/local/lib/libjpeg.dll.a +0 -0
- data/vendor/local/lib/libopenjp2.dll.a +0 -0
- data/vendor/local/lib/libpoppler-cpp.dll.a +0 -0
- data/vendor/local/lib/libpoppler-glib.dll.a +0 -0
- data/vendor/local/lib/libpoppler.a +0 -0
- data/vendor/local/lib/libpoppler.dll.a +0 -0
- data/vendor/local/lib/libsqlite3.a +0 -0
- data/vendor/local/lib/libsqlite3.dll.a +0 -0
- data/vendor/local/lib/pkgconfig/sqlite3.pc +1 -1
- data/vendor/local/share/gtk-doc/html/poppler/PopplerAnnot.html +75 -75
- data/vendor/local/share/gtk-doc/html/poppler/PopplerAttachment.html +26 -26
- data/vendor/local/share/gtk-doc/html/poppler/PopplerDocument.html +164 -164
- data/vendor/local/share/gtk-doc/html/poppler/PopplerFormField.html +70 -70
- data/vendor/local/share/gtk-doc/html/poppler/PopplerLayer.html +11 -11
- data/vendor/local/share/gtk-doc/html/poppler/PopplerMedia.html +35 -35
- data/vendor/local/share/gtk-doc/html/poppler/PopplerMovie.html +9 -9
- data/vendor/local/share/gtk-doc/html/poppler/PopplerPage.html +82 -82
- data/vendor/local/share/gtk-doc/html/poppler/PopplerStructureElement.html +131 -131
- data/vendor/local/share/gtk-doc/html/poppler/poppler-Error-handling.html +1 -1
- data/vendor/local/share/gtk-doc/html/poppler/poppler-PDF-Utility-functions.html +5 -5
- data/vendor/local/share/gtk-doc/html/poppler/poppler-PopplerAction.html +5 -5
- data/vendor/local/share/gtk-doc/html/poppler/poppler-PopplerColor.html +3 -3
- data/vendor/local/share/gtk-doc/html/poppler/poppler-Version-and-Features-Information.html +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69f8e4fe4a595a2e17fbe4bd26839f971eda3d6b
|
4
|
+
data.tar.gz: f842b715e2e88d41198ed7b356976baeb94511ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a1867d3e6346225d698ddf247c10ac371075e666ed776638dc2ea96b6ee1ede1d41b1998f4c58c11d873dcbe3d2a42ad534bec5af96eb92e23527bd1e6f0f7b3
|
7
|
+
data.tar.gz: 7e7267baa331e3978894db8abe8dc3422ac88f7fac3f9534f37f1982ba358331e8bdad37cc37ba6dd39cc546d4534c9b1589883b54c1c6eaef78820ae5982254
|
data/Rakefile
CHANGED
@@ -49,7 +49,7 @@ package_task = GNOME2::Rake::PackageTask.new do |package|
|
|
49
49
|
:name => "sqlite-autoconf",
|
50
50
|
:download_base_url => "http://www.sqlite.org/2016",
|
51
51
|
:label => "SQLite",
|
52
|
-
:version => "
|
52
|
+
:version => "3140100",
|
53
53
|
:compression_method => "gz",
|
54
54
|
:windows => {
|
55
55
|
:configure_args => [],
|
data/ext/poppler/extconf.rb
CHANGED
@@ -30,7 +30,7 @@ rescue LoadError
|
|
30
30
|
require 'mkmf-gnome2'
|
31
31
|
end
|
32
32
|
|
33
|
-
["glib2", "atk"
|
33
|
+
["glib2", "atk"].each do |package|
|
34
34
|
directory = "#{package}#{version_suffix}"
|
35
35
|
build_dir = "#{directory}/tmp/#{RUBY_PLATFORM}/#{package}/#{RUBY_VERSION}"
|
36
36
|
add_depend_package(package, "#{directory}/ext/#{package}",
|
@@ -205,17 +205,17 @@ rg_text_layout(VALUE self)
|
|
205
205
|
guint n_rectangles;
|
206
206
|
|
207
207
|
if (poppler_page_get_text_layout(SELF(self), &rectangles, &n_rectangles)) {
|
208
|
-
VALUE
|
209
|
-
VALUE ary;
|
208
|
+
VALUE rb_rectangles;
|
210
209
|
guint i;
|
211
|
-
|
212
|
-
|
213
|
-
|
210
|
+
|
211
|
+
rb_rectangles = rb_ary_new2(n_rectangles);
|
212
|
+
for (i = 0; i < n_rectangles; i++) {
|
213
|
+
rb_ary_push(rb_rectangles,
|
214
|
+
POPPLERRECTANGLE2RVAL(&(rectangles[i])));
|
214
215
|
}
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
return ary;
|
216
|
+
g_free(rectangles);
|
217
|
+
|
218
|
+
return rb_rectangles;
|
219
219
|
} else {
|
220
220
|
return Qnil;
|
221
221
|
}
|
data/lib/2.2/poppler.so
CHANGED
Binary file
|
data/lib/2.3/poppler.so
CHANGED
Binary file
|
data/sample/pdf2.rb
CHANGED
@@ -115,7 +115,7 @@ def to_pixbuf_with_cairo(input, page_number, scale, rotate)
|
|
115
115
|
temp = Tempfile.new("pdf2")
|
116
116
|
cr.target.write_to_png(temp.path)
|
117
117
|
cr.target.finish
|
118
|
-
|
118
|
+
GdkPixbuf::Pixbuf.new(:file => temp.path)
|
119
119
|
end
|
120
120
|
|
121
121
|
unless Poppler.cairo_available?
|
data/test/run-test.rb
CHANGED
@@ -15,10 +15,12 @@ require 'glib-test-init'
|
|
15
15
|
[pango_dir, "pango"],
|
16
16
|
[glib_dir, "glib2"],
|
17
17
|
[base_dir, "poppler"]].each do |dir, module_name|
|
18
|
-
if
|
19
|
-
|
18
|
+
if File.exist?(File.join(dir, "Makefile"))
|
19
|
+
if have_make
|
20
|
+
system("cd #{dir.dump} && make > /dev/null") or exit(false)
|
21
|
+
end
|
22
|
+
$LOAD_PATH.unshift(File.join(dir, "ext", module_name))
|
20
23
|
end
|
21
|
-
$LOAD_PATH.unshift(File.join(dir, "ext", module_name))
|
22
24
|
$LOAD_PATH.unshift(File.join(dir, "lib"))
|
23
25
|
end
|
24
26
|
require "poppler"
|
data/test/test_page.rb
CHANGED
@@ -30,6 +30,15 @@ class TestPage < Test::Unit::TestCase
|
|
30
30
|
assert_kind_of(Poppler::Annotation, mapping.annotation)
|
31
31
|
end
|
32
32
|
|
33
|
+
def test_text_layout
|
34
|
+
only_poppler_version(0, 16, 0)
|
35
|
+
document = Poppler::Document.new(form_pdf)
|
36
|
+
page = document[0]
|
37
|
+
layout = page.text_layout
|
38
|
+
assert_equal([60, 31, 79, 60],
|
39
|
+
layout[0].to_a.collect(&:round))
|
40
|
+
end
|
41
|
+
|
33
42
|
private
|
34
43
|
def find_first_image_mapping(document)
|
35
44
|
document.each do |page|
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -30,8 +30,8 @@
|
|
30
30
|
** the version number) and changes its name to "sqlite3.h" as
|
31
31
|
** part of the build process.
|
32
32
|
*/
|
33
|
-
#ifndef
|
34
|
-
#define
|
33
|
+
#ifndef SQLITE3_H
|
34
|
+
#define SQLITE3_H
|
35
35
|
#include <stdarg.h> /* Needed for the definition of va_list */
|
36
36
|
|
37
37
|
/*
|
@@ -54,8 +54,17 @@ extern "C" {
|
|
54
54
|
#ifndef SQLITE_CDECL
|
55
55
|
# define SQLITE_CDECL
|
56
56
|
#endif
|
57
|
+
#ifndef SQLITE_APICALL
|
58
|
+
# define SQLITE_APICALL
|
59
|
+
#endif
|
57
60
|
#ifndef SQLITE_STDCALL
|
58
|
-
# define SQLITE_STDCALL
|
61
|
+
# define SQLITE_STDCALL SQLITE_APICALL
|
62
|
+
#endif
|
63
|
+
#ifndef SQLITE_CALLBACK
|
64
|
+
# define SQLITE_CALLBACK
|
65
|
+
#endif
|
66
|
+
#ifndef SQLITE_SYSAPI
|
67
|
+
# define SQLITE_SYSAPI
|
59
68
|
#endif
|
60
69
|
|
61
70
|
/*
|
@@ -111,9 +120,9 @@ extern "C" {
|
|
111
120
|
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
|
112
121
|
** [sqlite_version()] and [sqlite_source_id()].
|
113
122
|
*/
|
114
|
-
#define SQLITE_VERSION "3.
|
115
|
-
#define SQLITE_VERSION_NUMBER
|
116
|
-
#define SQLITE_SOURCE_ID "2016-
|
123
|
+
#define SQLITE_VERSION "3.14.1"
|
124
|
+
#define SQLITE_VERSION_NUMBER 3014001
|
125
|
+
#define SQLITE_SOURCE_ID "2016-08-11 18:53:32 a12d8059770df4bca59e321c266410344242bf7b"
|
117
126
|
|
118
127
|
/*
|
119
128
|
** CAPI3REF: Run-Time Library Version Numbers
|
@@ -506,6 +515,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_exec(
|
|
506
515
|
#define SQLITE_NOTICE_RECOVER_ROLLBACK (SQLITE_NOTICE | (2<<8))
|
507
516
|
#define SQLITE_WARNING_AUTOINDEX (SQLITE_WARNING | (1<<8))
|
508
517
|
#define SQLITE_AUTH_USER (SQLITE_AUTH | (1<<8))
|
518
|
+
#define SQLITE_OK_LOAD_PERMANENTLY (SQLITE_OK | (1<<8))
|
509
519
|
|
510
520
|
/*
|
511
521
|
** CAPI3REF: Flags For File Open Operations
|
@@ -1035,6 +1045,16 @@ struct sqlite3_io_methods {
|
|
1035
1045
|
*/
|
1036
1046
|
typedef struct sqlite3_mutex sqlite3_mutex;
|
1037
1047
|
|
1048
|
+
/*
|
1049
|
+
** CAPI3REF: Loadable Extension Thunk
|
1050
|
+
**
|
1051
|
+
** A pointer to the opaque sqlite3_api_routines structure is passed as
|
1052
|
+
** the third parameter to entry points of [loadable extensions]. This
|
1053
|
+
** structure must be typedefed in order to work around compiler warnings
|
1054
|
+
** on some platforms.
|
1055
|
+
*/
|
1056
|
+
typedef struct sqlite3_api_routines sqlite3_api_routines;
|
1057
|
+
|
1038
1058
|
/*
|
1039
1059
|
** CAPI3REF: OS Interface Object
|
1040
1060
|
**
|
@@ -1932,12 +1952,30 @@ struct sqlite3_mem_methods {
|
|
1932
1952
|
** following this call. The second parameter may be a NULL pointer, in
|
1933
1953
|
** which case the new setting is not reported back. </dd>
|
1934
1954
|
**
|
1955
|
+
** <dt>SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION</dt>
|
1956
|
+
** <dd> ^This option is used to enable or disable the [sqlite3_load_extension()]
|
1957
|
+
** interface independently of the [load_extension()] SQL function.
|
1958
|
+
** The [sqlite3_enable_load_extension()] API enables or disables both the
|
1959
|
+
** C-API [sqlite3_load_extension()] and the SQL function [load_extension()].
|
1960
|
+
** There should be two additional arguments.
|
1961
|
+
** When the first argument to this interface is 1, then only the C-API is
|
1962
|
+
** enabled and the SQL function remains disabled. If the first argument to
|
1963
|
+
** this interface is 0, then both the C-API and the SQL function are disabled.
|
1964
|
+
** If the first argument is -1, then no changes are made to state of either the
|
1965
|
+
** C-API or the SQL function.
|
1966
|
+
** The second parameter is a pointer to an integer into which
|
1967
|
+
** is written 0 or 1 to indicate whether [sqlite3_load_extension()] interface
|
1968
|
+
** is disabled or enabled following this call. The second parameter may
|
1969
|
+
** be a NULL pointer, in which case the new setting is not reported back.
|
1970
|
+
** </dd>
|
1971
|
+
**
|
1935
1972
|
** </dl>
|
1936
1973
|
*/
|
1937
1974
|
#define SQLITE_DBCONFIG_LOOKASIDE 1001 /* void* int int */
|
1938
1975
|
#define SQLITE_DBCONFIG_ENABLE_FKEY 1002 /* int int* */
|
1939
1976
|
#define SQLITE_DBCONFIG_ENABLE_TRIGGER 1003 /* int int* */
|
1940
1977
|
#define SQLITE_DBCONFIG_ENABLE_FTS3_TOKENIZER 1004 /* int int* */
|
1978
|
+
#define SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION 1005 /* int int* */
|
1941
1979
|
|
1942
1980
|
|
1943
1981
|
/*
|
@@ -2214,7 +2252,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_complete16(const void *sql);
|
|
2214
2252
|
** A busy handler must not close the database connection
|
2215
2253
|
** or [prepared statement] that invoked the busy handler.
|
2216
2254
|
*/
|
2217
|
-
SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,
|
2255
|
+
SQLITE_API int SQLITE_STDCALL sqlite3_busy_handler(sqlite3*,int(*)(void*,int),void*);
|
2218
2256
|
|
2219
2257
|
/*
|
2220
2258
|
** CAPI3REF: Set A Busy Timeout
|
@@ -2736,6 +2774,9 @@ SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
|
|
2736
2774
|
** CAPI3REF: Tracing And Profiling Functions
|
2737
2775
|
** METHOD: sqlite3
|
2738
2776
|
**
|
2777
|
+
** These routines are deprecated. Use the [sqlite3_trace_v2()] interface
|
2778
|
+
** instead of the routines described here.
|
2779
|
+
**
|
2739
2780
|
** These routines register callback functions that can be used for
|
2740
2781
|
** tracing and profiling the execution of SQL statements.
|
2741
2782
|
**
|
@@ -2761,10 +2802,104 @@ SQLITE_API int SQLITE_STDCALL sqlite3_set_authorizer(
|
|
2761
2802
|
** sqlite3_profile() function is considered experimental and is
|
2762
2803
|
** subject to change in future versions of SQLite.
|
2763
2804
|
*/
|
2764
|
-
SQLITE_API void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
|
2765
|
-
|
2805
|
+
SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_trace(sqlite3*,
|
2806
|
+
void(*xTrace)(void*,const char*), void*);
|
2807
|
+
SQLITE_API SQLITE_DEPRECATED void *SQLITE_STDCALL sqlite3_profile(sqlite3*,
|
2766
2808
|
void(*xProfile)(void*,const char*,sqlite3_uint64), void*);
|
2767
2809
|
|
2810
|
+
/*
|
2811
|
+
** CAPI3REF: SQL Trace Event Codes
|
2812
|
+
** KEYWORDS: SQLITE_TRACE
|
2813
|
+
**
|
2814
|
+
** These constants identify classes of events that can be monitored
|
2815
|
+
** using the [sqlite3_trace_v2()] tracing logic. The third argument
|
2816
|
+
** to [sqlite3_trace_v2()] is an OR-ed combination of one or more of
|
2817
|
+
** the following constants. ^The first argument to the trace callback
|
2818
|
+
** is one of the following constants.
|
2819
|
+
**
|
2820
|
+
** New tracing constants may be added in future releases.
|
2821
|
+
**
|
2822
|
+
** ^A trace callback has four arguments: xCallback(T,C,P,X).
|
2823
|
+
** ^The T argument is one of the integer type codes above.
|
2824
|
+
** ^The C argument is a copy of the context pointer passed in as the
|
2825
|
+
** fourth argument to [sqlite3_trace_v2()].
|
2826
|
+
** The P and X arguments are pointers whose meanings depend on T.
|
2827
|
+
**
|
2828
|
+
** <dl>
|
2829
|
+
** [[SQLITE_TRACE_STMT]] <dt>SQLITE_TRACE_STMT</dt>
|
2830
|
+
** <dd>^An SQLITE_TRACE_STMT callback is invoked when a prepared statement
|
2831
|
+
** first begins running and possibly at other times during the
|
2832
|
+
** execution of the prepared statement, such as at the start of each
|
2833
|
+
** trigger subprogram. ^The P argument is a pointer to the
|
2834
|
+
** [prepared statement]. ^The X argument is a pointer to a string which
|
2835
|
+
** is the unexpanded SQL text of the prepared statement or an SQL comment
|
2836
|
+
** that indicates the invocation of a trigger. ^The callback can compute
|
2837
|
+
** the same text that would have been returned by the legacy [sqlite3_trace()]
|
2838
|
+
** interface by using the X argument when X begins with "--" and invoking
|
2839
|
+
** [sqlite3_expanded_sql(P)] otherwise.
|
2840
|
+
**
|
2841
|
+
** [[SQLITE_TRACE_PROFILE]] <dt>SQLITE_TRACE_PROFILE</dt>
|
2842
|
+
** <dd>^An SQLITE_TRACE_PROFILE callback provides approximately the same
|
2843
|
+
** information as is provided by the [sqlite3_profile()] callback.
|
2844
|
+
** ^The P argument is a pointer to the [prepared statement] and the
|
2845
|
+
** X argument points to a 64-bit integer which is the estimated of
|
2846
|
+
** the number of nanosecond that the prepared statement took to run.
|
2847
|
+
** ^The SQLITE_TRACE_PROFILE callback is invoked when the statement finishes.
|
2848
|
+
**
|
2849
|
+
** [[SQLITE_TRACE_ROW]] <dt>SQLITE_TRACE_ROW</dt>
|
2850
|
+
** <dd>^An SQLITE_TRACE_ROW callback is invoked whenever a prepared
|
2851
|
+
** statement generates a single row of result.
|
2852
|
+
** ^The P argument is a pointer to the [prepared statement] and the
|
2853
|
+
** X argument is unused.
|
2854
|
+
**
|
2855
|
+
** [[SQLITE_TRACE_CLOSE]] <dt>SQLITE_TRACE_CLOSE</dt>
|
2856
|
+
** <dd>^An SQLITE_TRACE_CLOSE callback is invoked when a database
|
2857
|
+
** connection closes.
|
2858
|
+
** ^The P argument is a pointer to the [database connection] object
|
2859
|
+
** and the X argument is unused.
|
2860
|
+
** </dl>
|
2861
|
+
*/
|
2862
|
+
#define SQLITE_TRACE_STMT 0x01
|
2863
|
+
#define SQLITE_TRACE_PROFILE 0x02
|
2864
|
+
#define SQLITE_TRACE_ROW 0x04
|
2865
|
+
#define SQLITE_TRACE_CLOSE 0x08
|
2866
|
+
|
2867
|
+
/*
|
2868
|
+
** CAPI3REF: SQL Trace Hook
|
2869
|
+
** METHOD: sqlite3
|
2870
|
+
**
|
2871
|
+
** ^The sqlite3_trace_v2(D,M,X,P) interface registers a trace callback
|
2872
|
+
** function X against [database connection] D, using property mask M
|
2873
|
+
** and context pointer P. ^If the X callback is
|
2874
|
+
** NULL or if the M mask is zero, then tracing is disabled. The
|
2875
|
+
** M argument should be the bitwise OR-ed combination of
|
2876
|
+
** zero or more [SQLITE_TRACE] constants.
|
2877
|
+
**
|
2878
|
+
** ^Each call to either sqlite3_trace() or sqlite3_trace_v2() overrides
|
2879
|
+
** (cancels) any prior calls to sqlite3_trace() or sqlite3_trace_v2().
|
2880
|
+
**
|
2881
|
+
** ^The X callback is invoked whenever any of the events identified by
|
2882
|
+
** mask M occur. ^The integer return value from the callback is currently
|
2883
|
+
** ignored, though this may change in future releases. Callback
|
2884
|
+
** implementations should return zero to ensure future compatibility.
|
2885
|
+
**
|
2886
|
+
** ^A trace callback is invoked with four arguments: callback(T,C,P,X).
|
2887
|
+
** ^The T argument is one of the [SQLITE_TRACE]
|
2888
|
+
** constants to indicate why the callback was invoked.
|
2889
|
+
** ^The C argument is a copy of the context pointer.
|
2890
|
+
** The P and X arguments are pointers whose meanings depend on T.
|
2891
|
+
**
|
2892
|
+
** The sqlite3_trace_v2() interface is intended to replace the legacy
|
2893
|
+
** interfaces [sqlite3_trace()] and [sqlite3_profile()], both of which
|
2894
|
+
** are deprecated.
|
2895
|
+
*/
|
2896
|
+
SQLITE_API int SQLITE_STDCALL sqlite3_trace_v2(
|
2897
|
+
sqlite3*,
|
2898
|
+
unsigned uMask,
|
2899
|
+
int(*xCallback)(unsigned,void*,void*,void*),
|
2900
|
+
void *pCtx
|
2901
|
+
);
|
2902
|
+
|
2768
2903
|
/*
|
2769
2904
|
** CAPI3REF: Query Progress Callbacks
|
2770
2905
|
** METHOD: sqlite3
|
@@ -3383,11 +3518,35 @@ SQLITE_API int SQLITE_STDCALL sqlite3_prepare16_v2(
|
|
3383
3518
|
** CAPI3REF: Retrieving Statement SQL
|
3384
3519
|
** METHOD: sqlite3_stmt
|
3385
3520
|
**
|
3386
|
-
** ^
|
3387
|
-
** SQL text used to create
|
3388
|
-
**
|
3521
|
+
** ^The sqlite3_sql(P) interface returns a pointer to a copy of the UTF-8
|
3522
|
+
** SQL text used to create [prepared statement] P if P was
|
3523
|
+
** created by either [sqlite3_prepare_v2()] or [sqlite3_prepare16_v2()].
|
3524
|
+
** ^The sqlite3_expanded_sql(P) interface returns a pointer to a UTF-8
|
3525
|
+
** string containing the SQL text of prepared statement P with
|
3526
|
+
** [bound parameters] expanded.
|
3527
|
+
**
|
3528
|
+
** ^(For example, if a prepared statement is created using the SQL
|
3529
|
+
** text "SELECT $abc,:xyz" and if parameter $abc is bound to integer 2345
|
3530
|
+
** and parameter :xyz is unbound, then sqlite3_sql() will return
|
3531
|
+
** the original string, "SELECT $abc,:xyz" but sqlite3_expanded_sql()
|
3532
|
+
** will return "SELECT 2345,NULL".)^
|
3533
|
+
**
|
3534
|
+
** ^The sqlite3_expanded_sql() interface returns NULL if insufficient memory
|
3535
|
+
** is available to hold the result, or if the result would exceed the
|
3536
|
+
** the maximum string length determined by the [SQLITE_LIMIT_LENGTH].
|
3537
|
+
**
|
3538
|
+
** ^The [SQLITE_TRACE_SIZE_LIMIT] compile-time option limits the size of
|
3539
|
+
** bound parameter expansions. ^The [SQLITE_OMIT_TRACE] compile-time
|
3540
|
+
** option causes sqlite3_expanded_sql() to always return NULL.
|
3541
|
+
**
|
3542
|
+
** ^The string returned by sqlite3_sql(P) is managed by SQLite and is
|
3543
|
+
** automatically freed when the prepared statement is finalized.
|
3544
|
+
** ^The string returned by sqlite3_expanded_sql(P), on the other hand,
|
3545
|
+
** is obtained from [sqlite3_malloc()] and must be free by the application
|
3546
|
+
** by passing it to [sqlite3_free()].
|
3389
3547
|
*/
|
3390
3548
|
SQLITE_API const char *SQLITE_STDCALL sqlite3_sql(sqlite3_stmt *pStmt);
|
3549
|
+
SQLITE_API char *SQLITE_STDCALL sqlite3_expanded_sql(sqlite3_stmt *pStmt);
|
3391
3550
|
|
3392
3551
|
/*
|
3393
3552
|
** CAPI3REF: Determine If An SQL Statement Writes The Database
|
@@ -4545,12 +4704,13 @@ SQLITE_API sqlite3 *SQLITE_STDCALL sqlite3_context_db_handle(sqlite3_context*);
|
|
4545
4704
|
** SQLite will invoke the destructor function X with parameter P exactly
|
4546
4705
|
** once, when the metadata is discarded.
|
4547
4706
|
** SQLite is free to discard the metadata at any time, including: <ul>
|
4548
|
-
** <li> when the corresponding function parameter changes
|
4549
|
-
** <li> when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
|
4550
|
-
** SQL statement
|
4551
|
-
** <li> when sqlite3_set_auxdata() is invoked again on the same
|
4552
|
-
**
|
4553
|
-
**
|
4707
|
+
** <li> ^(when the corresponding function parameter changes)^, or
|
4708
|
+
** <li> ^(when [sqlite3_reset()] or [sqlite3_finalize()] is called for the
|
4709
|
+
** SQL statement)^, or
|
4710
|
+
** <li> ^(when sqlite3_set_auxdata() is invoked again on the same
|
4711
|
+
** parameter)^, or
|
4712
|
+
** <li> ^(during the original sqlite3_set_auxdata() call when a memory
|
4713
|
+
** allocation error occurs.)^ </ul>
|
4554
4714
|
**
|
4555
4715
|
** Note the last bullet in particular. The destructor X in
|
4556
4716
|
** sqlite3_set_auxdata(C,N,P,X) might be called immediately, before the
|
@@ -5187,7 +5347,7 @@ SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *),
|
|
5187
5347
|
** ^The sqlite3_update_hook() interface registers a callback function
|
5188
5348
|
** with the [database connection] identified by the first argument
|
5189
5349
|
** to be invoked whenever a row is updated, inserted or deleted in
|
5190
|
-
** a rowid table.
|
5350
|
+
** a [rowid table].
|
5191
5351
|
** ^Any callback set by a previous call to this function
|
5192
5352
|
** for the same database connection is overridden.
|
5193
5353
|
**
|
@@ -5226,8 +5386,8 @@ SQLITE_API void *SQLITE_STDCALL sqlite3_rollback_hook(sqlite3*, void(*)(void *),
|
|
5226
5386
|
** on the same [database connection] D, or NULL for
|
5227
5387
|
** the first call on D.
|
5228
5388
|
**
|
5229
|
-
** See also the [sqlite3_commit_hook()]
|
5230
|
-
** interfaces.
|
5389
|
+
** See also the [sqlite3_commit_hook()], [sqlite3_rollback_hook()],
|
5390
|
+
** and [sqlite3_preupdate_hook()] interfaces.
|
5231
5391
|
*/
|
5232
5392
|
SQLITE_API void *SQLITE_STDCALL sqlite3_update_hook(
|
5233
5393
|
sqlite3*,
|
@@ -5377,7 +5537,7 @@ SQLITE_API SQLITE_DEPRECATED void SQLITE_STDCALL sqlite3_soft_heap_limit(int N);
|
|
5377
5537
|
** column exists. ^The sqlite3_table_column_metadata() interface returns
|
5378
5538
|
** SQLITE_ERROR and if the specified column does not exist.
|
5379
5539
|
** ^If the column-name parameter to sqlite3_table_column_metadata() is a
|
5380
|
-
** NULL pointer, then this routine simply checks for the
|
5540
|
+
** NULL pointer, then this routine simply checks for the existence of the
|
5381
5541
|
** table and returns SQLITE_OK if the table exists and SQLITE_ERROR if it
|
5382
5542
|
** does not.
|
5383
5543
|
**
|
@@ -5474,9 +5634,18 @@ SQLITE_API int SQLITE_STDCALL sqlite3_table_column_metadata(
|
|
5474
5634
|
** should free this memory by calling [sqlite3_free()].
|
5475
5635
|
**
|
5476
5636
|
** ^Extension loading must be enabled using
|
5477
|
-
** [sqlite3_enable_load_extension()]
|
5637
|
+
** [sqlite3_enable_load_extension()] or
|
5638
|
+
** [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],1,NULL)
|
5639
|
+
** prior to calling this API,
|
5478
5640
|
** otherwise an error will be returned.
|
5479
5641
|
**
|
5642
|
+
** <b>Security warning:</b> It is recommended that the
|
5643
|
+
** [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method be used to enable only this
|
5644
|
+
** interface. The use of the [sqlite3_enable_load_extension()] interface
|
5645
|
+
** should be avoided. This will keep the SQL function [load_extension()]
|
5646
|
+
** disabled and prevent SQL injections from giving attackers
|
5647
|
+
** access to extension loading capabilities.
|
5648
|
+
**
|
5480
5649
|
** See also the [load_extension() SQL function].
|
5481
5650
|
*/
|
5482
5651
|
SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
|
@@ -5499,6 +5668,17 @@ SQLITE_API int SQLITE_STDCALL sqlite3_load_extension(
|
|
5499
5668
|
** ^Call the sqlite3_enable_load_extension() routine with onoff==1
|
5500
5669
|
** to turn extension loading on and call it with onoff==0 to turn
|
5501
5670
|
** it back off again.
|
5671
|
+
**
|
5672
|
+
** ^This interface enables or disables both the C-API
|
5673
|
+
** [sqlite3_load_extension()] and the SQL function [load_extension()].
|
5674
|
+
** ^(Use [sqlite3_db_config](db,[SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION],..)
|
5675
|
+
** to enable or disable only the C-API.)^
|
5676
|
+
**
|
5677
|
+
** <b>Security warning:</b> It is recommended that extension loading
|
5678
|
+
** be disabled using the [SQLITE_DBCONFIG_ENABLE_LOAD_EXTENSION] method
|
5679
|
+
** rather than this interface, so the [load_extension()] SQL function
|
5680
|
+
** remains disabled. This will prevent SQL injections from giving attackers
|
5681
|
+
** access to extension loading capabilities.
|
5502
5682
|
*/
|
5503
5683
|
SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int onoff);
|
5504
5684
|
|
@@ -5512,7 +5692,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int ono
|
|
5512
5692
|
**
|
5513
5693
|
** ^(Even though the function prototype shows that xEntryPoint() takes
|
5514
5694
|
** no arguments and returns void, SQLite invokes xEntryPoint() with three
|
5515
|
-
** arguments and expects
|
5695
|
+
** arguments and expects an integer result as if the signature of the
|
5516
5696
|
** entry point where as follows:
|
5517
5697
|
**
|
5518
5698
|
** <blockquote><pre>
|
@@ -5538,7 +5718,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_enable_load_extension(sqlite3 *db, int ono
|
|
5538
5718
|
** See also: [sqlite3_reset_auto_extension()]
|
5539
5719
|
** and [sqlite3_cancel_auto_extension()]
|
5540
5720
|
*/
|
5541
|
-
SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void
|
5721
|
+
SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void(*xEntryPoint)(void));
|
5542
5722
|
|
5543
5723
|
/*
|
5544
5724
|
** CAPI3REF: Cancel Automatic Extension Loading
|
@@ -5550,7 +5730,7 @@ SQLITE_API int SQLITE_STDCALL sqlite3_auto_extension(void (*xEntryPoint)(void));
|
|
5550
5730
|
** unregistered and it returns 0 if X was not on the list of initialization
|
5551
5731
|
** routines.
|
5552
5732
|
*/
|
5553
|
-
SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void
|
5733
|
+
SQLITE_API int SQLITE_STDCALL sqlite3_cancel_auto_extension(void(*xEntryPoint)(void));
|
5554
5734
|
|
5555
5735
|
/*
|
5556
5736
|
** CAPI3REF: Reset Automatic Extension Loading
|
@@ -6726,6 +6906,18 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int
|
|
6726
6906
|
** memory used by all pager caches associated with the database connection.)^
|
6727
6907
|
** ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_USED is always 0.
|
6728
6908
|
**
|
6909
|
+
** [[SQLITE_DBSTATUS_CACHE_USED_SHARED]]
|
6910
|
+
** ^(<dt>SQLITE_DBSTATUS_CACHE_USED_SHARED</dt>
|
6911
|
+
** <dd>This parameter is similar to DBSTATUS_CACHE_USED, except that if a
|
6912
|
+
** pager cache is shared between two or more connections the bytes of heap
|
6913
|
+
** memory used by that pager cache is divided evenly between the attached
|
6914
|
+
** connections.)^ In other words, if none of the pager caches associated
|
6915
|
+
** with the database connection are shared, this request returns the same
|
6916
|
+
** value as DBSTATUS_CACHE_USED. Or, if one or more or the pager caches are
|
6917
|
+
** shared, the value returned by this call will be smaller than that returned
|
6918
|
+
** by DBSTATUS_CACHE_USED. ^The highwater mark associated with
|
6919
|
+
** SQLITE_DBSTATUS_CACHE_USED_SHARED is always 0.
|
6920
|
+
**
|
6729
6921
|
** [[SQLITE_DBSTATUS_SCHEMA_USED]] ^(<dt>SQLITE_DBSTATUS_SCHEMA_USED</dt>
|
6730
6922
|
** <dd>This parameter returns the approximate number of bytes of heap
|
6731
6923
|
** memory used to store the schema for all databases associated
|
@@ -6783,7 +6975,8 @@ SQLITE_API int SQLITE_STDCALL sqlite3_db_status(sqlite3*, int op, int *pCur, int
|
|
6783
6975
|
#define SQLITE_DBSTATUS_CACHE_MISS 8
|
6784
6976
|
#define SQLITE_DBSTATUS_CACHE_WRITE 9
|
6785
6977
|
#define SQLITE_DBSTATUS_DEFERRED_FKS 10
|
6786
|
-
#define
|
6978
|
+
#define SQLITE_DBSTATUS_CACHE_USED_SHARED 11
|
6979
|
+
#define SQLITE_DBSTATUS_MAX 11 /* Largest defined DBSTATUS */
|
6787
6980
|
|
6788
6981
|
|
6789
6982
|
/*
|
@@ -7137,7 +7330,7 @@ typedef struct sqlite3_backup sqlite3_backup;
|
|
7137
7330
|
** must be different or else sqlite3_backup_init(D,N,S,M) will fail with
|
7138
7331
|
** an error.
|
7139
7332
|
**
|
7140
|
-
** ^A call to sqlite3_backup_init() will fail, returning
|
7333
|
+
** ^A call to sqlite3_backup_init() will fail, returning NULL, if
|
7141
7334
|
** there is already a read or read-write transaction open on the
|
7142
7335
|
** destination database.
|
7143
7336
|
**
|
@@ -7915,11 +8108,107 @@ SQLITE_API void SQLITE_STDCALL sqlite3_stmt_scanstatus_reset(sqlite3_stmt*);
|
|
7915
8108
|
*/
|
7916
8109
|
SQLITE_API int SQLITE_STDCALL sqlite3_db_cacheflush(sqlite3*);
|
7917
8110
|
|
8111
|
+
/*
|
8112
|
+
** CAPI3REF: The pre-update hook.
|
8113
|
+
**
|
8114
|
+
** ^These interfaces are only available if SQLite is compiled using the
|
8115
|
+
** [SQLITE_ENABLE_PREUPDATE_HOOK] compile-time option.
|
8116
|
+
**
|
8117
|
+
** ^The [sqlite3_preupdate_hook()] interface registers a callback function
|
8118
|
+
** that is invoked prior to each [INSERT], [UPDATE], and [DELETE] operation
|
8119
|
+
** on a [rowid table].
|
8120
|
+
** ^At most one preupdate hook may be registered at a time on a single
|
8121
|
+
** [database connection]; each call to [sqlite3_preupdate_hook()] overrides
|
8122
|
+
** the previous setting.
|
8123
|
+
** ^The preupdate hook is disabled by invoking [sqlite3_preupdate_hook()]
|
8124
|
+
** with a NULL pointer as the second parameter.
|
8125
|
+
** ^The third parameter to [sqlite3_preupdate_hook()] is passed through as
|
8126
|
+
** the first parameter to callbacks.
|
8127
|
+
**
|
8128
|
+
** ^The preupdate hook only fires for changes to [rowid tables]; the preupdate
|
8129
|
+
** hook is not invoked for changes to [virtual tables] or [WITHOUT ROWID]
|
8130
|
+
** tables.
|
8131
|
+
**
|
8132
|
+
** ^The second parameter to the preupdate callback is a pointer to
|
8133
|
+
** the [database connection] that registered the preupdate hook.
|
8134
|
+
** ^The third parameter to the preupdate callback is one of the constants
|
8135
|
+
** [SQLITE_INSERT], [SQLITE_DELETE], or [SQLITE_UPDATE] to identify the
|
8136
|
+
** kind of update operation that is about to occur.
|
8137
|
+
** ^(The fourth parameter to the preupdate callback is the name of the
|
8138
|
+
** database within the database connection that is being modified. This
|
8139
|
+
** will be "main" for the main database or "temp" for TEMP tables or
|
8140
|
+
** the name given after the AS keyword in the [ATTACH] statement for attached
|
8141
|
+
** databases.)^
|
8142
|
+
** ^The fifth parameter to the preupdate callback is the name of the
|
8143
|
+
** table that is being modified.
|
8144
|
+
** ^The sixth parameter to the preupdate callback is the initial [rowid] of the
|
8145
|
+
** row being changes for SQLITE_UPDATE and SQLITE_DELETE changes and is
|
8146
|
+
** undefined for SQLITE_INSERT changes.
|
8147
|
+
** ^The seventh parameter to the preupdate callback is the final [rowid] of
|
8148
|
+
** the row being changed for SQLITE_UPDATE and SQLITE_INSERT changes and is
|
8149
|
+
** undefined for SQLITE_DELETE changes.
|
8150
|
+
**
|
8151
|
+
** The [sqlite3_preupdate_old()], [sqlite3_preupdate_new()],
|
8152
|
+
** [sqlite3_preupdate_count()], and [sqlite3_preupdate_depth()] interfaces
|
8153
|
+
** provide additional information about a preupdate event. These routines
|
8154
|
+
** may only be called from within a preupdate callback. Invoking any of
|
8155
|
+
** these routines from outside of a preupdate callback or with a
|
8156
|
+
** [database connection] pointer that is different from the one supplied
|
8157
|
+
** to the preupdate callback results in undefined and probably undesirable
|
8158
|
+
** behavior.
|
8159
|
+
**
|
8160
|
+
** ^The [sqlite3_preupdate_count(D)] interface returns the number of columns
|
8161
|
+
** in the row that is being inserted, updated, or deleted.
|
8162
|
+
**
|
8163
|
+
** ^The [sqlite3_preupdate_old(D,N,P)] interface writes into P a pointer to
|
8164
|
+
** a [protected sqlite3_value] that contains the value of the Nth column of
|
8165
|
+
** the table row before it is updated. The N parameter must be between 0
|
8166
|
+
** and one less than the number of columns or the behavior will be
|
8167
|
+
** undefined. This must only be used within SQLITE_UPDATE and SQLITE_DELETE
|
8168
|
+
** preupdate callbacks; if it is used by an SQLITE_INSERT callback then the
|
8169
|
+
** behavior is undefined. The [sqlite3_value] that P points to
|
8170
|
+
** will be destroyed when the preupdate callback returns.
|
8171
|
+
**
|
8172
|
+
** ^The [sqlite3_preupdate_new(D,N,P)] interface writes into P a pointer to
|
8173
|
+
** a [protected sqlite3_value] that contains the value of the Nth column of
|
8174
|
+
** the table row after it is updated. The N parameter must be between 0
|
8175
|
+
** and one less than the number of columns or the behavior will be
|
8176
|
+
** undefined. This must only be used within SQLITE_INSERT and SQLITE_UPDATE
|
8177
|
+
** preupdate callbacks; if it is used by an SQLITE_DELETE callback then the
|
8178
|
+
** behavior is undefined. The [sqlite3_value] that P points to
|
8179
|
+
** will be destroyed when the preupdate callback returns.
|
8180
|
+
**
|
8181
|
+
** ^The [sqlite3_preupdate_depth(D)] interface returns 0 if the preupdate
|
8182
|
+
** callback was invoked as a result of a direct insert, update, or delete
|
8183
|
+
** operation; or 1 for inserts, updates, or deletes invoked by top-level
|
8184
|
+
** triggers; or 2 for changes resulting from triggers called by top-level
|
8185
|
+
** triggers; and so forth.
|
8186
|
+
**
|
8187
|
+
** See also: [sqlite3_update_hook()]
|
8188
|
+
*/
|
8189
|
+
SQLITE_API SQLITE_EXPERIMENTAL void *SQLITE_STDCALL sqlite3_preupdate_hook(
|
8190
|
+
sqlite3 *db,
|
8191
|
+
void(*xPreUpdate)(
|
8192
|
+
void *pCtx, /* Copy of third arg to preupdate_hook() */
|
8193
|
+
sqlite3 *db, /* Database handle */
|
8194
|
+
int op, /* SQLITE_UPDATE, DELETE or INSERT */
|
8195
|
+
char const *zDb, /* Database name */
|
8196
|
+
char const *zName, /* Table name */
|
8197
|
+
sqlite3_int64 iKey1, /* Rowid of row about to be deleted/updated */
|
8198
|
+
sqlite3_int64 iKey2 /* New rowid value (for a rowid UPDATE) */
|
8199
|
+
),
|
8200
|
+
void*
|
8201
|
+
);
|
8202
|
+
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_old(sqlite3 *, int, sqlite3_value **);
|
8203
|
+
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_count(sqlite3 *);
|
8204
|
+
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_depth(sqlite3 *);
|
8205
|
+
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_preupdate_new(sqlite3 *, int, sqlite3_value **);
|
8206
|
+
|
7918
8207
|
/*
|
7919
8208
|
** CAPI3REF: Low-level system error code
|
7920
8209
|
**
|
7921
8210
|
** ^Attempt to return the underlying operating system error code or error
|
7922
|
-
** number that caused the most
|
8211
|
+
** number that caused the most recent I/O error or failure to open a file.
|
7923
8212
|
** The return value is OS-dependent. For example, on unix systems, after
|
7924
8213
|
** [sqlite3_open_v2()] returns [SQLITE_CANTOPEN], this interface could be
|
7925
8214
|
** called to get back the underlying "errno" that caused the problem, such
|
@@ -7985,20 +8274,29 @@ SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_get(
|
|
7985
8274
|
** CAPI3REF: Start a read transaction on an historical snapshot
|
7986
8275
|
** EXPERIMENTAL
|
7987
8276
|
**
|
7988
|
-
** ^The [sqlite3_snapshot_open(D,S,P)] interface
|
7989
|
-
** read transaction
|
7990
|
-
** [database connection] D
|
8277
|
+
** ^The [sqlite3_snapshot_open(D,S,P)] interface starts a
|
8278
|
+
** read transaction for schema S of
|
8279
|
+
** [database connection] D such that the read transaction
|
8280
|
+
** refers to historical [snapshot] P, rather than the most
|
8281
|
+
** recent change to the database.
|
7991
8282
|
** ^The [sqlite3_snapshot_open()] interface returns SQLITE_OK on success
|
7992
8283
|
** or an appropriate [error code] if it fails.
|
7993
8284
|
**
|
7994
8285
|
** ^In order to succeed, a call to [sqlite3_snapshot_open(D,S,P)] must be
|
7995
|
-
** the first operation
|
7996
|
-
**
|
7997
|
-
** ^
|
8286
|
+
** the first operation following the [BEGIN] that takes the schema S
|
8287
|
+
** out of [autocommit mode].
|
8288
|
+
** ^In other words, schema S must not currently be in
|
8289
|
+
** a transaction for [sqlite3_snapshot_open(D,S,P)] to work, but the
|
8290
|
+
** database connection D must be out of [autocommit mode].
|
8291
|
+
** ^A [snapshot] will fail to open if it has been overwritten by a
|
7998
8292
|
** [checkpoint].
|
7999
|
-
** ^A [
|
8000
|
-
**
|
8001
|
-
**
|
8293
|
+
** ^(A call to [sqlite3_snapshot_open(D,S,P)] will fail if the
|
8294
|
+
** database connection D does not know that the database file for
|
8295
|
+
** schema S is in [WAL mode]. A database connection might not know
|
8296
|
+
** that the database file is in [WAL mode] if there has been no prior
|
8297
|
+
** I/O on that database connection, or if the database entered [WAL mode]
|
8298
|
+
** after the most recent I/O on the database connection.)^
|
8299
|
+
** (Hint: Run "[PRAGMA application_id]" against a newly opened
|
8002
8300
|
** database connection in order to make it ready to use snapshots.)
|
8003
8301
|
**
|
8004
8302
|
** The [sqlite3_snapshot_open()] interface is only available when the
|
@@ -8023,6 +8321,33 @@ SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_open(
|
|
8023
8321
|
*/
|
8024
8322
|
SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3_snapshot*);
|
8025
8323
|
|
8324
|
+
/*
|
8325
|
+
** CAPI3REF: Compare the ages of two snapshot handles.
|
8326
|
+
** EXPERIMENTAL
|
8327
|
+
**
|
8328
|
+
** The sqlite3_snapshot_cmp(P1, P2) interface is used to compare the ages
|
8329
|
+
** of two valid snapshot handles.
|
8330
|
+
**
|
8331
|
+
** If the two snapshot handles are not associated with the same database
|
8332
|
+
** file, the result of the comparison is undefined.
|
8333
|
+
**
|
8334
|
+
** Additionally, the result of the comparison is only valid if both of the
|
8335
|
+
** snapshot handles were obtained by calling sqlite3_snapshot_get() since the
|
8336
|
+
** last time the wal file was deleted. The wal file is deleted when the
|
8337
|
+
** database is changed back to rollback mode or when the number of database
|
8338
|
+
** clients drops to zero. If either snapshot handle was obtained before the
|
8339
|
+
** wal file was last deleted, the value returned by this function
|
8340
|
+
** is undefined.
|
8341
|
+
**
|
8342
|
+
** Otherwise, this API returns a negative value if P1 refers to an older
|
8343
|
+
** snapshot than P2, zero if the two handles refer to the same database
|
8344
|
+
** snapshot, and a positive value if P1 is a newer snapshot than P2.
|
8345
|
+
*/
|
8346
|
+
SQLITE_API SQLITE_EXPERIMENTAL int SQLITE_STDCALL sqlite3_snapshot_cmp(
|
8347
|
+
sqlite3_snapshot *p1,
|
8348
|
+
sqlite3_snapshot *p2
|
8349
|
+
);
|
8350
|
+
|
8026
8351
|
/*
|
8027
8352
|
** Undo the hack that converts floating point types to integer for
|
8028
8353
|
** builds on processors without floating point support.
|
@@ -8034,8 +8359,9 @@ SQLITE_API SQLITE_EXPERIMENTAL void SQLITE_STDCALL sqlite3_snapshot_free(sqlite3
|
|
8034
8359
|
#ifdef __cplusplus
|
8035
8360
|
} /* End of the 'extern "C"' block */
|
8036
8361
|
#endif
|
8037
|
-
#endif /*
|
8362
|
+
#endif /* SQLITE3_H */
|
8038
8363
|
|
8364
|
+
/******** Begin file sqlite3rtree.h *********/
|
8039
8365
|
/*
|
8040
8366
|
** 2010 August 30
|
8041
8367
|
**
|
@@ -8153,6 +8479,1287 @@ struct sqlite3_rtree_query_info {
|
|
8153
8479
|
|
8154
8480
|
#endif /* ifndef _SQLITE3RTREE_H_ */
|
8155
8481
|
|
8482
|
+
/******** End of sqlite3rtree.h *********/
|
8483
|
+
/******** Begin file sqlite3session.h *********/
|
8484
|
+
|
8485
|
+
#if !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION)
|
8486
|
+
#define __SQLITESESSION_H_ 1
|
8487
|
+
|
8488
|
+
/*
|
8489
|
+
** Make sure we can call this stuff from C++.
|
8490
|
+
*/
|
8491
|
+
#ifdef __cplusplus
|
8492
|
+
extern "C" {
|
8493
|
+
#endif
|
8494
|
+
|
8495
|
+
|
8496
|
+
/*
|
8497
|
+
** CAPI3REF: Session Object Handle
|
8498
|
+
*/
|
8499
|
+
typedef struct sqlite3_session sqlite3_session;
|
8500
|
+
|
8501
|
+
/*
|
8502
|
+
** CAPI3REF: Changeset Iterator Handle
|
8503
|
+
*/
|
8504
|
+
typedef struct sqlite3_changeset_iter sqlite3_changeset_iter;
|
8505
|
+
|
8506
|
+
/*
|
8507
|
+
** CAPI3REF: Create A New Session Object
|
8508
|
+
**
|
8509
|
+
** Create a new session object attached to database handle db. If successful,
|
8510
|
+
** a pointer to the new object is written to *ppSession and SQLITE_OK is
|
8511
|
+
** returned. If an error occurs, *ppSession is set to NULL and an SQLite
|
8512
|
+
** error code (e.g. SQLITE_NOMEM) is returned.
|
8513
|
+
**
|
8514
|
+
** It is possible to create multiple session objects attached to a single
|
8515
|
+
** database handle.
|
8516
|
+
**
|
8517
|
+
** Session objects created using this function should be deleted using the
|
8518
|
+
** [sqlite3session_delete()] function before the database handle that they
|
8519
|
+
** are attached to is itself closed. If the database handle is closed before
|
8520
|
+
** the session object is deleted, then the results of calling any session
|
8521
|
+
** module function, including [sqlite3session_delete()] on the session object
|
8522
|
+
** are undefined.
|
8523
|
+
**
|
8524
|
+
** Because the session module uses the [sqlite3_preupdate_hook()] API, it
|
8525
|
+
** is not possible for an application to register a pre-update hook on a
|
8526
|
+
** database handle that has one or more session objects attached. Nor is
|
8527
|
+
** it possible to create a session object attached to a database handle for
|
8528
|
+
** which a pre-update hook is already defined. The results of attempting
|
8529
|
+
** either of these things are undefined.
|
8530
|
+
**
|
8531
|
+
** The session object will be used to create changesets for tables in
|
8532
|
+
** database zDb, where zDb is either "main", or "temp", or the name of an
|
8533
|
+
** attached database. It is not an error if database zDb is not attached
|
8534
|
+
** to the database when the session object is created.
|
8535
|
+
*/
|
8536
|
+
int sqlite3session_create(
|
8537
|
+
sqlite3 *db, /* Database handle */
|
8538
|
+
const char *zDb, /* Name of db (e.g. "main") */
|
8539
|
+
sqlite3_session **ppSession /* OUT: New session object */
|
8540
|
+
);
|
8541
|
+
|
8542
|
+
/*
|
8543
|
+
** CAPI3REF: Delete A Session Object
|
8544
|
+
**
|
8545
|
+
** Delete a session object previously allocated using
|
8546
|
+
** [sqlite3session_create()]. Once a session object has been deleted, the
|
8547
|
+
** results of attempting to use pSession with any other session module
|
8548
|
+
** function are undefined.
|
8549
|
+
**
|
8550
|
+
** Session objects must be deleted before the database handle to which they
|
8551
|
+
** are attached is closed. Refer to the documentation for
|
8552
|
+
** [sqlite3session_create()] for details.
|
8553
|
+
*/
|
8554
|
+
void sqlite3session_delete(sqlite3_session *pSession);
|
8555
|
+
|
8556
|
+
|
8557
|
+
/*
|
8558
|
+
** CAPI3REF: Enable Or Disable A Session Object
|
8559
|
+
**
|
8560
|
+
** Enable or disable the recording of changes by a session object. When
|
8561
|
+
** enabled, a session object records changes made to the database. When
|
8562
|
+
** disabled - it does not. A newly created session object is enabled.
|
8563
|
+
** Refer to the documentation for [sqlite3session_changeset()] for further
|
8564
|
+
** details regarding how enabling and disabling a session object affects
|
8565
|
+
** the eventual changesets.
|
8566
|
+
**
|
8567
|
+
** Passing zero to this function disables the session. Passing a value
|
8568
|
+
** greater than zero enables it. Passing a value less than zero is a
|
8569
|
+
** no-op, and may be used to query the current state of the session.
|
8570
|
+
**
|
8571
|
+
** The return value indicates the final state of the session object: 0 if
|
8572
|
+
** the session is disabled, or 1 if it is enabled.
|
8573
|
+
*/
|
8574
|
+
int sqlite3session_enable(sqlite3_session *pSession, int bEnable);
|
8575
|
+
|
8576
|
+
/*
|
8577
|
+
** CAPI3REF: Set Or Clear the Indirect Change Flag
|
8578
|
+
**
|
8579
|
+
** Each change recorded by a session object is marked as either direct or
|
8580
|
+
** indirect. A change is marked as indirect if either:
|
8581
|
+
**
|
8582
|
+
** <ul>
|
8583
|
+
** <li> The session object "indirect" flag is set when the change is
|
8584
|
+
** made, or
|
8585
|
+
** <li> The change is made by an SQL trigger or foreign key action
|
8586
|
+
** instead of directly as a result of a users SQL statement.
|
8587
|
+
** </ul>
|
8588
|
+
**
|
8589
|
+
** If a single row is affected by more than one operation within a session,
|
8590
|
+
** then the change is considered indirect if all operations meet the criteria
|
8591
|
+
** for an indirect change above, or direct otherwise.
|
8592
|
+
**
|
8593
|
+
** This function is used to set, clear or query the session object indirect
|
8594
|
+
** flag. If the second argument passed to this function is zero, then the
|
8595
|
+
** indirect flag is cleared. If it is greater than zero, the indirect flag
|
8596
|
+
** is set. Passing a value less than zero does not modify the current value
|
8597
|
+
** of the indirect flag, and may be used to query the current state of the
|
8598
|
+
** indirect flag for the specified session object.
|
8599
|
+
**
|
8600
|
+
** The return value indicates the final state of the indirect flag: 0 if
|
8601
|
+
** it is clear, or 1 if it is set.
|
8602
|
+
*/
|
8603
|
+
int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect);
|
8604
|
+
|
8605
|
+
/*
|
8606
|
+
** CAPI3REF: Attach A Table To A Session Object
|
8607
|
+
**
|
8608
|
+
** If argument zTab is not NULL, then it is the name of a table to attach
|
8609
|
+
** to the session object passed as the first argument. All subsequent changes
|
8610
|
+
** made to the table while the session object is enabled will be recorded. See
|
8611
|
+
** documentation for [sqlite3session_changeset()] for further details.
|
8612
|
+
**
|
8613
|
+
** Or, if argument zTab is NULL, then changes are recorded for all tables
|
8614
|
+
** in the database. If additional tables are added to the database (by
|
8615
|
+
** executing "CREATE TABLE" statements) after this call is made, changes for
|
8616
|
+
** the new tables are also recorded.
|
8617
|
+
**
|
8618
|
+
** Changes can only be recorded for tables that have a PRIMARY KEY explicitly
|
8619
|
+
** defined as part of their CREATE TABLE statement. It does not matter if the
|
8620
|
+
** PRIMARY KEY is an "INTEGER PRIMARY KEY" (rowid alias) or not. The PRIMARY
|
8621
|
+
** KEY may consist of a single column, or may be a composite key.
|
8622
|
+
**
|
8623
|
+
** It is not an error if the named table does not exist in the database. Nor
|
8624
|
+
** is it an error if the named table does not have a PRIMARY KEY. However,
|
8625
|
+
** no changes will be recorded in either of these scenarios.
|
8626
|
+
**
|
8627
|
+
** Changes are not recorded for individual rows that have NULL values stored
|
8628
|
+
** in one or more of their PRIMARY KEY columns.
|
8629
|
+
**
|
8630
|
+
** SQLITE_OK is returned if the call completes without error. Or, if an error
|
8631
|
+
** occurs, an SQLite error code (e.g. SQLITE_NOMEM) is returned.
|
8632
|
+
*/
|
8633
|
+
int sqlite3session_attach(
|
8634
|
+
sqlite3_session *pSession, /* Session object */
|
8635
|
+
const char *zTab /* Table name */
|
8636
|
+
);
|
8637
|
+
|
8638
|
+
/*
|
8639
|
+
** CAPI3REF: Set a table filter on a Session Object.
|
8640
|
+
**
|
8641
|
+
** The second argument (xFilter) is the "filter callback". For changes to rows
|
8642
|
+
** in tables that are not attached to the Session oject, the filter is called
|
8643
|
+
** to determine whether changes to the table's rows should be tracked or not.
|
8644
|
+
** If xFilter returns 0, changes is not tracked. Note that once a table is
|
8645
|
+
** attached, xFilter will not be called again.
|
8646
|
+
*/
|
8647
|
+
void sqlite3session_table_filter(
|
8648
|
+
sqlite3_session *pSession, /* Session object */
|
8649
|
+
int(*xFilter)(
|
8650
|
+
void *pCtx, /* Copy of third arg to _filter_table() */
|
8651
|
+
const char *zTab /* Table name */
|
8652
|
+
),
|
8653
|
+
void *pCtx /* First argument passed to xFilter */
|
8654
|
+
);
|
8655
|
+
|
8656
|
+
/*
|
8657
|
+
** CAPI3REF: Generate A Changeset From A Session Object
|
8658
|
+
**
|
8659
|
+
** Obtain a changeset containing changes to the tables attached to the
|
8660
|
+
** session object passed as the first argument. If successful,
|
8661
|
+
** set *ppChangeset to point to a buffer containing the changeset
|
8662
|
+
** and *pnChangeset to the size of the changeset in bytes before returning
|
8663
|
+
** SQLITE_OK. If an error occurs, set both *ppChangeset and *pnChangeset to
|
8664
|
+
** zero and return an SQLite error code.
|
8665
|
+
**
|
8666
|
+
** A changeset consists of zero or more INSERT, UPDATE and/or DELETE changes,
|
8667
|
+
** each representing a change to a single row of an attached table. An INSERT
|
8668
|
+
** change contains the values of each field of a new database row. A DELETE
|
8669
|
+
** contains the original values of each field of a deleted database row. An
|
8670
|
+
** UPDATE change contains the original values of each field of an updated
|
8671
|
+
** database row along with the updated values for each updated non-primary-key
|
8672
|
+
** column. It is not possible for an UPDATE change to represent a change that
|
8673
|
+
** modifies the values of primary key columns. If such a change is made, it
|
8674
|
+
** is represented in a changeset as a DELETE followed by an INSERT.
|
8675
|
+
**
|
8676
|
+
** Changes are not recorded for rows that have NULL values stored in one or
|
8677
|
+
** more of their PRIMARY KEY columns. If such a row is inserted or deleted,
|
8678
|
+
** no corresponding change is present in the changesets returned by this
|
8679
|
+
** function. If an existing row with one or more NULL values stored in
|
8680
|
+
** PRIMARY KEY columns is updated so that all PRIMARY KEY columns are non-NULL,
|
8681
|
+
** only an INSERT is appears in the changeset. Similarly, if an existing row
|
8682
|
+
** with non-NULL PRIMARY KEY values is updated so that one or more of its
|
8683
|
+
** PRIMARY KEY columns are set to NULL, the resulting changeset contains a
|
8684
|
+
** DELETE change only.
|
8685
|
+
**
|
8686
|
+
** The contents of a changeset may be traversed using an iterator created
|
8687
|
+
** using the [sqlite3changeset_start()] API. A changeset may be applied to
|
8688
|
+
** a database with a compatible schema using the [sqlite3changeset_apply()]
|
8689
|
+
** API.
|
8690
|
+
**
|
8691
|
+
** Within a changeset generated by this function, all changes related to a
|
8692
|
+
** single table are grouped together. In other words, when iterating through
|
8693
|
+
** a changeset or when applying a changeset to a database, all changes related
|
8694
|
+
** to a single table are processed before moving on to the next table. Tables
|
8695
|
+
** are sorted in the same order in which they were attached (or auto-attached)
|
8696
|
+
** to the sqlite3_session object. The order in which the changes related to
|
8697
|
+
** a single table are stored is undefined.
|
8698
|
+
**
|
8699
|
+
** Following a successful call to this function, it is the responsibility of
|
8700
|
+
** the caller to eventually free the buffer that *ppChangeset points to using
|
8701
|
+
** [sqlite3_free()].
|
8702
|
+
**
|
8703
|
+
** <h3>Changeset Generation</h3>
|
8704
|
+
**
|
8705
|
+
** Once a table has been attached to a session object, the session object
|
8706
|
+
** records the primary key values of all new rows inserted into the table.
|
8707
|
+
** It also records the original primary key and other column values of any
|
8708
|
+
** deleted or updated rows. For each unique primary key value, data is only
|
8709
|
+
** recorded once - the first time a row with said primary key is inserted,
|
8710
|
+
** updated or deleted in the lifetime of the session.
|
8711
|
+
**
|
8712
|
+
** There is one exception to the previous paragraph: when a row is inserted,
|
8713
|
+
** updated or deleted, if one or more of its primary key columns contain a
|
8714
|
+
** NULL value, no record of the change is made.
|
8715
|
+
**
|
8716
|
+
** The session object therefore accumulates two types of records - those
|
8717
|
+
** that consist of primary key values only (created when the user inserts
|
8718
|
+
** a new record) and those that consist of the primary key values and the
|
8719
|
+
** original values of other table columns (created when the users deletes
|
8720
|
+
** or updates a record).
|
8721
|
+
**
|
8722
|
+
** When this function is called, the requested changeset is created using
|
8723
|
+
** both the accumulated records and the current contents of the database
|
8724
|
+
** file. Specifically:
|
8725
|
+
**
|
8726
|
+
** <ul>
|
8727
|
+
** <li> For each record generated by an insert, the database is queried
|
8728
|
+
** for a row with a matching primary key. If one is found, an INSERT
|
8729
|
+
** change is added to the changeset. If no such row is found, no change
|
8730
|
+
** is added to the changeset.
|
8731
|
+
**
|
8732
|
+
** <li> For each record generated by an update or delete, the database is
|
8733
|
+
** queried for a row with a matching primary key. If such a row is
|
8734
|
+
** found and one or more of the non-primary key fields have been
|
8735
|
+
** modified from their original values, an UPDATE change is added to
|
8736
|
+
** the changeset. Or, if no such row is found in the table, a DELETE
|
8737
|
+
** change is added to the changeset. If there is a row with a matching
|
8738
|
+
** primary key in the database, but all fields contain their original
|
8739
|
+
** values, no change is added to the changeset.
|
8740
|
+
** </ul>
|
8741
|
+
**
|
8742
|
+
** This means, amongst other things, that if a row is inserted and then later
|
8743
|
+
** deleted while a session object is active, neither the insert nor the delete
|
8744
|
+
** will be present in the changeset. Or if a row is deleted and then later a
|
8745
|
+
** row with the same primary key values inserted while a session object is
|
8746
|
+
** active, the resulting changeset will contain an UPDATE change instead of
|
8747
|
+
** a DELETE and an INSERT.
|
8748
|
+
**
|
8749
|
+
** When a session object is disabled (see the [sqlite3session_enable()] API),
|
8750
|
+
** it does not accumulate records when rows are inserted, updated or deleted.
|
8751
|
+
** This may appear to have some counter-intuitive effects if a single row
|
8752
|
+
** is written to more than once during a session. For example, if a row
|
8753
|
+
** is inserted while a session object is enabled, then later deleted while
|
8754
|
+
** the same session object is disabled, no INSERT record will appear in the
|
8755
|
+
** changeset, even though the delete took place while the session was disabled.
|
8756
|
+
** Or, if one field of a row is updated while a session is disabled, and
|
8757
|
+
** another field of the same row is updated while the session is enabled, the
|
8758
|
+
** resulting changeset will contain an UPDATE change that updates both fields.
|
8759
|
+
*/
|
8760
|
+
int sqlite3session_changeset(
|
8761
|
+
sqlite3_session *pSession, /* Session object */
|
8762
|
+
int *pnChangeset, /* OUT: Size of buffer at *ppChangeset */
|
8763
|
+
void **ppChangeset /* OUT: Buffer containing changeset */
|
8764
|
+
);
|
8765
|
+
|
8766
|
+
/*
|
8767
|
+
** CAPI3REF: Load The Difference Between Tables Into A Session
|
8768
|
+
**
|
8769
|
+
** If it is not already attached to the session object passed as the first
|
8770
|
+
** argument, this function attaches table zTbl in the same manner as the
|
8771
|
+
** [sqlite3session_attach()] function. If zTbl does not exist, or if it
|
8772
|
+
** does not have a primary key, this function is a no-op (but does not return
|
8773
|
+
** an error).
|
8774
|
+
**
|
8775
|
+
** Argument zFromDb must be the name of a database ("main", "temp" etc.)
|
8776
|
+
** attached to the same database handle as the session object that contains
|
8777
|
+
** a table compatible with the table attached to the session by this function.
|
8778
|
+
** A table is considered compatible if it:
|
8779
|
+
**
|
8780
|
+
** <ul>
|
8781
|
+
** <li> Has the same name,
|
8782
|
+
** <li> Has the same set of columns declared in the same order, and
|
8783
|
+
** <li> Has the same PRIMARY KEY definition.
|
8784
|
+
** </ul>
|
8785
|
+
**
|
8786
|
+
** If the tables are not compatible, SQLITE_SCHEMA is returned. If the tables
|
8787
|
+
** are compatible but do not have any PRIMARY KEY columns, it is not an error
|
8788
|
+
** but no changes are added to the session object. As with other session
|
8789
|
+
** APIs, tables without PRIMARY KEYs are simply ignored.
|
8790
|
+
**
|
8791
|
+
** This function adds a set of changes to the session object that could be
|
8792
|
+
** used to update the table in database zFrom (call this the "from-table")
|
8793
|
+
** so that its content is the same as the table attached to the session
|
8794
|
+
** object (call this the "to-table"). Specifically:
|
8795
|
+
**
|
8796
|
+
** <ul>
|
8797
|
+
** <li> For each row (primary key) that exists in the to-table but not in
|
8798
|
+
** the from-table, an INSERT record is added to the session object.
|
8799
|
+
**
|
8800
|
+
** <li> For each row (primary key) that exists in the to-table but not in
|
8801
|
+
** the from-table, a DELETE record is added to the session object.
|
8802
|
+
**
|
8803
|
+
** <li> For each row (primary key) that exists in both tables, but features
|
8804
|
+
** different in each, an UPDATE record is added to the session.
|
8805
|
+
** </ul>
|
8806
|
+
**
|
8807
|
+
** To clarify, if this function is called and then a changeset constructed
|
8808
|
+
** using [sqlite3session_changeset()], then after applying that changeset to
|
8809
|
+
** database zFrom the contents of the two compatible tables would be
|
8810
|
+
** identical.
|
8811
|
+
**
|
8812
|
+
** It an error if database zFrom does not exist or does not contain the
|
8813
|
+
** required compatible table.
|
8814
|
+
**
|
8815
|
+
** If the operation successful, SQLITE_OK is returned. Otherwise, an SQLite
|
8816
|
+
** error code. In this case, if argument pzErrMsg is not NULL, *pzErrMsg
|
8817
|
+
** may be set to point to a buffer containing an English language error
|
8818
|
+
** message. It is the responsibility of the caller to free this buffer using
|
8819
|
+
** sqlite3_free().
|
8820
|
+
*/
|
8821
|
+
int sqlite3session_diff(
|
8822
|
+
sqlite3_session *pSession,
|
8823
|
+
const char *zFromDb,
|
8824
|
+
const char *zTbl,
|
8825
|
+
char **pzErrMsg
|
8826
|
+
);
|
8827
|
+
|
8828
|
+
|
8829
|
+
/*
|
8830
|
+
** CAPI3REF: Generate A Patchset From A Session Object
|
8831
|
+
**
|
8832
|
+
** The differences between a patchset and a changeset are that:
|
8833
|
+
**
|
8834
|
+
** <ul>
|
8835
|
+
** <li> DELETE records consist of the primary key fields only. The
|
8836
|
+
** original values of other fields are omitted.
|
8837
|
+
** <li> The original values of any modified fields are omitted from
|
8838
|
+
** UPDATE records.
|
8839
|
+
** </ul>
|
8840
|
+
**
|
8841
|
+
** A patchset blob may be used with up to date versions of all
|
8842
|
+
** sqlite3changeset_xxx API functions except for sqlite3changeset_invert(),
|
8843
|
+
** which returns SQLITE_CORRUPT if it is passed a patchset. Similarly,
|
8844
|
+
** attempting to use a patchset blob with old versions of the
|
8845
|
+
** sqlite3changeset_xxx APIs also provokes an SQLITE_CORRUPT error.
|
8846
|
+
**
|
8847
|
+
** Because the non-primary key "old.*" fields are omitted, no
|
8848
|
+
** SQLITE_CHANGESET_DATA conflicts can be detected or reported if a patchset
|
8849
|
+
** is passed to the sqlite3changeset_apply() API. Other conflict types work
|
8850
|
+
** in the same way as for changesets.
|
8851
|
+
**
|
8852
|
+
** Changes within a patchset are ordered in the same way as for changesets
|
8853
|
+
** generated by the sqlite3session_changeset() function (i.e. all changes for
|
8854
|
+
** a single table are grouped together, tables appear in the order in which
|
8855
|
+
** they were attached to the session object).
|
8856
|
+
*/
|
8857
|
+
int sqlite3session_patchset(
|
8858
|
+
sqlite3_session *pSession, /* Session object */
|
8859
|
+
int *pnPatchset, /* OUT: Size of buffer at *ppChangeset */
|
8860
|
+
void **ppPatchset /* OUT: Buffer containing changeset */
|
8861
|
+
);
|
8862
|
+
|
8863
|
+
/*
|
8864
|
+
** CAPI3REF: Test if a changeset has recorded any changes.
|
8865
|
+
**
|
8866
|
+
** Return non-zero if no changes to attached tables have been recorded by
|
8867
|
+
** the session object passed as the first argument. Otherwise, if one or
|
8868
|
+
** more changes have been recorded, return zero.
|
8869
|
+
**
|
8870
|
+
** Even if this function returns zero, it is possible that calling
|
8871
|
+
** [sqlite3session_changeset()] on the session handle may still return a
|
8872
|
+
** changeset that contains no changes. This can happen when a row in
|
8873
|
+
** an attached table is modified and then later on the original values
|
8874
|
+
** are restored. However, if this function returns non-zero, then it is
|
8875
|
+
** guaranteed that a call to sqlite3session_changeset() will return a
|
8876
|
+
** changeset containing zero changes.
|
8877
|
+
*/
|
8878
|
+
int sqlite3session_isempty(sqlite3_session *pSession);
|
8879
|
+
|
8880
|
+
/*
|
8881
|
+
** CAPI3REF: Create An Iterator To Traverse A Changeset
|
8882
|
+
**
|
8883
|
+
** Create an iterator used to iterate through the contents of a changeset.
|
8884
|
+
** If successful, *pp is set to point to the iterator handle and SQLITE_OK
|
8885
|
+
** is returned. Otherwise, if an error occurs, *pp is set to zero and an
|
8886
|
+
** SQLite error code is returned.
|
8887
|
+
**
|
8888
|
+
** The following functions can be used to advance and query a changeset
|
8889
|
+
** iterator created by this function:
|
8890
|
+
**
|
8891
|
+
** <ul>
|
8892
|
+
** <li> [sqlite3changeset_next()]
|
8893
|
+
** <li> [sqlite3changeset_op()]
|
8894
|
+
** <li> [sqlite3changeset_new()]
|
8895
|
+
** <li> [sqlite3changeset_old()]
|
8896
|
+
** </ul>
|
8897
|
+
**
|
8898
|
+
** It is the responsibility of the caller to eventually destroy the iterator
|
8899
|
+
** by passing it to [sqlite3changeset_finalize()]. The buffer containing the
|
8900
|
+
** changeset (pChangeset) must remain valid until after the iterator is
|
8901
|
+
** destroyed.
|
8902
|
+
**
|
8903
|
+
** Assuming the changeset blob was created by one of the
|
8904
|
+
** [sqlite3session_changeset()], [sqlite3changeset_concat()] or
|
8905
|
+
** [sqlite3changeset_invert()] functions, all changes within the changeset
|
8906
|
+
** that apply to a single table are grouped together. This means that when
|
8907
|
+
** an application iterates through a changeset using an iterator created by
|
8908
|
+
** this function, all changes that relate to a single table are visted
|
8909
|
+
** consecutively. There is no chance that the iterator will visit a change
|
8910
|
+
** the applies to table X, then one for table Y, and then later on visit
|
8911
|
+
** another change for table X.
|
8912
|
+
*/
|
8913
|
+
int sqlite3changeset_start(
|
8914
|
+
sqlite3_changeset_iter **pp, /* OUT: New changeset iterator handle */
|
8915
|
+
int nChangeset, /* Size of changeset blob in bytes */
|
8916
|
+
void *pChangeset /* Pointer to blob containing changeset */
|
8917
|
+
);
|
8918
|
+
|
8919
|
+
|
8920
|
+
/*
|
8921
|
+
** CAPI3REF: Advance A Changeset Iterator
|
8922
|
+
**
|
8923
|
+
** This function may only be used with iterators created by function
|
8924
|
+
** [sqlite3changeset_start()]. If it is called on an iterator passed to
|
8925
|
+
** a conflict-handler callback by [sqlite3changeset_apply()], SQLITE_MISUSE
|
8926
|
+
** is returned and the call has no effect.
|
8927
|
+
**
|
8928
|
+
** Immediately after an iterator is created by sqlite3changeset_start(), it
|
8929
|
+
** does not point to any change in the changeset. Assuming the changeset
|
8930
|
+
** is not empty, the first call to this function advances the iterator to
|
8931
|
+
** point to the first change in the changeset. Each subsequent call advances
|
8932
|
+
** the iterator to point to the next change in the changeset (if any). If
|
8933
|
+
** no error occurs and the iterator points to a valid change after a call
|
8934
|
+
** to sqlite3changeset_next() has advanced it, SQLITE_ROW is returned.
|
8935
|
+
** Otherwise, if all changes in the changeset have already been visited,
|
8936
|
+
** SQLITE_DONE is returned.
|
8937
|
+
**
|
8938
|
+
** If an error occurs, an SQLite error code is returned. Possible error
|
8939
|
+
** codes include SQLITE_CORRUPT (if the changeset buffer is corrupt) or
|
8940
|
+
** SQLITE_NOMEM.
|
8941
|
+
*/
|
8942
|
+
int sqlite3changeset_next(sqlite3_changeset_iter *pIter);
|
8943
|
+
|
8944
|
+
/*
|
8945
|
+
** CAPI3REF: Obtain The Current Operation From A Changeset Iterator
|
8946
|
+
**
|
8947
|
+
** The pIter argument passed to this function may either be an iterator
|
8948
|
+
** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
|
8949
|
+
** created by [sqlite3changeset_start()]. In the latter case, the most recent
|
8950
|
+
** call to [sqlite3changeset_next()] must have returned [SQLITE_ROW]. If this
|
8951
|
+
** is not the case, this function returns [SQLITE_MISUSE].
|
8952
|
+
**
|
8953
|
+
** If argument pzTab is not NULL, then *pzTab is set to point to a
|
8954
|
+
** nul-terminated utf-8 encoded string containing the name of the table
|
8955
|
+
** affected by the current change. The buffer remains valid until either
|
8956
|
+
** sqlite3changeset_next() is called on the iterator or until the
|
8957
|
+
** conflict-handler function returns. If pnCol is not NULL, then *pnCol is
|
8958
|
+
** set to the number of columns in the table affected by the change. If
|
8959
|
+
** pbIncorrect is not NULL, then *pbIndirect is set to true (1) if the change
|
8960
|
+
** is an indirect change, or false (0) otherwise. See the documentation for
|
8961
|
+
** [sqlite3session_indirect()] for a description of direct and indirect
|
8962
|
+
** changes. Finally, if pOp is not NULL, then *pOp is set to one of
|
8963
|
+
** [SQLITE_INSERT], [SQLITE_DELETE] or [SQLITE_UPDATE], depending on the
|
8964
|
+
** type of change that the iterator currently points to.
|
8965
|
+
**
|
8966
|
+
** If no error occurs, SQLITE_OK is returned. If an error does occur, an
|
8967
|
+
** SQLite error code is returned. The values of the output variables may not
|
8968
|
+
** be trusted in this case.
|
8969
|
+
*/
|
8970
|
+
int sqlite3changeset_op(
|
8971
|
+
sqlite3_changeset_iter *pIter, /* Iterator object */
|
8972
|
+
const char **pzTab, /* OUT: Pointer to table name */
|
8973
|
+
int *pnCol, /* OUT: Number of columns in table */
|
8974
|
+
int *pOp, /* OUT: SQLITE_INSERT, DELETE or UPDATE */
|
8975
|
+
int *pbIndirect /* OUT: True for an 'indirect' change */
|
8976
|
+
);
|
8977
|
+
|
8978
|
+
/*
|
8979
|
+
** CAPI3REF: Obtain The Primary Key Definition Of A Table
|
8980
|
+
**
|
8981
|
+
** For each modified table, a changeset includes the following:
|
8982
|
+
**
|
8983
|
+
** <ul>
|
8984
|
+
** <li> The number of columns in the table, and
|
8985
|
+
** <li> Which of those columns make up the tables PRIMARY KEY.
|
8986
|
+
** </ul>
|
8987
|
+
**
|
8988
|
+
** This function is used to find which columns comprise the PRIMARY KEY of
|
8989
|
+
** the table modified by the change that iterator pIter currently points to.
|
8990
|
+
** If successful, *pabPK is set to point to an array of nCol entries, where
|
8991
|
+
** nCol is the number of columns in the table. Elements of *pabPK are set to
|
8992
|
+
** 0x01 if the corresponding column is part of the tables primary key, or
|
8993
|
+
** 0x00 if it is not.
|
8994
|
+
**
|
8995
|
+
** If argumet pnCol is not NULL, then *pnCol is set to the number of columns
|
8996
|
+
** in the table.
|
8997
|
+
**
|
8998
|
+
** If this function is called when the iterator does not point to a valid
|
8999
|
+
** entry, SQLITE_MISUSE is returned and the output variables zeroed. Otherwise,
|
9000
|
+
** SQLITE_OK is returned and the output variables populated as described
|
9001
|
+
** above.
|
9002
|
+
*/
|
9003
|
+
int sqlite3changeset_pk(
|
9004
|
+
sqlite3_changeset_iter *pIter, /* Iterator object */
|
9005
|
+
unsigned char **pabPK, /* OUT: Array of boolean - true for PK cols */
|
9006
|
+
int *pnCol /* OUT: Number of entries in output array */
|
9007
|
+
);
|
9008
|
+
|
9009
|
+
/*
|
9010
|
+
** CAPI3REF: Obtain old.* Values From A Changeset Iterator
|
9011
|
+
**
|
9012
|
+
** The pIter argument passed to this function may either be an iterator
|
9013
|
+
** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
|
9014
|
+
** created by [sqlite3changeset_start()]. In the latter case, the most recent
|
9015
|
+
** call to [sqlite3changeset_next()] must have returned SQLITE_ROW.
|
9016
|
+
** Furthermore, it may only be called if the type of change that the iterator
|
9017
|
+
** currently points to is either [SQLITE_DELETE] or [SQLITE_UPDATE]. Otherwise,
|
9018
|
+
** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
|
9019
|
+
**
|
9020
|
+
** Argument iVal must be greater than or equal to 0, and less than the number
|
9021
|
+
** of columns in the table affected by the current change. Otherwise,
|
9022
|
+
** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
|
9023
|
+
**
|
9024
|
+
** If successful, this function sets *ppValue to point to a protected
|
9025
|
+
** sqlite3_value object containing the iVal'th value from the vector of
|
9026
|
+
** original row values stored as part of the UPDATE or DELETE change and
|
9027
|
+
** returns SQLITE_OK. The name of the function comes from the fact that this
|
9028
|
+
** is similar to the "old.*" columns available to update or delete triggers.
|
9029
|
+
**
|
9030
|
+
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9031
|
+
** is returned and *ppValue is set to NULL.
|
9032
|
+
*/
|
9033
|
+
int sqlite3changeset_old(
|
9034
|
+
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9035
|
+
int iVal, /* Column number */
|
9036
|
+
sqlite3_value **ppValue /* OUT: Old value (or NULL pointer) */
|
9037
|
+
);
|
9038
|
+
|
9039
|
+
/*
|
9040
|
+
** CAPI3REF: Obtain new.* Values From A Changeset Iterator
|
9041
|
+
**
|
9042
|
+
** The pIter argument passed to this function may either be an iterator
|
9043
|
+
** passed to a conflict-handler by [sqlite3changeset_apply()], or an iterator
|
9044
|
+
** created by [sqlite3changeset_start()]. In the latter case, the most recent
|
9045
|
+
** call to [sqlite3changeset_next()] must have returned SQLITE_ROW.
|
9046
|
+
** Furthermore, it may only be called if the type of change that the iterator
|
9047
|
+
** currently points to is either [SQLITE_UPDATE] or [SQLITE_INSERT]. Otherwise,
|
9048
|
+
** this function returns [SQLITE_MISUSE] and sets *ppValue to NULL.
|
9049
|
+
**
|
9050
|
+
** Argument iVal must be greater than or equal to 0, and less than the number
|
9051
|
+
** of columns in the table affected by the current change. Otherwise,
|
9052
|
+
** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
|
9053
|
+
**
|
9054
|
+
** If successful, this function sets *ppValue to point to a protected
|
9055
|
+
** sqlite3_value object containing the iVal'th value from the vector of
|
9056
|
+
** new row values stored as part of the UPDATE or INSERT change and
|
9057
|
+
** returns SQLITE_OK. If the change is an UPDATE and does not include
|
9058
|
+
** a new value for the requested column, *ppValue is set to NULL and
|
9059
|
+
** SQLITE_OK returned. The name of the function comes from the fact that
|
9060
|
+
** this is similar to the "new.*" columns available to update or delete
|
9061
|
+
** triggers.
|
9062
|
+
**
|
9063
|
+
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9064
|
+
** is returned and *ppValue is set to NULL.
|
9065
|
+
*/
|
9066
|
+
int sqlite3changeset_new(
|
9067
|
+
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9068
|
+
int iVal, /* Column number */
|
9069
|
+
sqlite3_value **ppValue /* OUT: New value (or NULL pointer) */
|
9070
|
+
);
|
9071
|
+
|
9072
|
+
/*
|
9073
|
+
** CAPI3REF: Obtain Conflicting Row Values From A Changeset Iterator
|
9074
|
+
**
|
9075
|
+
** This function should only be used with iterator objects passed to a
|
9076
|
+
** conflict-handler callback by [sqlite3changeset_apply()] with either
|
9077
|
+
** [SQLITE_CHANGESET_DATA] or [SQLITE_CHANGESET_CONFLICT]. If this function
|
9078
|
+
** is called on any other iterator, [SQLITE_MISUSE] is returned and *ppValue
|
9079
|
+
** is set to NULL.
|
9080
|
+
**
|
9081
|
+
** Argument iVal must be greater than or equal to 0, and less than the number
|
9082
|
+
** of columns in the table affected by the current change. Otherwise,
|
9083
|
+
** [SQLITE_RANGE] is returned and *ppValue is set to NULL.
|
9084
|
+
**
|
9085
|
+
** If successful, this function sets *ppValue to point to a protected
|
9086
|
+
** sqlite3_value object containing the iVal'th value from the
|
9087
|
+
** "conflicting row" associated with the current conflict-handler callback
|
9088
|
+
** and returns SQLITE_OK.
|
9089
|
+
**
|
9090
|
+
** If some other error occurs (e.g. an OOM condition), an SQLite error code
|
9091
|
+
** is returned and *ppValue is set to NULL.
|
9092
|
+
*/
|
9093
|
+
int sqlite3changeset_conflict(
|
9094
|
+
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9095
|
+
int iVal, /* Column number */
|
9096
|
+
sqlite3_value **ppValue /* OUT: Value from conflicting row */
|
9097
|
+
);
|
9098
|
+
|
9099
|
+
/*
|
9100
|
+
** CAPI3REF: Determine The Number Of Foreign Key Constraint Violations
|
9101
|
+
**
|
9102
|
+
** This function may only be called with an iterator passed to an
|
9103
|
+
** SQLITE_CHANGESET_FOREIGN_KEY conflict handler callback. In this case
|
9104
|
+
** it sets the output variable to the total number of known foreign key
|
9105
|
+
** violations in the destination database and returns SQLITE_OK.
|
9106
|
+
**
|
9107
|
+
** In all other cases this function returns SQLITE_MISUSE.
|
9108
|
+
*/
|
9109
|
+
int sqlite3changeset_fk_conflicts(
|
9110
|
+
sqlite3_changeset_iter *pIter, /* Changeset iterator */
|
9111
|
+
int *pnOut /* OUT: Number of FK violations */
|
9112
|
+
);
|
9113
|
+
|
9114
|
+
|
9115
|
+
/*
|
9116
|
+
** CAPI3REF: Finalize A Changeset Iterator
|
9117
|
+
**
|
9118
|
+
** This function is used to finalize an iterator allocated with
|
9119
|
+
** [sqlite3changeset_start()].
|
9120
|
+
**
|
9121
|
+
** This function should only be called on iterators created using the
|
9122
|
+
** [sqlite3changeset_start()] function. If an application calls this
|
9123
|
+
** function with an iterator passed to a conflict-handler by
|
9124
|
+
** [sqlite3changeset_apply()], [SQLITE_MISUSE] is immediately returned and the
|
9125
|
+
** call has no effect.
|
9126
|
+
**
|
9127
|
+
** If an error was encountered within a call to an sqlite3changeset_xxx()
|
9128
|
+
** function (for example an [SQLITE_CORRUPT] in [sqlite3changeset_next()] or an
|
9129
|
+
** [SQLITE_NOMEM] in [sqlite3changeset_new()]) then an error code corresponding
|
9130
|
+
** to that error is returned by this function. Otherwise, SQLITE_OK is
|
9131
|
+
** returned. This is to allow the following pattern (pseudo-code):
|
9132
|
+
**
|
9133
|
+
** sqlite3changeset_start();
|
9134
|
+
** while( SQLITE_ROW==sqlite3changeset_next() ){
|
9135
|
+
** // Do something with change.
|
9136
|
+
** }
|
9137
|
+
** rc = sqlite3changeset_finalize();
|
9138
|
+
** if( rc!=SQLITE_OK ){
|
9139
|
+
** // An error has occurred
|
9140
|
+
** }
|
9141
|
+
*/
|
9142
|
+
int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter);
|
9143
|
+
|
9144
|
+
/*
|
9145
|
+
** CAPI3REF: Invert A Changeset
|
9146
|
+
**
|
9147
|
+
** This function is used to "invert" a changeset object. Applying an inverted
|
9148
|
+
** changeset to a database reverses the effects of applying the uninverted
|
9149
|
+
** changeset. Specifically:
|
9150
|
+
**
|
9151
|
+
** <ul>
|
9152
|
+
** <li> Each DELETE change is changed to an INSERT, and
|
9153
|
+
** <li> Each INSERT change is changed to a DELETE, and
|
9154
|
+
** <li> For each UPDATE change, the old.* and new.* values are exchanged.
|
9155
|
+
** </ul>
|
9156
|
+
**
|
9157
|
+
** This function does not change the order in which changes appear within
|
9158
|
+
** the changeset. It merely reverses the sense of each individual change.
|
9159
|
+
**
|
9160
|
+
** If successful, a pointer to a buffer containing the inverted changeset
|
9161
|
+
** is stored in *ppOut, the size of the same buffer is stored in *pnOut, and
|
9162
|
+
** SQLITE_OK is returned. If an error occurs, both *pnOut and *ppOut are
|
9163
|
+
** zeroed and an SQLite error code returned.
|
9164
|
+
**
|
9165
|
+
** It is the responsibility of the caller to eventually call sqlite3_free()
|
9166
|
+
** on the *ppOut pointer to free the buffer allocation following a successful
|
9167
|
+
** call to this function.
|
9168
|
+
**
|
9169
|
+
** WARNING/TODO: This function currently assumes that the input is a valid
|
9170
|
+
** changeset. If it is not, the results are undefined.
|
9171
|
+
*/
|
9172
|
+
int sqlite3changeset_invert(
|
9173
|
+
int nIn, const void *pIn, /* Input changeset */
|
9174
|
+
int *pnOut, void **ppOut /* OUT: Inverse of input */
|
9175
|
+
);
|
9176
|
+
|
9177
|
+
/*
|
9178
|
+
** CAPI3REF: Concatenate Two Changeset Objects
|
9179
|
+
**
|
9180
|
+
** This function is used to concatenate two changesets, A and B, into a
|
9181
|
+
** single changeset. The result is a changeset equivalent to applying
|
9182
|
+
** changeset A followed by changeset B.
|
9183
|
+
**
|
9184
|
+
** This function combines the two input changesets using an
|
9185
|
+
** sqlite3_changegroup object. Calling it produces similar results as the
|
9186
|
+
** following code fragment:
|
9187
|
+
**
|
9188
|
+
** sqlite3_changegroup *pGrp;
|
9189
|
+
** rc = sqlite3_changegroup_new(&pGrp);
|
9190
|
+
** if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nA, pA);
|
9191
|
+
** if( rc==SQLITE_OK ) rc = sqlite3changegroup_add(pGrp, nB, pB);
|
9192
|
+
** if( rc==SQLITE_OK ){
|
9193
|
+
** rc = sqlite3changegroup_output(pGrp, pnOut, ppOut);
|
9194
|
+
** }else{
|
9195
|
+
** *ppOut = 0;
|
9196
|
+
** *pnOut = 0;
|
9197
|
+
** }
|
9198
|
+
**
|
9199
|
+
** Refer to the sqlite3_changegroup documentation below for details.
|
9200
|
+
*/
|
9201
|
+
int sqlite3changeset_concat(
|
9202
|
+
int nA, /* Number of bytes in buffer pA */
|
9203
|
+
void *pA, /* Pointer to buffer containing changeset A */
|
9204
|
+
int nB, /* Number of bytes in buffer pB */
|
9205
|
+
void *pB, /* Pointer to buffer containing changeset B */
|
9206
|
+
int *pnOut, /* OUT: Number of bytes in output changeset */
|
9207
|
+
void **ppOut /* OUT: Buffer containing output changeset */
|
9208
|
+
);
|
9209
|
+
|
9210
|
+
|
9211
|
+
/*
|
9212
|
+
** Changegroup handle.
|
9213
|
+
*/
|
9214
|
+
typedef struct sqlite3_changegroup sqlite3_changegroup;
|
9215
|
+
|
9216
|
+
/*
|
9217
|
+
** CAPI3REF: Combine two or more changesets into a single changeset.
|
9218
|
+
**
|
9219
|
+
** An sqlite3_changegroup object is used to combine two or more changesets
|
9220
|
+
** (or patchsets) into a single changeset (or patchset). A single changegroup
|
9221
|
+
** object may combine changesets or patchsets, but not both. The output is
|
9222
|
+
** always in the same format as the input.
|
9223
|
+
**
|
9224
|
+
** If successful, this function returns SQLITE_OK and populates (*pp) with
|
9225
|
+
** a pointer to a new sqlite3_changegroup object before returning. The caller
|
9226
|
+
** should eventually free the returned object using a call to
|
9227
|
+
** sqlite3changegroup_delete(). If an error occurs, an SQLite error code
|
9228
|
+
** (i.e. SQLITE_NOMEM) is returned and *pp is set to NULL.
|
9229
|
+
**
|
9230
|
+
** The usual usage pattern for an sqlite3_changegroup object is as follows:
|
9231
|
+
**
|
9232
|
+
** <ul>
|
9233
|
+
** <li> It is created using a call to sqlite3changegroup_new().
|
9234
|
+
**
|
9235
|
+
** <li> Zero or more changesets (or patchsets) are added to the object
|
9236
|
+
** by calling sqlite3changegroup_add().
|
9237
|
+
**
|
9238
|
+
** <li> The result of combining all input changesets together is obtained
|
9239
|
+
** by the application via a call to sqlite3changegroup_output().
|
9240
|
+
**
|
9241
|
+
** <li> The object is deleted using a call to sqlite3changegroup_delete().
|
9242
|
+
** </ul>
|
9243
|
+
**
|
9244
|
+
** Any number of calls to add() and output() may be made between the calls to
|
9245
|
+
** new() and delete(), and in any order.
|
9246
|
+
**
|
9247
|
+
** As well as the regular sqlite3changegroup_add() and
|
9248
|
+
** sqlite3changegroup_output() functions, also available are the streaming
|
9249
|
+
** versions sqlite3changegroup_add_strm() and sqlite3changegroup_output_strm().
|
9250
|
+
*/
|
9251
|
+
int sqlite3changegroup_new(sqlite3_changegroup **pp);
|
9252
|
+
|
9253
|
+
/*
|
9254
|
+
** Add all changes within the changeset (or patchset) in buffer pData (size
|
9255
|
+
** nData bytes) to the changegroup.
|
9256
|
+
**
|
9257
|
+
** If the buffer contains a patchset, then all prior calls to this function
|
9258
|
+
** on the same changegroup object must also have specified patchsets. Or, if
|
9259
|
+
** the buffer contains a changeset, so must have the earlier calls to this
|
9260
|
+
** function. Otherwise, SQLITE_ERROR is returned and no changes are added
|
9261
|
+
** to the changegroup.
|
9262
|
+
**
|
9263
|
+
** Rows within the changeset and changegroup are identified by the values in
|
9264
|
+
** their PRIMARY KEY columns. A change in the changeset is considered to
|
9265
|
+
** apply to the same row as a change already present in the changegroup if
|
9266
|
+
** the two rows have the same primary key.
|
9267
|
+
**
|
9268
|
+
** Changes to rows that that do not already appear in the changegroup are
|
9269
|
+
** simply copied into it. Or, if both the new changeset and the changegroup
|
9270
|
+
** contain changes that apply to a single row, the final contents of the
|
9271
|
+
** changegroup depends on the type of each change, as follows:
|
9272
|
+
**
|
9273
|
+
** <table border=1 style="margin-left:8ex;margin-right:8ex">
|
9274
|
+
** <tr><th style="white-space:pre">Existing Change </th>
|
9275
|
+
** <th style="white-space:pre">New Change </th>
|
9276
|
+
** <th>Output Change
|
9277
|
+
** <tr><td>INSERT <td>INSERT <td>
|
9278
|
+
** The new change is ignored. This case does not occur if the new
|
9279
|
+
** changeset was recorded immediately after the changesets already
|
9280
|
+
** added to the changegroup.
|
9281
|
+
** <tr><td>INSERT <td>UPDATE <td>
|
9282
|
+
** The INSERT change remains in the changegroup. The values in the
|
9283
|
+
** INSERT change are modified as if the row was inserted by the
|
9284
|
+
** existing change and then updated according to the new change.
|
9285
|
+
** <tr><td>INSERT <td>DELETE <td>
|
9286
|
+
** The existing INSERT is removed from the changegroup. The DELETE is
|
9287
|
+
** not added.
|
9288
|
+
** <tr><td>UPDATE <td>INSERT <td>
|
9289
|
+
** The new change is ignored. This case does not occur if the new
|
9290
|
+
** changeset was recorded immediately after the changesets already
|
9291
|
+
** added to the changegroup.
|
9292
|
+
** <tr><td>UPDATE <td>UPDATE <td>
|
9293
|
+
** The existing UPDATE remains within the changegroup. It is amended
|
9294
|
+
** so that the accompanying values are as if the row was updated once
|
9295
|
+
** by the existing change and then again by the new change.
|
9296
|
+
** <tr><td>UPDATE <td>DELETE <td>
|
9297
|
+
** The existing UPDATE is replaced by the new DELETE within the
|
9298
|
+
** changegroup.
|
9299
|
+
** <tr><td>DELETE <td>INSERT <td>
|
9300
|
+
** If one or more of the column values in the row inserted by the
|
9301
|
+
** new change differ from those in the row deleted by the existing
|
9302
|
+
** change, the existing DELETE is replaced by an UPDATE within the
|
9303
|
+
** changegroup. Otherwise, if the inserted row is exactly the same
|
9304
|
+
** as the deleted row, the existing DELETE is simply discarded.
|
9305
|
+
** <tr><td>DELETE <td>UPDATE <td>
|
9306
|
+
** The new change is ignored. This case does not occur if the new
|
9307
|
+
** changeset was recorded immediately after the changesets already
|
9308
|
+
** added to the changegroup.
|
9309
|
+
** <tr><td>DELETE <td>DELETE <td>
|
9310
|
+
** The new change is ignored. This case does not occur if the new
|
9311
|
+
** changeset was recorded immediately after the changesets already
|
9312
|
+
** added to the changegroup.
|
9313
|
+
** </table>
|
9314
|
+
**
|
9315
|
+
** If the new changeset contains changes to a table that is already present
|
9316
|
+
** in the changegroup, then the number of columns and the position of the
|
9317
|
+
** primary key columns for the table must be consistent. If this is not the
|
9318
|
+
** case, this function fails with SQLITE_SCHEMA. If the input changeset
|
9319
|
+
** appears to be corrupt and the corruption is detected, SQLITE_CORRUPT is
|
9320
|
+
** returned. Or, if an out-of-memory condition occurs during processing, this
|
9321
|
+
** function returns SQLITE_NOMEM. In all cases, if an error occurs the
|
9322
|
+
** final contents of the changegroup is undefined.
|
9323
|
+
**
|
9324
|
+
** If no error occurs, SQLITE_OK is returned.
|
9325
|
+
*/
|
9326
|
+
int sqlite3changegroup_add(sqlite3_changegroup*, int nData, void *pData);
|
9327
|
+
|
9328
|
+
/*
|
9329
|
+
** Obtain a buffer containing a changeset (or patchset) representing the
|
9330
|
+
** current contents of the changegroup. If the inputs to the changegroup
|
9331
|
+
** were themselves changesets, the output is a changeset. Or, if the
|
9332
|
+
** inputs were patchsets, the output is also a patchset.
|
9333
|
+
**
|
9334
|
+
** As with the output of the sqlite3session_changeset() and
|
9335
|
+
** sqlite3session_patchset() functions, all changes related to a single
|
9336
|
+
** table are grouped together in the output of this function. Tables appear
|
9337
|
+
** in the same order as for the very first changeset added to the changegroup.
|
9338
|
+
** If the second or subsequent changesets added to the changegroup contain
|
9339
|
+
** changes for tables that do not appear in the first changeset, they are
|
9340
|
+
** appended onto the end of the output changeset, again in the order in
|
9341
|
+
** which they are first encountered.
|
9342
|
+
**
|
9343
|
+
** If an error occurs, an SQLite error code is returned and the output
|
9344
|
+
** variables (*pnData) and (*ppData) are set to 0. Otherwise, SQLITE_OK
|
9345
|
+
** is returned and the output variables are set to the size of and a
|
9346
|
+
** pointer to the output buffer, respectively. In this case it is the
|
9347
|
+
** responsibility of the caller to eventually free the buffer using a
|
9348
|
+
** call to sqlite3_free().
|
9349
|
+
*/
|
9350
|
+
int sqlite3changegroup_output(
|
9351
|
+
sqlite3_changegroup*,
|
9352
|
+
int *pnData, /* OUT: Size of output buffer in bytes */
|
9353
|
+
void **ppData /* OUT: Pointer to output buffer */
|
9354
|
+
);
|
9355
|
+
|
9356
|
+
/*
|
9357
|
+
** Delete a changegroup object.
|
9358
|
+
*/
|
9359
|
+
void sqlite3changegroup_delete(sqlite3_changegroup*);
|
9360
|
+
|
9361
|
+
/*
|
9362
|
+
** CAPI3REF: Apply A Changeset To A Database
|
9363
|
+
**
|
9364
|
+
** Apply a changeset to a database. This function attempts to update the
|
9365
|
+
** "main" database attached to handle db with the changes found in the
|
9366
|
+
** changeset passed via the second and third arguments.
|
9367
|
+
**
|
9368
|
+
** The fourth argument (xFilter) passed to this function is the "filter
|
9369
|
+
** callback". If it is not NULL, then for each table affected by at least one
|
9370
|
+
** change in the changeset, the filter callback is invoked with
|
9371
|
+
** the table name as the second argument, and a copy of the context pointer
|
9372
|
+
** passed as the sixth argument to this function as the first. If the "filter
|
9373
|
+
** callback" returns zero, then no attempt is made to apply any changes to
|
9374
|
+
** the table. Otherwise, if the return value is non-zero or the xFilter
|
9375
|
+
** argument to this function is NULL, all changes related to the table are
|
9376
|
+
** attempted.
|
9377
|
+
**
|
9378
|
+
** For each table that is not excluded by the filter callback, this function
|
9379
|
+
** tests that the target database contains a compatible table. A table is
|
9380
|
+
** considered compatible if all of the following are true:
|
9381
|
+
**
|
9382
|
+
** <ul>
|
9383
|
+
** <li> The table has the same name as the name recorded in the
|
9384
|
+
** changeset, and
|
9385
|
+
** <li> The table has the same number of columns as recorded in the
|
9386
|
+
** changeset, and
|
9387
|
+
** <li> The table has primary key columns in the same position as
|
9388
|
+
** recorded in the changeset.
|
9389
|
+
** </ul>
|
9390
|
+
**
|
9391
|
+
** If there is no compatible table, it is not an error, but none of the
|
9392
|
+
** changes associated with the table are applied. A warning message is issued
|
9393
|
+
** via the sqlite3_log() mechanism with the error code SQLITE_SCHEMA. At most
|
9394
|
+
** one such warning is issued for each table in the changeset.
|
9395
|
+
**
|
9396
|
+
** For each change for which there is a compatible table, an attempt is made
|
9397
|
+
** to modify the table contents according to the UPDATE, INSERT or DELETE
|
9398
|
+
** change. If a change cannot be applied cleanly, the conflict handler
|
9399
|
+
** function passed as the fifth argument to sqlite3changeset_apply() may be
|
9400
|
+
** invoked. A description of exactly when the conflict handler is invoked for
|
9401
|
+
** each type of change is below.
|
9402
|
+
**
|
9403
|
+
** Unlike the xFilter argument, xConflict may not be passed NULL. The results
|
9404
|
+
** of passing anything other than a valid function pointer as the xConflict
|
9405
|
+
** argument are undefined.
|
9406
|
+
**
|
9407
|
+
** Each time the conflict handler function is invoked, it must return one
|
9408
|
+
** of [SQLITE_CHANGESET_OMIT], [SQLITE_CHANGESET_ABORT] or
|
9409
|
+
** [SQLITE_CHANGESET_REPLACE]. SQLITE_CHANGESET_REPLACE may only be returned
|
9410
|
+
** if the second argument passed to the conflict handler is either
|
9411
|
+
** SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If the conflict-handler
|
9412
|
+
** returns an illegal value, any changes already made are rolled back and
|
9413
|
+
** the call to sqlite3changeset_apply() returns SQLITE_MISUSE. Different
|
9414
|
+
** actions are taken by sqlite3changeset_apply() depending on the value
|
9415
|
+
** returned by each invocation of the conflict-handler function. Refer to
|
9416
|
+
** the documentation for the three
|
9417
|
+
** [SQLITE_CHANGESET_OMIT|available return values] for details.
|
9418
|
+
**
|
9419
|
+
** <dl>
|
9420
|
+
** <dt>DELETE Changes<dd>
|
9421
|
+
** For each DELETE change, this function checks if the target database
|
9422
|
+
** contains a row with the same primary key value (or values) as the
|
9423
|
+
** original row values stored in the changeset. If it does, and the values
|
9424
|
+
** stored in all non-primary key columns also match the values stored in
|
9425
|
+
** the changeset the row is deleted from the target database.
|
9426
|
+
**
|
9427
|
+
** If a row with matching primary key values is found, but one or more of
|
9428
|
+
** the non-primary key fields contains a value different from the original
|
9429
|
+
** row value stored in the changeset, the conflict-handler function is
|
9430
|
+
** invoked with [SQLITE_CHANGESET_DATA] as the second argument.
|
9431
|
+
**
|
9432
|
+
** If no row with matching primary key values is found in the database,
|
9433
|
+
** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]
|
9434
|
+
** passed as the second argument.
|
9435
|
+
**
|
9436
|
+
** If the DELETE operation is attempted, but SQLite returns SQLITE_CONSTRAINT
|
9437
|
+
** (which can only happen if a foreign key constraint is violated), the
|
9438
|
+
** conflict-handler function is invoked with [SQLITE_CHANGESET_CONSTRAINT]
|
9439
|
+
** passed as the second argument. This includes the case where the DELETE
|
9440
|
+
** operation is attempted because an earlier call to the conflict handler
|
9441
|
+
** function returned [SQLITE_CHANGESET_REPLACE].
|
9442
|
+
**
|
9443
|
+
** <dt>INSERT Changes<dd>
|
9444
|
+
** For each INSERT change, an attempt is made to insert the new row into
|
9445
|
+
** the database.
|
9446
|
+
**
|
9447
|
+
** If the attempt to insert the row fails because the database already
|
9448
|
+
** contains a row with the same primary key values, the conflict handler
|
9449
|
+
** function is invoked with the second argument set to
|
9450
|
+
** [SQLITE_CHANGESET_CONFLICT].
|
9451
|
+
**
|
9452
|
+
** If the attempt to insert the row fails because of some other constraint
|
9453
|
+
** violation (e.g. NOT NULL or UNIQUE), the conflict handler function is
|
9454
|
+
** invoked with the second argument set to [SQLITE_CHANGESET_CONSTRAINT].
|
9455
|
+
** This includes the case where the INSERT operation is re-attempted because
|
9456
|
+
** an earlier call to the conflict handler function returned
|
9457
|
+
** [SQLITE_CHANGESET_REPLACE].
|
9458
|
+
**
|
9459
|
+
** <dt>UPDATE Changes<dd>
|
9460
|
+
** For each UPDATE change, this function checks if the target database
|
9461
|
+
** contains a row with the same primary key value (or values) as the
|
9462
|
+
** original row values stored in the changeset. If it does, and the values
|
9463
|
+
** stored in all non-primary key columns also match the values stored in
|
9464
|
+
** the changeset the row is updated within the target database.
|
9465
|
+
**
|
9466
|
+
** If a row with matching primary key values is found, but one or more of
|
9467
|
+
** the non-primary key fields contains a value different from an original
|
9468
|
+
** row value stored in the changeset, the conflict-handler function is
|
9469
|
+
** invoked with [SQLITE_CHANGESET_DATA] as the second argument. Since
|
9470
|
+
** UPDATE changes only contain values for non-primary key fields that are
|
9471
|
+
** to be modified, only those fields need to match the original values to
|
9472
|
+
** avoid the SQLITE_CHANGESET_DATA conflict-handler callback.
|
9473
|
+
**
|
9474
|
+
** If no row with matching primary key values is found in the database,
|
9475
|
+
** the conflict-handler function is invoked with [SQLITE_CHANGESET_NOTFOUND]
|
9476
|
+
** passed as the second argument.
|
9477
|
+
**
|
9478
|
+
** If the UPDATE operation is attempted, but SQLite returns
|
9479
|
+
** SQLITE_CONSTRAINT, the conflict-handler function is invoked with
|
9480
|
+
** [SQLITE_CHANGESET_CONSTRAINT] passed as the second argument.
|
9481
|
+
** This includes the case where the UPDATE operation is attempted after
|
9482
|
+
** an earlier call to the conflict handler function returned
|
9483
|
+
** [SQLITE_CHANGESET_REPLACE].
|
9484
|
+
** </dl>
|
9485
|
+
**
|
9486
|
+
** It is safe to execute SQL statements, including those that write to the
|
9487
|
+
** table that the callback related to, from within the xConflict callback.
|
9488
|
+
** This can be used to further customize the applications conflict
|
9489
|
+
** resolution strategy.
|
9490
|
+
**
|
9491
|
+
** All changes made by this function are enclosed in a savepoint transaction.
|
9492
|
+
** If any other error (aside from a constraint failure when attempting to
|
9493
|
+
** write to the target database) occurs, then the savepoint transaction is
|
9494
|
+
** rolled back, restoring the target database to its original state, and an
|
9495
|
+
** SQLite error code returned.
|
9496
|
+
*/
|
9497
|
+
int sqlite3changeset_apply(
|
9498
|
+
sqlite3 *db, /* Apply change to "main" db of this handle */
|
9499
|
+
int nChangeset, /* Size of changeset in bytes */
|
9500
|
+
void *pChangeset, /* Changeset blob */
|
9501
|
+
int(*xFilter)(
|
9502
|
+
void *pCtx, /* Copy of sixth arg to _apply() */
|
9503
|
+
const char *zTab /* Table name */
|
9504
|
+
),
|
9505
|
+
int(*xConflict)(
|
9506
|
+
void *pCtx, /* Copy of sixth arg to _apply() */
|
9507
|
+
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
|
9508
|
+
sqlite3_changeset_iter *p /* Handle describing change and conflict */
|
9509
|
+
),
|
9510
|
+
void *pCtx /* First argument passed to xConflict */
|
9511
|
+
);
|
9512
|
+
|
9513
|
+
/*
|
9514
|
+
** CAPI3REF: Constants Passed To The Conflict Handler
|
9515
|
+
**
|
9516
|
+
** Values that may be passed as the second argument to a conflict-handler.
|
9517
|
+
**
|
9518
|
+
** <dl>
|
9519
|
+
** <dt>SQLITE_CHANGESET_DATA<dd>
|
9520
|
+
** The conflict handler is invoked with CHANGESET_DATA as the second argument
|
9521
|
+
** when processing a DELETE or UPDATE change if a row with the required
|
9522
|
+
** PRIMARY KEY fields is present in the database, but one or more other
|
9523
|
+
** (non primary-key) fields modified by the update do not contain the
|
9524
|
+
** expected "before" values.
|
9525
|
+
**
|
9526
|
+
** The conflicting row, in this case, is the database row with the matching
|
9527
|
+
** primary key.
|
9528
|
+
**
|
9529
|
+
** <dt>SQLITE_CHANGESET_NOTFOUND<dd>
|
9530
|
+
** The conflict handler is invoked with CHANGESET_NOTFOUND as the second
|
9531
|
+
** argument when processing a DELETE or UPDATE change if a row with the
|
9532
|
+
** required PRIMARY KEY fields is not present in the database.
|
9533
|
+
**
|
9534
|
+
** There is no conflicting row in this case. The results of invoking the
|
9535
|
+
** sqlite3changeset_conflict() API are undefined.
|
9536
|
+
**
|
9537
|
+
** <dt>SQLITE_CHANGESET_CONFLICT<dd>
|
9538
|
+
** CHANGESET_CONFLICT is passed as the second argument to the conflict
|
9539
|
+
** handler while processing an INSERT change if the operation would result
|
9540
|
+
** in duplicate primary key values.
|
9541
|
+
**
|
9542
|
+
** The conflicting row in this case is the database row with the matching
|
9543
|
+
** primary key.
|
9544
|
+
**
|
9545
|
+
** <dt>SQLITE_CHANGESET_FOREIGN_KEY<dd>
|
9546
|
+
** If foreign key handling is enabled, and applying a changeset leaves the
|
9547
|
+
** database in a state containing foreign key violations, the conflict
|
9548
|
+
** handler is invoked with CHANGESET_FOREIGN_KEY as the second argument
|
9549
|
+
** exactly once before the changeset is committed. If the conflict handler
|
9550
|
+
** returns CHANGESET_OMIT, the changes, including those that caused the
|
9551
|
+
** foreign key constraint violation, are committed. Or, if it returns
|
9552
|
+
** CHANGESET_ABORT, the changeset is rolled back.
|
9553
|
+
**
|
9554
|
+
** No current or conflicting row information is provided. The only function
|
9555
|
+
** it is possible to call on the supplied sqlite3_changeset_iter handle
|
9556
|
+
** is sqlite3changeset_fk_conflicts().
|
9557
|
+
**
|
9558
|
+
** <dt>SQLITE_CHANGESET_CONSTRAINT<dd>
|
9559
|
+
** If any other constraint violation occurs while applying a change (i.e.
|
9560
|
+
** a UNIQUE, CHECK or NOT NULL constraint), the conflict handler is
|
9561
|
+
** invoked with CHANGESET_CONSTRAINT as the second argument.
|
9562
|
+
**
|
9563
|
+
** There is no conflicting row in this case. The results of invoking the
|
9564
|
+
** sqlite3changeset_conflict() API are undefined.
|
9565
|
+
**
|
9566
|
+
** </dl>
|
9567
|
+
*/
|
9568
|
+
#define SQLITE_CHANGESET_DATA 1
|
9569
|
+
#define SQLITE_CHANGESET_NOTFOUND 2
|
9570
|
+
#define SQLITE_CHANGESET_CONFLICT 3
|
9571
|
+
#define SQLITE_CHANGESET_CONSTRAINT 4
|
9572
|
+
#define SQLITE_CHANGESET_FOREIGN_KEY 5
|
9573
|
+
|
9574
|
+
/*
|
9575
|
+
** CAPI3REF: Constants Returned By The Conflict Handler
|
9576
|
+
**
|
9577
|
+
** A conflict handler callback must return one of the following three values.
|
9578
|
+
**
|
9579
|
+
** <dl>
|
9580
|
+
** <dt>SQLITE_CHANGESET_OMIT<dd>
|
9581
|
+
** If a conflict handler returns this value no special action is taken. The
|
9582
|
+
** change that caused the conflict is not applied. The session module
|
9583
|
+
** continues to the next change in the changeset.
|
9584
|
+
**
|
9585
|
+
** <dt>SQLITE_CHANGESET_REPLACE<dd>
|
9586
|
+
** This value may only be returned if the second argument to the conflict
|
9587
|
+
** handler was SQLITE_CHANGESET_DATA or SQLITE_CHANGESET_CONFLICT. If this
|
9588
|
+
** is not the case, any changes applied so far are rolled back and the
|
9589
|
+
** call to sqlite3changeset_apply() returns SQLITE_MISUSE.
|
9590
|
+
**
|
9591
|
+
** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_DATA conflict
|
9592
|
+
** handler, then the conflicting row is either updated or deleted, depending
|
9593
|
+
** on the type of change.
|
9594
|
+
**
|
9595
|
+
** If CHANGESET_REPLACE is returned by an SQLITE_CHANGESET_CONFLICT conflict
|
9596
|
+
** handler, then the conflicting row is removed from the database and a
|
9597
|
+
** second attempt to apply the change is made. If this second attempt fails,
|
9598
|
+
** the original row is restored to the database before continuing.
|
9599
|
+
**
|
9600
|
+
** <dt>SQLITE_CHANGESET_ABORT<dd>
|
9601
|
+
** If this value is returned, any changes applied so far are rolled back
|
9602
|
+
** and the call to sqlite3changeset_apply() returns SQLITE_ABORT.
|
9603
|
+
** </dl>
|
9604
|
+
*/
|
9605
|
+
#define SQLITE_CHANGESET_OMIT 0
|
9606
|
+
#define SQLITE_CHANGESET_REPLACE 1
|
9607
|
+
#define SQLITE_CHANGESET_ABORT 2
|
9608
|
+
|
9609
|
+
/*
|
9610
|
+
** CAPI3REF: Streaming Versions of API functions.
|
9611
|
+
**
|
9612
|
+
** The six streaming API xxx_strm() functions serve similar purposes to the
|
9613
|
+
** corresponding non-streaming API functions:
|
9614
|
+
**
|
9615
|
+
** <table border=1 style="margin-left:8ex;margin-right:8ex">
|
9616
|
+
** <tr><th>Streaming function<th>Non-streaming equivalent</th>
|
9617
|
+
** <tr><td>sqlite3changeset_apply_str<td>[sqlite3changeset_apply]
|
9618
|
+
** <tr><td>sqlite3changeset_concat_str<td>[sqlite3changeset_concat]
|
9619
|
+
** <tr><td>sqlite3changeset_invert_str<td>[sqlite3changeset_invert]
|
9620
|
+
** <tr><td>sqlite3changeset_start_str<td>[sqlite3changeset_start]
|
9621
|
+
** <tr><td>sqlite3session_changeset_str<td>[sqlite3session_changeset]
|
9622
|
+
** <tr><td>sqlite3session_patchset_str<td>[sqlite3session_patchset]
|
9623
|
+
** </table>
|
9624
|
+
**
|
9625
|
+
** Non-streaming functions that accept changesets (or patchsets) as input
|
9626
|
+
** require that the entire changeset be stored in a single buffer in memory.
|
9627
|
+
** Similarly, those that return a changeset or patchset do so by returning
|
9628
|
+
** a pointer to a single large buffer allocated using sqlite3_malloc().
|
9629
|
+
** Normally this is convenient. However, if an application running in a
|
9630
|
+
** low-memory environment is required to handle very large changesets, the
|
9631
|
+
** large contiguous memory allocations required can become onerous.
|
9632
|
+
**
|
9633
|
+
** In order to avoid this problem, instead of a single large buffer, input
|
9634
|
+
** is passed to a streaming API functions by way of a callback function that
|
9635
|
+
** the sessions module invokes to incrementally request input data as it is
|
9636
|
+
** required. In all cases, a pair of API function parameters such as
|
9637
|
+
**
|
9638
|
+
** <pre>
|
9639
|
+
** int nChangeset,
|
9640
|
+
** void *pChangeset,
|
9641
|
+
** </pre>
|
9642
|
+
**
|
9643
|
+
** Is replaced by:
|
9644
|
+
**
|
9645
|
+
** <pre>
|
9646
|
+
** int (*xInput)(void *pIn, void *pData, int *pnData),
|
9647
|
+
** void *pIn,
|
9648
|
+
** </pre>
|
9649
|
+
**
|
9650
|
+
** Each time the xInput callback is invoked by the sessions module, the first
|
9651
|
+
** argument passed is a copy of the supplied pIn context pointer. The second
|
9652
|
+
** argument, pData, points to a buffer (*pnData) bytes in size. Assuming no
|
9653
|
+
** error occurs the xInput method should copy up to (*pnData) bytes of data
|
9654
|
+
** into the buffer and set (*pnData) to the actual number of bytes copied
|
9655
|
+
** before returning SQLITE_OK. If the input is completely exhausted, (*pnData)
|
9656
|
+
** should be set to zero to indicate this. Or, if an error occurs, an SQLite
|
9657
|
+
** error code should be returned. In all cases, if an xInput callback returns
|
9658
|
+
** an error, all processing is abandoned and the streaming API function
|
9659
|
+
** returns a copy of the error code to the caller.
|
9660
|
+
**
|
9661
|
+
** In the case of sqlite3changeset_start_strm(), the xInput callback may be
|
9662
|
+
** invoked by the sessions module at any point during the lifetime of the
|
9663
|
+
** iterator. If such an xInput callback returns an error, the iterator enters
|
9664
|
+
** an error state, whereby all subsequent calls to iterator functions
|
9665
|
+
** immediately fail with the same error code as returned by xInput.
|
9666
|
+
**
|
9667
|
+
** Similarly, streaming API functions that return changesets (or patchsets)
|
9668
|
+
** return them in chunks by way of a callback function instead of via a
|
9669
|
+
** pointer to a single large buffer. In this case, a pair of parameters such
|
9670
|
+
** as:
|
9671
|
+
**
|
9672
|
+
** <pre>
|
9673
|
+
** int *pnChangeset,
|
9674
|
+
** void **ppChangeset,
|
9675
|
+
** </pre>
|
9676
|
+
**
|
9677
|
+
** Is replaced by:
|
9678
|
+
**
|
9679
|
+
** <pre>
|
9680
|
+
** int (*xOutput)(void *pOut, const void *pData, int nData),
|
9681
|
+
** void *pOut
|
9682
|
+
** </pre>
|
9683
|
+
**
|
9684
|
+
** The xOutput callback is invoked zero or more times to return data to
|
9685
|
+
** the application. The first parameter passed to each call is a copy of the
|
9686
|
+
** pOut pointer supplied by the application. The second parameter, pData,
|
9687
|
+
** points to a buffer nData bytes in size containing the chunk of output
|
9688
|
+
** data being returned. If the xOutput callback successfully processes the
|
9689
|
+
** supplied data, it should return SQLITE_OK to indicate success. Otherwise,
|
9690
|
+
** it should return some other SQLite error code. In this case processing
|
9691
|
+
** is immediately abandoned and the streaming API function returns a copy
|
9692
|
+
** of the xOutput error code to the application.
|
9693
|
+
**
|
9694
|
+
** The sessions module never invokes an xOutput callback with the third
|
9695
|
+
** parameter set to a value less than or equal to zero. Other than this,
|
9696
|
+
** no guarantees are made as to the size of the chunks of data returned.
|
9697
|
+
*/
|
9698
|
+
int sqlite3changeset_apply_strm(
|
9699
|
+
sqlite3 *db, /* Apply change to "main" db of this handle */
|
9700
|
+
int (*xInput)(void *pIn, void *pData, int *pnData), /* Input function */
|
9701
|
+
void *pIn, /* First arg for xInput */
|
9702
|
+
int(*xFilter)(
|
9703
|
+
void *pCtx, /* Copy of sixth arg to _apply() */
|
9704
|
+
const char *zTab /* Table name */
|
9705
|
+
),
|
9706
|
+
int(*xConflict)(
|
9707
|
+
void *pCtx, /* Copy of sixth arg to _apply() */
|
9708
|
+
int eConflict, /* DATA, MISSING, CONFLICT, CONSTRAINT */
|
9709
|
+
sqlite3_changeset_iter *p /* Handle describing change and conflict */
|
9710
|
+
),
|
9711
|
+
void *pCtx /* First argument passed to xConflict */
|
9712
|
+
);
|
9713
|
+
int sqlite3changeset_concat_strm(
|
9714
|
+
int (*xInputA)(void *pIn, void *pData, int *pnData),
|
9715
|
+
void *pInA,
|
9716
|
+
int (*xInputB)(void *pIn, void *pData, int *pnData),
|
9717
|
+
void *pInB,
|
9718
|
+
int (*xOutput)(void *pOut, const void *pData, int nData),
|
9719
|
+
void *pOut
|
9720
|
+
);
|
9721
|
+
int sqlite3changeset_invert_strm(
|
9722
|
+
int (*xInput)(void *pIn, void *pData, int *pnData),
|
9723
|
+
void *pIn,
|
9724
|
+
int (*xOutput)(void *pOut, const void *pData, int nData),
|
9725
|
+
void *pOut
|
9726
|
+
);
|
9727
|
+
int sqlite3changeset_start_strm(
|
9728
|
+
sqlite3_changeset_iter **pp,
|
9729
|
+
int (*xInput)(void *pIn, void *pData, int *pnData),
|
9730
|
+
void *pIn
|
9731
|
+
);
|
9732
|
+
int sqlite3session_changeset_strm(
|
9733
|
+
sqlite3_session *pSession,
|
9734
|
+
int (*xOutput)(void *pOut, const void *pData, int nData),
|
9735
|
+
void *pOut
|
9736
|
+
);
|
9737
|
+
int sqlite3session_patchset_strm(
|
9738
|
+
sqlite3_session *pSession,
|
9739
|
+
int (*xOutput)(void *pOut, const void *pData, int nData),
|
9740
|
+
void *pOut
|
9741
|
+
);
|
9742
|
+
int sqlite3changegroup_add_strm(sqlite3_changegroup*,
|
9743
|
+
int (*xInput)(void *pIn, void *pData, int *pnData),
|
9744
|
+
void *pIn
|
9745
|
+
);
|
9746
|
+
int sqlite3changegroup_output_strm(sqlite3_changegroup*,
|
9747
|
+
int (*xOutput)(void *pOut, const void *pData, int nData),
|
9748
|
+
void *pOut
|
9749
|
+
);
|
9750
|
+
|
9751
|
+
|
9752
|
+
/*
|
9753
|
+
** Make sure we can call this stuff from C++.
|
9754
|
+
*/
|
9755
|
+
#ifdef __cplusplus
|
9756
|
+
}
|
9757
|
+
#endif
|
9758
|
+
|
9759
|
+
#endif /* !defined(__SQLITESESSION_H_) && defined(SQLITE_ENABLE_SESSION) */
|
9760
|
+
|
9761
|
+
/******** End of sqlite3session.h *********/
|
9762
|
+
/******** Begin file fts5.h *********/
|
8156
9763
|
/*
|
8157
9764
|
** 2014 May 31
|
8158
9765
|
**
|
@@ -8297,11 +9904,13 @@ struct Fts5PhraseIter {
|
|
8297
9904
|
** ... FROM ftstable WHERE ftstable MATCH $p ORDER BY rowid
|
8298
9905
|
**
|
8299
9906
|
** with $p set to a phrase equivalent to the phrase iPhrase of the
|
8300
|
-
** current query is executed.
|
8301
|
-
**
|
8302
|
-
**
|
8303
|
-
**
|
8304
|
-
**
|
9907
|
+
** current query is executed. Any column filter that applies to
|
9908
|
+
** phrase iPhrase of the current query is included in $p. For each
|
9909
|
+
** row visited, the callback function passed as the fourth argument
|
9910
|
+
** is invoked. The context and API objects passed to the callback
|
9911
|
+
** function may be used to access the properties of each matched row.
|
9912
|
+
** Invoking Api.xUserData() returns a copy of the pointer passed as
|
9913
|
+
** the third argument to pUserData.
|
8305
9914
|
**
|
8306
9915
|
** If the callback function returns any value other than SQLITE_OK, the
|
8307
9916
|
** query is abandoned and the xQueryPhrase function returns immediately.
|
@@ -8470,7 +10079,7 @@ struct Fts5ExtensionApi {
|
|
8470
10079
|
** behaviour. The structure methods are expected to function as follows:
|
8471
10080
|
**
|
8472
10081
|
** xCreate:
|
8473
|
-
** This function is used to allocate and
|
10082
|
+
** This function is used to allocate and initialize a tokenizer instance.
|
8474
10083
|
** A tokenizer instance is required to actually tokenize text.
|
8475
10084
|
**
|
8476
10085
|
** The first argument passed to this function is a copy of the (void*)
|
@@ -8730,4 +10339,4 @@ struct fts5_api {
|
|
8730
10339
|
|
8731
10340
|
#endif /* _FTS5_H */
|
8732
10341
|
|
8733
|
-
|
10342
|
+
/******** End of fts5.h *********/
|