Fossil SCM

Merge in Trunk...

mgagnon 2012-06-11 17:23 mgagnon_fix merge
Commit c109e66db54017b9c14ca636acb15767dd4cc23d
+13 -4
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881881
** no editor is set.
882882
**
883883
** All files that have changed will be committed unless some subset of
884884
** files is specified on the command line.
885885
**
886
-** The --branch option followed by a branch name causes the new check-in
887
-** to be placed in the named branch. The --bgcolor option can be followed
888
-** by a color name (ex: '#ffc0c0') to specify the background color of
889
-** entries in the new branch when shown in the web timeline interface.
886
+** The --branch option followed by a branch name causes the new
887
+** check-in to be placed in a newly-created branch with the name
888
+** passed to the --branch option.
889
+**
890
+** Use the --branchcolor option followed by a color name (ex:
891
+** '#ffc0c0') to specify the background color of entries in the new
892
+** branch when shown in the web timeline interface. The use of
893
+** the --branchcolor option is not recommend. Instead, let Fossil
894
+** choose the branch color automatically.
895
+**
896
+** The --bgcolor option works like --branchcolor but only sets the
897
+** background color for a single check-in. Subsequent check-ins revert
898
+** to the default color.
890899
**
891900
** A check-in is not permitted to fork unless the --force or -f
892901
** option appears. A check-in is not allowed against a closed leaf.
893902
**
894903
** The --private option creates a private check-in that is never synced.
895904
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881 ** no editor is set.
882 **
883 ** All files that have changed will be committed unless some subset of
884 ** files is specified on the command line.
885 **
886 ** The --branch option followed by a branch name causes the new check-in
887 ** to be placed in the named branch. The --bgcolor option can be followed
888 ** by a color name (ex: '#ffc0c0') to specify the background color of
889 ** entries in the new branch when shown in the web timeline interface.
 
 
 
 
 
 
 
 
 
890 **
891 ** A check-in is not permitted to fork unless the --force or -f
892 ** option appears. A check-in is not allowed against a closed leaf.
893 **
894 ** The --private option creates a private check-in that is never synced.
895
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881 ** no editor is set.
882 **
883 ** All files that have changed will be committed unless some subset of
884 ** files is specified on the command line.
885 **
886 ** The --branch option followed by a branch name causes the new
887 ** check-in to be placed in a newly-created branch with the name
888 ** passed to the --branch option.
889 **
890 ** Use the --branchcolor option followed by a color name (ex:
891 ** '#ffc0c0') to specify the background color of entries in the new
892 ** branch when shown in the web timeline interface. The use of
893 ** the --branchcolor option is not recommend. Instead, let Fossil
894 ** choose the branch color automatically.
895 **
896 ** The --bgcolor option works like --branchcolor but only sets the
897 ** background color for a single check-in. Subsequent check-ins revert
898 ** to the default color.
899 **
900 ** A check-in is not permitted to fork unless the --force or -f
901 ** option appears. A check-in is not allowed against a closed leaf.
902 **
903 ** The --private option creates a private check-in that is never synced.
904
+13 -4
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881881
** no editor is set.
882882
**
883883
** All files that have changed will be committed unless some subset of
884884
** files is specified on the command line.
885885
**
886
-** The --branch option followed by a branch name causes the new check-in
887
-** to be placed in the named branch. The --bgcolor option can be followed
888
-** by a color name (ex: '#ffc0c0') to specify the background color of
889
-** entries in the new branch when shown in the web timeline interface.
886
+** The --branch option followed by a branch name causes the new
887
+** check-in to be placed in a newly-created branch with the name
888
+** passed to the --branch option.
889
+**
890
+** Use the --branchcolor option followed by a color name (ex:
891
+** '#ffc0c0') to specify the background color of entries in the new
892
+** branch when shown in the web timeline interface. The use of
893
+** the --branchcolor option is not recommend. Instead, let Fossil
894
+** choose the branch color automatically.
895
+**
896
+** The --bgcolor option works like --branchcolor but only sets the
897
+** background color for a single check-in. Subsequent check-ins revert
898
+** to the default color.
890899
**
891900
** A check-in is not permitted to fork unless the --force or -f
892901
** option appears. A check-in is not allowed against a closed leaf.
893902
**
894903
** The --private option creates a private check-in that is never synced.
895904
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881 ** no editor is set.
882 **
883 ** All files that have changed will be committed unless some subset of
884 ** files is specified on the command line.
885 **
886 ** The --branch option followed by a branch name causes the new check-in
887 ** to be placed in the named branch. The --bgcolor option can be followed
888 ** by a color name (ex: '#ffc0c0') to specify the background color of
889 ** entries in the new branch when shown in the web timeline interface.
 
 
 
 
 
 
 
 
 
890 **
891 ** A check-in is not permitted to fork unless the --force or -f
892 ** option appears. A check-in is not allowed against a closed leaf.
893 **
894 ** The --private option creates a private check-in that is never synced.
895
--- src/checkin.c
+++ src/checkin.c
@@ -881,14 +881,23 @@
881 ** no editor is set.
882 **
883 ** All files that have changed will be committed unless some subset of
884 ** files is specified on the command line.
885 **
886 ** The --branch option followed by a branch name causes the new
887 ** check-in to be placed in a newly-created branch with the name
888 ** passed to the --branch option.
889 **
890 ** Use the --branchcolor option followed by a color name (ex:
891 ** '#ffc0c0') to specify the background color of entries in the new
892 ** branch when shown in the web timeline interface. The use of
893 ** the --branchcolor option is not recommend. Instead, let Fossil
894 ** choose the branch color automatically.
895 **
896 ** The --bgcolor option works like --branchcolor but only sets the
897 ** background color for a single check-in. Subsequent check-ins revert
898 ** to the default color.
899 **
900 ** A check-in is not permitted to fork unless the --force or -f
901 ** option appears. A check-in is not allowed against a closed leaf.
902 **
903 ** The --private option creates a private check-in that is never synced.
904
+15 -6
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
7878
{ "css", CONFIGSET_SKIN },
7979
{ "header", CONFIGSET_SKIN },
8080
{ "footer", CONFIGSET_SKIN },
8181
{ "logo-mimetype", CONFIGSET_SKIN },
8282
{ "logo-image", CONFIGSET_SKIN },
83
+ { "background-mimetype", CONFIGSET_SKIN },
84
+ { "background-image", CONFIGSET_SKIN },
85
+ { "index-page", CONFIGSET_SKIN },
86
+ { "timeline-block-markup", CONFIGSET_SKIN },
87
+ { "timeline-max-comment", CONFIGSET_SKIN },
88
+#ifdef FOSSIL_ENABLE_TCL
89
+ { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90
+#endif
91
+
8392
{ "project-name", CONFIGSET_PROJ },
8493
{ "project-description", CONFIGSET_PROJ },
8594
{ "manifest", CONFIGSET_PROJ },
8695
{ "ignore-glob", CONFIGSET_PROJ },
8796
{ "crnl-glob", CONFIGSET_PROJ },
8897
{ "empty-dirs", CONFIGSET_PROJ },
8998
{ "allow-symlinks", CONFIGSET_PROJ },
90
- { "index-page", CONFIGSET_SKIN },
91
-#ifdef FOSSIL_ENABLE_TCL
92
- { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93
-#endif
94
- { "timeline-block-markup", CONFIGSET_SKIN },
95
- { "timeline-max-comment", CONFIGSET_SKIN },
99
+
96100
{ "ticket-table", CONFIGSET_TKT },
97101
{ "ticket-common", CONFIGSET_TKT },
98102
{ "ticket-change", CONFIGSET_TKT },
99103
{ "ticket-newpage", CONFIGSET_TKT },
100104
{ "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103107
{ "ticket-report-template", CONFIGSET_TKT },
104108
{ "ticket-key-template", CONFIGSET_TKT },
105109
{ "ticket-title-expr", CONFIGSET_TKT },
106110
{ "ticket-closed-expr", CONFIGSET_TKT },
107111
{ "@reportfmt", CONFIGSET_TKT },
112
+
108113
{ "@user", CONFIGSET_USER },
114
+
109115
{ "@concealed", CONFIGSET_ADDR },
116
+
110117
{ "@shun", CONFIGSET_SHUN },
118
+
111119
{ "xfer-common-script", CONFIGSET_XFER },
112120
{ "xfer-push-script", CONFIGSET_XFER },
121
+
113122
};
114123
static int iConfig = 0;
115124
116125
/*
117126
** Return name of first configuration property matching the given mask.
118127
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
 
 
 
 
 
 
 
 
 
83 { "project-name", CONFIGSET_PROJ },
84 { "project-description", CONFIGSET_PROJ },
85 { "manifest", CONFIGSET_PROJ },
86 { "ignore-glob", CONFIGSET_PROJ },
87 { "crnl-glob", CONFIGSET_PROJ },
88 { "empty-dirs", CONFIGSET_PROJ },
89 { "allow-symlinks", CONFIGSET_PROJ },
90 { "index-page", CONFIGSET_SKIN },
91 #ifdef FOSSIL_ENABLE_TCL
92 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93 #endif
94 { "timeline-block-markup", CONFIGSET_SKIN },
95 { "timeline-max-comment", CONFIGSET_SKIN },
96 { "ticket-table", CONFIGSET_TKT },
97 { "ticket-common", CONFIGSET_TKT },
98 { "ticket-change", CONFIGSET_TKT },
99 { "ticket-newpage", CONFIGSET_TKT },
100 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103 { "ticket-report-template", CONFIGSET_TKT },
104 { "ticket-key-template", CONFIGSET_TKT },
105 { "ticket-title-expr", CONFIGSET_TKT },
106 { "ticket-closed-expr", CONFIGSET_TKT },
107 { "@reportfmt", CONFIGSET_TKT },
 
108 { "@user", CONFIGSET_USER },
 
109 { "@concealed", CONFIGSET_ADDR },
 
110 { "@shun", CONFIGSET_SHUN },
 
111 { "xfer-common-script", CONFIGSET_XFER },
112 { "xfer-push-script", CONFIGSET_XFER },
 
113 };
114 static int iConfig = 0;
115
116 /*
117 ** Return name of first configuration property matching the given mask.
118
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
83 { "background-mimetype", CONFIGSET_SKIN },
84 { "background-image", CONFIGSET_SKIN },
85 { "index-page", CONFIGSET_SKIN },
86 { "timeline-block-markup", CONFIGSET_SKIN },
87 { "timeline-max-comment", CONFIGSET_SKIN },
88 #ifdef FOSSIL_ENABLE_TCL
89 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90 #endif
91
92 { "project-name", CONFIGSET_PROJ },
93 { "project-description", CONFIGSET_PROJ },
94 { "manifest", CONFIGSET_PROJ },
95 { "ignore-glob", CONFIGSET_PROJ },
96 { "crnl-glob", CONFIGSET_PROJ },
97 { "empty-dirs", CONFIGSET_PROJ },
98 { "allow-symlinks", CONFIGSET_PROJ },
99
 
 
 
 
 
100 { "ticket-table", CONFIGSET_TKT },
101 { "ticket-common", CONFIGSET_TKT },
102 { "ticket-change", CONFIGSET_TKT },
103 { "ticket-newpage", CONFIGSET_TKT },
104 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
107 { "ticket-report-template", CONFIGSET_TKT },
108 { "ticket-key-template", CONFIGSET_TKT },
109 { "ticket-title-expr", CONFIGSET_TKT },
110 { "ticket-closed-expr", CONFIGSET_TKT },
111 { "@reportfmt", CONFIGSET_TKT },
112
113 { "@user", CONFIGSET_USER },
114
115 { "@concealed", CONFIGSET_ADDR },
116
117 { "@shun", CONFIGSET_SHUN },
118
119 { "xfer-common-script", CONFIGSET_XFER },
120 { "xfer-push-script", CONFIGSET_XFER },
121
122 };
123 static int iConfig = 0;
124
125 /*
126 ** Return name of first configuration property matching the given mask.
127
+15 -6
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
7878
{ "css", CONFIGSET_SKIN },
7979
{ "header", CONFIGSET_SKIN },
8080
{ "footer", CONFIGSET_SKIN },
8181
{ "logo-mimetype", CONFIGSET_SKIN },
8282
{ "logo-image", CONFIGSET_SKIN },
83
+ { "background-mimetype", CONFIGSET_SKIN },
84
+ { "background-image", CONFIGSET_SKIN },
85
+ { "index-page", CONFIGSET_SKIN },
86
+ { "timeline-block-markup", CONFIGSET_SKIN },
87
+ { "timeline-max-comment", CONFIGSET_SKIN },
88
+#ifdef FOSSIL_ENABLE_TCL
89
+ { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90
+#endif
91
+
8392
{ "project-name", CONFIGSET_PROJ },
8493
{ "project-description", CONFIGSET_PROJ },
8594
{ "manifest", CONFIGSET_PROJ },
8695
{ "ignore-glob", CONFIGSET_PROJ },
8796
{ "crnl-glob", CONFIGSET_PROJ },
8897
{ "empty-dirs", CONFIGSET_PROJ },
8998
{ "allow-symlinks", CONFIGSET_PROJ },
90
- { "index-page", CONFIGSET_SKIN },
91
-#ifdef FOSSIL_ENABLE_TCL
92
- { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93
-#endif
94
- { "timeline-block-markup", CONFIGSET_SKIN },
95
- { "timeline-max-comment", CONFIGSET_SKIN },
99
+
96100
{ "ticket-table", CONFIGSET_TKT },
97101
{ "ticket-common", CONFIGSET_TKT },
98102
{ "ticket-change", CONFIGSET_TKT },
99103
{ "ticket-newpage", CONFIGSET_TKT },
100104
{ "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103107
{ "ticket-report-template", CONFIGSET_TKT },
104108
{ "ticket-key-template", CONFIGSET_TKT },
105109
{ "ticket-title-expr", CONFIGSET_TKT },
106110
{ "ticket-closed-expr", CONFIGSET_TKT },
107111
{ "@reportfmt", CONFIGSET_TKT },
112
+
108113
{ "@user", CONFIGSET_USER },
114
+
109115
{ "@concealed", CONFIGSET_ADDR },
116
+
110117
{ "@shun", CONFIGSET_SHUN },
118
+
111119
{ "xfer-common-script", CONFIGSET_XFER },
112120
{ "xfer-push-script", CONFIGSET_XFER },
121
+
113122
};
114123
static int iConfig = 0;
115124
116125
/*
117126
** Return name of first configuration property matching the given mask.
118127
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
 
 
 
 
 
 
 
 
 
83 { "project-name", CONFIGSET_PROJ },
84 { "project-description", CONFIGSET_PROJ },
85 { "manifest", CONFIGSET_PROJ },
86 { "ignore-glob", CONFIGSET_PROJ },
87 { "crnl-glob", CONFIGSET_PROJ },
88 { "empty-dirs", CONFIGSET_PROJ },
89 { "allow-symlinks", CONFIGSET_PROJ },
90 { "index-page", CONFIGSET_SKIN },
91 #ifdef FOSSIL_ENABLE_TCL
92 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
93 #endif
94 { "timeline-block-markup", CONFIGSET_SKIN },
95 { "timeline-max-comment", CONFIGSET_SKIN },
96 { "ticket-table", CONFIGSET_TKT },
97 { "ticket-common", CONFIGSET_TKT },
98 { "ticket-change", CONFIGSET_TKT },
99 { "ticket-newpage", CONFIGSET_TKT },
100 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
103 { "ticket-report-template", CONFIGSET_TKT },
104 { "ticket-key-template", CONFIGSET_TKT },
105 { "ticket-title-expr", CONFIGSET_TKT },
106 { "ticket-closed-expr", CONFIGSET_TKT },
107 { "@reportfmt", CONFIGSET_TKT },
 
108 { "@user", CONFIGSET_USER },
 
109 { "@concealed", CONFIGSET_ADDR },
 
110 { "@shun", CONFIGSET_SHUN },
 
111 { "xfer-common-script", CONFIGSET_XFER },
112 { "xfer-push-script", CONFIGSET_XFER },
 
113 };
114 static int iConfig = 0;
115
116 /*
117 ** Return name of first configuration property matching the given mask.
118
--- src/configure.c
+++ src/configure.c
@@ -78,23 +78,27 @@
78 { "css", CONFIGSET_SKIN },
79 { "header", CONFIGSET_SKIN },
80 { "footer", CONFIGSET_SKIN },
81 { "logo-mimetype", CONFIGSET_SKIN },
82 { "logo-image", CONFIGSET_SKIN },
83 { "background-mimetype", CONFIGSET_SKIN },
84 { "background-image", CONFIGSET_SKIN },
85 { "index-page", CONFIGSET_SKIN },
86 { "timeline-block-markup", CONFIGSET_SKIN },
87 { "timeline-max-comment", CONFIGSET_SKIN },
88 #ifdef FOSSIL_ENABLE_TCL
89 { "tcl", CONFIGSET_SKIN|CONFIGSET_TKT|CONFIGSET_XFER },
90 #endif
91
92 { "project-name", CONFIGSET_PROJ },
93 { "project-description", CONFIGSET_PROJ },
94 { "manifest", CONFIGSET_PROJ },
95 { "ignore-glob", CONFIGSET_PROJ },
96 { "crnl-glob", CONFIGSET_PROJ },
97 { "empty-dirs", CONFIGSET_PROJ },
98 { "allow-symlinks", CONFIGSET_PROJ },
99
 
 
 
 
 
100 { "ticket-table", CONFIGSET_TKT },
101 { "ticket-common", CONFIGSET_TKT },
102 { "ticket-change", CONFIGSET_TKT },
103 { "ticket-newpage", CONFIGSET_TKT },
104 { "ticket-viewpage", CONFIGSET_TKT },
@@ -103,15 +107,20 @@
107 { "ticket-report-template", CONFIGSET_TKT },
108 { "ticket-key-template", CONFIGSET_TKT },
109 { "ticket-title-expr", CONFIGSET_TKT },
110 { "ticket-closed-expr", CONFIGSET_TKT },
111 { "@reportfmt", CONFIGSET_TKT },
112
113 { "@user", CONFIGSET_USER },
114
115 { "@concealed", CONFIGSET_ADDR },
116
117 { "@shun", CONFIGSET_SHUN },
118
119 { "xfer-common-script", CONFIGSET_XFER },
120 { "xfer-push-script", CONFIGSET_XFER },
121
122 };
123 static int iConfig = 0;
124
125 /*
126 ** Return name of first configuration property matching the given mask.
127
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
56295629
rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
56305630
sqlite3_finalize( st );
56315631
return rc;
56325632
}
56335633
}
5634
+
5635
+int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v )
5636
+{
5637
+ int rc = 0;
5638
+ char convertErr = 0;
5639
+ if(!st) return cson_rc.ArgError;
5640
+ else if( ndx < 1 ) {
5641
+ rc = cson_rc.RangeError;
5642
+ }
5643
+ else if( cson_value_is_array(v) ){
5644
+ cson_array * ar = cson_value_get_array(v);
5645
+ unsigned int len = cson_array_length_get(ar);
5646
+ unsigned int i;
5647
+ assert(NULL != ar);
5648
+ for( i = 0; !rc && (i < len); ++i ){
5649
+ rc = cson_sqlite3_bind_value( st, (int)i+ndx,
5650
+ cson_array_get(ar, i));
5651
+ }
5652
+ }
5653
+ else if(!v || cson_value_is_null(v)){
5654
+ rc = sqlite3_bind_null(st,ndx);
5655
+ convertErr = 1;
5656
+ }
5657
+ else if( cson_value_is_double(v) ){
5658
+ rc = sqlite3_bind_double( st, ndx, cson_value_get_double(v) );
5659
+ convertErr = 1;
5660
+ }
5661
+ else if( cson_value_is_bool(v) ){
5662
+ rc = sqlite3_bind_int( st, ndx, cson_value_get_bool(v) ? 1 : 0 );
5663
+ convertErr = 1;
5664
+ }
5665
+ else if( cson_value_is_integer(v) ){
5666
+ rc = sqlite3_bind_int64( st, ndx, cson_value_get_integer(v) );
5667
+ convertErr = 1;
5668
+ }
5669
+ else if( cson_value_is_string(v) ){
5670
+ cson_string const * s = cson_value_get_string(v);
5671
+ rc = sqlite3_bind_text( st, ndx,
5672
+ cson_string_cstr(s),
5673
+ cson_string_length_bytes(s),
5674
+ SQLITE_TRANSIENT);
5675
+ convertErr = 1;
5676
+ }
5677
+ else {
5678
+ rc = cson_rc.TypeError;
5679
+ }
5680
+ if(convertErr && rc) switch(rc){
5681
+ case SQLITE_TOOBIG:
5682
+ case SQLITE_RANGE: rc = cson_rc.RangeError; break;
5683
+ case SQLITE_NOMEM: rc = cson_rc.AllocError; break;
5684
+ case SQLITE_IOERR: rc = cson_rc.IOError; break;
5685
+ default: rc = cson_rc.UnknownError; break;
5686
+ };
5687
+ return rc;
5688
+}
5689
+
56345690
56355691
#if defined(__cplusplus)
56365692
} /*extern "C"*/
56375693
#endif
56385694
#undef MARKER
56395695
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
5629 rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
5630 sqlite3_finalize( st );
5631 return rc;
5632 }
5633 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5634
5635 #if defined(__cplusplus)
5636 } /*extern "C"*/
5637 #endif
5638 #undef MARKER
5639
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
5629 rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
5630 sqlite3_finalize( st );
5631 return rc;
5632 }
5633 }
5634
5635 int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v )
5636 {
5637 int rc = 0;
5638 char convertErr = 0;
5639 if(!st) return cson_rc.ArgError;
5640 else if( ndx < 1 ) {
5641 rc = cson_rc.RangeError;
5642 }
5643 else if( cson_value_is_array(v) ){
5644 cson_array * ar = cson_value_get_array(v);
5645 unsigned int len = cson_array_length_get(ar);
5646 unsigned int i;
5647 assert(NULL != ar);
5648 for( i = 0; !rc && (i < len); ++i ){
5649 rc = cson_sqlite3_bind_value( st, (int)i+ndx,
5650 cson_array_get(ar, i));
5651 }
5652 }
5653 else if(!v || cson_value_is_null(v)){
5654 rc = sqlite3_bind_null(st,ndx);
5655 convertErr = 1;
5656 }
5657 else if( cson_value_is_double(v) ){
5658 rc = sqlite3_bind_double( st, ndx, cson_value_get_double(v) );
5659 convertErr = 1;
5660 }
5661 else if( cson_value_is_bool(v) ){
5662 rc = sqlite3_bind_int( st, ndx, cson_value_get_bool(v) ? 1 : 0 );
5663 convertErr = 1;
5664 }
5665 else if( cson_value_is_integer(v) ){
5666 rc = sqlite3_bind_int64( st, ndx, cson_value_get_integer(v) );
5667 convertErr = 1;
5668 }
5669 else if( cson_value_is_string(v) ){
5670 cson_string const * s = cson_value_get_string(v);
5671 rc = sqlite3_bind_text( st, ndx,
5672 cson_string_cstr(s),
5673 cson_string_length_bytes(s),
5674 SQLITE_TRANSIENT);
5675 convertErr = 1;
5676 }
5677 else {
5678 rc = cson_rc.TypeError;
5679 }
5680 if(convertErr && rc) switch(rc){
5681 case SQLITE_TOOBIG:
5682 case SQLITE_RANGE: rc = cson_rc.RangeError; break;
5683 case SQLITE_NOMEM: rc = cson_rc.AllocError; break;
5684 case SQLITE_IOERR: rc = cson_rc.IOError; break;
5685 default: rc = cson_rc.UnknownError; break;
5686 };
5687 return rc;
5688 }
5689
5690
5691 #if defined(__cplusplus)
5692 } /*extern "C"*/
5693 #endif
5694 #undef MARKER
5695
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
56295629
rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
56305630
sqlite3_finalize( st );
56315631
return rc;
56325632
}
56335633
}
5634
+
5635
+int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v )
5636
+{
5637
+ int rc = 0;
5638
+ char convertErr = 0;
5639
+ if(!st) return cson_rc.ArgError;
5640
+ else if( ndx < 1 ) {
5641
+ rc = cson_rc.RangeError;
5642
+ }
5643
+ else if( cson_value_is_array(v) ){
5644
+ cson_array * ar = cson_value_get_array(v);
5645
+ unsigned int len = cson_array_length_get(ar);
5646
+ unsigned int i;
5647
+ assert(NULL != ar);
5648
+ for( i = 0; !rc && (i < len); ++i ){
5649
+ rc = cson_sqlite3_bind_value( st, (int)i+ndx,
5650
+ cson_array_get(ar, i));
5651
+ }
5652
+ }
5653
+ else if(!v || cson_value_is_null(v)){
5654
+ rc = sqlite3_bind_null(st,ndx);
5655
+ convertErr = 1;
5656
+ }
5657
+ else if( cson_value_is_double(v) ){
5658
+ rc = sqlite3_bind_double( st, ndx, cson_value_get_double(v) );
5659
+ convertErr = 1;
5660
+ }
5661
+ else if( cson_value_is_bool(v) ){
5662
+ rc = sqlite3_bind_int( st, ndx, cson_value_get_bool(v) ? 1 : 0 );
5663
+ convertErr = 1;
5664
+ }
5665
+ else if( cson_value_is_integer(v) ){
5666
+ rc = sqlite3_bind_int64( st, ndx, cson_value_get_integer(v) );
5667
+ convertErr = 1;
5668
+ }
5669
+ else if( cson_value_is_string(v) ){
5670
+ cson_string const * s = cson_value_get_string(v);
5671
+ rc = sqlite3_bind_text( st, ndx,
5672
+ cson_string_cstr(s),
5673
+ cson_string_length_bytes(s),
5674
+ SQLITE_TRANSIENT);
5675
+ convertErr = 1;
5676
+ }
5677
+ else {
5678
+ rc = cson_rc.TypeError;
5679
+ }
5680
+ if(convertErr && rc) switch(rc){
5681
+ case SQLITE_TOOBIG:
5682
+ case SQLITE_RANGE: rc = cson_rc.RangeError; break;
5683
+ case SQLITE_NOMEM: rc = cson_rc.AllocError; break;
5684
+ case SQLITE_IOERR: rc = cson_rc.IOError; break;
5685
+ default: rc = cson_rc.UnknownError; break;
5686
+ };
5687
+ return rc;
5688
+}
5689
+
56345690
56355691
#if defined(__cplusplus)
56365692
} /*extern "C"*/
56375693
#endif
56385694
#undef MARKER
56395695
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
5629 rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
5630 sqlite3_finalize( st );
5631 return rc;
5632 }
5633 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5634
5635 #if defined(__cplusplus)
5636 } /*extern "C"*/
5637 #endif
5638 #undef MARKER
5639
--- src/cson_amalgamation.c
+++ src/cson_amalgamation.c
@@ -5629,10 +5629,66 @@
5629 rc = cson_sqlite3_stmt_to_json( st, tgt, fat );
5630 sqlite3_finalize( st );
5631 return rc;
5632 }
5633 }
5634
5635 int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v )
5636 {
5637 int rc = 0;
5638 char convertErr = 0;
5639 if(!st) return cson_rc.ArgError;
5640 else if( ndx < 1 ) {
5641 rc = cson_rc.RangeError;
5642 }
5643 else if( cson_value_is_array(v) ){
5644 cson_array * ar = cson_value_get_array(v);
5645 unsigned int len = cson_array_length_get(ar);
5646 unsigned int i;
5647 assert(NULL != ar);
5648 for( i = 0; !rc && (i < len); ++i ){
5649 rc = cson_sqlite3_bind_value( st, (int)i+ndx,
5650 cson_array_get(ar, i));
5651 }
5652 }
5653 else if(!v || cson_value_is_null(v)){
5654 rc = sqlite3_bind_null(st,ndx);
5655 convertErr = 1;
5656 }
5657 else if( cson_value_is_double(v) ){
5658 rc = sqlite3_bind_double( st, ndx, cson_value_get_double(v) );
5659 convertErr = 1;
5660 }
5661 else if( cson_value_is_bool(v) ){
5662 rc = sqlite3_bind_int( st, ndx, cson_value_get_bool(v) ? 1 : 0 );
5663 convertErr = 1;
5664 }
5665 else if( cson_value_is_integer(v) ){
5666 rc = sqlite3_bind_int64( st, ndx, cson_value_get_integer(v) );
5667 convertErr = 1;
5668 }
5669 else if( cson_value_is_string(v) ){
5670 cson_string const * s = cson_value_get_string(v);
5671 rc = sqlite3_bind_text( st, ndx,
5672 cson_string_cstr(s),
5673 cson_string_length_bytes(s),
5674 SQLITE_TRANSIENT);
5675 convertErr = 1;
5676 }
5677 else {
5678 rc = cson_rc.TypeError;
5679 }
5680 if(convertErr && rc) switch(rc){
5681 case SQLITE_TOOBIG:
5682 case SQLITE_RANGE: rc = cson_rc.RangeError; break;
5683 case SQLITE_NOMEM: rc = cson_rc.AllocError; break;
5684 case SQLITE_IOERR: rc = cson_rc.IOError; break;
5685 default: rc = cson_rc.UnknownError; break;
5686 };
5687 return rc;
5688 }
5689
5690
5691 #if defined(__cplusplus)
5692 } /*extern "C"*/
5693 #endif
5694 #undef MARKER
5695
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
24942494
takes SQL instead of a sqlite3_stmt object. It has the same
24952495
return value and argument semantics as that function.
24962496
*/
24972497
int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
24982498
2499
+/**
2500
+ Binds a JSON value to a 1-based parameter index in a prepared SQL
2501
+ statement. v must be NULL or one of one of the types (null, string,
2502
+ integer, double, boolean, array). Booleans are bound as integer 0
2503
+ or 1. NULL or null are bound as SQL NULL. Integers are bound as
2504
+ 64-bit ints. Strings are bound using sqlite3_bind_text() (as
2505
+ opposed to text16), but we could/should arguably bind them as
2506
+ blobs.
2507
+
2508
+ If v is an Array then ndx is is used as a starting position
2509
+ (1-based) and each item in the array is bound to the next parameter
2510
+ position (starting and ndx, though the array uses 0-based offsets).
2511
+
2512
+ TODO: add Object support for named parameters.
2513
+
2514
+ Returns 0 on success, non-0 on error.
2515
+ */
2516
+int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v );
2517
+
24992518
#if defined(__cplusplus)
25002519
} /*extern "C"*/
25012520
#endif
25022521
25032522
#endif /* CSON_ENABLE_SQLITE3 */
25042523
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
2494 takes SQL instead of a sqlite3_stmt object. It has the same
2495 return value and argument semantics as that function.
2496 */
2497 int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
2498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2499 #if defined(__cplusplus)
2500 } /*extern "C"*/
2501 #endif
2502
2503 #endif /* CSON_ENABLE_SQLITE3 */
2504
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
2494 takes SQL instead of a sqlite3_stmt object. It has the same
2495 return value and argument semantics as that function.
2496 */
2497 int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
2498
2499 /**
2500 Binds a JSON value to a 1-based parameter index in a prepared SQL
2501 statement. v must be NULL or one of one of the types (null, string,
2502 integer, double, boolean, array). Booleans are bound as integer 0
2503 or 1. NULL or null are bound as SQL NULL. Integers are bound as
2504 64-bit ints. Strings are bound using sqlite3_bind_text() (as
2505 opposed to text16), but we could/should arguably bind them as
2506 blobs.
2507
2508 If v is an Array then ndx is is used as a starting position
2509 (1-based) and each item in the array is bound to the next parameter
2510 position (starting and ndx, though the array uses 0-based offsets).
2511
2512 TODO: add Object support for named parameters.
2513
2514 Returns 0 on success, non-0 on error.
2515 */
2516 int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v );
2517
2518 #if defined(__cplusplus)
2519 } /*extern "C"*/
2520 #endif
2521
2522 #endif /* CSON_ENABLE_SQLITE3 */
2523
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
24942494
takes SQL instead of a sqlite3_stmt object. It has the same
24952495
return value and argument semantics as that function.
24962496
*/
24972497
int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
24982498
2499
+/**
2500
+ Binds a JSON value to a 1-based parameter index in a prepared SQL
2501
+ statement. v must be NULL or one of one of the types (null, string,
2502
+ integer, double, boolean, array). Booleans are bound as integer 0
2503
+ or 1. NULL or null are bound as SQL NULL. Integers are bound as
2504
+ 64-bit ints. Strings are bound using sqlite3_bind_text() (as
2505
+ opposed to text16), but we could/should arguably bind them as
2506
+ blobs.
2507
+
2508
+ If v is an Array then ndx is is used as a starting position
2509
+ (1-based) and each item in the array is bound to the next parameter
2510
+ position (starting and ndx, though the array uses 0-based offsets).
2511
+
2512
+ TODO: add Object support for named parameters.
2513
+
2514
+ Returns 0 on success, non-0 on error.
2515
+ */
2516
+int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v );
2517
+
24992518
#if defined(__cplusplus)
25002519
} /*extern "C"*/
25012520
#endif
25022521
25032522
#endif /* CSON_ENABLE_SQLITE3 */
25042523
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
2494 takes SQL instead of a sqlite3_stmt object. It has the same
2495 return value and argument semantics as that function.
2496 */
2497 int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
2498
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2499 #if defined(__cplusplus)
2500 } /*extern "C"*/
2501 #endif
2502
2503 #endif /* CSON_ENABLE_SQLITE3 */
2504
--- src/cson_amalgamation.h
+++ src/cson_amalgamation.h
@@ -2494,10 +2494,29 @@
2494 takes SQL instead of a sqlite3_stmt object. It has the same
2495 return value and argument semantics as that function.
2496 */
2497 int cson_sqlite3_sql_to_json( sqlite3 * db, cson_value ** tgt, char const * sql, char fat );
2498
2499 /**
2500 Binds a JSON value to a 1-based parameter index in a prepared SQL
2501 statement. v must be NULL or one of one of the types (null, string,
2502 integer, double, boolean, array). Booleans are bound as integer 0
2503 or 1. NULL or null are bound as SQL NULL. Integers are bound as
2504 64-bit ints. Strings are bound using sqlite3_bind_text() (as
2505 opposed to text16), but we could/should arguably bind them as
2506 blobs.
2507
2508 If v is an Array then ndx is is used as a starting position
2509 (1-based) and each item in the array is bound to the next parameter
2510 position (starting and ndx, though the array uses 0-based offsets).
2511
2512 TODO: add Object support for named parameters.
2513
2514 Returns 0 on success, non-0 on error.
2515 */
2516 int cson_sqlite3_bind_value( sqlite3_stmt * st, int ndx, cson_value const * v );
2517
2518 #if defined(__cplusplus)
2519 } /*extern "C"*/
2520 #endif
2521
2522 #endif /* CSON_ENABLE_SQLITE3 */
2523
+33
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604604
}
605605
cgi_set_content_type(zMime);
606606
cgi_set_content(&logo);
607607
g.isConst = 1;
608608
}
609
+
610
+/*
611
+** The default background image: a 16x16 white GIF
612
+*/
613
+static const unsigned char aBackground[] = {
614
+ 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615
+ 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616
+ 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617
+ 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618
+ 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619
+ 179, 62, 5, 0, 59,
620
+};
621
+
622
+
623
+/*
624
+** WEBPAGE: background
625
+**
626
+** Return the background image.
627
+*/
628
+void background_page(void){
629
+ Blob bgimg;
630
+ char *zMime;
631
+
632
+ zMime = db_get("background-mimetype", "image/gif");
633
+ blob_zero(&bgimg);
634
+ db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635
+ if( blob_size(&bgimg)==0 ){
636
+ blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637
+ }
638
+ cgi_set_content_type(zMime);
639
+ cgi_set_content(&bgimg);
640
+ g.isConst = 1;
641
+}
609642
610643
/*
611644
* vim:ts=2:sts=2:et:sw=2:ft=c
612645
*/
613646
614647
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
610 /*
611 * vim:ts=2:sts=2:et:sw=2:ft=c
612 */
613
614
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
609
610 /*
611 ** The default background image: a 16x16 white GIF
612 */
613 static const unsigned char aBackground[] = {
614 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619 179, 62, 5, 0, 59,
620 };
621
622
623 /*
624 ** WEBPAGE: background
625 **
626 ** Return the background image.
627 */
628 void background_page(void){
629 Blob bgimg;
630 char *zMime;
631
632 zMime = db_get("background-mimetype", "image/gif");
633 blob_zero(&bgimg);
634 db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635 if( blob_size(&bgimg)==0 ){
636 blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637 }
638 cgi_set_content_type(zMime);
639 cgi_set_content(&bgimg);
640 g.isConst = 1;
641 }
642
643 /*
644 * vim:ts=2:sts=2:et:sw=2:ft=c
645 */
646
647
+33
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604604
}
605605
cgi_set_content_type(zMime);
606606
cgi_set_content(&logo);
607607
g.isConst = 1;
608608
}
609
+
610
+/*
611
+** The default background image: a 16x16 white GIF
612
+*/
613
+static const unsigned char aBackground[] = {
614
+ 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615
+ 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616
+ 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617
+ 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618
+ 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619
+ 179, 62, 5, 0, 59,
620
+};
621
+
622
+
623
+/*
624
+** WEBPAGE: background
625
+**
626
+** Return the background image.
627
+*/
628
+void background_page(void){
629
+ Blob bgimg;
630
+ char *zMime;
631
+
632
+ zMime = db_get("background-mimetype", "image/gif");
633
+ blob_zero(&bgimg);
634
+ db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635
+ if( blob_size(&bgimg)==0 ){
636
+ blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637
+ }
638
+ cgi_set_content_type(zMime);
639
+ cgi_set_content(&bgimg);
640
+ g.isConst = 1;
641
+}
609642
610643
/*
611644
* vim:ts=2:sts=2:et:sw=2:ft=c
612645
*/
613646
614647
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
609
610 /*
611 * vim:ts=2:sts=2:et:sw=2:ft=c
612 */
613
614
--- src/doc.c
+++ src/doc.c
@@ -604,10 +604,43 @@
604 }
605 cgi_set_content_type(zMime);
606 cgi_set_content(&logo);
607 g.isConst = 1;
608 }
609
610 /*
611 ** The default background image: a 16x16 white GIF
612 */
613 static const unsigned char aBackground[] = {
614 71, 73, 70, 56, 57, 97, 16, 0, 16, 0,
615 240, 0, 0, 255, 255, 255, 0, 0, 0, 33,
616 254, 4, 119, 105, 115, 104, 0, 44, 0, 0,
617 0, 0, 16, 0, 16, 0, 0, 2, 14, 132,
618 143, 169, 203, 237, 15, 163, 156, 180, 218, 139,
619 179, 62, 5, 0, 59,
620 };
621
622
623 /*
624 ** WEBPAGE: background
625 **
626 ** Return the background image.
627 */
628 void background_page(void){
629 Blob bgimg;
630 char *zMime;
631
632 zMime = db_get("background-mimetype", "image/gif");
633 blob_zero(&bgimg);
634 db_blob(&bgimg, "SELECT value FROM config WHERE name='background-image'");
635 if( blob_size(&bgimg)==0 ){
636 blob_init(&bgimg, (char*)aBackground, sizeof(aBackground));
637 }
638 cgi_set_content_type(zMime);
639 cgi_set_content(&bgimg);
640 g.isConst = 1;
641 }
642
643 /*
644 * vim:ts=2:sts=2:et:sw=2:ft=c
645 */
646
647
+8 -4
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423423
cson_array * list = NULL;
424424
char const * zGlob = NULL;
425425
Stmt q = empty_Stmt;
426426
Blob sql = empty_blob;
427427
char const verbose = json_find_option_bool("verbose",NULL,"v",0);
428
+ char fInvert = json_find_option_bool("invert",NULL,"i",0);;
428429
429430
if( !g.perm.RdWiki && !g.perm.Read ){
430431
json_set_err(FSL_JSON_E_DENIED,
431432
"Requires 'j' or 'o' permissions.");
432433
return NULL;
433434
}
434435
blob_append(&sql,"SELECT"
435436
" substr(tagname,6) as name"
436
- " FROM tag WHERE tagname GLOB 'wiki-*' ",
437
+ " FROM tag WHERE tagname GLOB 'wiki-*'",
437438
-1);
438439
zGlob = json_find_option_cstr("glob",NULL,"g");
439440
if(zGlob && *zGlob){
440
- blob_appendf(&sql," AND name GLOB %Q ", zGlob);
441
+ blob_appendf(&sql," AND name %s GLOB %Q",
442
+ fInvert ? "NOT" : "", zGlob);
441443
}else{
442444
zGlob = json_find_option_cstr("like",NULL,"l");
443445
if(zGlob && *zGlob){
444
- blob_appendf(&sql," AND name LIKE %Q ", zGlob);
446
+ blob_appendf(&sql," AND name %s LIKE %Q",
447
+ fInvert ? "NOT" : "",
448
+ zGlob);
445449
}
446450
}
447
- blob_append(&sql,"ORDER BY lower(name)", -1);
451
+ blob_append(&sql," ORDER BY lower(name)", -1);
448452
db_prepare(&q,"%s", blob_str(&sql));
449453
blob_reset(&sql);
450454
listV = cson_value_new_array();
451455
list = cson_value_get_array(listV);
452456
while( SQLITE_ROW == db_step(&q) ){
453457
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423 cson_array * list = NULL;
424 char const * zGlob = NULL;
425 Stmt q = empty_Stmt;
426 Blob sql = empty_blob;
427 char const verbose = json_find_option_bool("verbose",NULL,"v",0);
 
428
429 if( !g.perm.RdWiki && !g.perm.Read ){
430 json_set_err(FSL_JSON_E_DENIED,
431 "Requires 'j' or 'o' permissions.");
432 return NULL;
433 }
434 blob_append(&sql,"SELECT"
435 " substr(tagname,6) as name"
436 " FROM tag WHERE tagname GLOB 'wiki-*' ",
437 -1);
438 zGlob = json_find_option_cstr("glob",NULL,"g");
439 if(zGlob && *zGlob){
440 blob_appendf(&sql," AND name GLOB %Q ", zGlob);
 
441 }else{
442 zGlob = json_find_option_cstr("like",NULL,"l");
443 if(zGlob && *zGlob){
444 blob_appendf(&sql," AND name LIKE %Q ", zGlob);
 
 
445 }
446 }
447 blob_append(&sql,"ORDER BY lower(name)", -1);
448 db_prepare(&q,"%s", blob_str(&sql));
449 blob_reset(&sql);
450 listV = cson_value_new_array();
451 list = cson_value_get_array(listV);
452 while( SQLITE_ROW == db_step(&q) ){
453
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423 cson_array * list = NULL;
424 char const * zGlob = NULL;
425 Stmt q = empty_Stmt;
426 Blob sql = empty_blob;
427 char const verbose = json_find_option_bool("verbose",NULL,"v",0);
428 char fInvert = json_find_option_bool("invert",NULL,"i",0);;
429
430 if( !g.perm.RdWiki && !g.perm.Read ){
431 json_set_err(FSL_JSON_E_DENIED,
432 "Requires 'j' or 'o' permissions.");
433 return NULL;
434 }
435 blob_append(&sql,"SELECT"
436 " substr(tagname,6) as name"
437 " FROM tag WHERE tagname GLOB 'wiki-*'",
438 -1);
439 zGlob = json_find_option_cstr("glob",NULL,"g");
440 if(zGlob && *zGlob){
441 blob_appendf(&sql," AND name %s GLOB %Q",
442 fInvert ? "NOT" : "", zGlob);
443 }else{
444 zGlob = json_find_option_cstr("like",NULL,"l");
445 if(zGlob && *zGlob){
446 blob_appendf(&sql," AND name %s LIKE %Q",
447 fInvert ? "NOT" : "",
448 zGlob);
449 }
450 }
451 blob_append(&sql," ORDER BY lower(name)", -1);
452 db_prepare(&q,"%s", blob_str(&sql));
453 blob_reset(&sql);
454 listV = cson_value_new_array();
455 list = cson_value_get_array(listV);
456 while( SQLITE_ROW == db_step(&q) ){
457
+8 -4
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423423
cson_array * list = NULL;
424424
char const * zGlob = NULL;
425425
Stmt q = empty_Stmt;
426426
Blob sql = empty_blob;
427427
char const verbose = json_find_option_bool("verbose",NULL,"v",0);
428
+ char fInvert = json_find_option_bool("invert",NULL,"i",0);;
428429
429430
if( !g.perm.RdWiki && !g.perm.Read ){
430431
json_set_err(FSL_JSON_E_DENIED,
431432
"Requires 'j' or 'o' permissions.");
432433
return NULL;
433434
}
434435
blob_append(&sql,"SELECT"
435436
" substr(tagname,6) as name"
436
- " FROM tag WHERE tagname GLOB 'wiki-*' ",
437
+ " FROM tag WHERE tagname GLOB 'wiki-*'",
437438
-1);
438439
zGlob = json_find_option_cstr("glob",NULL,"g");
439440
if(zGlob && *zGlob){
440
- blob_appendf(&sql," AND name GLOB %Q ", zGlob);
441
+ blob_appendf(&sql," AND name %s GLOB %Q",
442
+ fInvert ? "NOT" : "", zGlob);
441443
}else{
442444
zGlob = json_find_option_cstr("like",NULL,"l");
443445
if(zGlob && *zGlob){
444
- blob_appendf(&sql," AND name LIKE %Q ", zGlob);
446
+ blob_appendf(&sql," AND name %s LIKE %Q",
447
+ fInvert ? "NOT" : "",
448
+ zGlob);
445449
}
446450
}
447
- blob_append(&sql,"ORDER BY lower(name)", -1);
451
+ blob_append(&sql," ORDER BY lower(name)", -1);
448452
db_prepare(&q,"%s", blob_str(&sql));
449453
blob_reset(&sql);
450454
listV = cson_value_new_array();
451455
list = cson_value_get_array(listV);
452456
while( SQLITE_ROW == db_step(&q) ){
453457
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423 cson_array * list = NULL;
424 char const * zGlob = NULL;
425 Stmt q = empty_Stmt;
426 Blob sql = empty_blob;
427 char const verbose = json_find_option_bool("verbose",NULL,"v",0);
 
428
429 if( !g.perm.RdWiki && !g.perm.Read ){
430 json_set_err(FSL_JSON_E_DENIED,
431 "Requires 'j' or 'o' permissions.");
432 return NULL;
433 }
434 blob_append(&sql,"SELECT"
435 " substr(tagname,6) as name"
436 " FROM tag WHERE tagname GLOB 'wiki-*' ",
437 -1);
438 zGlob = json_find_option_cstr("glob",NULL,"g");
439 if(zGlob && *zGlob){
440 blob_appendf(&sql," AND name GLOB %Q ", zGlob);
 
441 }else{
442 zGlob = json_find_option_cstr("like",NULL,"l");
443 if(zGlob && *zGlob){
444 blob_appendf(&sql," AND name LIKE %Q ", zGlob);
 
 
445 }
446 }
447 blob_append(&sql,"ORDER BY lower(name)", -1);
448 db_prepare(&q,"%s", blob_str(&sql));
449 blob_reset(&sql);
450 listV = cson_value_new_array();
451 list = cson_value_get_array(listV);
452 while( SQLITE_ROW == db_step(&q) ){
453
--- src/json_wiki.c
+++ src/json_wiki.c
@@ -423,30 +423,34 @@
423 cson_array * list = NULL;
424 char const * zGlob = NULL;
425 Stmt q = empty_Stmt;
426 Blob sql = empty_blob;
427 char const verbose = json_find_option_bool("verbose",NULL,"v",0);
428 char fInvert = json_find_option_bool("invert",NULL,"i",0);;
429
430 if( !g.perm.RdWiki && !g.perm.Read ){
431 json_set_err(FSL_JSON_E_DENIED,
432 "Requires 'j' or 'o' permissions.");
433 return NULL;
434 }
435 blob_append(&sql,"SELECT"
436 " substr(tagname,6) as name"
437 " FROM tag WHERE tagname GLOB 'wiki-*'",
438 -1);
439 zGlob = json_find_option_cstr("glob",NULL,"g");
440 if(zGlob && *zGlob){
441 blob_appendf(&sql," AND name %s GLOB %Q",
442 fInvert ? "NOT" : "", zGlob);
443 }else{
444 zGlob = json_find_option_cstr("like",NULL,"l");
445 if(zGlob && *zGlob){
446 blob_appendf(&sql," AND name %s LIKE %Q",
447 fInvert ? "NOT" : "",
448 zGlob);
449 }
450 }
451 blob_append(&sql," ORDER BY lower(name)", -1);
452 db_prepare(&q,"%s", blob_str(&sql));
453 blob_reset(&sql);
454 listV = cson_value_new_array();
455 list = cson_value_get_array(listV);
456 while( SQLITE_ROW == db_step(&q) ){
457
+6 -24
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938938
939939
/*
940940
** Flags passed into the 2nd argument of login_set/replace_capabilities().
941941
*/
942942
#if INTERFACE
943
-#define LOGIN_IGNORE_U 0x01 /* Ignore "u" */
944
-#define LOGIN_IGNORE_V 0x01 /* Ignore "v" */
943
+#define LOGIN_IGNORE_UV 0x01 /* Ignore "u" and "v" */
945944
#endif
946945
947946
/*
948947
** Adds all capability flags in zCap to g.perm.
949948
*/
@@ -986,25 +985,25 @@
986985
case 'x': g.perm.Private = 1; break;
987986
988987
/* The "u" privileges is a little different. It recursively
989988
** inherits all privileges of the user named "reader" */
990989
case 'u': {
991
- if( (flags & LOGIN_IGNORE_U)==0 ){
990
+ if( (flags & LOGIN_IGNORE_UV)==0 ){
992991
const char *zUser;
993992
zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
994
- login_set_capabilities(zUser, flags | LOGIN_IGNORE_U);
993
+ login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV);
995994
}
996995
break;
997996
}
998997
999998
/* The "v" privileges is a little different. It recursively
1000999
** inherits all privileges of the user named "developer" */
10011000
case 'v': {
1002
- if( (flags & LOGIN_IGNORE_V)==0 ){
1001
+ if( (flags & LOGIN_IGNORE_UV)==0 ){
10031002
const char *zDev;
10041003
zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1005
- login_set_capabilities(zDev, flags | LOGIN_IGNORE_V);
1004
+ login_set_capabilities(zDev, flags | LOGIN_IGNORE_UV);
10061005
}
10071006
break;
10081007
}
10091008
}
10101009
}
@@ -1215,37 +1214,20 @@
12151214
@ %s(zUsername) already exists.
12161215
@ </span></p>
12171216
}else{
12181217
char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
12191218
int uid;
1220
- char *zCookie;
1221
- const char *zCookieName;
1222
- const char *zExpire;
1223
- int expires;
1224
- const char *zIpAddr;
12251219
db_multi_exec(
12261220
"INSERT INTO user(login,pw,cap,info)"
12271221
"VALUES(%B,%Q,%B,%B)",
12281222
&login, zPw, &caps, &contact
12291223
);
12301224
free(zPw);
12311225
12321226
/* The user is registered, now just log him in. */
12331227
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1234
- zCookieName = login_cookie_name();
1235
- zExpire = db_get("cookie-expire","8766");
1236
- expires = atoi(zExpire)*3600;
1237
- zIpAddr = PD("REMOTE_ADDR","nil");
1238
-
1239
- zCookie = db_text(0, "SELECT '%d/' || hex(randomblob(25))", uid);
1240
- cgi_set_cookie(zCookieName, zCookie, login_cookie_path(), expires);
1241
- record_login_attempt(zUsername, zIpAddr, 1);
1242
- db_multi_exec(
1243
- "UPDATE user SET cookie=%Q, ipaddr=%Q, "
1244
- " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
1245
- zCookie, ipPrefix(zIpAddr), expires, uid
1246
- );
1228
+ login_set_user_cookie( zUsername, uid, NULL );
12471229
redirect_to_g();
12481230
12491231
}
12501232
}
12511233
}
12521234
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938
939 /*
940 ** Flags passed into the 2nd argument of login_set/replace_capabilities().
941 */
942 #if INTERFACE
943 #define LOGIN_IGNORE_U 0x01 /* Ignore "u" */
944 #define LOGIN_IGNORE_V 0x01 /* Ignore "v" */
945 #endif
946
947 /*
948 ** Adds all capability flags in zCap to g.perm.
949 */
@@ -986,25 +985,25 @@
986 case 'x': g.perm.Private = 1; break;
987
988 /* The "u" privileges is a little different. It recursively
989 ** inherits all privileges of the user named "reader" */
990 case 'u': {
991 if( (flags & LOGIN_IGNORE_U)==0 ){
992 const char *zUser;
993 zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
994 login_set_capabilities(zUser, flags | LOGIN_IGNORE_U);
995 }
996 break;
997 }
998
999 /* The "v" privileges is a little different. It recursively
1000 ** inherits all privileges of the user named "developer" */
1001 case 'v': {
1002 if( (flags & LOGIN_IGNORE_V)==0 ){
1003 const char *zDev;
1004 zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1005 login_set_capabilities(zDev, flags | LOGIN_IGNORE_V);
1006 }
1007 break;
1008 }
1009 }
1010 }
@@ -1215,37 +1214,20 @@
1215 @ %s(zUsername) already exists.
1216 @ </span></p>
1217 }else{
1218 char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
1219 int uid;
1220 char *zCookie;
1221 const char *zCookieName;
1222 const char *zExpire;
1223 int expires;
1224 const char *zIpAddr;
1225 db_multi_exec(
1226 "INSERT INTO user(login,pw,cap,info)"
1227 "VALUES(%B,%Q,%B,%B)",
1228 &login, zPw, &caps, &contact
1229 );
1230 free(zPw);
1231
1232 /* The user is registered, now just log him in. */
1233 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1234 zCookieName = login_cookie_name();
1235 zExpire = db_get("cookie-expire","8766");
1236 expires = atoi(zExpire)*3600;
1237 zIpAddr = PD("REMOTE_ADDR","nil");
1238
1239 zCookie = db_text(0, "SELECT '%d/' || hex(randomblob(25))", uid);
1240 cgi_set_cookie(zCookieName, zCookie, login_cookie_path(), expires);
1241 record_login_attempt(zUsername, zIpAddr, 1);
1242 db_multi_exec(
1243 "UPDATE user SET cookie=%Q, ipaddr=%Q, "
1244 " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
1245 zCookie, ipPrefix(zIpAddr), expires, uid
1246 );
1247 redirect_to_g();
1248
1249 }
1250 }
1251 }
1252
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938
939 /*
940 ** Flags passed into the 2nd argument of login_set/replace_capabilities().
941 */
942 #if INTERFACE
943 #define LOGIN_IGNORE_UV 0x01 /* Ignore "u" and "v" */
 
944 #endif
945
946 /*
947 ** Adds all capability flags in zCap to g.perm.
948 */
@@ -986,25 +985,25 @@
985 case 'x': g.perm.Private = 1; break;
986
987 /* The "u" privileges is a little different. It recursively
988 ** inherits all privileges of the user named "reader" */
989 case 'u': {
990 if( (flags & LOGIN_IGNORE_UV)==0 ){
991 const char *zUser;
992 zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
993 login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV);
994 }
995 break;
996 }
997
998 /* The "v" privileges is a little different. It recursively
999 ** inherits all privileges of the user named "developer" */
1000 case 'v': {
1001 if( (flags & LOGIN_IGNORE_UV)==0 ){
1002 const char *zDev;
1003 zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1004 login_set_capabilities(zDev, flags | LOGIN_IGNORE_UV);
1005 }
1006 break;
1007 }
1008 }
1009 }
@@ -1215,37 +1214,20 @@
1214 @ %s(zUsername) already exists.
1215 @ </span></p>
1216 }else{
1217 char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
1218 int uid;
 
 
 
 
 
1219 db_multi_exec(
1220 "INSERT INTO user(login,pw,cap,info)"
1221 "VALUES(%B,%Q,%B,%B)",
1222 &login, zPw, &caps, &contact
1223 );
1224 free(zPw);
1225
1226 /* The user is registered, now just log him in. */
1227 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1228 login_set_user_cookie( zUsername, uid, NULL );
 
 
 
 
 
 
 
 
 
 
 
 
1229 redirect_to_g();
1230
1231 }
1232 }
1233 }
1234
+6 -24
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938938
939939
/*
940940
** Flags passed into the 2nd argument of login_set/replace_capabilities().
941941
*/
942942
#if INTERFACE
943
-#define LOGIN_IGNORE_U 0x01 /* Ignore "u" */
944
-#define LOGIN_IGNORE_V 0x01 /* Ignore "v" */
943
+#define LOGIN_IGNORE_UV 0x01 /* Ignore "u" and "v" */
945944
#endif
946945
947946
/*
948947
** Adds all capability flags in zCap to g.perm.
949948
*/
@@ -986,25 +985,25 @@
986985
case 'x': g.perm.Private = 1; break;
987986
988987
/* The "u" privileges is a little different. It recursively
989988
** inherits all privileges of the user named "reader" */
990989
case 'u': {
991
- if( (flags & LOGIN_IGNORE_U)==0 ){
990
+ if( (flags & LOGIN_IGNORE_UV)==0 ){
992991
const char *zUser;
993992
zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
994
- login_set_capabilities(zUser, flags | LOGIN_IGNORE_U);
993
+ login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV);
995994
}
996995
break;
997996
}
998997
999998
/* The "v" privileges is a little different. It recursively
1000999
** inherits all privileges of the user named "developer" */
10011000
case 'v': {
1002
- if( (flags & LOGIN_IGNORE_V)==0 ){
1001
+ if( (flags & LOGIN_IGNORE_UV)==0 ){
10031002
const char *zDev;
10041003
zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1005
- login_set_capabilities(zDev, flags | LOGIN_IGNORE_V);
1004
+ login_set_capabilities(zDev, flags | LOGIN_IGNORE_UV);
10061005
}
10071006
break;
10081007
}
10091008
}
10101009
}
@@ -1215,37 +1214,20 @@
12151214
@ %s(zUsername) already exists.
12161215
@ </span></p>
12171216
}else{
12181217
char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
12191218
int uid;
1220
- char *zCookie;
1221
- const char *zCookieName;
1222
- const char *zExpire;
1223
- int expires;
1224
- const char *zIpAddr;
12251219
db_multi_exec(
12261220
"INSERT INTO user(login,pw,cap,info)"
12271221
"VALUES(%B,%Q,%B,%B)",
12281222
&login, zPw, &caps, &contact
12291223
);
12301224
free(zPw);
12311225
12321226
/* The user is registered, now just log him in. */
12331227
uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1234
- zCookieName = login_cookie_name();
1235
- zExpire = db_get("cookie-expire","8766");
1236
- expires = atoi(zExpire)*3600;
1237
- zIpAddr = PD("REMOTE_ADDR","nil");
1238
-
1239
- zCookie = db_text(0, "SELECT '%d/' || hex(randomblob(25))", uid);
1240
- cgi_set_cookie(zCookieName, zCookie, login_cookie_path(), expires);
1241
- record_login_attempt(zUsername, zIpAddr, 1);
1242
- db_multi_exec(
1243
- "UPDATE user SET cookie=%Q, ipaddr=%Q, "
1244
- " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
1245
- zCookie, ipPrefix(zIpAddr), expires, uid
1246
- );
1228
+ login_set_user_cookie( zUsername, uid, NULL );
12471229
redirect_to_g();
12481230
12491231
}
12501232
}
12511233
}
12521234
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938
939 /*
940 ** Flags passed into the 2nd argument of login_set/replace_capabilities().
941 */
942 #if INTERFACE
943 #define LOGIN_IGNORE_U 0x01 /* Ignore "u" */
944 #define LOGIN_IGNORE_V 0x01 /* Ignore "v" */
945 #endif
946
947 /*
948 ** Adds all capability flags in zCap to g.perm.
949 */
@@ -986,25 +985,25 @@
986 case 'x': g.perm.Private = 1; break;
987
988 /* The "u" privileges is a little different. It recursively
989 ** inherits all privileges of the user named "reader" */
990 case 'u': {
991 if( (flags & LOGIN_IGNORE_U)==0 ){
992 const char *zUser;
993 zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
994 login_set_capabilities(zUser, flags | LOGIN_IGNORE_U);
995 }
996 break;
997 }
998
999 /* The "v" privileges is a little different. It recursively
1000 ** inherits all privileges of the user named "developer" */
1001 case 'v': {
1002 if( (flags & LOGIN_IGNORE_V)==0 ){
1003 const char *zDev;
1004 zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1005 login_set_capabilities(zDev, flags | LOGIN_IGNORE_V);
1006 }
1007 break;
1008 }
1009 }
1010 }
@@ -1215,37 +1214,20 @@
1215 @ %s(zUsername) already exists.
1216 @ </span></p>
1217 }else{
1218 char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
1219 int uid;
1220 char *zCookie;
1221 const char *zCookieName;
1222 const char *zExpire;
1223 int expires;
1224 const char *zIpAddr;
1225 db_multi_exec(
1226 "INSERT INTO user(login,pw,cap,info)"
1227 "VALUES(%B,%Q,%B,%B)",
1228 &login, zPw, &caps, &contact
1229 );
1230 free(zPw);
1231
1232 /* The user is registered, now just log him in. */
1233 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1234 zCookieName = login_cookie_name();
1235 zExpire = db_get("cookie-expire","8766");
1236 expires = atoi(zExpire)*3600;
1237 zIpAddr = PD("REMOTE_ADDR","nil");
1238
1239 zCookie = db_text(0, "SELECT '%d/' || hex(randomblob(25))", uid);
1240 cgi_set_cookie(zCookieName, zCookie, login_cookie_path(), expires);
1241 record_login_attempt(zUsername, zIpAddr, 1);
1242 db_multi_exec(
1243 "UPDATE user SET cookie=%Q, ipaddr=%Q, "
1244 " cexpire=julianday('now')+%d/86400.0 WHERE uid=%d",
1245 zCookie, ipPrefix(zIpAddr), expires, uid
1246 );
1247 redirect_to_g();
1248
1249 }
1250 }
1251 }
1252
--- src/login.c
+++ src/login.c
@@ -938,12 +938,11 @@
938
939 /*
940 ** Flags passed into the 2nd argument of login_set/replace_capabilities().
941 */
942 #if INTERFACE
943 #define LOGIN_IGNORE_UV 0x01 /* Ignore "u" and "v" */
 
944 #endif
945
946 /*
947 ** Adds all capability flags in zCap to g.perm.
948 */
@@ -986,25 +985,25 @@
985 case 'x': g.perm.Private = 1; break;
986
987 /* The "u" privileges is a little different. It recursively
988 ** inherits all privileges of the user named "reader" */
989 case 'u': {
990 if( (flags & LOGIN_IGNORE_UV)==0 ){
991 const char *zUser;
992 zUser = db_text("", "SELECT cap FROM user WHERE login='reader'");
993 login_set_capabilities(zUser, flags | LOGIN_IGNORE_UV);
994 }
995 break;
996 }
997
998 /* The "v" privileges is a little different. It recursively
999 ** inherits all privileges of the user named "developer" */
1000 case 'v': {
1001 if( (flags & LOGIN_IGNORE_UV)==0 ){
1002 const char *zDev;
1003 zDev = db_text("", "SELECT cap FROM user WHERE login='developer'");
1004 login_set_capabilities(zDev, flags | LOGIN_IGNORE_UV);
1005 }
1006 break;
1007 }
1008 }
1009 }
@@ -1215,37 +1214,20 @@
1214 @ %s(zUsername) already exists.
1215 @ </span></p>
1216 }else{
1217 char *zPw = sha1_shared_secret(blob_str(&passwd), blob_str(&login), 0);
1218 int uid;
 
 
 
 
 
1219 db_multi_exec(
1220 "INSERT INTO user(login,pw,cap,info)"
1221 "VALUES(%B,%Q,%B,%B)",
1222 &login, zPw, &caps, &contact
1223 );
1224 free(zPw);
1225
1226 /* The user is registered, now just log him in. */
1227 uid = db_int(0, "SELECT uid FROM user WHERE login=%Q", zUsername);
1228 login_set_user_cookie( zUsername, uid, NULL );
 
 
 
 
 
 
 
 
 
 
 
 
1229 redirect_to_g();
1230
1231 }
1232 }
1233 }
1234
+80 -26
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
8484
setup_menu_entry("Header", "setup_header",
8585
"Edit HTML text inserted at the top of every page");
8686
setup_menu_entry("Footer", "setup_footer",
8787
"Edit HTML text inserted at the bottom of every page");
8888
setup_menu_entry("Logo", "setup_logo",
89
- "Change the logo image for the server");
89
+ "Change the logo and background images for the server");
9090
setup_menu_entry("Shunned", "shun",
9191
"Show artifacts that are shunned by this repository");
9292
setup_menu_entry("Log", "rcvfromlist",
9393
"A record of received artifacts and their sources");
9494
setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
13191319
13201320
/*
13211321
** WEBPAGE: setup_logo
13221322
*/
13231323
void setup_logo(void){
1324
- const char *zMime = db_get("logo-mimetype","image/gif");
1325
- const char *aImg = P("im");
1326
- int szImg = atoi(PD("im:bytes","0"));
1327
- if( szImg>0 ){
1328
- zMime = PD("im:mimetype","image/gif");
1324
+ const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325
+ const char *aLogoImg = P("logoim");
1326
+ int szLogoImg = atoi(PD("logoim:bytes","0"));
1327
+ const char *zBgMime = db_get("background-mimetype","image/gif");
1328
+ const char *aBgImg = P("bgim");
1329
+ int szBgImg = atoi(PD("bgim:bytes","0"));
1330
+ if( szLogoImg>0 ){
1331
+ zLogoMime = PD("logoim:mimetype","image/gif");
1332
+ }
1333
+ if( szBgImg>0 ){
1334
+ zBgMime = PD("bgim:mimetype","image/gif");
13291335
}
13301336
login_check_credentials();
13311337
if( !g.perm.Setup ){
13321338
login_needed();
13331339
}
13341340
db_begin_transaction();
1335
- if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1341
+ if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
13361342
Blob img;
13371343
Stmt ins;
1338
- blob_init(&img, aImg, szImg);
1344
+ blob_init(&img, aLogoImg, szLogoImg);
13391345
db_prepare(&ins,
13401346
"REPLACE INTO config(name,value,mtime)"
13411347
" VALUES('logo-image',:bytes,now())"
13421348
);
13431349
db_bind_blob(&ins, ":bytes", &img);
13441350
db_step(&ins);
13451351
db_finalize(&ins);
13461352
db_multi_exec(
13471353
"REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348
- zMime
1354
+ zLogoMime
1355
+ );
1356
+ db_end_transaction(0);
1357
+ cgi_redirect("setup_logo");
1358
+ }else if( P("clrlogo")!=0 ){
1359
+ db_multi_exec(
1360
+ "DELETE FROM config WHERE name IN "
1361
+ "('logo-image','logo-mimetype')"
1362
+ );
1363
+ db_end_transaction(0);
1364
+ cgi_redirect("setup_logo");
1365
+ }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366
+ Blob img;
1367
+ Stmt ins;
1368
+ blob_init(&img, aBgImg, szBgImg);
1369
+ db_prepare(&ins,
1370
+ "REPLACE INTO config(name,value,mtime)"
1371
+ " VALUES('background-image',:bytes,now())"
1372
+ );
1373
+ db_bind_blob(&ins, ":bytes", &img);
1374
+ db_step(&ins);
1375
+ db_finalize(&ins);
1376
+ db_multi_exec(
1377
+ "REPLACE INTO config(name,value,mtime)"
1378
+ " VALUES('background-mimetype',%Q,now())",
1379
+ zBgMime
13491380
);
13501381
db_end_transaction(0);
13511382
cgi_redirect("setup_logo");
1352
- }else if( P("clr")!=0 ){
1383
+ }else if( P("clrbg")!=0 ){
13531384
db_multi_exec(
1354
- "DELETE FROM config WHERE name GLOB 'logo-*'"
1385
+ "DELETE FROM config WHERE name IN "
1386
+ "('background-image','background-mimetype')"
13551387
);
13561388
db_end_transaction(0);
13571389
cgi_redirect("setup_logo");
13581390
}
1359
- style_header("Edit Project Logo");
1360
- @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361
- @ like this:</p>
1362
- @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
1391
+ style_header("Edit Project Logo And Background");
1392
+ @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393
+ @ and looks like this:</p>
1394
+ @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395
+ @ </p></blockquote>
13631396
@
1397
+ @ <form action="%s(g.zTop)/setup_logo" method="post"
1398
+ @ enctype="multipart/form-data"><div>
13641399
@ <p>The logo is accessible to all users at this URL:
13651400
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
13661401
@ The logo may or may not appear on each
13671402
@ page depending on the <a href="setup_editcss">CSS</a> and
1368
- @ <a href="setup_header">header setup</a>.</p>
1403
+ @ <a href="setup_header">header setup</a>.
1404
+ @ To change the logo image, use the following form:</p>
1405
+ login_insert_csrf_secret();
1406
+ @ Logo Image file:
1407
+ @ <input type="file" name="logoim" size="60" accept="image/*" />
1408
+ @ <p align="center">
1409
+ @ <input type="submit" name="setlogo" value="Change Logo" />
1410
+ @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411
+ @ </div></form>
1412
+ @ <hr />
1413
+ @
1414
+ @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415
+ @ and looks like this:</p>
1416
+ @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417
+ @ </p></blockquote>
13691418
@
13701419
@ <form action="%s(g.zTop)/setup_logo" method="post"
13711420
@ enctype="multipart/form-data"><div>
1372
- @ <p>To set a new logo image, select a file to use as the logo using
1373
- @ the entry box below and then press the "Change Logo" button.</p>
1421
+ @ <p>The background image is accessible to all users at this URL:
1422
+ @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423
+ @ The background image may or may not appear on each
1424
+ @ page depending on the <a href="setup_editcss">CSS</a> and
1425
+ @ <a href="setup_header">header setup</a>.
1426
+ @ To change the background image, use the following form:</p>
13741427
login_insert_csrf_secret();
1375
- @ Logo Image file:
1376
- @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377
- @ <input type="submit" name="set" value="Change Logo" />
1378
- @ <input type="submit" name="clr" value="Revert To Default" />
1428
+ @ Background image file:
1429
+ @ <input type="file" name="bgim" size="60" accept="image/*" />
1430
+ @ <p align="center">
1431
+ @ <input type="submit" name="setbg" value="Change Background" />
1432
+ @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
13791433
@ </div></form>
1434
+ @ <hr />
13801435
@
1381
- @ <p><span class="note">Note:</span> Your browser has probably cached the
1382
- @ logo image, so you will probably need to press the Reload button on your
1383
- @ browser after changing the logo to provoke your browser to reload the new
1384
- @ logo image. </p>
1436
+ @ <p><span class="note">Note:</span> Your browser has probably cached these
1437
+ @ images, so you may need to press the Reload button before changes will
1438
+ @ take effect. </p>
13851439
style_footer();
13861440
db_end_transaction(0);
13871441
}
13881442
13891443
/*
13901444
* vim:ts=2:sts=2:et:sw=2:ft=c
13911445
*/
13921446
13931447
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo image for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zMime = db_get("logo-mimetype","image/gif");
1325 const char *aImg = P("im");
1326 int szImg = atoi(PD("im:bytes","0"));
1327 if( szImg>0 ){
1328 zMime = PD("im:mimetype","image/gif");
 
 
 
 
 
 
1329 }
1330 login_check_credentials();
1331 if( !g.perm.Setup ){
1332 login_needed();
1333 }
1334 db_begin_transaction();
1335 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1336 Blob img;
1337 Stmt ins;
1338 blob_init(&img, aImg, szImg);
1339 db_prepare(&ins,
1340 "REPLACE INTO config(name,value,mtime)"
1341 " VALUES('logo-image',:bytes,now())"
1342 );
1343 db_bind_blob(&ins, ":bytes", &img);
1344 db_step(&ins);
1345 db_finalize(&ins);
1346 db_multi_exec(
1347 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348 zMime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1349 );
1350 db_end_transaction(0);
1351 cgi_redirect("setup_logo");
1352 }else if( P("clr")!=0 ){
1353 db_multi_exec(
1354 "DELETE FROM config WHERE name GLOB 'logo-*'"
 
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }
1359 style_header("Edit Project Logo");
1360 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361 @ like this:</p>
1362 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
 
1363 @
 
 
1364 @ <p>The logo is accessible to all users at this URL:
1365 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1366 @ The logo may or may not appear on each
1367 @ page depending on the <a href="setup_editcss">CSS</a> and
1368 @ <a href="setup_header">header setup</a>.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369 @
1370 @ <form action="%s(g.zTop)/setup_logo" method="post"
1371 @ enctype="multipart/form-data"><div>
1372 @ <p>To set a new logo image, select a file to use as the logo using
1373 @ the entry box below and then press the "Change Logo" button.</p>
 
 
 
 
1374 login_insert_csrf_secret();
1375 @ Logo Image file:
1376 @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377 @ <input type="submit" name="set" value="Change Logo" />
1378 @ <input type="submit" name="clr" value="Revert To Default" />
 
1379 @ </div></form>
 
1380 @
1381 @ <p><span class="note">Note:</span> Your browser has probably cached the
1382 @ logo image, so you will probably need to press the Reload button on your
1383 @ browser after changing the logo to provoke your browser to reload the new
1384 @ logo image. </p>
1385 style_footer();
1386 db_end_transaction(0);
1387 }
1388
1389 /*
1390 * vim:ts=2:sts=2:et:sw=2:ft=c
1391 */
1392
1393
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo and background images for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325 const char *aLogoImg = P("logoim");
1326 int szLogoImg = atoi(PD("logoim:bytes","0"));
1327 const char *zBgMime = db_get("background-mimetype","image/gif");
1328 const char *aBgImg = P("bgim");
1329 int szBgImg = atoi(PD("bgim:bytes","0"));
1330 if( szLogoImg>0 ){
1331 zLogoMime = PD("logoim:mimetype","image/gif");
1332 }
1333 if( szBgImg>0 ){
1334 zBgMime = PD("bgim:mimetype","image/gif");
1335 }
1336 login_check_credentials();
1337 if( !g.perm.Setup ){
1338 login_needed();
1339 }
1340 db_begin_transaction();
1341 if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
1342 Blob img;
1343 Stmt ins;
1344 blob_init(&img, aLogoImg, szLogoImg);
1345 db_prepare(&ins,
1346 "REPLACE INTO config(name,value,mtime)"
1347 " VALUES('logo-image',:bytes,now())"
1348 );
1349 db_bind_blob(&ins, ":bytes", &img);
1350 db_step(&ins);
1351 db_finalize(&ins);
1352 db_multi_exec(
1353 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1354 zLogoMime
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }else if( P("clrlogo")!=0 ){
1359 db_multi_exec(
1360 "DELETE FROM config WHERE name IN "
1361 "('logo-image','logo-mimetype')"
1362 );
1363 db_end_transaction(0);
1364 cgi_redirect("setup_logo");
1365 }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366 Blob img;
1367 Stmt ins;
1368 blob_init(&img, aBgImg, szBgImg);
1369 db_prepare(&ins,
1370 "REPLACE INTO config(name,value,mtime)"
1371 " VALUES('background-image',:bytes,now())"
1372 );
1373 db_bind_blob(&ins, ":bytes", &img);
1374 db_step(&ins);
1375 db_finalize(&ins);
1376 db_multi_exec(
1377 "REPLACE INTO config(name,value,mtime)"
1378 " VALUES('background-mimetype',%Q,now())",
1379 zBgMime
1380 );
1381 db_end_transaction(0);
1382 cgi_redirect("setup_logo");
1383 }else if( P("clrbg")!=0 ){
1384 db_multi_exec(
1385 "DELETE FROM config WHERE name IN "
1386 "('background-image','background-mimetype')"
1387 );
1388 db_end_transaction(0);
1389 cgi_redirect("setup_logo");
1390 }
1391 style_header("Edit Project Logo And Background");
1392 @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393 @ and looks like this:</p>
1394 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395 @ </p></blockquote>
1396 @
1397 @ <form action="%s(g.zTop)/setup_logo" method="post"
1398 @ enctype="multipart/form-data"><div>
1399 @ <p>The logo is accessible to all users at this URL:
1400 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1401 @ The logo may or may not appear on each
1402 @ page depending on the <a href="setup_editcss">CSS</a> and
1403 @ <a href="setup_header">header setup</a>.
1404 @ To change the logo image, use the following form:</p>
1405 login_insert_csrf_secret();
1406 @ Logo Image file:
1407 @ <input type="file" name="logoim" size="60" accept="image/*" />
1408 @ <p align="center">
1409 @ <input type="submit" name="setlogo" value="Change Logo" />
1410 @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411 @ </div></form>
1412 @ <hr />
1413 @
1414 @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415 @ and looks like this:</p>
1416 @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417 @ </p></blockquote>
1418 @
1419 @ <form action="%s(g.zTop)/setup_logo" method="post"
1420 @ enctype="multipart/form-data"><div>
1421 @ <p>The background image is accessible to all users at this URL:
1422 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423 @ The background image may or may not appear on each
1424 @ page depending on the <a href="setup_editcss">CSS</a> and
1425 @ <a href="setup_header">header setup</a>.
1426 @ To change the background image, use the following form:</p>
1427 login_insert_csrf_secret();
1428 @ Background image file:
1429 @ <input type="file" name="bgim" size="60" accept="image/*" />
1430 @ <p align="center">
1431 @ <input type="submit" name="setbg" value="Change Background" />
1432 @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
1433 @ </div></form>
1434 @ <hr />
1435 @
1436 @ <p><span class="note">Note:</span> Your browser has probably cached these
1437 @ images, so you may need to press the Reload button before changes will
1438 @ take effect. </p>
 
1439 style_footer();
1440 db_end_transaction(0);
1441 }
1442
1443 /*
1444 * vim:ts=2:sts=2:et:sw=2:ft=c
1445 */
1446
1447
+80 -26
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
8484
setup_menu_entry("Header", "setup_header",
8585
"Edit HTML text inserted at the top of every page");
8686
setup_menu_entry("Footer", "setup_footer",
8787
"Edit HTML text inserted at the bottom of every page");
8888
setup_menu_entry("Logo", "setup_logo",
89
- "Change the logo image for the server");
89
+ "Change the logo and background images for the server");
9090
setup_menu_entry("Shunned", "shun",
9191
"Show artifacts that are shunned by this repository");
9292
setup_menu_entry("Log", "rcvfromlist",
9393
"A record of received artifacts and their sources");
9494
setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
13191319
13201320
/*
13211321
** WEBPAGE: setup_logo
13221322
*/
13231323
void setup_logo(void){
1324
- const char *zMime = db_get("logo-mimetype","image/gif");
1325
- const char *aImg = P("im");
1326
- int szImg = atoi(PD("im:bytes","0"));
1327
- if( szImg>0 ){
1328
- zMime = PD("im:mimetype","image/gif");
1324
+ const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325
+ const char *aLogoImg = P("logoim");
1326
+ int szLogoImg = atoi(PD("logoim:bytes","0"));
1327
+ const char *zBgMime = db_get("background-mimetype","image/gif");
1328
+ const char *aBgImg = P("bgim");
1329
+ int szBgImg = atoi(PD("bgim:bytes","0"));
1330
+ if( szLogoImg>0 ){
1331
+ zLogoMime = PD("logoim:mimetype","image/gif");
1332
+ }
1333
+ if( szBgImg>0 ){
1334
+ zBgMime = PD("bgim:mimetype","image/gif");
13291335
}
13301336
login_check_credentials();
13311337
if( !g.perm.Setup ){
13321338
login_needed();
13331339
}
13341340
db_begin_transaction();
1335
- if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1341
+ if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
13361342
Blob img;
13371343
Stmt ins;
1338
- blob_init(&img, aImg, szImg);
1344
+ blob_init(&img, aLogoImg, szLogoImg);
13391345
db_prepare(&ins,
13401346
"REPLACE INTO config(name,value,mtime)"
13411347
" VALUES('logo-image',:bytes,now())"
13421348
);
13431349
db_bind_blob(&ins, ":bytes", &img);
13441350
db_step(&ins);
13451351
db_finalize(&ins);
13461352
db_multi_exec(
13471353
"REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348
- zMime
1354
+ zLogoMime
1355
+ );
1356
+ db_end_transaction(0);
1357
+ cgi_redirect("setup_logo");
1358
+ }else if( P("clrlogo")!=0 ){
1359
+ db_multi_exec(
1360
+ "DELETE FROM config WHERE name IN "
1361
+ "('logo-image','logo-mimetype')"
1362
+ );
1363
+ db_end_transaction(0);
1364
+ cgi_redirect("setup_logo");
1365
+ }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366
+ Blob img;
1367
+ Stmt ins;
1368
+ blob_init(&img, aBgImg, szBgImg);
1369
+ db_prepare(&ins,
1370
+ "REPLACE INTO config(name,value,mtime)"
1371
+ " VALUES('background-image',:bytes,now())"
1372
+ );
1373
+ db_bind_blob(&ins, ":bytes", &img);
1374
+ db_step(&ins);
1375
+ db_finalize(&ins);
1376
+ db_multi_exec(
1377
+ "REPLACE INTO config(name,value,mtime)"
1378
+ " VALUES('background-mimetype',%Q,now())",
1379
+ zBgMime
13491380
);
13501381
db_end_transaction(0);
13511382
cgi_redirect("setup_logo");
1352
- }else if( P("clr")!=0 ){
1383
+ }else if( P("clrbg")!=0 ){
13531384
db_multi_exec(
1354
- "DELETE FROM config WHERE name GLOB 'logo-*'"
1385
+ "DELETE FROM config WHERE name IN "
1386
+ "('background-image','background-mimetype')"
13551387
);
13561388
db_end_transaction(0);
13571389
cgi_redirect("setup_logo");
13581390
}
1359
- style_header("Edit Project Logo");
1360
- @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361
- @ like this:</p>
1362
- @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
1391
+ style_header("Edit Project Logo And Background");
1392
+ @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393
+ @ and looks like this:</p>
1394
+ @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395
+ @ </p></blockquote>
13631396
@
1397
+ @ <form action="%s(g.zTop)/setup_logo" method="post"
1398
+ @ enctype="multipart/form-data"><div>
13641399
@ <p>The logo is accessible to all users at this URL:
13651400
@ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
13661401
@ The logo may or may not appear on each
13671402
@ page depending on the <a href="setup_editcss">CSS</a> and
1368
- @ <a href="setup_header">header setup</a>.</p>
1403
+ @ <a href="setup_header">header setup</a>.
1404
+ @ To change the logo image, use the following form:</p>
1405
+ login_insert_csrf_secret();
1406
+ @ Logo Image file:
1407
+ @ <input type="file" name="logoim" size="60" accept="image/*" />
1408
+ @ <p align="center">
1409
+ @ <input type="submit" name="setlogo" value="Change Logo" />
1410
+ @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411
+ @ </div></form>
1412
+ @ <hr />
1413
+ @
1414
+ @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415
+ @ and looks like this:</p>
1416
+ @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417
+ @ </p></blockquote>
13691418
@
13701419
@ <form action="%s(g.zTop)/setup_logo" method="post"
13711420
@ enctype="multipart/form-data"><div>
1372
- @ <p>To set a new logo image, select a file to use as the logo using
1373
- @ the entry box below and then press the "Change Logo" button.</p>
1421
+ @ <p>The background image is accessible to all users at this URL:
1422
+ @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423
+ @ The background image may or may not appear on each
1424
+ @ page depending on the <a href="setup_editcss">CSS</a> and
1425
+ @ <a href="setup_header">header setup</a>.
1426
+ @ To change the background image, use the following form:</p>
13741427
login_insert_csrf_secret();
1375
- @ Logo Image file:
1376
- @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377
- @ <input type="submit" name="set" value="Change Logo" />
1378
- @ <input type="submit" name="clr" value="Revert To Default" />
1428
+ @ Background image file:
1429
+ @ <input type="file" name="bgim" size="60" accept="image/*" />
1430
+ @ <p align="center">
1431
+ @ <input type="submit" name="setbg" value="Change Background" />
1432
+ @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
13791433
@ </div></form>
1434
+ @ <hr />
13801435
@
1381
- @ <p><span class="note">Note:</span> Your browser has probably cached the
1382
- @ logo image, so you will probably need to press the Reload button on your
1383
- @ browser after changing the logo to provoke your browser to reload the new
1384
- @ logo image. </p>
1436
+ @ <p><span class="note">Note:</span> Your browser has probably cached these
1437
+ @ images, so you may need to press the Reload button before changes will
1438
+ @ take effect. </p>
13851439
style_footer();
13861440
db_end_transaction(0);
13871441
}
13881442
13891443
/*
13901444
* vim:ts=2:sts=2:et:sw=2:ft=c
13911445
*/
13921446
13931447
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo image for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zMime = db_get("logo-mimetype","image/gif");
1325 const char *aImg = P("im");
1326 int szImg = atoi(PD("im:bytes","0"));
1327 if( szImg>0 ){
1328 zMime = PD("im:mimetype","image/gif");
 
 
 
 
 
 
1329 }
1330 login_check_credentials();
1331 if( !g.perm.Setup ){
1332 login_needed();
1333 }
1334 db_begin_transaction();
1335 if( P("set")!=0 && zMime && zMime[0] && szImg>0 ){
1336 Blob img;
1337 Stmt ins;
1338 blob_init(&img, aImg, szImg);
1339 db_prepare(&ins,
1340 "REPLACE INTO config(name,value,mtime)"
1341 " VALUES('logo-image',:bytes,now())"
1342 );
1343 db_bind_blob(&ins, ":bytes", &img);
1344 db_step(&ins);
1345 db_finalize(&ins);
1346 db_multi_exec(
1347 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1348 zMime
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1349 );
1350 db_end_transaction(0);
1351 cgi_redirect("setup_logo");
1352 }else if( P("clr")!=0 ){
1353 db_multi_exec(
1354 "DELETE FROM config WHERE name GLOB 'logo-*'"
 
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }
1359 style_header("Edit Project Logo");
1360 @ <p>The current project logo has a MIME-Type of <b>%h(zMime)</b> and looks
1361 @ like this:</p>
1362 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" /></p></blockquote>
 
1363 @
 
 
1364 @ <p>The logo is accessible to all users at this URL:
1365 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1366 @ The logo may or may not appear on each
1367 @ page depending on the <a href="setup_editcss">CSS</a> and
1368 @ <a href="setup_header">header setup</a>.</p>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1369 @
1370 @ <form action="%s(g.zTop)/setup_logo" method="post"
1371 @ enctype="multipart/form-data"><div>
1372 @ <p>To set a new logo image, select a file to use as the logo using
1373 @ the entry box below and then press the "Change Logo" button.</p>
 
 
 
 
1374 login_insert_csrf_secret();
1375 @ Logo Image file:
1376 @ <input type="file" name="im" size="60" accept="image/*" /><br />
1377 @ <input type="submit" name="set" value="Change Logo" />
1378 @ <input type="submit" name="clr" value="Revert To Default" />
 
1379 @ </div></form>
 
1380 @
1381 @ <p><span class="note">Note:</span> Your browser has probably cached the
1382 @ logo image, so you will probably need to press the Reload button on your
1383 @ browser after changing the logo to provoke your browser to reload the new
1384 @ logo image. </p>
1385 style_footer();
1386 db_end_transaction(0);
1387 }
1388
1389 /*
1390 * vim:ts=2:sts=2:et:sw=2:ft=c
1391 */
1392
1393
--- src/setup.c
+++ src/setup.c
@@ -84,11 +84,11 @@
84 setup_menu_entry("Header", "setup_header",
85 "Edit HTML text inserted at the top of every page");
86 setup_menu_entry("Footer", "setup_footer",
87 "Edit HTML text inserted at the bottom of every page");
88 setup_menu_entry("Logo", "setup_logo",
89 "Change the logo and background images for the server");
90 setup_menu_entry("Shunned", "shun",
91 "Show artifacts that are shunned by this repository");
92 setup_menu_entry("Log", "rcvfromlist",
93 "A record of received artifacts and their sources");
94 setup_menu_entry("User-Log", "access_log",
@@ -1319,74 +1319,128 @@
1319
1320 /*
1321 ** WEBPAGE: setup_logo
1322 */
1323 void setup_logo(void){
1324 const char *zLogoMime = db_get("logo-mimetype","image/gif");
1325 const char *aLogoImg = P("logoim");
1326 int szLogoImg = atoi(PD("logoim:bytes","0"));
1327 const char *zBgMime = db_get("background-mimetype","image/gif");
1328 const char *aBgImg = P("bgim");
1329 int szBgImg = atoi(PD("bgim:bytes","0"));
1330 if( szLogoImg>0 ){
1331 zLogoMime = PD("logoim:mimetype","image/gif");
1332 }
1333 if( szBgImg>0 ){
1334 zBgMime = PD("bgim:mimetype","image/gif");
1335 }
1336 login_check_credentials();
1337 if( !g.perm.Setup ){
1338 login_needed();
1339 }
1340 db_begin_transaction();
1341 if( P("setlogo")!=0 && zLogoMime && zLogoMime[0] && szLogoImg>0 ){
1342 Blob img;
1343 Stmt ins;
1344 blob_init(&img, aLogoImg, szLogoImg);
1345 db_prepare(&ins,
1346 "REPLACE INTO config(name,value,mtime)"
1347 " VALUES('logo-image',:bytes,now())"
1348 );
1349 db_bind_blob(&ins, ":bytes", &img);
1350 db_step(&ins);
1351 db_finalize(&ins);
1352 db_multi_exec(
1353 "REPLACE INTO config(name,value,mtime) VALUES('logo-mimetype',%Q,now())",
1354 zLogoMime
1355 );
1356 db_end_transaction(0);
1357 cgi_redirect("setup_logo");
1358 }else if( P("clrlogo")!=0 ){
1359 db_multi_exec(
1360 "DELETE FROM config WHERE name IN "
1361 "('logo-image','logo-mimetype')"
1362 );
1363 db_end_transaction(0);
1364 cgi_redirect("setup_logo");
1365 }else if( P("setbg")!=0 && zBgMime && zBgMime[0] && szBgImg>0 ){
1366 Blob img;
1367 Stmt ins;
1368 blob_init(&img, aBgImg, szBgImg);
1369 db_prepare(&ins,
1370 "REPLACE INTO config(name,value,mtime)"
1371 " VALUES('background-image',:bytes,now())"
1372 );
1373 db_bind_blob(&ins, ":bytes", &img);
1374 db_step(&ins);
1375 db_finalize(&ins);
1376 db_multi_exec(
1377 "REPLACE INTO config(name,value,mtime)"
1378 " VALUES('background-mimetype',%Q,now())",
1379 zBgMime
1380 );
1381 db_end_transaction(0);
1382 cgi_redirect("setup_logo");
1383 }else if( P("clrbg")!=0 ){
1384 db_multi_exec(
1385 "DELETE FROM config WHERE name IN "
1386 "('background-image','background-mimetype')"
1387 );
1388 db_end_transaction(0);
1389 cgi_redirect("setup_logo");
1390 }
1391 style_header("Edit Project Logo And Background");
1392 @ <p>The current project logo has a MIME-Type of <b>%h(zLogoMime)</b>
1393 @ and looks like this:</p>
1394 @ <blockquote><p><img src="%s(g.zTop)/logo" alt="logo" border="1" />
1395 @ </p></blockquote>
1396 @
1397 @ <form action="%s(g.zTop)/setup_logo" method="post"
1398 @ enctype="multipart/form-data"><div>
1399 @ <p>The logo is accessible to all users at this URL:
1400 @ <a href="%s(g.zBaseURL)/logo">%s(g.zBaseURL)/logo</a>.
1401 @ The logo may or may not appear on each
1402 @ page depending on the <a href="setup_editcss">CSS</a> and
1403 @ <a href="setup_header">header setup</a>.
1404 @ To change the logo image, use the following form:</p>
1405 login_insert_csrf_secret();
1406 @ Logo Image file:
1407 @ <input type="file" name="logoim" size="60" accept="image/*" />
1408 @ <p align="center">
1409 @ <input type="submit" name="setlogo" value="Change Logo" />
1410 @ <input type="submit" name="clrlogo" value="Revert To Default" /></p>
1411 @ </div></form>
1412 @ <hr />
1413 @
1414 @ <p>The current background image has a MIME-Type of <b>%h(zBgMime)</b>
1415 @ and looks like this:</p>
1416 @ <blockquote><p><img src="%s(g.zTop)/background" alt="background" border=1 />
1417 @ </p></blockquote>
1418 @
1419 @ <form action="%s(g.zTop)/setup_logo" method="post"
1420 @ enctype="multipart/form-data"><div>
1421 @ <p>The background image is accessible to all users at this URL:
1422 @ <a href="%s(g.zBaseURL)/background">%s(g.zBaseURL)/background</a>.
1423 @ The background image may or may not appear on each
1424 @ page depending on the <a href="setup_editcss">CSS</a> and
1425 @ <a href="setup_header">header setup</a>.
1426 @ To change the background image, use the following form:</p>
1427 login_insert_csrf_secret();
1428 @ Background image file:
1429 @ <input type="file" name="bgim" size="60" accept="image/*" />
1430 @ <p align="center">
1431 @ <input type="submit" name="setbg" value="Change Background" />
1432 @ <input type="submit" name="clrbg" value="Revert To Default" /></p>
1433 @ </div></form>
1434 @ <hr />
1435 @
1436 @ <p><span class="note">Note:</span> Your browser has probably cached these
1437 @ images, so you may need to press the Reload button before changes will
1438 @ take effect. </p>
 
1439 style_footer();
1440 db_end_transaction(0);
1441 }
1442
1443 /*
1444 * vim:ts=2:sts=2:et:sw=2:ft=c
1445 */
1446
1447
+22 -8
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
6666
6767
#if defined(_WIN32) || defined(WIN32)
6868
# include <io.h>
6969
#define isatty(h) _isatty(h)
7070
#define access(f,m) _access((f),(m))
71
+#define popen(a,b) _popen((a),(b))
72
+#define pclose(x) _pclose(x)
7173
#else
7274
/* Make sure isatty() has a prototype.
7375
*/
7476
extern int isatty(int);
7577
#endif
@@ -1075,10 +1077,13 @@
10751077
fprintf(pArg->out, "Page cache hits: %d\n", iCur);
10761078
iHiwtr = iCur = -1;
10771079
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
10781080
fprintf(pArg->out, "Page cache misses: %d\n", iCur);
10791081
iHiwtr = iCur = -1;
1082
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
1083
+ fprintf(pArg->out, "Page cache writes: %d\n", iCur);
1084
+ iHiwtr = iCur = -1;
10801085
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
10811086
fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
10821087
iHiwtr = iCur = -1;
10831088
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
10841089
fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
12851290
sqlite3_stmt *pTableInfo = 0;
12861291
char *zSelect = 0;
12871292
char *zTableInfo = 0;
12881293
char *zTmp = 0;
12891294
int nRow = 0;
1290
- int kk;
12911295
12921296
zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
12931297
zTableInfo = appendText(zTableInfo, zTable, '"');
12941298
zTableInfo = appendText(zTableInfo, ");", 0);
12951299
@@ -1298,16 +1302,13 @@
12981302
if( rc!=SQLITE_OK || !pTableInfo ){
12991303
return 1;
13001304
}
13011305
13021306
zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1303
- if( !isalpha(zTable[0]) ){
1304
- kk = 0;
1305
- }else{
1306
- for(kk=1; isalnum(zTable[kk]); kk++){}
1307
- }
1308
- zTmp = appendText(zTmp, zTable, zTable[kk] ? '"' : 0);
1307
+ /* Always quote the table name, even if it appears to be pure ascii,
1308
+ ** in case it is a keyword. Ex: INSERT INTO "table" ... */
1309
+ zTmp = appendText(zTmp, zTable, '"');
13091310
if( zTmp ){
13101311
zSelect = appendText(zSelect, zTmp, '\'');
13111312
}
13121313
zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
13131314
rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
19981999
"%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
19992000
}else
20002001
20012002
if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
20022003
if( p->out!=stdout ){
2003
- fclose(p->out);
2004
+ if( p->outfile[0]=='|' ){
2005
+ pclose(p->out);
2006
+ }else{
2007
+ fclose(p->out);
2008
+ }
20042009
}
20052010
if( strcmp(azArg[1],"stdout")==0 ){
20062011
p->out = stdout;
20072012
sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
2013
+ }else if( azArg[1][0]=='|' ){
2014
+ p->out = popen(&azArg[1][1], "w");
2015
+ if( p->out==0 ){
2016
+ fprintf(stderr,"Error: cannot open pipe \"%s\"\n", &azArg[1][1]);
2017
+ p->out = stdout;
2018
+ rc = 1;
2019
+ }else{
2020
+ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]);
2021
+ }
20082022
}else{
20092023
p->out = fopen(azArg[1], "wb");
20102024
if( p->out==0 ){
20112025
fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
20122026
p->out = stdout;
20132027
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
66
67 #if defined(_WIN32) || defined(WIN32)
68 # include <io.h>
69 #define isatty(h) _isatty(h)
70 #define access(f,m) _access((f),(m))
 
 
71 #else
72 /* Make sure isatty() has a prototype.
73 */
74 extern int isatty(int);
75 #endif
@@ -1075,10 +1077,13 @@
1075 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
1076 iHiwtr = iCur = -1;
1077 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
1078 fprintf(pArg->out, "Page cache misses: %d\n", iCur);
1079 iHiwtr = iCur = -1;
 
 
 
1080 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
1081 fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
1082 iHiwtr = iCur = -1;
1083 sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
1084 fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
1285 sqlite3_stmt *pTableInfo = 0;
1286 char *zSelect = 0;
1287 char *zTableInfo = 0;
1288 char *zTmp = 0;
1289 int nRow = 0;
1290 int kk;
1291
1292 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1293 zTableInfo = appendText(zTableInfo, zTable, '"');
1294 zTableInfo = appendText(zTableInfo, ");", 0);
1295
@@ -1298,16 +1302,13 @@
1298 if( rc!=SQLITE_OK || !pTableInfo ){
1299 return 1;
1300 }
1301
1302 zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1303 if( !isalpha(zTable[0]) ){
1304 kk = 0;
1305 }else{
1306 for(kk=1; isalnum(zTable[kk]); kk++){}
1307 }
1308 zTmp = appendText(zTmp, zTable, zTable[kk] ? '"' : 0);
1309 if( zTmp ){
1310 zSelect = appendText(zSelect, zTmp, '\'');
1311 }
1312 zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
1313 rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
1998 "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
1999 }else
2000
2001 if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
2002 if( p->out!=stdout ){
2003 fclose(p->out);
 
 
 
 
2004 }
2005 if( strcmp(azArg[1],"stdout")==0 ){
2006 p->out = stdout;
2007 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
 
 
 
 
 
 
 
 
 
2008 }else{
2009 p->out = fopen(azArg[1], "wb");
2010 if( p->out==0 ){
2011 fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
2012 p->out = stdout;
2013
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
66
67 #if defined(_WIN32) || defined(WIN32)
68 # include <io.h>
69 #define isatty(h) _isatty(h)
70 #define access(f,m) _access((f),(m))
71 #define popen(a,b) _popen((a),(b))
72 #define pclose(x) _pclose(x)
73 #else
74 /* Make sure isatty() has a prototype.
75 */
76 extern int isatty(int);
77 #endif
@@ -1075,10 +1077,13 @@
1077 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
1078 iHiwtr = iCur = -1;
1079 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
1080 fprintf(pArg->out, "Page cache misses: %d\n", iCur);
1081 iHiwtr = iCur = -1;
1082 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
1083 fprintf(pArg->out, "Page cache writes: %d\n", iCur);
1084 iHiwtr = iCur = -1;
1085 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
1086 fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
1087 iHiwtr = iCur = -1;
1088 sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
1089 fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
1290 sqlite3_stmt *pTableInfo = 0;
1291 char *zSelect = 0;
1292 char *zTableInfo = 0;
1293 char *zTmp = 0;
1294 int nRow = 0;
 
1295
1296 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1297 zTableInfo = appendText(zTableInfo, zTable, '"');
1298 zTableInfo = appendText(zTableInfo, ");", 0);
1299
@@ -1298,16 +1302,13 @@
1302 if( rc!=SQLITE_OK || !pTableInfo ){
1303 return 1;
1304 }
1305
1306 zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1307 /* Always quote the table name, even if it appears to be pure ascii,
1308 ** in case it is a keyword. Ex: INSERT INTO "table" ... */
1309 zTmp = appendText(zTmp, zTable, '"');
 
 
 
1310 if( zTmp ){
1311 zSelect = appendText(zSelect, zTmp, '\'');
1312 }
1313 zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
1314 rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
1999 "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
2000 }else
2001
2002 if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
2003 if( p->out!=stdout ){
2004 if( p->outfile[0]=='|' ){
2005 pclose(p->out);
2006 }else{
2007 fclose(p->out);
2008 }
2009 }
2010 if( strcmp(azArg[1],"stdout")==0 ){
2011 p->out = stdout;
2012 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
2013 }else if( azArg[1][0]=='|' ){
2014 p->out = popen(&azArg[1][1], "w");
2015 if( p->out==0 ){
2016 fprintf(stderr,"Error: cannot open pipe \"%s\"\n", &azArg[1][1]);
2017 p->out = stdout;
2018 rc = 1;
2019 }else{
2020 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]);
2021 }
2022 }else{
2023 p->out = fopen(azArg[1], "wb");
2024 if( p->out==0 ){
2025 fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
2026 p->out = stdout;
2027
+22 -8
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
6666
6767
#if defined(_WIN32) || defined(WIN32)
6868
# include <io.h>
6969
#define isatty(h) _isatty(h)
7070
#define access(f,m) _access((f),(m))
71
+#define popen(a,b) _popen((a),(b))
72
+#define pclose(x) _pclose(x)
7173
#else
7274
/* Make sure isatty() has a prototype.
7375
*/
7476
extern int isatty(int);
7577
#endif
@@ -1075,10 +1077,13 @@
10751077
fprintf(pArg->out, "Page cache hits: %d\n", iCur);
10761078
iHiwtr = iCur = -1;
10771079
sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
10781080
fprintf(pArg->out, "Page cache misses: %d\n", iCur);
10791081
iHiwtr = iCur = -1;
1082
+ sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
1083
+ fprintf(pArg->out, "Page cache writes: %d\n", iCur);
1084
+ iHiwtr = iCur = -1;
10801085
sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
10811086
fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
10821087
iHiwtr = iCur = -1;
10831088
sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
10841089
fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
12851290
sqlite3_stmt *pTableInfo = 0;
12861291
char *zSelect = 0;
12871292
char *zTableInfo = 0;
12881293
char *zTmp = 0;
12891294
int nRow = 0;
1290
- int kk;
12911295
12921296
zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
12931297
zTableInfo = appendText(zTableInfo, zTable, '"');
12941298
zTableInfo = appendText(zTableInfo, ");", 0);
12951299
@@ -1298,16 +1302,13 @@
12981302
if( rc!=SQLITE_OK || !pTableInfo ){
12991303
return 1;
13001304
}
13011305
13021306
zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1303
- if( !isalpha(zTable[0]) ){
1304
- kk = 0;
1305
- }else{
1306
- for(kk=1; isalnum(zTable[kk]); kk++){}
1307
- }
1308
- zTmp = appendText(zTmp, zTable, zTable[kk] ? '"' : 0);
1307
+ /* Always quote the table name, even if it appears to be pure ascii,
1308
+ ** in case it is a keyword. Ex: INSERT INTO "table" ... */
1309
+ zTmp = appendText(zTmp, zTable, '"');
13091310
if( zTmp ){
13101311
zSelect = appendText(zSelect, zTmp, '\'');
13111312
}
13121313
zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
13131314
rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
19981999
"%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
19992000
}else
20002001
20012002
if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
20022003
if( p->out!=stdout ){
2003
- fclose(p->out);
2004
+ if( p->outfile[0]=='|' ){
2005
+ pclose(p->out);
2006
+ }else{
2007
+ fclose(p->out);
2008
+ }
20042009
}
20052010
if( strcmp(azArg[1],"stdout")==0 ){
20062011
p->out = stdout;
20072012
sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
2013
+ }else if( azArg[1][0]=='|' ){
2014
+ p->out = popen(&azArg[1][1], "w");
2015
+ if( p->out==0 ){
2016
+ fprintf(stderr,"Error: cannot open pipe \"%s\"\n", &azArg[1][1]);
2017
+ p->out = stdout;
2018
+ rc = 1;
2019
+ }else{
2020
+ sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]);
2021
+ }
20082022
}else{
20092023
p->out = fopen(azArg[1], "wb");
20102024
if( p->out==0 ){
20112025
fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
20122026
p->out = stdout;
20132027
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
66
67 #if defined(_WIN32) || defined(WIN32)
68 # include <io.h>
69 #define isatty(h) _isatty(h)
70 #define access(f,m) _access((f),(m))
 
 
71 #else
72 /* Make sure isatty() has a prototype.
73 */
74 extern int isatty(int);
75 #endif
@@ -1075,10 +1077,13 @@
1075 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
1076 iHiwtr = iCur = -1;
1077 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
1078 fprintf(pArg->out, "Page cache misses: %d\n", iCur);
1079 iHiwtr = iCur = -1;
 
 
 
1080 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
1081 fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
1082 iHiwtr = iCur = -1;
1083 sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
1084 fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
1285 sqlite3_stmt *pTableInfo = 0;
1286 char *zSelect = 0;
1287 char *zTableInfo = 0;
1288 char *zTmp = 0;
1289 int nRow = 0;
1290 int kk;
1291
1292 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1293 zTableInfo = appendText(zTableInfo, zTable, '"');
1294 zTableInfo = appendText(zTableInfo, ");", 0);
1295
@@ -1298,16 +1302,13 @@
1298 if( rc!=SQLITE_OK || !pTableInfo ){
1299 return 1;
1300 }
1301
1302 zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1303 if( !isalpha(zTable[0]) ){
1304 kk = 0;
1305 }else{
1306 for(kk=1; isalnum(zTable[kk]); kk++){}
1307 }
1308 zTmp = appendText(zTmp, zTable, zTable[kk] ? '"' : 0);
1309 if( zTmp ){
1310 zSelect = appendText(zSelect, zTmp, '\'');
1311 }
1312 zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
1313 rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
1998 "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
1999 }else
2000
2001 if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
2002 if( p->out!=stdout ){
2003 fclose(p->out);
 
 
 
 
2004 }
2005 if( strcmp(azArg[1],"stdout")==0 ){
2006 p->out = stdout;
2007 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
 
 
 
 
 
 
 
 
 
2008 }else{
2009 p->out = fopen(azArg[1], "wb");
2010 if( p->out==0 ){
2011 fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
2012 p->out = stdout;
2013
--- src/shell.c
+++ src/shell.c
@@ -66,10 +66,12 @@
66
67 #if defined(_WIN32) || defined(WIN32)
68 # include <io.h>
69 #define isatty(h) _isatty(h)
70 #define access(f,m) _access((f),(m))
71 #define popen(a,b) _popen((a),(b))
72 #define pclose(x) _pclose(x)
73 #else
74 /* Make sure isatty() has a prototype.
75 */
76 extern int isatty(int);
77 #endif
@@ -1075,10 +1077,13 @@
1077 fprintf(pArg->out, "Page cache hits: %d\n", iCur);
1078 iHiwtr = iCur = -1;
1079 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_MISS, &iCur, &iHiwtr, 1);
1080 fprintf(pArg->out, "Page cache misses: %d\n", iCur);
1081 iHiwtr = iCur = -1;
1082 sqlite3_db_status(db, SQLITE_DBSTATUS_CACHE_WRITE, &iCur, &iHiwtr, 1);
1083 fprintf(pArg->out, "Page cache writes: %d\n", iCur);
1084 iHiwtr = iCur = -1;
1085 sqlite3_db_status(db, SQLITE_DBSTATUS_SCHEMA_USED, &iCur, &iHiwtr, bReset);
1086 fprintf(pArg->out, "Schema Heap Usage: %d bytes\n", iCur);
1087 iHiwtr = iCur = -1;
1088 sqlite3_db_status(db, SQLITE_DBSTATUS_STMT_USED, &iCur, &iHiwtr, bReset);
1089 fprintf(pArg->out, "Statement Heap/Lookaside Usage: %d bytes\n", iCur);
@@ -1285,11 +1290,10 @@
1290 sqlite3_stmt *pTableInfo = 0;
1291 char *zSelect = 0;
1292 char *zTableInfo = 0;
1293 char *zTmp = 0;
1294 int nRow = 0;
 
1295
1296 zTableInfo = appendText(zTableInfo, "PRAGMA table_info(", 0);
1297 zTableInfo = appendText(zTableInfo, zTable, '"');
1298 zTableInfo = appendText(zTableInfo, ");", 0);
1299
@@ -1298,16 +1302,13 @@
1302 if( rc!=SQLITE_OK || !pTableInfo ){
1303 return 1;
1304 }
1305
1306 zSelect = appendText(zSelect, "SELECT 'INSERT INTO ' || ", 0);
1307 /* Always quote the table name, even if it appears to be pure ascii,
1308 ** in case it is a keyword. Ex: INSERT INTO "table" ... */
1309 zTmp = appendText(zTmp, zTable, '"');
 
 
 
1310 if( zTmp ){
1311 zSelect = appendText(zSelect, zTmp, '\'');
1312 }
1313 zSelect = appendText(zSelect, " || ' VALUES(' || ", 0);
1314 rc = sqlite3_step(pTableInfo);
@@ -1998,15 +1999,28 @@
1999 "%.*s", (int)ArraySize(p->nullvalue)-1, azArg[1]);
2000 }else
2001
2002 if( c=='o' && strncmp(azArg[0], "output", n)==0 && nArg==2 ){
2003 if( p->out!=stdout ){
2004 if( p->outfile[0]=='|' ){
2005 pclose(p->out);
2006 }else{
2007 fclose(p->out);
2008 }
2009 }
2010 if( strcmp(azArg[1],"stdout")==0 ){
2011 p->out = stdout;
2012 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "stdout");
2013 }else if( azArg[1][0]=='|' ){
2014 p->out = popen(&azArg[1][1], "w");
2015 if( p->out==0 ){
2016 fprintf(stderr,"Error: cannot open pipe \"%s\"\n", &azArg[1][1]);
2017 p->out = stdout;
2018 rc = 1;
2019 }else{
2020 sqlite3_snprintf(sizeof(p->outfile), p->outfile, "%s", azArg[1]);
2021 }
2022 }else{
2023 p->out = fopen(azArg[1], "wb");
2024 if( p->out==0 ){
2025 fprintf(stderr,"Error: cannot write to \"%s\"\n", azArg[1]);
2026 p->out = stdout;
2027
+3292 -1165
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.7.11. By combining all the individual C code files into this
3
+** version 3.7.12. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -655,13 +655,13 @@
655655
**
656656
** See also: [sqlite3_libversion()],
657657
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658658
** [sqlite_version()] and [sqlite_source_id()].
659659
*/
660
-#define SQLITE_VERSION "3.7.11"
661
-#define SQLITE_VERSION_NUMBER 3007011
662
-#define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
660
+#define SQLITE_VERSION "3.7.12"
661
+#define SQLITE_VERSION_NUMBER 3007012
662
+#define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
663663
664664
/*
665665
** CAPI3REF: Run-Time Library Version Numbers
666666
** KEYWORDS: sqlite3_version, sqlite3_sourceid
667667
**
@@ -6554,10 +6554,21 @@
65546554
** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
65556555
** <dd>This parameter returns the number of pager cache misses that have
65566556
** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
65576557
** is always 0.
65586558
** </dd>
6559
+**
6560
+** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6561
+** <dd>This parameter returns the number of dirty cache entries that have
6562
+** been written to disk. Specifically, the number of pages written to the
6563
+** wal file in wal mode databases, or the number of pages written to the
6564
+** database file in rollback mode databases. Any pages written as part of
6565
+** transaction rollback or database recovery operations are not included.
6566
+** If an IO or other error occurs while writing a page to disk, the effect
6567
+** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6568
+** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6569
+** </dd>
65596570
** </dl>
65606571
*/
65616572
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
65626573
#define SQLITE_DBSTATUS_CACHE_USED 1
65636574
#define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
65656576
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
65666577
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
65676578
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
65686579
#define SQLITE_DBSTATUS_CACHE_HIT 7
65696580
#define SQLITE_DBSTATUS_CACHE_MISS 8
6570
-#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
6581
+#define SQLITE_DBSTATUS_CACHE_WRITE 9
6582
+#define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
65716583
65726584
65736585
/*
65746586
** CAPI3REF: Prepared Statement Status
65756587
**
@@ -9919,18 +9931,22 @@
99199931
void (*xDestroy)(void *);
99209932
void *pUserData;
99219933
};
99229934
99239935
/*
9924
-** Possible values for FuncDef.flags
9936
+** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF
9937
+** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There
9938
+** are assert() statements in the code to verify this.
99259939
*/
99269940
#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
99279941
#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
99289942
#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
99299943
#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9930
-#define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */
9931
-#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
9944
+#define SQLITE_FUNC_COUNT 0x10 /* Built-in count(*) aggregate */
9945
+#define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */
9946
+#define SQLITE_FUNC_LENGTH 0x40 /* Built-in length() function */
9947
+#define SQLITE_FUNC_TYPEOF 0x80 /* Built-in typeof() function */
99329948
99339949
/*
99349950
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
99359951
** used to create the initializers for the FuncDef structures.
99369952
**
@@ -9954,11 +9970,14 @@
99549970
** available as the function user-data (sqlite3_user_data()). The
99559971
** FuncDef.flags variable is set to the value passed as the flags
99569972
** parameter.
99579973
*/
99589974
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9959
- {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9975
+ {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \
9976
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9977
+#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
9978
+ {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
99609979
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
99619980
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
99629981
{nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
99639982
pArg, 0, xFunc, 0, 0, #zName, 0, 0}
99649983
#define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
1018410203
u8 tabFlags; /* Mask of TF_* values */
1018510204
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
1018610205
FKey *pFKey; /* Linked list of all foreign keys in this table */
1018710206
char *zColAff; /* String defining the affinity of each column */
1018810207
#ifndef SQLITE_OMIT_CHECK
10189
- Expr *pCheck; /* The AND of all CHECK constraints */
10208
+ ExprList *pCheck; /* All CHECK constraints */
1019010209
#endif
1019110210
#ifndef SQLITE_OMIT_ALTERTABLE
1019210211
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
1019310212
#endif
1019410213
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
1057710596
** TK_VARIABLE: variable number (always >= 1). */
1057810597
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
1057910598
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
1058010599
u8 flags2; /* Second set of flags. EP2_... */
1058110600
u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
10601
+ /* If TK_COLUMN, the value of p5 for OP_Column */
1058210602
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1058310603
Table *pTab; /* Table for TK_COLUMN expressions. */
1058410604
#if SQLITE_MAX_EXPR_DEPTH>0
1058510605
int nHeight; /* Height of the tree headed by this node */
1058610606
#endif
@@ -10599,11 +10619,11 @@
1059910619
#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
1060010620
#define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
1060110621
#define EP_FixedDest 0x0200 /* Result needed in a specific register */
1060210622
#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
1060310623
#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10604
-#define EP_Hint 0x1000 /* Optimizer hint. Not required for correctness */
10624
+#define EP_Hint 0x1000 /* Not used */
1060510625
#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
1060610626
#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
1060710627
#define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
1060810628
1060910629
/*
@@ -11118,10 +11138,11 @@
1111811138
int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
1111911139
int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
1112011140
int regRowid; /* Register holding rowid of CREATE TABLE entry */
1112111141
int regRoot; /* Register holding root page number for new objects */
1112211142
int nMaxArg; /* Max args passed to user function by sub-program */
11143
+ Token constraintName;/* Name of the constraint currently being parsed */
1112311144
#ifndef SQLITE_OMIT_SHARED_CACHE
1112411145
int nTableLock; /* Number of locks in aTableLock */
1112511146
TableLock *aTableLock; /* Required table locks for shared-cache mode */
1112611147
#endif
1112711148
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
1118611207
const char *zAuthContext; /* Put saved Parse.zAuthContext here */
1118711208
Parse *pParse; /* The Parse structure */
1118811209
};
1118911210
1119011211
/*
11191
-** Bitfield flags for P5 value in OP_Insert and OP_Delete
11212
+** Bitfield flags for P5 value in various opcodes.
1119211213
*/
1119311214
#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
1119411215
#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
1119511216
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
1119611217
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
1119711218
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
1119811219
#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
11220
+#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
11221
+#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
1119911222
1120011223
/*
1120111224
* Each trigger present in the database schema is stored as an instance of
1120211225
* struct Trigger.
1120311226
*
@@ -11677,11 +11700,11 @@
1167711700
#endif
1167811701
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
1167911702
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
1168011703
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
1168111704
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11682
-SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
11705
+SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
1168311706
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
1168411707
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
1168511708
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
1168611709
SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
1168711710
SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
1350913532
** Set *pCurrent to the total cache hits or misses encountered by all
1351013533
** pagers the database handle is connected to. *pHighwater is always set
1351113534
** to zero.
1351213535
*/
1351313536
case SQLITE_DBSTATUS_CACHE_HIT:
13514
- case SQLITE_DBSTATUS_CACHE_MISS: {
13537
+ case SQLITE_DBSTATUS_CACHE_MISS:
13538
+ case SQLITE_DBSTATUS_CACHE_WRITE:{
1351513539
int i;
1351613540
int nRet = 0;
1351713541
assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
13542
+ assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );
1351813543
1351913544
for(i=0; i<db->nDb; i++){
1352013545
if( db->aDb[i].pBt ){
1352113546
Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
1352213547
sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
2125921284
2126021285
/*
2126121286
** Some systems have stricmp(). Others have strcasecmp(). Because
2126221287
** there is no consistency, we will define our own.
2126321288
**
21264
-** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows
21265
-** applications and extensions to compare the contents of two buffers
21266
-** containing UTF-8 strings in a case-independent fashion, using the same
21267
-** definition of case independence that SQLite uses internally when
21268
-** comparing identifiers.
21289
+** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
21290
+** sqlite3_strnicmp() APIs allow applications and extensions to compare
21291
+** the contents of two buffers containing UTF-8 strings in a
21292
+** case-independent fashion, using the same definition of "case
21293
+** independence" that SQLite uses internally when comparing identifiers.
2126921294
*/
2127021295
SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
2127121296
register unsigned char *a, *b;
2127221297
a = (unsigned char *)zLeft;
2127321298
b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
3372733752
}
3372833753
sqlite3_free(pFile->zDeleteOnClose);
3372933754
}
3373033755
#endif
3373133756
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
33757
+ if( rc ){
33758
+ pFile->h = NULL;
33759
+ }
3373233760
OpenCounter(-1);
3373333761
return rc ? SQLITE_OK
3373433762
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
3373533763
"winClose", pFile->zPath);
3373633764
}
@@ -33744,22 +33772,33 @@
3374433772
sqlite3_file *id, /* File to read from */
3374533773
void *pBuf, /* Write content into this buffer */
3374633774
int amt, /* Number of bytes to read */
3374733775
sqlite3_int64 offset /* Begin reading at this offset */
3374833776
){
33777
+#if !SQLITE_OS_WINCE
33778
+ OVERLAPPED overlapped; /* The offset for ReadFile. */
33779
+#endif
3374933780
winFile *pFile = (winFile*)id; /* file handle */
3375033781
DWORD nRead; /* Number of bytes actually read from file */
3375133782
int nRetry = 0; /* Number of retrys */
3375233783
3375333784
assert( id!=0 );
3375433785
SimulateIOError(return SQLITE_IOERR_READ);
3375533786
OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
3375633787
33788
+#if SQLITE_OS_WINCE
3375733789
if( seekWinFile(pFile, offset) ){
3375833790
return SQLITE_FULL;
3375933791
}
3376033792
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
33793
+#else
33794
+ memset(&overlapped, 0, sizeof(OVERLAPPED));
33795
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33796
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33797
+ while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
33798
+ osGetLastError()!=ERROR_HANDLE_EOF ){
33799
+#endif
3376133800
DWORD lastErrno;
3376233801
if( retryIoerr(&nRetry, &lastErrno) ) continue;
3376333802
pFile->lastErrno = lastErrno;
3376433803
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
3376533804
"winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
3378233821
sqlite3_file *id, /* File to write into */
3378333822
const void *pBuf, /* The bytes to be written */
3378433823
int amt, /* Number of bytes to write */
3378533824
sqlite3_int64 offset /* Offset into the file to begin writing at */
3378633825
){
33787
- int rc; /* True if error has occured, else false */
33826
+ int rc = 0; /* True if error has occured, else false */
3378833827
winFile *pFile = (winFile*)id; /* File handle */
3378933828
int nRetry = 0; /* Number of retries */
3379033829
3379133830
assert( amt>0 );
3379233831
assert( pFile );
@@ -33793,23 +33832,48 @@
3379333832
SimulateIOError(return SQLITE_IOERR_WRITE);
3379433833
SimulateDiskfullError(return SQLITE_FULL);
3379533834
3379633835
OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
3379733836
33837
+#if SQLITE_OS_WINCE
3379833838
rc = seekWinFile(pFile, offset);
3379933839
if( rc==0 ){
33840
+#else
33841
+ {
33842
+#endif
33843
+#if !SQLITE_OS_WINCE
33844
+ OVERLAPPED overlapped; /* The offset for WriteFile. */
33845
+#endif
3380033846
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
3380133847
int nRem = amt; /* Number of bytes yet to be written */
3380233848
DWORD nWrite; /* Bytes written by each WriteFile() call */
3380333849
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
33850
+
33851
+#if !SQLITE_OS_WINCE
33852
+ memset(&overlapped, 0, sizeof(OVERLAPPED));
33853
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33854
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33855
+#endif
3380433856
3380533857
while( nRem>0 ){
33858
+#if SQLITE_OS_WINCE
3380633859
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
33860
+#else
33861
+ if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
33862
+#endif
3380733863
if( retryIoerr(&nRetry, &lastErrno) ) continue;
3380833864
break;
3380933865
}
33810
- if( nWrite<=0 ) break;
33866
+ if( nWrite<=0 ){
33867
+ lastErrno = osGetLastError();
33868
+ break;
33869
+ }
33870
+#if !SQLITE_OS_WINCE
33871
+ offset += nWrite;
33872
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33873
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33874
+#endif
3381133875
aRem += nWrite;
3381233876
nRem -= nWrite;
3381333877
}
3381433878
if( nRem>0 ){
3381533879
pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
3909439158
i64 journalSizeLimit; /* Size limit for persistent journal files */
3909539159
char *zFilename; /* Name of the database file */
3909639160
char *zJournal; /* Name of the journal file */
3909739161
int (*xBusyHandler)(void*); /* Function to call when busy */
3909839162
void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39099
- int nHit, nMiss; /* Total cache hits and misses */
39163
+ int aStat[3]; /* Total cache hits, misses and writes */
3910039164
#ifdef SQLITE_TEST
39101
- int nRead, nWrite; /* Database pages read/written */
39165
+ int nRead; /* Database pages read */
3910239166
#endif
3910339167
void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
3910439168
#ifdef SQLITE_HAS_CODEC
3910539169
void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
3910639170
void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
3911339177
Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
3911439178
char *zWal; /* File name for write-ahead log */
3911539179
#endif
3911639180
};
3911739181
39182
+/*
39183
+** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
39184
+** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS
39185
+** or CACHE_WRITE to sqlite3_db_status().
39186
+*/
39187
+#define PAGER_STAT_HIT 0
39188
+#define PAGER_STAT_MISS 1
39189
+#define PAGER_STAT_WRITE 2
39190
+
3911839191
/*
3911939192
** The following global variables hold counters used for
3912039193
** testing purposes only. These variables do not exist in
3912139194
** a non-testing build. These variables are not thread-safe.
3912239195
*/
@@ -41395,10 +41468,11 @@
4139541468
PgHdr *pList, /* List of frames to log */
4139641469
Pgno nTruncate, /* Database size after this commit */
4139741470
int isCommit /* True if this is a commit */
4139841471
){
4139941472
int rc; /* Return code */
41473
+ int nList; /* Number of pages in pList */
4140041474
#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
4140141475
PgHdr *p; /* For looping over pages */
4140241476
#endif
4140341477
4140441478
assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
4140841482
for(p=pList; p && p->pDirty; p=p->pDirty){
4140941483
assert( p->pgno < p->pDirty->pgno );
4141041484
}
4141141485
#endif
4141241486
41487
+ assert( pList->pDirty==0 || isCommit );
4141341488
if( isCommit ){
4141441489
/* If a WAL transaction is being committed, there is no point in writing
4141541490
** any pages with page numbers greater than nTruncate into the WAL file.
4141641491
** They will never be read by any client. So remove them from the pDirty
4141741492
** list here. */
4141841493
PgHdr *p;
4141941494
PgHdr **ppNext = &pList;
41495
+ nList = 0;
4142041496
for(p=pList; (*ppNext = p); p=p->pDirty){
41421
- if( p->pgno<=nTruncate ) ppNext = &p->pDirty;
41497
+ if( p->pgno<=nTruncate ){
41498
+ ppNext = &p->pDirty;
41499
+ nList++;
41500
+ }
4142241501
}
4142341502
assert( pList );
41503
+ }else{
41504
+ nList = 1;
4142441505
}
41506
+ pPager->aStat[PAGER_STAT_WRITE] += nList;
4142541507
4142641508
if( pList->pgno==1 ) pager_write_changecounter(pList);
4142741509
rc = sqlite3WalFrames(pPager->pWal,
4142841510
pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
4142941511
);
@@ -42487,19 +42569,19 @@
4248742569
memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
4248842570
}
4248942571
if( pgno>pPager->dbFileSize ){
4249042572
pPager->dbFileSize = pgno;
4249142573
}
42574
+ pPager->aStat[PAGER_STAT_WRITE]++;
4249242575
4249342576
/* Update any backup objects copying the contents of this pager. */
4249442577
sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
4249542578
4249642579
PAGERTRACE(("STORE %d page %d hash(%08x)\n",
4249742580
PAGERID(pPager), pgno, pager_pagehash(pList)));
4249842581
IOTRACE(("PGOUT %p %d\n", pPager, pgno));
4249942582
PAGER_INCR(sqlite3_pager_writedb_count);
42500
- PAGER_INCR(pPager->nWrite);
4250142583
}else{
4250242584
PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
4250342585
}
4250442586
pager_set_pagehash(pList);
4250542587
pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
4345343535
4345443536
if( (*ppPage)->pPager && !noContent ){
4345543537
/* In this case the pcache already contains an initialized copy of
4345643538
** the page. Return without further ado. */
4345743539
assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43458
- pPager->nHit++;
43540
+ pPager->aStat[PAGER_STAT_HIT]++;
4345943541
return SQLITE_OK;
4346043542
4346143543
}else{
4346243544
/* The pager cache has created a new page. Its content needs to
4346343545
** be initialized. */
@@ -43495,11 +43577,11 @@
4349543577
}
4349643578
memset(pPg->pData, 0, pPager->pageSize);
4349743579
IOTRACE(("ZERO %p %d\n", pPager, pgno));
4349843580
}else{
4349943581
assert( pPg->pPager==pPager );
43500
- pPager->nMiss++;
43582
+ pPager->aStat[PAGER_STAT_MISS]++;
4350143583
rc = readDbPage(pPg);
4350243584
if( rc!=SQLITE_OK ){
4350343585
goto pager_acquire_err;
4350443586
}
4350543587
}
@@ -44080,10 +44162,11 @@
4408044162
const void *zBuf;
4408144163
assert( pPager->dbFileSize>0 );
4408244164
CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
4408344165
if( rc==SQLITE_OK ){
4408444166
rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
44167
+ pPager->aStat[PAGER_STAT_WRITE]++;
4408544168
}
4408644169
if( rc==SQLITE_OK ){
4408744170
pPager->changeCountDone = 1;
4408844171
}
4408944172
}else{
@@ -44523,15 +44606,15 @@
4452344606
a[1] = sqlite3PcachePagecount(pPager->pPCache);
4452444607
a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
4452544608
a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
4452644609
a[4] = pPager->eState;
4452744610
a[5] = pPager->errCode;
44528
- a[6] = pPager->nHit;
44529
- a[7] = pPager->nMiss;
44611
+ a[6] = pPager->aStat[PAGER_STAT_HIT];
44612
+ a[7] = pPager->aStat[PAGER_STAT_MISS];
4453044613
a[8] = 0; /* Used to be pPager->nOvfl */
4453144614
a[9] = pPager->nRead;
44532
- a[10] = pPager->nWrite;
44615
+ a[10] = pPager->aStat[PAGER_STAT_WRITE];
4453344616
return a;
4453444617
}
4453544618
#endif
4453644619
4453744620
/*
@@ -44540,24 +44623,23 @@
4454044623
** current cache hit or miss count, according to the value of eStat. If the
4454144624
** reset parameter is non-zero, the cache hit or miss count is zeroed before
4454244625
** returning.
4454344626
*/
4454444627
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
44545
- int *piStat;
4454644628
4454744629
assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
4454844630
|| eStat==SQLITE_DBSTATUS_CACHE_MISS
44631
+ || eStat==SQLITE_DBSTATUS_CACHE_WRITE
4454944632
);
44550
- if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){
44551
- piStat = &pPager->nHit;
44552
- }else{
44553
- piStat = &pPager->nMiss;
44554
- }
4455544633
44556
- *pnVal += *piStat;
44634
+ assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );
44635
+ assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );
44636
+ assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );
44637
+
44638
+ *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];
4455744639
if( reset ){
44558
- *piStat = 0;
44640
+ pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;
4455944641
}
4456044642
}
4456144643
4456244644
/*
4456344645
** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
5615156233
** keys with no associated data. If the cursor was opened expecting an
5615256234
** intkey table, the caller should be inserting integer keys with a
5615356235
** blob of associated data. */
5615456236
assert( (pKey==0)==(pCur->pKeyInfo==0) );
5615556237
56156
- /* If this is an insert into a table b-tree, invalidate any incrblob
56157
- ** cursors open on the row being replaced (assuming this is a replace
56158
- ** operation - if it is not, the following is a no-op). */
56159
- if( pCur->pKeyInfo==0 ){
56160
- invalidateIncrblobCursors(p, nKey, 0);
56161
- }
56162
-
5616356238
/* Save the positions of any other cursors open on this table.
5616456239
**
5616556240
** In some cases, the call to btreeMoveto() below is a no-op. For
5616656241
** example, when inserting data into a table with auto-generated integer
5616756242
** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
5617156246
** doing any work. To avoid thwarting these optimizations, it is important
5617256247
** not to clear the cursor here.
5617356248
*/
5617456249
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
5617556250
if( rc ) return rc;
56251
+
56252
+ /* If this is an insert into a table b-tree, invalidate any incrblob
56253
+ ** cursors open on the row being replaced (assuming this is a replace
56254
+ ** operation - if it is not, the following is a no-op). */
56255
+ if( pCur->pKeyInfo==0 ){
56256
+ invalidateIncrblobCursors(p, nKey, 0);
56257
+ }
56258
+
5617656259
if( !loc ){
5617756260
rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
5617856261
if( rc ) return rc;
5617956262
}
5618056263
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
5628156364
|| NEVER(pCur->eState!=CURSOR_VALID)
5628256365
){
5628356366
return SQLITE_ERROR; /* Something has gone awry. */
5628456367
}
5628556368
56286
- /* If this is a delete operation to remove a row from a table b-tree,
56287
- ** invalidate any incrblob cursors open on the row being deleted. */
56288
- if( pCur->pKeyInfo==0 ){
56289
- invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56290
- }
56291
-
5629256369
iCellDepth = pCur->iPage;
5629356370
iCellIdx = pCur->aiIdx[iCellDepth];
5629456371
pPage = pCur->apPage[iCellDepth];
5629556372
pCell = findCell(pPage, iCellIdx);
5629656373
@@ -56312,10 +56389,17 @@
5631256389
** deleted writable. Then free any overflow pages associated with the
5631356390
** entry and finally remove the cell itself from within the page.
5631456391
*/
5631556392
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
5631656393
if( rc ) return rc;
56394
+
56395
+ /* If this is a delete operation to remove a row from a table b-tree,
56396
+ ** invalidate any incrblob cursors open on the row being deleted. */
56397
+ if( pCur->pKeyInfo==0 ){
56398
+ invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56399
+ }
56400
+
5631756401
rc = sqlite3PagerWrite(pPage->pDbPage);
5631856402
if( rc ) return rc;
5631956403
rc = clearCell(pPage, pCell);
5632056404
dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
5632156405
if( rc ) return rc;
@@ -56593,17 +56677,17 @@
5659356677
int rc;
5659456678
BtShared *pBt = p->pBt;
5659556679
sqlite3BtreeEnter(p);
5659656680
assert( p->inTrans==TRANS_WRITE );
5659756681
56598
- /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56599
- ** is the root of a table b-tree - if it is not, the following call is
56600
- ** a no-op). */
56601
- invalidateIncrblobCursors(p, 0, 1);
56602
-
5660356682
rc = saveAllCursors(pBt, (Pgno)iTable, 0);
56683
+
5660456684
if( SQLITE_OK==rc ){
56685
+ /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56686
+ ** is the root of a table b-tree - if it is not, the following call is
56687
+ ** a no-op). */
56688
+ invalidateIncrblobCursors(p, 0, 1);
5660556689
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
5660656690
}
5660756691
sqlite3BtreeLeave(p);
5660856692
return rc;
5660956693
}
@@ -58411,14 +58495,14 @@
5841158495
5841258496
/*
5841358497
** Make sure pMem->z points to a writable allocation of at least
5841458498
** n bytes.
5841558499
**
58416
-** If the memory cell currently contains string or blob data
58417
-** and the third argument passed to this function is true, the
58418
-** current content of the cell is preserved. Otherwise, it may
58419
-** be discarded.
58500
+** If the third argument passed to this function is true, then memory
58501
+** cell pMem must contain a string or blob. In this case the content is
58502
+** preserved. Otherwise, if the third parameter to this function is false,
58503
+** any current string or blob value may be discarded.
5842058504
**
5842158505
** This function sets the MEM_Dyn flag and clears any xDel callback.
5842258506
** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
5842358507
** not set, Mem.n is zeroed.
5842458508
*/
@@ -58428,10 +58512,14 @@
5842858512
(((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
5842958513
((pMem->flags&MEM_Ephem) ? 1 : 0) +
5843058514
((pMem->flags&MEM_Static) ? 1 : 0)
5843158515
);
5843258516
assert( (pMem->flags&MEM_RowSet)==0 );
58517
+
58518
+ /* If the preserve flag is set to true, then the memory cell must already
58519
+ ** contain a valid string or blob value. */
58520
+ assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
5843358521
5843458522
if( n<32 ) n = 32;
5843558523
if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
5843658524
if( preserve && pMem->z==pMem->zMalloc ){
5843758525
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
6074760835
int nByte = (nSub+1)*sizeof(SubProgram*);
6074860836
int j;
6074960837
for(j=0; j<nSub; j++){
6075060838
if( apSub[j]==pOp->p4.pProgram ) break;
6075160839
}
60752
- if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){
60840
+ if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
6075360841
apSub = (SubProgram **)pSub->z;
6075460842
apSub[nSub++] = pOp->p4.pProgram;
6075560843
pSub->flags |= MEM_Blob;
6075660844
pSub->n = nSub*sizeof(SubProgram*);
6075760845
}
@@ -66996,10 +67084,15 @@
6699667084
**
6699767085
** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
6699867086
** then the cache of the cursor is reset prior to extracting the column.
6699967087
** The first OP_Column against a pseudo-table after the value of the content
6700067088
** register has changed should have this bit set.
67089
+**
67090
+** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when
67091
+** the result is guaranteed to only be used as the argument of a length()
67092
+** or typeof() function, respectively. The loading of large blobs can be
67093
+** skipped for length() and all content loading can be skipped for typeof().
6700167094
*/
6700267095
case OP_Column: {
6700367096
#if 0 /* local variables moved into u.an */
6700467097
u32 payloadSize; /* Number of bytes in the record */
6700567098
i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
6713867231
u.an.pC->aRow = (u8*)u.an.zData;
6713967232
}else{
6714067233
u.an.pC->aRow = 0;
6714167234
}
6714267235
}
67143
- /* The following assert is true in all cases accept when
67236
+ /* The following assert is true in all cases except when
6714467237
** the database file has been corrupted externally.
6714567238
** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
6714667239
u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
6714767240
6714867241
/* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
6721367306
if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
6721467307
u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
6721567308
break;
6721667309
}
6721767310
}else{
67218
- /* If u.an.i is less that u.an.nField, then there are less fields in this
67311
+ /* If u.an.i is less that u.an.nField, then there are fewer fields in this
6721967312
** record than SetNumColumns indicated there are columns in the
6722067313
** table. Set the u.an.offset for any extra columns not present in
67221
- ** the record to 0. This tells code below to store a NULL
67222
- ** instead of deserializing a value from the record.
67314
+ ** the record to 0. This tells code below to store the default value
67315
+ ** for the column instead of deserializing a value from the record.
6722367316
*/
6722467317
u.an.aOffset[u.an.i] = 0;
6722567318
}
6722667319
}
6722767320
sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
6724767340
** a pointer to a Mem object.
6724867341
*/
6724967342
if( u.an.aOffset[u.an.p2] ){
6725067343
assert( rc==SQLITE_OK );
6725167344
if( u.an.zRec ){
67345
+ /* This is the common case where the whole row fits on a single page */
6725267346
VdbeMemRelease(u.an.pDest);
6725367347
sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
6725467348
}else{
67255
- u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67256
- sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67257
- rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67258
- if( rc!=SQLITE_OK ){
67259
- goto op_column_out;
67260
- }
67261
- u.an.zData = u.an.sMem.z;
67262
- sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
67349
+ /* This branch happens only when the row overflows onto multiple pages */
67350
+ u.an.t = u.an.aType[u.an.p2];
67351
+ if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
67352
+ && ((u.an.t>=12 && (u.an.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)
67353
+ ){
67354
+ /* Content is irrelevant for the typeof() function and for
67355
+ ** the length(X) function if X is a blob. So we might as well use
67356
+ ** bogus content rather than reading content from disk. NULL works
67357
+ ** for text and blob and whatever is in the u.an.payloadSize64 variable
67358
+ ** will work for everything else. */
67359
+ u.an.zData = u.an.t<12 ? (char*)&u.an.payloadSize64 : 0;
67360
+ }else{
67361
+ u.an.len = sqlite3VdbeSerialTypeLen(u.an.t);
67362
+ sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67363
+ rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex,
67364
+ &u.an.sMem);
67365
+ if( rc!=SQLITE_OK ){
67366
+ goto op_column_out;
67367
+ }
67368
+ u.an.zData = u.an.sMem.z;
67369
+ }
67370
+ sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.t, u.an.pDest);
6726367371
}
6726467372
u.an.pDest->enc = encoding;
6726567373
}else{
6726667374
if( pOp->p4type==P4_MEM ){
6726767375
sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
6759367701
}
6759467702
db->isTransactionSavepoint = 0;
6759567703
rc = p->rc;
6759667704
}else{
6759767705
u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67598
- for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67599
- sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67706
+ if( u.ar.p1==SAVEPOINT_ROLLBACK ){
67707
+ for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67708
+ sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67709
+ }
6760067710
}
6760167711
for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
6760267712
rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
6760367713
if( rc!=SQLITE_OK ){
6760467714
goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
7487374983
int op, /* Expression opcode */
7487474984
Expr *pLeft, /* Left operand */
7487574985
Expr *pRight, /* Right operand */
7487674986
const Token *pToken /* Argument token */
7487774987
){
74878
- Expr *p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74879
- sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74988
+ Expr *p;
74989
+ if( op==TK_AND && pLeft && pRight ){
74990
+ /* Take advantage of short-circuit false optimization for AND */
74991
+ p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
74992
+ }else{
74993
+ p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74994
+ sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74995
+ }
7488074996
if( p ) {
7488174997
sqlite3ExprCheckHeight(pParse, p->nHeight);
7488274998
}
7488374999
return p;
7488475000
}
75001
+
75002
+/*
75003
+** Return 1 if an expression must be FALSE in all cases and 0 if the
75004
+** expression might be true. This is an optimization. If is OK to
75005
+** return 0 here even if the expression really is always false (a
75006
+** false negative). But it is a bug to return 1 if the expression
75007
+** might be true in some rare circumstances (a false positive.)
75008
+**
75009
+** Note that if the expression is part of conditional for a
75010
+** LEFT JOIN, then we cannot determine at compile-time whether or not
75011
+** is it true or false, so always return 0.
75012
+*/
75013
+static int exprAlwaysFalse(Expr *p){
75014
+ int v = 0;
75015
+ if( ExprHasProperty(p, EP_FromJoin) ) return 0;
75016
+ if( !sqlite3ExprIsInteger(p, &v) ) return 0;
75017
+ return v==0;
75018
+}
7488575019
7488675020
/*
7488775021
** Join two expressions using an AND operator. If either expression is
7488875022
** NULL, then just return the other expression.
75023
+**
75024
+** If one side or the other of the AND is known to be false, then instead
75025
+** of returning an AND expression, just return a constant expression with
75026
+** a value of false.
7488975027
*/
7489075028
SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
7489175029
if( pLeft==0 ){
7489275030
return pRight;
7489375031
}else if( pRight==0 ){
7489475032
return pLeft;
75033
+ }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){
75034
+ sqlite3ExprDelete(db, pLeft);
75035
+ sqlite3ExprDelete(db, pRight);
75036
+ return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);
7489575037
}else{
7489675038
Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
7489775039
sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
7489875040
return pNew;
7489975041
}
@@ -76421,19 +76563,10 @@
7642176563
** Actually, the way the column cache is currently used, we are guaranteed
7642276564
** that the object will never already be in cache. Verify this guarantee.
7642376565
*/
7642476566
#ifndef NDEBUG
7642576567
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
76426
-#if 0 /* This code wold remove the entry from the cache if it existed */
76427
- if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
76428
- cacheEntryClear(pParse, p);
76429
- p->iLevel = pParse->iCacheLevel;
76430
- p->iReg = iReg;
76431
- p->lru = pParse->iCacheCnt++;
76432
- return;
76433
- }
76434
-#endif
7643576568
assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
7643676569
}
7643776570
#endif
7643876571
7643976572
/* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
7656476697
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
7656576698
Parse *pParse, /* Parsing and code generating context */
7656676699
Table *pTab, /* Description of the table we are reading from */
7656776700
int iColumn, /* Index of the table column */
7656876701
int iTable, /* The cursor pointing to the table */
76569
- int iReg /* Store results here */
76702
+ int iReg, /* Store results here */
76703
+ u8 p5 /* P5 value for OP_Column */
7657076704
){
7657176705
Vdbe *v = pParse->pVdbe;
7657276706
int i;
7657376707
struct yColCache *p;
7657476708
@@ -76579,11 +76713,15 @@
7657976713
return p->iReg;
7658076714
}
7658176715
}
7658276716
assert( v!=0 );
7658376717
sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76584
- sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76718
+ if( p5 ){
76719
+ sqlite3VdbeChangeP5(v, p5);
76720
+ }else{
76721
+ sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76722
+ }
7658576723
return iReg;
7658676724
}
7658776725
7658876726
/*
7658976727
** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
7670776845
/* This only happens when coding check constraints */
7670876846
assert( pParse->ckBase>0 );
7670976847
inReg = pExpr->iColumn + pParse->ckBase;
7671076848
}else{
7671176849
inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76712
- pExpr->iColumn, pExpr->iTable, target);
76850
+ pExpr->iColumn, pExpr->iTable, target,
76851
+ pExpr->op2);
7671376852
}
7671476853
break;
7671576854
}
7671676855
case TK_INTEGER: {
7671776856
codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
7698477123
}
7698577124
7698677125
7698777126
if( pFarg ){
7698877127
r1 = sqlite3GetTempRange(pParse, nFarg);
77128
+
77129
+ /* For length() and typeof() functions with a column argument,
77130
+ ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
77131
+ ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
77132
+ ** loading.
77133
+ */
77134
+ if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
77135
+ u8 exprOp;
77136
+ assert( nFarg==1 );
77137
+ assert( pFarg->a[0].pExpr!=0 );
77138
+ exprOp = pFarg->a[0].pExpr->op;
77139
+ if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){
77140
+ assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
77141
+ assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
77142
+ testcase( pDef->flags==SQLITE_FUNC_LENGTH );
77143
+ pFarg->a[0].pExpr->op2 = pDef->flags;
77144
+ }
77145
+ }
77146
+
7698977147
sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
7699077148
sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
7699177149
sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
7699277150
}else{
7699377151
r1 = 0;
@@ -80189,10 +80347,11 @@
8018980347
Index *pPrevIdx = 0; /* Previous index in the loop */
8019080348
int idx = 0; /* slot in pIdx->aSample[] for next sample */
8019180349
int eType; /* Datatype of a sample */
8019280350
IndexSample *pSample; /* A slot in pIdx->aSample[] */
8019380351
80352
+ assert( db->lookaside.bEnabled==0 );
8019480353
if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
8019580354
return SQLITE_OK;
8019680355
}
8019780356
8019880357
zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
8021580374
nSample = sqlite3_column_int(pStmt, 1);
8021680375
pIdx = sqlite3FindIndex(db, zIndex, zDb);
8021780376
if( pIdx==0 ) continue;
8021880377
assert( pIdx->nSample==0 );
8021980378
pIdx->nSample = nSample;
80220
- pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) );
80379
+ pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));
8022180380
pIdx->avgEq = pIdx->aiRowEst[1];
8022280381
if( pIdx->aSample==0 ){
8022380382
db->mallocFailed = 1;
8022480383
sqlite3_finalize(pStmt);
8022580384
return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
8028880447
int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
8028980448
pSample->nByte = n;
8029080449
if( n < 1){
8029180450
pSample->u.z = 0;
8029280451
}else{
80293
- pSample->u.z = sqlite3Malloc(n);
80452
+ pSample->u.z = sqlite3DbMallocRaw(db, n);
8029480453
if( pSample->u.z==0 ){
8029580454
db->mallocFailed = 1;
8029680455
sqlite3_finalize(pStmt);
8029780456
return SQLITE_NOMEM;
8029880457
}
@@ -80364,11 +80523,14 @@
8036480523
8036580524
8036680525
/* Load the statistics from the sqlite_stat3 table. */
8036780526
#ifdef SQLITE_ENABLE_STAT3
8036880527
if( rc==SQLITE_OK ){
80528
+ int lookasideEnabled = db->lookaside.bEnabled;
80529
+ db->lookaside.bEnabled = 0;
8036980530
rc = loadStat3(db, sInfo.zDatabase);
80531
+ db->lookaside.bEnabled = lookasideEnabled;
8037080532
}
8037180533
#endif
8037280534
8037380535
if( rc==SQLITE_NOMEM ){
8037480536
db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
8172781889
sqliteDeleteColumnNames(db, pTable);
8172881890
sqlite3DbFree(db, pTable->zName);
8172981891
sqlite3DbFree(db, pTable->zColAff);
8173081892
sqlite3SelectDelete(db, pTable->pSelect);
8173181893
#ifndef SQLITE_OMIT_CHECK
81732
- sqlite3ExprDelete(db, pTable->pCheck);
81894
+ sqlite3ExprListDelete(db, pTable->pCheck);
8173381895
#endif
8173481896
#ifndef SQLITE_OMIT_VIRTUALTABLE
8173581897
sqlite3VtabClear(db, pTable);
8173681898
#endif
8173781899
sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
8239082552
*/
8239182553
SQLITE_PRIVATE void sqlite3AddCheckConstraint(
8239282554
Parse *pParse, /* Parsing context */
8239382555
Expr *pCheckExpr /* The check expression */
8239482556
){
82395
- sqlite3 *db = pParse->db;
8239682557
#ifndef SQLITE_OMIT_CHECK
8239782558
Table *pTab = pParse->pNewTable;
8239882559
if( pTab && !IN_DECLARE_VTAB ){
82399
- pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, pCheckExpr);
82560
+ pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
82561
+ if( pParse->constraintName.n ){
82562
+ sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
82563
+ }
8240082564
}else
8240182565
#endif
8240282566
{
82403
- sqlite3ExprDelete(db, pCheckExpr);
82567
+ sqlite3ExprDelete(pParse->db, pCheckExpr);
8240482568
}
8240582569
}
8240682570
8240782571
/*
8240882572
** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
8266882832
/* Resolve names in all CHECK constraint expressions.
8266982833
*/
8267082834
if( p->pCheck ){
8267182835
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
8267282836
NameContext sNC; /* Name context for pParse->pNewTable */
82837
+ ExprList *pList; /* List of all CHECK constraints */
82838
+ int i; /* Loop counter */
8267382839
8267482840
memset(&sNC, 0, sizeof(sNC));
8267582841
memset(&sSrc, 0, sizeof(sSrc));
8267682842
sSrc.nSrc = 1;
8267782843
sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
8267882844
sSrc.a[0].pTab = p;
8267982845
sSrc.a[0].iCursor = -1;
8268082846
sNC.pParse = pParse;
8268182847
sNC.pSrcList = &sSrc;
8268282848
sNC.isCheck = 1;
82683
- if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){
82684
- return;
82849
+ pList = p->pCheck;
82850
+ for(i=0; i<pList->nExpr; i++){
82851
+ if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
82852
+ return;
82853
+ }
8268582854
}
8268682855
}
8268782856
#endif /* !defined(SQLITE_OMIT_CHECK) */
8268882857
8268982858
/* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
8423084399
exit_drop_index:
8423184400
sqlite3SrcListDelete(db, pName);
8423284401
}
8423384402
8423484403
/*
84235
-** pArray is a pointer to an array of objects. Each object in the
84236
-** array is szEntry bytes in size. This routine allocates a new
84237
-** object on the end of the array.
84238
-**
84239
-** *pnEntry is the number of entries already in use. *pnAlloc is
84240
-** the previously allocated size of the array. initSize is the
84241
-** suggested initial array size allocation.
84242
-**
84243
-** The index of the new entry is returned in *pIdx.
84244
-**
84245
-** This routine returns a pointer to the array of objects. This
84246
-** might be the same as the pArray parameter or it might be a different
84247
-** pointer if the array was resized.
84404
+** pArray is a pointer to an array of objects. Each object in the
84405
+** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()
84406
+** to extend the array so that there is space for a new object at the end.
84407
+**
84408
+** When this function is called, *pnEntry contains the current size of
84409
+** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes
84410
+** in total).
84411
+**
84412
+** If the realloc() is successful (i.e. if no OOM condition occurs), the
84413
+** space allocated for the new object is zeroed, *pnEntry updated to
84414
+** reflect the new size of the array and a pointer to the new allocation
84415
+** returned. *pIdx is set to the index of the new array entry in this case.
84416
+**
84417
+** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
84418
+** unchanged and a copy of pArray returned.
8424884419
*/
8424984420
SQLITE_PRIVATE void *sqlite3ArrayAllocate(
8425084421
sqlite3 *db, /* Connection to notify of malloc failures */
8425184422
void *pArray, /* Array of objects. Might be reallocated */
8425284423
int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
8583986010
sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
8584086011
pWInfo = sqlite3WhereBegin(
8584186012
pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
8584286013
);
8584386014
if( pWInfo==0 ) goto delete_from_cleanup;
85844
- regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
86015
+ regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
8584586016
sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
8584686017
if( db->flags & SQLITE_CountRows ){
8584786018
sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
8584886019
}
8584986020
sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
8765987830
FUNCTION(min, 0, 0, 1, 0 ),
8766087831
AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
8766187832
FUNCTION(max, -1, 1, 1, minmaxFunc ),
8766287833
FUNCTION(max, 0, 1, 1, 0 ),
8766387834
AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87664
- FUNCTION(typeof, 1, 0, 0, typeofFunc ),
87665
- FUNCTION(length, 1, 0, 0, lengthFunc ),
87835
+ FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
87836
+ FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
8766687837
FUNCTION(substr, 2, 0, 0, substrFunc ),
8766787838
FUNCTION(substr, 3, 0, 0, substrFunc ),
8766887839
FUNCTION(abs, 1, 0, 0, absFunc ),
8766987840
#ifndef SQLITE_OMIT_FLOATING_POINT
8767087841
FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
8767287843
#endif
8767387844
FUNCTION(upper, 1, 0, 0, upperFunc ),
8767487845
FUNCTION(lower, 1, 0, 0, lowerFunc ),
8767587846
FUNCTION(coalesce, 1, 0, 0, 0 ),
8767687847
FUNCTION(coalesce, 0, 0, 0, 0 ),
87677
-/* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */
87678
- {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0},
87848
+ FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
8767987849
FUNCTION(hex, 1, 0, 0, hexFunc ),
87680
-/* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */
87681
- {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0},
87850
+ FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
8768287851
FUNCTION(random, 0, 0, 0, randomFunc ),
8768387852
FUNCTION(randomblob, 1, 0, 0, randomBlob ),
8768487853
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
8768587854
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
8768687855
FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
9011390282
int j1; /* Addresss of jump instruction */
9011490283
int j2 = 0, j3; /* Addresses of jump instructions */
9011590284
int regData; /* Register containing first data column */
9011690285
int iCur; /* Table cursor number */
9011790286
Index *pIdx; /* Pointer to one of the indices */
90287
+ sqlite3 *db; /* Database connection */
9011890288
int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
9011990289
int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
9012090290
90291
+ db = pParse->db;
9012190292
v = sqlite3GetVdbe(pParse);
9012290293
assert( v!=0 );
9012390294
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
9012490295
nCol = pTab->nCol;
9012590296
regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
9014890319
case OE_Rollback:
9014990320
case OE_Fail: {
9015090321
char *zMsg;
9015190322
sqlite3VdbeAddOp3(v, OP_HaltIfNull,
9015290323
SQLITE_CONSTRAINT, onError, regData+i);
90153
- zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
90324
+ zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL",
9015490325
pTab->zName, pTab->aCol[i].zName);
9015590326
sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
9015690327
break;
9015790328
}
9015890329
case OE_Ignore: {
@@ -90170,22 +90341,31 @@
9017090341
}
9017190342
9017290343
/* Test all CHECK constraints
9017390344
*/
9017490345
#ifndef SQLITE_OMIT_CHECK
90175
- if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){
90176
- int allOk = sqlite3VdbeMakeLabel(v);
90346
+ if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
90347
+ ExprList *pCheck = pTab->pCheck;
9017790348
pParse->ckBase = regData;
90178
- sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL);
9017990349
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90180
- if( onError==OE_Ignore ){
90181
- sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90182
- }else{
90183
- if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90184
- sqlite3HaltConstraint(pParse, onError, 0, 0);
90350
+ for(i=0; i<pCheck->nExpr; i++){
90351
+ int allOk = sqlite3VdbeMakeLabel(v);
90352
+ sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
90353
+ if( onError==OE_Ignore ){
90354
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90355
+ }else{
90356
+ char *zConsName = pCheck->a[i].zName;
90357
+ if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90358
+ if( zConsName ){
90359
+ zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
90360
+ }else{
90361
+ zConsName = 0;
90362
+ }
90363
+ sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
90364
+ }
90365
+ sqlite3VdbeResolveLabel(v, allOk);
9018590366
}
90186
- sqlite3VdbeResolveLabel(v, allOk);
9018790367
}
9018890368
#endif /* !defined(SQLITE_OMIT_CHECK) */
9018990369
9019090370
/* If we have an INTEGER PRIMARY KEY, make sure the primary key
9019190371
** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
9023790417
**
9023890418
** to run without a statement journal if there are no indexes on the
9023990419
** table.
9024090420
*/
9024190421
Trigger *pTrigger = 0;
90242
- if( pParse->db->flags&SQLITE_RecTriggers ){
90422
+ if( db->flags&SQLITE_RecTriggers ){
9024390423
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
9024490424
}
9024590425
if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
9024690426
sqlite3MultiWrite(pParse);
9024790427
sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
9032690506
StrAccum errMsg;
9032790507
const char *zSep;
9032890508
char *zErr;
9032990509
9033090510
sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90331
- errMsg.db = pParse->db;
90511
+ errMsg.db = db;
9033290512
zSep = pIdx->nColumn>1 ? "columns " : "column ";
9033390513
for(j=0; j<pIdx->nColumn; j++){
9033490514
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
9033590515
sqlite3StrAccumAppend(&errMsg, zSep, -1);
9033690516
zSep = ", ";
@@ -90350,11 +90530,11 @@
9035090530
}
9035190531
default: {
9035290532
Trigger *pTrigger = 0;
9035390533
assert( onError==OE_Replace );
9035490534
sqlite3MultiWrite(pParse);
90355
- if( pParse->db->flags&SQLITE_RecTriggers ){
90535
+ if( db->flags&SQLITE_RecTriggers ){
9035690536
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
9035790537
}
9035890538
sqlite3GenerateRowDelete(
9035990539
pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
9036090540
);
@@ -90680,11 +90860,11 @@
9068090860
if( pSrcIdx==0 ){
9068190861
return 0; /* pDestIdx has no corresponding index in pSrc */
9068290862
}
9068390863
}
9068490864
#ifndef SQLITE_OMIT_CHECK
90685
- if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){
90865
+ if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
9068690866
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
9068790867
}
9068890868
#endif
9068990869
#ifndef SQLITE_OMIT_FOREIGN_KEY
9069090870
/* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
9575395933
int nCol; /* Number of columns in the result set */
9575495934
Expr *p; /* Expression for a single result column */
9575595935
char *zName; /* Column name */
9575695936
int nName; /* Size of name in zName[] */
9575795937
95758
- *pnCol = nCol = pEList ? pEList->nExpr : 0;
95759
- aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95760
- if( aCol==0 ) return SQLITE_NOMEM;
95938
+ if( pEList ){
95939
+ nCol = pEList->nExpr;
95940
+ aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95941
+ testcase( aCol==0 );
95942
+ }else{
95943
+ nCol = 0;
95944
+ aCol = 0;
95945
+ }
95946
+ *pnCol = nCol;
95947
+ *paCol = aCol;
95948
+
9576195949
for(i=0, pCol=aCol; i<nCol; i++, pCol++){
9576295950
/* Get an appropriate name for the column
9576395951
*/
9576495952
p = pEList->a[i].pExpr;
9576595953
assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
9872398911
if( pCol->iSorterColumn>=j ){
9872498912
int r1 = j + regBase;
9872598913
int r2;
9872698914
9872798915
r2 = sqlite3ExprCodeGetColumn(pParse,
98728
- pCol->pTab, pCol->iColumn, pCol->iTable, r1);
98916
+ pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
9872998917
if( r1!=r2 ){
9873098918
sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
9873198919
}
9873298920
j++;
9873398921
}
@@ -103212,11 +103400,14 @@
103212103400
#ifdef SQLITE_EBCDIC
103213103401
if( *pnoCase ) return 0;
103214103402
#endif
103215103403
pList = pExpr->x.pList;
103216103404
pLeft = pList->a[1].pExpr;
103217
- if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){
103405
+ if( pLeft->op!=TK_COLUMN
103406
+ || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
103407
+ || IsVirtual(pLeft->pTab)
103408
+ ){
103218103409
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103219103410
** be the name of an indexed column with TEXT affinity. */
103220103411
return 0;
103221103412
}
103222103413
assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
106909107100
);
106910107101
if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
106911107102
int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
106912107103
int r;
106913107104
r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
106914
- regRowid);
107105
+ regRowid, 0);
106915107106
sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
106916107107
sqlite3VdbeCurrentAddr(v)+2, r, iSet);
106917107108
}
106918107109
sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
106919107110
@@ -107822,11 +108013,11 @@
107822108013
** An instance of this structure is used to store the LIKE,
107823108014
** GLOB, NOT LIKE, and NOT GLOB operators.
107824108015
*/
107825108016
struct LikeOp {
107826108017
Token eOperator; /* "like" or "glob" or "regexp" */
107827
- int not; /* True if the NOT keyword is present */
108018
+ int bNot; /* True if the NOT keyword is present */
107828108019
};
107829108020
107830108021
/*
107831108022
** An instance of the following structure describes the event of a
107832108023
** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108001108192
#endif
108002108193
#define sqlite3ParserARG_SDECL Parse *pParse;
108003108194
#define sqlite3ParserARG_PDECL ,Parse *pParse
108004108195
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108005108196
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
108006
-#define YYNSTATE 629
108007
-#define YYNRULE 327
108197
+#define YYNSTATE 627
108198
+#define YYNRULE 325
108008108199
#define YYFALLBACK 1
108009108200
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108010108201
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108011108202
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108012108203
@@ -108072,480 +108263,478 @@
108072108263
** shifting terminals.
108073108264
** yy_reduce_ofst[] For each state, the offset into yy_action for
108074108265
** shifting non-terminals after a reduce.
108075108266
** yy_default[] Default action for each state.
108076108267
*/
108077
-#define YY_ACTTAB_COUNT (1580)
108268
+#define YY_ACTTAB_COUNT (1561)
108078108269
static const YYACTIONTYPE yy_action[] = {
108079
- /* 0 */ 310, 328, 574, 573, 15, 172, 187, 596, 56, 56,
108270
+ /* 0 */ 310, 328, 573, 572, 15, 171, 185, 595, 56, 56,
108080108271
/* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108081
- /* 20 */ 52, 52, 51, 234, 622, 621, 626, 622, 621, 299,
108082
- /* 30 */ 589, 583, 56, 56, 56, 56, 236, 54, 54, 54,
108083
- /* 40 */ 54, 53, 53, 52, 52, 52, 51, 234, 351, 57,
108084
- /* 50 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108085
- /* 60 */ 56, 56, 570, 54, 54, 54, 54, 53, 53, 52,
108086
- /* 70 */ 52, 52, 51, 234, 310, 596, 326, 607, 233, 232,
108272
+ /* 20 */ 52, 52, 51, 233, 52, 52, 52, 51, 233, 624,
108273
+ /* 30 */ 588, 582, 56, 56, 56, 56, 314, 54, 54, 54,
108274
+ /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 299, 57,
108275
+ /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108276
+ /* 60 */ 56, 56, 569, 54, 54, 54, 54, 53, 53, 52,
108277
+ /* 70 */ 52, 52, 51, 233, 310, 595, 326, 575, 663, 65,
108087108278
/* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108088
- /* 90 */ 51, 234, 619, 618, 326, 619, 618, 166, 605, 492,
108089
- /* 100 */ 381, 378, 377, 235, 589, 583, 554, 495, 1, 59,
108090
- /* 110 */ 19, 376, 622, 621, 53, 53, 52, 52, 52, 51,
108091
- /* 120 */ 234, 571, 571, 57, 58, 48, 581, 580, 582, 582,
108092
- /* 130 */ 55, 55, 56, 56, 56, 56, 215, 54, 54, 54,
108093
- /* 140 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 224,
108094
- /* 150 */ 50, 47, 147, 177, 139, 281, 384, 276, 383, 169,
108095
- /* 160 */ 408, 553, 578, 578, 622, 621, 272, 224, 439, 550,
108096
- /* 170 */ 552, 410, 139, 281, 384, 276, 383, 169, 589, 583,
108097
- /* 180 */ 619, 618, 280, 620, 272, 195, 413, 309, 440, 441,
108098
- /* 190 */ 567, 491, 214, 279, 560, 600, 92, 57, 58, 48,
108099
- /* 200 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108100
- /* 210 */ 559, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108101
- /* 220 */ 51, 234, 310, 464, 233, 232, 558, 133, 519, 50,
108102
- /* 230 */ 47, 147, 619, 618, 565, 436, 397, 515, 514, 518,
108103
- /* 240 */ 410, 387, 438, 389, 437, 622, 621, 442, 570, 433,
108104
- /* 250 */ 203, 390, 589, 583, 6, 413, 166, 670, 250, 381,
108105
- /* 260 */ 378, 377, 525, 190, 600, 92, 594, 571, 571, 465,
108106
- /* 270 */ 376, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108107
- /* 280 */ 56, 56, 56, 56, 599, 54, 54, 54, 54, 53,
108108
- /* 290 */ 53, 52, 52, 52, 51, 234, 310, 592, 592, 592,
108109
- /* 300 */ 490, 182, 247, 548, 249, 397, 273, 410, 7, 439,
108110
- /* 310 */ 398, 606, 67, 619, 618, 620, 472, 256, 347, 255,
108111
- /* 320 */ 473, 620, 413, 576, 620, 65, 589, 583, 236, 440,
108112
- /* 330 */ 336, 600, 92, 68, 364, 192, 481, 622, 621, 547,
108113
- /* 340 */ 622, 621, 560, 323, 207, 57, 58, 48, 581, 580,
108114
- /* 350 */ 582, 582, 55, 55, 56, 56, 56, 56, 559, 54,
108115
- /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108116
- /* 370 */ 310, 410, 397, 146, 558, 531, 401, 348, 599, 166,
108117
- /* 380 */ 248, 204, 381, 378, 377, 541, 413, 171, 337, 570,
108118
- /* 390 */ 622, 621, 40, 376, 38, 600, 74, 465, 548, 490,
108119
- /* 400 */ 589, 583, 532, 350, 579, 619, 618, 297, 619, 618,
108120
- /* 410 */ 480, 67, 470, 39, 620, 599, 406, 574, 573, 57,
108121
- /* 420 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108122
- /* 430 */ 56, 56, 577, 54, 54, 54, 54, 53, 53, 52,
108123
- /* 440 */ 52, 52, 51, 234, 310, 256, 347, 255, 530, 52,
108124
- /* 450 */ 52, 52, 51, 234, 345, 564, 236, 386, 619, 618,
108125
- /* 460 */ 957, 185, 418, 2, 408, 410, 578, 578, 198, 197,
108126
- /* 470 */ 196, 499, 183, 167, 589, 583, 671, 570, 505, 506,
108127
- /* 480 */ 413, 267, 601, 672, 546, 208, 602, 36, 601, 600,
108128
- /* 490 */ 91, 468, 602, 57, 58, 48, 581, 580, 582, 582,
108129
- /* 500 */ 55, 55, 56, 56, 56, 56, 202, 54, 54, 54,
108130
- /* 510 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 599,
108131
- /* 520 */ 157, 408, 527, 578, 578, 263, 490, 265, 410, 873,
108132
- /* 530 */ 410, 474, 474, 366, 373, 410, 504, 428, 67, 290,
108133
- /* 540 */ 599, 620, 352, 413, 408, 413, 578, 578, 589, 583,
108134
- /* 550 */ 413, 382, 600, 92, 600, 16, 543, 62, 503, 600,
108135
- /* 560 */ 92, 408, 346, 578, 578, 168, 45, 57, 58, 48,
108136
- /* 570 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108137
- /* 580 */ 200, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108138
- /* 590 */ 51, 234, 310, 393, 395, 534, 510, 617, 616, 615,
108139
- /* 600 */ 318, 314, 172, 66, 596, 410, 338, 596, 324, 571,
108140
- /* 610 */ 571, 50, 47, 147, 599, 629, 627, 330, 539, 315,
108141
- /* 620 */ 413, 30, 589, 583, 272, 236, 199, 144, 176, 600,
108142
- /* 630 */ 73, 420, 947, 620, 947, 420, 946, 351, 946, 175,
108143
- /* 640 */ 596, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108144
- /* 650 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108145
- /* 660 */ 53, 52, 52, 52, 51, 234, 310, 261, 410, 413,
108146
- /* 670 */ 269, 208, 596, 363, 410, 596, 424, 360, 600, 69,
108147
- /* 680 */ 424, 327, 620, 413, 50, 47, 147, 410, 358, 413,
108148
- /* 690 */ 575, 553, 600, 94, 483, 509, 589, 583, 600, 97,
108149
- /* 700 */ 552, 484, 413, 620, 188, 599, 551, 563, 596, 566,
108150
- /* 710 */ 334, 600, 95, 205, 201, 57, 58, 48, 581, 580,
108151
- /* 720 */ 582, 582, 55, 55, 56, 56, 56, 56, 352, 54,
108152
- /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108153
- /* 740 */ 310, 410, 261, 410, 167, 22, 356, 599, 359, 623,
108154
- /* 750 */ 50, 47, 147, 548, 357, 562, 413, 620, 413, 332,
108155
- /* 760 */ 523, 270, 410, 167, 620, 600, 104, 600, 103, 603,
108156
- /* 770 */ 589, 583, 339, 539, 304, 423, 222, 413, 174, 304,
108157
- /* 780 */ 422, 561, 567, 405, 214, 260, 600, 106, 620, 57,
108158
- /* 790 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108159
- /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
108160
- /* 810 */ 52, 52, 51, 234, 310, 410, 557, 413, 410, 421,
108161
- /* 820 */ 273, 35, 512, 146, 421, 12, 600, 107, 213, 144,
108162
- /* 830 */ 413, 410, 32, 413, 410, 620, 365, 353, 358, 600,
108163
- /* 840 */ 134, 11, 600, 135, 589, 583, 413, 21, 548, 413,
108164
- /* 850 */ 316, 148, 620, 620, 170, 600, 98, 223, 600, 102,
108165
- /* 860 */ 374, 168, 167, 57, 58, 48, 581, 580, 582, 582,
108166
- /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
108167
- /* 880 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 410,
108168
- /* 890 */ 273, 413, 410, 273, 212, 469, 410, 167, 628, 2,
108169
- /* 900 */ 600, 101, 545, 221, 413, 620, 130, 413, 620, 410,
108170
- /* 910 */ 539, 413, 537, 600, 93, 315, 600, 100, 589, 583,
108171
- /* 920 */ 600, 77, 425, 305, 413, 620, 254, 322, 599, 458,
108172
- /* 930 */ 320, 171, 543, 600, 96, 521, 520, 57, 58, 48,
108173
- /* 940 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108174
- /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108175
- /* 960 */ 51, 234, 310, 410, 273, 413, 410, 457, 358, 35,
108176
- /* 970 */ 426, 230, 306, 319, 600, 138, 467, 520, 413, 620,
108177
- /* 980 */ 143, 413, 410, 620, 410, 353, 529, 600, 137, 142,
108178
- /* 990 */ 600, 136, 589, 583, 604, 261, 528, 413, 229, 413,
108179
- /* 1000 */ 620, 321, 495, 28, 543, 543, 600, 76, 600, 90,
108180
- /* 1010 */ 620, 57, 46, 48, 581, 580, 582, 582, 55, 55,
108181
- /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108182
- /* 1030 */ 53, 52, 52, 52, 51, 234, 310, 261, 451, 413,
108183
- /* 1040 */ 410, 211, 611, 285, 283, 610, 609, 502, 600, 89,
108184
- /* 1050 */ 380, 217, 620, 128, 140, 413, 220, 620, 410, 409,
108185
- /* 1060 */ 620, 620, 588, 587, 600, 75, 589, 583, 271, 620,
108186
- /* 1070 */ 51, 234, 127, 413, 620, 599, 627, 330, 27, 375,
108187
- /* 1080 */ 449, 279, 600, 88, 585, 584, 58, 48, 581, 580,
108188
- /* 1090 */ 582, 582, 55, 55, 56, 56, 56, 56, 410, 54,
108189
- /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108190
- /* 1110 */ 310, 586, 410, 413, 410, 261, 593, 165, 399, 556,
108191
- /* 1120 */ 126, 371, 600, 87, 478, 186, 123, 413, 367, 413,
108192
- /* 1130 */ 620, 620, 410, 620, 620, 410, 600, 99, 600, 86,
108193
- /* 1140 */ 589, 583, 475, 122, 258, 171, 471, 413, 160, 121,
108194
- /* 1150 */ 413, 14, 159, 463, 25, 24, 600, 17, 448, 600,
108195
- /* 1160 */ 85, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108196
- /* 1170 */ 56, 56, 158, 54, 54, 54, 54, 53, 53, 52,
108197
- /* 1180 */ 52, 52, 51, 234, 44, 404, 261, 3, 544, 261,
108198
- /* 1190 */ 540, 414, 621, 460, 119, 118, 538, 275, 10, 349,
108199
- /* 1200 */ 4, 620, 407, 620, 620, 620, 116, 44, 404, 410,
108200
- /* 1210 */ 3, 620, 620, 410, 414, 621, 456, 454, 252, 450,
108201
- /* 1220 */ 508, 402, 111, 109, 413, 407, 155, 444, 413, 447,
108202
- /* 1230 */ 435, 565, 219, 600, 84, 620, 108, 600, 83, 64,
108203
- /* 1240 */ 434, 417, 625, 150, 402, 333, 410, 237, 238, 124,
108204
- /* 1250 */ 274, 41, 42, 533, 565, 206, 189, 261, 43, 412,
108205
- /* 1260 */ 411, 413, 261, 594, 488, 620, 329, 149, 419, 268,
108206
- /* 1270 */ 600, 72, 620, 266, 41, 42, 181, 620, 410, 620,
108207
- /* 1280 */ 105, 43, 412, 411, 620, 624, 594, 614, 620, 599,
108208
- /* 1290 */ 228, 125, 313, 413, 592, 592, 592, 591, 590, 13,
108209
- /* 1300 */ 218, 410, 600, 71, 236, 244, 44, 404, 264, 3,
108210
- /* 1310 */ 312, 613, 340, 414, 621, 180, 413, 592, 592, 592,
108211
- /* 1320 */ 591, 590, 13, 620, 407, 600, 82, 410, 416, 34,
108212
- /* 1330 */ 404, 410, 3, 410, 262, 410, 414, 621, 612, 331,
108213
- /* 1340 */ 178, 415, 413, 402, 8, 236, 413, 407, 413, 620,
108214
- /* 1350 */ 413, 600, 81, 565, 257, 600, 80, 600, 70, 600,
108215
- /* 1360 */ 18, 598, 361, 462, 461, 30, 402, 294, 31, 620,
108216
- /* 1370 */ 293, 354, 251, 41, 42, 410, 565, 620, 620, 620,
108217
- /* 1380 */ 43, 412, 411, 453, 396, 594, 620, 620, 394, 61,
108218
- /* 1390 */ 413, 292, 443, 622, 621, 243, 41, 42, 620, 600,
108219
- /* 1400 */ 79, 597, 291, 43, 412, 411, 60, 620, 594, 240,
108220
- /* 1410 */ 620, 410, 231, 37, 555, 173, 592, 592, 592, 591,
108221
- /* 1420 */ 590, 13, 216, 239, 620, 184, 413, 302, 301, 300,
108222
- /* 1430 */ 179, 298, 388, 565, 452, 600, 78, 286, 620, 592,
108223
- /* 1440 */ 592, 592, 591, 590, 13, 429, 29, 413, 151, 289,
108224
- /* 1450 */ 242, 145, 392, 194, 193, 288, 600, 9, 542, 241,
108225
- /* 1460 */ 620, 525, 391, 284, 620, 594, 620, 620, 522, 536,
108226
- /* 1470 */ 620, 535, 153, 385, 465, 516, 282, 325, 154, 517,
108227
- /* 1480 */ 277, 152, 512, 511, 513, 129, 226, 308, 487, 486,
108228
- /* 1490 */ 485, 164, 372, 493, 307, 227, 592, 592, 592, 225,
108229
- /* 1500 */ 479, 163, 368, 370, 162, 476, 210, 477, 26, 259,
108230
- /* 1510 */ 161, 466, 362, 141, 132, 120, 117, 455, 156, 115,
108231
- /* 1520 */ 344, 343, 256, 342, 245, 114, 113, 446, 311, 112,
108232
- /* 1530 */ 23, 317, 432, 236, 131, 431, 110, 430, 20, 427,
108233
- /* 1540 */ 608, 595, 295, 63, 379, 287, 509, 191, 278, 403,
108234
- /* 1550 */ 572, 569, 497, 498, 496, 494, 335, 459, 445, 303,
108235
- /* 1560 */ 296, 246, 341, 355, 5, 568, 369, 507, 253, 549,
108236
- /* 1570 */ 526, 209, 400, 501, 500, 524, 234, 958, 489, 482,
108279
+ /* 90 */ 51, 233, 53, 53, 52, 52, 52, 51, 233, 489,
108280
+ /* 100 */ 663, 440, 663, 235, 588, 582, 553, 297, 363, 59,
108281
+ /* 110 */ 481, 67, 360, 1, 618, 351, 618, 620, 619, 207,
108282
+ /* 120 */ 6, 441, 442, 57, 58, 48, 580, 579, 581, 581,
108283
+ /* 130 */ 55, 55, 56, 56, 56, 56, 605, 54, 54, 54,
108284
+ /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
108285
+ /* 150 */ 50, 47, 146, 598, 138, 281, 385, 276, 384, 168,
108286
+ /* 160 */ 489, 552, 620, 619, 620, 619, 272, 214, 440, 411,
108287
+ /* 170 */ 551, 604, 67, 165, 7, 618, 352, 353, 588, 582,
108288
+ /* 180 */ 443, 569, 192, 618, 414, 617, 616, 668, 441, 336,
108289
+ /* 190 */ 669, 62, 618, 599, 92, 382, 346, 57, 58, 48,
108290
+ /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108291
+ /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108292
+ /* 220 */ 51, 233, 310, 465, 232, 231, 373, 132, 514, 513,
108293
+ /* 230 */ 617, 616, 617, 616, 398, 437, 411, 66, 280, 388,
108294
+ /* 240 */ 411, 595, 439, 220, 438, 620, 619, 337, 569, 279,
108295
+ /* 250 */ 201, 414, 588, 582, 166, 414, 546, 167, 68, 234,
108296
+ /* 260 */ 599, 92, 620, 619, 599, 92, 19, 570, 570, 466,
108297
+ /* 270 */ 564, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108298
+ /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108299
+ /* 290 */ 53, 52, 52, 52, 51, 233, 310, 411, 524, 232,
108300
+ /* 300 */ 231, 398, 593, 547, 559, 398, 348, 202, 175, 595,
108301
+ /* 310 */ 399, 315, 414, 617, 616, 387, 272, 255, 347, 254,
108302
+ /* 320 */ 558, 599, 74, 620, 619, 45, 588, 582, 235, 466,
108303
+ /* 330 */ 617, 616, 511, 591, 591, 591, 557, 578, 402, 545,
108304
+ /* 340 */ 600, 598, 570, 570, 601, 57, 58, 48, 580, 579,
108305
+ /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 550, 54,
108306
+ /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108307
+ /* 370 */ 310, 309, 411, 145, 566, 490, 213, 255, 347, 254,
108308
+ /* 380 */ 196, 195, 194, 587, 586, 531, 600, 414, 235, 174,
108309
+ /* 390 */ 601, 617, 616, 411, 620, 619, 599, 91, 547, 574,
108310
+ /* 400 */ 588, 582, 50, 47, 146, 584, 583, 471, 414, 249,
108311
+ /* 410 */ 565, 542, 186, 39, 304, 424, 562, 599, 16, 57,
108312
+ /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108313
+ /* 430 */ 56, 56, 585, 54, 54, 54, 54, 53, 53, 52,
108314
+ /* 440 */ 52, 52, 51, 233, 310, 559, 290, 530, 529, 345,
108315
+ /* 450 */ 533, 576, 540, 246, 170, 248, 411, 396, 411, 422,
108316
+ /* 460 */ 199, 558, 617, 616, 165, 563, 50, 47, 146, 181,
108317
+ /* 470 */ 498, 414, 166, 414, 588, 582, 269, 557, 166, 518,
108318
+ /* 480 */ 599, 92, 599, 92, 561, 595, 469, 36, 173, 409,
108319
+ /* 490 */ 517, 577, 577, 57, 58, 48, 580, 579, 581, 581,
108320
+ /* 500 */ 55, 55, 56, 56, 56, 56, 338, 54, 54, 54,
108321
+ /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 304,
108322
+ /* 520 */ 423, 394, 526, 318, 869, 235, 167, 180, 473, 547,
108323
+ /* 530 */ 503, 247, 474, 381, 378, 377, 409, 351, 577, 577,
108324
+ /* 540 */ 409, 560, 577, 577, 376, 383, 364, 603, 588, 582,
108325
+ /* 550 */ 620, 619, 502, 595, 409, 494, 577, 577, 409, 266,
108326
+ /* 560 */ 577, 577, 421, 943, 422, 943, 198, 57, 58, 48,
108327
+ /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108328
+ /* 580 */ 315, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108329
+ /* 590 */ 51, 233, 310, 390, 421, 942, 509, 942, 556, 145,
108330
+ /* 600 */ 598, 391, 324, 262, 549, 264, 411, 425, 407, 573,
108331
+ /* 610 */ 572, 12, 197, 143, 489, 50, 47, 146, 617, 616,
108332
+ /* 620 */ 206, 414, 588, 582, 547, 429, 67, 212, 143, 618,
108333
+ /* 630 */ 599, 73, 504, 505, 207, 434, 475, 475, 366, 425,
108334
+ /* 640 */ 35, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108335
+ /* 650 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108336
+ /* 660 */ 53, 52, 52, 52, 51, 233, 310, 260, 598, 569,
108337
+ /* 670 */ 268, 615, 614, 613, 171, 411, 595, 11, 411, 350,
108338
+ /* 680 */ 411, 32, 618, 953, 183, 419, 2, 627, 625, 330,
108339
+ /* 690 */ 414, 352, 552, 414, 538, 414, 588, 582, 188, 599,
108340
+ /* 700 */ 69, 551, 599, 94, 599, 97, 374, 544, 166, 618,
108341
+ /* 710 */ 334, 359, 50, 47, 146, 57, 58, 48, 580, 579,
108342
+ /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108343
+ /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108344
+ /* 740 */ 310, 411, 129, 414, 595, 22, 273, 156, 411, 566,
108345
+ /* 750 */ 406, 213, 599, 95, 570, 570, 414, 327, 169, 332,
108346
+ /* 760 */ 411, 618, 536, 414, 358, 599, 104, 483, 508, 356,
108347
+ /* 770 */ 588, 582, 599, 103, 484, 414, 470, 357, 166, 618,
108348
+ /* 780 */ 626, 2, 204, 323, 599, 105, 40, 528, 38, 57,
108349
+ /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108350
+ /* 800 */ 56, 56, 411, 54, 54, 54, 54, 53, 53, 52,
108351
+ /* 810 */ 52, 52, 51, 233, 310, 411, 598, 414, 411, 260,
108352
+ /* 820 */ 273, 273, 273, 273, 426, 305, 599, 106, 520, 519,
108353
+ /* 830 */ 414, 411, 142, 414, 618, 618, 618, 618, 618, 599,
108354
+ /* 840 */ 133, 339, 599, 134, 588, 582, 414, 21, 30, 316,
108355
+ /* 850 */ 147, 459, 221, 170, 527, 599, 98, 222, 322, 321,
108356
+ /* 860 */ 320, 141, 259, 57, 58, 48, 580, 579, 581, 581,
108357
+ /* 870 */ 55, 55, 56, 56, 56, 56, 411, 54, 54, 54,
108358
+ /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 411,
108359
+ /* 890 */ 260, 414, 411, 458, 200, 35, 411, 358, 211, 228,
108360
+ /* 900 */ 599, 102, 468, 519, 414, 618, 28, 414, 538, 501,
108361
+ /* 910 */ 411, 414, 618, 599, 101, 358, 599, 93, 588, 582,
108362
+ /* 920 */ 599, 100, 522, 618, 427, 414, 306, 271, 598, 380,
108363
+ /* 930 */ 618, 602, 598, 452, 599, 77, 210, 57, 58, 48,
108364
+ /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108365
+ /* 950 */ 411, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108366
+ /* 960 */ 51, 233, 310, 411, 621, 414, 411, 127, 609, 270,
108367
+ /* 970 */ 598, 365, 51, 233, 599, 96, 625, 330, 414, 618,
108368
+ /* 980 */ 126, 414, 411, 618, 411, 253, 608, 599, 137, 27,
108369
+ /* 990 */ 599, 136, 588, 582, 375, 260, 125, 414, 164, 414,
108370
+ /* 1000 */ 371, 618, 279, 219, 542, 542, 599, 135, 599, 76,
108371
+ /* 1010 */ 618, 57, 46, 48, 580, 579, 581, 581, 55, 55,
108372
+ /* 1020 */ 56, 56, 56, 56, 411, 54, 54, 54, 54, 53,
108373
+ /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 411, 450, 414,
108374
+ /* 1040 */ 411, 260, 542, 229, 285, 607, 479, 184, 599, 90,
108375
+ /* 1050 */ 367, 122, 414, 476, 121, 414, 618, 170, 411, 353,
108376
+ /* 1060 */ 618, 599, 89, 410, 599, 75, 588, 582, 472, 257,
108377
+ /* 1070 */ 538, 120, 159, 414, 618, 14, 464, 158, 618, 157,
108378
+ /* 1080 */ 461, 283, 599, 88, 449, 618, 58, 48, 580, 579,
108379
+ /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108380
+ /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108381
+ /* 1110 */ 310, 411, 260, 414, 411, 592, 260, 118, 25, 400,
108382
+ /* 1120 */ 10, 24, 599, 87, 117, 216, 414, 618, 349, 414,
108383
+ /* 1130 */ 618, 618, 411, 319, 618, 599, 99, 555, 599, 86,
108384
+ /* 1140 */ 588, 582, 4, 260, 457, 455, 115, 414, 251, 154,
108385
+ /* 1150 */ 451, 108, 618, 110, 436, 448, 599, 17, 618, 218,
108386
+ /* 1160 */ 107, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108387
+ /* 1170 */ 56, 56, 435, 54, 54, 54, 54, 53, 53, 52,
108388
+ /* 1180 */ 52, 52, 51, 233, 44, 405, 217, 3, 411, 260,
108389
+ /* 1190 */ 543, 415, 619, 445, 64, 149, 539, 237, 333, 329,
108390
+ /* 1200 */ 203, 187, 408, 414, 618, 618, 420, 44, 405, 411,
108391
+ /* 1210 */ 3, 618, 599, 85, 415, 619, 148, 227, 622, 179,
108392
+ /* 1220 */ 313, 403, 312, 612, 414, 408, 611, 124, 417, 178,
108393
+ /* 1230 */ 610, 564, 243, 599, 84, 537, 8, 176, 235, 416,
108394
+ /* 1240 */ 294, 418, 623, 30, 403, 597, 411, 236, 293, 123,
108395
+ /* 1250 */ 618, 41, 42, 532, 564, 205, 292, 275, 43, 413,
108396
+ /* 1260 */ 412, 414, 395, 593, 507, 274, 31, 397, 291, 37,
108397
+ /* 1270 */ 599, 83, 618, 491, 41, 42, 267, 411, 265, 618,
108398
+ /* 1280 */ 618, 43, 413, 412, 596, 263, 593, 60, 618, 598,
108399
+ /* 1290 */ 261, 618, 414, 618, 591, 591, 591, 590, 589, 13,
108400
+ /* 1300 */ 618, 599, 72, 554, 235, 618, 44, 405, 256, 3,
108401
+ /* 1310 */ 361, 172, 340, 415, 619, 230, 411, 591, 591, 591,
108402
+ /* 1320 */ 590, 589, 13, 618, 408, 618, 182, 411, 286, 34,
108403
+ /* 1330 */ 405, 414, 3, 411, 463, 411, 415, 619, 29, 331,
108404
+ /* 1340 */ 599, 71, 414, 403, 392, 386, 284, 408, 414, 618,
108405
+ /* 1350 */ 414, 599, 82, 564, 411, 462, 354, 599, 81, 599,
108406
+ /* 1360 */ 80, 541, 250, 535, 282, 521, 403, 534, 516, 414,
108407
+ /* 1370 */ 618, 618, 454, 41, 42, 411, 564, 618, 599, 70,
108408
+ /* 1380 */ 43, 413, 412, 444, 515, 593, 242, 618, 325, 61,
108409
+ /* 1390 */ 414, 277, 239, 620, 619, 238, 41, 42, 618, 599,
108410
+ /* 1400 */ 18, 618, 512, 43, 413, 412, 511, 618, 593, 430,
108411
+ /* 1410 */ 618, 411, 128, 510, 308, 226, 591, 591, 591, 590,
108412
+ /* 1420 */ 589, 13, 215, 289, 618, 225, 414, 302, 301, 300,
108413
+ /* 1430 */ 177, 298, 411, 564, 453, 599, 79, 224, 618, 591,
108414
+ /* 1440 */ 591, 591, 590, 589, 13, 389, 492, 414, 150, 144,
108415
+ /* 1450 */ 241, 393, 288, 191, 190, 193, 599, 78, 165, 240,
108416
+ /* 1460 */ 414, 524, 487, 307, 618, 593, 618, 618, 486, 599,
108417
+ /* 1470 */ 9, 163, 152, 485, 466, 372, 480, 162, 153, 370,
108418
+ /* 1480 */ 161, 151, 209, 478, 258, 368, 477, 26, 160, 467,
108419
+ /* 1490 */ 140, 362, 131, 119, 116, 456, 591, 591, 591, 155,
108420
+ /* 1500 */ 114, 344, 343, 113, 112, 111, 447, 109, 130, 23,
108421
+ /* 1510 */ 317, 433, 20, 432, 431, 428, 606, 594, 63, 189,
108422
+ /* 1520 */ 404, 571, 255, 342, 244, 295, 287, 278, 311, 508,
108423
+ /* 1530 */ 496, 497, 495, 235, 493, 568, 379, 355, 460, 245,
108424
+ /* 1540 */ 341, 446, 303, 567, 5, 252, 548, 208, 139, 506,
108425
+ /* 1550 */ 369, 401, 500, 499, 296, 525, 335, 488, 482, 523,
108426
+ /* 1560 */ 233,
108237108427
};
108238108428
static const YYCODETYPE yy_lookahead[] = {
108239108429
/* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108240108430
/* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108241
- /* 20 */ 89, 90, 91, 92, 26, 27, 1, 26, 27, 15,
108242
- /* 30 */ 49, 50, 77, 78, 79, 80, 116, 82, 83, 84,
108243
- /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 128, 68,
108431
+ /* 20 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 1,
108432
+ /* 30 */ 49, 50, 77, 78, 79, 80, 155, 82, 83, 84,
108433
+ /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 15, 68,
108244108434
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108245108435
/* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108246
- /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 86, 87,
108436
+ /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 1, 25,
108247108437
/* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108248
- /* 90 */ 91, 92, 94, 95, 19, 94, 95, 96, 172, 173,
108249
- /* 100 */ 99, 100, 101, 197, 49, 50, 177, 181, 22, 54,
108250
- /* 110 */ 204, 110, 26, 27, 86, 87, 88, 89, 90, 91,
108251
- /* 120 */ 92, 129, 130, 68, 69, 70, 71, 72, 73, 74,
108252
- /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84,
108438
+ /* 90 */ 91, 92, 86, 87, 88, 89, 90, 91, 92, 150,
108439
+ /* 100 */ 23, 150, 25, 116, 49, 50, 177, 158, 227, 54,
108440
+ /* 110 */ 161, 162, 231, 22, 165, 128, 165, 26, 27, 160,
108441
+ /* 120 */ 22, 170, 171, 68, 69, 70, 71, 72, 73, 74,
108442
+ /* 130 */ 75, 76, 77, 78, 79, 80, 23, 82, 83, 84,
108253108443
/* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108254
- /* 150 */ 221, 222, 223, 96, 97, 98, 99, 100, 101, 102,
108255
- /* 160 */ 112, 32, 114, 115, 26, 27, 109, 92, 150, 25,
108256
- /* 170 */ 41, 150, 97, 98, 99, 100, 101, 102, 49, 50,
108257
- /* 180 */ 94, 95, 98, 165, 109, 25, 165, 163, 170, 171,
108258
- /* 190 */ 166, 167, 168, 109, 12, 174, 175, 68, 69, 70,
108444
+ /* 150 */ 221, 222, 223, 194, 97, 98, 99, 100, 101, 102,
108445
+ /* 160 */ 150, 32, 26, 27, 26, 27, 109, 22, 150, 150,
108446
+ /* 170 */ 41, 161, 162, 96, 76, 165, 217, 150, 49, 50,
108447
+ /* 180 */ 229, 230, 172, 165, 165, 94, 95, 118, 170, 171,
108448
+ /* 190 */ 118, 232, 165, 174, 175, 185, 237, 68, 69, 70,
108259108449
/* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108260
- /* 210 */ 28, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108261
- /* 220 */ 91, 92, 19, 11, 86, 87, 44, 24, 46, 221,
108262
- /* 230 */ 222, 223, 94, 95, 66, 97, 215, 7, 8, 57,
108263
- /* 240 */ 150, 220, 104, 19, 106, 26, 27, 229, 230, 241,
108264
- /* 250 */ 160, 27, 49, 50, 22, 165, 96, 118, 16, 99,
108265
- /* 260 */ 100, 101, 94, 119, 174, 175, 98, 129, 130, 57,
108266
- /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108450
+ /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108451
+ /* 220 */ 91, 92, 19, 11, 86, 87, 19, 24, 7, 8,
108452
+ /* 230 */ 94, 95, 94, 95, 215, 97, 150, 22, 98, 220,
108453
+ /* 240 */ 150, 26, 104, 216, 106, 26, 27, 229, 230, 109,
108454
+ /* 250 */ 160, 165, 49, 50, 25, 165, 120, 50, 22, 197,
108455
+ /* 260 */ 174, 175, 26, 27, 174, 175, 204, 129, 130, 57,
108456
+ /* 270 */ 66, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108267108457
/* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108268
- /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
108269
- /* 300 */ 150, 23, 60, 25, 62, 215, 150, 150, 76, 150,
108270
- /* 310 */ 220, 161, 162, 94, 95, 165, 30, 105, 106, 107,
108271
- /* 320 */ 34, 165, 165, 23, 165, 25, 49, 50, 116, 170,
108272
- /* 330 */ 171, 174, 175, 22, 48, 185, 186, 26, 27, 120,
108273
- /* 340 */ 26, 27, 12, 187, 160, 68, 69, 70, 71, 72,
108274
- /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 28, 82,
108458
+ /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 94, 86,
108459
+ /* 300 */ 87, 215, 98, 25, 12, 215, 220, 160, 118, 94,
108460
+ /* 310 */ 220, 104, 165, 94, 95, 88, 109, 105, 106, 107,
108461
+ /* 320 */ 28, 174, 175, 26, 27, 22, 49, 50, 116, 57,
108462
+ /* 330 */ 94, 95, 103, 129, 130, 131, 44, 113, 46, 120,
108463
+ /* 340 */ 113, 194, 129, 130, 117, 68, 69, 70, 71, 72,
108464
+ /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 177, 82,
108275108465
/* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108276
- /* 370 */ 19, 150, 215, 95, 44, 23, 46, 220, 194, 96,
108277
- /* 380 */ 138, 160, 99, 100, 101, 23, 165, 25, 229, 230,
108278
- /* 390 */ 26, 27, 135, 110, 137, 174, 175, 57, 120, 150,
108279
- /* 400 */ 49, 50, 88, 219, 113, 94, 95, 158, 94, 95,
108280
- /* 410 */ 161, 162, 21, 136, 165, 194, 169, 170, 171, 68,
108466
+ /* 370 */ 19, 163, 150, 95, 166, 167, 168, 105, 106, 107,
108467
+ /* 380 */ 105, 106, 107, 49, 50, 88, 113, 165, 116, 118,
108468
+ /* 390 */ 117, 94, 95, 150, 26, 27, 174, 175, 120, 23,
108469
+ /* 400 */ 49, 50, 221, 222, 223, 71, 72, 21, 165, 16,
108470
+ /* 410 */ 23, 166, 22, 136, 22, 23, 11, 174, 175, 68,
108281108471
/* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108282
- /* 430 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108283
- /* 440 */ 89, 90, 91, 92, 19, 105, 106, 107, 23, 88,
108284
- /* 450 */ 89, 90, 91, 92, 63, 23, 116, 88, 94, 95,
108285
- /* 460 */ 142, 143, 144, 145, 112, 150, 114, 115, 105, 106,
108286
- /* 470 */ 107, 23, 23, 25, 49, 50, 118, 230, 97, 98,
108287
- /* 480 */ 165, 16, 113, 118, 120, 160, 117, 136, 113, 174,
108288
- /* 490 */ 175, 100, 117, 68, 69, 70, 71, 72, 73, 74,
108289
- /* 500 */ 75, 76, 77, 78, 79, 80, 160, 82, 83, 84,
108290
- /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 194,
108291
- /* 520 */ 25, 112, 23, 114, 115, 60, 150, 62, 150, 138,
108292
- /* 530 */ 150, 105, 106, 107, 19, 150, 36, 161, 162, 224,
108293
- /* 540 */ 194, 165, 217, 165, 112, 165, 114, 115, 49, 50,
108294
- /* 550 */ 165, 51, 174, 175, 174, 175, 166, 232, 58, 174,
108295
- /* 560 */ 175, 112, 237, 114, 115, 50, 22, 68, 69, 70,
108472
+ /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
108473
+ /* 440 */ 89, 90, 91, 92, 19, 12, 224, 23, 23, 63,
108474
+ /* 450 */ 205, 23, 23, 60, 25, 62, 150, 214, 150, 67,
108475
+ /* 460 */ 22, 28, 94, 95, 96, 23, 221, 222, 223, 23,
108476
+ /* 470 */ 23, 165, 25, 165, 49, 50, 23, 44, 25, 46,
108477
+ /* 480 */ 174, 175, 174, 175, 23, 26, 100, 136, 25, 112,
108478
+ /* 490 */ 57, 114, 115, 68, 69, 70, 71, 72, 73, 74,
108479
+ /* 500 */ 75, 76, 77, 78, 79, 80, 97, 82, 83, 84,
108480
+ /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 22,
108481
+ /* 520 */ 23, 215, 23, 215, 138, 116, 50, 23, 30, 25,
108482
+ /* 530 */ 36, 138, 34, 99, 100, 101, 112, 128, 114, 115,
108483
+ /* 540 */ 112, 23, 114, 115, 110, 51, 48, 173, 49, 50,
108484
+ /* 550 */ 26, 27, 58, 94, 112, 181, 114, 115, 112, 16,
108485
+ /* 560 */ 114, 115, 22, 23, 67, 25, 160, 68, 69, 70,
108296108486
/* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108297
- /* 580 */ 160, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108298
- /* 590 */ 91, 92, 19, 215, 214, 205, 23, 7, 8, 9,
108299
- /* 600 */ 215, 155, 24, 22, 26, 150, 97, 26, 108, 129,
108300
- /* 610 */ 130, 221, 222, 223, 194, 0, 1, 2, 150, 104,
108301
- /* 620 */ 165, 126, 49, 50, 109, 116, 206, 207, 118, 174,
108302
- /* 630 */ 175, 22, 23, 165, 25, 22, 23, 128, 25, 118,
108303
- /* 640 */ 26, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108304
- /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108305
- /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
108306
- /* 670 */ 23, 160, 94, 227, 150, 94, 67, 231, 174, 175,
108307
- /* 680 */ 67, 213, 165, 165, 221, 222, 223, 150, 150, 165,
108308
- /* 690 */ 23, 32, 174, 175, 181, 182, 49, 50, 174, 175,
108309
- /* 700 */ 41, 188, 165, 165, 22, 194, 177, 11, 94, 23,
108310
- /* 710 */ 193, 174, 175, 160, 22, 68, 69, 70, 71, 72,
108311
- /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 217, 82,
108487
+ /* 580 */ 104, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108488
+ /* 590 */ 91, 92, 19, 19, 22, 23, 23, 25, 23, 95,
108489
+ /* 600 */ 194, 27, 108, 60, 25, 62, 150, 67, 169, 170,
108490
+ /* 610 */ 171, 35, 206, 207, 150, 221, 222, 223, 94, 95,
108491
+ /* 620 */ 160, 165, 49, 50, 120, 161, 162, 206, 207, 165,
108492
+ /* 630 */ 174, 175, 97, 98, 160, 241, 105, 106, 107, 67,
108493
+ /* 640 */ 25, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108494
+ /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108495
+ /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 230,
108496
+ /* 670 */ 23, 7, 8, 9, 24, 150, 26, 35, 150, 219,
108497
+ /* 680 */ 150, 25, 165, 142, 143, 144, 145, 0, 1, 2,
108498
+ /* 690 */ 165, 217, 32, 165, 150, 165, 49, 50, 119, 174,
108499
+ /* 700 */ 175, 41, 174, 175, 174, 175, 23, 120, 25, 165,
108500
+ /* 710 */ 193, 237, 221, 222, 223, 68, 69, 70, 71, 72,
108501
+ /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108312108502
/* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108313
- /* 740 */ 19, 150, 150, 150, 25, 24, 19, 194, 237, 150,
108314
- /* 750 */ 221, 222, 223, 25, 27, 23, 165, 165, 165, 242,
108315
- /* 760 */ 165, 23, 150, 25, 165, 174, 175, 174, 175, 174,
108316
- /* 770 */ 49, 50, 219, 150, 22, 23, 238, 165, 25, 22,
108317
- /* 780 */ 23, 23, 166, 167, 168, 193, 174, 175, 165, 68,
108503
+ /* 740 */ 19, 150, 22, 165, 94, 24, 150, 25, 150, 166,
108504
+ /* 750 */ 167, 168, 174, 175, 129, 130, 165, 213, 35, 242,
108505
+ /* 760 */ 150, 165, 27, 165, 150, 174, 175, 181, 182, 19,
108506
+ /* 770 */ 49, 50, 174, 175, 188, 165, 23, 27, 25, 165,
108507
+ /* 780 */ 144, 145, 160, 187, 174, 175, 135, 23, 137, 68,
108318108508
/* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108319108509
/* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108320
- /* 810 */ 89, 90, 91, 92, 19, 150, 23, 165, 150, 67,
108321
- /* 820 */ 150, 25, 103, 95, 67, 35, 174, 175, 206, 207,
108322
- /* 830 */ 165, 150, 25, 165, 150, 165, 213, 150, 150, 174,
108323
- /* 840 */ 175, 35, 174, 175, 49, 50, 165, 52, 120, 165,
108324
- /* 850 */ 245, 246, 165, 165, 35, 174, 175, 187, 174, 175,
108325
- /* 860 */ 23, 50, 25, 68, 69, 70, 71, 72, 73, 74,
108510
+ /* 810 */ 89, 90, 91, 92, 19, 150, 194, 165, 150, 150,
108511
+ /* 820 */ 150, 150, 150, 150, 247, 248, 174, 175, 190, 191,
108512
+ /* 830 */ 165, 150, 118, 165, 165, 165, 165, 165, 165, 174,
108513
+ /* 840 */ 175, 219, 174, 175, 49, 50, 165, 52, 126, 245,
108514
+ /* 850 */ 246, 23, 238, 25, 23, 174, 175, 187, 187, 187,
108515
+ /* 860 */ 187, 39, 193, 68, 69, 70, 71, 72, 73, 74,
108326108516
/* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108327108517
/* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108328
- /* 890 */ 150, 165, 150, 150, 160, 23, 150, 25, 144, 145,
108329
- /* 900 */ 174, 175, 120, 216, 165, 165, 22, 165, 165, 150,
108330
- /* 910 */ 150, 165, 27, 174, 175, 104, 174, 175, 49, 50,
108331
- /* 920 */ 174, 175, 247, 248, 165, 165, 238, 187, 194, 23,
108332
- /* 930 */ 187, 25, 166, 174, 175, 190, 191, 68, 69, 70,
108518
+ /* 890 */ 150, 165, 150, 23, 160, 25, 150, 150, 160, 52,
108519
+ /* 900 */ 174, 175, 190, 191, 165, 165, 22, 165, 150, 29,
108520
+ /* 910 */ 150, 165, 165, 174, 175, 150, 174, 175, 49, 50,
108521
+ /* 920 */ 174, 175, 165, 165, 23, 165, 25, 25, 194, 52,
108522
+ /* 930 */ 165, 174, 194, 193, 174, 175, 160, 68, 69, 70,
108333108523
/* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108334108524
/* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108335
- /* 960 */ 91, 92, 19, 150, 150, 165, 150, 23, 150, 25,
108336
- /* 970 */ 23, 205, 25, 213, 174, 175, 190, 191, 165, 165,
108337
- /* 980 */ 118, 165, 150, 165, 150, 150, 23, 174, 175, 39,
108338
- /* 990 */ 174, 175, 49, 50, 173, 150, 23, 165, 52, 165,
108339
- /* 1000 */ 165, 187, 181, 22, 166, 166, 174, 175, 174, 175,
108525
+ /* 960 */ 91, 92, 19, 150, 150, 165, 150, 22, 150, 23,
108526
+ /* 970 */ 194, 213, 91, 92, 174, 175, 1, 2, 165, 165,
108527
+ /* 980 */ 22, 165, 150, 165, 150, 238, 150, 174, 175, 22,
108528
+ /* 990 */ 174, 175, 49, 50, 52, 150, 22, 165, 102, 165,
108529
+ /* 1000 */ 19, 165, 109, 238, 166, 166, 174, 175, 174, 175,
108340108530
/* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108341108531
/* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108342108532
/* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108343
- /* 1040 */ 150, 160, 150, 205, 205, 150, 150, 29, 174, 175,
108344
- /* 1050 */ 52, 216, 165, 22, 150, 165, 238, 165, 150, 150,
108345
- /* 1060 */ 165, 165, 49, 50, 174, 175, 49, 50, 23, 165,
108346
- /* 1070 */ 91, 92, 22, 165, 165, 194, 1, 2, 22, 52,
108347
- /* 1080 */ 193, 109, 174, 175, 71, 72, 69, 70, 71, 72,
108533
+ /* 1040 */ 150, 150, 166, 205, 205, 150, 20, 24, 174, 175,
108534
+ /* 1050 */ 43, 104, 165, 59, 53, 165, 165, 25, 150, 150,
108535
+ /* 1060 */ 165, 174, 175, 150, 174, 175, 49, 50, 53, 138,
108536
+ /* 1070 */ 150, 22, 104, 165, 165, 5, 1, 118, 165, 35,
108537
+ /* 1080 */ 27, 205, 174, 175, 193, 165, 69, 70, 71, 72,
108348108538
/* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108349108539
/* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108350
- /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 102, 150, 150,
108351
- /* 1120 */ 22, 19, 174, 175, 20, 24, 104, 165, 43, 165,
108352
- /* 1130 */ 165, 165, 150, 165, 165, 150, 174, 175, 174, 175,
108353
- /* 1140 */ 49, 50, 59, 53, 138, 25, 53, 165, 104, 22,
108354
- /* 1150 */ 165, 5, 118, 1, 76, 76, 174, 175, 193, 174,
108355
- /* 1160 */ 175, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108356
- /* 1170 */ 79, 80, 35, 82, 83, 84, 85, 86, 87, 88,
108357
- /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 150,
108358
- /* 1190 */ 150, 26, 27, 27, 108, 127, 150, 150, 22, 25,
108359
- /* 1200 */ 22, 165, 37, 165, 165, 165, 119, 19, 20, 150,
108360
- /* 1210 */ 22, 165, 165, 150, 26, 27, 23, 1, 16, 20,
108361
- /* 1220 */ 150, 56, 119, 108, 165, 37, 121, 128, 165, 193,
108362
- /* 1230 */ 23, 66, 193, 174, 175, 165, 127, 174, 175, 16,
108363
- /* 1240 */ 23, 146, 147, 15, 56, 65, 150, 152, 140, 154,
108364
- /* 1250 */ 150, 86, 87, 88, 66, 160, 22, 150, 93, 94,
108365
- /* 1260 */ 95, 165, 150, 98, 150, 165, 3, 246, 4, 150,
108366
- /* 1270 */ 174, 175, 165, 150, 86, 87, 6, 165, 150, 165,
108367
- /* 1280 */ 164, 93, 94, 95, 165, 149, 98, 149, 165, 194,
108368
- /* 1290 */ 180, 180, 249, 165, 129, 130, 131, 132, 133, 134,
108369
- /* 1300 */ 193, 150, 174, 175, 116, 193, 19, 20, 150, 22,
108370
- /* 1310 */ 249, 149, 217, 26, 27, 151, 165, 129, 130, 131,
108371
- /* 1320 */ 132, 133, 134, 165, 37, 174, 175, 150, 149, 19,
108372
- /* 1330 */ 20, 150, 22, 150, 150, 150, 26, 27, 13, 244,
108373
- /* 1340 */ 151, 159, 165, 56, 25, 116, 165, 37, 165, 165,
108374
- /* 1350 */ 165, 174, 175, 66, 150, 174, 175, 174, 175, 174,
108375
- /* 1360 */ 175, 194, 150, 150, 150, 126, 56, 199, 124, 165,
108376
- /* 1370 */ 200, 150, 150, 86, 87, 150, 66, 165, 165, 165,
108377
- /* 1380 */ 93, 94, 95, 150, 122, 98, 165, 165, 123, 22,
108378
- /* 1390 */ 165, 201, 150, 26, 27, 150, 86, 87, 165, 174,
108379
- /* 1400 */ 175, 203, 202, 93, 94, 95, 125, 165, 98, 150,
108380
- /* 1410 */ 165, 150, 225, 135, 157, 118, 129, 130, 131, 132,
108381
- /* 1420 */ 133, 134, 5, 150, 165, 157, 165, 10, 11, 12,
108382
- /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 210, 165, 129,
108383
- /* 1440 */ 130, 131, 132, 133, 134, 150, 104, 165, 31, 150,
108384
- /* 1450 */ 33, 150, 150, 86, 87, 150, 174, 175, 211, 42,
108385
- /* 1460 */ 165, 94, 121, 210, 165, 98, 165, 165, 176, 211,
108386
- /* 1470 */ 165, 211, 55, 104, 57, 184, 210, 47, 61, 176,
108387
- /* 1480 */ 176, 64, 103, 176, 178, 22, 92, 179, 176, 176,
108388
- /* 1490 */ 176, 156, 18, 184, 179, 228, 129, 130, 131, 228,
108389
- /* 1500 */ 157, 156, 45, 157, 156, 236, 157, 157, 135, 235,
108390
- /* 1510 */ 156, 189, 157, 68, 218, 189, 22, 199, 156, 192,
108391
- /* 1520 */ 157, 18, 105, 106, 107, 192, 192, 199, 111, 192,
108392
- /* 1530 */ 240, 157, 40, 116, 218, 157, 189, 157, 240, 38,
108393
- /* 1540 */ 153, 166, 198, 243, 178, 209, 182, 196, 177, 226,
108394
- /* 1550 */ 230, 230, 166, 177, 177, 166, 139, 199, 199, 148,
108395
- /* 1560 */ 195, 209, 209, 239, 196, 166, 234, 183, 239, 208,
108396
- /* 1570 */ 174, 233, 191, 183, 183, 174, 92, 250, 186, 186,
108540
+ /* 1110 */ 19, 150, 150, 165, 150, 150, 150, 108, 76, 150,
108541
+ /* 1120 */ 22, 76, 174, 175, 127, 216, 165, 165, 25, 165,
108542
+ /* 1130 */ 165, 165, 150, 213, 165, 174, 175, 150, 174, 175,
108543
+ /* 1140 */ 49, 50, 22, 150, 23, 1, 119, 165, 16, 121,
108544
+ /* 1150 */ 20, 108, 165, 119, 23, 193, 174, 175, 165, 193,
108545
+ /* 1160 */ 127, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108546
+ /* 1170 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108547
+ /* 1180 */ 89, 90, 91, 92, 19, 20, 193, 22, 150, 150,
108548
+ /* 1190 */ 150, 26, 27, 128, 16, 15, 150, 140, 65, 3,
108549
+ /* 1200 */ 164, 22, 37, 165, 165, 165, 4, 19, 20, 150,
108550
+ /* 1210 */ 22, 165, 174, 175, 26, 27, 246, 180, 149, 6,
108551
+ /* 1220 */ 249, 56, 249, 149, 165, 37, 149, 180, 149, 151,
108552
+ /* 1230 */ 13, 66, 193, 174, 175, 150, 25, 151, 116, 159,
108553
+ /* 1240 */ 199, 146, 147, 126, 56, 194, 150, 152, 200, 154,
108554
+ /* 1250 */ 165, 86, 87, 88, 66, 160, 201, 150, 93, 94,
108555
+ /* 1260 */ 95, 165, 123, 98, 150, 150, 124, 122, 202, 135,
108556
+ /* 1270 */ 174, 175, 165, 150, 86, 87, 150, 150, 150, 165,
108557
+ /* 1280 */ 165, 93, 94, 95, 203, 150, 98, 125, 165, 194,
108558
+ /* 1290 */ 150, 165, 165, 165, 129, 130, 131, 132, 133, 134,
108559
+ /* 1300 */ 165, 174, 175, 157, 116, 165, 19, 20, 150, 22,
108560
+ /* 1310 */ 150, 118, 217, 26, 27, 225, 150, 129, 130, 131,
108561
+ /* 1320 */ 132, 133, 134, 165, 37, 165, 157, 150, 210, 19,
108562
+ /* 1330 */ 20, 165, 22, 150, 150, 150, 26, 27, 104, 244,
108563
+ /* 1340 */ 174, 175, 165, 56, 121, 104, 210, 37, 165, 165,
108564
+ /* 1350 */ 165, 174, 175, 66, 150, 150, 150, 174, 175, 174,
108565
+ /* 1360 */ 175, 211, 150, 211, 210, 176, 56, 211, 176, 165,
108566
+ /* 1370 */ 165, 165, 150, 86, 87, 150, 66, 165, 174, 175,
108567
+ /* 1380 */ 93, 94, 95, 150, 184, 98, 150, 165, 47, 22,
108568
+ /* 1390 */ 165, 176, 150, 26, 27, 150, 86, 87, 165, 174,
108569
+ /* 1400 */ 175, 165, 178, 93, 94, 95, 103, 165, 98, 150,
108570
+ /* 1410 */ 165, 150, 22, 176, 179, 228, 129, 130, 131, 132,
108571
+ /* 1420 */ 133, 134, 5, 150, 165, 92, 165, 10, 11, 12,
108572
+ /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 228, 165, 129,
108573
+ /* 1440 */ 130, 131, 132, 133, 134, 150, 184, 165, 31, 150,
108574
+ /* 1450 */ 33, 150, 150, 86, 87, 172, 174, 175, 96, 42,
108575
+ /* 1460 */ 165, 94, 176, 179, 165, 98, 165, 165, 176, 174,
108576
+ /* 1470 */ 175, 156, 55, 176, 57, 18, 157, 156, 61, 157,
108577
+ /* 1480 */ 156, 64, 157, 157, 235, 45, 236, 135, 156, 189,
108578
+ /* 1490 */ 68, 157, 218, 189, 22, 199, 129, 130, 131, 156,
108579
+ /* 1500 */ 192, 157, 18, 192, 192, 192, 199, 189, 218, 240,
108580
+ /* 1510 */ 157, 40, 240, 157, 157, 38, 153, 166, 243, 196,
108581
+ /* 1520 */ 226, 230, 105, 106, 107, 198, 209, 177, 111, 182,
108582
+ /* 1530 */ 166, 177, 177, 116, 166, 230, 178, 239, 199, 209,
108583
+ /* 1540 */ 209, 199, 148, 166, 196, 239, 208, 233, 172, 183,
108584
+ /* 1550 */ 234, 191, 183, 183, 195, 174, 139, 186, 186, 174,
108585
+ /* 1560 */ 92,
108397108586
};
108398
-#define YY_SHIFT_USE_DFLT (-81)
108399
-#define YY_SHIFT_COUNT (417)
108400
-#define YY_SHIFT_MIN (-80)
108401
-#define YY_SHIFT_MAX (1503)
108587
+#define YY_SHIFT_USE_DFLT (-70)
108588
+#define YY_SHIFT_COUNT (418)
108589
+#define YY_SHIFT_MIN (-69)
108590
+#define YY_SHIFT_MAX (1484)
108402108591
static const short yy_shift_ofst[] = {
108403
- /* 0 */ 1075, 1188, 1417, 1188, 1287, 1287, 138, 138, 1, -19,
108404
- /* 10 */ 1287, 1287, 1287, 1287, 340, -2, 129, 129, 795, 1165,
108592
+ /* 0 */ 975, 1188, 1417, 1188, 1287, 1287, 138, 138, 368, -19,
108593
+ /* 10 */ 1287, 1287, 1287, 1287, 272, 524, 129, 129, 795, 1165,
108405108594
/* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108406108595
/* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108407108596
/* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108408108597
/* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108409
- /* 60 */ 1287, 1287, 212, -2, -2, -8, -8, 614, 1229, 55,
108598
+ /* 60 */ 1287, 1287, 212, 524, 524, 213, 213, 459, 1122, 55,
108410108599
/* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108411108600
/* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108412108601
/* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108413
- /* 100 */ -45, -45, -45, -45, -1, 57, 28, 361, -2, -2,
108414
- /* 110 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108415
- /* 120 */ -2, -2, -2, -2, 391, 515, -2, -2, -2, -2,
108416
- /* 130 */ -2, 509, -80, 614, 979, 1484, -81, -81, -81, 1367,
108417
- /* 140 */ 75, 182, 182, 314, 311, 364, 219, 86, 613, 609,
108418
- /* 150 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108419
- /* 160 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108420
- /* 170 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108421
- /* 180 */ -2, -2, 578, 578, 578, 615, 1229, 1229, 1229, -81,
108422
- /* 190 */ -81, -81, 160, 168, 168, 283, 500, 500, 500, 278,
108423
- /* 200 */ 449, 330, 432, 409, 352, 48, 48, 48, 48, 426,
108424
- /* 210 */ 286, 48, 48, 728, 581, 369, 590, 495, 224, 224,
108425
- /* 220 */ 727, 495, 727, 719, 614, 659, 614, 659, 811, 659,
108426
- /* 230 */ 224, 257, 480, 480, 614, 144, 375, -18, 1501, 1297,
108427
- /* 240 */ 1297, 1492, 1492, 1297, 1494, 1445, 1239, 1503, 1503, 1503,
108428
- /* 250 */ 1503, 1297, 1474, 1239, 1494, 1445, 1445, 1297, 1474, 1373,
108429
- /* 260 */ 1457, 1297, 1297, 1474, 1297, 1474, 1297, 1474, 1463, 1369,
108430
- /* 270 */ 1369, 1369, 1430, 1394, 1394, 1463, 1369, 1379, 1369, 1430,
108431
- /* 280 */ 1369, 1369, 1341, 1342, 1341, 1342, 1341, 1342, 1297, 1297,
108432
- /* 290 */ 1278, 1281, 1262, 1244, 1265, 1239, 1229, 1319, 1325, 1325,
108433
- /* 300 */ 1270, 1270, 1270, 1270, -81, -81, -81, -81, -81, -81,
108434
- /* 310 */ 1013, 242, 757, 752, 465, 363, 947, 232, 944, 906,
108435
- /* 320 */ 872, 837, 738, 448, 381, 230, 84, 362, 300, 1264,
108436
- /* 330 */ 1263, 1234, 1108, 1228, 1180, 1223, 1217, 1207, 1099, 1174,
108437
- /* 340 */ 1109, 1115, 1103, 1199, 1105, 1202, 1216, 1087, 1193, 1178,
108438
- /* 350 */ 1174, 1176, 1068, 1079, 1078, 1086, 1166, 1137, 1034, 1152,
108439
- /* 360 */ 1146, 1127, 1044, 1006, 1093, 1120, 1090, 1083, 1085, 1022,
108440
- /* 370 */ 1101, 1104, 1102, 972, 1015, 1098, 1027, 1056, 1050, 1045,
108441
- /* 380 */ 1031, 998, 1018, 981, 946, 950, 973, 963, 862, 885,
108442
- /* 390 */ 819, 884, 782, 796, 806, 807, 790, 796, 793, 758,
108443
- /* 400 */ 753, 732, 692, 696, 682, 686, 667, 544, 291, 521,
108444
- /* 410 */ 510, 365, 358, 139, 114, 54, 14, 25,
108602
+ /* 100 */ -45, -45, -45, -45, -1, 6, -64, 524, 524, 524,
108603
+ /* 110 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108604
+ /* 120 */ 524, 524, 524, 386, 207, 524, 524, 524, 524, 524,
108605
+ /* 130 */ 409, -13, 459, 881, 1468, -70, -70, -70, 1367, 57,
108606
+ /* 140 */ 433, 433, 297, 236, 219, 136, 91, 572, 540, 524,
108607
+ /* 150 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108608
+ /* 160 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108609
+ /* 170 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108610
+ /* 180 */ 650, 650, 650, 687, 1122, 1122, 1122, -70, -70, -70,
108611
+ /* 190 */ 204, 204, 434, 434, 494, 494, 494, 504, 446, 292,
108612
+ /* 200 */ 442, 428, 424, 77, 377, 377, 377, 377, 531, 498,
108613
+ /* 210 */ 377, 377, 278, 215, 227, 664, 722, 574, 574, 750,
108614
+ /* 220 */ 722, 750, 229, 459, 660, 459, 660, 476, 660, 574,
108615
+ /* 230 */ 651, 625, 625, 459, 579, 273, -18, 1477, 1193, 1193,
108616
+ /* 240 */ 1471, 1471, 1193, 1472, 1422, 1117, 1484, 1484, 1484, 1484,
108617
+ /* 250 */ 1193, 1457, 1117, 1472, 1422, 1422, 1193, 1457, 1352, 1440,
108618
+ /* 260 */ 1193, 1193, 1457, 1193, 1457, 1193, 1457, 1390, 1241, 1241,
108619
+ /* 270 */ 1241, 1362, 1341, 1333, 1333, 1390, 1241, 1303, 1241, 1341,
108620
+ /* 280 */ 1241, 1241, 1223, 1234, 1223, 1234, 1223, 1234, 1193, 1193,
108621
+ /* 290 */ 1134, 1162, 1145, 1142, 1139, 1117, 1122, 1211, 1217, 1217,
108622
+ /* 300 */ 1213, 1213, 1213, 1213, -70, -70, -70, -70, -70, -70,
108623
+ /* 310 */ 334, 393, 497, 392, 543, 275, 901, 98, 870, 828,
108624
+ /* 320 */ 753, 683, 453, 447, 535, 221, 140, 429, 54, 1202,
108625
+ /* 330 */ 1196, 1179, 1057, 1180, 1133, 1178, 1149, 1131, 1065, 1103,
108626
+ /* 340 */ 1033, 1043, 1034, 1130, 1028, 1132, 1144, 1027, 1121, 1120,
108627
+ /* 350 */ 1103, 1098, 997, 1045, 1042, 1009, 1053, 1044, 959, 1075,
108628
+ /* 360 */ 1070, 1049, 968, 931, 1015, 1032, 1001, 994, 1007, 947,
108629
+ /* 370 */ 1023, 1026, 981, 893, 896, 974, 942, 967, 958, 946,
108630
+ /* 380 */ 945, 877, 902, 880, 884, 847, 822, 831, 764, 714,
108631
+ /* 390 */ 735, 723, 720, 587, 615, 642, 656, 576, 615, 575,
108632
+ /* 400 */ 518, 463, 461, 438, 405, 390, 387, 376, 303, 224,
108633
+ /* 410 */ 271, 190, 92, 72, 69, 145, 113, 33, 28,
108445108634
};
108446108635
#define YY_REDUCE_USE_DFLT (-169)
108447108636
#define YY_REDUCE_COUNT (309)
108448108637
#define YY_REDUCE_MIN (-168)
108449
-#define YY_REDUCE_MAX (1411)
108638
+#define YY_REDUCE_MAX (1394)
108450108639
static const short yy_reduce_ofst[] = {
108451
- /* 0 */ 318, 90, 1095, 221, 157, 21, 159, 18, 150, 390,
108452
- /* 10 */ 385, 378, 380, 315, 325, 249, 529, -71, 8, 1282,
108453
- /* 20 */ 1261, 1225, 1185, 1183, 1181, 1177, 1151, 1128, 1096, 1063,
108454
- /* 30 */ 1059, 985, 982, 964, 962, 948, 908, 890, 874, 834,
108455
- /* 40 */ 832, 816, 813, 800, 759, 746, 742, 739, 726, 684,
108456
- /* 50 */ 681, 668, 665, 652, 612, 593, 591, 537, 524, 518,
108457
- /* 60 */ 504, 455, 511, 376, 517, 247, -168, 24, 420, 463,
108458
- /* 70 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108459
- /* 80 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108460
- /* 90 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108461
- /* 100 */ 463, 463, 463, 463, 463, -74, 463, 463, 1112, 835,
108462
- /* 110 */ 1107, 1039, 1036, 965, 887, 845, 818, 760, 688, 687,
108463
- /* 120 */ 538, 743, 623, 592, 446, 513, 814, 740, 670, 156,
108464
- /* 130 */ 468, 553, 184, 616, 463, 463, 463, 463, 463, 595,
108465
- /* 140 */ 821, 786, 745, 909, 1305, 1302, 1301, 1299, 675, 675,
108466
- /* 150 */ 1295, 1273, 1259, 1245, 1242, 1233, 1222, 1221, 1214, 1213,
108467
- /* 160 */ 1212, 1204, 1184, 1158, 1123, 1119, 1114, 1100, 1070, 1047,
108468
- /* 170 */ 1046, 1040, 1038, 969, 968, 966, 909, 904, 896, 895,
108469
- /* 180 */ 892, 599, 839, 838, 766, 754, 881, 734, 346, 605,
108470
- /* 190 */ 622, -94, 1393, 1401, 1396, 1392, 1391, 1390, 1384, 1361,
108471
- /* 200 */ 1365, 1381, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1332,
108472
- /* 210 */ 1338, 1365, 1365, 1361, 1399, 1368, 1411, 1359, 1353, 1352,
108473
- /* 220 */ 1329, 1358, 1324, 1366, 1389, 1377, 1386, 1376, 1364, 1371,
108474
- /* 230 */ 1336, 1323, 1321, 1320, 1375, 1344, 1351, 1387, 1300, 1380,
108475
- /* 240 */ 1378, 1298, 1290, 1374, 1316, 1347, 1328, 1337, 1334, 1333,
108476
- /* 250 */ 1327, 1363, 1362, 1318, 1296, 1326, 1322, 1355, 1354, 1269,
108477
- /* 260 */ 1274, 1350, 1349, 1348, 1346, 1345, 1343, 1335, 1315, 1314,
108478
- /* 270 */ 1313, 1312, 1309, 1271, 1267, 1308, 1307, 1306, 1304, 1291,
108479
- /* 280 */ 1303, 1292, 1260, 1266, 1258, 1253, 1247, 1227, 1268, 1257,
108480
- /* 290 */ 1187, 1198, 1200, 1190, 1170, 1168, 1167, 1182, 1189, 1164,
108481
- /* 300 */ 1179, 1162, 1138, 1136, 1061, 1043, 1021, 1111, 1110, 1116,
108640
+ /* 0 */ 541, 90, 1095, 147, 86, 19, 18, -49, 10, 245,
108641
+ /* 10 */ 308, 306, 243, 222, -41, -51, 181, -71, 394, 1295,
108642
+ /* 20 */ 1282, 1261, 1225, 1204, 1185, 1183, 1177, 1166, 1127, 1096,
108643
+ /* 30 */ 1059, 1038, 982, 964, 961, 948, 908, 890, 887, 874,
108644
+ /* 40 */ 834, 832, 816, 813, 800, 760, 746, 742, 739, 726,
108645
+ /* 50 */ 681, 668, 665, 652, 610, 598, 591, 578, 530, 528,
108646
+ /* 60 */ 525, 456, 474, 464, 517, 439, -168, 208, 406, 491,
108647
+ /* 70 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108648
+ /* 80 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108649
+ /* 90 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108650
+ /* 100 */ 491, 491, 491, 491, 491, 491, 491, 1039, 909, 993,
108651
+ /* 110 */ 966, 962, 891, 845, 740, 765, 920, 747, 27, 614,
108652
+ /* 120 */ 673, 758, 669, -119, 586, 672, 671, 670, 596, 544,
108653
+ /* 130 */ 622, 460, 583, 491, 491, 491, 491, 491, 757, 374,
108654
+ /* 140 */ 712, 638, 913, 1302, 1301, 1299, 1273, 577, 577, 1259,
108655
+ /* 150 */ 1245, 1242, 1236, 1233, 1222, 1212, 1206, 1205, 1184, 1160,
108656
+ /* 160 */ 1158, 1140, 1135, 1128, 1126, 1123, 1115, 1114, 1107, 1085,
108657
+ /* 170 */ 1046, 1040, 987, 969, 965, 913, 895, 836, 818, 814,
108658
+ /* 180 */ 876, 839, 838, 636, 776, 738, 734, 604, 421, 62,
108659
+ /* 190 */ 1385, 1381, 1372, 1371, 1370, 1369, 1366, 1338, 1359, 1360,
108660
+ /* 200 */ 1359, 1359, 1359, 1376, 1359, 1359, 1359, 1359, 1316, 1314,
108661
+ /* 210 */ 1359, 1359, 1338, 1377, 1348, 1394, 1342, 1331, 1330, 1306,
108662
+ /* 220 */ 1339, 1298, 1358, 1368, 1355, 1364, 1354, 1347, 1350, 1317,
108663
+ /* 230 */ 1294, 1305, 1291, 1351, 1327, 1323, 1363, 1275, 1357, 1356,
108664
+ /* 240 */ 1272, 1269, 1353, 1290, 1318, 1307, 1313, 1312, 1311, 1308,
108665
+ /* 250 */ 1344, 1343, 1296, 1274, 1304, 1300, 1334, 1332, 1250, 1249,
108666
+ /* 260 */ 1326, 1325, 1324, 1322, 1321, 1319, 1315, 1284, 1297, 1292,
108667
+ /* 270 */ 1286, 1283, 1262, 1209, 1187, 1235, 1237, 1224, 1215, 1200,
108668
+ /* 280 */ 1192, 1189, 1156, 1154, 1152, 1136, 1150, 1118, 1169, 1146,
108669
+ /* 290 */ 1090, 1081, 1066, 1055, 1048, 1041, 1051, 1080, 1086, 1078,
108670
+ /* 300 */ 1079, 1077, 1074, 1069, 973, 971, 970, 1047, 1037, 1036,
108482108671
};
108483108672
static const YYACTIONTYPE yy_default[] = {
108484
- /* 0 */ 634, 868, 956, 956, 868, 868, 956, 956, 956, 758,
108485
- /* 10 */ 956, 956, 956, 866, 956, 956, 786, 786, 930, 956,
108486
- /* 20 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108487
- /* 30 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108488
- /* 40 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108489
- /* 50 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108490
- /* 60 */ 956, 956, 956, 956, 956, 956, 956, 673, 762, 792,
108491
- /* 70 */ 956, 956, 956, 956, 956, 956, 956, 956, 929, 931,
108492
- /* 80 */ 800, 799, 909, 773, 797, 790, 794, 869, 862, 863,
108493
- /* 90 */ 861, 865, 870, 956, 793, 829, 846, 828, 840, 845,
108494
- /* 100 */ 852, 844, 841, 831, 830, 665, 832, 833, 956, 956,
108495
- /* 110 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108496
- /* 120 */ 956, 956, 956, 956, 660, 727, 956, 956, 956, 956,
108497
- /* 130 */ 956, 956, 956, 956, 834, 835, 849, 848, 847, 956,
108498
- /* 140 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108499
- /* 150 */ 956, 936, 934, 956, 881, 956, 956, 956, 956, 956,
108500
- /* 160 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108501
- /* 170 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108502
- /* 180 */ 956, 640, 758, 758, 758, 634, 956, 956, 956, 948,
108503
- /* 190 */ 762, 752, 718, 956, 956, 956, 956, 956, 956, 956,
108504
- /* 200 */ 956, 956, 956, 956, 956, 802, 741, 919, 921, 956,
108505
- /* 210 */ 902, 739, 662, 760, 675, 750, 642, 796, 775, 775,
108506
- /* 220 */ 914, 796, 914, 699, 956, 786, 956, 786, 696, 786,
108507
- /* 230 */ 775, 864, 956, 956, 956, 759, 750, 956, 941, 766,
108508
- /* 240 */ 766, 933, 933, 766, 808, 731, 796, 738, 738, 738,
108509
- /* 250 */ 738, 766, 657, 796, 808, 731, 731, 766, 657, 908,
108510
- /* 260 */ 906, 766, 766, 657, 766, 657, 766, 657, 874, 729,
108511
- /* 270 */ 729, 729, 714, 878, 878, 874, 729, 699, 729, 714,
108512
- /* 280 */ 729, 729, 779, 774, 779, 774, 779, 774, 766, 766,
108513
- /* 290 */ 956, 791, 780, 789, 787, 796, 956, 717, 650, 650,
108514
- /* 300 */ 639, 639, 639, 639, 953, 953, 948, 701, 701, 683,
108515
- /* 310 */ 956, 956, 956, 956, 956, 956, 956, 883, 956, 956,
108516
- /* 320 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108517
- /* 330 */ 635, 943, 956, 956, 940, 956, 956, 956, 956, 801,
108518
- /* 340 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108519
- /* 350 */ 918, 956, 956, 956, 956, 956, 956, 956, 912, 956,
108520
- /* 360 */ 956, 956, 956, 956, 956, 905, 904, 956, 956, 956,
108521
- /* 370 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108522
- /* 380 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108523
- /* 390 */ 956, 956, 956, 788, 956, 781, 956, 867, 956, 956,
108524
- /* 400 */ 956, 956, 956, 956, 956, 956, 956, 956, 744, 817,
108525
- /* 410 */ 956, 816, 820, 815, 667, 956, 648, 956, 631, 636,
108526
- /* 420 */ 952, 955, 954, 951, 950, 949, 944, 942, 939, 938,
108527
- /* 430 */ 937, 935, 932, 928, 887, 885, 892, 891, 890, 889,
108528
- /* 440 */ 888, 886, 884, 882, 803, 798, 795, 927, 880, 740,
108529
- /* 450 */ 737, 736, 656, 945, 911, 920, 807, 806, 809, 917,
108530
- /* 460 */ 916, 915, 913, 910, 897, 805, 804, 732, 872, 871,
108531
- /* 470 */ 659, 901, 900, 899, 903, 907, 898, 768, 658, 655,
108532
- /* 480 */ 664, 721, 720, 728, 726, 725, 724, 723, 722, 719,
108533
- /* 490 */ 666, 674, 685, 713, 698, 697, 877, 879, 876, 875,
108534
- /* 500 */ 706, 705, 711, 710, 709, 708, 707, 704, 703, 702,
108535
- /* 510 */ 695, 694, 700, 693, 716, 715, 712, 692, 735, 734,
108536
- /* 520 */ 733, 730, 691, 690, 689, 820, 688, 687, 826, 825,
108537
- /* 530 */ 813, 856, 755, 754, 753, 765, 764, 777, 776, 811,
108538
- /* 540 */ 810, 778, 763, 757, 756, 772, 771, 770, 769, 761,
108539
- /* 550 */ 751, 783, 785, 784, 782, 858, 767, 855, 926, 925,
108540
- /* 560 */ 924, 923, 922, 860, 859, 827, 824, 678, 679, 895,
108541
- /* 570 */ 894, 896, 893, 681, 680, 677, 676, 857, 746, 745,
108542
- /* 580 */ 853, 850, 842, 838, 854, 851, 843, 839, 837, 836,
108543
- /* 590 */ 822, 821, 819, 818, 814, 823, 669, 747, 743, 742,
108544
- /* 600 */ 812, 749, 748, 686, 684, 682, 663, 661, 654, 652,
108545
- /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
108546
- /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
108673
+ /* 0 */ 632, 864, 952, 952, 864, 864, 952, 952, 683, 754,
108674
+ /* 10 */ 952, 952, 952, 862, 952, 952, 782, 782, 926, 952,
108675
+ /* 20 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108676
+ /* 30 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108677
+ /* 40 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108678
+ /* 50 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108679
+ /* 60 */ 952, 952, 952, 952, 952, 952, 952, 671, 758, 788,
108680
+ /* 70 */ 952, 952, 952, 952, 952, 952, 952, 952, 925, 927,
108681
+ /* 80 */ 796, 795, 905, 769, 793, 786, 790, 865, 858, 859,
108682
+ /* 90 */ 857, 861, 866, 952, 789, 825, 842, 824, 836, 841,
108683
+ /* 100 */ 848, 840, 837, 827, 826, 828, 829, 952, 952, 952,
108684
+ /* 110 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108685
+ /* 120 */ 952, 952, 952, 658, 723, 952, 952, 952, 952, 952,
108686
+ /* 130 */ 952, 952, 952, 830, 831, 845, 844, 843, 952, 952,
108687
+ /* 140 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108688
+ /* 150 */ 932, 930, 952, 877, 952, 952, 952, 952, 952, 952,
108689
+ /* 160 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108690
+ /* 170 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 638,
108691
+ /* 180 */ 754, 754, 754, 632, 952, 952, 952, 944, 758, 748,
108692
+ /* 190 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108693
+ /* 200 */ 952, 952, 952, 683, 798, 737, 915, 917, 952, 898,
108694
+ /* 210 */ 735, 660, 756, 673, 746, 640, 792, 771, 771, 910,
108695
+ /* 220 */ 792, 910, 697, 952, 782, 952, 782, 694, 782, 771,
108696
+ /* 230 */ 860, 952, 952, 952, 755, 746, 952, 937, 762, 762,
108697
+ /* 240 */ 929, 929, 762, 804, 727, 792, 734, 734, 734, 734,
108698
+ /* 250 */ 762, 655, 792, 804, 727, 727, 762, 655, 904, 902,
108699
+ /* 260 */ 762, 762, 655, 762, 655, 762, 655, 870, 725, 725,
108700
+ /* 270 */ 725, 683, 712, 874, 874, 870, 725, 697, 725, 712,
108701
+ /* 280 */ 725, 725, 775, 770, 775, 770, 775, 770, 762, 762,
108702
+ /* 290 */ 952, 787, 776, 785, 783, 792, 952, 715, 648, 648,
108703
+ /* 300 */ 637, 637, 637, 637, 949, 949, 944, 699, 699, 681,
108704
+ /* 310 */ 952, 952, 952, 952, 952, 952, 952, 879, 952, 952,
108705
+ /* 320 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108706
+ /* 330 */ 633, 939, 952, 952, 936, 952, 952, 952, 952, 797,
108707
+ /* 340 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108708
+ /* 350 */ 914, 952, 952, 952, 952, 952, 952, 952, 908, 952,
108709
+ /* 360 */ 952, 952, 952, 952, 952, 901, 900, 952, 952, 952,
108710
+ /* 370 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108711
+ /* 380 */ 952, 952, 716, 952, 952, 952, 952, 952, 952, 952,
108712
+ /* 390 */ 952, 952, 952, 952, 784, 952, 777, 952, 863, 952,
108713
+ /* 400 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 740,
108714
+ /* 410 */ 813, 952, 812, 816, 811, 665, 952, 646, 952, 629,
108715
+ /* 420 */ 634, 948, 951, 950, 947, 946, 945, 940, 938, 935,
108716
+ /* 430 */ 934, 933, 931, 928, 924, 883, 881, 888, 887, 886,
108717
+ /* 440 */ 885, 884, 882, 880, 878, 799, 794, 791, 923, 876,
108718
+ /* 450 */ 736, 733, 732, 654, 941, 907, 916, 803, 802, 805,
108719
+ /* 460 */ 913, 912, 911, 909, 906, 893, 801, 800, 728, 868,
108720
+ /* 470 */ 867, 657, 897, 896, 895, 899, 903, 894, 764, 656,
108721
+ /* 480 */ 653, 662, 718, 724, 722, 721, 720, 719, 717, 664,
108722
+ /* 490 */ 672, 682, 711, 696, 695, 873, 875, 872, 871, 704,
108723
+ /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
108724
+ /* 510 */ 692, 698, 691, 714, 713, 710, 690, 731, 730, 729,
108725
+ /* 520 */ 726, 689, 688, 687, 816, 686, 685, 822, 821, 809,
108726
+ /* 530 */ 852, 751, 750, 749, 761, 760, 773, 772, 807, 806,
108727
+ /* 540 */ 774, 759, 753, 752, 768, 767, 766, 765, 757, 747,
108728
+ /* 550 */ 779, 781, 780, 778, 854, 763, 851, 922, 921, 920,
108729
+ /* 560 */ 919, 918, 856, 855, 823, 820, 676, 677, 891, 890,
108730
+ /* 570 */ 892, 889, 679, 678, 675, 674, 853, 742, 741, 849,
108731
+ /* 580 */ 846, 838, 834, 850, 847, 839, 835, 833, 832, 818,
108732
+ /* 590 */ 817, 815, 814, 810, 819, 667, 743, 739, 738, 808,
108733
+ /* 600 */ 745, 744, 684, 680, 661, 659, 652, 650, 649, 651,
108734
+ /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
108735
+ /* 620 */ 665, 639, 636, 635, 631, 630, 628,
108547108736
};
108548108737
108549108738
/* The next table maps tokens into fallback tokens. If a construct
108550108739
** like the following:
108551108740
**
@@ -108744,11 +108933,11 @@
108744108933
"create_table", "create_table_args", "createkw", "temp",
108745108934
"ifnotexists", "dbnm", "columnlist", "conslist_opt",
108746108935
"select", "column", "columnid", "type",
108747108936
"carglist", "id", "ids", "typetoken",
108748108937
"typename", "signed", "plus_num", "minus_num",
108749
- "carg", "ccons", "term", "expr",
108938
+ "cname", "ccons", "term", "expr",
108750108939
"onconf", "sortorder", "autoinc", "idxlist_opt",
108751108940
"refargs", "defer_subclause", "refarg", "refact",
108752108941
"init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108753108942
"defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108754108943
"ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
108824109013
/* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
108825109014
/* 49 */ "typename ::= ids",
108826109015
/* 50 */ "typename ::= typename ids",
108827109016
/* 51 */ "signed ::= plus_num",
108828109017
/* 52 */ "signed ::= minus_num",
108829
- /* 53 */ "carglist ::= carglist carg",
109018
+ /* 53 */ "carglist ::= carglist cname ccons",
108830109019
/* 54 */ "carglist ::=",
108831
- /* 55 */ "carg ::= CONSTRAINT nm ccons",
108832
- /* 56 */ "carg ::= ccons",
109020
+ /* 55 */ "cname ::= CONSTRAINT nm",
109021
+ /* 56 */ "cname ::=",
108833109022
/* 57 */ "ccons ::= DEFAULT term",
108834109023
/* 58 */ "ccons ::= DEFAULT LP expr RP",
108835109024
/* 59 */ "ccons ::= DEFAULT PLUS term",
108836109025
/* 60 */ "ccons ::= DEFAULT MINUS term",
108837109026
/* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
108861109050
/* 85 */ "init_deferred_pred_opt ::=",
108862109051
/* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
108863109052
/* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
108864109053
/* 88 */ "conslist_opt ::=",
108865109054
/* 89 */ "conslist_opt ::= COMMA conslist",
108866
- /* 90 */ "conslist ::= conslist COMMA tcons",
108867
- /* 91 */ "conslist ::= conslist tcons",
108868
- /* 92 */ "conslist ::= tcons",
108869
- /* 93 */ "tcons ::= CONSTRAINT nm",
108870
- /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
108871
- /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
108872
- /* 96 */ "tcons ::= CHECK LP expr RP onconf",
108873
- /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
108874
- /* 98 */ "defer_subclause_opt ::=",
108875
- /* 99 */ "defer_subclause_opt ::= defer_subclause",
108876
- /* 100 */ "onconf ::=",
108877
- /* 101 */ "onconf ::= ON CONFLICT resolvetype",
108878
- /* 102 */ "orconf ::=",
108879
- /* 103 */ "orconf ::= OR resolvetype",
108880
- /* 104 */ "resolvetype ::= raisetype",
108881
- /* 105 */ "resolvetype ::= IGNORE",
108882
- /* 106 */ "resolvetype ::= REPLACE",
108883
- /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
108884
- /* 108 */ "ifexists ::= IF EXISTS",
108885
- /* 109 */ "ifexists ::=",
108886
- /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
108887
- /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
108888
- /* 112 */ "cmd ::= select",
108889
- /* 113 */ "select ::= oneselect",
108890
- /* 114 */ "select ::= select multiselect_op oneselect",
108891
- /* 115 */ "multiselect_op ::= UNION",
108892
- /* 116 */ "multiselect_op ::= UNION ALL",
108893
- /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
108894
- /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
108895
- /* 119 */ "distinct ::= DISTINCT",
108896
- /* 120 */ "distinct ::= ALL",
108897
- /* 121 */ "distinct ::=",
108898
- /* 122 */ "sclp ::= selcollist COMMA",
108899
- /* 123 */ "sclp ::=",
108900
- /* 124 */ "selcollist ::= sclp expr as",
108901
- /* 125 */ "selcollist ::= sclp STAR",
108902
- /* 126 */ "selcollist ::= sclp nm DOT STAR",
108903
- /* 127 */ "as ::= AS nm",
108904
- /* 128 */ "as ::= ids",
108905
- /* 129 */ "as ::=",
108906
- /* 130 */ "from ::=",
108907
- /* 131 */ "from ::= FROM seltablist",
108908
- /* 132 */ "stl_prefix ::= seltablist joinop",
108909
- /* 133 */ "stl_prefix ::=",
108910
- /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
108911
- /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
108912
- /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
108913
- /* 137 */ "dbnm ::=",
108914
- /* 138 */ "dbnm ::= DOT nm",
108915
- /* 139 */ "fullname ::= nm dbnm",
108916
- /* 140 */ "joinop ::= COMMA|JOIN",
108917
- /* 141 */ "joinop ::= JOIN_KW JOIN",
108918
- /* 142 */ "joinop ::= JOIN_KW nm JOIN",
108919
- /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
108920
- /* 144 */ "on_opt ::= ON expr",
108921
- /* 145 */ "on_opt ::=",
108922
- /* 146 */ "indexed_opt ::=",
108923
- /* 147 */ "indexed_opt ::= INDEXED BY nm",
108924
- /* 148 */ "indexed_opt ::= NOT INDEXED",
108925
- /* 149 */ "using_opt ::= USING LP inscollist RP",
108926
- /* 150 */ "using_opt ::=",
108927
- /* 151 */ "orderby_opt ::=",
108928
- /* 152 */ "orderby_opt ::= ORDER BY sortlist",
108929
- /* 153 */ "sortlist ::= sortlist COMMA expr sortorder",
108930
- /* 154 */ "sortlist ::= expr sortorder",
108931
- /* 155 */ "sortorder ::= ASC",
108932
- /* 156 */ "sortorder ::= DESC",
108933
- /* 157 */ "sortorder ::=",
108934
- /* 158 */ "groupby_opt ::=",
108935
- /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
108936
- /* 160 */ "having_opt ::=",
108937
- /* 161 */ "having_opt ::= HAVING expr",
108938
- /* 162 */ "limit_opt ::=",
108939
- /* 163 */ "limit_opt ::= LIMIT expr",
108940
- /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
108941
- /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
108942
- /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
108943
- /* 167 */ "where_opt ::=",
108944
- /* 168 */ "where_opt ::= WHERE expr",
108945
- /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
108946
- /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
108947
- /* 171 */ "setlist ::= nm EQ expr",
108948
- /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
108949
- /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
108950
- /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
108951
- /* 175 */ "insert_cmd ::= INSERT orconf",
108952
- /* 176 */ "insert_cmd ::= REPLACE",
108953
- /* 177 */ "valuelist ::= VALUES LP nexprlist RP",
108954
- /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP",
108955
- /* 179 */ "inscollist_opt ::=",
108956
- /* 180 */ "inscollist_opt ::= LP inscollist RP",
108957
- /* 181 */ "inscollist ::= inscollist COMMA nm",
108958
- /* 182 */ "inscollist ::= nm",
108959
- /* 183 */ "expr ::= term",
108960
- /* 184 */ "expr ::= LP expr RP",
108961
- /* 185 */ "term ::= NULL",
108962
- /* 186 */ "expr ::= id",
108963
- /* 187 */ "expr ::= JOIN_KW",
108964
- /* 188 */ "expr ::= nm DOT nm",
108965
- /* 189 */ "expr ::= nm DOT nm DOT nm",
108966
- /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
108967
- /* 191 */ "term ::= STRING",
108968
- /* 192 */ "expr ::= REGISTER",
108969
- /* 193 */ "expr ::= VARIABLE",
108970
- /* 194 */ "expr ::= expr COLLATE ids",
108971
- /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
108972
- /* 196 */ "expr ::= ID LP distinct exprlist RP",
108973
- /* 197 */ "expr ::= ID LP STAR RP",
108974
- /* 198 */ "term ::= CTIME_KW",
108975
- /* 199 */ "expr ::= expr AND expr",
108976
- /* 200 */ "expr ::= expr OR expr",
108977
- /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
108978
- /* 202 */ "expr ::= expr EQ|NE expr",
108979
- /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
108980
- /* 204 */ "expr ::= expr PLUS|MINUS expr",
108981
- /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
108982
- /* 206 */ "expr ::= expr CONCAT expr",
108983
- /* 207 */ "likeop ::= LIKE_KW",
108984
- /* 208 */ "likeop ::= NOT LIKE_KW",
108985
- /* 209 */ "likeop ::= MATCH",
108986
- /* 210 */ "likeop ::= NOT MATCH",
108987
- /* 211 */ "expr ::= expr likeop expr",
108988
- /* 212 */ "expr ::= expr likeop expr ESCAPE expr",
108989
- /* 213 */ "expr ::= expr ISNULL|NOTNULL",
108990
- /* 214 */ "expr ::= expr NOT NULL",
108991
- /* 215 */ "expr ::= expr IS expr",
108992
- /* 216 */ "expr ::= expr IS NOT expr",
108993
- /* 217 */ "expr ::= NOT expr",
108994
- /* 218 */ "expr ::= BITNOT expr",
108995
- /* 219 */ "expr ::= MINUS expr",
108996
- /* 220 */ "expr ::= PLUS expr",
108997
- /* 221 */ "between_op ::= BETWEEN",
108998
- /* 222 */ "between_op ::= NOT BETWEEN",
108999
- /* 223 */ "expr ::= expr between_op expr AND expr",
109000
- /* 224 */ "in_op ::= IN",
109001
- /* 225 */ "in_op ::= NOT IN",
109002
- /* 226 */ "expr ::= expr in_op LP exprlist RP",
109003
- /* 227 */ "expr ::= LP select RP",
109004
- /* 228 */ "expr ::= expr in_op LP select RP",
109005
- /* 229 */ "expr ::= expr in_op nm dbnm",
109006
- /* 230 */ "expr ::= EXISTS LP select RP",
109007
- /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END",
109008
- /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109009
- /* 233 */ "case_exprlist ::= WHEN expr THEN expr",
109010
- /* 234 */ "case_else ::= ELSE expr",
109011
- /* 235 */ "case_else ::=",
109012
- /* 236 */ "case_operand ::= expr",
109013
- /* 237 */ "case_operand ::=",
109014
- /* 238 */ "exprlist ::= nexprlist",
109015
- /* 239 */ "exprlist ::=",
109016
- /* 240 */ "nexprlist ::= nexprlist COMMA expr",
109017
- /* 241 */ "nexprlist ::= expr",
109018
- /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109019
- /* 243 */ "uniqueflag ::= UNIQUE",
109020
- /* 244 */ "uniqueflag ::=",
109021
- /* 245 */ "idxlist_opt ::=",
109022
- /* 246 */ "idxlist_opt ::= LP idxlist RP",
109023
- /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109024
- /* 248 */ "idxlist ::= nm collate sortorder",
109025
- /* 249 */ "collate ::=",
109026
- /* 250 */ "collate ::= COLLATE ids",
109027
- /* 251 */ "cmd ::= DROP INDEX ifexists fullname",
109028
- /* 252 */ "cmd ::= VACUUM",
109029
- /* 253 */ "cmd ::= VACUUM nm",
109030
- /* 254 */ "cmd ::= PRAGMA nm dbnm",
109031
- /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109032
- /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109033
- /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109034
- /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109035
- /* 259 */ "nmnum ::= plus_num",
109036
- /* 260 */ "nmnum ::= nm",
109037
- /* 261 */ "nmnum ::= ON",
109038
- /* 262 */ "nmnum ::= DELETE",
109039
- /* 263 */ "nmnum ::= DEFAULT",
109040
- /* 264 */ "plus_num ::= PLUS number",
109041
- /* 265 */ "plus_num ::= number",
109042
- /* 266 */ "minus_num ::= MINUS number",
109043
- /* 267 */ "number ::= INTEGER|FLOAT",
109044
- /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109045
- /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109046
- /* 270 */ "trigger_time ::= BEFORE",
109047
- /* 271 */ "trigger_time ::= AFTER",
109048
- /* 272 */ "trigger_time ::= INSTEAD OF",
109049
- /* 273 */ "trigger_time ::=",
109050
- /* 274 */ "trigger_event ::= DELETE|INSERT",
109051
- /* 275 */ "trigger_event ::= UPDATE",
109052
- /* 276 */ "trigger_event ::= UPDATE OF inscollist",
109053
- /* 277 */ "foreach_clause ::=",
109054
- /* 278 */ "foreach_clause ::= FOR EACH ROW",
109055
- /* 279 */ "when_clause ::=",
109056
- /* 280 */ "when_clause ::= WHEN expr",
109057
- /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109058
- /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109059
- /* 283 */ "trnm ::= nm",
109060
- /* 284 */ "trnm ::= nm DOT nm",
109061
- /* 285 */ "tridxby ::=",
109062
- /* 286 */ "tridxby ::= INDEXED BY nm",
109063
- /* 287 */ "tridxby ::= NOT INDEXED",
109064
- /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109065
- /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109066
- /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109067
- /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109068
- /* 292 */ "trigger_cmd ::= select",
109069
- /* 293 */ "expr ::= RAISE LP IGNORE RP",
109070
- /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109071
- /* 295 */ "raisetype ::= ROLLBACK",
109072
- /* 296 */ "raisetype ::= ABORT",
109073
- /* 297 */ "raisetype ::= FAIL",
109074
- /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname",
109075
- /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109076
- /* 300 */ "cmd ::= DETACH database_kw_opt expr",
109077
- /* 301 */ "key_opt ::=",
109078
- /* 302 */ "key_opt ::= KEY expr",
109079
- /* 303 */ "database_kw_opt ::= DATABASE",
109080
- /* 304 */ "database_kw_opt ::=",
109081
- /* 305 */ "cmd ::= REINDEX",
109082
- /* 306 */ "cmd ::= REINDEX nm dbnm",
109083
- /* 307 */ "cmd ::= ANALYZE",
109084
- /* 308 */ "cmd ::= ANALYZE nm dbnm",
109085
- /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109086
- /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109087
- /* 311 */ "add_column_fullname ::= fullname",
109088
- /* 312 */ "kwcolumn_opt ::=",
109089
- /* 313 */ "kwcolumn_opt ::= COLUMNKW",
109090
- /* 314 */ "cmd ::= create_vtab",
109091
- /* 315 */ "cmd ::= create_vtab LP vtabarglist RP",
109092
- /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109093
- /* 317 */ "vtabarglist ::= vtabarg",
109094
- /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109095
- /* 319 */ "vtabarg ::=",
109096
- /* 320 */ "vtabarg ::= vtabarg vtabargtoken",
109097
- /* 321 */ "vtabargtoken ::= ANY",
109098
- /* 322 */ "vtabargtoken ::= lp anylist RP",
109099
- /* 323 */ "lp ::= LP",
109100
- /* 324 */ "anylist ::=",
109101
- /* 325 */ "anylist ::= anylist LP anylist RP",
109102
- /* 326 */ "anylist ::= anylist ANY",
109055
+ /* 90 */ "conslist ::= conslist COMMA cname tcons",
109056
+ /* 91 */ "conslist ::= cname tcons",
109057
+ /* 92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
109058
+ /* 93 */ "tcons ::= UNIQUE LP idxlist RP onconf",
109059
+ /* 94 */ "tcons ::= CHECK LP expr RP onconf",
109060
+ /* 95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
109061
+ /* 96 */ "defer_subclause_opt ::=",
109062
+ /* 97 */ "defer_subclause_opt ::= defer_subclause",
109063
+ /* 98 */ "onconf ::=",
109064
+ /* 99 */ "onconf ::= ON CONFLICT resolvetype",
109065
+ /* 100 */ "orconf ::=",
109066
+ /* 101 */ "orconf ::= OR resolvetype",
109067
+ /* 102 */ "resolvetype ::= raisetype",
109068
+ /* 103 */ "resolvetype ::= IGNORE",
109069
+ /* 104 */ "resolvetype ::= REPLACE",
109070
+ /* 105 */ "cmd ::= DROP TABLE ifexists fullname",
109071
+ /* 106 */ "ifexists ::= IF EXISTS",
109072
+ /* 107 */ "ifexists ::=",
109073
+ /* 108 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
109074
+ /* 109 */ "cmd ::= DROP VIEW ifexists fullname",
109075
+ /* 110 */ "cmd ::= select",
109076
+ /* 111 */ "select ::= oneselect",
109077
+ /* 112 */ "select ::= select multiselect_op oneselect",
109078
+ /* 113 */ "multiselect_op ::= UNION",
109079
+ /* 114 */ "multiselect_op ::= UNION ALL",
109080
+ /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT",
109081
+ /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
109082
+ /* 117 */ "distinct ::= DISTINCT",
109083
+ /* 118 */ "distinct ::= ALL",
109084
+ /* 119 */ "distinct ::=",
109085
+ /* 120 */ "sclp ::= selcollist COMMA",
109086
+ /* 121 */ "sclp ::=",
109087
+ /* 122 */ "selcollist ::= sclp expr as",
109088
+ /* 123 */ "selcollist ::= sclp STAR",
109089
+ /* 124 */ "selcollist ::= sclp nm DOT STAR",
109090
+ /* 125 */ "as ::= AS nm",
109091
+ /* 126 */ "as ::= ids",
109092
+ /* 127 */ "as ::=",
109093
+ /* 128 */ "from ::=",
109094
+ /* 129 */ "from ::= FROM seltablist",
109095
+ /* 130 */ "stl_prefix ::= seltablist joinop",
109096
+ /* 131 */ "stl_prefix ::=",
109097
+ /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
109098
+ /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
109099
+ /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
109100
+ /* 135 */ "dbnm ::=",
109101
+ /* 136 */ "dbnm ::= DOT nm",
109102
+ /* 137 */ "fullname ::= nm dbnm",
109103
+ /* 138 */ "joinop ::= COMMA|JOIN",
109104
+ /* 139 */ "joinop ::= JOIN_KW JOIN",
109105
+ /* 140 */ "joinop ::= JOIN_KW nm JOIN",
109106
+ /* 141 */ "joinop ::= JOIN_KW nm nm JOIN",
109107
+ /* 142 */ "on_opt ::= ON expr",
109108
+ /* 143 */ "on_opt ::=",
109109
+ /* 144 */ "indexed_opt ::=",
109110
+ /* 145 */ "indexed_opt ::= INDEXED BY nm",
109111
+ /* 146 */ "indexed_opt ::= NOT INDEXED",
109112
+ /* 147 */ "using_opt ::= USING LP inscollist RP",
109113
+ /* 148 */ "using_opt ::=",
109114
+ /* 149 */ "orderby_opt ::=",
109115
+ /* 150 */ "orderby_opt ::= ORDER BY sortlist",
109116
+ /* 151 */ "sortlist ::= sortlist COMMA expr sortorder",
109117
+ /* 152 */ "sortlist ::= expr sortorder",
109118
+ /* 153 */ "sortorder ::= ASC",
109119
+ /* 154 */ "sortorder ::= DESC",
109120
+ /* 155 */ "sortorder ::=",
109121
+ /* 156 */ "groupby_opt ::=",
109122
+ /* 157 */ "groupby_opt ::= GROUP BY nexprlist",
109123
+ /* 158 */ "having_opt ::=",
109124
+ /* 159 */ "having_opt ::= HAVING expr",
109125
+ /* 160 */ "limit_opt ::=",
109126
+ /* 161 */ "limit_opt ::= LIMIT expr",
109127
+ /* 162 */ "limit_opt ::= LIMIT expr OFFSET expr",
109128
+ /* 163 */ "limit_opt ::= LIMIT expr COMMA expr",
109129
+ /* 164 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
109130
+ /* 165 */ "where_opt ::=",
109131
+ /* 166 */ "where_opt ::= WHERE expr",
109132
+ /* 167 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
109133
+ /* 168 */ "setlist ::= setlist COMMA nm EQ expr",
109134
+ /* 169 */ "setlist ::= nm EQ expr",
109135
+ /* 170 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
109136
+ /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
109137
+ /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
109138
+ /* 173 */ "insert_cmd ::= INSERT orconf",
109139
+ /* 174 */ "insert_cmd ::= REPLACE",
109140
+ /* 175 */ "valuelist ::= VALUES LP nexprlist RP",
109141
+ /* 176 */ "valuelist ::= valuelist COMMA LP exprlist RP",
109142
+ /* 177 */ "inscollist_opt ::=",
109143
+ /* 178 */ "inscollist_opt ::= LP inscollist RP",
109144
+ /* 179 */ "inscollist ::= inscollist COMMA nm",
109145
+ /* 180 */ "inscollist ::= nm",
109146
+ /* 181 */ "expr ::= term",
109147
+ /* 182 */ "expr ::= LP expr RP",
109148
+ /* 183 */ "term ::= NULL",
109149
+ /* 184 */ "expr ::= id",
109150
+ /* 185 */ "expr ::= JOIN_KW",
109151
+ /* 186 */ "expr ::= nm DOT nm",
109152
+ /* 187 */ "expr ::= nm DOT nm DOT nm",
109153
+ /* 188 */ "term ::= INTEGER|FLOAT|BLOB",
109154
+ /* 189 */ "term ::= STRING",
109155
+ /* 190 */ "expr ::= REGISTER",
109156
+ /* 191 */ "expr ::= VARIABLE",
109157
+ /* 192 */ "expr ::= expr COLLATE ids",
109158
+ /* 193 */ "expr ::= CAST LP expr AS typetoken RP",
109159
+ /* 194 */ "expr ::= ID LP distinct exprlist RP",
109160
+ /* 195 */ "expr ::= ID LP STAR RP",
109161
+ /* 196 */ "term ::= CTIME_KW",
109162
+ /* 197 */ "expr ::= expr AND expr",
109163
+ /* 198 */ "expr ::= expr OR expr",
109164
+ /* 199 */ "expr ::= expr LT|GT|GE|LE expr",
109165
+ /* 200 */ "expr ::= expr EQ|NE expr",
109166
+ /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
109167
+ /* 202 */ "expr ::= expr PLUS|MINUS expr",
109168
+ /* 203 */ "expr ::= expr STAR|SLASH|REM expr",
109169
+ /* 204 */ "expr ::= expr CONCAT expr",
109170
+ /* 205 */ "likeop ::= LIKE_KW",
109171
+ /* 206 */ "likeop ::= NOT LIKE_KW",
109172
+ /* 207 */ "likeop ::= MATCH",
109173
+ /* 208 */ "likeop ::= NOT MATCH",
109174
+ /* 209 */ "expr ::= expr likeop expr",
109175
+ /* 210 */ "expr ::= expr likeop expr ESCAPE expr",
109176
+ /* 211 */ "expr ::= expr ISNULL|NOTNULL",
109177
+ /* 212 */ "expr ::= expr NOT NULL",
109178
+ /* 213 */ "expr ::= expr IS expr",
109179
+ /* 214 */ "expr ::= expr IS NOT expr",
109180
+ /* 215 */ "expr ::= NOT expr",
109181
+ /* 216 */ "expr ::= BITNOT expr",
109182
+ /* 217 */ "expr ::= MINUS expr",
109183
+ /* 218 */ "expr ::= PLUS expr",
109184
+ /* 219 */ "between_op ::= BETWEEN",
109185
+ /* 220 */ "between_op ::= NOT BETWEEN",
109186
+ /* 221 */ "expr ::= expr between_op expr AND expr",
109187
+ /* 222 */ "in_op ::= IN",
109188
+ /* 223 */ "in_op ::= NOT IN",
109189
+ /* 224 */ "expr ::= expr in_op LP exprlist RP",
109190
+ /* 225 */ "expr ::= LP select RP",
109191
+ /* 226 */ "expr ::= expr in_op LP select RP",
109192
+ /* 227 */ "expr ::= expr in_op nm dbnm",
109193
+ /* 228 */ "expr ::= EXISTS LP select RP",
109194
+ /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END",
109195
+ /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109196
+ /* 231 */ "case_exprlist ::= WHEN expr THEN expr",
109197
+ /* 232 */ "case_else ::= ELSE expr",
109198
+ /* 233 */ "case_else ::=",
109199
+ /* 234 */ "case_operand ::= expr",
109200
+ /* 235 */ "case_operand ::=",
109201
+ /* 236 */ "exprlist ::= nexprlist",
109202
+ /* 237 */ "exprlist ::=",
109203
+ /* 238 */ "nexprlist ::= nexprlist COMMA expr",
109204
+ /* 239 */ "nexprlist ::= expr",
109205
+ /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109206
+ /* 241 */ "uniqueflag ::= UNIQUE",
109207
+ /* 242 */ "uniqueflag ::=",
109208
+ /* 243 */ "idxlist_opt ::=",
109209
+ /* 244 */ "idxlist_opt ::= LP idxlist RP",
109210
+ /* 245 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109211
+ /* 246 */ "idxlist ::= nm collate sortorder",
109212
+ /* 247 */ "collate ::=",
109213
+ /* 248 */ "collate ::= COLLATE ids",
109214
+ /* 249 */ "cmd ::= DROP INDEX ifexists fullname",
109215
+ /* 250 */ "cmd ::= VACUUM",
109216
+ /* 251 */ "cmd ::= VACUUM nm",
109217
+ /* 252 */ "cmd ::= PRAGMA nm dbnm",
109218
+ /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109219
+ /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109220
+ /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109221
+ /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109222
+ /* 257 */ "nmnum ::= plus_num",
109223
+ /* 258 */ "nmnum ::= nm",
109224
+ /* 259 */ "nmnum ::= ON",
109225
+ /* 260 */ "nmnum ::= DELETE",
109226
+ /* 261 */ "nmnum ::= DEFAULT",
109227
+ /* 262 */ "plus_num ::= PLUS number",
109228
+ /* 263 */ "plus_num ::= number",
109229
+ /* 264 */ "minus_num ::= MINUS number",
109230
+ /* 265 */ "number ::= INTEGER|FLOAT",
109231
+ /* 266 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109232
+ /* 267 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109233
+ /* 268 */ "trigger_time ::= BEFORE",
109234
+ /* 269 */ "trigger_time ::= AFTER",
109235
+ /* 270 */ "trigger_time ::= INSTEAD OF",
109236
+ /* 271 */ "trigger_time ::=",
109237
+ /* 272 */ "trigger_event ::= DELETE|INSERT",
109238
+ /* 273 */ "trigger_event ::= UPDATE",
109239
+ /* 274 */ "trigger_event ::= UPDATE OF inscollist",
109240
+ /* 275 */ "foreach_clause ::=",
109241
+ /* 276 */ "foreach_clause ::= FOR EACH ROW",
109242
+ /* 277 */ "when_clause ::=",
109243
+ /* 278 */ "when_clause ::= WHEN expr",
109244
+ /* 279 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109245
+ /* 280 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109246
+ /* 281 */ "trnm ::= nm",
109247
+ /* 282 */ "trnm ::= nm DOT nm",
109248
+ /* 283 */ "tridxby ::=",
109249
+ /* 284 */ "tridxby ::= INDEXED BY nm",
109250
+ /* 285 */ "tridxby ::= NOT INDEXED",
109251
+ /* 286 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109252
+ /* 287 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109253
+ /* 288 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109254
+ /* 289 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109255
+ /* 290 */ "trigger_cmd ::= select",
109256
+ /* 291 */ "expr ::= RAISE LP IGNORE RP",
109257
+ /* 292 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109258
+ /* 293 */ "raisetype ::= ROLLBACK",
109259
+ /* 294 */ "raisetype ::= ABORT",
109260
+ /* 295 */ "raisetype ::= FAIL",
109261
+ /* 296 */ "cmd ::= DROP TRIGGER ifexists fullname",
109262
+ /* 297 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109263
+ /* 298 */ "cmd ::= DETACH database_kw_opt expr",
109264
+ /* 299 */ "key_opt ::=",
109265
+ /* 300 */ "key_opt ::= KEY expr",
109266
+ /* 301 */ "database_kw_opt ::= DATABASE",
109267
+ /* 302 */ "database_kw_opt ::=",
109268
+ /* 303 */ "cmd ::= REINDEX",
109269
+ /* 304 */ "cmd ::= REINDEX nm dbnm",
109270
+ /* 305 */ "cmd ::= ANALYZE",
109271
+ /* 306 */ "cmd ::= ANALYZE nm dbnm",
109272
+ /* 307 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109273
+ /* 308 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109274
+ /* 309 */ "add_column_fullname ::= fullname",
109275
+ /* 310 */ "kwcolumn_opt ::=",
109276
+ /* 311 */ "kwcolumn_opt ::= COLUMNKW",
109277
+ /* 312 */ "cmd ::= create_vtab",
109278
+ /* 313 */ "cmd ::= create_vtab LP vtabarglist RP",
109279
+ /* 314 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109280
+ /* 315 */ "vtabarglist ::= vtabarg",
109281
+ /* 316 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109282
+ /* 317 */ "vtabarg ::=",
109283
+ /* 318 */ "vtabarg ::= vtabarg vtabargtoken",
109284
+ /* 319 */ "vtabargtoken ::= ANY",
109285
+ /* 320 */ "vtabargtoken ::= lp anylist RP",
109286
+ /* 321 */ "lp ::= LP",
109287
+ /* 322 */ "anylist ::=",
109288
+ /* 323 */ "anylist ::= anylist LP anylist RP",
109289
+ /* 324 */ "anylist ::= anylist ANY",
109103109290
};
109104109291
#endif /* NDEBUG */
109105109292
109106109293
109107109294
#if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109543109730
{ 167, 6 },
109544109731
{ 168, 1 },
109545109732
{ 168, 2 },
109546109733
{ 169, 1 },
109547109734
{ 169, 1 },
109548
- { 164, 2 },
109735
+ { 164, 3 },
109549109736
{ 164, 0 },
109550
- { 172, 3 },
109551
- { 172, 1 },
109737
+ { 172, 2 },
109738
+ { 172, 0 },
109552109739
{ 173, 2 },
109553109740
{ 173, 4 },
109554109741
{ 173, 3 },
109555109742
{ 173, 3 },
109556109743
{ 173, 2 },
@@ -109580,14 +109767,12 @@
109580109767
{ 184, 0 },
109581109768
{ 184, 2 },
109582109769
{ 184, 2 },
109583109770
{ 159, 0 },
109584109771
{ 159, 2 },
109585
- { 185, 3 },
109772
+ { 185, 4 },
109586109773
{ 185, 2 },
109587
- { 185, 1 },
109588
- { 186, 2 },
109589109774
{ 186, 7 },
109590109775
{ 186, 5 },
109591109776
{ 186, 5 },
109592109777
{ 186, 10 },
109593109778
{ 188, 0 },
@@ -109892,12 +110077,12 @@
109892110077
{yygotominor.yy392 = TK_DEFERRED;}
109893110078
break;
109894110079
case 14: /* transtype ::= DEFERRED */
109895110080
case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
109896110081
case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
109897
- case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
109898
- case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
110082
+ case 113: /* multiselect_op ::= UNION */ yytestcase(yyruleno==113);
110083
+ case 115: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==115);
109899110084
{yygotominor.yy392 = yymsp[0].major;}
109900110085
break;
109901110086
case 17: /* cmd ::= COMMIT trans_opt */
109902110087
case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
109903110088
{sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
109935110120
case 31: /* temp ::= */ yytestcase(yyruleno==31);
109936110121
case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
109937110122
case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
109938110123
case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
109939110124
case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
109940
- case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
109941
- case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
109942
- case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
109943
- case 121: /* distinct ::= */ yytestcase(yyruleno==121);
109944
- case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221);
109945
- case 224: /* in_op ::= IN */ yytestcase(yyruleno==224);
110125
+ case 96: /* defer_subclause_opt ::= */ yytestcase(yyruleno==96);
110126
+ case 107: /* ifexists ::= */ yytestcase(yyruleno==107);
110127
+ case 118: /* distinct ::= ALL */ yytestcase(yyruleno==118);
110128
+ case 119: /* distinct ::= */ yytestcase(yyruleno==119);
110129
+ case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219);
110130
+ case 222: /* in_op ::= IN */ yytestcase(yyruleno==222);
109946110131
{yygotominor.yy392 = 0;}
109947110132
break;
109948110133
case 29: /* ifnotexists ::= IF NOT EXISTS */
109949110134
case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
109950110135
case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
109951110136
case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
109952
- case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
109953
- case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
109954
- case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222);
109955
- case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225);
110137
+ case 106: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==106);
110138
+ case 117: /* distinct ::= DISTINCT */ yytestcase(yyruleno==117);
110139
+ case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220);
110140
+ case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223);
109956110141
{yygotominor.yy392 = 1;}
109957110142
break;
109958110143
case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
109959110144
{
109960110145
sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
109984110169
case 41: /* nm ::= id */ yytestcase(yyruleno==41);
109985110170
case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
109986110171
case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
109987110172
case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
109988110173
case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
109989
- case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
109990
- case 128: /* as ::= ids */ yytestcase(yyruleno==128);
109991
- case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
109992
- case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
109993
- case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250);
109994
- case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259);
109995
- case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260);
109996
- case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261);
109997
- case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262);
109998
- case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263);
109999
- case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264);
110000
- case 265: /* plus_num ::= number */ yytestcase(yyruleno==265);
110001
- case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
110002
- case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
110003
- case 283: /* trnm ::= nm */ yytestcase(yyruleno==283);
110174
+ case 125: /* as ::= AS nm */ yytestcase(yyruleno==125);
110175
+ case 126: /* as ::= ids */ yytestcase(yyruleno==126);
110176
+ case 136: /* dbnm ::= DOT nm */ yytestcase(yyruleno==136);
110177
+ case 145: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==145);
110178
+ case 248: /* collate ::= COLLATE ids */ yytestcase(yyruleno==248);
110179
+ case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257);
110180
+ case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258);
110181
+ case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259);
110182
+ case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260);
110183
+ case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261);
110184
+ case 262: /* plus_num ::= PLUS number */ yytestcase(yyruleno==262);
110185
+ case 263: /* plus_num ::= number */ yytestcase(yyruleno==263);
110186
+ case 264: /* minus_num ::= MINUS number */ yytestcase(yyruleno==264);
110187
+ case 265: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==265);
110188
+ case 281: /* trnm ::= nm */ yytestcase(yyruleno==281);
110004110189
{yygotominor.yy0 = yymsp[0].minor.yy0;}
110005110190
break;
110006110191
case 45: /* type ::= typetoken */
110007110192
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110008110193
break;
@@ -110018,10 +110203,16 @@
110018110203
yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110019110204
}
110020110205
break;
110021110206
case 50: /* typename ::= typename ids */
110022110207
{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
110208
+ break;
110209
+ case 55: /* cname ::= CONSTRAINT nm */
110210
+{pParse->constraintName = yymsp[0].minor.yy0;}
110211
+ break;
110212
+ case 56: /* cname ::= */
110213
+{pParse->constraintName.n = 0;}
110023110214
break;
110024110215
case 57: /* ccons ::= DEFAULT term */
110025110216
case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110026110217
{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110027110218
break;
@@ -110095,80 +110286,80 @@
110095110286
break;
110096110287
case 82: /* refact ::= NO ACTION */
110097110288
{ yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110098110289
break;
110099110290
case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110100
- case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
110101
- case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
110102
- case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
110291
+ case 97: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==97);
110292
+ case 99: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==99);
110293
+ case 102: /* resolvetype ::= raisetype */ yytestcase(yyruleno==102);
110103110294
{yygotominor.yy392 = yymsp[0].minor.yy392;}
110104110295
break;
110105110296
case 88: /* conslist_opt ::= */
110106110297
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110107110298
break;
110108110299
case 89: /* conslist_opt ::= COMMA conslist */
110109110300
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
110110110301
break;
110111
- case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110302
+ case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110112110303
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110113110304
break;
110114
- case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
110305
+ case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */
110115110306
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110116110307
break;
110117
- case 96: /* tcons ::= CHECK LP expr RP onconf */
110308
+ case 94: /* tcons ::= CHECK LP expr RP onconf */
110118110309
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110119110310
break;
110120
- case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110311
+ case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110121110312
{
110122110313
sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110123110314
sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110124110315
}
110125110316
break;
110126
- case 100: /* onconf ::= */
110317
+ case 98: /* onconf ::= */
110127110318
{yygotominor.yy392 = OE_Default;}
110128110319
break;
110129
- case 102: /* orconf ::= */
110320
+ case 100: /* orconf ::= */
110130110321
{yygotominor.yy258 = OE_Default;}
110131110322
break;
110132
- case 103: /* orconf ::= OR resolvetype */
110323
+ case 101: /* orconf ::= OR resolvetype */
110133110324
{yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110134110325
break;
110135
- case 105: /* resolvetype ::= IGNORE */
110326
+ case 103: /* resolvetype ::= IGNORE */
110136110327
{yygotominor.yy392 = OE_Ignore;}
110137110328
break;
110138
- case 106: /* resolvetype ::= REPLACE */
110329
+ case 104: /* resolvetype ::= REPLACE */
110139110330
{yygotominor.yy392 = OE_Replace;}
110140110331
break;
110141
- case 107: /* cmd ::= DROP TABLE ifexists fullname */
110332
+ case 105: /* cmd ::= DROP TABLE ifexists fullname */
110142110333
{
110143110334
sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110144110335
}
110145110336
break;
110146
- case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110337
+ case 108: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110147110338
{
110148110339
sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110149110340
}
110150110341
break;
110151
- case 111: /* cmd ::= DROP VIEW ifexists fullname */
110342
+ case 109: /* cmd ::= DROP VIEW ifexists fullname */
110152110343
{
110153110344
sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110154110345
}
110155110346
break;
110156
- case 112: /* cmd ::= select */
110347
+ case 110: /* cmd ::= select */
110157110348
{
110158110349
SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110159110350
sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110160110351
sqlite3ExplainBegin(pParse->pVdbe);
110161110352
sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110162110353
sqlite3ExplainFinish(pParse->pVdbe);
110163110354
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110164110355
}
110165110356
break;
110166
- case 113: /* select ::= oneselect */
110357
+ case 111: /* select ::= oneselect */
110167110358
{yygotominor.yy159 = yymsp[0].minor.yy159;}
110168110359
break;
110169
- case 114: /* select ::= select multiselect_op oneselect */
110360
+ case 112: /* select ::= select multiselect_op oneselect */
110170110361
{
110171110362
if( yymsp[0].minor.yy159 ){
110172110363
yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110173110364
yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110174110365
}else{
@@ -110175,83 +110366,83 @@
110175110366
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110176110367
}
110177110368
yygotominor.yy159 = yymsp[0].minor.yy159;
110178110369
}
110179110370
break;
110180
- case 116: /* multiselect_op ::= UNION ALL */
110371
+ case 114: /* multiselect_op ::= UNION ALL */
110181110372
{yygotominor.yy392 = TK_ALL;}
110182110373
break;
110183
- case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110374
+ case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110184110375
{
110185110376
yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110186110377
}
110187110378
break;
110188
- case 122: /* sclp ::= selcollist COMMA */
110189
- case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246);
110379
+ case 120: /* sclp ::= selcollist COMMA */
110380
+ case 244: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==244);
110190110381
{yygotominor.yy442 = yymsp[-1].minor.yy442;}
110191110382
break;
110192
- case 123: /* sclp ::= */
110193
- case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
110194
- case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
110195
- case 239: /* exprlist ::= */ yytestcase(yyruleno==239);
110196
- case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245);
110383
+ case 121: /* sclp ::= */
110384
+ case 149: /* orderby_opt ::= */ yytestcase(yyruleno==149);
110385
+ case 156: /* groupby_opt ::= */ yytestcase(yyruleno==156);
110386
+ case 237: /* exprlist ::= */ yytestcase(yyruleno==237);
110387
+ case 243: /* idxlist_opt ::= */ yytestcase(yyruleno==243);
110197110388
{yygotominor.yy442 = 0;}
110198110389
break;
110199
- case 124: /* selcollist ::= sclp expr as */
110390
+ case 122: /* selcollist ::= sclp expr as */
110200110391
{
110201110392
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110202110393
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110203110394
sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110204110395
}
110205110396
break;
110206
- case 125: /* selcollist ::= sclp STAR */
110397
+ case 123: /* selcollist ::= sclp STAR */
110207110398
{
110208110399
Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110209110400
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110210110401
}
110211110402
break;
110212
- case 126: /* selcollist ::= sclp nm DOT STAR */
110403
+ case 124: /* selcollist ::= sclp nm DOT STAR */
110213110404
{
110214110405
Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110215110406
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110216110407
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110217110408
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110218110409
}
110219110410
break;
110220
- case 129: /* as ::= */
110411
+ case 127: /* as ::= */
110221110412
{yygotominor.yy0.n = 0;}
110222110413
break;
110223
- case 130: /* from ::= */
110414
+ case 128: /* from ::= */
110224110415
{yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110225110416
break;
110226
- case 131: /* from ::= FROM seltablist */
110417
+ case 129: /* from ::= FROM seltablist */
110227110418
{
110228110419
yygotominor.yy347 = yymsp[0].minor.yy347;
110229110420
sqlite3SrcListShiftJoinType(yygotominor.yy347);
110230110421
}
110231110422
break;
110232
- case 132: /* stl_prefix ::= seltablist joinop */
110423
+ case 130: /* stl_prefix ::= seltablist joinop */
110233110424
{
110234110425
yygotominor.yy347 = yymsp[-1].minor.yy347;
110235110426
if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110236110427
}
110237110428
break;
110238
- case 133: /* stl_prefix ::= */
110429
+ case 131: /* stl_prefix ::= */
110239110430
{yygotominor.yy347 = 0;}
110240110431
break;
110241
- case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110432
+ case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110242110433
{
110243110434
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110244110435
sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110245110436
}
110246110437
break;
110247
- case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110438
+ case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110248110439
{
110249110440
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110250110441
}
110251110442
break;
110252
- case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110443
+ case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110253110444
{
110254110445
if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110255110446
yygotominor.yy347 = yymsp[-4].minor.yy347;
110256110447
}else{
110257110448
Select *pSubquery;
@@ -110259,137 +110450,137 @@
110259110450
pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110260110451
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110261110452
}
110262110453
}
110263110454
break;
110264
- case 137: /* dbnm ::= */
110265
- case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
110455
+ case 135: /* dbnm ::= */
110456
+ case 144: /* indexed_opt ::= */ yytestcase(yyruleno==144);
110266110457
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110267110458
break;
110268
- case 139: /* fullname ::= nm dbnm */
110459
+ case 137: /* fullname ::= nm dbnm */
110269110460
{yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110270110461
break;
110271
- case 140: /* joinop ::= COMMA|JOIN */
110462
+ case 138: /* joinop ::= COMMA|JOIN */
110272110463
{ yygotominor.yy392 = JT_INNER; }
110273110464
break;
110274
- case 141: /* joinop ::= JOIN_KW JOIN */
110465
+ case 139: /* joinop ::= JOIN_KW JOIN */
110275110466
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110276110467
break;
110277
- case 142: /* joinop ::= JOIN_KW nm JOIN */
110468
+ case 140: /* joinop ::= JOIN_KW nm JOIN */
110278110469
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110279110470
break;
110280
- case 143: /* joinop ::= JOIN_KW nm nm JOIN */
110471
+ case 141: /* joinop ::= JOIN_KW nm nm JOIN */
110281110472
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110282110473
break;
110283
- case 144: /* on_opt ::= ON expr */
110284
- case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
110285
- case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
110286
- case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234);
110287
- case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236);
110474
+ case 142: /* on_opt ::= ON expr */
110475
+ case 159: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==159);
110476
+ case 166: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==166);
110477
+ case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232);
110478
+ case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234);
110288110479
{yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110289110480
break;
110290
- case 145: /* on_opt ::= */
110291
- case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
110292
- case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
110293
- case 235: /* case_else ::= */ yytestcase(yyruleno==235);
110294
- case 237: /* case_operand ::= */ yytestcase(yyruleno==237);
110481
+ case 143: /* on_opt ::= */
110482
+ case 158: /* having_opt ::= */ yytestcase(yyruleno==158);
110483
+ case 165: /* where_opt ::= */ yytestcase(yyruleno==165);
110484
+ case 233: /* case_else ::= */ yytestcase(yyruleno==233);
110485
+ case 235: /* case_operand ::= */ yytestcase(yyruleno==235);
110295110486
{yygotominor.yy122 = 0;}
110296110487
break;
110297
- case 148: /* indexed_opt ::= NOT INDEXED */
110488
+ case 146: /* indexed_opt ::= NOT INDEXED */
110298110489
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110299110490
break;
110300
- case 149: /* using_opt ::= USING LP inscollist RP */
110301
- case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
110491
+ case 147: /* using_opt ::= USING LP inscollist RP */
110492
+ case 178: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==178);
110302110493
{yygotominor.yy180 = yymsp[-1].minor.yy180;}
110303110494
break;
110304
- case 150: /* using_opt ::= */
110305
- case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
110495
+ case 148: /* using_opt ::= */
110496
+ case 177: /* inscollist_opt ::= */ yytestcase(yyruleno==177);
110306110497
{yygotominor.yy180 = 0;}
110307110498
break;
110308
- case 152: /* orderby_opt ::= ORDER BY sortlist */
110309
- case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
110310
- case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238);
110499
+ case 150: /* orderby_opt ::= ORDER BY sortlist */
110500
+ case 157: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==157);
110501
+ case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236);
110311110502
{yygotominor.yy442 = yymsp[0].minor.yy442;}
110312110503
break;
110313
- case 153: /* sortlist ::= sortlist COMMA expr sortorder */
110504
+ case 151: /* sortlist ::= sortlist COMMA expr sortorder */
110314110505
{
110315110506
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110316110507
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110317110508
}
110318110509
break;
110319
- case 154: /* sortlist ::= expr sortorder */
110510
+ case 152: /* sortlist ::= expr sortorder */
110320110511
{
110321110512
yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110322110513
if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110323110514
}
110324110515
break;
110325
- case 155: /* sortorder ::= ASC */
110326
- case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
110516
+ case 153: /* sortorder ::= ASC */
110517
+ case 155: /* sortorder ::= */ yytestcase(yyruleno==155);
110327110518
{yygotominor.yy392 = SQLITE_SO_ASC;}
110328110519
break;
110329
- case 156: /* sortorder ::= DESC */
110520
+ case 154: /* sortorder ::= DESC */
110330110521
{yygotominor.yy392 = SQLITE_SO_DESC;}
110331110522
break;
110332
- case 162: /* limit_opt ::= */
110523
+ case 160: /* limit_opt ::= */
110333110524
{yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110334110525
break;
110335
- case 163: /* limit_opt ::= LIMIT expr */
110526
+ case 161: /* limit_opt ::= LIMIT expr */
110336110527
{yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110337110528
break;
110338
- case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
110529
+ case 162: /* limit_opt ::= LIMIT expr OFFSET expr */
110339110530
{yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110340110531
break;
110341
- case 165: /* limit_opt ::= LIMIT expr COMMA expr */
110532
+ case 163: /* limit_opt ::= LIMIT expr COMMA expr */
110342110533
{yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110343110534
break;
110344
- case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110535
+ case 164: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110345110536
{
110346110537
sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110347110538
sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110348110539
}
110349110540
break;
110350
- case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110541
+ case 167: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110351110542
{
110352110543
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110353110544
sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110354110545
sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110355110546
}
110356110547
break;
110357
- case 170: /* setlist ::= setlist COMMA nm EQ expr */
110548
+ case 168: /* setlist ::= setlist COMMA nm EQ expr */
110358110549
{
110359110550
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110360110551
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110361110552
}
110362110553
break;
110363
- case 171: /* setlist ::= nm EQ expr */
110554
+ case 169: /* setlist ::= nm EQ expr */
110364110555
{
110365110556
yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110366110557
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110367110558
}
110368110559
break;
110369
- case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110560
+ case 170: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110370110561
{sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110371110562
break;
110372
- case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110563
+ case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110373110564
{sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110374110565
break;
110375
- case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110566
+ case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110376110567
{sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110377110568
break;
110378
- case 175: /* insert_cmd ::= INSERT orconf */
110569
+ case 173: /* insert_cmd ::= INSERT orconf */
110379110570
{yygotominor.yy258 = yymsp[0].minor.yy258;}
110380110571
break;
110381
- case 176: /* insert_cmd ::= REPLACE */
110572
+ case 174: /* insert_cmd ::= REPLACE */
110382110573
{yygotominor.yy258 = OE_Replace;}
110383110574
break;
110384
- case 177: /* valuelist ::= VALUES LP nexprlist RP */
110575
+ case 175: /* valuelist ::= VALUES LP nexprlist RP */
110385110576
{
110386110577
yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110387110578
yygotominor.yy487.pSelect = 0;
110388110579
}
110389110580
break;
110390
- case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */
110581
+ case 176: /* valuelist ::= valuelist COMMA LP exprlist RP */
110391110582
{
110392110583
Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110393110584
if( yymsp[-4].minor.yy487.pList ){
110394110585
yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110395110586
yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110406110597
pRight->pPrior->selFlags |= SF_Values;
110407110598
yygotominor.yy487.pSelect = pRight;
110408110599
}
110409110600
}
110410110601
break;
110411
- case 181: /* inscollist ::= inscollist COMMA nm */
110602
+ case 179: /* inscollist ::= inscollist COMMA nm */
110412110603
{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110413110604
break;
110414
- case 182: /* inscollist ::= nm */
110605
+ case 180: /* inscollist ::= nm */
110415110606
{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110416110607
break;
110417
- case 183: /* expr ::= term */
110608
+ case 181: /* expr ::= term */
110418110609
{yygotominor.yy342 = yymsp[0].minor.yy342;}
110419110610
break;
110420
- case 184: /* expr ::= LP expr RP */
110611
+ case 182: /* expr ::= LP expr RP */
110421110612
{yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110422110613
break;
110423
- case 185: /* term ::= NULL */
110424
- case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
110425
- case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
110614
+ case 183: /* term ::= NULL */
110615
+ case 188: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==188);
110616
+ case 189: /* term ::= STRING */ yytestcase(yyruleno==189);
110426110617
{spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110427110618
break;
110428
- case 186: /* expr ::= id */
110429
- case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
110619
+ case 184: /* expr ::= id */
110620
+ case 185: /* expr ::= JOIN_KW */ yytestcase(yyruleno==185);
110430110621
{spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110431110622
break;
110432
- case 188: /* expr ::= nm DOT nm */
110623
+ case 186: /* expr ::= nm DOT nm */
110433110624
{
110434110625
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110435110626
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110436110627
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110437110628
spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110438110629
}
110439110630
break;
110440
- case 189: /* expr ::= nm DOT nm DOT nm */
110631
+ case 187: /* expr ::= nm DOT nm DOT nm */
110441110632
{
110442110633
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110443110634
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110444110635
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110445110636
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110446110637
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110447110638
spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110448110639
}
110449110640
break;
110450
- case 192: /* expr ::= REGISTER */
110641
+ case 190: /* expr ::= REGISTER */
110451110642
{
110452110643
/* When doing a nested parse, one can include terms in an expression
110453110644
** that look like this: #1 #2 ... These terms refer to registers
110454110645
** in the virtual machine. #N is the N-th register. */
110455110646
if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110460110651
if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110461110652
}
110462110653
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110463110654
}
110464110655
break;
110465
- case 193: /* expr ::= VARIABLE */
110656
+ case 191: /* expr ::= VARIABLE */
110466110657
{
110467110658
spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110468110659
sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110469110660
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110470110661
}
110471110662
break;
110472
- case 194: /* expr ::= expr COLLATE ids */
110663
+ case 192: /* expr ::= expr COLLATE ids */
110473110664
{
110474110665
yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110475110666
yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110476110667
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110477110668
}
110478110669
break;
110479
- case 195: /* expr ::= CAST LP expr AS typetoken RP */
110670
+ case 193: /* expr ::= CAST LP expr AS typetoken RP */
110480110671
{
110481110672
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110482110673
spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110483110674
}
110484110675
break;
110485
- case 196: /* expr ::= ID LP distinct exprlist RP */
110676
+ case 194: /* expr ::= ID LP distinct exprlist RP */
110486110677
{
110487110678
if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110488110679
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110489110680
}
110490110681
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110492110683
if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110493110684
yygotominor.yy342.pExpr->flags |= EP_Distinct;
110494110685
}
110495110686
}
110496110687
break;
110497
- case 197: /* expr ::= ID LP STAR RP */
110688
+ case 195: /* expr ::= ID LP STAR RP */
110498110689
{
110499110690
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110500110691
spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110501110692
}
110502110693
break;
110503
- case 198: /* term ::= CTIME_KW */
110694
+ case 196: /* term ::= CTIME_KW */
110504110695
{
110505110696
/* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110506110697
** treated as functions that return constants */
110507110698
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110508110699
if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110509110700
yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110510110701
}
110511110702
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110512110703
}
110513110704
break;
110514
- case 199: /* expr ::= expr AND expr */
110515
- case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
110516
- case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
110517
- case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
110518
- case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
110519
- case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
110520
- case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
110521
- case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
110705
+ case 197: /* expr ::= expr AND expr */
110706
+ case 198: /* expr ::= expr OR expr */ yytestcase(yyruleno==198);
110707
+ case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
110708
+ case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
110709
+ case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
110710
+ case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
110711
+ case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
110712
+ case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
110522110713
{spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110523110714
break;
110524
- case 207: /* likeop ::= LIKE_KW */
110525
- case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
110526
-{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 0;}
110527
- break;
110528
- case 208: /* likeop ::= NOT LIKE_KW */
110529
- case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
110530
-{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 1;}
110531
- break;
110532
- case 211: /* expr ::= expr likeop expr */
110715
+ case 205: /* likeop ::= LIKE_KW */
110716
+ case 207: /* likeop ::= MATCH */ yytestcase(yyruleno==207);
110717
+{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;}
110718
+ break;
110719
+ case 206: /* likeop ::= NOT LIKE_KW */
110720
+ case 208: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==208);
110721
+{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;}
110722
+ break;
110723
+ case 209: /* expr ::= expr likeop expr */
110533110724
{
110534110725
ExprList *pList;
110535110726
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110536110727
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110537110728
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110538
- if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110729
+ if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110539110730
yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110540110731
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110541110732
if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110542110733
}
110543110734
break;
110544
- case 212: /* expr ::= expr likeop expr ESCAPE expr */
110735
+ case 210: /* expr ::= expr likeop expr ESCAPE expr */
110545110736
{
110546110737
ExprList *pList;
110547110738
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110548110739
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110549110740
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110550110741
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110551
- if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110742
+ if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110552110743
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110553110744
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110554110745
if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110555110746
}
110556110747
break;
110557
- case 213: /* expr ::= expr ISNULL|NOTNULL */
110748
+ case 211: /* expr ::= expr ISNULL|NOTNULL */
110558110749
{spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110559110750
break;
110560
- case 214: /* expr ::= expr NOT NULL */
110751
+ case 212: /* expr ::= expr NOT NULL */
110561110752
{spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110562110753
break;
110563
- case 215: /* expr ::= expr IS expr */
110754
+ case 213: /* expr ::= expr IS expr */
110564110755
{
110565110756
spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110566110757
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110567110758
}
110568110759
break;
110569
- case 216: /* expr ::= expr IS NOT expr */
110760
+ case 214: /* expr ::= expr IS NOT expr */
110570110761
{
110571110762
spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110572110763
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110573110764
}
110574110765
break;
110575
- case 217: /* expr ::= NOT expr */
110576
- case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218);
110766
+ case 215: /* expr ::= NOT expr */
110767
+ case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216);
110577110768
{spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110578110769
break;
110579
- case 219: /* expr ::= MINUS expr */
110770
+ case 217: /* expr ::= MINUS expr */
110580110771
{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110581110772
break;
110582
- case 220: /* expr ::= PLUS expr */
110773
+ case 218: /* expr ::= PLUS expr */
110583110774
{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110584110775
break;
110585
- case 223: /* expr ::= expr between_op expr AND expr */
110776
+ case 221: /* expr ::= expr between_op expr AND expr */
110586110777
{
110587110778
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110588110779
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110589110780
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110590110781
if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110595110786
if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110596110787
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110597110788
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110598110789
}
110599110790
break;
110600
- case 226: /* expr ::= expr in_op LP exprlist RP */
110791
+ case 224: /* expr ::= expr in_op LP exprlist RP */
110601110792
{
110602110793
if( yymsp[-1].minor.yy442==0 ){
110603110794
/* Expressions of the form
110604110795
**
110605110796
** expr1 IN ()
@@ -110622,11 +110813,11 @@
110622110813
}
110623110814
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110624110815
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110625110816
}
110626110817
break;
110627
- case 227: /* expr ::= LP select RP */
110818
+ case 225: /* expr ::= LP select RP */
110628110819
{
110629110820
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110630110821
if( yygotominor.yy342.pExpr ){
110631110822
yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110632110823
ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110636110827
}
110637110828
yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110638110829
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110639110830
}
110640110831
break;
110641
- case 228: /* expr ::= expr in_op LP select RP */
110832
+ case 226: /* expr ::= expr in_op LP select RP */
110642110833
{
110643110834
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110644110835
if( yygotominor.yy342.pExpr ){
110645110836
yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110646110837
ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110651110842
if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110652110843
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110653110844
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110654110845
}
110655110846
break;
110656
- case 229: /* expr ::= expr in_op nm dbnm */
110847
+ case 227: /* expr ::= expr in_op nm dbnm */
110657110848
{
110658110849
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110659110850
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110660110851
if( yygotominor.yy342.pExpr ){
110661110852
yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110667110858
if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110668110859
yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110669110860
yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110670110861
}
110671110862
break;
110672
- case 230: /* expr ::= EXISTS LP select RP */
110863
+ case 228: /* expr ::= EXISTS LP select RP */
110673110864
{
110674110865
Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110675110866
if( p ){
110676110867
p->x.pSelect = yymsp[-1].minor.yy159;
110677110868
ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110681110872
}
110682110873
yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110683110874
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110684110875
}
110685110876
break;
110686
- case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
110877
+ case 229: /* expr ::= CASE case_operand case_exprlist case_else END */
110687110878
{
110688110879
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110689110880
if( yygotominor.yy342.pExpr ){
110690110881
yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110691110882
sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110694110885
}
110695110886
yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110696110887
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110697110888
}
110698110889
break;
110699
- case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110890
+ case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110700110891
{
110701110892
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110702110893
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110703110894
}
110704110895
break;
110705
- case 233: /* case_exprlist ::= WHEN expr THEN expr */
110896
+ case 231: /* case_exprlist ::= WHEN expr THEN expr */
110706110897
{
110707110898
yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110708110899
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110709110900
}
110710110901
break;
110711
- case 240: /* nexprlist ::= nexprlist COMMA expr */
110902
+ case 238: /* nexprlist ::= nexprlist COMMA expr */
110712110903
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110713110904
break;
110714
- case 241: /* nexprlist ::= expr */
110905
+ case 239: /* nexprlist ::= expr */
110715110906
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110716110907
break;
110717
- case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110908
+ case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110718110909
{
110719110910
sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110720110911
sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110721110912
&yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110722110913
}
110723110914
break;
110724
- case 243: /* uniqueflag ::= UNIQUE */
110725
- case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
110915
+ case 241: /* uniqueflag ::= UNIQUE */
110916
+ case 294: /* raisetype ::= ABORT */ yytestcase(yyruleno==294);
110726110917
{yygotominor.yy392 = OE_Abort;}
110727110918
break;
110728
- case 244: /* uniqueflag ::= */
110919
+ case 242: /* uniqueflag ::= */
110729110920
{yygotominor.yy392 = OE_None;}
110730110921
break;
110731
- case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */
110922
+ case 245: /* idxlist ::= idxlist COMMA nm collate sortorder */
110732110923
{
110733110924
Expr *p = 0;
110734110925
if( yymsp[-1].minor.yy0.n>0 ){
110735110926
p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110736110927
sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110739110930
sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110740110931
sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110741110932
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110742110933
}
110743110934
break;
110744
- case 248: /* idxlist ::= nm collate sortorder */
110935
+ case 246: /* idxlist ::= nm collate sortorder */
110745110936
{
110746110937
Expr *p = 0;
110747110938
if( yymsp[-1].minor.yy0.n>0 ){
110748110939
p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110749110940
sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110752110943
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110753110944
sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110754110945
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110755110946
}
110756110947
break;
110757
- case 249: /* collate ::= */
110948
+ case 247: /* collate ::= */
110758110949
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110759110950
break;
110760
- case 251: /* cmd ::= DROP INDEX ifexists fullname */
110951
+ case 249: /* cmd ::= DROP INDEX ifexists fullname */
110761110952
{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110762110953
break;
110763
- case 252: /* cmd ::= VACUUM */
110764
- case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253);
110954
+ case 250: /* cmd ::= VACUUM */
110955
+ case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251);
110765110956
{sqlite3Vacuum(pParse);}
110766110957
break;
110767
- case 254: /* cmd ::= PRAGMA nm dbnm */
110958
+ case 252: /* cmd ::= PRAGMA nm dbnm */
110768110959
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110769110960
break;
110770
- case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110961
+ case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110771110962
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110772110963
break;
110773
- case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110964
+ case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110774110965
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110775110966
break;
110776
- case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110967
+ case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110777110968
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110778110969
break;
110779
- case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110970
+ case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110780110971
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110781110972
break;
110782
- case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110973
+ case 266: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110783110974
{
110784110975
Token all;
110785110976
all.z = yymsp[-3].minor.yy0.z;
110786110977
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110787110978
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110788110979
}
110789110980
break;
110790
- case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110981
+ case 267: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110791110982
{
110792110983
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110793110984
yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110794110985
}
110795110986
break;
110796
- case 270: /* trigger_time ::= BEFORE */
110797
- case 273: /* trigger_time ::= */ yytestcase(yyruleno==273);
110987
+ case 268: /* trigger_time ::= BEFORE */
110988
+ case 271: /* trigger_time ::= */ yytestcase(yyruleno==271);
110798110989
{ yygotominor.yy392 = TK_BEFORE; }
110799110990
break;
110800
- case 271: /* trigger_time ::= AFTER */
110991
+ case 269: /* trigger_time ::= AFTER */
110801110992
{ yygotominor.yy392 = TK_AFTER; }
110802110993
break;
110803
- case 272: /* trigger_time ::= INSTEAD OF */
110994
+ case 270: /* trigger_time ::= INSTEAD OF */
110804110995
{ yygotominor.yy392 = TK_INSTEAD;}
110805110996
break;
110806
- case 274: /* trigger_event ::= DELETE|INSERT */
110807
- case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275);
110997
+ case 272: /* trigger_event ::= DELETE|INSERT */
110998
+ case 273: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==273);
110808110999
{yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
110809111000
break;
110810
- case 276: /* trigger_event ::= UPDATE OF inscollist */
111001
+ case 274: /* trigger_event ::= UPDATE OF inscollist */
110811111002
{yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
110812111003
break;
110813
- case 279: /* when_clause ::= */
110814
- case 301: /* key_opt ::= */ yytestcase(yyruleno==301);
111004
+ case 277: /* when_clause ::= */
111005
+ case 299: /* key_opt ::= */ yytestcase(yyruleno==299);
110815111006
{ yygotominor.yy122 = 0; }
110816111007
break;
110817
- case 280: /* when_clause ::= WHEN expr */
110818
- case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302);
111008
+ case 278: /* when_clause ::= WHEN expr */
111009
+ case 300: /* key_opt ::= KEY expr */ yytestcase(yyruleno==300);
110819111010
{ yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110820111011
break;
110821
- case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
111012
+ case 279: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
110822111013
{
110823111014
assert( yymsp[-2].minor.yy327!=0 );
110824111015
yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
110825111016
yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
110826111017
yygotominor.yy327 = yymsp[-2].minor.yy327;
110827111018
}
110828111019
break;
110829
- case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
111020
+ case 280: /* trigger_cmd_list ::= trigger_cmd SEMI */
110830111021
{
110831111022
assert( yymsp[-1].minor.yy327!=0 );
110832111023
yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
110833111024
yygotominor.yy327 = yymsp[-1].minor.yy327;
110834111025
}
110835111026
break;
110836
- case 284: /* trnm ::= nm DOT nm */
111027
+ case 282: /* trnm ::= nm DOT nm */
110837111028
{
110838111029
yygotominor.yy0 = yymsp[0].minor.yy0;
110839111030
sqlite3ErrorMsg(pParse,
110840111031
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110841111032
"statements within triggers");
110842111033
}
110843111034
break;
110844
- case 286: /* tridxby ::= INDEXED BY nm */
111035
+ case 284: /* tridxby ::= INDEXED BY nm */
110845111036
{
110846111037
sqlite3ErrorMsg(pParse,
110847111038
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
110848111039
"within triggers");
110849111040
}
110850111041
break;
110851
- case 287: /* tridxby ::= NOT INDEXED */
111042
+ case 285: /* tridxby ::= NOT INDEXED */
110852111043
{
110853111044
sqlite3ErrorMsg(pParse,
110854111045
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
110855111046
"within triggers");
110856111047
}
110857111048
break;
110858
- case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
111049
+ case 286: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
110859111050
{ yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
110860111051
break;
110861
- case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
111052
+ case 287: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
110862111053
{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
110863111054
break;
110864
- case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
111055
+ case 288: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
110865111056
{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
110866111057
break;
110867
- case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
111058
+ case 289: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
110868111059
{yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
110869111060
break;
110870
- case 292: /* trigger_cmd ::= select */
111061
+ case 290: /* trigger_cmd ::= select */
110871111062
{yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
110872111063
break;
110873
- case 293: /* expr ::= RAISE LP IGNORE RP */
111064
+ case 291: /* expr ::= RAISE LP IGNORE RP */
110874111065
{
110875111066
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110876111067
if( yygotominor.yy342.pExpr ){
110877111068
yygotominor.yy342.pExpr->affinity = OE_Ignore;
110878111069
}
110879111070
yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110880111071
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110881111072
}
110882111073
break;
110883
- case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */
111074
+ case 292: /* expr ::= RAISE LP raisetype COMMA nm RP */
110884111075
{
110885111076
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110886111077
if( yygotominor.yy342.pExpr ) {
110887111078
yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110888111079
}
110889111080
yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
110890111081
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110891111082
}
110892111083
break;
110893
- case 295: /* raisetype ::= ROLLBACK */
111084
+ case 293: /* raisetype ::= ROLLBACK */
110894111085
{yygotominor.yy392 = OE_Rollback;}
110895111086
break;
110896
- case 297: /* raisetype ::= FAIL */
111087
+ case 295: /* raisetype ::= FAIL */
110897111088
{yygotominor.yy392 = OE_Fail;}
110898111089
break;
110899
- case 298: /* cmd ::= DROP TRIGGER ifexists fullname */
111090
+ case 296: /* cmd ::= DROP TRIGGER ifexists fullname */
110900111091
{
110901111092
sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
110902111093
}
110903111094
break;
110904
- case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
111095
+ case 297: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
110905111096
{
110906111097
sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110907111098
}
110908111099
break;
110909
- case 300: /* cmd ::= DETACH database_kw_opt expr */
111100
+ case 298: /* cmd ::= DETACH database_kw_opt expr */
110910111101
{
110911111102
sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
110912111103
}
110913111104
break;
110914
- case 305: /* cmd ::= REINDEX */
111105
+ case 303: /* cmd ::= REINDEX */
110915111106
{sqlite3Reindex(pParse, 0, 0);}
110916111107
break;
110917
- case 306: /* cmd ::= REINDEX nm dbnm */
111108
+ case 304: /* cmd ::= REINDEX nm dbnm */
110918111109
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110919111110
break;
110920
- case 307: /* cmd ::= ANALYZE */
111111
+ case 305: /* cmd ::= ANALYZE */
110921111112
{sqlite3Analyze(pParse, 0, 0);}
110922111113
break;
110923
- case 308: /* cmd ::= ANALYZE nm dbnm */
111114
+ case 306: /* cmd ::= ANALYZE nm dbnm */
110924111115
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110925111116
break;
110926
- case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
111117
+ case 307: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110927111118
{
110928111119
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
110929111120
}
110930111121
break;
110931
- case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
111122
+ case 308: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110932111123
{
110933111124
sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
110934111125
}
110935111126
break;
110936
- case 311: /* add_column_fullname ::= fullname */
111127
+ case 309: /* add_column_fullname ::= fullname */
110937111128
{
110938111129
pParse->db->lookaside.bEnabled = 0;
110939111130
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
110940111131
}
110941111132
break;
110942
- case 314: /* cmd ::= create_vtab */
111133
+ case 312: /* cmd ::= create_vtab */
110943111134
{sqlite3VtabFinishParse(pParse,0);}
110944111135
break;
110945
- case 315: /* cmd ::= create_vtab LP vtabarglist RP */
111136
+ case 313: /* cmd ::= create_vtab LP vtabarglist RP */
110946111137
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
110947111138
break;
110948
- case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111139
+ case 314: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
110949111140
{
110950111141
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
110951111142
}
110952111143
break;
110953
- case 319: /* vtabarg ::= */
111144
+ case 317: /* vtabarg ::= */
110954111145
{sqlite3VtabArgInit(pParse);}
110955111146
break;
110956
- case 321: /* vtabargtoken ::= ANY */
110957
- case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322);
110958
- case 323: /* lp ::= LP */ yytestcase(yyruleno==323);
111147
+ case 319: /* vtabargtoken ::= ANY */
111148
+ case 320: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==320);
111149
+ case 321: /* lp ::= LP */ yytestcase(yyruleno==321);
110959111150
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
110960111151
break;
110961111152
default:
110962111153
/* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
110963111154
/* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
110973111164
/* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
110974111165
/* (35) columnlist ::= column */ yytestcase(yyruleno==35);
110975111166
/* (44) type ::= */ yytestcase(yyruleno==44);
110976111167
/* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
110977111168
/* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
110978
- /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
111169
+ /* (53) carglist ::= carglist cname ccons */ yytestcase(yyruleno==53);
110979111170
/* (54) carglist ::= */ yytestcase(yyruleno==54);
110980
- /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
110981
- /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
110982111171
/* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
110983
- /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
110984
- /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
110985
- /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
110986
- /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
110987
- /* (277) foreach_clause ::= */ yytestcase(yyruleno==277);
110988
- /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278);
110989
- /* (285) tridxby ::= */ yytestcase(yyruleno==285);
110990
- /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
110991
- /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304);
110992
- /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312);
110993
- /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313);
110994
- /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317);
110995
- /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318);
110996
- /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320);
110997
- /* (324) anylist ::= */ yytestcase(yyruleno==324);
110998
- /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110999
- /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
111172
+ /* (90) conslist ::= conslist COMMA cname tcons */ yytestcase(yyruleno==90);
111173
+ /* (91) conslist ::= cname tcons */ yytestcase(yyruleno==91);
111174
+ /* (275) foreach_clause ::= */ yytestcase(yyruleno==275);
111175
+ /* (276) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==276);
111176
+ /* (283) tridxby ::= */ yytestcase(yyruleno==283);
111177
+ /* (301) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==301);
111178
+ /* (302) database_kw_opt ::= */ yytestcase(yyruleno==302);
111179
+ /* (310) kwcolumn_opt ::= */ yytestcase(yyruleno==310);
111180
+ /* (311) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==311);
111181
+ /* (315) vtabarglist ::= vtabarg */ yytestcase(yyruleno==315);
111182
+ /* (316) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==316);
111183
+ /* (318) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==318);
111184
+ /* (322) anylist ::= */ yytestcase(yyruleno==322);
111185
+ /* (323) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==323);
111186
+ /* (324) anylist ::= anylist ANY */ yytestcase(yyruleno==324);
111000111187
break;
111001111188
};
111002111189
yygoto = yyRuleInfo[yyruleno].lhs;
111003111190
yysize = yyRuleInfo[yyruleno].nrhs;
111004111191
yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
115889116076
** option. But that functionality is no longer supported.
115890116077
**
115891116078
** A doclist is stored like this:
115892116079
**
115893116080
** array {
115894
-** varint docid;
116081
+** varint docid; (delta from previous doclist)
115895116082
** array { (position list for column 0)
115896116083
** varint position; (2 more than the delta from previous position)
115897116084
** }
115898116085
** array {
115899116086
** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
115920116107
** The 123 value is the first docid. For column zero in this document
115921116108
** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
115922116109
** at D signals the start of a new column; the 1 at E indicates that the
115923116110
** new column is column number 1. There are two positions at 12 and 45
115924116111
** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
115925
-** 234 at I is the next docid. It has one position 72 (72-2) and then
115926
-** terminates with the 0 at K.
116112
+** 234 at I is the delta to next docid (357). It has one position 70
116113
+** (72-2) and then terminates with the 0 at K.
115927116114
**
115928116115
** A "position-list" is the list of positions for multiple columns for
115929116116
** a single docid. A "column-list" is the set of positions for a single
115930116117
** column. Hence, a position-list consists of one or more column-lists,
115931116118
** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116456116643
116457116644
116458116645
#ifndef MIN
116459116646
# define MIN(x,y) ((x)<(y)?(x):(y))
116460116647
#endif
116648
+#ifndef MAX
116649
+# define MAX(x,y) ((x)>(y)?(x):(y))
116650
+#endif
116461116651
116462116652
/*
116463116653
** Maximum length of a varint encoded integer. The varint format is different
116464116654
** from that used by SQLite, so the maximum length is 10, not 9.
116465116655
*/
@@ -116510,20 +116700,21 @@
116510116700
#ifdef SQLITE_COVERAGE_TEST
116511116701
# define ALWAYS(x) (1)
116512116702
# define NEVER(X) (0)
116513116703
#else
116514116704
# define ALWAYS(x) (x)
116515
-# define NEVER(X) (x)
116705
+# define NEVER(x) (x)
116516116706
#endif
116517116707
116518116708
/*
116519116709
** Internal types used by SQLite.
116520116710
*/
116521116711
typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116522116712
typedef short int i16; /* 2-byte (or larger) signed integer */
116523116713
typedef unsigned int u32; /* 4-byte unsigned integer */
116524116714
typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
116715
+typedef sqlite3_int64 i64; /* 8-byte signed integer */
116525116716
116526116717
/*
116527116718
** Macro used to suppress compiler warnings for unused parameters.
116528116719
*/
116529116720
#define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116582116773
int nColumn; /* number of named columns in virtual table */
116583116774
char **azColumn; /* column names. malloced */
116584116775
sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116585116776
char *zContentTbl; /* content=xxx option, or NULL */
116586116777
char *zLanguageid; /* languageid=xxx option, or NULL */
116778
+ u8 bAutoincrmerge; /* True if automerge=1 */
116779
+ u32 nLeafAdd; /* Number of leaf blocks added this trans */
116587116780
116588116781
/* Precompiled statements used by the implementation. Each of these
116589116782
** statements is run and reset within a single virtual table API call.
116590116783
*/
116591
- sqlite3_stmt *aStmt[28];
116784
+ sqlite3_stmt *aStmt[37];
116592116785
116593116786
char *zReadExprlist;
116594116787
char *zWriteExprlist;
116595116788
116596116789
int nNodeSize; /* Soft limit for node size */
116790
+ u8 bFts4; /* True for FTS4, false for FTS3 */
116597116791
u8 bHasStat; /* True if %_stat table exists */
116598116792
u8 bHasDocsize; /* True if %_docsize table exists */
116599116793
u8 bDescIdx; /* True if doclists are in reverse order */
116794
+ u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */
116600116795
int nPgsz; /* Page size for host database */
116601116796
char *zSegmentsTbl; /* Name of %_segments table */
116602116797
sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116603116798
116604
- /* TODO: Fix the first paragraph of this comment.
116605
- **
116799
+ /*
116606116800
** The following array of hash tables is used to buffer pending index
116607
- ** updates during transactions. Variable nPendingData estimates the memory
116608
- ** size of the pending data, including hash table overhead, not including
116609
- ** malloc overhead. When nPendingData exceeds nMaxPendingData, the buffer
116610
- ** is flushed automatically. Variable iPrevDocid is the docid of the most
116611
- ** recently inserted record.
116801
+ ** updates during transactions. All pending updates buffered at any one
116802
+ ** time must share a common language-id (see the FTS4 langid= feature).
116803
+ ** The current language id is stored in variable iPrevLangid.
116612116804
**
116613116805
** A single FTS4 table may have multiple full-text indexes. For each index
116614116806
** there is an entry in the aIndex[] array. Index 0 is an index of all the
116615116807
** terms that appear in the document set. Each subsequent index in aIndex[]
116616116808
** is an index of prefixes of a specific length.
116809
+ **
116810
+ ** Variable nPendingData contains an estimate the memory consumed by the
116811
+ ** pending data structures, including hash table overhead, but not including
116812
+ ** malloc overhead. When nPendingData exceeds nMaxPendingData, all hash
116813
+ ** tables are flushed to disk. Variable iPrevDocid is the docid of the most
116814
+ ** recently inserted record.
116617116815
*/
116618116816
int nIndex; /* Size of aIndex[] */
116619116817
struct Fts3Index {
116620116818
int nPrefix; /* Prefix length (0 for main terms index) */
116621116819
Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
116810117008
SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
116811117009
SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
116812117010
SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
116813117011
SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
116814117012
SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
117013
+SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);
116815117014
116816117015
/* Special values interpreted by sqlite3SegReaderCursor() */
116817117016
#define FTS3_SEGCURSOR_PENDING -1
116818117017
#define FTS3_SEGCURSOR_ALL -2
116819117018
@@ -116861,19 +117060,22 @@
116861117060
int nTerm; /* Size of zTerm in bytes */
116862117061
char *aDoclist; /* Pointer to doclist buffer */
116863117062
int nDoclist; /* Size of aDoclist[] in bytes */
116864117063
};
116865117064
117065
+SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
117066
+
116866117067
/* fts3.c */
116867117068
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
116868117069
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
116869117070
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
116870117071
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
116871117072
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
116872117073
SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
116873117074
SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
116874117075
SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
117076
+SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);
116875117077
116876117078
/* fts3_tokenizer.c */
116877117079
SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
116878117080
SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
116879117081
SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117198117400
sqlite3_free(zSql);
117199117401
sqlite3_free(zCols);
117200117402
*pRc = rc;
117201117403
}
117202117404
}
117405
+
117406
+/*
117407
+** Create the %_stat table if it does not already exist.
117408
+*/
117409
+SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){
117410
+ fts3DbExec(pRc, p->db,
117411
+ "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
117412
+ "(id INTEGER PRIMARY KEY, value BLOB);",
117413
+ p->zDb, p->zName
117414
+ );
117415
+ if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;
117416
+}
117203117417
117204117418
/*
117205117419
** Create the backing store tables (%_content, %_segments and %_segdir)
117206117420
** required by the FTS3 table passed as the only argument. This is done
117207117421
** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117259117473
fts3DbExec(&rc, db,
117260117474
"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117261117475
p->zDb, p->zName
117262117476
);
117263117477
}
117478
+ assert( p->bHasStat==p->bFts4 );
117264117479
if( p->bHasStat ){
117265
- fts3DbExec(&rc, db,
117266
- "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117267
- p->zDb, p->zName
117268
- );
117480
+ sqlite3Fts3CreateStatTable(&rc, p);
117269117481
}
117270117482
return rc;
117271117483
}
117272117484
117273117485
/*
@@ -117370,11 +117582,11 @@
117370117582
** memory.
117371117583
*/
117372117584
static char *fts3QuoteId(char const *zInput){
117373117585
int nRet;
117374117586
char *zRet;
117375
- nRet = 2 + strlen(zInput)*2 + 1;
117587
+ nRet = 2 + (int)strlen(zInput)*2 + 1;
117376117588
zRet = sqlite3_malloc(nRet);
117377117589
if( zRet ){
117378117590
int i;
117379117591
char *z = zRet;
117380117592
*(z++) = '"';
@@ -117626,11 +117838,11 @@
117626117838
** space required to store a copy of each column name, including the
117627117839
** nul-terminator byte. */
117628117840
nCol = sqlite3_column_count(pStmt);
117629117841
for(i=0; i<nCol; i++){
117630117842
const char *zCol = sqlite3_column_name(pStmt, i);
117631
- nStr += strlen(zCol) + 1;
117843
+ nStr += (int)strlen(zCol) + 1;
117632117844
}
117633117845
117634117846
/* Allocate and populate the array to return. */
117635117847
azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117636117848
if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117637117849
rc = SQLITE_NOMEM;
117638117850
}else{
117639117851
char *p = (char *)&azCol[nCol];
117640117852
for(i=0; i<nCol; i++){
117641117853
const char *zCol = sqlite3_column_name(pStmt, i);
117642
- int n = strlen(zCol)+1;
117854
+ int n = (int)strlen(zCol)+1;
117643117855
memcpy(p, zCol, n);
117644117856
azCol[i] = p;
117645117857
p += n;
117646117858
}
117647117859
}
@@ -117852,11 +118064,12 @@
117852118064
** column from the aCol[] array. */
117853118065
if( rc==SQLITE_OK && zLanguageid ){
117854118066
int j;
117855118067
for(j=0; j<nCol; j++){
117856118068
if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
117857
- memmove(&aCol[j], &aCol[j+1], (nCol-j) * sizeof(aCol[0]));
118069
+ int k;
118070
+ for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];
117858118071
nCol--;
117859118072
break;
117860118073
}
117861118074
}
117862118075
}
@@ -117903,11 +118116,13 @@
117903118116
p->azColumn = (char **)&p[1];
117904118117
p->pTokenizer = pTokenizer;
117905118118
p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
117906118119
p->bHasDocsize = (isFts4 && bNoDocsize==0);
117907118120
p->bHasStat = isFts4;
118121
+ p->bFts4 = isFts4;
117908118122
p->bDescIdx = bDescIdx;
118123
+ p->bAutoincrmerge = 0xff; /* 0xff means setting unknown */
117909118124
p->zContentTbl = zContent;
117910118125
p->zLanguageid = zLanguageid;
117911118126
zContent = 0;
117912118127
zLanguageid = 0;
117913118128
TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
117955118170
** database. TODO: For xConnect(), it could verify that said tables exist.
117956118171
*/
117957118172
if( isCreate ){
117958118173
rc = fts3CreateTables(p);
117959118174
}
118175
+
118176
+ /* Check to see if a legacy fts3 table has been "upgraded" by the
118177
+ ** addition of a %_stat table so that it can use incremental merge.
118178
+ */
118179
+ if( !isFts4 && !isCreate ){
118180
+ int rc2 = SQLITE_OK;
118181
+ fts3DbExec(&rc2, db, "SELECT 1 FROM %Q.'%q_stat' WHERE id=2",
118182
+ p->zDb, p->zName);
118183
+ if( rc2==SQLITE_OK ) p->bHasStat = 1;
118184
+ }
117960118185
117961118186
/* Figure out the page-size for the database. This is required in order to
117962118187
** estimate the cost of loading large doclists from the database. */
117963118188
fts3DatabasePageSize(&rc, p);
117964118189
p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
118959119184
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
118960119185
}
118961119186
}
118962119187
118963119188
*paOut = aOut;
118964
- *pnOut = (p-aOut);
119189
+ *pnOut = (int)(p-aOut);
118965119190
assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
118966119191
return SQLITE_OK;
118967119192
}
118968119193
118969119194
/*
@@ -119023,11 +119248,11 @@
119023119248
fts3PoslistCopy(0, &p2);
119024119249
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119025119250
}
119026119251
}
119027119252
119028
- *pnRight = p - aOut;
119253
+ *pnRight = (int)(p - aOut);
119029119254
}
119030119255
119031119256
/*
119032119257
** Argument pList points to a position list nList bytes in size. This
119033119258
** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119299119524
** Set up a cursor object for iterating through a full-text index or a
119300119525
** single level therein.
119301119526
*/
119302119527
SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119303119528
Fts3Table *p, /* FTS3 table handle */
119304
- int iLangid,
119529
+ int iLangid, /* Language-id to search */
119305119530
int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119306119531
int iLevel, /* Level of segments to scan */
119307119532
const char *zTerm, /* Term to query for */
119308119533
int nTerm, /* Size of zTerm in bytes */
119309119534
int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119317119542
);
119318119543
assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119319119544
assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119320119545
assert( isPrefix==0 || isScan==0 );
119321119546
119322
- /* "isScan" is only set to true by the ft4aux module, an ordinary
119323
- ** full-text tables. */
119324
- assert( isScan==0 || p->aIndex==0 );
119325
-
119326119547
memset(pCsr, 0, sizeof(Fts3MultiSegReader));
119327
-
119328119548
return fts3SegReaderCursor(
119329119549
p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119330119550
);
119331119551
}
119332119552
@@ -119587,11 +119807,11 @@
119587119807
119588119808
pCsr->iLangid = 0;
119589119809
if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119590119810
119591119811
rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119592
- p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119812
+ p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119593119813
);
119594119814
if( rc!=SQLITE_OK ){
119595119815
if( rc==SQLITE_ERROR ){
119596119816
static const char *zErr = "malformed MATCH expression: [%s]";
119597119817
p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119730119950
/*
119731119951
** Implementation of xSync() method. Flush the contents of the pending-terms
119732119952
** hash-table to the database.
119733119953
*/
119734119954
static int fts3SyncMethod(sqlite3_vtab *pVtab){
119735
- int rc = sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab);
119736
- sqlite3Fts3SegmentsClose((Fts3Table *)pVtab);
119955
+
119956
+ /* Following an incremental-merge operation, assuming that the input
119957
+ ** segments are not completely consumed (the usual case), they are updated
119958
+ ** in place to remove the entries that have already been merged. This
119959
+ ** involves updating the leaf block that contains the smallest unmerged
119960
+ ** entry and each block (if any) between the leaf and the root node. So
119961
+ ** if the height of the input segment b-trees is N, and input segments
119962
+ ** are merged eight at a time, updating the input segments at the end
119963
+ ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually
119964
+ ** small - often between 0 and 2. So the overhead of the incremental
119965
+ ** merge is somewhere between 8 and 24 blocks. To avoid this overhead
119966
+ ** dwarfing the actual productive work accomplished, the incremental merge
119967
+ ** is only attempted if it will write at least 64 leaf blocks. Hence
119968
+ ** nMinMerge.
119969
+ **
119970
+ ** Of course, updating the input segments also involves deleting a bunch
119971
+ ** of blocks from the segments table. But this is not considered overhead
119972
+ ** as it would also be required by a crisis-merge that used the same input
119973
+ ** segments.
119974
+ */
119975
+ const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
119976
+
119977
+ Fts3Table *p = (Fts3Table*)pVtab;
119978
+ int rc = sqlite3Fts3PendingTermsFlush(p);
119979
+
119980
+ if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){
119981
+ int mxLevel = 0; /* Maximum relative level value in db */
119982
+ int A; /* Incr-merge parameter A */
119983
+
119984
+ rc = sqlite3Fts3MaxLevel(p, &mxLevel);
119985
+ assert( rc==SQLITE_OK || mxLevel==0 );
119986
+ A = p->nLeafAdd * mxLevel;
119987
+ A += (A/2);
119988
+ if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);
119989
+ }
119990
+ sqlite3Fts3SegmentsClose(p);
119737119991
return rc;
119738119992
}
119739119993
119740119994
/*
119741119995
** Implementation of xBegin() method. This is a no-op.
119742119996
*/
119743119997
static int fts3BeginMethod(sqlite3_vtab *pVtab){
119744
- TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
119998
+ Fts3Table *p = (Fts3Table*)pVtab;
119745119999
UNUSED_PARAMETER(pVtab);
119746120000
assert( p->pSegments==0 );
119747120001
assert( p->nPendingData==0 );
119748120002
assert( p->inTransaction!=1 );
119749120003
TESTONLY( p->inTransaction = 1 );
119750120004
TESTONLY( p->mxSavepoint = -1; );
120005
+ p->nLeafAdd = 0;
119751120006
return SQLITE_OK;
119752120007
}
119753120008
119754120009
/*
119755120010
** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120040120295
** The xSavepoint() method.
120041120296
**
120042120297
** Flush the contents of the pending-terms table to disk.
120043120298
*/
120044120299
static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
120300
+ int rc = SQLITE_OK;
120045120301
UNUSED_PARAMETER(iSavepoint);
120046120302
assert( ((Fts3Table *)pVtab)->inTransaction );
120047120303
assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120048120304
TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120049
- return fts3SyncMethod(pVtab);
120305
+ if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
120306
+ rc = fts3SyncMethod(pVtab);
120307
+ }
120308
+ return rc;
120050120309
}
120051120310
120052120311
/*
120053120312
** The xRelease() method.
120054120313
**
@@ -120404,11 +120663,11 @@
120404120663
120405120664
assert( iPrev>=0 );
120406120665
fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120407120666
sqlite3_free(aPoslist);
120408120667
aPoslist = pList;
120409
- nPoslist = aOut - aPoslist;
120668
+ nPoslist = (int)(aOut - aPoslist);
120410120669
if( nPoslist==0 ){
120411120670
sqlite3_free(aPoslist);
120412120671
pPhrase->doclist.pList = 0;
120413120672
pPhrase->doclist.nList = 0;
120414120673
return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120448120707
}
120449120708
120450120709
pPhrase->doclist.pList = aOut;
120451120710
if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120452120711
pPhrase->doclist.bFreeList = 1;
120453
- pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList);
120712
+ pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);
120454120713
}else{
120455120714
sqlite3_free(aOut);
120456120715
pPhrase->doclist.pList = 0;
120457120716
pPhrase->doclist.nList = 0;
120458120717
}
@@ -120544,11 +120803,11 @@
120544120803
fts3PoslistCopy(0, &pDocid);
120545120804
while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120546120805
iMul = (bDescIdx ? -1 : 1);
120547120806
}
120548120807
120549
- *pnList = pEnd - pNext;
120808
+ *pnList = (int)(pEnd - pNext);
120550120809
*ppIter = pNext;
120551120810
*piDocid = iDocid;
120552120811
}else{
120553120812
int iMul = (bDescIdx ? -1 : 1);
120554120813
sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120558120817
if( p==aDoclist ){
120559120818
*pbEof = 1;
120560120819
}else{
120561120820
char *pSave = p;
120562120821
fts3ReversePoslist(aDoclist, &p);
120563
- *pnList = (pSave - p);
120822
+ *pnList = (int)(pSave - p);
120564120823
}
120565120824
*ppIter = p;
120566120825
}
120567120826
}
120568120827
@@ -120618,11 +120877,11 @@
120618120877
}else{
120619120878
pDL->iDocid -= iDelta;
120620120879
}
120621120880
pDL->pList = pIter;
120622120881
fts3PoslistCopy(0, &pIter);
120623
- pDL->nList = (pIter - pDL->pList);
120882
+ pDL->nList = (int)(pIter - pDL->pList);
120624120883
120625120884
/* pIter now points just past the 0x00 that terminates the position-
120626120885
** list for document pDL->iDocid. However, if this position-list was
120627120886
** edited in place by fts3EvalNearTrim(), then pIter may not actually
120628120887
** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
120959121218
120960121219
/* Allocate a MultiSegReader for each token in the expression. */
120961121220
fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
120962121221
120963121222
/* Determine which, if any, tokens in the expression should be deferred. */
120964
- if( rc==SQLITE_OK && nToken>1 && pTab->bHasStat ){
121223
+ if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
120965121224
Fts3TokenAndCost *aTC;
120966121225
Fts3Expr **apOr;
120967121226
aTC = (Fts3TokenAndCost *)sqlite3_malloc(
120968121227
sizeof(Fts3TokenAndCost) * nToken
120969121228
+ sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
120976121235
int ii;
120977121236
Fts3TokenAndCost *pTC = aTC;
120978121237
Fts3Expr **ppOr = apOr;
120979121238
120980121239
fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
120981
- nToken = pTC-aTC;
120982
- nOr = ppOr-apOr;
121240
+ nToken = (int)(pTC-aTC);
121241
+ nOr = (int)(ppOr-apOr);
120983121242
120984121243
if( rc==SQLITE_OK ){
120985121244
rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
120986121245
for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
120987121246
rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121049121308
p2 = pOut = pPhrase->doclist.pList;
121050121309
res = fts3PoslistNearMerge(
121051121310
&pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121052121311
);
121053121312
if( res ){
121054
- nNew = (pOut - pPhrase->doclist.pList) - 1;
121313
+ nNew = (int)(pOut - pPhrase->doclist.pList) - 1;
121055121314
assert( pPhrase->doclist.pList[nNew]=='\0' );
121056121315
assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121057121316
memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121058121317
pPhrase->doclist.nList = nNew;
121059121318
*paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
121774122033
fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
121775122034
pPhrase->aToken[i].pSegcsr = 0;
121776122035
}
121777122036
}
121778122037
}
122038
+
121779122039
121780122040
/*
121781122041
** Return SQLITE_CORRUPT_VTAB.
121782122042
*/
121783122043
#ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
121882122142
);
121883122143
return SQLITE_ERROR;
121884122144
}
121885122145
121886122146
zDb = argv[1];
121887
- nDb = strlen(zDb);
122147
+ nDb = (int)strlen(zDb);
121888122148
zFts3 = argv[3];
121889
- nFts3 = strlen(zFts3);
122149
+ nFts3 = (int)strlen(zFts3);
121890122150
121891122151
rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
121892122152
if( rc!=SQLITE_OK ) return rc;
121893122153
121894122154
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125074125334
125075125335
/* #include <string.h> */
125076125336
/* #include <assert.h> */
125077125337
/* #include <stdlib.h> */
125078125338
125339
+
125340
+#define FTS_MAX_APPENDABLE_HEIGHT 16
125341
+
125079125342
/*
125080125343
** When full-text index nodes are loaded from disk, the buffer that they
125081125344
** are loaded into has the following number of bytes of padding at the end
125082125345
** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125083125346
** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125112125375
# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125113125376
#else
125114125377
# define FTS3_NODE_CHUNKSIZE (4*1024)
125115125378
# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125116125379
#endif
125380
+
125381
+/*
125382
+** The two values that may be meaningfully bound to the :1 parameter in
125383
+** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
125384
+*/
125385
+#define FTS_STAT_DOCTOTAL 0
125386
+#define FTS_STAT_INCRMERGEHINT 1
125387
+#define FTS_STAT_AUTOINCRMERGE 2
125388
+
125389
+/*
125390
+** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic
125391
+** and incremental merge operation that takes place. This is used for
125392
+** debugging FTS only, it should not usually be turned on in production
125393
+** systems.
125394
+*/
125395
+#ifdef FTS3_LOG_MERGES
125396
+static void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){
125397
+ sqlite3_log(SQLITE_OK, "%d-way merge from level %d", nMerge, (int)iAbsLevel);
125398
+}
125399
+#else
125400
+#define fts3LogMerge(x, y)
125401
+#endif
125402
+
125117125403
125118125404
typedef struct PendingList PendingList;
125119125405
typedef struct SegmentNode SegmentNode;
125120125406
typedef struct SegmentWriter SegmentWriter;
125121125407
@@ -125274,19 +125560,26 @@
125274125560
#define SQL_DELETE_SEGMENTS_RANGE 17
125275125561
#define SQL_CONTENT_INSERT 18
125276125562
#define SQL_DELETE_DOCSIZE 19
125277125563
#define SQL_REPLACE_DOCSIZE 20
125278125564
#define SQL_SELECT_DOCSIZE 21
125279
-#define SQL_SELECT_DOCTOTAL 22
125280
-#define SQL_REPLACE_DOCTOTAL 23
125565
+#define SQL_SELECT_STAT 22
125566
+#define SQL_REPLACE_STAT 23
125281125567
125282125568
#define SQL_SELECT_ALL_PREFIX_LEVEL 24
125283125569
#define SQL_DELETE_ALL_TERMS_SEGDIR 25
125284
-
125285125570
#define SQL_DELETE_SEGDIR_RANGE 26
125286
-
125287125571
#define SQL_SELECT_ALL_LANGID 27
125572
+#define SQL_FIND_MERGE_LEVEL 28
125573
+#define SQL_MAX_LEAF_NODE_ESTIMATE 29
125574
+#define SQL_DELETE_SEGDIR_ENTRY 30
125575
+#define SQL_SHIFT_SEGDIR_ENTRY 31
125576
+#define SQL_SELECT_SEGDIR 32
125577
+#define SQL_CHOMP_SEGDIR 33
125578
+#define SQL_SEGMENT_IS_APPENDABLE 34
125579
+#define SQL_SELECT_INDEXES 35
125580
+#define SQL_SELECT_MXLEVEL 36
125288125581
125289125582
/*
125290125583
** This function is used to obtain an SQLite prepared statement handle
125291125584
** for the statement identified by the second argument. If successful,
125292125585
** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125311125604
/* 4 */ "DELETE FROM %Q.'%q_segdir'",
125312125605
/* 5 */ "DELETE FROM %Q.'%q_docsize'",
125313125606
/* 6 */ "DELETE FROM %Q.'%q_stat'",
125314125607
/* 7 */ "SELECT %s WHERE rowid=?",
125315125608
/* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125316
-/* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125609
+/* 9 */ "REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125317125610
/* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125318
-/* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125611
+/* 11 */ "REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125319125612
125320125613
/* Return segments in order from oldest to newest.*/
125321125614
/* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125322125615
"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125323125616
/* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125331125624
/* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125332125625
/* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125333125626
/* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125334125627
/* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125335125628
/* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125336
-/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=0",
125337
-/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(0,?)",
125629
+/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=?",
125630
+/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
125338125631
/* 24 */ "",
125339125632
/* 25 */ "",
125340125633
125341125634
/* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125342125635
/* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125343125636
125637
+/* This statement is used to determine which level to read the input from
125638
+** when performing an incremental merge. It returns the absolute level number
125639
+** of the oldest level in the db that contains at least ? segments. Or,
125640
+** if no level in the FTS index contains more than ? segments, the statement
125641
+** returns zero rows. */
125642
+/* 28 */ "SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?"
125643
+ " ORDER BY (level %% 1024) ASC LIMIT 1",
125644
+
125645
+/* Estimate the upper limit on the number of leaf nodes in a new segment
125646
+** created by merging the oldest :2 segments from absolute level :1. See
125647
+** function sqlite3Fts3Incrmerge() for details. */
125648
+/* 29 */ "SELECT 2 * total(1 + leaves_end_block - start_block) "
125649
+ " FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?",
125650
+
125651
+/* SQL_DELETE_SEGDIR_ENTRY
125652
+** Delete the %_segdir entry on absolute level :1 with index :2. */
125653
+/* 30 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125654
+
125655
+/* SQL_SHIFT_SEGDIR_ENTRY
125656
+** Modify the idx value for the segment with idx=:3 on absolute level :2
125657
+** to :1. */
125658
+/* 31 */ "UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?",
125659
+
125660
+/* SQL_SELECT_SEGDIR
125661
+** Read a single entry from the %_segdir table. The entry from absolute
125662
+** level :1 with index value :2. */
125663
+/* 32 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125664
+ "FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125665
+
125666
+/* SQL_CHOMP_SEGDIR
125667
+** Update the start_block (:1) and root (:2) fields of the %_segdir
125668
+** entry located on absolute level :3 with index :4. */
125669
+/* 33 */ "UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?"
125670
+ "WHERE level = ? AND idx = ?",
125671
+
125672
+/* SQL_SEGMENT_IS_APPENDABLE
125673
+** Return a single row if the segment with end_block=? is appendable. Or
125674
+** no rows otherwise. */
125675
+/* 34 */ "SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL",
125676
+
125677
+/* SQL_SELECT_INDEXES
125678
+** Return the list of valid segment indexes for absolute level ? */
125679
+/* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
125680
+
125681
+/* SQL_SELECT_MXLEVEL
125682
+** Return the largest relative level in the FTS index or indexes. */
125683
+/* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'"
125344125684
};
125345125685
int rc = SQLITE_OK;
125346125686
sqlite3_stmt *pStmt;
125347125687
125348125688
assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125375125715
}
125376125716
}
125377125717
*pp = pStmt;
125378125718
return rc;
125379125719
}
125720
+
125380125721
125381125722
static int fts3SelectDocsize(
125382125723
Fts3Table *pTab, /* FTS3 table handle */
125383
- int eStmt, /* Either SQL_SELECT_DOCSIZE or DOCTOTAL */
125384125724
sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125385125725
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125386125726
){
125387125727
sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125388125728
int rc; /* Return code */
125389125729
125390
- assert( eStmt==SQL_SELECT_DOCSIZE || eStmt==SQL_SELECT_DOCTOTAL );
125391
-
125392
- rc = fts3SqlStmt(pTab, eStmt, &pStmt, 0);
125730
+ rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);
125393125731
if( rc==SQLITE_OK ){
125394
- if( eStmt==SQL_SELECT_DOCSIZE ){
125395
- sqlite3_bind_int64(pStmt, 1, iDocid);
125396
- }
125732
+ sqlite3_bind_int64(pStmt, 1, iDocid);
125397125733
rc = sqlite3_step(pStmt);
125398125734
if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125399125735
rc = sqlite3_reset(pStmt);
125400125736
if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125401125737
pStmt = 0;
@@ -125410,19 +125746,33 @@
125410125746
125411125747
SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125412125748
Fts3Table *pTab, /* Fts3 table handle */
125413125749
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125414125750
){
125415
- return fts3SelectDocsize(pTab, SQL_SELECT_DOCTOTAL, 0, ppStmt);
125751
+ sqlite3_stmt *pStmt = 0;
125752
+ int rc;
125753
+ rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);
125754
+ if( rc==SQLITE_OK ){
125755
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
125756
+ if( sqlite3_step(pStmt)!=SQLITE_ROW
125757
+ || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB
125758
+ ){
125759
+ rc = sqlite3_reset(pStmt);
125760
+ if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125761
+ pStmt = 0;
125762
+ }
125763
+ }
125764
+ *ppStmt = pStmt;
125765
+ return rc;
125416125766
}
125417125767
125418125768
SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125419125769
Fts3Table *pTab, /* Fts3 table handle */
125420125770
sqlite3_int64 iDocid, /* Docid to read size data for */
125421125771
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125422125772
){
125423
- return fts3SelectDocsize(pTab, SQL_SELECT_DOCSIZE, iDocid, ppStmt);
125773
+ return fts3SelectDocsize(pTab, iDocid, ppStmt);
125424125774
}
125425125775
125426125776
/*
125427125777
** Similar to fts3SqlStmt(). Except, after binding the parameters in
125428125778
** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125484125834
}
125485125835
125486125836
return rc;
125487125837
}
125488125838
125839
+/*
125840
+** FTS maintains a separate indexes for each language-id (a 32-bit integer).
125841
+** Within each language id, a separate index is maintained to store the
125842
+** document terms, and each configured prefix size (configured the FTS
125843
+** "prefix=" option). And each index consists of multiple levels ("relative
125844
+** levels").
125845
+**
125846
+** All three of these values (the language id, the specific index and the
125847
+** level within the index) are encoded in 64-bit integer values stored
125848
+** in the %_segdir table on disk. This function is used to convert three
125849
+** separate component values into the single 64-bit integer value that
125850
+** can be used to query the %_segdir table.
125851
+**
125852
+** Specifically, each language-id/index combination is allocated 1024
125853
+** 64-bit integer level values ("absolute levels"). The main terms index
125854
+** for language-id 0 is allocate values 0-1023. The first prefix index
125855
+** (if any) for language-id 0 is allocated values 1024-2047. And so on.
125856
+** Language 1 indexes are allocated immediately following language 0.
125857
+**
125858
+** So, for a system with nPrefix prefix indexes configured, the block of
125859
+** absolute levels that corresponds to language-id iLangid and index
125860
+** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).
125861
+*/
125489125862
static sqlite3_int64 getAbsoluteLevel(
125490
- Fts3Table *p,
125491
- int iLangid,
125492
- int iIndex,
125493
- int iLevel
125863
+ Fts3Table *p, /* FTS3 table handle */
125864
+ int iLangid, /* Language id */
125865
+ int iIndex, /* Index in p->aIndex[] */
125866
+ int iLevel /* Level of segments */
125494125867
){
125868
+ sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
125495125869
assert( iLangid>=0 );
125496125870
assert( p->nIndex>0 );
125497125871
assert( iIndex>=0 && iIndex<p->nIndex );
125498
- return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel;
125872
+
125873
+ iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;
125874
+ return iBase + iLevel;
125499125875
}
125500
-
125501125876
125502125877
/*
125503125878
** Set *ppStmt to a statement handle that may be used to iterate through
125504125879
** all rows in the %_segdir table, from oldest to newest. If successful,
125505125880
** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125518125893
*/
125519125894
SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125520125895
Fts3Table *p, /* FTS3 table */
125521125896
int iLangid, /* Language being queried */
125522125897
int iIndex, /* Index for p->aIndex[] */
125523
- int iLevel, /* Level to select */
125898
+ int iLevel, /* Level to select (relative level) */
125524125899
sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125525125900
){
125526125901
int rc;
125527125902
sqlite3_stmt *pStmt = 0;
125528125903
@@ -125533,19 +125908,19 @@
125533125908
if( iLevel<0 ){
125534125909
/* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125535125910
rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125536125911
if( rc==SQLITE_OK ){
125537125912
sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125538
- sqlite3_bind_int(pStmt, 2,
125913
+ sqlite3_bind_int64(pStmt, 2,
125539125914
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125540125915
);
125541125916
}
125542125917
}else{
125543125918
/* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125544125919
rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125545125920
if( rc==SQLITE_OK ){
125546
- sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
125921
+ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
125547125922
}
125548125923
}
125549125924
*ppStmt = pStmt;
125550125925
return rc;
125551125926
}
@@ -126062,10 +126437,11 @@
126062126437
** full, merge all segments in level iLevel into a single iLevel+1
126063126438
** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126064126439
** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126065126440
*/
126066126441
if( iNext>=FTS3_MERGE_COUNT ){
126442
+ fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
126067126443
rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126068126444
*piIdx = 0;
126069126445
}else{
126070126446
*piIdx = iNext;
126071126447
}
@@ -126109,11 +126485,11 @@
126109126485
int *pnLoad /* OUT: Bytes actually loaded */
126110126486
){
126111126487
int rc; /* Return code */
126112126488
126113126489
/* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126114
- assert( pnBlob);
126490
+ assert( pnBlob );
126115126491
126116126492
if( p->pSegments ){
126117126493
rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126118126494
}else{
126119126495
if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126450126826
int nOvfl = 0;
126451126827
int ii;
126452126828
int rc = SQLITE_OK;
126453126829
int pgsz = p->nPgsz;
126454126830
126455
- assert( p->bHasStat );
126831
+ assert( p->bFts4 );
126456126832
assert( pgsz>0 );
126457126833
126458126834
for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126459126835
Fts3SegReader *pReader = pMsr->apSegment[ii];
126460126836
if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
126807127183
sqlite3_step(pStmt);
126808127184
rc = sqlite3_reset(pStmt);
126809127185
}
126810127186
return rc;
126811127187
}
127188
+
127189
+/*
127190
+** Find the largest relative level number in the table. If successful, set
127191
+** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
127192
+** set *pnMax to zero and return an SQLite error code.
127193
+*/
127194
+SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){
127195
+ int rc;
127196
+ int mxLevel = 0;
127197
+ sqlite3_stmt *pStmt = 0;
127198
+
127199
+ rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
127200
+ if( rc==SQLITE_OK ){
127201
+ if( SQLITE_ROW==sqlite3_step(pStmt) ){
127202
+ mxLevel = sqlite3_column_int(pStmt, 0);
127203
+ }
127204
+ rc = sqlite3_reset(pStmt);
127205
+ }
127206
+ *pnMax = mxLevel;
127207
+ return rc;
127208
+}
126812127209
126813127210
/*
126814127211
** Insert a record into the %_segdir table.
126815127212
*/
126816127213
static int fts3WriteSegdir(
126817127214
Fts3Table *p, /* Virtual table handle */
126818
- int iLevel, /* Value for "level" field */
127215
+ sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */
126819127216
int iIdx, /* Value for "idx" field */
126820127217
sqlite3_int64 iStartBlock, /* Value for "start_block" field */
126821127218
sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
126822127219
sqlite3_int64 iEndBlock, /* Value for "end_block" field */
126823127220
char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
126824127221
int nRoot /* Number of bytes in buffer zRoot */
126825127222
){
126826127223
sqlite3_stmt *pStmt;
126827127224
int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
126828127225
if( rc==SQLITE_OK ){
126829
- sqlite3_bind_int(pStmt, 1, iLevel);
127226
+ sqlite3_bind_int64(pStmt, 1, iLevel);
126830127227
sqlite3_bind_int(pStmt, 2, iIdx);
126831127228
sqlite3_bind_int64(pStmt, 3, iStartBlock);
126832127229
sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
126833127230
sqlite3_bind_int64(pStmt, 5, iEndBlock);
126834127231
sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127124127521
int rc;
127125127522
127126127523
/* The current leaf node is full. Write it out to the database. */
127127127524
rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127128127525
if( rc!=SQLITE_OK ) return rc;
127526
+ p->nLeafAdd++;
127129127527
127130127528
/* Add the current term to the interior node tree. The term added to
127131127529
** the interior tree must:
127132127530
**
127133127531
** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127207127605
** returned. Otherwise, an SQLite error code.
127208127606
*/
127209127607
static int fts3SegWriterFlush(
127210127608
Fts3Table *p, /* Virtual table handle */
127211127609
SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127212
- int iLevel, /* Value for 'level' column of %_segdir */
127610
+ sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */
127213127611
int iIdx /* Value for 'idx' column of %_segdir */
127214127612
){
127215127613
int rc; /* Return code */
127216127614
if( pWriter->pTree ){
127217127615
sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127232127630
}else{
127233127631
/* The entire tree fits on the root node. Write it to the segdir table. */
127234127632
rc = fts3WriteSegdir(
127235127633
p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127236127634
}
127635
+ p->nLeafAdd++;
127237127636
return rc;
127238127637
}
127239127638
127240127639
/*
127241127640
** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127289127688
*/
127290127689
static int fts3SegmentMaxLevel(
127291127690
Fts3Table *p,
127292127691
int iLangid,
127293127692
int iIndex,
127294
- int *pnMax
127693
+ sqlite3_int64 *pnMax
127295127694
){
127296127695
sqlite3_stmt *pStmt;
127297127696
int rc;
127298127697
assert( iIndex>=0 && iIndex<p->nIndex );
127299127698
@@ -127303,19 +127702,42 @@
127303127702
**
127304127703
** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127305127704
*/
127306127705
rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127307127706
if( rc!=SQLITE_OK ) return rc;
127308
- sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127309
- sqlite3_bind_int(pStmt, 2,
127707
+ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127708
+ sqlite3_bind_int64(pStmt, 2,
127310127709
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127311127710
);
127312127711
if( SQLITE_ROW==sqlite3_step(pStmt) ){
127313
- *pnMax = sqlite3_column_int(pStmt, 0);
127712
+ *pnMax = sqlite3_column_int64(pStmt, 0);
127314127713
}
127315127714
return sqlite3_reset(pStmt);
127316127715
}
127716
+
127717
+/*
127718
+** Delete all entries in the %_segments table associated with the segment
127719
+** opened with seg-reader pSeg. This function does not affect the contents
127720
+** of the %_segdir table.
127721
+*/
127722
+static int fts3DeleteSegment(
127723
+ Fts3Table *p, /* FTS table handle */
127724
+ Fts3SegReader *pSeg /* Segment to delete */
127725
+){
127726
+ int rc = SQLITE_OK; /* Return code */
127727
+ if( pSeg->iStartBlock ){
127728
+ sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127729
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127730
+ if( rc==SQLITE_OK ){
127731
+ sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);
127732
+ sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);
127733
+ sqlite3_step(pDelete);
127734
+ rc = sqlite3_reset(pDelete);
127735
+ }
127736
+ }
127737
+ return rc;
127738
+}
127317127739
127318127740
/*
127319127741
** This function is used after merging multiple segments into a single large
127320127742
** segment to delete the old, now redundant, segment b-trees. Specifically,
127321127743
** it:
@@ -127335,41 +127757,36 @@
127335127757
int iIndex, /* Index for p->aIndex */
127336127758
int iLevel, /* Level of %_segdir entries to delete */
127337127759
Fts3SegReader **apSegment, /* Array of SegReader objects */
127338127760
int nReader /* Size of array apSegment */
127339127761
){
127340
- int rc; /* Return Code */
127762
+ int rc = SQLITE_OK; /* Return Code */
127341127763
int i; /* Iterator variable */
127342
- sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127764
+ sqlite3_stmt *pDelete = 0; /* SQL statement to delete rows */
127343127765
127344
- rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127345127766
for(i=0; rc==SQLITE_OK && i<nReader; i++){
127346
- Fts3SegReader *pSegment = apSegment[i];
127347
- if( pSegment->iStartBlock ){
127348
- sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock);
127349
- sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock);
127350
- sqlite3_step(pDelete);
127351
- rc = sqlite3_reset(pDelete);
127352
- }
127767
+ rc = fts3DeleteSegment(p, apSegment[i]);
127353127768
}
127354127769
if( rc!=SQLITE_OK ){
127355127770
return rc;
127356127771
}
127357127772
127358127773
assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127359127774
if( iLevel==FTS3_SEGCURSOR_ALL ){
127360127775
rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127361127776
if( rc==SQLITE_OK ){
127362
- sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127363
- sqlite3_bind_int(pDelete, 2,
127777
+ sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127778
+ sqlite3_bind_int64(pDelete, 2,
127364127779
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127365127780
);
127366127781
}
127367127782
}else{
127368127783
rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127369127784
if( rc==SQLITE_OK ){
127370
- sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
127785
+ sqlite3_bind_int64(
127786
+ pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)
127787
+ );
127371127788
}
127372127789
}
127373127790
127374127791
if( rc==SQLITE_OK ){
127375127792
sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
127842128259
int iIndex, /* Index in p->aIndex[] to merge */
127843128260
int iLevel /* Level to merge */
127844128261
){
127845128262
int rc; /* Return code */
127846128263
int iIdx = 0; /* Index of new segment */
127847
- int iNewLevel = 0; /* Level/index to create new segment at */
128264
+ sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */
127848128265
SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
127849128266
Fts3SegFilter filter; /* Segment term filter condition */
127850128267
Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
127851128268
int bIgnoreEmpty = 0; /* True to ignore empty segments */
127852128269
@@ -127921,15 +128338,32 @@
127921128338
** Flush the contents of pendingTerms to level 0 segments.
127922128339
*/
127923128340
SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
127924128341
int rc = SQLITE_OK;
127925128342
int i;
128343
+
127926128344
for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
127927128345
rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
127928128346
if( rc==SQLITE_DONE ) rc = SQLITE_OK;
127929128347
}
127930128348
sqlite3Fts3PendingTermsClear(p);
128349
+
128350
+ /* Determine the auto-incr-merge setting if unknown. If enabled,
128351
+ ** estimate the number of leaf blocks of content to be written
128352
+ */
128353
+ if( rc==SQLITE_OK && p->bHasStat
128354
+ && p->bAutoincrmerge==0xff && p->nLeafAdd>0
128355
+ ){
128356
+ sqlite3_stmt *pStmt = 0;
128357
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128358
+ if( rc==SQLITE_OK ){
128359
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
128360
+ rc = sqlite3_step(pStmt);
128361
+ p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
128362
+ rc = sqlite3_reset(pStmt);
128363
+ }
128364
+ }
127931128365
return rc;
127932128366
}
127933128367
127934128368
/*
127935128369
** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128036128470
if( a==0 ){
128037128471
*pRC = SQLITE_NOMEM;
128038128472
return;
128039128473
}
128040128474
pBlob = (char*)&a[nStat];
128041
- rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0);
128475
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128042128476
if( rc ){
128043128477
sqlite3_free(a);
128044128478
*pRC = rc;
128045128479
return;
128046128480
}
128481
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128047128482
if( sqlite3_step(pStmt)==SQLITE_ROW ){
128048128483
fts3DecodeIntArray(nStat, a,
128049128484
sqlite3_column_blob(pStmt, 0),
128050128485
sqlite3_column_bytes(pStmt, 0));
128051128486
}else{
@@ -128065,17 +128500,18 @@
128065128500
x = x + aSzIns[i] - aSzDel[i];
128066128501
}
128067128502
a[i+1] = x;
128068128503
}
128069128504
fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128070
- rc = fts3SqlStmt(p, SQL_REPLACE_DOCTOTAL, &pStmt, 0);
128505
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
128071128506
if( rc ){
128072128507
sqlite3_free(a);
128073128508
*pRC = rc;
128074128509
return;
128075128510
}
128076
- sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
128511
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128512
+ sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);
128077128513
sqlite3_step(pStmt);
128078128514
*pRC = sqlite3_reset(pStmt);
128079128515
sqlite3_free(a);
128080128516
}
128081128517
@@ -128176,11 +128612,11 @@
128176128612
for(iCol=0; iCol<=p->nColumn; iCol++){
128177128613
aSzIns[iCol] += aSz[iCol];
128178128614
}
128179128615
}
128180128616
}
128181
- if( p->bHasStat ){
128617
+ if( p->bFts4 ){
128182128618
fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128183128619
}
128184128620
sqlite3_free(aSz);
128185128621
128186128622
if( pStmt ){
@@ -128192,10 +128628,1692 @@
128192128628
}
128193128629
128194128630
return rc;
128195128631
}
128196128632
128633
+
128634
+/*
128635
+** This function opens a cursor used to read the input data for an
128636
+** incremental merge operation. Specifically, it opens a cursor to scan
128637
+** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute
128638
+** level iAbsLevel.
128639
+*/
128640
+static int fts3IncrmergeCsr(
128641
+ Fts3Table *p, /* FTS3 table handle */
128642
+ sqlite3_int64 iAbsLevel, /* Absolute level to open */
128643
+ int nSeg, /* Number of segments to merge */
128644
+ Fts3MultiSegReader *pCsr /* Cursor object to populate */
128645
+){
128646
+ int rc; /* Return Code */
128647
+ sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */
128648
+ int nByte; /* Bytes allocated at pCsr->apSegment[] */
128649
+
128650
+ /* Allocate space for the Fts3MultiSegReader.aCsr[] array */
128651
+ memset(pCsr, 0, sizeof(*pCsr));
128652
+ nByte = sizeof(Fts3SegReader *) * nSeg;
128653
+ pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);
128654
+
128655
+ if( pCsr->apSegment==0 ){
128656
+ rc = SQLITE_NOMEM;
128657
+ }else{
128658
+ memset(pCsr->apSegment, 0, nByte);
128659
+ rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
128660
+ }
128661
+ if( rc==SQLITE_OK ){
128662
+ int i;
128663
+ int rc2;
128664
+ sqlite3_bind_int64(pStmt, 1, iAbsLevel);
128665
+ assert( pCsr->nSegment==0 );
128666
+ for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){
128667
+ rc = sqlite3Fts3SegReaderNew(i, 0,
128668
+ sqlite3_column_int64(pStmt, 1), /* segdir.start_block */
128669
+ sqlite3_column_int64(pStmt, 2), /* segdir.leaves_end_block */
128670
+ sqlite3_column_int64(pStmt, 3), /* segdir.end_block */
128671
+ sqlite3_column_blob(pStmt, 4), /* segdir.root */
128672
+ sqlite3_column_bytes(pStmt, 4), /* segdir.root */
128673
+ &pCsr->apSegment[i]
128674
+ );
128675
+ pCsr->nSegment++;
128676
+ }
128677
+ rc2 = sqlite3_reset(pStmt);
128678
+ if( rc==SQLITE_OK ) rc = rc2;
128679
+ }
128680
+
128681
+ return rc;
128682
+}
128683
+
128684
+typedef struct IncrmergeWriter IncrmergeWriter;
128685
+typedef struct NodeWriter NodeWriter;
128686
+typedef struct Blob Blob;
128687
+typedef struct NodeReader NodeReader;
128688
+
128689
+/*
128690
+** An instance of the following structure is used as a dynamic buffer
128691
+** to build up nodes or other blobs of data in.
128692
+**
128693
+** The function blobGrowBuffer() is used to extend the allocation.
128694
+*/
128695
+struct Blob {
128696
+ char *a; /* Pointer to allocation */
128697
+ int n; /* Number of valid bytes of data in a[] */
128698
+ int nAlloc; /* Allocated size of a[] (nAlloc>=n) */
128699
+};
128700
+
128701
+/*
128702
+** This structure is used to build up buffers containing segment b-tree
128703
+** nodes (blocks).
128704
+*/
128705
+struct NodeWriter {
128706
+ sqlite3_int64 iBlock; /* Current block id */
128707
+ Blob key; /* Last key written to the current block */
128708
+ Blob block; /* Current block image */
128709
+};
128710
+
128711
+/*
128712
+** An object of this type contains the state required to create or append
128713
+** to an appendable b-tree segment.
128714
+*/
128715
+struct IncrmergeWriter {
128716
+ int nLeafEst; /* Space allocated for leaf blocks */
128717
+ int nWork; /* Number of leaf pages flushed */
128718
+ sqlite3_int64 iAbsLevel; /* Absolute level of input segments */
128719
+ int iIdx; /* Index of *output* segment in iAbsLevel+1 */
128720
+ sqlite3_int64 iStart; /* Block number of first allocated block */
128721
+ sqlite3_int64 iEnd; /* Block number of last allocated block */
128722
+ NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];
128723
+};
128724
+
128725
+/*
128726
+** An object of the following type is used to read data from a single
128727
+** FTS segment node. See the following functions:
128728
+**
128729
+** nodeReaderInit()
128730
+** nodeReaderNext()
128731
+** nodeReaderRelease()
128732
+*/
128733
+struct NodeReader {
128734
+ const char *aNode;
128735
+ int nNode;
128736
+ int iOff; /* Current offset within aNode[] */
128737
+
128738
+ /* Output variables. Containing the current node entry. */
128739
+ sqlite3_int64 iChild; /* Pointer to child node */
128740
+ Blob term; /* Current term */
128741
+ const char *aDoclist; /* Pointer to doclist */
128742
+ int nDoclist; /* Size of doclist in bytes */
128743
+};
128744
+
128745
+/*
128746
+** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
128747
+** Otherwise, if the allocation at pBlob->a is not already at least nMin
128748
+** bytes in size, extend (realloc) it to be so.
128749
+**
128750
+** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a
128751
+** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc
128752
+** to reflect the new size of the pBlob->a[] buffer.
128753
+*/
128754
+static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){
128755
+ if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){
128756
+ int nAlloc = nMin;
128757
+ char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);
128758
+ if( a ){
128759
+ pBlob->nAlloc = nAlloc;
128760
+ pBlob->a = a;
128761
+ }else{
128762
+ *pRc = SQLITE_NOMEM;
128763
+ }
128764
+ }
128765
+}
128766
+
128767
+/*
128768
+** Attempt to advance the node-reader object passed as the first argument to
128769
+** the next entry on the node.
128770
+**
128771
+** Return an error code if an error occurs (SQLITE_NOMEM is possible).
128772
+** Otherwise return SQLITE_OK. If there is no next entry on the node
128773
+** (e.g. because the current entry is the last) set NodeReader->aNode to
128774
+** NULL to indicate EOF. Otherwise, populate the NodeReader structure output
128775
+** variables for the new entry.
128776
+*/
128777
+static int nodeReaderNext(NodeReader *p){
128778
+ int bFirst = (p->term.n==0); /* True for first term on the node */
128779
+ int nPrefix = 0; /* Bytes to copy from previous term */
128780
+ int nSuffix = 0; /* Bytes to append to the prefix */
128781
+ int rc = SQLITE_OK; /* Return code */
128782
+
128783
+ assert( p->aNode );
128784
+ if( p->iChild && bFirst==0 ) p->iChild++;
128785
+ if( p->iOff>=p->nNode ){
128786
+ /* EOF */
128787
+ p->aNode = 0;
128788
+ }else{
128789
+ if( bFirst==0 ){
128790
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
128791
+ }
128792
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
128793
+
128794
+ blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
128795
+ if( rc==SQLITE_OK ){
128796
+ memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
128797
+ p->term.n = nPrefix+nSuffix;
128798
+ p->iOff += nSuffix;
128799
+ if( p->iChild==0 ){
128800
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
128801
+ p->aDoclist = &p->aNode[p->iOff];
128802
+ p->iOff += p->nDoclist;
128803
+ }
128804
+ }
128805
+ }
128806
+
128807
+ assert( p->iOff<=p->nNode );
128808
+
128809
+ return rc;
128810
+}
128811
+
128812
+/*
128813
+** Release all dynamic resources held by node-reader object *p.
128814
+*/
128815
+static void nodeReaderRelease(NodeReader *p){
128816
+ sqlite3_free(p->term.a);
128817
+}
128818
+
128819
+/*
128820
+** Initialize a node-reader object to read the node in buffer aNode/nNode.
128821
+**
128822
+** If successful, SQLITE_OK is returned and the NodeReader object set to
128823
+** point to the first entry on the node (if any). Otherwise, an SQLite
128824
+** error code is returned.
128825
+*/
128826
+static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){
128827
+ memset(p, 0, sizeof(NodeReader));
128828
+ p->aNode = aNode;
128829
+ p->nNode = nNode;
128830
+
128831
+ /* Figure out if this is a leaf or an internal node. */
128832
+ if( p->aNode[0] ){
128833
+ /* An internal node. */
128834
+ p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);
128835
+ }else{
128836
+ p->iOff = 1;
128837
+ }
128838
+
128839
+ return nodeReaderNext(p);
128840
+}
128841
+
128842
+/*
128843
+** This function is called while writing an FTS segment each time a leaf o
128844
+** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed
128845
+** to be greater than the largest key on the node just written, but smaller
128846
+** than or equal to the first key that will be written to the next leaf
128847
+** node.
128848
+**
128849
+** The block id of the leaf node just written to disk may be found in
128850
+** (pWriter->aNodeWriter[0].iBlock) when this function is called.
128851
+*/
128852
+static int fts3IncrmergePush(
128853
+ Fts3Table *p, /* Fts3 table handle */
128854
+ IncrmergeWriter *pWriter, /* Writer object */
128855
+ const char *zTerm, /* Term to write to internal node */
128856
+ int nTerm /* Bytes at zTerm */
128857
+){
128858
+ sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
128859
+ int iLayer;
128860
+
128861
+ assert( nTerm>0 );
128862
+ for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){
128863
+ sqlite3_int64 iNextPtr = 0;
128864
+ NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
128865
+ int rc = SQLITE_OK;
128866
+ int nPrefix;
128867
+ int nSuffix;
128868
+ int nSpace;
128869
+
128870
+ /* Figure out how much space the key will consume if it is written to
128871
+ ** the current node of layer iLayer. Due to the prefix compression,
128872
+ ** the space required changes depending on which node the key is to
128873
+ ** be added to. */
128874
+ nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
128875
+ nSuffix = nTerm - nPrefix;
128876
+ nSpace = sqlite3Fts3VarintLen(nPrefix);
128877
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
128878
+
128879
+ if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
128880
+ /* If the current node of layer iLayer contains zero keys, or if adding
128881
+ ** the key to it will not cause it to grow to larger than nNodeSize
128882
+ ** bytes in size, write the key here. */
128883
+
128884
+ Blob *pBlk = &pNode->block;
128885
+ if( pBlk->n==0 ){
128886
+ blobGrowBuffer(pBlk, p->nNodeSize, &rc);
128887
+ if( rc==SQLITE_OK ){
128888
+ pBlk->a[0] = (char)iLayer;
128889
+ pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);
128890
+ }
128891
+ }
128892
+ blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);
128893
+ blobGrowBuffer(&pNode->key, nTerm, &rc);
128894
+
128895
+ if( rc==SQLITE_OK ){
128896
+ if( pNode->key.n ){
128897
+ pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);
128898
+ }
128899
+ pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);
128900
+ memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);
128901
+ pBlk->n += nSuffix;
128902
+
128903
+ memcpy(pNode->key.a, zTerm, nTerm);
128904
+ pNode->key.n = nTerm;
128905
+ }
128906
+ }else{
128907
+ /* Otherwise, flush the the current node of layer iLayer to disk.
128908
+ ** Then allocate a new, empty sibling node. The key will be written
128909
+ ** into the parent of this node. */
128910
+ rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
128911
+
128912
+ assert( pNode->block.nAlloc>=p->nNodeSize );
128913
+ pNode->block.a[0] = (char)iLayer;
128914
+ pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);
128915
+
128916
+ iNextPtr = pNode->iBlock;
128917
+ pNode->iBlock++;
128918
+ pNode->key.n = 0;
128919
+ }
128920
+
128921
+ if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;
128922
+ iPtr = iNextPtr;
128923
+ }
128924
+
128925
+ assert( 0 );
128926
+ return 0;
128927
+}
128928
+
128929
+/*
128930
+** Append a term and (optionally) doclist to the FTS segment node currently
128931
+** stored in blob *pNode. The node need not contain any terms, but the
128932
+** header must be written before this function is called.
128933
+**
128934
+** A node header is a single 0x00 byte for a leaf node, or a height varint
128935
+** followed by the left-hand-child varint for an internal node.
128936
+**
128937
+** The term to be appended is passed via arguments zTerm/nTerm. For a
128938
+** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal
128939
+** node, both aDoclist and nDoclist must be passed 0.
128940
+**
128941
+** If the size of the value in blob pPrev is zero, then this is the first
128942
+** term written to the node. Otherwise, pPrev contains a copy of the
128943
+** previous term. Before this function returns, it is updated to contain a
128944
+** copy of zTerm/nTerm.
128945
+**
128946
+** It is assumed that the buffer associated with pNode is already large
128947
+** enough to accommodate the new entry. The buffer associated with pPrev
128948
+** is extended by this function if requrired.
128949
+**
128950
+** If an error (i.e. OOM condition) occurs, an SQLite error code is
128951
+** returned. Otherwise, SQLITE_OK.
128952
+*/
128953
+static int fts3AppendToNode(
128954
+ Blob *pNode, /* Current node image to append to */
128955
+ Blob *pPrev, /* Buffer containing previous term written */
128956
+ const char *zTerm, /* New term to write */
128957
+ int nTerm, /* Size of zTerm in bytes */
128958
+ const char *aDoclist, /* Doclist (or NULL) to write */
128959
+ int nDoclist /* Size of aDoclist in bytes */
128960
+){
128961
+ int rc = SQLITE_OK; /* Return code */
128962
+ int bFirst = (pPrev->n==0); /* True if this is the first term written */
128963
+ int nPrefix; /* Size of term prefix in bytes */
128964
+ int nSuffix; /* Size of term suffix in bytes */
128965
+
128966
+ /* Node must have already been started. There must be a doclist for a
128967
+ ** leaf node, and there must not be a doclist for an internal node. */
128968
+ assert( pNode->n>0 );
128969
+ assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
128970
+
128971
+ blobGrowBuffer(pPrev, nTerm, &rc);
128972
+ if( rc!=SQLITE_OK ) return rc;
128973
+
128974
+ nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
128975
+ nSuffix = nTerm - nPrefix;
128976
+ memcpy(pPrev->a, zTerm, nTerm);
128977
+ pPrev->n = nTerm;
128978
+
128979
+ if( bFirst==0 ){
128980
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
128981
+ }
128982
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);
128983
+ memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);
128984
+ pNode->n += nSuffix;
128985
+
128986
+ if( aDoclist ){
128987
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);
128988
+ memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);
128989
+ pNode->n += nDoclist;
128990
+ }
128991
+
128992
+ assert( pNode->n<=pNode->nAlloc );
128993
+
128994
+ return SQLITE_OK;
128995
+}
128996
+
128997
+/*
128998
+** Append the current term and doclist pointed to by cursor pCsr to the
128999
+** appendable b-tree segment opened for writing by pWriter.
129000
+**
129001
+** Return SQLITE_OK if successful, or an SQLite error code otherwise.
129002
+*/
129003
+static int fts3IncrmergeAppend(
129004
+ Fts3Table *p, /* Fts3 table handle */
129005
+ IncrmergeWriter *pWriter, /* Writer object */
129006
+ Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */
129007
+){
129008
+ const char *zTerm = pCsr->zTerm;
129009
+ int nTerm = pCsr->nTerm;
129010
+ const char *aDoclist = pCsr->aDoclist;
129011
+ int nDoclist = pCsr->nDoclist;
129012
+ int rc = SQLITE_OK; /* Return code */
129013
+ int nSpace; /* Total space in bytes required on leaf */
129014
+ int nPrefix; /* Size of prefix shared with previous term */
129015
+ int nSuffix; /* Size of suffix (nTerm - nPrefix) */
129016
+ NodeWriter *pLeaf; /* Object used to write leaf nodes */
129017
+
129018
+ pLeaf = &pWriter->aNodeWriter[0];
129019
+ nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);
129020
+ nSuffix = nTerm - nPrefix;
129021
+
129022
+ nSpace = sqlite3Fts3VarintLen(nPrefix);
129023
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129024
+ nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129025
+
129026
+ /* If the current block is not empty, and if adding this term/doclist
129027
+ ** to the current block would make it larger than Fts3Table.nNodeSize
129028
+ ** bytes, write this block out to the database. */
129029
+ if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){
129030
+ rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
129031
+ pWriter->nWork++;
129032
+
129033
+ /* Add the current term to the parent node. The term added to the
129034
+ ** parent must:
129035
+ **
129036
+ ** a) be greater than the largest term on the leaf node just written
129037
+ ** to the database (still available in pLeaf->key), and
129038
+ **
129039
+ ** b) be less than or equal to the term about to be added to the new
129040
+ ** leaf node (zTerm/nTerm).
129041
+ **
129042
+ ** In other words, it must be the prefix of zTerm 1 byte longer than
129043
+ ** the common prefix (if any) of zTerm and pWriter->zTerm.
129044
+ */
129045
+ if( rc==SQLITE_OK ){
129046
+ rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
129047
+ }
129048
+
129049
+ /* Advance to the next output block */
129050
+ pLeaf->iBlock++;
129051
+ pLeaf->key.n = 0;
129052
+ pLeaf->block.n = 0;
129053
+
129054
+ nPrefix = 0;
129055
+ nSuffix = nTerm;
129056
+ nSpace = 1;
129057
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129058
+ nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129059
+ }
129060
+
129061
+ blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);
129062
+
129063
+ if( rc==SQLITE_OK ){
129064
+ if( pLeaf->block.n==0 ){
129065
+ pLeaf->block.n = 1;
129066
+ pLeaf->block.a[0] = '\0';
129067
+ }
129068
+ rc = fts3AppendToNode(
129069
+ &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist
129070
+ );
129071
+ }
129072
+
129073
+ return rc;
129074
+}
129075
+
129076
+/*
129077
+** This function is called to release all dynamic resources held by the
129078
+** merge-writer object pWriter, and if no error has occurred, to flush
129079
+** all outstanding node buffers held by pWriter to disk.
129080
+**
129081
+** If *pRc is not SQLITE_OK when this function is called, then no attempt
129082
+** is made to write any data to disk. Instead, this function serves only
129083
+** to release outstanding resources.
129084
+**
129085
+** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while
129086
+** flushing buffers to disk, *pRc is set to an SQLite error code before
129087
+** returning.
129088
+*/
129089
+static void fts3IncrmergeRelease(
129090
+ Fts3Table *p, /* FTS3 table handle */
129091
+ IncrmergeWriter *pWriter, /* Merge-writer object */
129092
+ int *pRc /* IN/OUT: Error code */
129093
+){
129094
+ int i; /* Used to iterate through non-root layers */
129095
+ int iRoot; /* Index of root in pWriter->aNodeWriter */
129096
+ NodeWriter *pRoot; /* NodeWriter for root node */
129097
+ int rc = *pRc; /* Error code */
129098
+
129099
+ /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment
129100
+ ** root node. If the segment fits entirely on a single leaf node, iRoot
129101
+ ** will be set to 0. If the root node is the parent of the leaves, iRoot
129102
+ ** will be 1. And so on. */
129103
+ for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){
129104
+ NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
129105
+ if( pNode->block.n>0 ) break;
129106
+ assert( *pRc || pNode->block.nAlloc==0 );
129107
+ assert( *pRc || pNode->key.nAlloc==0 );
129108
+ sqlite3_free(pNode->block.a);
129109
+ sqlite3_free(pNode->key.a);
129110
+ }
129111
+
129112
+ /* Empty output segment. This is a no-op. */
129113
+ if( iRoot<0 ) return;
129114
+
129115
+ /* The entire output segment fits on a single node. Normally, this means
129116
+ ** the node would be stored as a blob in the "root" column of the %_segdir
129117
+ ** table. However, this is not permitted in this case. The problem is that
129118
+ ** space has already been reserved in the %_segments table, and so the
129119
+ ** start_block and end_block fields of the %_segdir table must be populated.
129120
+ ** And, by design or by accident, released versions of FTS cannot handle
129121
+ ** segments that fit entirely on the root node with start_block!=0.
129122
+ **
129123
+ ** Instead, create a synthetic root node that contains nothing but a
129124
+ ** pointer to the single content node. So that the segment consists of a
129125
+ ** single leaf and a single interior (root) node.
129126
+ **
129127
+ ** Todo: Better might be to defer allocating space in the %_segments
129128
+ ** table until we are sure it is needed.
129129
+ */
129130
+ if( iRoot==0 ){
129131
+ Blob *pBlock = &pWriter->aNodeWriter[1].block;
129132
+ blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);
129133
+ if( rc==SQLITE_OK ){
129134
+ pBlock->a[0] = 0x01;
129135
+ pBlock->n = 1 + sqlite3Fts3PutVarint(
129136
+ &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
129137
+ );
129138
+ }
129139
+ iRoot = 1;
129140
+ }
129141
+ pRoot = &pWriter->aNodeWriter[iRoot];
129142
+
129143
+ /* Flush all currently outstanding nodes to disk. */
129144
+ for(i=0; i<iRoot; i++){
129145
+ NodeWriter *pNode = &pWriter->aNodeWriter[i];
129146
+ if( pNode->block.n>0 && rc==SQLITE_OK ){
129147
+ rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
129148
+ }
129149
+ sqlite3_free(pNode->block.a);
129150
+ sqlite3_free(pNode->key.a);
129151
+ }
129152
+
129153
+ /* Write the %_segdir record. */
129154
+ if( rc==SQLITE_OK ){
129155
+ rc = fts3WriteSegdir(p,
129156
+ pWriter->iAbsLevel+1, /* level */
129157
+ pWriter->iIdx, /* idx */
129158
+ pWriter->iStart, /* start_block */
129159
+ pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
129160
+ pWriter->iEnd, /* end_block */
129161
+ pRoot->block.a, pRoot->block.n /* root */
129162
+ );
129163
+ }
129164
+ sqlite3_free(pRoot->block.a);
129165
+ sqlite3_free(pRoot->key.a);
129166
+
129167
+ *pRc = rc;
129168
+}
129169
+
129170
+/*
129171
+** Compare the term in buffer zLhs (size in bytes nLhs) with that in
129172
+** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of
129173
+** the other, it is considered to be smaller than the other.
129174
+**
129175
+** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve
129176
+** if it is greater.
129177
+*/
129178
+static int fts3TermCmp(
129179
+ const char *zLhs, int nLhs, /* LHS of comparison */
129180
+ const char *zRhs, int nRhs /* RHS of comparison */
129181
+){
129182
+ int nCmp = MIN(nLhs, nRhs);
129183
+ int res;
129184
+
129185
+ res = memcmp(zLhs, zRhs, nCmp);
129186
+ if( res==0 ) res = nLhs - nRhs;
129187
+
129188
+ return res;
129189
+}
129190
+
129191
+
129192
+/*
129193
+** Query to see if the entry in the %_segments table with blockid iEnd is
129194
+** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before
129195
+** returning. Otherwise, set *pbRes to 0.
129196
+**
129197
+** Or, if an error occurs while querying the database, return an SQLite
129198
+** error code. The final value of *pbRes is undefined in this case.
129199
+**
129200
+** This is used to test if a segment is an "appendable" segment. If it
129201
+** is, then a NULL entry has been inserted into the %_segments table
129202
+** with blockid %_segdir.end_block.
129203
+*/
129204
+static int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){
129205
+ int bRes = 0; /* Result to set *pbRes to */
129206
+ sqlite3_stmt *pCheck = 0; /* Statement to query database with */
129207
+ int rc; /* Return code */
129208
+
129209
+ rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
129210
+ if( rc==SQLITE_OK ){
129211
+ sqlite3_bind_int64(pCheck, 1, iEnd);
129212
+ if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
129213
+ rc = sqlite3_reset(pCheck);
129214
+ }
129215
+
129216
+ *pbRes = bRes;
129217
+ return rc;
129218
+}
129219
+
129220
+/*
129221
+** This function is called when initializing an incremental-merge operation.
129222
+** It checks if the existing segment with index value iIdx at absolute level
129223
+** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the
129224
+** merge-writer object *pWriter is initialized to write to it.
129225
+**
129226
+** An existing segment can be appended to by an incremental merge if:
129227
+**
129228
+** * It was initially created as an appendable segment (with all required
129229
+** space pre-allocated), and
129230
+**
129231
+** * The first key read from the input (arguments zKey and nKey) is
129232
+** greater than the largest key currently stored in the potential
129233
+** output segment.
129234
+*/
129235
+static int fts3IncrmergeLoad(
129236
+ Fts3Table *p, /* Fts3 table handle */
129237
+ sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129238
+ int iIdx, /* Index of candidate output segment */
129239
+ const char *zKey, /* First key to write */
129240
+ int nKey, /* Number of bytes in nKey */
129241
+ IncrmergeWriter *pWriter /* Populate this object */
129242
+){
129243
+ int rc; /* Return code */
129244
+ sqlite3_stmt *pSelect = 0; /* SELECT to read %_segdir entry */
129245
+
129246
+ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);
129247
+ if( rc==SQLITE_OK ){
129248
+ sqlite3_int64 iStart = 0; /* Value of %_segdir.start_block */
129249
+ sqlite3_int64 iLeafEnd = 0; /* Value of %_segdir.leaves_end_block */
129250
+ sqlite3_int64 iEnd = 0; /* Value of %_segdir.end_block */
129251
+ const char *aRoot = 0; /* Pointer to %_segdir.root buffer */
129252
+ int nRoot = 0; /* Size of aRoot[] in bytes */
129253
+ int rc2; /* Return code from sqlite3_reset() */
129254
+ int bAppendable = 0; /* Set to true if segment is appendable */
129255
+
129256
+ /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */
129257
+ sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);
129258
+ sqlite3_bind_int(pSelect, 2, iIdx);
129259
+ if( sqlite3_step(pSelect)==SQLITE_ROW ){
129260
+ iStart = sqlite3_column_int64(pSelect, 1);
129261
+ iLeafEnd = sqlite3_column_int64(pSelect, 2);
129262
+ iEnd = sqlite3_column_int64(pSelect, 3);
129263
+ nRoot = sqlite3_column_bytes(pSelect, 4);
129264
+ aRoot = sqlite3_column_blob(pSelect, 4);
129265
+ }else{
129266
+ return sqlite3_reset(pSelect);
129267
+ }
129268
+
129269
+ /* Check for the zero-length marker in the %_segments table */
129270
+ rc = fts3IsAppendable(p, iEnd, &bAppendable);
129271
+
129272
+ /* Check that zKey/nKey is larger than the largest key the candidate */
129273
+ if( rc==SQLITE_OK && bAppendable ){
129274
+ char *aLeaf = 0;
129275
+ int nLeaf = 0;
129276
+
129277
+ rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);
129278
+ if( rc==SQLITE_OK ){
129279
+ NodeReader reader;
129280
+ for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);
129281
+ rc==SQLITE_OK && reader.aNode;
129282
+ rc = nodeReaderNext(&reader)
129283
+ ){
129284
+ assert( reader.aNode );
129285
+ }
129286
+ if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){
129287
+ bAppendable = 0;
129288
+ }
129289
+ nodeReaderRelease(&reader);
129290
+ }
129291
+ sqlite3_free(aLeaf);
129292
+ }
129293
+
129294
+ if( rc==SQLITE_OK && bAppendable ){
129295
+ /* It is possible to append to this segment. Set up the IncrmergeWriter
129296
+ ** object to do so. */
129297
+ int i;
129298
+ int nHeight = (int)aRoot[0];
129299
+ NodeWriter *pNode;
129300
+
129301
+ pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
129302
+ pWriter->iStart = iStart;
129303
+ pWriter->iEnd = iEnd;
129304
+ pWriter->iAbsLevel = iAbsLevel;
129305
+ pWriter->iIdx = iIdx;
129306
+
129307
+ for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129308
+ pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129309
+ }
129310
+
129311
+ pNode = &pWriter->aNodeWriter[nHeight];
129312
+ pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
129313
+ blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
129314
+ if( rc==SQLITE_OK ){
129315
+ memcpy(pNode->block.a, aRoot, nRoot);
129316
+ pNode->block.n = nRoot;
129317
+ }
129318
+
129319
+ for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
129320
+ NodeReader reader;
129321
+ pNode = &pWriter->aNodeWriter[i];
129322
+
129323
+ rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
129324
+ while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
129325
+ blobGrowBuffer(&pNode->key, reader.term.n, &rc);
129326
+ if( rc==SQLITE_OK ){
129327
+ memcpy(pNode->key.a, reader.term.a, reader.term.n);
129328
+ pNode->key.n = reader.term.n;
129329
+ if( i>0 ){
129330
+ char *aBlock = 0;
129331
+ int nBlock = 0;
129332
+ pNode = &pWriter->aNodeWriter[i-1];
129333
+ pNode->iBlock = reader.iChild;
129334
+ rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
129335
+ blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
129336
+ if( rc==SQLITE_OK ){
129337
+ memcpy(pNode->block.a, aBlock, nBlock);
129338
+ pNode->block.n = nBlock;
129339
+ }
129340
+ sqlite3_free(aBlock);
129341
+ }
129342
+ }
129343
+ nodeReaderRelease(&reader);
129344
+ }
129345
+ }
129346
+
129347
+ rc2 = sqlite3_reset(pSelect);
129348
+ if( rc==SQLITE_OK ) rc = rc2;
129349
+ }
129350
+
129351
+ return rc;
129352
+}
129353
+
129354
+/*
129355
+** Determine the largest segment index value that exists within absolute
129356
+** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus
129357
+** one before returning SQLITE_OK. Or, if there are no segments at all
129358
+** within level iAbsLevel, set *piIdx to zero.
129359
+**
129360
+** If an error occurs, return an SQLite error code. The final value of
129361
+** *piIdx is undefined in this case.
129362
+*/
129363
+static int fts3IncrmergeOutputIdx(
129364
+ Fts3Table *p, /* FTS Table handle */
129365
+ sqlite3_int64 iAbsLevel, /* Absolute index of input segments */
129366
+ int *piIdx /* OUT: Next free index at iAbsLevel+1 */
129367
+){
129368
+ int rc;
129369
+ sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */
129370
+
129371
+ rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);
129372
+ if( rc==SQLITE_OK ){
129373
+ sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);
129374
+ sqlite3_step(pOutputIdx);
129375
+ *piIdx = sqlite3_column_int(pOutputIdx, 0);
129376
+ rc = sqlite3_reset(pOutputIdx);
129377
+ }
129378
+
129379
+ return rc;
129380
+}
129381
+
129382
+/*
129383
+** Allocate an appendable output segment on absolute level iAbsLevel+1
129384
+** with idx value iIdx.
129385
+**
129386
+** In the %_segdir table, a segment is defined by the values in three
129387
+** columns:
129388
+**
129389
+** start_block
129390
+** leaves_end_block
129391
+** end_block
129392
+**
129393
+** When an appendable segment is allocated, it is estimated that the
129394
+** maximum number of leaf blocks that may be required is the sum of the
129395
+** number of leaf blocks consumed by the input segments, plus the number
129396
+** of input segments, multiplied by two. This value is stored in stack
129397
+** variable nLeafEst.
129398
+**
129399
+** A total of 16*nLeafEst blocks are allocated when an appendable segment
129400
+** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous
129401
+** array of leaf nodes starts at the first block allocated. The array
129402
+** of interior nodes that are parents of the leaf nodes start at block
129403
+** (start_block + (1 + end_block - start_block) / 16). And so on.
129404
+**
129405
+** In the actual code below, the value "16" is replaced with the
129406
+** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.
129407
+*/
129408
+static int fts3IncrmergeWriter(
129409
+ Fts3Table *p, /* Fts3 table handle */
129410
+ sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129411
+ int iIdx, /* Index of new output segment */
129412
+ Fts3MultiSegReader *pCsr, /* Cursor that data will be read from */
129413
+ IncrmergeWriter *pWriter /* Populate this object */
129414
+){
129415
+ int rc; /* Return Code */
129416
+ int i; /* Iterator variable */
129417
+ int nLeafEst = 0; /* Blocks allocated for leaf nodes */
129418
+ sqlite3_stmt *pLeafEst = 0; /* SQL used to determine nLeafEst */
129419
+ sqlite3_stmt *pFirstBlock = 0; /* SQL used to determine first block */
129420
+
129421
+ /* Calculate nLeafEst. */
129422
+ rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);
129423
+ if( rc==SQLITE_OK ){
129424
+ sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);
129425
+ sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);
129426
+ if( SQLITE_ROW==sqlite3_step(pLeafEst) ){
129427
+ nLeafEst = sqlite3_column_int(pLeafEst, 0);
129428
+ }
129429
+ rc = sqlite3_reset(pLeafEst);
129430
+ }
129431
+ if( rc!=SQLITE_OK ) return rc;
129432
+
129433
+ /* Calculate the first block to use in the output segment */
129434
+ rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);
129435
+ if( rc==SQLITE_OK ){
129436
+ if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){
129437
+ pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
129438
+ pWriter->iEnd = pWriter->iStart - 1;
129439
+ pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
129440
+ }
129441
+ rc = sqlite3_reset(pFirstBlock);
129442
+ }
129443
+ if( rc!=SQLITE_OK ) return rc;
129444
+
129445
+ /* Insert the marker in the %_segments table to make sure nobody tries
129446
+ ** to steal the space just allocated. This is also used to identify
129447
+ ** appendable segments. */
129448
+ rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
129449
+ if( rc!=SQLITE_OK ) return rc;
129450
+
129451
+ pWriter->iAbsLevel = iAbsLevel;
129452
+ pWriter->nLeafEst = nLeafEst;
129453
+ pWriter->iIdx = iIdx;
129454
+
129455
+ /* Set up the array of NodeWriter objects */
129456
+ for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129457
+ pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129458
+ }
129459
+ return SQLITE_OK;
129460
+}
129461
+
129462
+/*
129463
+** Remove an entry from the %_segdir table. This involves running the
129464
+** following two statements:
129465
+**
129466
+** DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx
129467
+** UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx
129468
+**
129469
+** The DELETE statement removes the specific %_segdir level. The UPDATE
129470
+** statement ensures that the remaining segments have contiguously allocated
129471
+** idx values.
129472
+*/
129473
+static int fts3RemoveSegdirEntry(
129474
+ Fts3Table *p, /* FTS3 table handle */
129475
+ sqlite3_int64 iAbsLevel, /* Absolute level to delete from */
129476
+ int iIdx /* Index of %_segdir entry to delete */
129477
+){
129478
+ int rc; /* Return code */
129479
+ sqlite3_stmt *pDelete = 0; /* DELETE statement */
129480
+
129481
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);
129482
+ if( rc==SQLITE_OK ){
129483
+ sqlite3_bind_int64(pDelete, 1, iAbsLevel);
129484
+ sqlite3_bind_int(pDelete, 2, iIdx);
129485
+ sqlite3_step(pDelete);
129486
+ rc = sqlite3_reset(pDelete);
129487
+ }
129488
+
129489
+ return rc;
129490
+}
129491
+
129492
+/*
129493
+** One or more segments have just been removed from absolute level iAbsLevel.
129494
+** Update the 'idx' values of the remaining segments in the level so that
129495
+** the idx values are a contiguous sequence starting from 0.
129496
+*/
129497
+static int fts3RepackSegdirLevel(
129498
+ Fts3Table *p, /* FTS3 table handle */
129499
+ sqlite3_int64 iAbsLevel /* Absolute level to repack */
129500
+){
129501
+ int rc; /* Return code */
129502
+ int *aIdx = 0; /* Array of remaining idx values */
129503
+ int nIdx = 0; /* Valid entries in aIdx[] */
129504
+ int nAlloc = 0; /* Allocated size of aIdx[] */
129505
+ int i; /* Iterator variable */
129506
+ sqlite3_stmt *pSelect = 0; /* Select statement to read idx values */
129507
+ sqlite3_stmt *pUpdate = 0; /* Update statement to modify idx values */
129508
+
129509
+ rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);
129510
+ if( rc==SQLITE_OK ){
129511
+ int rc2;
129512
+ sqlite3_bind_int64(pSelect, 1, iAbsLevel);
129513
+ while( SQLITE_ROW==sqlite3_step(pSelect) ){
129514
+ if( nIdx>=nAlloc ){
129515
+ int *aNew;
129516
+ nAlloc += 16;
129517
+ aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));
129518
+ if( !aNew ){
129519
+ rc = SQLITE_NOMEM;
129520
+ break;
129521
+ }
129522
+ aIdx = aNew;
129523
+ }
129524
+ aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);
129525
+ }
129526
+ rc2 = sqlite3_reset(pSelect);
129527
+ if( rc==SQLITE_OK ) rc = rc2;
129528
+ }
129529
+
129530
+ if( rc==SQLITE_OK ){
129531
+ rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);
129532
+ }
129533
+ if( rc==SQLITE_OK ){
129534
+ sqlite3_bind_int64(pUpdate, 2, iAbsLevel);
129535
+ }
129536
+
129537
+ assert( p->bIgnoreSavepoint==0 );
129538
+ p->bIgnoreSavepoint = 1;
129539
+ for(i=0; rc==SQLITE_OK && i<nIdx; i++){
129540
+ if( aIdx[i]!=i ){
129541
+ sqlite3_bind_int(pUpdate, 3, aIdx[i]);
129542
+ sqlite3_bind_int(pUpdate, 1, i);
129543
+ sqlite3_step(pUpdate);
129544
+ rc = sqlite3_reset(pUpdate);
129545
+ }
129546
+ }
129547
+ p->bIgnoreSavepoint = 0;
129548
+
129549
+ sqlite3_free(aIdx);
129550
+ return rc;
129551
+}
129552
+
129553
+static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){
129554
+ pNode->a[0] = (char)iHeight;
129555
+ if( iChild ){
129556
+ assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );
129557
+ pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);
129558
+ }else{
129559
+ assert( pNode->nAlloc>=1 );
129560
+ pNode->n = 1;
129561
+ }
129562
+}
129563
+
129564
+/*
129565
+** The first two arguments are a pointer to and the size of a segment b-tree
129566
+** node. The node may be a leaf or an internal node.
129567
+**
129568
+** This function creates a new node image in blob object *pNew by copying
129569
+** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)
129570
+** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.
129571
+*/
129572
+static int fts3TruncateNode(
129573
+ const char *aNode, /* Current node image */
129574
+ int nNode, /* Size of aNode in bytes */
129575
+ Blob *pNew, /* OUT: Write new node image here */
129576
+ const char *zTerm, /* Omit all terms smaller than this */
129577
+ int nTerm, /* Size of zTerm in bytes */
129578
+ sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
129579
+){
129580
+ NodeReader reader; /* Reader object */
129581
+ Blob prev = {0, 0, 0}; /* Previous term written to new node */
129582
+ int rc = SQLITE_OK; /* Return code */
129583
+ int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
129584
+
129585
+ /* Allocate required output space */
129586
+ blobGrowBuffer(pNew, nNode, &rc);
129587
+ if( rc!=SQLITE_OK ) return rc;
129588
+ pNew->n = 0;
129589
+
129590
+ /* Populate new node buffer */
129591
+ for(rc = nodeReaderInit(&reader, aNode, nNode);
129592
+ rc==SQLITE_OK && reader.aNode;
129593
+ rc = nodeReaderNext(&reader)
129594
+ ){
129595
+ if( pNew->n==0 ){
129596
+ int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);
129597
+ if( res<0 || (bLeaf==0 && res==0) ) continue;
129598
+ fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129599
+ *piBlock = reader.iChild;
129600
+ }
129601
+ rc = fts3AppendToNode(
129602
+ pNew, &prev, reader.term.a, reader.term.n,
129603
+ reader.aDoclist, reader.nDoclist
129604
+ );
129605
+ if( rc!=SQLITE_OK ) break;
129606
+ }
129607
+ if( pNew->n==0 ){
129608
+ fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129609
+ *piBlock = reader.iChild;
129610
+ }
129611
+ assert( pNew->n<=pNew->nAlloc );
129612
+
129613
+ nodeReaderRelease(&reader);
129614
+ sqlite3_free(prev.a);
129615
+ return rc;
129616
+}
129617
+
129618
+/*
129619
+** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute
129620
+** level iAbsLevel. This may involve deleting entries from the %_segments
129621
+** table, and modifying existing entries in both the %_segments and %_segdir
129622
+** tables.
129623
+**
129624
+** SQLITE_OK is returned if the segment is updated successfully. Or an
129625
+** SQLite error code otherwise.
129626
+*/
129627
+static int fts3TruncateSegment(
129628
+ Fts3Table *p, /* FTS3 table handle */
129629
+ sqlite3_int64 iAbsLevel, /* Absolute level of segment to modify */
129630
+ int iIdx, /* Index within level of segment to modify */
129631
+ const char *zTerm, /* Remove terms smaller than this */
129632
+ int nTerm /* Number of bytes in buffer zTerm */
129633
+){
129634
+ int rc = SQLITE_OK; /* Return code */
129635
+ Blob root = {0,0,0}; /* New root page image */
129636
+ Blob block = {0,0,0}; /* Buffer used for any other block */
129637
+ sqlite3_int64 iBlock = 0; /* Block id */
129638
+ sqlite3_int64 iNewStart = 0; /* New value for iStartBlock */
129639
+ sqlite3_int64 iOldStart = 0; /* Old value for iStartBlock */
129640
+ sqlite3_stmt *pFetch = 0; /* Statement used to fetch segdir */
129641
+
129642
+ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);
129643
+ if( rc==SQLITE_OK ){
129644
+ int rc2; /* sqlite3_reset() return code */
129645
+ sqlite3_bind_int64(pFetch, 1, iAbsLevel);
129646
+ sqlite3_bind_int(pFetch, 2, iIdx);
129647
+ if( SQLITE_ROW==sqlite3_step(pFetch) ){
129648
+ const char *aRoot = sqlite3_column_blob(pFetch, 4);
129649
+ int nRoot = sqlite3_column_bytes(pFetch, 4);
129650
+ iOldStart = sqlite3_column_int64(pFetch, 1);
129651
+ rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);
129652
+ }
129653
+ rc2 = sqlite3_reset(pFetch);
129654
+ if( rc==SQLITE_OK ) rc = rc2;
129655
+ }
129656
+
129657
+ while( rc==SQLITE_OK && iBlock ){
129658
+ char *aBlock = 0;
129659
+ int nBlock = 0;
129660
+ iNewStart = iBlock;
129661
+
129662
+ rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);
129663
+ if( rc==SQLITE_OK ){
129664
+ rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);
129665
+ }
129666
+ if( rc==SQLITE_OK ){
129667
+ rc = fts3WriteSegment(p, iNewStart, block.a, block.n);
129668
+ }
129669
+ sqlite3_free(aBlock);
129670
+ }
129671
+
129672
+ /* Variable iNewStart now contains the first valid leaf node. */
129673
+ if( rc==SQLITE_OK && iNewStart ){
129674
+ sqlite3_stmt *pDel = 0;
129675
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);
129676
+ if( rc==SQLITE_OK ){
129677
+ sqlite3_bind_int64(pDel, 1, iOldStart);
129678
+ sqlite3_bind_int64(pDel, 2, iNewStart-1);
129679
+ sqlite3_step(pDel);
129680
+ rc = sqlite3_reset(pDel);
129681
+ }
129682
+ }
129683
+
129684
+ if( rc==SQLITE_OK ){
129685
+ sqlite3_stmt *pChomp = 0;
129686
+ rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);
129687
+ if( rc==SQLITE_OK ){
129688
+ sqlite3_bind_int64(pChomp, 1, iNewStart);
129689
+ sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);
129690
+ sqlite3_bind_int64(pChomp, 3, iAbsLevel);
129691
+ sqlite3_bind_int(pChomp, 4, iIdx);
129692
+ sqlite3_step(pChomp);
129693
+ rc = sqlite3_reset(pChomp);
129694
+ }
129695
+ }
129696
+
129697
+ sqlite3_free(root.a);
129698
+ sqlite3_free(block.a);
129699
+ return rc;
129700
+}
129701
+
129702
+/*
129703
+** This function is called after an incrmental-merge operation has run to
129704
+** merge (or partially merge) two or more segments from absolute level
129705
+** iAbsLevel.
129706
+**
129707
+** Each input segment is either removed from the db completely (if all of
129708
+** its data was copied to the output segment by the incrmerge operation)
129709
+** or modified in place so that it no longer contains those entries that
129710
+** have been duplicated in the output segment.
129711
+*/
129712
+static int fts3IncrmergeChomp(
129713
+ Fts3Table *p, /* FTS table handle */
129714
+ sqlite3_int64 iAbsLevel, /* Absolute level containing segments */
129715
+ Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */
129716
+ int *pnRem /* Number of segments not deleted */
129717
+){
129718
+ int i;
129719
+ int nRem = 0;
129720
+ int rc = SQLITE_OK;
129721
+
129722
+ for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){
129723
+ Fts3SegReader *pSeg = 0;
129724
+ int j;
129725
+
129726
+ /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding
129727
+ ** somewhere in the pCsr->apSegment[] array. */
129728
+ for(j=0; ALWAYS(j<pCsr->nSegment); j++){
129729
+ pSeg = pCsr->apSegment[j];
129730
+ if( pSeg->iIdx==i ) break;
129731
+ }
129732
+ assert( j<pCsr->nSegment && pSeg->iIdx==i );
129733
+
129734
+ if( pSeg->aNode==0 ){
129735
+ /* Seg-reader is at EOF. Remove the entire input segment. */
129736
+ rc = fts3DeleteSegment(p, pSeg);
129737
+ if( rc==SQLITE_OK ){
129738
+ rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);
129739
+ }
129740
+ *pnRem = 0;
129741
+ }else{
129742
+ /* The incremental merge did not copy all the data from this
129743
+ ** segment to the upper level. The segment is modified in place
129744
+ ** so that it contains no keys smaller than zTerm/nTerm. */
129745
+ const char *zTerm = pSeg->zTerm;
129746
+ int nTerm = pSeg->nTerm;
129747
+ rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);
129748
+ nRem++;
129749
+ }
129750
+ }
129751
+
129752
+ if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){
129753
+ rc = fts3RepackSegdirLevel(p, iAbsLevel);
129754
+ }
129755
+
129756
+ *pnRem = nRem;
129757
+ return rc;
129758
+}
129759
+
129760
+/*
129761
+** Store an incr-merge hint in the database.
129762
+*/
129763
+static int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){
129764
+ sqlite3_stmt *pReplace = 0;
129765
+ int rc; /* Return code */
129766
+
129767
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
129768
+ if( rc==SQLITE_OK ){
129769
+ sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);
129770
+ sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);
129771
+ sqlite3_step(pReplace);
129772
+ rc = sqlite3_reset(pReplace);
129773
+ }
129774
+
129775
+ return rc;
129776
+}
129777
+
129778
+/*
129779
+** Load an incr-merge hint from the database. The incr-merge hint, if one
129780
+** exists, is stored in the rowid==1 row of the %_stat table.
129781
+**
129782
+** If successful, populate blob *pHint with the value read from the %_stat
129783
+** table and return SQLITE_OK. Otherwise, if an error occurs, return an
129784
+** SQLite error code.
129785
+*/
129786
+static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){
129787
+ sqlite3_stmt *pSelect = 0;
129788
+ int rc;
129789
+
129790
+ pHint->n = 0;
129791
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
129792
+ if( rc==SQLITE_OK ){
129793
+ int rc2;
129794
+ sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
129795
+ if( SQLITE_ROW==sqlite3_step(pSelect) ){
129796
+ const char *aHint = sqlite3_column_blob(pSelect, 0);
129797
+ int nHint = sqlite3_column_bytes(pSelect, 0);
129798
+ if( aHint ){
129799
+ blobGrowBuffer(pHint, nHint, &rc);
129800
+ if( rc==SQLITE_OK ){
129801
+ memcpy(pHint->a, aHint, nHint);
129802
+ pHint->n = nHint;
129803
+ }
129804
+ }
129805
+ }
129806
+ rc2 = sqlite3_reset(pSelect);
129807
+ if( rc==SQLITE_OK ) rc = rc2;
129808
+ }
129809
+
129810
+ return rc;
129811
+}
129812
+
129813
+/*
129814
+** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
129815
+** Otherwise, append an entry to the hint stored in blob *pHint. Each entry
129816
+** consists of two varints, the absolute level number of the input segments
129817
+** and the number of input segments.
129818
+**
129819
+** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,
129820
+** set *pRc to an SQLite error code before returning.
129821
+*/
129822
+static void fts3IncrmergeHintPush(
129823
+ Blob *pHint, /* Hint blob to append to */
129824
+ i64 iAbsLevel, /* First varint to store in hint */
129825
+ int nInput, /* Second varint to store in hint */
129826
+ int *pRc /* IN/OUT: Error code */
129827
+){
129828
+ blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);
129829
+ if( *pRc==SQLITE_OK ){
129830
+ pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);
129831
+ pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);
129832
+ }
129833
+}
129834
+
129835
+/*
129836
+** Read the last entry (most recently pushed) from the hint blob *pHint
129837
+** and then remove the entry. Write the two values read to *piAbsLevel and
129838
+** *pnInput before returning.
129839
+**
129840
+** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does
129841
+** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.
129842
+*/
129843
+static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
129844
+ const int nHint = pHint->n;
129845
+ int i;
129846
+
129847
+ i = pHint->n-2;
129848
+ while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129849
+ while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129850
+
129851
+ pHint->n = i;
129852
+ i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
129853
+ i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
129854
+ if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
129855
+
129856
+ return SQLITE_OK;
129857
+}
129858
+
129859
+
129860
+/*
129861
+** Attempt an incremental merge that writes nMerge leaf blocks.
129862
+**
129863
+** Incremental merges happen nMin segments at a time. The two
129864
+** segments to be merged are the nMin oldest segments (the ones with
129865
+** the smallest indexes) in the highest level that contains at least
129866
+** nMin segments. Multiple merges might occur in an attempt to write the
129867
+** quota of nMerge leaf blocks.
129868
+*/
129869
+SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){
129870
+ int rc; /* Return code */
129871
+ int nRem = nMerge; /* Number of leaf pages yet to be written */
129872
+ Fts3MultiSegReader *pCsr; /* Cursor used to read input data */
129873
+ Fts3SegFilter *pFilter; /* Filter used with cursor pCsr */
129874
+ IncrmergeWriter *pWriter; /* Writer object */
129875
+ int nSeg = 0; /* Number of input segments */
129876
+ sqlite3_int64 iAbsLevel = 0; /* Absolute level number to work on */
129877
+ Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
129878
+ int bDirtyHint = 0; /* True if blob 'hint' has been modified */
129879
+
129880
+ /* Allocate space for the cursor, filter and writer objects */
129881
+ const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
129882
+ pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
129883
+ if( !pWriter ) return SQLITE_NOMEM;
129884
+ pFilter = (Fts3SegFilter *)&pWriter[1];
129885
+ pCsr = (Fts3MultiSegReader *)&pFilter[1];
129886
+
129887
+ rc = fts3IncrmergeHintLoad(p, &hint);
129888
+ while( rc==SQLITE_OK && nRem>0 ){
129889
+ const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;
129890
+ sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */
129891
+ int bUseHint = 0; /* True if attempting to append */
129892
+
129893
+ /* Search the %_segdir table for the absolute level with the smallest
129894
+ ** relative level number that contains at least nMin segments, if any.
129895
+ ** If one is found, set iAbsLevel to the absolute level number and
129896
+ ** nSeg to nMin. If no level with at least nMin segments can be found,
129897
+ ** set nSeg to -1.
129898
+ */
129899
+ rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);
129900
+ sqlite3_bind_int(pFindLevel, 1, nMin);
129901
+ if( sqlite3_step(pFindLevel)==SQLITE_ROW ){
129902
+ iAbsLevel = sqlite3_column_int64(pFindLevel, 0);
129903
+ nSeg = nMin;
129904
+ }else{
129905
+ nSeg = -1;
129906
+ }
129907
+ rc = sqlite3_reset(pFindLevel);
129908
+
129909
+ /* If the hint read from the %_stat table is not empty, check if the
129910
+ ** last entry in it specifies a relative level smaller than or equal
129911
+ ** to the level identified by the block above (if any). If so, this
129912
+ ** iteration of the loop will work on merging at the hinted level.
129913
+ */
129914
+ if( rc==SQLITE_OK && hint.n ){
129915
+ int nHint = hint.n;
129916
+ sqlite3_int64 iHintAbsLevel = 0; /* Hint level */
129917
+ int nHintSeg = 0; /* Hint number of segments */
129918
+
129919
+ rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);
129920
+ if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){
129921
+ iAbsLevel = iHintAbsLevel;
129922
+ nSeg = nHintSeg;
129923
+ bUseHint = 1;
129924
+ bDirtyHint = 1;
129925
+ }else{
129926
+ /* This undoes the effect of the HintPop() above - so that no entry
129927
+ ** is removed from the hint blob. */
129928
+ hint.n = nHint;
129929
+ }
129930
+ }
129931
+
129932
+ /* If nSeg is less that zero, then there is no level with at least
129933
+ ** nMin segments and no hint in the %_stat table. No work to do.
129934
+ ** Exit early in this case. */
129935
+ if( nSeg<0 ) break;
129936
+
129937
+ /* Open a cursor to iterate through the contents of the oldest nSeg
129938
+ ** indexes of absolute level iAbsLevel. If this cursor is opened using
129939
+ ** the 'hint' parameters, it is possible that there are less than nSeg
129940
+ ** segments available in level iAbsLevel. In this case, no work is
129941
+ ** done on iAbsLevel - fall through to the next iteration of the loop
129942
+ ** to start work on some other level. */
129943
+ memset(pWriter, 0, nAlloc);
129944
+ pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;
129945
+ if( rc==SQLITE_OK ){
129946
+ rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
129947
+ }
129948
+ if( SQLITE_OK==rc && pCsr->nSegment==nSeg
129949
+ && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
129950
+ && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
129951
+ ){
129952
+ int iIdx = 0; /* Largest idx in level (iAbsLevel+1) */
129953
+ rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);
129954
+ if( rc==SQLITE_OK ){
129955
+ if( bUseHint && iIdx>0 ){
129956
+ const char *zKey = pCsr->zTerm;
129957
+ int nKey = pCsr->nTerm;
129958
+ rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
129959
+ }else{
129960
+ rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
129961
+ }
129962
+ }
129963
+
129964
+ if( rc==SQLITE_OK && pWriter->nLeafEst ){
129965
+ fts3LogMerge(nSeg, iAbsLevel);
129966
+ do {
129967
+ rc = fts3IncrmergeAppend(p, pWriter, pCsr);
129968
+ if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
129969
+ if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
129970
+ }while( rc==SQLITE_ROW );
129971
+
129972
+ /* Update or delete the input segments */
129973
+ if( rc==SQLITE_OK ){
129974
+ nRem -= (1 + pWriter->nWork);
129975
+ rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
129976
+ if( nSeg!=0 ){
129977
+ bDirtyHint = 1;
129978
+ fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);
129979
+ }
129980
+ }
129981
+ }
129982
+
129983
+ fts3IncrmergeRelease(p, pWriter, &rc);
129984
+ }
129985
+
129986
+ sqlite3Fts3SegReaderFinish(pCsr);
129987
+ }
129988
+
129989
+ /* Write the hint values into the %_stat table for the next incr-merger */
129990
+ if( bDirtyHint && rc==SQLITE_OK ){
129991
+ rc = fts3IncrmergeHintStore(p, &hint);
129992
+ }
129993
+
129994
+ sqlite3_free(pWriter);
129995
+ sqlite3_free(hint.a);
129996
+ return rc;
129997
+}
129998
+
129999
+/*
130000
+** Convert the text beginning at *pz into an integer and return
130001
+** its value. Advance *pz to point to the first character past
130002
+** the integer.
130003
+*/
130004
+static int fts3Getint(const char **pz){
130005
+ const char *z = *pz;
130006
+ int i = 0;
130007
+ while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0';
130008
+ *pz = z;
130009
+ return i;
130010
+}
130011
+
130012
+/*
130013
+** Process statements of the form:
130014
+**
130015
+** INSERT INTO table(table) VALUES('merge=A,B');
130016
+**
130017
+** A and B are integers that decode to be the number of leaf pages
130018
+** written for the merge, and the minimum number of segments on a level
130019
+** before it will be selected for a merge, respectively.
130020
+*/
130021
+static int fts3DoIncrmerge(
130022
+ Fts3Table *p, /* FTS3 table handle */
130023
+ const char *zParam /* Nul-terminated string containing "A,B" */
130024
+){
130025
+ int rc;
130026
+ int nMin = (FTS3_MERGE_COUNT / 2);
130027
+ int nMerge = 0;
130028
+ const char *z = zParam;
130029
+
130030
+ /* Read the first integer value */
130031
+ nMerge = fts3Getint(&z);
130032
+
130033
+ /* If the first integer value is followed by a ',', read the second
130034
+ ** integer value. */
130035
+ if( z[0]==',' && z[1]!='\0' ){
130036
+ z++;
130037
+ nMin = fts3Getint(&z);
130038
+ }
130039
+
130040
+ if( z[0]!='\0' || nMin<2 ){
130041
+ rc = SQLITE_ERROR;
130042
+ }else{
130043
+ rc = SQLITE_OK;
130044
+ if( !p->bHasStat ){
130045
+ assert( p->bFts4==0 );
130046
+ sqlite3Fts3CreateStatTable(&rc, p);
130047
+ }
130048
+ if( rc==SQLITE_OK ){
130049
+ rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);
130050
+ }
130051
+ sqlite3Fts3SegmentsClose(p);
130052
+ }
130053
+ return rc;
130054
+}
130055
+
130056
+/*
130057
+** Process statements of the form:
130058
+**
130059
+** INSERT INTO table(table) VALUES('automerge=X');
130060
+**
130061
+** where X is an integer. X==0 means to turn automerge off. X!=0 means
130062
+** turn it on. The setting is persistent.
130063
+*/
130064
+static int fts3DoAutoincrmerge(
130065
+ Fts3Table *p, /* FTS3 table handle */
130066
+ const char *zParam /* Nul-terminated string containing boolean */
130067
+){
130068
+ int rc = SQLITE_OK;
130069
+ sqlite3_stmt *pStmt = 0;
130070
+ p->bAutoincrmerge = fts3Getint(&zParam)!=0;
130071
+ if( !p->bHasStat ){
130072
+ assert( p->bFts4==0 );
130073
+ sqlite3Fts3CreateStatTable(&rc, p);
130074
+ if( rc ) return rc;
130075
+ }
130076
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
130077
+ if( rc ) return rc;;
130078
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
130079
+ sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);
130080
+ sqlite3_step(pStmt);
130081
+ rc = sqlite3_reset(pStmt);
130082
+ return rc;
130083
+}
130084
+
130085
+/*
130086
+** Return a 64-bit checksum for the FTS index entry specified by the
130087
+** arguments to this function.
130088
+*/
130089
+static u64 fts3ChecksumEntry(
130090
+ const char *zTerm, /* Pointer to buffer containing term */
130091
+ int nTerm, /* Size of zTerm in bytes */
130092
+ int iLangid, /* Language id for current row */
130093
+ int iIndex, /* Index (0..Fts3Table.nIndex-1) */
130094
+ i64 iDocid, /* Docid for current row. */
130095
+ int iCol, /* Column number */
130096
+ int iPos /* Position */
130097
+){
130098
+ int i;
130099
+ u64 ret = (u64)iDocid;
130100
+
130101
+ ret += (ret<<3) + iLangid;
130102
+ ret += (ret<<3) + iIndex;
130103
+ ret += (ret<<3) + iCol;
130104
+ ret += (ret<<3) + iPos;
130105
+ for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];
130106
+
130107
+ return ret;
130108
+}
130109
+
130110
+/*
130111
+** Return a checksum of all entries in the FTS index that correspond to
130112
+** language id iLangid. The checksum is calculated by XORing the checksums
130113
+** of each individual entry (see fts3ChecksumEntry()) together.
130114
+**
130115
+** If successful, the checksum value is returned and *pRc set to SQLITE_OK.
130116
+** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The
130117
+** return value is undefined in this case.
130118
+*/
130119
+static u64 fts3ChecksumIndex(
130120
+ Fts3Table *p, /* FTS3 table handle */
130121
+ int iLangid, /* Language id to return cksum for */
130122
+ int iIndex, /* Index to cksum (0..p->nIndex-1) */
130123
+ int *pRc /* OUT: Return code */
130124
+){
130125
+ Fts3SegFilter filter;
130126
+ Fts3MultiSegReader csr;
130127
+ int rc;
130128
+ u64 cksum = 0;
130129
+
130130
+ assert( *pRc==SQLITE_OK );
130131
+
130132
+ memset(&filter, 0, sizeof(filter));
130133
+ memset(&csr, 0, sizeof(csr));
130134
+ filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
130135
+ filter.flags |= FTS3_SEGMENT_SCAN;
130136
+
130137
+ rc = sqlite3Fts3SegReaderCursor(
130138
+ p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr
130139
+ );
130140
+ if( rc==SQLITE_OK ){
130141
+ rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
130142
+ }
130143
+
130144
+ if( rc==SQLITE_OK ){
130145
+ while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){
130146
+ char *pCsr = csr.aDoclist;
130147
+ char *pEnd = &pCsr[csr.nDoclist];
130148
+
130149
+ i64 iDocid = 0;
130150
+ i64 iCol = 0;
130151
+ i64 iPos = 0;
130152
+
130153
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
130154
+ while( pCsr<pEnd ){
130155
+ i64 iVal = 0;
130156
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130157
+ if( pCsr<pEnd ){
130158
+ if( iVal==0 || iVal==1 ){
130159
+ iCol = 0;
130160
+ iPos = 0;
130161
+ if( iVal ){
130162
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
130163
+ }else{
130164
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130165
+ iDocid += iVal;
130166
+ }
130167
+ }else{
130168
+ iPos += (iVal - 2);
130169
+ cksum = cksum ^ fts3ChecksumEntry(
130170
+ csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
130171
+ (int)iCol, (int)iPos
130172
+ );
130173
+ }
130174
+ }
130175
+ }
130176
+ }
130177
+ }
130178
+ sqlite3Fts3SegReaderFinish(&csr);
130179
+
130180
+ *pRc = rc;
130181
+ return cksum;
130182
+}
130183
+
130184
+/*
130185
+** Check if the contents of the FTS index match the current contents of the
130186
+** content table. If no error occurs and the contents do match, set *pbOk
130187
+** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk
130188
+** to false before returning.
130189
+**
130190
+** If an error occurs (e.g. an OOM or IO error), return an SQLite error
130191
+** code. The final value of *pbOk is undefined in this case.
130192
+*/
130193
+static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
130194
+ int rc = SQLITE_OK; /* Return code */
130195
+ u64 cksum1 = 0; /* Checksum based on FTS index contents */
130196
+ u64 cksum2 = 0; /* Checksum based on %_content contents */
130197
+ sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */
130198
+
130199
+ /* This block calculates the checksum according to the FTS index. */
130200
+ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130201
+ if( rc==SQLITE_OK ){
130202
+ int rc2;
130203
+ sqlite3_bind_int(pAllLangid, 1, p->nIndex);
130204
+ while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
130205
+ int iLangid = sqlite3_column_int(pAllLangid, 0);
130206
+ int i;
130207
+ for(i=0; i<p->nIndex; i++){
130208
+ cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
130209
+ }
130210
+ }
130211
+ rc2 = sqlite3_reset(pAllLangid);
130212
+ if( rc==SQLITE_OK ) rc = rc2;
130213
+ }
130214
+
130215
+ /* This block calculates the checksum according to the %_content table */
130216
+ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130217
+ if( rc==SQLITE_OK ){
130218
+ sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
130219
+ sqlite3_stmt *pStmt = 0;
130220
+ char *zSql;
130221
+
130222
+ zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist);
130223
+ if( !zSql ){
130224
+ rc = SQLITE_NOMEM;
130225
+ }else{
130226
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
130227
+ sqlite3_free(zSql);
130228
+ }
130229
+
130230
+ while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
130231
+ i64 iDocid = sqlite3_column_int64(pStmt, 0);
130232
+ int iLang = langidFromSelect(p, pStmt);
130233
+ int iCol;
130234
+
130235
+ for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
130236
+ const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
130237
+ int nText = sqlite3_column_bytes(pStmt, iCol+1);
130238
+ sqlite3_tokenizer_cursor *pT = 0;
130239
+
130240
+ rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130241
+ while( rc==SQLITE_OK ){
130242
+ char const *zToken; /* Buffer containing token */
130243
+ int nToken; /* Number of bytes in token */
130244
+ int iDum1, iDum2; /* Dummy variables */
130245
+ int iPos; /* Position of token in zText */
130246
+
130247
+ rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130248
+ if( rc==SQLITE_OK ){
130249
+ int i;
130250
+ cksum2 = cksum2 ^ fts3ChecksumEntry(
130251
+ zToken, nToken, iLang, 0, iDocid, iCol, iPos
130252
+ );
130253
+ for(i=1; i<p->nIndex; i++){
130254
+ if( p->aIndex[i].nPrefix<=nToken ){
130255
+ cksum2 = cksum2 ^ fts3ChecksumEntry(
130256
+ zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
130257
+ );
130258
+ }
130259
+ }
130260
+ }
130261
+ }
130262
+ if( pT ) pModule->xClose(pT);
130263
+ if( rc==SQLITE_DONE ) rc = SQLITE_OK;
130264
+ }
130265
+ }
130266
+
130267
+ sqlite3_finalize(pStmt);
130268
+ }
130269
+
130270
+ *pbOk = (cksum1==cksum2);
130271
+ return rc;
130272
+}
130273
+
130274
+/*
130275
+** Run the integrity-check. If no error occurs and the current contents of
130276
+** the FTS index are correct, return SQLITE_OK. Or, if the contents of the
130277
+** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.
130278
+**
130279
+** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite
130280
+** error code.
130281
+**
130282
+** The integrity-check works as follows. For each token and indexed token
130283
+** prefix in the document set, a 64-bit checksum is calculated (by code
130284
+** in fts3ChecksumEntry()) based on the following:
130285
+**
130286
+** + The index number (0 for the main index, 1 for the first prefix
130287
+** index etc.),
130288
+** + The token (or token prefix) text itself,
130289
+** + The language-id of the row it appears in,
130290
+** + The docid of the row it appears in,
130291
+** + The column it appears in, and
130292
+** + The tokens position within that column.
130293
+**
130294
+** The checksums for all entries in the index are XORed together to create
130295
+** a single checksum for the entire index.
130296
+**
130297
+** The integrity-check code calculates the same checksum in two ways:
130298
+**
130299
+** 1. By scanning the contents of the FTS index, and
130300
+** 2. By scanning and tokenizing the content table.
130301
+**
130302
+** If the two checksums are identical, the integrity-check is deemed to have
130303
+** passed.
130304
+*/
130305
+static int fts3DoIntegrityCheck(
130306
+ Fts3Table *p /* FTS3 table handle */
130307
+){
130308
+ int rc;
130309
+ int bOk = 0;
130310
+ rc = fts3IntegrityCheck(p, &bOk);
130311
+ if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
130312
+ return rc;
130313
+}
130314
+
128197130315
/*
128198130316
** Handle a 'special' INSERT of the form:
128199130317
**
128200130318
** "INSERT INTO tbl(tbl) VALUES(<expr>)"
128201130319
**
@@ -128211,10 +130329,16 @@
128211130329
return SQLITE_NOMEM;
128212130330
}else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
128213130331
rc = fts3DoOptimize(p, 0);
128214130332
}else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
128215130333
rc = fts3DoRebuild(p);
130334
+ }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, "integrity-check", 15) ){
130335
+ rc = fts3DoIntegrityCheck(p);
130336
+ }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
130337
+ rc = fts3DoIncrmerge(p, &zVal[6]);
130338
+ }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
130339
+ rc = fts3DoAutoincrmerge(p, &zVal[10]);
128216130340
#ifdef SQLITE_TEST
128217130341
}else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
128218130342
p->nNodeSize = atoi(&zVal[9]);
128219130343
rc = SQLITE_OK;
128220130344
}else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
128406130530
/*
128407130531
** This function does the work for the xUpdate method of FTS3 virtual
128408130532
** tables. The schema of the virtual table being:
128409130533
**
128410130534
** CREATE TABLE <table name>(
128411
-** <user COLUMns>,
130535
+** <user columns>,
128412130536
** <table name> HIDDEN,
128413130537
** docid HIDDEN,
128414130538
** <langid> HIDDEN
128415130539
** );
128416130540
**
@@ -128538,11 +130662,11 @@
128538130662
fts3InsertDocsize(&rc, p, aSzIns);
128539130663
}
128540130664
nChng++;
128541130665
}
128542130666
128543
- if( p->bHasStat ){
130667
+ if( p->bFts4 ){
128544130668
fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
128545130669
}
128546130670
128547130671
update_out:
128548130672
sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
129369131493
char cArg,
129370131494
char **pzErr
129371131495
){
129372131496
if( (cArg==FTS3_MATCHINFO_NPHRASE)
129373131497
|| (cArg==FTS3_MATCHINFO_NCOL)
129374
- || (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat)
129375
- || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat)
131498
+ || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
131499
+ || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
129376131500
|| (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
129377131501
|| (cArg==FTS3_MATCHINFO_LCS)
129378131502
|| (cArg==FTS3_MATCHINFO_HITS)
129379131503
){
129380131504
return SQLITE_OK;
@@ -133134,12 +135258,12 @@
133134135258
}
133135135259
133136135260
sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
133137135261
133138135262
/* Allocate the sqlite3_vtab structure */
133139
- nDb = strlen(argv[1]);
133140
- nName = strlen(argv[2]);
135263
+ nDb = (int)strlen(argv[1]);
135264
+ nName = (int)strlen(argv[2]);
133141135265
pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
133142135266
if( !pRtree ){
133143135267
return SQLITE_NOMEM;
133144135268
}
133145135269
memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
133230135354
RtreeCell cell;
133231135355
int jj;
133232135356
133233135357
nodeGetCell(&tree, &node, ii, &cell);
133234135358
sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
133235
- nCell = strlen(zCell);
135359
+ nCell = (int)strlen(zCell);
133236135360
for(jj=0; jj<tree.nDim*2; jj++){
133237135361
sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
133238
- nCell = strlen(zCell);
135362
+ nCell = (int)strlen(zCell);
133239135363
}
133240135364
133241135365
if( zText ){
133242135366
char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
133243135367
sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
133976136100
int iInput = 0;
133977136101
int iOut = 0;
133978136102
133979136103
*ppCursor = 0;
133980136104
133981
- if( nInput<0 ){
136105
+ if( zInput==0 ){
136106
+ nInput = 0;
136107
+ zInput = "";
136108
+ }else if( nInput<0 ){
133982136109
nInput = strlen(zInput);
133983136110
}
133984136111
nChar = nInput+1;
133985136112
pCsr = (IcuCursor *)sqlite3_malloc(
133986136113
sizeof(IcuCursor) + /* IcuCursor */
133987136114
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.7.11. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -655,13 +655,13 @@
655 **
656 ** See also: [sqlite3_libversion()],
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.11"
661 #define SQLITE_VERSION_NUMBER 3007011
662 #define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -6554,10 +6554,21 @@
6554 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6555 ** <dd>This parameter returns the number of pager cache misses that have
6556 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6557 ** is always 0.
6558 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
6559 ** </dl>
6560 */
6561 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6562 #define SQLITE_DBSTATUS_CACHE_USED 1
6563 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
6565 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6566 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6567 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6568 #define SQLITE_DBSTATUS_CACHE_HIT 7
6569 #define SQLITE_DBSTATUS_CACHE_MISS 8
6570 #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
 
6571
6572
6573 /*
6574 ** CAPI3REF: Prepared Statement Status
6575 **
@@ -9919,18 +9931,22 @@
9919 void (*xDestroy)(void *);
9920 void *pUserData;
9921 };
9922
9923 /*
9924 ** Possible values for FuncDef.flags
 
 
9925 */
9926 #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
9927 #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
9928 #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
9929 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9930 #define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */
9931 #define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
 
 
9932
9933 /*
9934 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
9935 ** used to create the initializers for the FuncDef structures.
9936 **
@@ -9954,11 +9970,14 @@
9954 ** available as the function user-data (sqlite3_user_data()). The
9955 ** FuncDef.flags variable is set to the value passed as the flags
9956 ** parameter.
9957 */
9958 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9959 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
 
 
 
9960 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9961 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
9962 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9963 pArg, 0, xFunc, 0, 0, #zName, 0, 0}
9964 #define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
10184 u8 tabFlags; /* Mask of TF_* values */
10185 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
10186 FKey *pFKey; /* Linked list of all foreign keys in this table */
10187 char *zColAff; /* String defining the affinity of each column */
10188 #ifndef SQLITE_OMIT_CHECK
10189 Expr *pCheck; /* The AND of all CHECK constraints */
10190 #endif
10191 #ifndef SQLITE_OMIT_ALTERTABLE
10192 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
10193 #endif
10194 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
10577 ** TK_VARIABLE: variable number (always >= 1). */
10578 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
10579 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
10580 u8 flags2; /* Second set of flags. EP2_... */
10581 u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
 
10582 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
10583 Table *pTab; /* Table for TK_COLUMN expressions. */
10584 #if SQLITE_MAX_EXPR_DEPTH>0
10585 int nHeight; /* Height of the tree headed by this node */
10586 #endif
@@ -10599,11 +10619,11 @@
10599 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
10600 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
10601 #define EP_FixedDest 0x0200 /* Result needed in a specific register */
10602 #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
10603 #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10604 #define EP_Hint 0x1000 /* Optimizer hint. Not required for correctness */
10605 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
10606 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
10607 #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
10608
10609 /*
@@ -11118,10 +11138,11 @@
11118 int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
11119 int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
11120 int regRowid; /* Register holding rowid of CREATE TABLE entry */
11121 int regRoot; /* Register holding root page number for new objects */
11122 int nMaxArg; /* Max args passed to user function by sub-program */
 
11123 #ifndef SQLITE_OMIT_SHARED_CACHE
11124 int nTableLock; /* Number of locks in aTableLock */
11125 TableLock *aTableLock; /* Required table locks for shared-cache mode */
11126 #endif
11127 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
11186 const char *zAuthContext; /* Put saved Parse.zAuthContext here */
11187 Parse *pParse; /* The Parse structure */
11188 };
11189
11190 /*
11191 ** Bitfield flags for P5 value in OP_Insert and OP_Delete
11192 */
11193 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
11194 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
11195 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
11196 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
11197 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
11198 #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
 
 
11199
11200 /*
11201 * Each trigger present in the database schema is stored as an instance of
11202 * struct Trigger.
11203 *
@@ -11677,11 +11700,11 @@
11677 #endif
11678 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
11679 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
11680 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
11681 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11682 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
11683 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
11684 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
11685 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
11686 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
11687 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
13509 ** Set *pCurrent to the total cache hits or misses encountered by all
13510 ** pagers the database handle is connected to. *pHighwater is always set
13511 ** to zero.
13512 */
13513 case SQLITE_DBSTATUS_CACHE_HIT:
13514 case SQLITE_DBSTATUS_CACHE_MISS: {
 
13515 int i;
13516 int nRet = 0;
13517 assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
 
13518
13519 for(i=0; i<db->nDb; i++){
13520 if( db->aDb[i].pBt ){
13521 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
13522 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
21259
21260 /*
21261 ** Some systems have stricmp(). Others have strcasecmp(). Because
21262 ** there is no consistency, we will define our own.
21263 **
21264 ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows
21265 ** applications and extensions to compare the contents of two buffers
21266 ** containing UTF-8 strings in a case-independent fashion, using the same
21267 ** definition of case independence that SQLite uses internally when
21268 ** comparing identifiers.
21269 */
21270 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
21271 register unsigned char *a, *b;
21272 a = (unsigned char *)zLeft;
21273 b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
33727 }
33728 sqlite3_free(pFile->zDeleteOnClose);
33729 }
33730 #endif
33731 OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
 
 
 
33732 OpenCounter(-1);
33733 return rc ? SQLITE_OK
33734 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
33735 "winClose", pFile->zPath);
33736 }
@@ -33744,22 +33772,33 @@
33744 sqlite3_file *id, /* File to read from */
33745 void *pBuf, /* Write content into this buffer */
33746 int amt, /* Number of bytes to read */
33747 sqlite3_int64 offset /* Begin reading at this offset */
33748 ){
 
 
 
33749 winFile *pFile = (winFile*)id; /* file handle */
33750 DWORD nRead; /* Number of bytes actually read from file */
33751 int nRetry = 0; /* Number of retrys */
33752
33753 assert( id!=0 );
33754 SimulateIOError(return SQLITE_IOERR_READ);
33755 OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
33756
 
33757 if( seekWinFile(pFile, offset) ){
33758 return SQLITE_FULL;
33759 }
33760 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
 
 
 
 
 
 
 
33761 DWORD lastErrno;
33762 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33763 pFile->lastErrno = lastErrno;
33764 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
33765 "winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
33782 sqlite3_file *id, /* File to write into */
33783 const void *pBuf, /* The bytes to be written */
33784 int amt, /* Number of bytes to write */
33785 sqlite3_int64 offset /* Offset into the file to begin writing at */
33786 ){
33787 int rc; /* True if error has occured, else false */
33788 winFile *pFile = (winFile*)id; /* File handle */
33789 int nRetry = 0; /* Number of retries */
33790
33791 assert( amt>0 );
33792 assert( pFile );
@@ -33793,23 +33832,48 @@
33793 SimulateIOError(return SQLITE_IOERR_WRITE);
33794 SimulateDiskfullError(return SQLITE_FULL);
33795
33796 OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
33797
 
33798 rc = seekWinFile(pFile, offset);
33799 if( rc==0 ){
 
 
 
 
 
 
33800 u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
33801 int nRem = amt; /* Number of bytes yet to be written */
33802 DWORD nWrite; /* Bytes written by each WriteFile() call */
33803 DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
 
 
 
 
 
 
33804
33805 while( nRem>0 ){
 
33806 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
 
 
 
33807 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33808 break;
33809 }
33810 if( nWrite<=0 ) break;
 
 
 
 
 
 
 
 
33811 aRem += nWrite;
33812 nRem -= nWrite;
33813 }
33814 if( nRem>0 ){
33815 pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
39094 i64 journalSizeLimit; /* Size limit for persistent journal files */
39095 char *zFilename; /* Name of the database file */
39096 char *zJournal; /* Name of the journal file */
39097 int (*xBusyHandler)(void*); /* Function to call when busy */
39098 void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39099 int nHit, nMiss; /* Total cache hits and misses */
39100 #ifdef SQLITE_TEST
39101 int nRead, nWrite; /* Database pages read/written */
39102 #endif
39103 void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
39104 #ifdef SQLITE_HAS_CODEC
39105 void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
39106 void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
39113 Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
39114 char *zWal; /* File name for write-ahead log */
39115 #endif
39116 };
39117
 
 
 
 
 
 
 
 
 
39118 /*
39119 ** The following global variables hold counters used for
39120 ** testing purposes only. These variables do not exist in
39121 ** a non-testing build. These variables are not thread-safe.
39122 */
@@ -41395,10 +41468,11 @@
41395 PgHdr *pList, /* List of frames to log */
41396 Pgno nTruncate, /* Database size after this commit */
41397 int isCommit /* True if this is a commit */
41398 ){
41399 int rc; /* Return code */
 
41400 #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
41401 PgHdr *p; /* For looping over pages */
41402 #endif
41403
41404 assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
41408 for(p=pList; p && p->pDirty; p=p->pDirty){
41409 assert( p->pgno < p->pDirty->pgno );
41410 }
41411 #endif
41412
 
41413 if( isCommit ){
41414 /* If a WAL transaction is being committed, there is no point in writing
41415 ** any pages with page numbers greater than nTruncate into the WAL file.
41416 ** They will never be read by any client. So remove them from the pDirty
41417 ** list here. */
41418 PgHdr *p;
41419 PgHdr **ppNext = &pList;
 
41420 for(p=pList; (*ppNext = p); p=p->pDirty){
41421 if( p->pgno<=nTruncate ) ppNext = &p->pDirty;
 
 
 
41422 }
41423 assert( pList );
 
 
41424 }
 
41425
41426 if( pList->pgno==1 ) pager_write_changecounter(pList);
41427 rc = sqlite3WalFrames(pPager->pWal,
41428 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
41429 );
@@ -42487,19 +42569,19 @@
42487 memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
42488 }
42489 if( pgno>pPager->dbFileSize ){
42490 pPager->dbFileSize = pgno;
42491 }
 
42492
42493 /* Update any backup objects copying the contents of this pager. */
42494 sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
42495
42496 PAGERTRACE(("STORE %d page %d hash(%08x)\n",
42497 PAGERID(pPager), pgno, pager_pagehash(pList)));
42498 IOTRACE(("PGOUT %p %d\n", pPager, pgno));
42499 PAGER_INCR(sqlite3_pager_writedb_count);
42500 PAGER_INCR(pPager->nWrite);
42501 }else{
42502 PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
42503 }
42504 pager_set_pagehash(pList);
42505 pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
43453
43454 if( (*ppPage)->pPager && !noContent ){
43455 /* In this case the pcache already contains an initialized copy of
43456 ** the page. Return without further ado. */
43457 assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43458 pPager->nHit++;
43459 return SQLITE_OK;
43460
43461 }else{
43462 /* The pager cache has created a new page. Its content needs to
43463 ** be initialized. */
@@ -43495,11 +43577,11 @@
43495 }
43496 memset(pPg->pData, 0, pPager->pageSize);
43497 IOTRACE(("ZERO %p %d\n", pPager, pgno));
43498 }else{
43499 assert( pPg->pPager==pPager );
43500 pPager->nMiss++;
43501 rc = readDbPage(pPg);
43502 if( rc!=SQLITE_OK ){
43503 goto pager_acquire_err;
43504 }
43505 }
@@ -44080,10 +44162,11 @@
44080 const void *zBuf;
44081 assert( pPager->dbFileSize>0 );
44082 CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
44083 if( rc==SQLITE_OK ){
44084 rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
 
44085 }
44086 if( rc==SQLITE_OK ){
44087 pPager->changeCountDone = 1;
44088 }
44089 }else{
@@ -44523,15 +44606,15 @@
44523 a[1] = sqlite3PcachePagecount(pPager->pPCache);
44524 a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
44525 a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
44526 a[4] = pPager->eState;
44527 a[5] = pPager->errCode;
44528 a[6] = pPager->nHit;
44529 a[7] = pPager->nMiss;
44530 a[8] = 0; /* Used to be pPager->nOvfl */
44531 a[9] = pPager->nRead;
44532 a[10] = pPager->nWrite;
44533 return a;
44534 }
44535 #endif
44536
44537 /*
@@ -44540,24 +44623,23 @@
44540 ** current cache hit or miss count, according to the value of eStat. If the
44541 ** reset parameter is non-zero, the cache hit or miss count is zeroed before
44542 ** returning.
44543 */
44544 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
44545 int *piStat;
44546
44547 assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
44548 || eStat==SQLITE_DBSTATUS_CACHE_MISS
 
44549 );
44550 if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){
44551 piStat = &pPager->nHit;
44552 }else{
44553 piStat = &pPager->nMiss;
44554 }
44555
44556 *pnVal += *piStat;
 
 
 
 
44557 if( reset ){
44558 *piStat = 0;
44559 }
44560 }
44561
44562 /*
44563 ** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
56151 ** keys with no associated data. If the cursor was opened expecting an
56152 ** intkey table, the caller should be inserting integer keys with a
56153 ** blob of associated data. */
56154 assert( (pKey==0)==(pCur->pKeyInfo==0) );
56155
56156 /* If this is an insert into a table b-tree, invalidate any incrblob
56157 ** cursors open on the row being replaced (assuming this is a replace
56158 ** operation - if it is not, the following is a no-op). */
56159 if( pCur->pKeyInfo==0 ){
56160 invalidateIncrblobCursors(p, nKey, 0);
56161 }
56162
56163 /* Save the positions of any other cursors open on this table.
56164 **
56165 ** In some cases, the call to btreeMoveto() below is a no-op. For
56166 ** example, when inserting data into a table with auto-generated integer
56167 ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
56171 ** doing any work. To avoid thwarting these optimizations, it is important
56172 ** not to clear the cursor here.
56173 */
56174 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56175 if( rc ) return rc;
 
 
 
 
 
 
 
 
56176 if( !loc ){
56177 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
56178 if( rc ) return rc;
56179 }
56180 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
56281 || NEVER(pCur->eState!=CURSOR_VALID)
56282 ){
56283 return SQLITE_ERROR; /* Something has gone awry. */
56284 }
56285
56286 /* If this is a delete operation to remove a row from a table b-tree,
56287 ** invalidate any incrblob cursors open on the row being deleted. */
56288 if( pCur->pKeyInfo==0 ){
56289 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56290 }
56291
56292 iCellDepth = pCur->iPage;
56293 iCellIdx = pCur->aiIdx[iCellDepth];
56294 pPage = pCur->apPage[iCellDepth];
56295 pCell = findCell(pPage, iCellIdx);
56296
@@ -56312,10 +56389,17 @@
56312 ** deleted writable. Then free any overflow pages associated with the
56313 ** entry and finally remove the cell itself from within the page.
56314 */
56315 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56316 if( rc ) return rc;
 
 
 
 
 
 
 
56317 rc = sqlite3PagerWrite(pPage->pDbPage);
56318 if( rc ) return rc;
56319 rc = clearCell(pPage, pCell);
56320 dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
56321 if( rc ) return rc;
@@ -56593,17 +56677,17 @@
56593 int rc;
56594 BtShared *pBt = p->pBt;
56595 sqlite3BtreeEnter(p);
56596 assert( p->inTrans==TRANS_WRITE );
56597
56598 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56599 ** is the root of a table b-tree - if it is not, the following call is
56600 ** a no-op). */
56601 invalidateIncrblobCursors(p, 0, 1);
56602
56603 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
 
56604 if( SQLITE_OK==rc ){
 
 
 
 
56605 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
56606 }
56607 sqlite3BtreeLeave(p);
56608 return rc;
56609 }
@@ -58411,14 +58495,14 @@
58411
58412 /*
58413 ** Make sure pMem->z points to a writable allocation of at least
58414 ** n bytes.
58415 **
58416 ** If the memory cell currently contains string or blob data
58417 ** and the third argument passed to this function is true, the
58418 ** current content of the cell is preserved. Otherwise, it may
58419 ** be discarded.
58420 **
58421 ** This function sets the MEM_Dyn flag and clears any xDel callback.
58422 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
58423 ** not set, Mem.n is zeroed.
58424 */
@@ -58428,10 +58512,14 @@
58428 (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
58429 ((pMem->flags&MEM_Ephem) ? 1 : 0) +
58430 ((pMem->flags&MEM_Static) ? 1 : 0)
58431 );
58432 assert( (pMem->flags&MEM_RowSet)==0 );
 
 
 
 
58433
58434 if( n<32 ) n = 32;
58435 if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
58436 if( preserve && pMem->z==pMem->zMalloc ){
58437 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
60747 int nByte = (nSub+1)*sizeof(SubProgram*);
60748 int j;
60749 for(j=0; j<nSub; j++){
60750 if( apSub[j]==pOp->p4.pProgram ) break;
60751 }
60752 if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){
60753 apSub = (SubProgram **)pSub->z;
60754 apSub[nSub++] = pOp->p4.pProgram;
60755 pSub->flags |= MEM_Blob;
60756 pSub->n = nSub*sizeof(SubProgram*);
60757 }
@@ -66996,10 +67084,15 @@
66996 **
66997 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
66998 ** then the cache of the cursor is reset prior to extracting the column.
66999 ** The first OP_Column against a pseudo-table after the value of the content
67000 ** register has changed should have this bit set.
 
 
 
 
 
67001 */
67002 case OP_Column: {
67003 #if 0 /* local variables moved into u.an */
67004 u32 payloadSize; /* Number of bytes in the record */
67005 i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
67138 u.an.pC->aRow = (u8*)u.an.zData;
67139 }else{
67140 u.an.pC->aRow = 0;
67141 }
67142 }
67143 /* The following assert is true in all cases accept when
67144 ** the database file has been corrupted externally.
67145 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67146 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67147
67148 /* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
67213 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67214 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67215 break;
67216 }
67217 }else{
67218 /* If u.an.i is less that u.an.nField, then there are less fields in this
67219 ** record than SetNumColumns indicated there are columns in the
67220 ** table. Set the u.an.offset for any extra columns not present in
67221 ** the record to 0. This tells code below to store a NULL
67222 ** instead of deserializing a value from the record.
67223 */
67224 u.an.aOffset[u.an.i] = 0;
67225 }
67226 }
67227 sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
67247 ** a pointer to a Mem object.
67248 */
67249 if( u.an.aOffset[u.an.p2] ){
67250 assert( rc==SQLITE_OK );
67251 if( u.an.zRec ){
 
67252 VdbeMemRelease(u.an.pDest);
67253 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67254 }else{
67255 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67256 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67257 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67258 if( rc!=SQLITE_OK ){
67259 goto op_column_out;
67260 }
67261 u.an.zData = u.an.sMem.z;
67262 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67263 }
67264 u.an.pDest->enc = encoding;
67265 }else{
67266 if( pOp->p4type==P4_MEM ){
67267 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
67593 }
67594 db->isTransactionSavepoint = 0;
67595 rc = p->rc;
67596 }else{
67597 u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67598 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67599 sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
 
 
67600 }
67601 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67602 rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
67603 if( rc!=SQLITE_OK ){
67604 goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
74873 int op, /* Expression opcode */
74874 Expr *pLeft, /* Left operand */
74875 Expr *pRight, /* Right operand */
74876 const Token *pToken /* Argument token */
74877 ){
74878 Expr *p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74879 sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
 
 
 
 
 
 
74880 if( p ) {
74881 sqlite3ExprCheckHeight(pParse, p->nHeight);
74882 }
74883 return p;
74884 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74885
74886 /*
74887 ** Join two expressions using an AND operator. If either expression is
74888 ** NULL, then just return the other expression.
 
 
 
 
74889 */
74890 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
74891 if( pLeft==0 ){
74892 return pRight;
74893 }else if( pRight==0 ){
74894 return pLeft;
 
 
 
 
74895 }else{
74896 Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
74897 sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
74898 return pNew;
74899 }
@@ -76421,19 +76563,10 @@
76421 ** Actually, the way the column cache is currently used, we are guaranteed
76422 ** that the object will never already be in cache. Verify this guarantee.
76423 */
76424 #ifndef NDEBUG
76425 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
76426 #if 0 /* This code wold remove the entry from the cache if it existed */
76427 if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
76428 cacheEntryClear(pParse, p);
76429 p->iLevel = pParse->iCacheLevel;
76430 p->iReg = iReg;
76431 p->lru = pParse->iCacheCnt++;
76432 return;
76433 }
76434 #endif
76435 assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
76436 }
76437 #endif
76438
76439 /* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
76564 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
76565 Parse *pParse, /* Parsing and code generating context */
76566 Table *pTab, /* Description of the table we are reading from */
76567 int iColumn, /* Index of the table column */
76568 int iTable, /* The cursor pointing to the table */
76569 int iReg /* Store results here */
 
76570 ){
76571 Vdbe *v = pParse->pVdbe;
76572 int i;
76573 struct yColCache *p;
76574
@@ -76579,11 +76713,15 @@
76579 return p->iReg;
76580 }
76581 }
76582 assert( v!=0 );
76583 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76584 sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
 
 
 
 
76585 return iReg;
76586 }
76587
76588 /*
76589 ** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
76707 /* This only happens when coding check constraints */
76708 assert( pParse->ckBase>0 );
76709 inReg = pExpr->iColumn + pParse->ckBase;
76710 }else{
76711 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76712 pExpr->iColumn, pExpr->iTable, target);
 
76713 }
76714 break;
76715 }
76716 case TK_INTEGER: {
76717 codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
76984 }
76985
76986
76987 if( pFarg ){
76988 r1 = sqlite3GetTempRange(pParse, nFarg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76989 sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
76990 sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
76991 sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
76992 }else{
76993 r1 = 0;
@@ -80189,10 +80347,11 @@
80189 Index *pPrevIdx = 0; /* Previous index in the loop */
80190 int idx = 0; /* slot in pIdx->aSample[] for next sample */
80191 int eType; /* Datatype of a sample */
80192 IndexSample *pSample; /* A slot in pIdx->aSample[] */
80193
 
80194 if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
80195 return SQLITE_OK;
80196 }
80197
80198 zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
80215 nSample = sqlite3_column_int(pStmt, 1);
80216 pIdx = sqlite3FindIndex(db, zIndex, zDb);
80217 if( pIdx==0 ) continue;
80218 assert( pIdx->nSample==0 );
80219 pIdx->nSample = nSample;
80220 pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) );
80221 pIdx->avgEq = pIdx->aiRowEst[1];
80222 if( pIdx->aSample==0 ){
80223 db->mallocFailed = 1;
80224 sqlite3_finalize(pStmt);
80225 return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
80288 int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
80289 pSample->nByte = n;
80290 if( n < 1){
80291 pSample->u.z = 0;
80292 }else{
80293 pSample->u.z = sqlite3Malloc(n);
80294 if( pSample->u.z==0 ){
80295 db->mallocFailed = 1;
80296 sqlite3_finalize(pStmt);
80297 return SQLITE_NOMEM;
80298 }
@@ -80364,11 +80523,14 @@
80364
80365
80366 /* Load the statistics from the sqlite_stat3 table. */
80367 #ifdef SQLITE_ENABLE_STAT3
80368 if( rc==SQLITE_OK ){
 
 
80369 rc = loadStat3(db, sInfo.zDatabase);
 
80370 }
80371 #endif
80372
80373 if( rc==SQLITE_NOMEM ){
80374 db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
81727 sqliteDeleteColumnNames(db, pTable);
81728 sqlite3DbFree(db, pTable->zName);
81729 sqlite3DbFree(db, pTable->zColAff);
81730 sqlite3SelectDelete(db, pTable->pSelect);
81731 #ifndef SQLITE_OMIT_CHECK
81732 sqlite3ExprDelete(db, pTable->pCheck);
81733 #endif
81734 #ifndef SQLITE_OMIT_VIRTUALTABLE
81735 sqlite3VtabClear(db, pTable);
81736 #endif
81737 sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
82390 */
82391 SQLITE_PRIVATE void sqlite3AddCheckConstraint(
82392 Parse *pParse, /* Parsing context */
82393 Expr *pCheckExpr /* The check expression */
82394 ){
82395 sqlite3 *db = pParse->db;
82396 #ifndef SQLITE_OMIT_CHECK
82397 Table *pTab = pParse->pNewTable;
82398 if( pTab && !IN_DECLARE_VTAB ){
82399 pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, pCheckExpr);
 
 
 
82400 }else
82401 #endif
82402 {
82403 sqlite3ExprDelete(db, pCheckExpr);
82404 }
82405 }
82406
82407 /*
82408 ** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
82668 /* Resolve names in all CHECK constraint expressions.
82669 */
82670 if( p->pCheck ){
82671 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
82672 NameContext sNC; /* Name context for pParse->pNewTable */
 
 
82673
82674 memset(&sNC, 0, sizeof(sNC));
82675 memset(&sSrc, 0, sizeof(sSrc));
82676 sSrc.nSrc = 1;
82677 sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
82678 sSrc.a[0].pTab = p;
82679 sSrc.a[0].iCursor = -1;
82680 sNC.pParse = pParse;
82681 sNC.pSrcList = &sSrc;
82682 sNC.isCheck = 1;
82683 if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){
82684 return;
 
 
 
82685 }
82686 }
82687 #endif /* !defined(SQLITE_OMIT_CHECK) */
82688
82689 /* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
84230 exit_drop_index:
84231 sqlite3SrcListDelete(db, pName);
84232 }
84233
84234 /*
84235 ** pArray is a pointer to an array of objects. Each object in the
84236 ** array is szEntry bytes in size. This routine allocates a new
84237 ** object on the end of the array.
84238 **
84239 ** *pnEntry is the number of entries already in use. *pnAlloc is
84240 ** the previously allocated size of the array. initSize is the
84241 ** suggested initial array size allocation.
84242 **
84243 ** The index of the new entry is returned in *pIdx.
84244 **
84245 ** This routine returns a pointer to the array of objects. This
84246 ** might be the same as the pArray parameter or it might be a different
84247 ** pointer if the array was resized.
 
 
84248 */
84249 SQLITE_PRIVATE void *sqlite3ArrayAllocate(
84250 sqlite3 *db, /* Connection to notify of malloc failures */
84251 void *pArray, /* Array of objects. Might be reallocated */
84252 int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
85839 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
85840 pWInfo = sqlite3WhereBegin(
85841 pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
85842 );
85843 if( pWInfo==0 ) goto delete_from_cleanup;
85844 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
85845 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
85846 if( db->flags & SQLITE_CountRows ){
85847 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
85848 }
85849 sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
87659 FUNCTION(min, 0, 0, 1, 0 ),
87660 AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
87661 FUNCTION(max, -1, 1, 1, minmaxFunc ),
87662 FUNCTION(max, 0, 1, 1, 0 ),
87663 AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87664 FUNCTION(typeof, 1, 0, 0, typeofFunc ),
87665 FUNCTION(length, 1, 0, 0, lengthFunc ),
87666 FUNCTION(substr, 2, 0, 0, substrFunc ),
87667 FUNCTION(substr, 3, 0, 0, substrFunc ),
87668 FUNCTION(abs, 1, 0, 0, absFunc ),
87669 #ifndef SQLITE_OMIT_FLOATING_POINT
87670 FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
87672 #endif
87673 FUNCTION(upper, 1, 0, 0, upperFunc ),
87674 FUNCTION(lower, 1, 0, 0, lowerFunc ),
87675 FUNCTION(coalesce, 1, 0, 0, 0 ),
87676 FUNCTION(coalesce, 0, 0, 0, 0 ),
87677 /* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */
87678 {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0},
87679 FUNCTION(hex, 1, 0, 0, hexFunc ),
87680 /* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */
87681 {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0},
87682 FUNCTION(random, 0, 0, 0, randomFunc ),
87683 FUNCTION(randomblob, 1, 0, 0, randomBlob ),
87684 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
87685 FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
87686 FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
90113 int j1; /* Addresss of jump instruction */
90114 int j2 = 0, j3; /* Addresses of jump instructions */
90115 int regData; /* Register containing first data column */
90116 int iCur; /* Table cursor number */
90117 Index *pIdx; /* Pointer to one of the indices */
 
90118 int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
90119 int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
90120
 
90121 v = sqlite3GetVdbe(pParse);
90122 assert( v!=0 );
90123 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90124 nCol = pTab->nCol;
90125 regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
90148 case OE_Rollback:
90149 case OE_Fail: {
90150 char *zMsg;
90151 sqlite3VdbeAddOp3(v, OP_HaltIfNull,
90152 SQLITE_CONSTRAINT, onError, regData+i);
90153 zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
90154 pTab->zName, pTab->aCol[i].zName);
90155 sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
90156 break;
90157 }
90158 case OE_Ignore: {
@@ -90170,22 +90341,31 @@
90170 }
90171
90172 /* Test all CHECK constraints
90173 */
90174 #ifndef SQLITE_OMIT_CHECK
90175 if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){
90176 int allOk = sqlite3VdbeMakeLabel(v);
90177 pParse->ckBase = regData;
90178 sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL);
90179 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90180 if( onError==OE_Ignore ){
90181 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90182 }else{
90183 if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90184 sqlite3HaltConstraint(pParse, onError, 0, 0);
 
 
 
 
 
 
 
 
 
 
 
90185 }
90186 sqlite3VdbeResolveLabel(v, allOk);
90187 }
90188 #endif /* !defined(SQLITE_OMIT_CHECK) */
90189
90190 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90191 ** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
90237 **
90238 ** to run without a statement journal if there are no indexes on the
90239 ** table.
90240 */
90241 Trigger *pTrigger = 0;
90242 if( pParse->db->flags&SQLITE_RecTriggers ){
90243 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90244 }
90245 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
90246 sqlite3MultiWrite(pParse);
90247 sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
90326 StrAccum errMsg;
90327 const char *zSep;
90328 char *zErr;
90329
90330 sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90331 errMsg.db = pParse->db;
90332 zSep = pIdx->nColumn>1 ? "columns " : "column ";
90333 for(j=0; j<pIdx->nColumn; j++){
90334 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
90335 sqlite3StrAccumAppend(&errMsg, zSep, -1);
90336 zSep = ", ";
@@ -90350,11 +90530,11 @@
90350 }
90351 default: {
90352 Trigger *pTrigger = 0;
90353 assert( onError==OE_Replace );
90354 sqlite3MultiWrite(pParse);
90355 if( pParse->db->flags&SQLITE_RecTriggers ){
90356 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90357 }
90358 sqlite3GenerateRowDelete(
90359 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
90360 );
@@ -90680,11 +90860,11 @@
90680 if( pSrcIdx==0 ){
90681 return 0; /* pDestIdx has no corresponding index in pSrc */
90682 }
90683 }
90684 #ifndef SQLITE_OMIT_CHECK
90685 if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){
90686 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
90687 }
90688 #endif
90689 #ifndef SQLITE_OMIT_FOREIGN_KEY
90690 /* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
95753 int nCol; /* Number of columns in the result set */
95754 Expr *p; /* Expression for a single result column */
95755 char *zName; /* Column name */
95756 int nName; /* Size of name in zName[] */
95757
95758 *pnCol = nCol = pEList ? pEList->nExpr : 0;
95759 aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95760 if( aCol==0 ) return SQLITE_NOMEM;
 
 
 
 
 
 
 
 
95761 for(i=0, pCol=aCol; i<nCol; i++, pCol++){
95762 /* Get an appropriate name for the column
95763 */
95764 p = pEList->a[i].pExpr;
95765 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
98723 if( pCol->iSorterColumn>=j ){
98724 int r1 = j + regBase;
98725 int r2;
98726
98727 r2 = sqlite3ExprCodeGetColumn(pParse,
98728 pCol->pTab, pCol->iColumn, pCol->iTable, r1);
98729 if( r1!=r2 ){
98730 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
98731 }
98732 j++;
98733 }
@@ -103212,11 +103400,14 @@
103212 #ifdef SQLITE_EBCDIC
103213 if( *pnoCase ) return 0;
103214 #endif
103215 pList = pExpr->x.pList;
103216 pLeft = pList->a[1].pExpr;
103217 if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){
 
 
 
103218 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103219 ** be the name of an indexed column with TEXT affinity. */
103220 return 0;
103221 }
103222 assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
106909 );
106910 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
106911 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
106912 int r;
106913 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
106914 regRowid);
106915 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
106916 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
106917 }
106918 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
106919
@@ -107822,11 +108013,11 @@
107822 ** An instance of this structure is used to store the LIKE,
107823 ** GLOB, NOT LIKE, and NOT GLOB operators.
107824 */
107825 struct LikeOp {
107826 Token eOperator; /* "like" or "glob" or "regexp" */
107827 int not; /* True if the NOT keyword is present */
107828 };
107829
107830 /*
107831 ** An instance of the following structure describes the event of a
107832 ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108001 #endif
108002 #define sqlite3ParserARG_SDECL Parse *pParse;
108003 #define sqlite3ParserARG_PDECL ,Parse *pParse
108004 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108005 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
108006 #define YYNSTATE 629
108007 #define YYNRULE 327
108008 #define YYFALLBACK 1
108009 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108010 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108011 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108012
@@ -108072,480 +108263,478 @@
108072 ** shifting terminals.
108073 ** yy_reduce_ofst[] For each state, the offset into yy_action for
108074 ** shifting non-terminals after a reduce.
108075 ** yy_default[] Default action for each state.
108076 */
108077 #define YY_ACTTAB_COUNT (1580)
108078 static const YYACTIONTYPE yy_action[] = {
108079 /* 0 */ 310, 328, 574, 573, 15, 172, 187, 596, 56, 56,
108080 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108081 /* 20 */ 52, 52, 51, 234, 622, 621, 626, 622, 621, 299,
108082 /* 30 */ 589, 583, 56, 56, 56, 56, 236, 54, 54, 54,
108083 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 234, 351, 57,
108084 /* 50 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108085 /* 60 */ 56, 56, 570, 54, 54, 54, 54, 53, 53, 52,
108086 /* 70 */ 52, 52, 51, 234, 310, 596, 326, 607, 233, 232,
108087 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108088 /* 90 */ 51, 234, 619, 618, 326, 619, 618, 166, 605, 492,
108089 /* 100 */ 381, 378, 377, 235, 589, 583, 554, 495, 1, 59,
108090 /* 110 */ 19, 376, 622, 621, 53, 53, 52, 52, 52, 51,
108091 /* 120 */ 234, 571, 571, 57, 58, 48, 581, 580, 582, 582,
108092 /* 130 */ 55, 55, 56, 56, 56, 56, 215, 54, 54, 54,
108093 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 224,
108094 /* 150 */ 50, 47, 147, 177, 139, 281, 384, 276, 383, 169,
108095 /* 160 */ 408, 553, 578, 578, 622, 621, 272, 224, 439, 550,
108096 /* 170 */ 552, 410, 139, 281, 384, 276, 383, 169, 589, 583,
108097 /* 180 */ 619, 618, 280, 620, 272, 195, 413, 309, 440, 441,
108098 /* 190 */ 567, 491, 214, 279, 560, 600, 92, 57, 58, 48,
108099 /* 200 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108100 /* 210 */ 559, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108101 /* 220 */ 51, 234, 310, 464, 233, 232, 558, 133, 519, 50,
108102 /* 230 */ 47, 147, 619, 618, 565, 436, 397, 515, 514, 518,
108103 /* 240 */ 410, 387, 438, 389, 437, 622, 621, 442, 570, 433,
108104 /* 250 */ 203, 390, 589, 583, 6, 413, 166, 670, 250, 381,
108105 /* 260 */ 378, 377, 525, 190, 600, 92, 594, 571, 571, 465,
108106 /* 270 */ 376, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108107 /* 280 */ 56, 56, 56, 56, 599, 54, 54, 54, 54, 53,
108108 /* 290 */ 53, 52, 52, 52, 51, 234, 310, 592, 592, 592,
108109 /* 300 */ 490, 182, 247, 548, 249, 397, 273, 410, 7, 439,
108110 /* 310 */ 398, 606, 67, 619, 618, 620, 472, 256, 347, 255,
108111 /* 320 */ 473, 620, 413, 576, 620, 65, 589, 583, 236, 440,
108112 /* 330 */ 336, 600, 92, 68, 364, 192, 481, 622, 621, 547,
108113 /* 340 */ 622, 621, 560, 323, 207, 57, 58, 48, 581, 580,
108114 /* 350 */ 582, 582, 55, 55, 56, 56, 56, 56, 559, 54,
108115 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108116 /* 370 */ 310, 410, 397, 146, 558, 531, 401, 348, 599, 166,
108117 /* 380 */ 248, 204, 381, 378, 377, 541, 413, 171, 337, 570,
108118 /* 390 */ 622, 621, 40, 376, 38, 600, 74, 465, 548, 490,
108119 /* 400 */ 589, 583, 532, 350, 579, 619, 618, 297, 619, 618,
108120 /* 410 */ 480, 67, 470, 39, 620, 599, 406, 574, 573, 57,
108121 /* 420 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108122 /* 430 */ 56, 56, 577, 54, 54, 54, 54, 53, 53, 52,
108123 /* 440 */ 52, 52, 51, 234, 310, 256, 347, 255, 530, 52,
108124 /* 450 */ 52, 52, 51, 234, 345, 564, 236, 386, 619, 618,
108125 /* 460 */ 957, 185, 418, 2, 408, 410, 578, 578, 198, 197,
108126 /* 470 */ 196, 499, 183, 167, 589, 583, 671, 570, 505, 506,
108127 /* 480 */ 413, 267, 601, 672, 546, 208, 602, 36, 601, 600,
108128 /* 490 */ 91, 468, 602, 57, 58, 48, 581, 580, 582, 582,
108129 /* 500 */ 55, 55, 56, 56, 56, 56, 202, 54, 54, 54,
108130 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 599,
108131 /* 520 */ 157, 408, 527, 578, 578, 263, 490, 265, 410, 873,
108132 /* 530 */ 410, 474, 474, 366, 373, 410, 504, 428, 67, 290,
108133 /* 540 */ 599, 620, 352, 413, 408, 413, 578, 578, 589, 583,
108134 /* 550 */ 413, 382, 600, 92, 600, 16, 543, 62, 503, 600,
108135 /* 560 */ 92, 408, 346, 578, 578, 168, 45, 57, 58, 48,
108136 /* 570 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108137 /* 580 */ 200, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108138 /* 590 */ 51, 234, 310, 393, 395, 534, 510, 617, 616, 615,
108139 /* 600 */ 318, 314, 172, 66, 596, 410, 338, 596, 324, 571,
108140 /* 610 */ 571, 50, 47, 147, 599, 629, 627, 330, 539, 315,
108141 /* 620 */ 413, 30, 589, 583, 272, 236, 199, 144, 176, 600,
108142 /* 630 */ 73, 420, 947, 620, 947, 420, 946, 351, 946, 175,
108143 /* 640 */ 596, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108144 /* 650 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108145 /* 660 */ 53, 52, 52, 52, 51, 234, 310, 261, 410, 413,
108146 /* 670 */ 269, 208, 596, 363, 410, 596, 424, 360, 600, 69,
108147 /* 680 */ 424, 327, 620, 413, 50, 47, 147, 410, 358, 413,
108148 /* 690 */ 575, 553, 600, 94, 483, 509, 589, 583, 600, 97,
108149 /* 700 */ 552, 484, 413, 620, 188, 599, 551, 563, 596, 566,
108150 /* 710 */ 334, 600, 95, 205, 201, 57, 58, 48, 581, 580,
108151 /* 720 */ 582, 582, 55, 55, 56, 56, 56, 56, 352, 54,
108152 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108153 /* 740 */ 310, 410, 261, 410, 167, 22, 356, 599, 359, 623,
108154 /* 750 */ 50, 47, 147, 548, 357, 562, 413, 620, 413, 332,
108155 /* 760 */ 523, 270, 410, 167, 620, 600, 104, 600, 103, 603,
108156 /* 770 */ 589, 583, 339, 539, 304, 423, 222, 413, 174, 304,
108157 /* 780 */ 422, 561, 567, 405, 214, 260, 600, 106, 620, 57,
108158 /* 790 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108159 /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
108160 /* 810 */ 52, 52, 51, 234, 310, 410, 557, 413, 410, 421,
108161 /* 820 */ 273, 35, 512, 146, 421, 12, 600, 107, 213, 144,
108162 /* 830 */ 413, 410, 32, 413, 410, 620, 365, 353, 358, 600,
108163 /* 840 */ 134, 11, 600, 135, 589, 583, 413, 21, 548, 413,
108164 /* 850 */ 316, 148, 620, 620, 170, 600, 98, 223, 600, 102,
108165 /* 860 */ 374, 168, 167, 57, 58, 48, 581, 580, 582, 582,
108166 /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
108167 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 410,
108168 /* 890 */ 273, 413, 410, 273, 212, 469, 410, 167, 628, 2,
108169 /* 900 */ 600, 101, 545, 221, 413, 620, 130, 413, 620, 410,
108170 /* 910 */ 539, 413, 537, 600, 93, 315, 600, 100, 589, 583,
108171 /* 920 */ 600, 77, 425, 305, 413, 620, 254, 322, 599, 458,
108172 /* 930 */ 320, 171, 543, 600, 96, 521, 520, 57, 58, 48,
108173 /* 940 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108174 /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108175 /* 960 */ 51, 234, 310, 410, 273, 413, 410, 457, 358, 35,
108176 /* 970 */ 426, 230, 306, 319, 600, 138, 467, 520, 413, 620,
108177 /* 980 */ 143, 413, 410, 620, 410, 353, 529, 600, 137, 142,
108178 /* 990 */ 600, 136, 589, 583, 604, 261, 528, 413, 229, 413,
108179 /* 1000 */ 620, 321, 495, 28, 543, 543, 600, 76, 600, 90,
108180 /* 1010 */ 620, 57, 46, 48, 581, 580, 582, 582, 55, 55,
108181 /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108182 /* 1030 */ 53, 52, 52, 52, 51, 234, 310, 261, 451, 413,
108183 /* 1040 */ 410, 211, 611, 285, 283, 610, 609, 502, 600, 89,
108184 /* 1050 */ 380, 217, 620, 128, 140, 413, 220, 620, 410, 409,
108185 /* 1060 */ 620, 620, 588, 587, 600, 75, 589, 583, 271, 620,
108186 /* 1070 */ 51, 234, 127, 413, 620, 599, 627, 330, 27, 375,
108187 /* 1080 */ 449, 279, 600, 88, 585, 584, 58, 48, 581, 580,
108188 /* 1090 */ 582, 582, 55, 55, 56, 56, 56, 56, 410, 54,
108189 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108190 /* 1110 */ 310, 586, 410, 413, 410, 261, 593, 165, 399, 556,
108191 /* 1120 */ 126, 371, 600, 87, 478, 186, 123, 413, 367, 413,
108192 /* 1130 */ 620, 620, 410, 620, 620, 410, 600, 99, 600, 86,
108193 /* 1140 */ 589, 583, 475, 122, 258, 171, 471, 413, 160, 121,
108194 /* 1150 */ 413, 14, 159, 463, 25, 24, 600, 17, 448, 600,
108195 /* 1160 */ 85, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108196 /* 1170 */ 56, 56, 158, 54, 54, 54, 54, 53, 53, 52,
108197 /* 1180 */ 52, 52, 51, 234, 44, 404, 261, 3, 544, 261,
108198 /* 1190 */ 540, 414, 621, 460, 119, 118, 538, 275, 10, 349,
108199 /* 1200 */ 4, 620, 407, 620, 620, 620, 116, 44, 404, 410,
108200 /* 1210 */ 3, 620, 620, 410, 414, 621, 456, 454, 252, 450,
108201 /* 1220 */ 508, 402, 111, 109, 413, 407, 155, 444, 413, 447,
108202 /* 1230 */ 435, 565, 219, 600, 84, 620, 108, 600, 83, 64,
108203 /* 1240 */ 434, 417, 625, 150, 402, 333, 410, 237, 238, 124,
108204 /* 1250 */ 274, 41, 42, 533, 565, 206, 189, 261, 43, 412,
108205 /* 1260 */ 411, 413, 261, 594, 488, 620, 329, 149, 419, 268,
108206 /* 1270 */ 600, 72, 620, 266, 41, 42, 181, 620, 410, 620,
108207 /* 1280 */ 105, 43, 412, 411, 620, 624, 594, 614, 620, 599,
108208 /* 1290 */ 228, 125, 313, 413, 592, 592, 592, 591, 590, 13,
108209 /* 1300 */ 218, 410, 600, 71, 236, 244, 44, 404, 264, 3,
108210 /* 1310 */ 312, 613, 340, 414, 621, 180, 413, 592, 592, 592,
108211 /* 1320 */ 591, 590, 13, 620, 407, 600, 82, 410, 416, 34,
108212 /* 1330 */ 404, 410, 3, 410, 262, 410, 414, 621, 612, 331,
108213 /* 1340 */ 178, 415, 413, 402, 8, 236, 413, 407, 413, 620,
108214 /* 1350 */ 413, 600, 81, 565, 257, 600, 80, 600, 70, 600,
108215 /* 1360 */ 18, 598, 361, 462, 461, 30, 402, 294, 31, 620,
108216 /* 1370 */ 293, 354, 251, 41, 42, 410, 565, 620, 620, 620,
108217 /* 1380 */ 43, 412, 411, 453, 396, 594, 620, 620, 394, 61,
108218 /* 1390 */ 413, 292, 443, 622, 621, 243, 41, 42, 620, 600,
108219 /* 1400 */ 79, 597, 291, 43, 412, 411, 60, 620, 594, 240,
108220 /* 1410 */ 620, 410, 231, 37, 555, 173, 592, 592, 592, 591,
108221 /* 1420 */ 590, 13, 216, 239, 620, 184, 413, 302, 301, 300,
108222 /* 1430 */ 179, 298, 388, 565, 452, 600, 78, 286, 620, 592,
108223 /* 1440 */ 592, 592, 591, 590, 13, 429, 29, 413, 151, 289,
108224 /* 1450 */ 242, 145, 392, 194, 193, 288, 600, 9, 542, 241,
108225 /* 1460 */ 620, 525, 391, 284, 620, 594, 620, 620, 522, 536,
108226 /* 1470 */ 620, 535, 153, 385, 465, 516, 282, 325, 154, 517,
108227 /* 1480 */ 277, 152, 512, 511, 513, 129, 226, 308, 487, 486,
108228 /* 1490 */ 485, 164, 372, 493, 307, 227, 592, 592, 592, 225,
108229 /* 1500 */ 479, 163, 368, 370, 162, 476, 210, 477, 26, 259,
108230 /* 1510 */ 161, 466, 362, 141, 132, 120, 117, 455, 156, 115,
108231 /* 1520 */ 344, 343, 256, 342, 245, 114, 113, 446, 311, 112,
108232 /* 1530 */ 23, 317, 432, 236, 131, 431, 110, 430, 20, 427,
108233 /* 1540 */ 608, 595, 295, 63, 379, 287, 509, 191, 278, 403,
108234 /* 1550 */ 572, 569, 497, 498, 496, 494, 335, 459, 445, 303,
108235 /* 1560 */ 296, 246, 341, 355, 5, 568, 369, 507, 253, 549,
108236 /* 1570 */ 526, 209, 400, 501, 500, 524, 234, 958, 489, 482,
108237 };
108238 static const YYCODETYPE yy_lookahead[] = {
108239 /* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108240 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108241 /* 20 */ 89, 90, 91, 92, 26, 27, 1, 26, 27, 15,
108242 /* 30 */ 49, 50, 77, 78, 79, 80, 116, 82, 83, 84,
108243 /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 128, 68,
108244 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108245 /* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108246 /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 86, 87,
108247 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108248 /* 90 */ 91, 92, 94, 95, 19, 94, 95, 96, 172, 173,
108249 /* 100 */ 99, 100, 101, 197, 49, 50, 177, 181, 22, 54,
108250 /* 110 */ 204, 110, 26, 27, 86, 87, 88, 89, 90, 91,
108251 /* 120 */ 92, 129, 130, 68, 69, 70, 71, 72, 73, 74,
108252 /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84,
108253 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108254 /* 150 */ 221, 222, 223, 96, 97, 98, 99, 100, 101, 102,
108255 /* 160 */ 112, 32, 114, 115, 26, 27, 109, 92, 150, 25,
108256 /* 170 */ 41, 150, 97, 98, 99, 100, 101, 102, 49, 50,
108257 /* 180 */ 94, 95, 98, 165, 109, 25, 165, 163, 170, 171,
108258 /* 190 */ 166, 167, 168, 109, 12, 174, 175, 68, 69, 70,
108259 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108260 /* 210 */ 28, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108261 /* 220 */ 91, 92, 19, 11, 86, 87, 44, 24, 46, 221,
108262 /* 230 */ 222, 223, 94, 95, 66, 97, 215, 7, 8, 57,
108263 /* 240 */ 150, 220, 104, 19, 106, 26, 27, 229, 230, 241,
108264 /* 250 */ 160, 27, 49, 50, 22, 165, 96, 118, 16, 99,
108265 /* 260 */ 100, 101, 94, 119, 174, 175, 98, 129, 130, 57,
108266 /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108267 /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108268 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
108269 /* 300 */ 150, 23, 60, 25, 62, 215, 150, 150, 76, 150,
108270 /* 310 */ 220, 161, 162, 94, 95, 165, 30, 105, 106, 107,
108271 /* 320 */ 34, 165, 165, 23, 165, 25, 49, 50, 116, 170,
108272 /* 330 */ 171, 174, 175, 22, 48, 185, 186, 26, 27, 120,
108273 /* 340 */ 26, 27, 12, 187, 160, 68, 69, 70, 71, 72,
108274 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 28, 82,
108275 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108276 /* 370 */ 19, 150, 215, 95, 44, 23, 46, 220, 194, 96,
108277 /* 380 */ 138, 160, 99, 100, 101, 23, 165, 25, 229, 230,
108278 /* 390 */ 26, 27, 135, 110, 137, 174, 175, 57, 120, 150,
108279 /* 400 */ 49, 50, 88, 219, 113, 94, 95, 158, 94, 95,
108280 /* 410 */ 161, 162, 21, 136, 165, 194, 169, 170, 171, 68,
108281 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108282 /* 430 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108283 /* 440 */ 89, 90, 91, 92, 19, 105, 106, 107, 23, 88,
108284 /* 450 */ 89, 90, 91, 92, 63, 23, 116, 88, 94, 95,
108285 /* 460 */ 142, 143, 144, 145, 112, 150, 114, 115, 105, 106,
108286 /* 470 */ 107, 23, 23, 25, 49, 50, 118, 230, 97, 98,
108287 /* 480 */ 165, 16, 113, 118, 120, 160, 117, 136, 113, 174,
108288 /* 490 */ 175, 100, 117, 68, 69, 70, 71, 72, 73, 74,
108289 /* 500 */ 75, 76, 77, 78, 79, 80, 160, 82, 83, 84,
108290 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 194,
108291 /* 520 */ 25, 112, 23, 114, 115, 60, 150, 62, 150, 138,
108292 /* 530 */ 150, 105, 106, 107, 19, 150, 36, 161, 162, 224,
108293 /* 540 */ 194, 165, 217, 165, 112, 165, 114, 115, 49, 50,
108294 /* 550 */ 165, 51, 174, 175, 174, 175, 166, 232, 58, 174,
108295 /* 560 */ 175, 112, 237, 114, 115, 50, 22, 68, 69, 70,
108296 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108297 /* 580 */ 160, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108298 /* 590 */ 91, 92, 19, 215, 214, 205, 23, 7, 8, 9,
108299 /* 600 */ 215, 155, 24, 22, 26, 150, 97, 26, 108, 129,
108300 /* 610 */ 130, 221, 222, 223, 194, 0, 1, 2, 150, 104,
108301 /* 620 */ 165, 126, 49, 50, 109, 116, 206, 207, 118, 174,
108302 /* 630 */ 175, 22, 23, 165, 25, 22, 23, 128, 25, 118,
108303 /* 640 */ 26, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108304 /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108305 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
108306 /* 670 */ 23, 160, 94, 227, 150, 94, 67, 231, 174, 175,
108307 /* 680 */ 67, 213, 165, 165, 221, 222, 223, 150, 150, 165,
108308 /* 690 */ 23, 32, 174, 175, 181, 182, 49, 50, 174, 175,
108309 /* 700 */ 41, 188, 165, 165, 22, 194, 177, 11, 94, 23,
108310 /* 710 */ 193, 174, 175, 160, 22, 68, 69, 70, 71, 72,
108311 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 217, 82,
108312 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108313 /* 740 */ 19, 150, 150, 150, 25, 24, 19, 194, 237, 150,
108314 /* 750 */ 221, 222, 223, 25, 27, 23, 165, 165, 165, 242,
108315 /* 760 */ 165, 23, 150, 25, 165, 174, 175, 174, 175, 174,
108316 /* 770 */ 49, 50, 219, 150, 22, 23, 238, 165, 25, 22,
108317 /* 780 */ 23, 23, 166, 167, 168, 193, 174, 175, 165, 68,
108318 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108319 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108320 /* 810 */ 89, 90, 91, 92, 19, 150, 23, 165, 150, 67,
108321 /* 820 */ 150, 25, 103, 95, 67, 35, 174, 175, 206, 207,
108322 /* 830 */ 165, 150, 25, 165, 150, 165, 213, 150, 150, 174,
108323 /* 840 */ 175, 35, 174, 175, 49, 50, 165, 52, 120, 165,
108324 /* 850 */ 245, 246, 165, 165, 35, 174, 175, 187, 174, 175,
108325 /* 860 */ 23, 50, 25, 68, 69, 70, 71, 72, 73, 74,
108326 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108327 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108328 /* 890 */ 150, 165, 150, 150, 160, 23, 150, 25, 144, 145,
108329 /* 900 */ 174, 175, 120, 216, 165, 165, 22, 165, 165, 150,
108330 /* 910 */ 150, 165, 27, 174, 175, 104, 174, 175, 49, 50,
108331 /* 920 */ 174, 175, 247, 248, 165, 165, 238, 187, 194, 23,
108332 /* 930 */ 187, 25, 166, 174, 175, 190, 191, 68, 69, 70,
108333 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108334 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108335 /* 960 */ 91, 92, 19, 150, 150, 165, 150, 23, 150, 25,
108336 /* 970 */ 23, 205, 25, 213, 174, 175, 190, 191, 165, 165,
108337 /* 980 */ 118, 165, 150, 165, 150, 150, 23, 174, 175, 39,
108338 /* 990 */ 174, 175, 49, 50, 173, 150, 23, 165, 52, 165,
108339 /* 1000 */ 165, 187, 181, 22, 166, 166, 174, 175, 174, 175,
108340 /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108341 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108342 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108343 /* 1040 */ 150, 160, 150, 205, 205, 150, 150, 29, 174, 175,
108344 /* 1050 */ 52, 216, 165, 22, 150, 165, 238, 165, 150, 150,
108345 /* 1060 */ 165, 165, 49, 50, 174, 175, 49, 50, 23, 165,
108346 /* 1070 */ 91, 92, 22, 165, 165, 194, 1, 2, 22, 52,
108347 /* 1080 */ 193, 109, 174, 175, 71, 72, 69, 70, 71, 72,
108348 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108349 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108350 /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 102, 150, 150,
108351 /* 1120 */ 22, 19, 174, 175, 20, 24, 104, 165, 43, 165,
108352 /* 1130 */ 165, 165, 150, 165, 165, 150, 174, 175, 174, 175,
108353 /* 1140 */ 49, 50, 59, 53, 138, 25, 53, 165, 104, 22,
108354 /* 1150 */ 165, 5, 118, 1, 76, 76, 174, 175, 193, 174,
108355 /* 1160 */ 175, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108356 /* 1170 */ 79, 80, 35, 82, 83, 84, 85, 86, 87, 88,
108357 /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 150,
108358 /* 1190 */ 150, 26, 27, 27, 108, 127, 150, 150, 22, 25,
108359 /* 1200 */ 22, 165, 37, 165, 165, 165, 119, 19, 20, 150,
108360 /* 1210 */ 22, 165, 165, 150, 26, 27, 23, 1, 16, 20,
108361 /* 1220 */ 150, 56, 119, 108, 165, 37, 121, 128, 165, 193,
108362 /* 1230 */ 23, 66, 193, 174, 175, 165, 127, 174, 175, 16,
108363 /* 1240 */ 23, 146, 147, 15, 56, 65, 150, 152, 140, 154,
108364 /* 1250 */ 150, 86, 87, 88, 66, 160, 22, 150, 93, 94,
108365 /* 1260 */ 95, 165, 150, 98, 150, 165, 3, 246, 4, 150,
108366 /* 1270 */ 174, 175, 165, 150, 86, 87, 6, 165, 150, 165,
108367 /* 1280 */ 164, 93, 94, 95, 165, 149, 98, 149, 165, 194,
108368 /* 1290 */ 180, 180, 249, 165, 129, 130, 131, 132, 133, 134,
108369 /* 1300 */ 193, 150, 174, 175, 116, 193, 19, 20, 150, 22,
108370 /* 1310 */ 249, 149, 217, 26, 27, 151, 165, 129, 130, 131,
108371 /* 1320 */ 132, 133, 134, 165, 37, 174, 175, 150, 149, 19,
108372 /* 1330 */ 20, 150, 22, 150, 150, 150, 26, 27, 13, 244,
108373 /* 1340 */ 151, 159, 165, 56, 25, 116, 165, 37, 165, 165,
108374 /* 1350 */ 165, 174, 175, 66, 150, 174, 175, 174, 175, 174,
108375 /* 1360 */ 175, 194, 150, 150, 150, 126, 56, 199, 124, 165,
108376 /* 1370 */ 200, 150, 150, 86, 87, 150, 66, 165, 165, 165,
108377 /* 1380 */ 93, 94, 95, 150, 122, 98, 165, 165, 123, 22,
108378 /* 1390 */ 165, 201, 150, 26, 27, 150, 86, 87, 165, 174,
108379 /* 1400 */ 175, 203, 202, 93, 94, 95, 125, 165, 98, 150,
108380 /* 1410 */ 165, 150, 225, 135, 157, 118, 129, 130, 131, 132,
108381 /* 1420 */ 133, 134, 5, 150, 165, 157, 165, 10, 11, 12,
108382 /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 210, 165, 129,
108383 /* 1440 */ 130, 131, 132, 133, 134, 150, 104, 165, 31, 150,
108384 /* 1450 */ 33, 150, 150, 86, 87, 150, 174, 175, 211, 42,
108385 /* 1460 */ 165, 94, 121, 210, 165, 98, 165, 165, 176, 211,
108386 /* 1470 */ 165, 211, 55, 104, 57, 184, 210, 47, 61, 176,
108387 /* 1480 */ 176, 64, 103, 176, 178, 22, 92, 179, 176, 176,
108388 /* 1490 */ 176, 156, 18, 184, 179, 228, 129, 130, 131, 228,
108389 /* 1500 */ 157, 156, 45, 157, 156, 236, 157, 157, 135, 235,
108390 /* 1510 */ 156, 189, 157, 68, 218, 189, 22, 199, 156, 192,
108391 /* 1520 */ 157, 18, 105, 106, 107, 192, 192, 199, 111, 192,
108392 /* 1530 */ 240, 157, 40, 116, 218, 157, 189, 157, 240, 38,
108393 /* 1540 */ 153, 166, 198, 243, 178, 209, 182, 196, 177, 226,
108394 /* 1550 */ 230, 230, 166, 177, 177, 166, 139, 199, 199, 148,
108395 /* 1560 */ 195, 209, 209, 239, 196, 166, 234, 183, 239, 208,
108396 /* 1570 */ 174, 233, 191, 183, 183, 174, 92, 250, 186, 186,
108397 };
108398 #define YY_SHIFT_USE_DFLT (-81)
108399 #define YY_SHIFT_COUNT (417)
108400 #define YY_SHIFT_MIN (-80)
108401 #define YY_SHIFT_MAX (1503)
108402 static const short yy_shift_ofst[] = {
108403 /* 0 */ 1075, 1188, 1417, 1188, 1287, 1287, 138, 138, 1, -19,
108404 /* 10 */ 1287, 1287, 1287, 1287, 340, -2, 129, 129, 795, 1165,
108405 /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108406 /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108407 /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108408 /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108409 /* 60 */ 1287, 1287, 212, -2, -2, -8, -8, 614, 1229, 55,
108410 /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108411 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108412 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108413 /* 100 */ -45, -45, -45, -45, -1, 57, 28, 361, -2, -2,
108414 /* 110 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108415 /* 120 */ -2, -2, -2, -2, 391, 515, -2, -2, -2, -2,
108416 /* 130 */ -2, 509, -80, 614, 979, 1484, -81, -81, -81, 1367,
108417 /* 140 */ 75, 182, 182, 314, 311, 364, 219, 86, 613, 609,
108418 /* 150 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108419 /* 160 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108420 /* 170 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108421 /* 180 */ -2, -2, 578, 578, 578, 615, 1229, 1229, 1229, -81,
108422 /* 190 */ -81, -81, 160, 168, 168, 283, 500, 500, 500, 278,
108423 /* 200 */ 449, 330, 432, 409, 352, 48, 48, 48, 48, 426,
108424 /* 210 */ 286, 48, 48, 728, 581, 369, 590, 495, 224, 224,
108425 /* 220 */ 727, 495, 727, 719, 614, 659, 614, 659, 811, 659,
108426 /* 230 */ 224, 257, 480, 480, 614, 144, 375, -18, 1501, 1297,
108427 /* 240 */ 1297, 1492, 1492, 1297, 1494, 1445, 1239, 1503, 1503, 1503,
108428 /* 250 */ 1503, 1297, 1474, 1239, 1494, 1445, 1445, 1297, 1474, 1373,
108429 /* 260 */ 1457, 1297, 1297, 1474, 1297, 1474, 1297, 1474, 1463, 1369,
108430 /* 270 */ 1369, 1369, 1430, 1394, 1394, 1463, 1369, 1379, 1369, 1430,
108431 /* 280 */ 1369, 1369, 1341, 1342, 1341, 1342, 1341, 1342, 1297, 1297,
108432 /* 290 */ 1278, 1281, 1262, 1244, 1265, 1239, 1229, 1319, 1325, 1325,
108433 /* 300 */ 1270, 1270, 1270, 1270, -81, -81, -81, -81, -81, -81,
108434 /* 310 */ 1013, 242, 757, 752, 465, 363, 947, 232, 944, 906,
108435 /* 320 */ 872, 837, 738, 448, 381, 230, 84, 362, 300, 1264,
108436 /* 330 */ 1263, 1234, 1108, 1228, 1180, 1223, 1217, 1207, 1099, 1174,
108437 /* 340 */ 1109, 1115, 1103, 1199, 1105, 1202, 1216, 1087, 1193, 1178,
108438 /* 350 */ 1174, 1176, 1068, 1079, 1078, 1086, 1166, 1137, 1034, 1152,
108439 /* 360 */ 1146, 1127, 1044, 1006, 1093, 1120, 1090, 1083, 1085, 1022,
108440 /* 370 */ 1101, 1104, 1102, 972, 1015, 1098, 1027, 1056, 1050, 1045,
108441 /* 380 */ 1031, 998, 1018, 981, 946, 950, 973, 963, 862, 885,
108442 /* 390 */ 819, 884, 782, 796, 806, 807, 790, 796, 793, 758,
108443 /* 400 */ 753, 732, 692, 696, 682, 686, 667, 544, 291, 521,
108444 /* 410 */ 510, 365, 358, 139, 114, 54, 14, 25,
108445 };
108446 #define YY_REDUCE_USE_DFLT (-169)
108447 #define YY_REDUCE_COUNT (309)
108448 #define YY_REDUCE_MIN (-168)
108449 #define YY_REDUCE_MAX (1411)
108450 static const short yy_reduce_ofst[] = {
108451 /* 0 */ 318, 90, 1095, 221, 157, 21, 159, 18, 150, 390,
108452 /* 10 */ 385, 378, 380, 315, 325, 249, 529, -71, 8, 1282,
108453 /* 20 */ 1261, 1225, 1185, 1183, 1181, 1177, 1151, 1128, 1096, 1063,
108454 /* 30 */ 1059, 985, 982, 964, 962, 948, 908, 890, 874, 834,
108455 /* 40 */ 832, 816, 813, 800, 759, 746, 742, 739, 726, 684,
108456 /* 50 */ 681, 668, 665, 652, 612, 593, 591, 537, 524, 518,
108457 /* 60 */ 504, 455, 511, 376, 517, 247, -168, 24, 420, 463,
108458 /* 70 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108459 /* 80 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108460 /* 90 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108461 /* 100 */ 463, 463, 463, 463, 463, -74, 463, 463, 1112, 835,
108462 /* 110 */ 1107, 1039, 1036, 965, 887, 845, 818, 760, 688, 687,
108463 /* 120 */ 538, 743, 623, 592, 446, 513, 814, 740, 670, 156,
108464 /* 130 */ 468, 553, 184, 616, 463, 463, 463, 463, 463, 595,
108465 /* 140 */ 821, 786, 745, 909, 1305, 1302, 1301, 1299, 675, 675,
108466 /* 150 */ 1295, 1273, 1259, 1245, 1242, 1233, 1222, 1221, 1214, 1213,
108467 /* 160 */ 1212, 1204, 1184, 1158, 1123, 1119, 1114, 1100, 1070, 1047,
108468 /* 170 */ 1046, 1040, 1038, 969, 968, 966, 909, 904, 896, 895,
108469 /* 180 */ 892, 599, 839, 838, 766, 754, 881, 734, 346, 605,
108470 /* 190 */ 622, -94, 1393, 1401, 1396, 1392, 1391, 1390, 1384, 1361,
108471 /* 200 */ 1365, 1381, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1332,
108472 /* 210 */ 1338, 1365, 1365, 1361, 1399, 1368, 1411, 1359, 1353, 1352,
108473 /* 220 */ 1329, 1358, 1324, 1366, 1389, 1377, 1386, 1376, 1364, 1371,
108474 /* 230 */ 1336, 1323, 1321, 1320, 1375, 1344, 1351, 1387, 1300, 1380,
108475 /* 240 */ 1378, 1298, 1290, 1374, 1316, 1347, 1328, 1337, 1334, 1333,
108476 /* 250 */ 1327, 1363, 1362, 1318, 1296, 1326, 1322, 1355, 1354, 1269,
108477 /* 260 */ 1274, 1350, 1349, 1348, 1346, 1345, 1343, 1335, 1315, 1314,
108478 /* 270 */ 1313, 1312, 1309, 1271, 1267, 1308, 1307, 1306, 1304, 1291,
108479 /* 280 */ 1303, 1292, 1260, 1266, 1258, 1253, 1247, 1227, 1268, 1257,
108480 /* 290 */ 1187, 1198, 1200, 1190, 1170, 1168, 1167, 1182, 1189, 1164,
108481 /* 300 */ 1179, 1162, 1138, 1136, 1061, 1043, 1021, 1111, 1110, 1116,
108482 };
108483 static const YYACTIONTYPE yy_default[] = {
108484 /* 0 */ 634, 868, 956, 956, 868, 868, 956, 956, 956, 758,
108485 /* 10 */ 956, 956, 956, 866, 956, 956, 786, 786, 930, 956,
108486 /* 20 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108487 /* 30 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108488 /* 40 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108489 /* 50 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108490 /* 60 */ 956, 956, 956, 956, 956, 956, 956, 673, 762, 792,
108491 /* 70 */ 956, 956, 956, 956, 956, 956, 956, 956, 929, 931,
108492 /* 80 */ 800, 799, 909, 773, 797, 790, 794, 869, 862, 863,
108493 /* 90 */ 861, 865, 870, 956, 793, 829, 846, 828, 840, 845,
108494 /* 100 */ 852, 844, 841, 831, 830, 665, 832, 833, 956, 956,
108495 /* 110 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108496 /* 120 */ 956, 956, 956, 956, 660, 727, 956, 956, 956, 956,
108497 /* 130 */ 956, 956, 956, 956, 834, 835, 849, 848, 847, 956,
108498 /* 140 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108499 /* 150 */ 956, 936, 934, 956, 881, 956, 956, 956, 956, 956,
108500 /* 160 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108501 /* 170 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108502 /* 180 */ 956, 640, 758, 758, 758, 634, 956, 956, 956, 948,
108503 /* 190 */ 762, 752, 718, 956, 956, 956, 956, 956, 956, 956,
108504 /* 200 */ 956, 956, 956, 956, 956, 802, 741, 919, 921, 956,
108505 /* 210 */ 902, 739, 662, 760, 675, 750, 642, 796, 775, 775,
108506 /* 220 */ 914, 796, 914, 699, 956, 786, 956, 786, 696, 786,
108507 /* 230 */ 775, 864, 956, 956, 956, 759, 750, 956, 941, 766,
108508 /* 240 */ 766, 933, 933, 766, 808, 731, 796, 738, 738, 738,
108509 /* 250 */ 738, 766, 657, 796, 808, 731, 731, 766, 657, 908,
108510 /* 260 */ 906, 766, 766, 657, 766, 657, 766, 657, 874, 729,
108511 /* 270 */ 729, 729, 714, 878, 878, 874, 729, 699, 729, 714,
108512 /* 280 */ 729, 729, 779, 774, 779, 774, 779, 774, 766, 766,
108513 /* 290 */ 956, 791, 780, 789, 787, 796, 956, 717, 650, 650,
108514 /* 300 */ 639, 639, 639, 639, 953, 953, 948, 701, 701, 683,
108515 /* 310 */ 956, 956, 956, 956, 956, 956, 956, 883, 956, 956,
108516 /* 320 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108517 /* 330 */ 635, 943, 956, 956, 940, 956, 956, 956, 956, 801,
108518 /* 340 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108519 /* 350 */ 918, 956, 956, 956, 956, 956, 956, 956, 912, 956,
108520 /* 360 */ 956, 956, 956, 956, 956, 905, 904, 956, 956, 956,
108521 /* 370 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108522 /* 380 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108523 /* 390 */ 956, 956, 956, 788, 956, 781, 956, 867, 956, 956,
108524 /* 400 */ 956, 956, 956, 956, 956, 956, 956, 956, 744, 817,
108525 /* 410 */ 956, 816, 820, 815, 667, 956, 648, 956, 631, 636,
108526 /* 420 */ 952, 955, 954, 951, 950, 949, 944, 942, 939, 938,
108527 /* 430 */ 937, 935, 932, 928, 887, 885, 892, 891, 890, 889,
108528 /* 440 */ 888, 886, 884, 882, 803, 798, 795, 927, 880, 740,
108529 /* 450 */ 737, 736, 656, 945, 911, 920, 807, 806, 809, 917,
108530 /* 460 */ 916, 915, 913, 910, 897, 805, 804, 732, 872, 871,
108531 /* 470 */ 659, 901, 900, 899, 903, 907, 898, 768, 658, 655,
108532 /* 480 */ 664, 721, 720, 728, 726, 725, 724, 723, 722, 719,
108533 /* 490 */ 666, 674, 685, 713, 698, 697, 877, 879, 876, 875,
108534 /* 500 */ 706, 705, 711, 710, 709, 708, 707, 704, 703, 702,
108535 /* 510 */ 695, 694, 700, 693, 716, 715, 712, 692, 735, 734,
108536 /* 520 */ 733, 730, 691, 690, 689, 820, 688, 687, 826, 825,
108537 /* 530 */ 813, 856, 755, 754, 753, 765, 764, 777, 776, 811,
108538 /* 540 */ 810, 778, 763, 757, 756, 772, 771, 770, 769, 761,
108539 /* 550 */ 751, 783, 785, 784, 782, 858, 767, 855, 926, 925,
108540 /* 560 */ 924, 923, 922, 860, 859, 827, 824, 678, 679, 895,
108541 /* 570 */ 894, 896, 893, 681, 680, 677, 676, 857, 746, 745,
108542 /* 580 */ 853, 850, 842, 838, 854, 851, 843, 839, 837, 836,
108543 /* 590 */ 822, 821, 819, 818, 814, 823, 669, 747, 743, 742,
108544 /* 600 */ 812, 749, 748, 686, 684, 682, 663, 661, 654, 652,
108545 /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
108546 /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
108547 };
108548
108549 /* The next table maps tokens into fallback tokens. If a construct
108550 ** like the following:
108551 **
@@ -108744,11 +108933,11 @@
108744 "create_table", "create_table_args", "createkw", "temp",
108745 "ifnotexists", "dbnm", "columnlist", "conslist_opt",
108746 "select", "column", "columnid", "type",
108747 "carglist", "id", "ids", "typetoken",
108748 "typename", "signed", "plus_num", "minus_num",
108749 "carg", "ccons", "term", "expr",
108750 "onconf", "sortorder", "autoinc", "idxlist_opt",
108751 "refargs", "defer_subclause", "refarg", "refact",
108752 "init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108753 "defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108754 "ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
108824 /* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
108825 /* 49 */ "typename ::= ids",
108826 /* 50 */ "typename ::= typename ids",
108827 /* 51 */ "signed ::= plus_num",
108828 /* 52 */ "signed ::= minus_num",
108829 /* 53 */ "carglist ::= carglist carg",
108830 /* 54 */ "carglist ::=",
108831 /* 55 */ "carg ::= CONSTRAINT nm ccons",
108832 /* 56 */ "carg ::= ccons",
108833 /* 57 */ "ccons ::= DEFAULT term",
108834 /* 58 */ "ccons ::= DEFAULT LP expr RP",
108835 /* 59 */ "ccons ::= DEFAULT PLUS term",
108836 /* 60 */ "ccons ::= DEFAULT MINUS term",
108837 /* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
108861 /* 85 */ "init_deferred_pred_opt ::=",
108862 /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
108863 /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
108864 /* 88 */ "conslist_opt ::=",
108865 /* 89 */ "conslist_opt ::= COMMA conslist",
108866 /* 90 */ "conslist ::= conslist COMMA tcons",
108867 /* 91 */ "conslist ::= conslist tcons",
108868 /* 92 */ "conslist ::= tcons",
108869 /* 93 */ "tcons ::= CONSTRAINT nm",
108870 /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
108871 /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
108872 /* 96 */ "tcons ::= CHECK LP expr RP onconf",
108873 /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
108874 /* 98 */ "defer_subclause_opt ::=",
108875 /* 99 */ "defer_subclause_opt ::= defer_subclause",
108876 /* 100 */ "onconf ::=",
108877 /* 101 */ "onconf ::= ON CONFLICT resolvetype",
108878 /* 102 */ "orconf ::=",
108879 /* 103 */ "orconf ::= OR resolvetype",
108880 /* 104 */ "resolvetype ::= raisetype",
108881 /* 105 */ "resolvetype ::= IGNORE",
108882 /* 106 */ "resolvetype ::= REPLACE",
108883 /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
108884 /* 108 */ "ifexists ::= IF EXISTS",
108885 /* 109 */ "ifexists ::=",
108886 /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
108887 /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
108888 /* 112 */ "cmd ::= select",
108889 /* 113 */ "select ::= oneselect",
108890 /* 114 */ "select ::= select multiselect_op oneselect",
108891 /* 115 */ "multiselect_op ::= UNION",
108892 /* 116 */ "multiselect_op ::= UNION ALL",
108893 /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
108894 /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
108895 /* 119 */ "distinct ::= DISTINCT",
108896 /* 120 */ "distinct ::= ALL",
108897 /* 121 */ "distinct ::=",
108898 /* 122 */ "sclp ::= selcollist COMMA",
108899 /* 123 */ "sclp ::=",
108900 /* 124 */ "selcollist ::= sclp expr as",
108901 /* 125 */ "selcollist ::= sclp STAR",
108902 /* 126 */ "selcollist ::= sclp nm DOT STAR",
108903 /* 127 */ "as ::= AS nm",
108904 /* 128 */ "as ::= ids",
108905 /* 129 */ "as ::=",
108906 /* 130 */ "from ::=",
108907 /* 131 */ "from ::= FROM seltablist",
108908 /* 132 */ "stl_prefix ::= seltablist joinop",
108909 /* 133 */ "stl_prefix ::=",
108910 /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
108911 /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
108912 /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
108913 /* 137 */ "dbnm ::=",
108914 /* 138 */ "dbnm ::= DOT nm",
108915 /* 139 */ "fullname ::= nm dbnm",
108916 /* 140 */ "joinop ::= COMMA|JOIN",
108917 /* 141 */ "joinop ::= JOIN_KW JOIN",
108918 /* 142 */ "joinop ::= JOIN_KW nm JOIN",
108919 /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
108920 /* 144 */ "on_opt ::= ON expr",
108921 /* 145 */ "on_opt ::=",
108922 /* 146 */ "indexed_opt ::=",
108923 /* 147 */ "indexed_opt ::= INDEXED BY nm",
108924 /* 148 */ "indexed_opt ::= NOT INDEXED",
108925 /* 149 */ "using_opt ::= USING LP inscollist RP",
108926 /* 150 */ "using_opt ::=",
108927 /* 151 */ "orderby_opt ::=",
108928 /* 152 */ "orderby_opt ::= ORDER BY sortlist",
108929 /* 153 */ "sortlist ::= sortlist COMMA expr sortorder",
108930 /* 154 */ "sortlist ::= expr sortorder",
108931 /* 155 */ "sortorder ::= ASC",
108932 /* 156 */ "sortorder ::= DESC",
108933 /* 157 */ "sortorder ::=",
108934 /* 158 */ "groupby_opt ::=",
108935 /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
108936 /* 160 */ "having_opt ::=",
108937 /* 161 */ "having_opt ::= HAVING expr",
108938 /* 162 */ "limit_opt ::=",
108939 /* 163 */ "limit_opt ::= LIMIT expr",
108940 /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
108941 /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
108942 /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
108943 /* 167 */ "where_opt ::=",
108944 /* 168 */ "where_opt ::= WHERE expr",
108945 /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
108946 /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
108947 /* 171 */ "setlist ::= nm EQ expr",
108948 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
108949 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
108950 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
108951 /* 175 */ "insert_cmd ::= INSERT orconf",
108952 /* 176 */ "insert_cmd ::= REPLACE",
108953 /* 177 */ "valuelist ::= VALUES LP nexprlist RP",
108954 /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP",
108955 /* 179 */ "inscollist_opt ::=",
108956 /* 180 */ "inscollist_opt ::= LP inscollist RP",
108957 /* 181 */ "inscollist ::= inscollist COMMA nm",
108958 /* 182 */ "inscollist ::= nm",
108959 /* 183 */ "expr ::= term",
108960 /* 184 */ "expr ::= LP expr RP",
108961 /* 185 */ "term ::= NULL",
108962 /* 186 */ "expr ::= id",
108963 /* 187 */ "expr ::= JOIN_KW",
108964 /* 188 */ "expr ::= nm DOT nm",
108965 /* 189 */ "expr ::= nm DOT nm DOT nm",
108966 /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
108967 /* 191 */ "term ::= STRING",
108968 /* 192 */ "expr ::= REGISTER",
108969 /* 193 */ "expr ::= VARIABLE",
108970 /* 194 */ "expr ::= expr COLLATE ids",
108971 /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
108972 /* 196 */ "expr ::= ID LP distinct exprlist RP",
108973 /* 197 */ "expr ::= ID LP STAR RP",
108974 /* 198 */ "term ::= CTIME_KW",
108975 /* 199 */ "expr ::= expr AND expr",
108976 /* 200 */ "expr ::= expr OR expr",
108977 /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
108978 /* 202 */ "expr ::= expr EQ|NE expr",
108979 /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
108980 /* 204 */ "expr ::= expr PLUS|MINUS expr",
108981 /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
108982 /* 206 */ "expr ::= expr CONCAT expr",
108983 /* 207 */ "likeop ::= LIKE_KW",
108984 /* 208 */ "likeop ::= NOT LIKE_KW",
108985 /* 209 */ "likeop ::= MATCH",
108986 /* 210 */ "likeop ::= NOT MATCH",
108987 /* 211 */ "expr ::= expr likeop expr",
108988 /* 212 */ "expr ::= expr likeop expr ESCAPE expr",
108989 /* 213 */ "expr ::= expr ISNULL|NOTNULL",
108990 /* 214 */ "expr ::= expr NOT NULL",
108991 /* 215 */ "expr ::= expr IS expr",
108992 /* 216 */ "expr ::= expr IS NOT expr",
108993 /* 217 */ "expr ::= NOT expr",
108994 /* 218 */ "expr ::= BITNOT expr",
108995 /* 219 */ "expr ::= MINUS expr",
108996 /* 220 */ "expr ::= PLUS expr",
108997 /* 221 */ "between_op ::= BETWEEN",
108998 /* 222 */ "between_op ::= NOT BETWEEN",
108999 /* 223 */ "expr ::= expr between_op expr AND expr",
109000 /* 224 */ "in_op ::= IN",
109001 /* 225 */ "in_op ::= NOT IN",
109002 /* 226 */ "expr ::= expr in_op LP exprlist RP",
109003 /* 227 */ "expr ::= LP select RP",
109004 /* 228 */ "expr ::= expr in_op LP select RP",
109005 /* 229 */ "expr ::= expr in_op nm dbnm",
109006 /* 230 */ "expr ::= EXISTS LP select RP",
109007 /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END",
109008 /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109009 /* 233 */ "case_exprlist ::= WHEN expr THEN expr",
109010 /* 234 */ "case_else ::= ELSE expr",
109011 /* 235 */ "case_else ::=",
109012 /* 236 */ "case_operand ::= expr",
109013 /* 237 */ "case_operand ::=",
109014 /* 238 */ "exprlist ::= nexprlist",
109015 /* 239 */ "exprlist ::=",
109016 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
109017 /* 241 */ "nexprlist ::= expr",
109018 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109019 /* 243 */ "uniqueflag ::= UNIQUE",
109020 /* 244 */ "uniqueflag ::=",
109021 /* 245 */ "idxlist_opt ::=",
109022 /* 246 */ "idxlist_opt ::= LP idxlist RP",
109023 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109024 /* 248 */ "idxlist ::= nm collate sortorder",
109025 /* 249 */ "collate ::=",
109026 /* 250 */ "collate ::= COLLATE ids",
109027 /* 251 */ "cmd ::= DROP INDEX ifexists fullname",
109028 /* 252 */ "cmd ::= VACUUM",
109029 /* 253 */ "cmd ::= VACUUM nm",
109030 /* 254 */ "cmd ::= PRAGMA nm dbnm",
109031 /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109032 /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109033 /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109034 /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109035 /* 259 */ "nmnum ::= plus_num",
109036 /* 260 */ "nmnum ::= nm",
109037 /* 261 */ "nmnum ::= ON",
109038 /* 262 */ "nmnum ::= DELETE",
109039 /* 263 */ "nmnum ::= DEFAULT",
109040 /* 264 */ "plus_num ::= PLUS number",
109041 /* 265 */ "plus_num ::= number",
109042 /* 266 */ "minus_num ::= MINUS number",
109043 /* 267 */ "number ::= INTEGER|FLOAT",
109044 /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109045 /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109046 /* 270 */ "trigger_time ::= BEFORE",
109047 /* 271 */ "trigger_time ::= AFTER",
109048 /* 272 */ "trigger_time ::= INSTEAD OF",
109049 /* 273 */ "trigger_time ::=",
109050 /* 274 */ "trigger_event ::= DELETE|INSERT",
109051 /* 275 */ "trigger_event ::= UPDATE",
109052 /* 276 */ "trigger_event ::= UPDATE OF inscollist",
109053 /* 277 */ "foreach_clause ::=",
109054 /* 278 */ "foreach_clause ::= FOR EACH ROW",
109055 /* 279 */ "when_clause ::=",
109056 /* 280 */ "when_clause ::= WHEN expr",
109057 /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109058 /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109059 /* 283 */ "trnm ::= nm",
109060 /* 284 */ "trnm ::= nm DOT nm",
109061 /* 285 */ "tridxby ::=",
109062 /* 286 */ "tridxby ::= INDEXED BY nm",
109063 /* 287 */ "tridxby ::= NOT INDEXED",
109064 /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109065 /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109066 /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109067 /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109068 /* 292 */ "trigger_cmd ::= select",
109069 /* 293 */ "expr ::= RAISE LP IGNORE RP",
109070 /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109071 /* 295 */ "raisetype ::= ROLLBACK",
109072 /* 296 */ "raisetype ::= ABORT",
109073 /* 297 */ "raisetype ::= FAIL",
109074 /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname",
109075 /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109076 /* 300 */ "cmd ::= DETACH database_kw_opt expr",
109077 /* 301 */ "key_opt ::=",
109078 /* 302 */ "key_opt ::= KEY expr",
109079 /* 303 */ "database_kw_opt ::= DATABASE",
109080 /* 304 */ "database_kw_opt ::=",
109081 /* 305 */ "cmd ::= REINDEX",
109082 /* 306 */ "cmd ::= REINDEX nm dbnm",
109083 /* 307 */ "cmd ::= ANALYZE",
109084 /* 308 */ "cmd ::= ANALYZE nm dbnm",
109085 /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109086 /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109087 /* 311 */ "add_column_fullname ::= fullname",
109088 /* 312 */ "kwcolumn_opt ::=",
109089 /* 313 */ "kwcolumn_opt ::= COLUMNKW",
109090 /* 314 */ "cmd ::= create_vtab",
109091 /* 315 */ "cmd ::= create_vtab LP vtabarglist RP",
109092 /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109093 /* 317 */ "vtabarglist ::= vtabarg",
109094 /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109095 /* 319 */ "vtabarg ::=",
109096 /* 320 */ "vtabarg ::= vtabarg vtabargtoken",
109097 /* 321 */ "vtabargtoken ::= ANY",
109098 /* 322 */ "vtabargtoken ::= lp anylist RP",
109099 /* 323 */ "lp ::= LP",
109100 /* 324 */ "anylist ::=",
109101 /* 325 */ "anylist ::= anylist LP anylist RP",
109102 /* 326 */ "anylist ::= anylist ANY",
109103 };
109104 #endif /* NDEBUG */
109105
109106
109107 #if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109543 { 167, 6 },
109544 { 168, 1 },
109545 { 168, 2 },
109546 { 169, 1 },
109547 { 169, 1 },
109548 { 164, 2 },
109549 { 164, 0 },
109550 { 172, 3 },
109551 { 172, 1 },
109552 { 173, 2 },
109553 { 173, 4 },
109554 { 173, 3 },
109555 { 173, 3 },
109556 { 173, 2 },
@@ -109580,14 +109767,12 @@
109580 { 184, 0 },
109581 { 184, 2 },
109582 { 184, 2 },
109583 { 159, 0 },
109584 { 159, 2 },
109585 { 185, 3 },
109586 { 185, 2 },
109587 { 185, 1 },
109588 { 186, 2 },
109589 { 186, 7 },
109590 { 186, 5 },
109591 { 186, 5 },
109592 { 186, 10 },
109593 { 188, 0 },
@@ -109892,12 +110077,12 @@
109892 {yygotominor.yy392 = TK_DEFERRED;}
109893 break;
109894 case 14: /* transtype ::= DEFERRED */
109895 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
109896 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
109897 case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
109898 case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
109899 {yygotominor.yy392 = yymsp[0].major;}
109900 break;
109901 case 17: /* cmd ::= COMMIT trans_opt */
109902 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
109903 {sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
109935 case 31: /* temp ::= */ yytestcase(yyruleno==31);
109936 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
109937 case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
109938 case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
109939 case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
109940 case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
109941 case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
109942 case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
109943 case 121: /* distinct ::= */ yytestcase(yyruleno==121);
109944 case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221);
109945 case 224: /* in_op ::= IN */ yytestcase(yyruleno==224);
109946 {yygotominor.yy392 = 0;}
109947 break;
109948 case 29: /* ifnotexists ::= IF NOT EXISTS */
109949 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
109950 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
109951 case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
109952 case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
109953 case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
109954 case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222);
109955 case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225);
109956 {yygotominor.yy392 = 1;}
109957 break;
109958 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
109959 {
109960 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
109984 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
109985 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
109986 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
109987 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
109988 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
109989 case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
109990 case 128: /* as ::= ids */ yytestcase(yyruleno==128);
109991 case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
109992 case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
109993 case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250);
109994 case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259);
109995 case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260);
109996 case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261);
109997 case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262);
109998 case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263);
109999 case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264);
110000 case 265: /* plus_num ::= number */ yytestcase(yyruleno==265);
110001 case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
110002 case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
110003 case 283: /* trnm ::= nm */ yytestcase(yyruleno==283);
110004 {yygotominor.yy0 = yymsp[0].minor.yy0;}
110005 break;
110006 case 45: /* type ::= typetoken */
110007 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110008 break;
@@ -110018,10 +110203,16 @@
110018 yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110019 }
110020 break;
110021 case 50: /* typename ::= typename ids */
110022 {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
 
 
 
 
 
 
110023 break;
110024 case 57: /* ccons ::= DEFAULT term */
110025 case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110026 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110027 break;
@@ -110095,80 +110286,80 @@
110095 break;
110096 case 82: /* refact ::= NO ACTION */
110097 { yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110098 break;
110099 case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110100 case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
110101 case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
110102 case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
110103 {yygotominor.yy392 = yymsp[0].minor.yy392;}
110104 break;
110105 case 88: /* conslist_opt ::= */
110106 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110107 break;
110108 case 89: /* conslist_opt ::= COMMA conslist */
110109 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
110110 break;
110111 case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110112 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110113 break;
110114 case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
110115 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110116 break;
110117 case 96: /* tcons ::= CHECK LP expr RP onconf */
110118 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110119 break;
110120 case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110121 {
110122 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110123 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110124 }
110125 break;
110126 case 100: /* onconf ::= */
110127 {yygotominor.yy392 = OE_Default;}
110128 break;
110129 case 102: /* orconf ::= */
110130 {yygotominor.yy258 = OE_Default;}
110131 break;
110132 case 103: /* orconf ::= OR resolvetype */
110133 {yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110134 break;
110135 case 105: /* resolvetype ::= IGNORE */
110136 {yygotominor.yy392 = OE_Ignore;}
110137 break;
110138 case 106: /* resolvetype ::= REPLACE */
110139 {yygotominor.yy392 = OE_Replace;}
110140 break;
110141 case 107: /* cmd ::= DROP TABLE ifexists fullname */
110142 {
110143 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110144 }
110145 break;
110146 case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110147 {
110148 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110149 }
110150 break;
110151 case 111: /* cmd ::= DROP VIEW ifexists fullname */
110152 {
110153 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110154 }
110155 break;
110156 case 112: /* cmd ::= select */
110157 {
110158 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110159 sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110160 sqlite3ExplainBegin(pParse->pVdbe);
110161 sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110162 sqlite3ExplainFinish(pParse->pVdbe);
110163 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110164 }
110165 break;
110166 case 113: /* select ::= oneselect */
110167 {yygotominor.yy159 = yymsp[0].minor.yy159;}
110168 break;
110169 case 114: /* select ::= select multiselect_op oneselect */
110170 {
110171 if( yymsp[0].minor.yy159 ){
110172 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110173 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110174 }else{
@@ -110175,83 +110366,83 @@
110175 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110176 }
110177 yygotominor.yy159 = yymsp[0].minor.yy159;
110178 }
110179 break;
110180 case 116: /* multiselect_op ::= UNION ALL */
110181 {yygotominor.yy392 = TK_ALL;}
110182 break;
110183 case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110184 {
110185 yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110186 }
110187 break;
110188 case 122: /* sclp ::= selcollist COMMA */
110189 case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246);
110190 {yygotominor.yy442 = yymsp[-1].minor.yy442;}
110191 break;
110192 case 123: /* sclp ::= */
110193 case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
110194 case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
110195 case 239: /* exprlist ::= */ yytestcase(yyruleno==239);
110196 case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245);
110197 {yygotominor.yy442 = 0;}
110198 break;
110199 case 124: /* selcollist ::= sclp expr as */
110200 {
110201 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110202 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110203 sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110204 }
110205 break;
110206 case 125: /* selcollist ::= sclp STAR */
110207 {
110208 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110209 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110210 }
110211 break;
110212 case 126: /* selcollist ::= sclp nm DOT STAR */
110213 {
110214 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110215 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110216 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110217 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110218 }
110219 break;
110220 case 129: /* as ::= */
110221 {yygotominor.yy0.n = 0;}
110222 break;
110223 case 130: /* from ::= */
110224 {yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110225 break;
110226 case 131: /* from ::= FROM seltablist */
110227 {
110228 yygotominor.yy347 = yymsp[0].minor.yy347;
110229 sqlite3SrcListShiftJoinType(yygotominor.yy347);
110230 }
110231 break;
110232 case 132: /* stl_prefix ::= seltablist joinop */
110233 {
110234 yygotominor.yy347 = yymsp[-1].minor.yy347;
110235 if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110236 }
110237 break;
110238 case 133: /* stl_prefix ::= */
110239 {yygotominor.yy347 = 0;}
110240 break;
110241 case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110242 {
110243 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110244 sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110245 }
110246 break;
110247 case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110248 {
110249 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110250 }
110251 break;
110252 case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110253 {
110254 if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110255 yygotominor.yy347 = yymsp[-4].minor.yy347;
110256 }else{
110257 Select *pSubquery;
@@ -110259,137 +110450,137 @@
110259 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110260 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110261 }
110262 }
110263 break;
110264 case 137: /* dbnm ::= */
110265 case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
110266 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110267 break;
110268 case 139: /* fullname ::= nm dbnm */
110269 {yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110270 break;
110271 case 140: /* joinop ::= COMMA|JOIN */
110272 { yygotominor.yy392 = JT_INNER; }
110273 break;
110274 case 141: /* joinop ::= JOIN_KW JOIN */
110275 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110276 break;
110277 case 142: /* joinop ::= JOIN_KW nm JOIN */
110278 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110279 break;
110280 case 143: /* joinop ::= JOIN_KW nm nm JOIN */
110281 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110282 break;
110283 case 144: /* on_opt ::= ON expr */
110284 case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
110285 case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
110286 case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234);
110287 case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236);
110288 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110289 break;
110290 case 145: /* on_opt ::= */
110291 case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
110292 case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
110293 case 235: /* case_else ::= */ yytestcase(yyruleno==235);
110294 case 237: /* case_operand ::= */ yytestcase(yyruleno==237);
110295 {yygotominor.yy122 = 0;}
110296 break;
110297 case 148: /* indexed_opt ::= NOT INDEXED */
110298 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110299 break;
110300 case 149: /* using_opt ::= USING LP inscollist RP */
110301 case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
110302 {yygotominor.yy180 = yymsp[-1].minor.yy180;}
110303 break;
110304 case 150: /* using_opt ::= */
110305 case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
110306 {yygotominor.yy180 = 0;}
110307 break;
110308 case 152: /* orderby_opt ::= ORDER BY sortlist */
110309 case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
110310 case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238);
110311 {yygotominor.yy442 = yymsp[0].minor.yy442;}
110312 break;
110313 case 153: /* sortlist ::= sortlist COMMA expr sortorder */
110314 {
110315 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110316 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110317 }
110318 break;
110319 case 154: /* sortlist ::= expr sortorder */
110320 {
110321 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110322 if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110323 }
110324 break;
110325 case 155: /* sortorder ::= ASC */
110326 case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
110327 {yygotominor.yy392 = SQLITE_SO_ASC;}
110328 break;
110329 case 156: /* sortorder ::= DESC */
110330 {yygotominor.yy392 = SQLITE_SO_DESC;}
110331 break;
110332 case 162: /* limit_opt ::= */
110333 {yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110334 break;
110335 case 163: /* limit_opt ::= LIMIT expr */
110336 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110337 break;
110338 case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
110339 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110340 break;
110341 case 165: /* limit_opt ::= LIMIT expr COMMA expr */
110342 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110343 break;
110344 case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110345 {
110346 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110347 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110348 }
110349 break;
110350 case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110351 {
110352 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110353 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110354 sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110355 }
110356 break;
110357 case 170: /* setlist ::= setlist COMMA nm EQ expr */
110358 {
110359 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110360 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110361 }
110362 break;
110363 case 171: /* setlist ::= nm EQ expr */
110364 {
110365 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110366 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110367 }
110368 break;
110369 case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110370 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110371 break;
110372 case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110373 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110374 break;
110375 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110376 {sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110377 break;
110378 case 175: /* insert_cmd ::= INSERT orconf */
110379 {yygotominor.yy258 = yymsp[0].minor.yy258;}
110380 break;
110381 case 176: /* insert_cmd ::= REPLACE */
110382 {yygotominor.yy258 = OE_Replace;}
110383 break;
110384 case 177: /* valuelist ::= VALUES LP nexprlist RP */
110385 {
110386 yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110387 yygotominor.yy487.pSelect = 0;
110388 }
110389 break;
110390 case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */
110391 {
110392 Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110393 if( yymsp[-4].minor.yy487.pList ){
110394 yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110395 yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110406 pRight->pPrior->selFlags |= SF_Values;
110407 yygotominor.yy487.pSelect = pRight;
110408 }
110409 }
110410 break;
110411 case 181: /* inscollist ::= inscollist COMMA nm */
110412 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110413 break;
110414 case 182: /* inscollist ::= nm */
110415 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110416 break;
110417 case 183: /* expr ::= term */
110418 {yygotominor.yy342 = yymsp[0].minor.yy342;}
110419 break;
110420 case 184: /* expr ::= LP expr RP */
110421 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110422 break;
110423 case 185: /* term ::= NULL */
110424 case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
110425 case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
110426 {spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110427 break;
110428 case 186: /* expr ::= id */
110429 case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
110430 {spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110431 break;
110432 case 188: /* expr ::= nm DOT nm */
110433 {
110434 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110435 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110436 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110437 spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110438 }
110439 break;
110440 case 189: /* expr ::= nm DOT nm DOT nm */
110441 {
110442 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110443 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110444 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110445 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110446 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110447 spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110448 }
110449 break;
110450 case 192: /* expr ::= REGISTER */
110451 {
110452 /* When doing a nested parse, one can include terms in an expression
110453 ** that look like this: #1 #2 ... These terms refer to registers
110454 ** in the virtual machine. #N is the N-th register. */
110455 if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110460 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110461 }
110462 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110463 }
110464 break;
110465 case 193: /* expr ::= VARIABLE */
110466 {
110467 spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110468 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110469 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110470 }
110471 break;
110472 case 194: /* expr ::= expr COLLATE ids */
110473 {
110474 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110475 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110476 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110477 }
110478 break;
110479 case 195: /* expr ::= CAST LP expr AS typetoken RP */
110480 {
110481 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110482 spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110483 }
110484 break;
110485 case 196: /* expr ::= ID LP distinct exprlist RP */
110486 {
110487 if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110488 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110489 }
110490 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110492 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110493 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110494 }
110495 }
110496 break;
110497 case 197: /* expr ::= ID LP STAR RP */
110498 {
110499 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110500 spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110501 }
110502 break;
110503 case 198: /* term ::= CTIME_KW */
110504 {
110505 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110506 ** treated as functions that return constants */
110507 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110508 if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110509 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110510 }
110511 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110512 }
110513 break;
110514 case 199: /* expr ::= expr AND expr */
110515 case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
110516 case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
110517 case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
110518 case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
110519 case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
110520 case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
110521 case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
110522 {spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110523 break;
110524 case 207: /* likeop ::= LIKE_KW */
110525 case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
110526 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 0;}
110527 break;
110528 case 208: /* likeop ::= NOT LIKE_KW */
110529 case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
110530 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 1;}
110531 break;
110532 case 211: /* expr ::= expr likeop expr */
110533 {
110534 ExprList *pList;
110535 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110536 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110537 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110538 if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110539 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110540 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110541 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110542 }
110543 break;
110544 case 212: /* expr ::= expr likeop expr ESCAPE expr */
110545 {
110546 ExprList *pList;
110547 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110548 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110549 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110550 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110551 if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110552 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110553 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110554 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110555 }
110556 break;
110557 case 213: /* expr ::= expr ISNULL|NOTNULL */
110558 {spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110559 break;
110560 case 214: /* expr ::= expr NOT NULL */
110561 {spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110562 break;
110563 case 215: /* expr ::= expr IS expr */
110564 {
110565 spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110566 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110567 }
110568 break;
110569 case 216: /* expr ::= expr IS NOT expr */
110570 {
110571 spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110572 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110573 }
110574 break;
110575 case 217: /* expr ::= NOT expr */
110576 case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218);
110577 {spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110578 break;
110579 case 219: /* expr ::= MINUS expr */
110580 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110581 break;
110582 case 220: /* expr ::= PLUS expr */
110583 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110584 break;
110585 case 223: /* expr ::= expr between_op expr AND expr */
110586 {
110587 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110588 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110589 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110590 if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110595 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110596 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110597 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110598 }
110599 break;
110600 case 226: /* expr ::= expr in_op LP exprlist RP */
110601 {
110602 if( yymsp[-1].minor.yy442==0 ){
110603 /* Expressions of the form
110604 **
110605 ** expr1 IN ()
@@ -110622,11 +110813,11 @@
110622 }
110623 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110624 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110625 }
110626 break;
110627 case 227: /* expr ::= LP select RP */
110628 {
110629 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110630 if( yygotominor.yy342.pExpr ){
110631 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110632 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110636 }
110637 yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110638 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110639 }
110640 break;
110641 case 228: /* expr ::= expr in_op LP select RP */
110642 {
110643 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110644 if( yygotominor.yy342.pExpr ){
110645 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110646 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110651 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110652 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110653 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110654 }
110655 break;
110656 case 229: /* expr ::= expr in_op nm dbnm */
110657 {
110658 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110659 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110660 if( yygotominor.yy342.pExpr ){
110661 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110667 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110668 yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110669 yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110670 }
110671 break;
110672 case 230: /* expr ::= EXISTS LP select RP */
110673 {
110674 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110675 if( p ){
110676 p->x.pSelect = yymsp[-1].minor.yy159;
110677 ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110681 }
110682 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110683 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110684 }
110685 break;
110686 case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
110687 {
110688 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110689 if( yygotominor.yy342.pExpr ){
110690 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110691 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110694 }
110695 yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110696 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110697 }
110698 break;
110699 case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110700 {
110701 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110702 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110703 }
110704 break;
110705 case 233: /* case_exprlist ::= WHEN expr THEN expr */
110706 {
110707 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110708 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110709 }
110710 break;
110711 case 240: /* nexprlist ::= nexprlist COMMA expr */
110712 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110713 break;
110714 case 241: /* nexprlist ::= expr */
110715 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110716 break;
110717 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110718 {
110719 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110720 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110721 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110722 }
110723 break;
110724 case 243: /* uniqueflag ::= UNIQUE */
110725 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
110726 {yygotominor.yy392 = OE_Abort;}
110727 break;
110728 case 244: /* uniqueflag ::= */
110729 {yygotominor.yy392 = OE_None;}
110730 break;
110731 case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */
110732 {
110733 Expr *p = 0;
110734 if( yymsp[-1].minor.yy0.n>0 ){
110735 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110736 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110739 sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110740 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110741 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110742 }
110743 break;
110744 case 248: /* idxlist ::= nm collate sortorder */
110745 {
110746 Expr *p = 0;
110747 if( yymsp[-1].minor.yy0.n>0 ){
110748 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110749 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110752 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110753 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110754 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110755 }
110756 break;
110757 case 249: /* collate ::= */
110758 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110759 break;
110760 case 251: /* cmd ::= DROP INDEX ifexists fullname */
110761 {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110762 break;
110763 case 252: /* cmd ::= VACUUM */
110764 case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253);
110765 {sqlite3Vacuum(pParse);}
110766 break;
110767 case 254: /* cmd ::= PRAGMA nm dbnm */
110768 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110769 break;
110770 case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110771 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110772 break;
110773 case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110774 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110775 break;
110776 case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110777 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110778 break;
110779 case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110780 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110781 break;
110782 case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110783 {
110784 Token all;
110785 all.z = yymsp[-3].minor.yy0.z;
110786 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110787 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110788 }
110789 break;
110790 case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110791 {
110792 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110793 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110794 }
110795 break;
110796 case 270: /* trigger_time ::= BEFORE */
110797 case 273: /* trigger_time ::= */ yytestcase(yyruleno==273);
110798 { yygotominor.yy392 = TK_BEFORE; }
110799 break;
110800 case 271: /* trigger_time ::= AFTER */
110801 { yygotominor.yy392 = TK_AFTER; }
110802 break;
110803 case 272: /* trigger_time ::= INSTEAD OF */
110804 { yygotominor.yy392 = TK_INSTEAD;}
110805 break;
110806 case 274: /* trigger_event ::= DELETE|INSERT */
110807 case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275);
110808 {yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
110809 break;
110810 case 276: /* trigger_event ::= UPDATE OF inscollist */
110811 {yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
110812 break;
110813 case 279: /* when_clause ::= */
110814 case 301: /* key_opt ::= */ yytestcase(yyruleno==301);
110815 { yygotominor.yy122 = 0; }
110816 break;
110817 case 280: /* when_clause ::= WHEN expr */
110818 case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302);
110819 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110820 break;
110821 case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
110822 {
110823 assert( yymsp[-2].minor.yy327!=0 );
110824 yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
110825 yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
110826 yygotominor.yy327 = yymsp[-2].minor.yy327;
110827 }
110828 break;
110829 case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
110830 {
110831 assert( yymsp[-1].minor.yy327!=0 );
110832 yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
110833 yygotominor.yy327 = yymsp[-1].minor.yy327;
110834 }
110835 break;
110836 case 284: /* trnm ::= nm DOT nm */
110837 {
110838 yygotominor.yy0 = yymsp[0].minor.yy0;
110839 sqlite3ErrorMsg(pParse,
110840 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110841 "statements within triggers");
110842 }
110843 break;
110844 case 286: /* tridxby ::= INDEXED BY nm */
110845 {
110846 sqlite3ErrorMsg(pParse,
110847 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
110848 "within triggers");
110849 }
110850 break;
110851 case 287: /* tridxby ::= NOT INDEXED */
110852 {
110853 sqlite3ErrorMsg(pParse,
110854 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
110855 "within triggers");
110856 }
110857 break;
110858 case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
110859 { yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
110860 break;
110861 case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
110862 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
110863 break;
110864 case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
110865 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
110866 break;
110867 case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
110868 {yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
110869 break;
110870 case 292: /* trigger_cmd ::= select */
110871 {yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
110872 break;
110873 case 293: /* expr ::= RAISE LP IGNORE RP */
110874 {
110875 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110876 if( yygotominor.yy342.pExpr ){
110877 yygotominor.yy342.pExpr->affinity = OE_Ignore;
110878 }
110879 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110880 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110881 }
110882 break;
110883 case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */
110884 {
110885 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110886 if( yygotominor.yy342.pExpr ) {
110887 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110888 }
110889 yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
110890 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110891 }
110892 break;
110893 case 295: /* raisetype ::= ROLLBACK */
110894 {yygotominor.yy392 = OE_Rollback;}
110895 break;
110896 case 297: /* raisetype ::= FAIL */
110897 {yygotominor.yy392 = OE_Fail;}
110898 break;
110899 case 298: /* cmd ::= DROP TRIGGER ifexists fullname */
110900 {
110901 sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
110902 }
110903 break;
110904 case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
110905 {
110906 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110907 }
110908 break;
110909 case 300: /* cmd ::= DETACH database_kw_opt expr */
110910 {
110911 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
110912 }
110913 break;
110914 case 305: /* cmd ::= REINDEX */
110915 {sqlite3Reindex(pParse, 0, 0);}
110916 break;
110917 case 306: /* cmd ::= REINDEX nm dbnm */
110918 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110919 break;
110920 case 307: /* cmd ::= ANALYZE */
110921 {sqlite3Analyze(pParse, 0, 0);}
110922 break;
110923 case 308: /* cmd ::= ANALYZE nm dbnm */
110924 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110925 break;
110926 case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110927 {
110928 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
110929 }
110930 break;
110931 case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110932 {
110933 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
110934 }
110935 break;
110936 case 311: /* add_column_fullname ::= fullname */
110937 {
110938 pParse->db->lookaside.bEnabled = 0;
110939 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
110940 }
110941 break;
110942 case 314: /* cmd ::= create_vtab */
110943 {sqlite3VtabFinishParse(pParse,0);}
110944 break;
110945 case 315: /* cmd ::= create_vtab LP vtabarglist RP */
110946 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
110947 break;
110948 case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
110949 {
110950 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
110951 }
110952 break;
110953 case 319: /* vtabarg ::= */
110954 {sqlite3VtabArgInit(pParse);}
110955 break;
110956 case 321: /* vtabargtoken ::= ANY */
110957 case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322);
110958 case 323: /* lp ::= LP */ yytestcase(yyruleno==323);
110959 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
110960 break;
110961 default:
110962 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
110963 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
110973 /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
110974 /* (35) columnlist ::= column */ yytestcase(yyruleno==35);
110975 /* (44) type ::= */ yytestcase(yyruleno==44);
110976 /* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
110977 /* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
110978 /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
110979 /* (54) carglist ::= */ yytestcase(yyruleno==54);
110980 /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
110981 /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
110982 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
110983 /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
110984 /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
110985 /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
110986 /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
110987 /* (277) foreach_clause ::= */ yytestcase(yyruleno==277);
110988 /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278);
110989 /* (285) tridxby ::= */ yytestcase(yyruleno==285);
110990 /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
110991 /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304);
110992 /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312);
110993 /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313);
110994 /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317);
110995 /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318);
110996 /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320);
110997 /* (324) anylist ::= */ yytestcase(yyruleno==324);
110998 /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110999 /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
111000 break;
111001 };
111002 yygoto = yyRuleInfo[yyruleno].lhs;
111003 yysize = yyRuleInfo[yyruleno].nrhs;
111004 yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
115889 ** option. But that functionality is no longer supported.
115890 **
115891 ** A doclist is stored like this:
115892 **
115893 ** array {
115894 ** varint docid;
115895 ** array { (position list for column 0)
115896 ** varint position; (2 more than the delta from previous position)
115897 ** }
115898 ** array {
115899 ** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
115920 ** The 123 value is the first docid. For column zero in this document
115921 ** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
115922 ** at D signals the start of a new column; the 1 at E indicates that the
115923 ** new column is column number 1. There are two positions at 12 and 45
115924 ** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
115925 ** 234 at I is the next docid. It has one position 72 (72-2) and then
115926 ** terminates with the 0 at K.
115927 **
115928 ** A "position-list" is the list of positions for multiple columns for
115929 ** a single docid. A "column-list" is the set of positions for a single
115930 ** column. Hence, a position-list consists of one or more column-lists,
115931 ** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116456
116457
116458 #ifndef MIN
116459 # define MIN(x,y) ((x)<(y)?(x):(y))
116460 #endif
 
 
 
116461
116462 /*
116463 ** Maximum length of a varint encoded integer. The varint format is different
116464 ** from that used by SQLite, so the maximum length is 10, not 9.
116465 */
@@ -116510,20 +116700,21 @@
116510 #ifdef SQLITE_COVERAGE_TEST
116511 # define ALWAYS(x) (1)
116512 # define NEVER(X) (0)
116513 #else
116514 # define ALWAYS(x) (x)
116515 # define NEVER(X) (x)
116516 #endif
116517
116518 /*
116519 ** Internal types used by SQLite.
116520 */
116521 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116522 typedef short int i16; /* 2-byte (or larger) signed integer */
116523 typedef unsigned int u32; /* 4-byte unsigned integer */
116524 typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
 
116525
116526 /*
116527 ** Macro used to suppress compiler warnings for unused parameters.
116528 */
116529 #define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116582 int nColumn; /* number of named columns in virtual table */
116583 char **azColumn; /* column names. malloced */
116584 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116585 char *zContentTbl; /* content=xxx option, or NULL */
116586 char *zLanguageid; /* languageid=xxx option, or NULL */
 
 
116587
116588 /* Precompiled statements used by the implementation. Each of these
116589 ** statements is run and reset within a single virtual table API call.
116590 */
116591 sqlite3_stmt *aStmt[28];
116592
116593 char *zReadExprlist;
116594 char *zWriteExprlist;
116595
116596 int nNodeSize; /* Soft limit for node size */
 
116597 u8 bHasStat; /* True if %_stat table exists */
116598 u8 bHasDocsize; /* True if %_docsize table exists */
116599 u8 bDescIdx; /* True if doclists are in reverse order */
 
116600 int nPgsz; /* Page size for host database */
116601 char *zSegmentsTbl; /* Name of %_segments table */
116602 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116603
116604 /* TODO: Fix the first paragraph of this comment.
116605 **
116606 ** The following array of hash tables is used to buffer pending index
116607 ** updates during transactions. Variable nPendingData estimates the memory
116608 ** size of the pending data, including hash table overhead, not including
116609 ** malloc overhead. When nPendingData exceeds nMaxPendingData, the buffer
116610 ** is flushed automatically. Variable iPrevDocid is the docid of the most
116611 ** recently inserted record.
116612 **
116613 ** A single FTS4 table may have multiple full-text indexes. For each index
116614 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116615 ** terms that appear in the document set. Each subsequent index in aIndex[]
116616 ** is an index of prefixes of a specific length.
 
 
 
 
 
 
116617 */
116618 int nIndex; /* Size of aIndex[] */
116619 struct Fts3Index {
116620 int nPrefix; /* Prefix length (0 for main terms index) */
116621 Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
116810 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
116811 SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
116812 SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
116813 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
116814 SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
 
116815
116816 /* Special values interpreted by sqlite3SegReaderCursor() */
116817 #define FTS3_SEGCURSOR_PENDING -1
116818 #define FTS3_SEGCURSOR_ALL -2
116819
@@ -116861,19 +117060,22 @@
116861 int nTerm; /* Size of zTerm in bytes */
116862 char *aDoclist; /* Pointer to doclist buffer */
116863 int nDoclist; /* Size of aDoclist[] in bytes */
116864 };
116865
 
 
116866 /* fts3.c */
116867 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
116868 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
116869 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
116870 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
116871 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
116872 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
116873 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
116874 SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
 
116875
116876 /* fts3_tokenizer.c */
116877 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
116878 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
116879 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117198 sqlite3_free(zSql);
117199 sqlite3_free(zCols);
117200 *pRc = rc;
117201 }
117202 }
 
 
 
 
 
 
 
 
 
 
 
 
117203
117204 /*
117205 ** Create the backing store tables (%_content, %_segments and %_segdir)
117206 ** required by the FTS3 table passed as the only argument. This is done
117207 ** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117259 fts3DbExec(&rc, db,
117260 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117261 p->zDb, p->zName
117262 );
117263 }
 
117264 if( p->bHasStat ){
117265 fts3DbExec(&rc, db,
117266 "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117267 p->zDb, p->zName
117268 );
117269 }
117270 return rc;
117271 }
117272
117273 /*
@@ -117370,11 +117582,11 @@
117370 ** memory.
117371 */
117372 static char *fts3QuoteId(char const *zInput){
117373 int nRet;
117374 char *zRet;
117375 nRet = 2 + strlen(zInput)*2 + 1;
117376 zRet = sqlite3_malloc(nRet);
117377 if( zRet ){
117378 int i;
117379 char *z = zRet;
117380 *(z++) = '"';
@@ -117626,11 +117838,11 @@
117626 ** space required to store a copy of each column name, including the
117627 ** nul-terminator byte. */
117628 nCol = sqlite3_column_count(pStmt);
117629 for(i=0; i<nCol; i++){
117630 const char *zCol = sqlite3_column_name(pStmt, i);
117631 nStr += strlen(zCol) + 1;
117632 }
117633
117634 /* Allocate and populate the array to return. */
117635 azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117636 if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117637 rc = SQLITE_NOMEM;
117638 }else{
117639 char *p = (char *)&azCol[nCol];
117640 for(i=0; i<nCol; i++){
117641 const char *zCol = sqlite3_column_name(pStmt, i);
117642 int n = strlen(zCol)+1;
117643 memcpy(p, zCol, n);
117644 azCol[i] = p;
117645 p += n;
117646 }
117647 }
@@ -117852,11 +118064,12 @@
117852 ** column from the aCol[] array. */
117853 if( rc==SQLITE_OK && zLanguageid ){
117854 int j;
117855 for(j=0; j<nCol; j++){
117856 if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
117857 memmove(&aCol[j], &aCol[j+1], (nCol-j) * sizeof(aCol[0]));
 
117858 nCol--;
117859 break;
117860 }
117861 }
117862 }
@@ -117903,11 +118116,13 @@
117903 p->azColumn = (char **)&p[1];
117904 p->pTokenizer = pTokenizer;
117905 p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
117906 p->bHasDocsize = (isFts4 && bNoDocsize==0);
117907 p->bHasStat = isFts4;
 
117908 p->bDescIdx = bDescIdx;
 
117909 p->zContentTbl = zContent;
117910 p->zLanguageid = zLanguageid;
117911 zContent = 0;
117912 zLanguageid = 0;
117913 TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
117955 ** database. TODO: For xConnect(), it could verify that said tables exist.
117956 */
117957 if( isCreate ){
117958 rc = fts3CreateTables(p);
117959 }
 
 
 
 
 
 
 
 
 
 
117960
117961 /* Figure out the page-size for the database. This is required in order to
117962 ** estimate the cost of loading large doclists from the database. */
117963 fts3DatabasePageSize(&rc, p);
117964 p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
118959 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
118960 }
118961 }
118962
118963 *paOut = aOut;
118964 *pnOut = (p-aOut);
118965 assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
118966 return SQLITE_OK;
118967 }
118968
118969 /*
@@ -119023,11 +119248,11 @@
119023 fts3PoslistCopy(0, &p2);
119024 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119025 }
119026 }
119027
119028 *pnRight = p - aOut;
119029 }
119030
119031 /*
119032 ** Argument pList points to a position list nList bytes in size. This
119033 ** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119299 ** Set up a cursor object for iterating through a full-text index or a
119300 ** single level therein.
119301 */
119302 SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119303 Fts3Table *p, /* FTS3 table handle */
119304 int iLangid,
119305 int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119306 int iLevel, /* Level of segments to scan */
119307 const char *zTerm, /* Term to query for */
119308 int nTerm, /* Size of zTerm in bytes */
119309 int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119317 );
119318 assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119319 assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119320 assert( isPrefix==0 || isScan==0 );
119321
119322 /* "isScan" is only set to true by the ft4aux module, an ordinary
119323 ** full-text tables. */
119324 assert( isScan==0 || p->aIndex==0 );
119325
119326 memset(pCsr, 0, sizeof(Fts3MultiSegReader));
119327
119328 return fts3SegReaderCursor(
119329 p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119330 );
119331 }
119332
@@ -119587,11 +119807,11 @@
119587
119588 pCsr->iLangid = 0;
119589 if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119590
119591 rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119592 p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119593 );
119594 if( rc!=SQLITE_OK ){
119595 if( rc==SQLITE_ERROR ){
119596 static const char *zErr = "malformed MATCH expression: [%s]";
119597 p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119730 /*
119731 ** Implementation of xSync() method. Flush the contents of the pending-terms
119732 ** hash-table to the database.
119733 */
119734 static int fts3SyncMethod(sqlite3_vtab *pVtab){
119735 int rc = sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab);
119736 sqlite3Fts3SegmentsClose((Fts3Table *)pVtab);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119737 return rc;
119738 }
119739
119740 /*
119741 ** Implementation of xBegin() method. This is a no-op.
119742 */
119743 static int fts3BeginMethod(sqlite3_vtab *pVtab){
119744 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
119745 UNUSED_PARAMETER(pVtab);
119746 assert( p->pSegments==0 );
119747 assert( p->nPendingData==0 );
119748 assert( p->inTransaction!=1 );
119749 TESTONLY( p->inTransaction = 1 );
119750 TESTONLY( p->mxSavepoint = -1; );
 
119751 return SQLITE_OK;
119752 }
119753
119754 /*
119755 ** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120040 ** The xSavepoint() method.
120041 **
120042 ** Flush the contents of the pending-terms table to disk.
120043 */
120044 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
 
120045 UNUSED_PARAMETER(iSavepoint);
120046 assert( ((Fts3Table *)pVtab)->inTransaction );
120047 assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120048 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120049 return fts3SyncMethod(pVtab);
 
 
 
120050 }
120051
120052 /*
120053 ** The xRelease() method.
120054 **
@@ -120404,11 +120663,11 @@
120404
120405 assert( iPrev>=0 );
120406 fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120407 sqlite3_free(aPoslist);
120408 aPoslist = pList;
120409 nPoslist = aOut - aPoslist;
120410 if( nPoslist==0 ){
120411 sqlite3_free(aPoslist);
120412 pPhrase->doclist.pList = 0;
120413 pPhrase->doclist.nList = 0;
120414 return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120448 }
120449
120450 pPhrase->doclist.pList = aOut;
120451 if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120452 pPhrase->doclist.bFreeList = 1;
120453 pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList);
120454 }else{
120455 sqlite3_free(aOut);
120456 pPhrase->doclist.pList = 0;
120457 pPhrase->doclist.nList = 0;
120458 }
@@ -120544,11 +120803,11 @@
120544 fts3PoslistCopy(0, &pDocid);
120545 while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120546 iMul = (bDescIdx ? -1 : 1);
120547 }
120548
120549 *pnList = pEnd - pNext;
120550 *ppIter = pNext;
120551 *piDocid = iDocid;
120552 }else{
120553 int iMul = (bDescIdx ? -1 : 1);
120554 sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120558 if( p==aDoclist ){
120559 *pbEof = 1;
120560 }else{
120561 char *pSave = p;
120562 fts3ReversePoslist(aDoclist, &p);
120563 *pnList = (pSave - p);
120564 }
120565 *ppIter = p;
120566 }
120567 }
120568
@@ -120618,11 +120877,11 @@
120618 }else{
120619 pDL->iDocid -= iDelta;
120620 }
120621 pDL->pList = pIter;
120622 fts3PoslistCopy(0, &pIter);
120623 pDL->nList = (pIter - pDL->pList);
120624
120625 /* pIter now points just past the 0x00 that terminates the position-
120626 ** list for document pDL->iDocid. However, if this position-list was
120627 ** edited in place by fts3EvalNearTrim(), then pIter may not actually
120628 ** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
120959
120960 /* Allocate a MultiSegReader for each token in the expression. */
120961 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
120962
120963 /* Determine which, if any, tokens in the expression should be deferred. */
120964 if( rc==SQLITE_OK && nToken>1 && pTab->bHasStat ){
120965 Fts3TokenAndCost *aTC;
120966 Fts3Expr **apOr;
120967 aTC = (Fts3TokenAndCost *)sqlite3_malloc(
120968 sizeof(Fts3TokenAndCost) * nToken
120969 + sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
120976 int ii;
120977 Fts3TokenAndCost *pTC = aTC;
120978 Fts3Expr **ppOr = apOr;
120979
120980 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
120981 nToken = pTC-aTC;
120982 nOr = ppOr-apOr;
120983
120984 if( rc==SQLITE_OK ){
120985 rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
120986 for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
120987 rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121049 p2 = pOut = pPhrase->doclist.pList;
121050 res = fts3PoslistNearMerge(
121051 &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121052 );
121053 if( res ){
121054 nNew = (pOut - pPhrase->doclist.pList) - 1;
121055 assert( pPhrase->doclist.pList[nNew]=='\0' );
121056 assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121057 memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121058 pPhrase->doclist.nList = nNew;
121059 *paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
121774 fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
121775 pPhrase->aToken[i].pSegcsr = 0;
121776 }
121777 }
121778 }
 
121779
121780 /*
121781 ** Return SQLITE_CORRUPT_VTAB.
121782 */
121783 #ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
121882 );
121883 return SQLITE_ERROR;
121884 }
121885
121886 zDb = argv[1];
121887 nDb = strlen(zDb);
121888 zFts3 = argv[3];
121889 nFts3 = strlen(zFts3);
121890
121891 rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
121892 if( rc!=SQLITE_OK ) return rc;
121893
121894 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125074
125075 /* #include <string.h> */
125076 /* #include <assert.h> */
125077 /* #include <stdlib.h> */
125078
 
 
 
125079 /*
125080 ** When full-text index nodes are loaded from disk, the buffer that they
125081 ** are loaded into has the following number of bytes of padding at the end
125082 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125083 ** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125112 # define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125113 #else
125114 # define FTS3_NODE_CHUNKSIZE (4*1024)
125115 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125116 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125117
125118 typedef struct PendingList PendingList;
125119 typedef struct SegmentNode SegmentNode;
125120 typedef struct SegmentWriter SegmentWriter;
125121
@@ -125274,19 +125560,26 @@
125274 #define SQL_DELETE_SEGMENTS_RANGE 17
125275 #define SQL_CONTENT_INSERT 18
125276 #define SQL_DELETE_DOCSIZE 19
125277 #define SQL_REPLACE_DOCSIZE 20
125278 #define SQL_SELECT_DOCSIZE 21
125279 #define SQL_SELECT_DOCTOTAL 22
125280 #define SQL_REPLACE_DOCTOTAL 23
125281
125282 #define SQL_SELECT_ALL_PREFIX_LEVEL 24
125283 #define SQL_DELETE_ALL_TERMS_SEGDIR 25
125284
125285 #define SQL_DELETE_SEGDIR_RANGE 26
125286
125287 #define SQL_SELECT_ALL_LANGID 27
 
 
 
 
 
 
 
 
 
125288
125289 /*
125290 ** This function is used to obtain an SQLite prepared statement handle
125291 ** for the statement identified by the second argument. If successful,
125292 ** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125311 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
125312 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
125313 /* 6 */ "DELETE FROM %Q.'%q_stat'",
125314 /* 7 */ "SELECT %s WHERE rowid=?",
125315 /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125316 /* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125317 /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125318 /* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125319
125320 /* Return segments in order from oldest to newest.*/
125321 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125322 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125323 /* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125331 /* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125332 /* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125333 /* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125334 /* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125335 /* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125336 /* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=0",
125337 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(0,?)",
125338 /* 24 */ "",
125339 /* 25 */ "",
125340
125341 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125342 /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125344 };
125345 int rc = SQLITE_OK;
125346 sqlite3_stmt *pStmt;
125347
125348 assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125375 }
125376 }
125377 *pp = pStmt;
125378 return rc;
125379 }
 
125380
125381 static int fts3SelectDocsize(
125382 Fts3Table *pTab, /* FTS3 table handle */
125383 int eStmt, /* Either SQL_SELECT_DOCSIZE or DOCTOTAL */
125384 sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125385 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125386 ){
125387 sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125388 int rc; /* Return code */
125389
125390 assert( eStmt==SQL_SELECT_DOCSIZE || eStmt==SQL_SELECT_DOCTOTAL );
125391
125392 rc = fts3SqlStmt(pTab, eStmt, &pStmt, 0);
125393 if( rc==SQLITE_OK ){
125394 if( eStmt==SQL_SELECT_DOCSIZE ){
125395 sqlite3_bind_int64(pStmt, 1, iDocid);
125396 }
125397 rc = sqlite3_step(pStmt);
125398 if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125399 rc = sqlite3_reset(pStmt);
125400 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125401 pStmt = 0;
@@ -125410,19 +125746,33 @@
125410
125411 SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125412 Fts3Table *pTab, /* Fts3 table handle */
125413 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125414 ){
125415 return fts3SelectDocsize(pTab, SQL_SELECT_DOCTOTAL, 0, ppStmt);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125416 }
125417
125418 SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125419 Fts3Table *pTab, /* Fts3 table handle */
125420 sqlite3_int64 iDocid, /* Docid to read size data for */
125421 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125422 ){
125423 return fts3SelectDocsize(pTab, SQL_SELECT_DOCSIZE, iDocid, ppStmt);
125424 }
125425
125426 /*
125427 ** Similar to fts3SqlStmt(). Except, after binding the parameters in
125428 ** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125484 }
125485
125486 return rc;
125487 }
125488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125489 static sqlite3_int64 getAbsoluteLevel(
125490 Fts3Table *p,
125491 int iLangid,
125492 int iIndex,
125493 int iLevel
125494 ){
 
125495 assert( iLangid>=0 );
125496 assert( p->nIndex>0 );
125497 assert( iIndex>=0 && iIndex<p->nIndex );
125498 return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel;
 
 
125499 }
125500
125501
125502 /*
125503 ** Set *ppStmt to a statement handle that may be used to iterate through
125504 ** all rows in the %_segdir table, from oldest to newest. If successful,
125505 ** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125518 */
125519 SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125520 Fts3Table *p, /* FTS3 table */
125521 int iLangid, /* Language being queried */
125522 int iIndex, /* Index for p->aIndex[] */
125523 int iLevel, /* Level to select */
125524 sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125525 ){
125526 int rc;
125527 sqlite3_stmt *pStmt = 0;
125528
@@ -125533,19 +125908,19 @@
125533 if( iLevel<0 ){
125534 /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125535 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125536 if( rc==SQLITE_OK ){
125537 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125538 sqlite3_bind_int(pStmt, 2,
125539 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125540 );
125541 }
125542 }else{
125543 /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125544 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125545 if( rc==SQLITE_OK ){
125546 sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
125547 }
125548 }
125549 *ppStmt = pStmt;
125550 return rc;
125551 }
@@ -126062,10 +126437,11 @@
126062 ** full, merge all segments in level iLevel into a single iLevel+1
126063 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126064 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126065 */
126066 if( iNext>=FTS3_MERGE_COUNT ){
 
126067 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126068 *piIdx = 0;
126069 }else{
126070 *piIdx = iNext;
126071 }
@@ -126109,11 +126485,11 @@
126109 int *pnLoad /* OUT: Bytes actually loaded */
126110 ){
126111 int rc; /* Return code */
126112
126113 /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126114 assert( pnBlob);
126115
126116 if( p->pSegments ){
126117 rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126118 }else{
126119 if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126450 int nOvfl = 0;
126451 int ii;
126452 int rc = SQLITE_OK;
126453 int pgsz = p->nPgsz;
126454
126455 assert( p->bHasStat );
126456 assert( pgsz>0 );
126457
126458 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126459 Fts3SegReader *pReader = pMsr->apSegment[ii];
126460 if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
126807 sqlite3_step(pStmt);
126808 rc = sqlite3_reset(pStmt);
126809 }
126810 return rc;
126811 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126812
126813 /*
126814 ** Insert a record into the %_segdir table.
126815 */
126816 static int fts3WriteSegdir(
126817 Fts3Table *p, /* Virtual table handle */
126818 int iLevel, /* Value for "level" field */
126819 int iIdx, /* Value for "idx" field */
126820 sqlite3_int64 iStartBlock, /* Value for "start_block" field */
126821 sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
126822 sqlite3_int64 iEndBlock, /* Value for "end_block" field */
126823 char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
126824 int nRoot /* Number of bytes in buffer zRoot */
126825 ){
126826 sqlite3_stmt *pStmt;
126827 int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
126828 if( rc==SQLITE_OK ){
126829 sqlite3_bind_int(pStmt, 1, iLevel);
126830 sqlite3_bind_int(pStmt, 2, iIdx);
126831 sqlite3_bind_int64(pStmt, 3, iStartBlock);
126832 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
126833 sqlite3_bind_int64(pStmt, 5, iEndBlock);
126834 sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127124 int rc;
127125
127126 /* The current leaf node is full. Write it out to the database. */
127127 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127128 if( rc!=SQLITE_OK ) return rc;
 
127129
127130 /* Add the current term to the interior node tree. The term added to
127131 ** the interior tree must:
127132 **
127133 ** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127207 ** returned. Otherwise, an SQLite error code.
127208 */
127209 static int fts3SegWriterFlush(
127210 Fts3Table *p, /* Virtual table handle */
127211 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127212 int iLevel, /* Value for 'level' column of %_segdir */
127213 int iIdx /* Value for 'idx' column of %_segdir */
127214 ){
127215 int rc; /* Return code */
127216 if( pWriter->pTree ){
127217 sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127232 }else{
127233 /* The entire tree fits on the root node. Write it to the segdir table. */
127234 rc = fts3WriteSegdir(
127235 p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127236 }
 
127237 return rc;
127238 }
127239
127240 /*
127241 ** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127289 */
127290 static int fts3SegmentMaxLevel(
127291 Fts3Table *p,
127292 int iLangid,
127293 int iIndex,
127294 int *pnMax
127295 ){
127296 sqlite3_stmt *pStmt;
127297 int rc;
127298 assert( iIndex>=0 && iIndex<p->nIndex );
127299
@@ -127303,19 +127702,42 @@
127303 **
127304 ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127305 */
127306 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127307 if( rc!=SQLITE_OK ) return rc;
127308 sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127309 sqlite3_bind_int(pStmt, 2,
127310 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127311 );
127312 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127313 *pnMax = sqlite3_column_int(pStmt, 0);
127314 }
127315 return sqlite3_reset(pStmt);
127316 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127317
127318 /*
127319 ** This function is used after merging multiple segments into a single large
127320 ** segment to delete the old, now redundant, segment b-trees. Specifically,
127321 ** it:
@@ -127335,41 +127757,36 @@
127335 int iIndex, /* Index for p->aIndex */
127336 int iLevel, /* Level of %_segdir entries to delete */
127337 Fts3SegReader **apSegment, /* Array of SegReader objects */
127338 int nReader /* Size of array apSegment */
127339 ){
127340 int rc; /* Return Code */
127341 int i; /* Iterator variable */
127342 sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127343
127344 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127345 for(i=0; rc==SQLITE_OK && i<nReader; i++){
127346 Fts3SegReader *pSegment = apSegment[i];
127347 if( pSegment->iStartBlock ){
127348 sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock);
127349 sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock);
127350 sqlite3_step(pDelete);
127351 rc = sqlite3_reset(pDelete);
127352 }
127353 }
127354 if( rc!=SQLITE_OK ){
127355 return rc;
127356 }
127357
127358 assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127359 if( iLevel==FTS3_SEGCURSOR_ALL ){
127360 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127361 if( rc==SQLITE_OK ){
127362 sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127363 sqlite3_bind_int(pDelete, 2,
127364 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127365 );
127366 }
127367 }else{
127368 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127369 if( rc==SQLITE_OK ){
127370 sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
 
 
127371 }
127372 }
127373
127374 if( rc==SQLITE_OK ){
127375 sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
127842 int iIndex, /* Index in p->aIndex[] to merge */
127843 int iLevel /* Level to merge */
127844 ){
127845 int rc; /* Return code */
127846 int iIdx = 0; /* Index of new segment */
127847 int iNewLevel = 0; /* Level/index to create new segment at */
127848 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
127849 Fts3SegFilter filter; /* Segment term filter condition */
127850 Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
127851 int bIgnoreEmpty = 0; /* True to ignore empty segments */
127852
@@ -127921,15 +128338,32 @@
127921 ** Flush the contents of pendingTerms to level 0 segments.
127922 */
127923 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
127924 int rc = SQLITE_OK;
127925 int i;
 
127926 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
127927 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
127928 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
127929 }
127930 sqlite3Fts3PendingTermsClear(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127931 return rc;
127932 }
127933
127934 /*
127935 ** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128036 if( a==0 ){
128037 *pRC = SQLITE_NOMEM;
128038 return;
128039 }
128040 pBlob = (char*)&a[nStat];
128041 rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0);
128042 if( rc ){
128043 sqlite3_free(a);
128044 *pRC = rc;
128045 return;
128046 }
 
128047 if( sqlite3_step(pStmt)==SQLITE_ROW ){
128048 fts3DecodeIntArray(nStat, a,
128049 sqlite3_column_blob(pStmt, 0),
128050 sqlite3_column_bytes(pStmt, 0));
128051 }else{
@@ -128065,17 +128500,18 @@
128065 x = x + aSzIns[i] - aSzDel[i];
128066 }
128067 a[i+1] = x;
128068 }
128069 fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128070 rc = fts3SqlStmt(p, SQL_REPLACE_DOCTOTAL, &pStmt, 0);
128071 if( rc ){
128072 sqlite3_free(a);
128073 *pRC = rc;
128074 return;
128075 }
128076 sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
 
128077 sqlite3_step(pStmt);
128078 *pRC = sqlite3_reset(pStmt);
128079 sqlite3_free(a);
128080 }
128081
@@ -128176,11 +128612,11 @@
128176 for(iCol=0; iCol<=p->nColumn; iCol++){
128177 aSzIns[iCol] += aSz[iCol];
128178 }
128179 }
128180 }
128181 if( p->bHasStat ){
128182 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128183 }
128184 sqlite3_free(aSz);
128185
128186 if( pStmt ){
@@ -128192,10 +128628,1692 @@
128192 }
128193
128194 return rc;
128195 }
128196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128197 /*
128198 ** Handle a 'special' INSERT of the form:
128199 **
128200 ** "INSERT INTO tbl(tbl) VALUES(<expr>)"
128201 **
@@ -128211,10 +130329,16 @@
128211 return SQLITE_NOMEM;
128212 }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
128213 rc = fts3DoOptimize(p, 0);
128214 }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
128215 rc = fts3DoRebuild(p);
 
 
 
 
 
 
128216 #ifdef SQLITE_TEST
128217 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
128218 p->nNodeSize = atoi(&zVal[9]);
128219 rc = SQLITE_OK;
128220 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
128406 /*
128407 ** This function does the work for the xUpdate method of FTS3 virtual
128408 ** tables. The schema of the virtual table being:
128409 **
128410 ** CREATE TABLE <table name>(
128411 ** <user COLUMns>,
128412 ** <table name> HIDDEN,
128413 ** docid HIDDEN,
128414 ** <langid> HIDDEN
128415 ** );
128416 **
@@ -128538,11 +130662,11 @@
128538 fts3InsertDocsize(&rc, p, aSzIns);
128539 }
128540 nChng++;
128541 }
128542
128543 if( p->bHasStat ){
128544 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
128545 }
128546
128547 update_out:
128548 sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
129369 char cArg,
129370 char **pzErr
129371 ){
129372 if( (cArg==FTS3_MATCHINFO_NPHRASE)
129373 || (cArg==FTS3_MATCHINFO_NCOL)
129374 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat)
129375 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat)
129376 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
129377 || (cArg==FTS3_MATCHINFO_LCS)
129378 || (cArg==FTS3_MATCHINFO_HITS)
129379 ){
129380 return SQLITE_OK;
@@ -133134,12 +135258,12 @@
133134 }
133135
133136 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
133137
133138 /* Allocate the sqlite3_vtab structure */
133139 nDb = strlen(argv[1]);
133140 nName = strlen(argv[2]);
133141 pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
133142 if( !pRtree ){
133143 return SQLITE_NOMEM;
133144 }
133145 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
133230 RtreeCell cell;
133231 int jj;
133232
133233 nodeGetCell(&tree, &node, ii, &cell);
133234 sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
133235 nCell = strlen(zCell);
133236 for(jj=0; jj<tree.nDim*2; jj++){
133237 sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
133238 nCell = strlen(zCell);
133239 }
133240
133241 if( zText ){
133242 char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
133243 sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
133976 int iInput = 0;
133977 int iOut = 0;
133978
133979 *ppCursor = 0;
133980
133981 if( nInput<0 ){
 
 
 
133982 nInput = strlen(zInput);
133983 }
133984 nChar = nInput+1;
133985 pCsr = (IcuCursor *)sqlite3_malloc(
133986 sizeof(IcuCursor) + /* IcuCursor */
133987
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.7.12. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -655,13 +655,13 @@
655 **
656 ** See also: [sqlite3_libversion()],
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.12"
661 #define SQLITE_VERSION_NUMBER 3007012
662 #define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -6554,10 +6554,21 @@
6554 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6555 ** <dd>This parameter returns the number of pager cache misses that have
6556 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6557 ** is always 0.
6558 ** </dd>
6559 **
6560 ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6561 ** <dd>This parameter returns the number of dirty cache entries that have
6562 ** been written to disk. Specifically, the number of pages written to the
6563 ** wal file in wal mode databases, or the number of pages written to the
6564 ** database file in rollback mode databases. Any pages written as part of
6565 ** transaction rollback or database recovery operations are not included.
6566 ** If an IO or other error occurs while writing a page to disk, the effect
6567 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6568 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6569 ** </dd>
6570 ** </dl>
6571 */
6572 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6573 #define SQLITE_DBSTATUS_CACHE_USED 1
6574 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
6576 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6577 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6578 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6579 #define SQLITE_DBSTATUS_CACHE_HIT 7
6580 #define SQLITE_DBSTATUS_CACHE_MISS 8
6581 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6582 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
6583
6584
6585 /*
6586 ** CAPI3REF: Prepared Statement Status
6587 **
@@ -9919,18 +9931,22 @@
9931 void (*xDestroy)(void *);
9932 void *pUserData;
9933 };
9934
9935 /*
9936 ** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF
9937 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There
9938 ** are assert() statements in the code to verify this.
9939 */
9940 #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
9941 #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
9942 #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
9943 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9944 #define SQLITE_FUNC_COUNT 0x10 /* Built-in count(*) aggregate */
9945 #define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */
9946 #define SQLITE_FUNC_LENGTH 0x40 /* Built-in length() function */
9947 #define SQLITE_FUNC_TYPEOF 0x80 /* Built-in typeof() function */
9948
9949 /*
9950 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
9951 ** used to create the initializers for the FuncDef structures.
9952 **
@@ -9954,11 +9970,14 @@
9970 ** available as the function user-data (sqlite3_user_data()). The
9971 ** FuncDef.flags variable is set to the value passed as the flags
9972 ** parameter.
9973 */
9974 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9975 {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \
9976 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9977 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
9978 {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
9979 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9980 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
9981 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9982 pArg, 0, xFunc, 0, 0, #zName, 0, 0}
9983 #define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
10203 u8 tabFlags; /* Mask of TF_* values */
10204 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
10205 FKey *pFKey; /* Linked list of all foreign keys in this table */
10206 char *zColAff; /* String defining the affinity of each column */
10207 #ifndef SQLITE_OMIT_CHECK
10208 ExprList *pCheck; /* All CHECK constraints */
10209 #endif
10210 #ifndef SQLITE_OMIT_ALTERTABLE
10211 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
10212 #endif
10213 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
10596 ** TK_VARIABLE: variable number (always >= 1). */
10597 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
10598 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
10599 u8 flags2; /* Second set of flags. EP2_... */
10600 u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
10601 /* If TK_COLUMN, the value of p5 for OP_Column */
10602 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
10603 Table *pTab; /* Table for TK_COLUMN expressions. */
10604 #if SQLITE_MAX_EXPR_DEPTH>0
10605 int nHeight; /* Height of the tree headed by this node */
10606 #endif
@@ -10599,11 +10619,11 @@
10619 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
10620 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
10621 #define EP_FixedDest 0x0200 /* Result needed in a specific register */
10622 #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
10623 #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10624 #define EP_Hint 0x1000 /* Not used */
10625 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
10626 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
10627 #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
10628
10629 /*
@@ -11118,10 +11138,11 @@
11138 int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
11139 int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
11140 int regRowid; /* Register holding rowid of CREATE TABLE entry */
11141 int regRoot; /* Register holding root page number for new objects */
11142 int nMaxArg; /* Max args passed to user function by sub-program */
11143 Token constraintName;/* Name of the constraint currently being parsed */
11144 #ifndef SQLITE_OMIT_SHARED_CACHE
11145 int nTableLock; /* Number of locks in aTableLock */
11146 TableLock *aTableLock; /* Required table locks for shared-cache mode */
11147 #endif
11148 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
11207 const char *zAuthContext; /* Put saved Parse.zAuthContext here */
11208 Parse *pParse; /* The Parse structure */
11209 };
11210
11211 /*
11212 ** Bitfield flags for P5 value in various opcodes.
11213 */
11214 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
11215 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
11216 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
11217 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
11218 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
11219 #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
11220 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
11221 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
11222
11223 /*
11224 * Each trigger present in the database schema is stored as an instance of
11225 * struct Trigger.
11226 *
@@ -11677,11 +11700,11 @@
11700 #endif
11701 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
11702 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
11703 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
11704 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11705 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
11706 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
11707 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
11708 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
11709 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
11710 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
13532 ** Set *pCurrent to the total cache hits or misses encountered by all
13533 ** pagers the database handle is connected to. *pHighwater is always set
13534 ** to zero.
13535 */
13536 case SQLITE_DBSTATUS_CACHE_HIT:
13537 case SQLITE_DBSTATUS_CACHE_MISS:
13538 case SQLITE_DBSTATUS_CACHE_WRITE:{
13539 int i;
13540 int nRet = 0;
13541 assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
13542 assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );
13543
13544 for(i=0; i<db->nDb; i++){
13545 if( db->aDb[i].pBt ){
13546 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
13547 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
21284
21285 /*
21286 ** Some systems have stricmp(). Others have strcasecmp(). Because
21287 ** there is no consistency, we will define our own.
21288 **
21289 ** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
21290 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
21291 ** the contents of two buffers containing UTF-8 strings in a
21292 ** case-independent fashion, using the same definition of "case
21293 ** independence" that SQLite uses internally when comparing identifiers.
21294 */
21295 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
21296 register unsigned char *a, *b;
21297 a = (unsigned char *)zLeft;
21298 b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
33752 }
33753 sqlite3_free(pFile->zDeleteOnClose);
33754 }
33755 #endif
33756 OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
33757 if( rc ){
33758 pFile->h = NULL;
33759 }
33760 OpenCounter(-1);
33761 return rc ? SQLITE_OK
33762 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
33763 "winClose", pFile->zPath);
33764 }
@@ -33744,22 +33772,33 @@
33772 sqlite3_file *id, /* File to read from */
33773 void *pBuf, /* Write content into this buffer */
33774 int amt, /* Number of bytes to read */
33775 sqlite3_int64 offset /* Begin reading at this offset */
33776 ){
33777 #if !SQLITE_OS_WINCE
33778 OVERLAPPED overlapped; /* The offset for ReadFile. */
33779 #endif
33780 winFile *pFile = (winFile*)id; /* file handle */
33781 DWORD nRead; /* Number of bytes actually read from file */
33782 int nRetry = 0; /* Number of retrys */
33783
33784 assert( id!=0 );
33785 SimulateIOError(return SQLITE_IOERR_READ);
33786 OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
33787
33788 #if SQLITE_OS_WINCE
33789 if( seekWinFile(pFile, offset) ){
33790 return SQLITE_FULL;
33791 }
33792 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
33793 #else
33794 memset(&overlapped, 0, sizeof(OVERLAPPED));
33795 overlapped.Offset = (LONG)(offset & 0xffffffff);
33796 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33797 while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
33798 osGetLastError()!=ERROR_HANDLE_EOF ){
33799 #endif
33800 DWORD lastErrno;
33801 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33802 pFile->lastErrno = lastErrno;
33803 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
33804 "winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
33821 sqlite3_file *id, /* File to write into */
33822 const void *pBuf, /* The bytes to be written */
33823 int amt, /* Number of bytes to write */
33824 sqlite3_int64 offset /* Offset into the file to begin writing at */
33825 ){
33826 int rc = 0; /* True if error has occured, else false */
33827 winFile *pFile = (winFile*)id; /* File handle */
33828 int nRetry = 0; /* Number of retries */
33829
33830 assert( amt>0 );
33831 assert( pFile );
@@ -33793,23 +33832,48 @@
33832 SimulateIOError(return SQLITE_IOERR_WRITE);
33833 SimulateDiskfullError(return SQLITE_FULL);
33834
33835 OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
33836
33837 #if SQLITE_OS_WINCE
33838 rc = seekWinFile(pFile, offset);
33839 if( rc==0 ){
33840 #else
33841 {
33842 #endif
33843 #if !SQLITE_OS_WINCE
33844 OVERLAPPED overlapped; /* The offset for WriteFile. */
33845 #endif
33846 u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
33847 int nRem = amt; /* Number of bytes yet to be written */
33848 DWORD nWrite; /* Bytes written by each WriteFile() call */
33849 DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
33850
33851 #if !SQLITE_OS_WINCE
33852 memset(&overlapped, 0, sizeof(OVERLAPPED));
33853 overlapped.Offset = (LONG)(offset & 0xffffffff);
33854 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33855 #endif
33856
33857 while( nRem>0 ){
33858 #if SQLITE_OS_WINCE
33859 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
33860 #else
33861 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
33862 #endif
33863 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33864 break;
33865 }
33866 if( nWrite<=0 ){
33867 lastErrno = osGetLastError();
33868 break;
33869 }
33870 #if !SQLITE_OS_WINCE
33871 offset += nWrite;
33872 overlapped.Offset = (LONG)(offset & 0xffffffff);
33873 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33874 #endif
33875 aRem += nWrite;
33876 nRem -= nWrite;
33877 }
33878 if( nRem>0 ){
33879 pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
39158 i64 journalSizeLimit; /* Size limit for persistent journal files */
39159 char *zFilename; /* Name of the database file */
39160 char *zJournal; /* Name of the journal file */
39161 int (*xBusyHandler)(void*); /* Function to call when busy */
39162 void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39163 int aStat[3]; /* Total cache hits, misses and writes */
39164 #ifdef SQLITE_TEST
39165 int nRead; /* Database pages read */
39166 #endif
39167 void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
39168 #ifdef SQLITE_HAS_CODEC
39169 void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
39170 void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
39177 Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
39178 char *zWal; /* File name for write-ahead log */
39179 #endif
39180 };
39181
39182 /*
39183 ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
39184 ** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS
39185 ** or CACHE_WRITE to sqlite3_db_status().
39186 */
39187 #define PAGER_STAT_HIT 0
39188 #define PAGER_STAT_MISS 1
39189 #define PAGER_STAT_WRITE 2
39190
39191 /*
39192 ** The following global variables hold counters used for
39193 ** testing purposes only. These variables do not exist in
39194 ** a non-testing build. These variables are not thread-safe.
39195 */
@@ -41395,10 +41468,11 @@
41468 PgHdr *pList, /* List of frames to log */
41469 Pgno nTruncate, /* Database size after this commit */
41470 int isCommit /* True if this is a commit */
41471 ){
41472 int rc; /* Return code */
41473 int nList; /* Number of pages in pList */
41474 #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
41475 PgHdr *p; /* For looping over pages */
41476 #endif
41477
41478 assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
41482 for(p=pList; p && p->pDirty; p=p->pDirty){
41483 assert( p->pgno < p->pDirty->pgno );
41484 }
41485 #endif
41486
41487 assert( pList->pDirty==0 || isCommit );
41488 if( isCommit ){
41489 /* If a WAL transaction is being committed, there is no point in writing
41490 ** any pages with page numbers greater than nTruncate into the WAL file.
41491 ** They will never be read by any client. So remove them from the pDirty
41492 ** list here. */
41493 PgHdr *p;
41494 PgHdr **ppNext = &pList;
41495 nList = 0;
41496 for(p=pList; (*ppNext = p); p=p->pDirty){
41497 if( p->pgno<=nTruncate ){
41498 ppNext = &p->pDirty;
41499 nList++;
41500 }
41501 }
41502 assert( pList );
41503 }else{
41504 nList = 1;
41505 }
41506 pPager->aStat[PAGER_STAT_WRITE] += nList;
41507
41508 if( pList->pgno==1 ) pager_write_changecounter(pList);
41509 rc = sqlite3WalFrames(pPager->pWal,
41510 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
41511 );
@@ -42487,19 +42569,19 @@
42569 memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
42570 }
42571 if( pgno>pPager->dbFileSize ){
42572 pPager->dbFileSize = pgno;
42573 }
42574 pPager->aStat[PAGER_STAT_WRITE]++;
42575
42576 /* Update any backup objects copying the contents of this pager. */
42577 sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
42578
42579 PAGERTRACE(("STORE %d page %d hash(%08x)\n",
42580 PAGERID(pPager), pgno, pager_pagehash(pList)));
42581 IOTRACE(("PGOUT %p %d\n", pPager, pgno));
42582 PAGER_INCR(sqlite3_pager_writedb_count);
 
42583 }else{
42584 PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
42585 }
42586 pager_set_pagehash(pList);
42587 pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
43535
43536 if( (*ppPage)->pPager && !noContent ){
43537 /* In this case the pcache already contains an initialized copy of
43538 ** the page. Return without further ado. */
43539 assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43540 pPager->aStat[PAGER_STAT_HIT]++;
43541 return SQLITE_OK;
43542
43543 }else{
43544 /* The pager cache has created a new page. Its content needs to
43545 ** be initialized. */
@@ -43495,11 +43577,11 @@
43577 }
43578 memset(pPg->pData, 0, pPager->pageSize);
43579 IOTRACE(("ZERO %p %d\n", pPager, pgno));
43580 }else{
43581 assert( pPg->pPager==pPager );
43582 pPager->aStat[PAGER_STAT_MISS]++;
43583 rc = readDbPage(pPg);
43584 if( rc!=SQLITE_OK ){
43585 goto pager_acquire_err;
43586 }
43587 }
@@ -44080,10 +44162,11 @@
44162 const void *zBuf;
44163 assert( pPager->dbFileSize>0 );
44164 CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
44165 if( rc==SQLITE_OK ){
44166 rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
44167 pPager->aStat[PAGER_STAT_WRITE]++;
44168 }
44169 if( rc==SQLITE_OK ){
44170 pPager->changeCountDone = 1;
44171 }
44172 }else{
@@ -44523,15 +44606,15 @@
44606 a[1] = sqlite3PcachePagecount(pPager->pPCache);
44607 a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
44608 a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
44609 a[4] = pPager->eState;
44610 a[5] = pPager->errCode;
44611 a[6] = pPager->aStat[PAGER_STAT_HIT];
44612 a[7] = pPager->aStat[PAGER_STAT_MISS];
44613 a[8] = 0; /* Used to be pPager->nOvfl */
44614 a[9] = pPager->nRead;
44615 a[10] = pPager->aStat[PAGER_STAT_WRITE];
44616 return a;
44617 }
44618 #endif
44619
44620 /*
@@ -44540,24 +44623,23 @@
44623 ** current cache hit or miss count, according to the value of eStat. If the
44624 ** reset parameter is non-zero, the cache hit or miss count is zeroed before
44625 ** returning.
44626 */
44627 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
 
44628
44629 assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
44630 || eStat==SQLITE_DBSTATUS_CACHE_MISS
44631 || eStat==SQLITE_DBSTATUS_CACHE_WRITE
44632 );
 
 
 
 
 
44633
44634 assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );
44635 assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );
44636 assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );
44637
44638 *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];
44639 if( reset ){
44640 pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;
44641 }
44642 }
44643
44644 /*
44645 ** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
56233 ** keys with no associated data. If the cursor was opened expecting an
56234 ** intkey table, the caller should be inserting integer keys with a
56235 ** blob of associated data. */
56236 assert( (pKey==0)==(pCur->pKeyInfo==0) );
56237
 
 
 
 
 
 
 
56238 /* Save the positions of any other cursors open on this table.
56239 **
56240 ** In some cases, the call to btreeMoveto() below is a no-op. For
56241 ** example, when inserting data into a table with auto-generated integer
56242 ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
56246 ** doing any work. To avoid thwarting these optimizations, it is important
56247 ** not to clear the cursor here.
56248 */
56249 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56250 if( rc ) return rc;
56251
56252 /* If this is an insert into a table b-tree, invalidate any incrblob
56253 ** cursors open on the row being replaced (assuming this is a replace
56254 ** operation - if it is not, the following is a no-op). */
56255 if( pCur->pKeyInfo==0 ){
56256 invalidateIncrblobCursors(p, nKey, 0);
56257 }
56258
56259 if( !loc ){
56260 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
56261 if( rc ) return rc;
56262 }
56263 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
56364 || NEVER(pCur->eState!=CURSOR_VALID)
56365 ){
56366 return SQLITE_ERROR; /* Something has gone awry. */
56367 }
56368
 
 
 
 
 
 
56369 iCellDepth = pCur->iPage;
56370 iCellIdx = pCur->aiIdx[iCellDepth];
56371 pPage = pCur->apPage[iCellDepth];
56372 pCell = findCell(pPage, iCellIdx);
56373
@@ -56312,10 +56389,17 @@
56389 ** deleted writable. Then free any overflow pages associated with the
56390 ** entry and finally remove the cell itself from within the page.
56391 */
56392 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56393 if( rc ) return rc;
56394
56395 /* If this is a delete operation to remove a row from a table b-tree,
56396 ** invalidate any incrblob cursors open on the row being deleted. */
56397 if( pCur->pKeyInfo==0 ){
56398 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56399 }
56400
56401 rc = sqlite3PagerWrite(pPage->pDbPage);
56402 if( rc ) return rc;
56403 rc = clearCell(pPage, pCell);
56404 dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
56405 if( rc ) return rc;
@@ -56593,17 +56677,17 @@
56677 int rc;
56678 BtShared *pBt = p->pBt;
56679 sqlite3BtreeEnter(p);
56680 assert( p->inTrans==TRANS_WRITE );
56681
 
 
 
 
 
56682 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
56683
56684 if( SQLITE_OK==rc ){
56685 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56686 ** is the root of a table b-tree - if it is not, the following call is
56687 ** a no-op). */
56688 invalidateIncrblobCursors(p, 0, 1);
56689 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
56690 }
56691 sqlite3BtreeLeave(p);
56692 return rc;
56693 }
@@ -58411,14 +58495,14 @@
58495
58496 /*
58497 ** Make sure pMem->z points to a writable allocation of at least
58498 ** n bytes.
58499 **
58500 ** If the third argument passed to this function is true, then memory
58501 ** cell pMem must contain a string or blob. In this case the content is
58502 ** preserved. Otherwise, if the third parameter to this function is false,
58503 ** any current string or blob value may be discarded.
58504 **
58505 ** This function sets the MEM_Dyn flag and clears any xDel callback.
58506 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
58507 ** not set, Mem.n is zeroed.
58508 */
@@ -58428,10 +58512,14 @@
58512 (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
58513 ((pMem->flags&MEM_Ephem) ? 1 : 0) +
58514 ((pMem->flags&MEM_Static) ? 1 : 0)
58515 );
58516 assert( (pMem->flags&MEM_RowSet)==0 );
58517
58518 /* If the preserve flag is set to true, then the memory cell must already
58519 ** contain a valid string or blob value. */
58520 assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
58521
58522 if( n<32 ) n = 32;
58523 if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
58524 if( preserve && pMem->z==pMem->zMalloc ){
58525 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
60835 int nByte = (nSub+1)*sizeof(SubProgram*);
60836 int j;
60837 for(j=0; j<nSub; j++){
60838 if( apSub[j]==pOp->p4.pProgram ) break;
60839 }
60840 if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
60841 apSub = (SubProgram **)pSub->z;
60842 apSub[nSub++] = pOp->p4.pProgram;
60843 pSub->flags |= MEM_Blob;
60844 pSub->n = nSub*sizeof(SubProgram*);
60845 }
@@ -66996,10 +67084,15 @@
67084 **
67085 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
67086 ** then the cache of the cursor is reset prior to extracting the column.
67087 ** The first OP_Column against a pseudo-table after the value of the content
67088 ** register has changed should have this bit set.
67089 **
67090 ** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when
67091 ** the result is guaranteed to only be used as the argument of a length()
67092 ** or typeof() function, respectively. The loading of large blobs can be
67093 ** skipped for length() and all content loading can be skipped for typeof().
67094 */
67095 case OP_Column: {
67096 #if 0 /* local variables moved into u.an */
67097 u32 payloadSize; /* Number of bytes in the record */
67098 i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
67231 u.an.pC->aRow = (u8*)u.an.zData;
67232 }else{
67233 u.an.pC->aRow = 0;
67234 }
67235 }
67236 /* The following assert is true in all cases except when
67237 ** the database file has been corrupted externally.
67238 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67239 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67240
67241 /* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
67306 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67307 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67308 break;
67309 }
67310 }else{
67311 /* If u.an.i is less that u.an.nField, then there are fewer fields in this
67312 ** record than SetNumColumns indicated there are columns in the
67313 ** table. Set the u.an.offset for any extra columns not present in
67314 ** the record to 0. This tells code below to store the default value
67315 ** for the column instead of deserializing a value from the record.
67316 */
67317 u.an.aOffset[u.an.i] = 0;
67318 }
67319 }
67320 sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
67340 ** a pointer to a Mem object.
67341 */
67342 if( u.an.aOffset[u.an.p2] ){
67343 assert( rc==SQLITE_OK );
67344 if( u.an.zRec ){
67345 /* This is the common case where the whole row fits on a single page */
67346 VdbeMemRelease(u.an.pDest);
67347 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67348 }else{
67349 /* This branch happens only when the row overflows onto multiple pages */
67350 u.an.t = u.an.aType[u.an.p2];
67351 if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
67352 && ((u.an.t>=12 && (u.an.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)
67353 ){
67354 /* Content is irrelevant for the typeof() function and for
67355 ** the length(X) function if X is a blob. So we might as well use
67356 ** bogus content rather than reading content from disk. NULL works
67357 ** for text and blob and whatever is in the u.an.payloadSize64 variable
67358 ** will work for everything else. */
67359 u.an.zData = u.an.t<12 ? (char*)&u.an.payloadSize64 : 0;
67360 }else{
67361 u.an.len = sqlite3VdbeSerialTypeLen(u.an.t);
67362 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67363 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex,
67364 &u.an.sMem);
67365 if( rc!=SQLITE_OK ){
67366 goto op_column_out;
67367 }
67368 u.an.zData = u.an.sMem.z;
67369 }
67370 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.t, u.an.pDest);
67371 }
67372 u.an.pDest->enc = encoding;
67373 }else{
67374 if( pOp->p4type==P4_MEM ){
67375 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
67701 }
67702 db->isTransactionSavepoint = 0;
67703 rc = p->rc;
67704 }else{
67705 u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67706 if( u.ar.p1==SAVEPOINT_ROLLBACK ){
67707 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67708 sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67709 }
67710 }
67711 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67712 rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
67713 if( rc!=SQLITE_OK ){
67714 goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
74983 int op, /* Expression opcode */
74984 Expr *pLeft, /* Left operand */
74985 Expr *pRight, /* Right operand */
74986 const Token *pToken /* Argument token */
74987 ){
74988 Expr *p;
74989 if( op==TK_AND && pLeft && pRight ){
74990 /* Take advantage of short-circuit false optimization for AND */
74991 p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
74992 }else{
74993 p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74994 sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74995 }
74996 if( p ) {
74997 sqlite3ExprCheckHeight(pParse, p->nHeight);
74998 }
74999 return p;
75000 }
75001
75002 /*
75003 ** Return 1 if an expression must be FALSE in all cases and 0 if the
75004 ** expression might be true. This is an optimization. If is OK to
75005 ** return 0 here even if the expression really is always false (a
75006 ** false negative). But it is a bug to return 1 if the expression
75007 ** might be true in some rare circumstances (a false positive.)
75008 **
75009 ** Note that if the expression is part of conditional for a
75010 ** LEFT JOIN, then we cannot determine at compile-time whether or not
75011 ** is it true or false, so always return 0.
75012 */
75013 static int exprAlwaysFalse(Expr *p){
75014 int v = 0;
75015 if( ExprHasProperty(p, EP_FromJoin) ) return 0;
75016 if( !sqlite3ExprIsInteger(p, &v) ) return 0;
75017 return v==0;
75018 }
75019
75020 /*
75021 ** Join two expressions using an AND operator. If either expression is
75022 ** NULL, then just return the other expression.
75023 **
75024 ** If one side or the other of the AND is known to be false, then instead
75025 ** of returning an AND expression, just return a constant expression with
75026 ** a value of false.
75027 */
75028 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
75029 if( pLeft==0 ){
75030 return pRight;
75031 }else if( pRight==0 ){
75032 return pLeft;
75033 }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){
75034 sqlite3ExprDelete(db, pLeft);
75035 sqlite3ExprDelete(db, pRight);
75036 return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);
75037 }else{
75038 Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
75039 sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
75040 return pNew;
75041 }
@@ -76421,19 +76563,10 @@
76563 ** Actually, the way the column cache is currently used, we are guaranteed
76564 ** that the object will never already be in cache. Verify this guarantee.
76565 */
76566 #ifndef NDEBUG
76567 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
 
 
 
 
 
 
 
 
 
76568 assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
76569 }
76570 #endif
76571
76572 /* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
76697 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
76698 Parse *pParse, /* Parsing and code generating context */
76699 Table *pTab, /* Description of the table we are reading from */
76700 int iColumn, /* Index of the table column */
76701 int iTable, /* The cursor pointing to the table */
76702 int iReg, /* Store results here */
76703 u8 p5 /* P5 value for OP_Column */
76704 ){
76705 Vdbe *v = pParse->pVdbe;
76706 int i;
76707 struct yColCache *p;
76708
@@ -76579,11 +76713,15 @@
76713 return p->iReg;
76714 }
76715 }
76716 assert( v!=0 );
76717 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76718 if( p5 ){
76719 sqlite3VdbeChangeP5(v, p5);
76720 }else{
76721 sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76722 }
76723 return iReg;
76724 }
76725
76726 /*
76727 ** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
76845 /* This only happens when coding check constraints */
76846 assert( pParse->ckBase>0 );
76847 inReg = pExpr->iColumn + pParse->ckBase;
76848 }else{
76849 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76850 pExpr->iColumn, pExpr->iTable, target,
76851 pExpr->op2);
76852 }
76853 break;
76854 }
76855 case TK_INTEGER: {
76856 codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
77123 }
77124
77125
77126 if( pFarg ){
77127 r1 = sqlite3GetTempRange(pParse, nFarg);
77128
77129 /* For length() and typeof() functions with a column argument,
77130 ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
77131 ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
77132 ** loading.
77133 */
77134 if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
77135 u8 exprOp;
77136 assert( nFarg==1 );
77137 assert( pFarg->a[0].pExpr!=0 );
77138 exprOp = pFarg->a[0].pExpr->op;
77139 if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){
77140 assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
77141 assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
77142 testcase( pDef->flags==SQLITE_FUNC_LENGTH );
77143 pFarg->a[0].pExpr->op2 = pDef->flags;
77144 }
77145 }
77146
77147 sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
77148 sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
77149 sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
77150 }else{
77151 r1 = 0;
@@ -80189,10 +80347,11 @@
80347 Index *pPrevIdx = 0; /* Previous index in the loop */
80348 int idx = 0; /* slot in pIdx->aSample[] for next sample */
80349 int eType; /* Datatype of a sample */
80350 IndexSample *pSample; /* A slot in pIdx->aSample[] */
80351
80352 assert( db->lookaside.bEnabled==0 );
80353 if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
80354 return SQLITE_OK;
80355 }
80356
80357 zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
80374 nSample = sqlite3_column_int(pStmt, 1);
80375 pIdx = sqlite3FindIndex(db, zIndex, zDb);
80376 if( pIdx==0 ) continue;
80377 assert( pIdx->nSample==0 );
80378 pIdx->nSample = nSample;
80379 pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));
80380 pIdx->avgEq = pIdx->aiRowEst[1];
80381 if( pIdx->aSample==0 ){
80382 db->mallocFailed = 1;
80383 sqlite3_finalize(pStmt);
80384 return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
80447 int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
80448 pSample->nByte = n;
80449 if( n < 1){
80450 pSample->u.z = 0;
80451 }else{
80452 pSample->u.z = sqlite3DbMallocRaw(db, n);
80453 if( pSample->u.z==0 ){
80454 db->mallocFailed = 1;
80455 sqlite3_finalize(pStmt);
80456 return SQLITE_NOMEM;
80457 }
@@ -80364,11 +80523,14 @@
80523
80524
80525 /* Load the statistics from the sqlite_stat3 table. */
80526 #ifdef SQLITE_ENABLE_STAT3
80527 if( rc==SQLITE_OK ){
80528 int lookasideEnabled = db->lookaside.bEnabled;
80529 db->lookaside.bEnabled = 0;
80530 rc = loadStat3(db, sInfo.zDatabase);
80531 db->lookaside.bEnabled = lookasideEnabled;
80532 }
80533 #endif
80534
80535 if( rc==SQLITE_NOMEM ){
80536 db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
81889 sqliteDeleteColumnNames(db, pTable);
81890 sqlite3DbFree(db, pTable->zName);
81891 sqlite3DbFree(db, pTable->zColAff);
81892 sqlite3SelectDelete(db, pTable->pSelect);
81893 #ifndef SQLITE_OMIT_CHECK
81894 sqlite3ExprListDelete(db, pTable->pCheck);
81895 #endif
81896 #ifndef SQLITE_OMIT_VIRTUALTABLE
81897 sqlite3VtabClear(db, pTable);
81898 #endif
81899 sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
82552 */
82553 SQLITE_PRIVATE void sqlite3AddCheckConstraint(
82554 Parse *pParse, /* Parsing context */
82555 Expr *pCheckExpr /* The check expression */
82556 ){
 
82557 #ifndef SQLITE_OMIT_CHECK
82558 Table *pTab = pParse->pNewTable;
82559 if( pTab && !IN_DECLARE_VTAB ){
82560 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
82561 if( pParse->constraintName.n ){
82562 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
82563 }
82564 }else
82565 #endif
82566 {
82567 sqlite3ExprDelete(pParse->db, pCheckExpr);
82568 }
82569 }
82570
82571 /*
82572 ** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
82832 /* Resolve names in all CHECK constraint expressions.
82833 */
82834 if( p->pCheck ){
82835 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
82836 NameContext sNC; /* Name context for pParse->pNewTable */
82837 ExprList *pList; /* List of all CHECK constraints */
82838 int i; /* Loop counter */
82839
82840 memset(&sNC, 0, sizeof(sNC));
82841 memset(&sSrc, 0, sizeof(sSrc));
82842 sSrc.nSrc = 1;
82843 sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
82844 sSrc.a[0].pTab = p;
82845 sSrc.a[0].iCursor = -1;
82846 sNC.pParse = pParse;
82847 sNC.pSrcList = &sSrc;
82848 sNC.isCheck = 1;
82849 pList = p->pCheck;
82850 for(i=0; i<pList->nExpr; i++){
82851 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
82852 return;
82853 }
82854 }
82855 }
82856 #endif /* !defined(SQLITE_OMIT_CHECK) */
82857
82858 /* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
84399 exit_drop_index:
84400 sqlite3SrcListDelete(db, pName);
84401 }
84402
84403 /*
84404 ** pArray is a pointer to an array of objects. Each object in the
84405 ** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()
84406 ** to extend the array so that there is space for a new object at the end.
84407 **
84408 ** When this function is called, *pnEntry contains the current size of
84409 ** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes
84410 ** in total).
84411 **
84412 ** If the realloc() is successful (i.e. if no OOM condition occurs), the
84413 ** space allocated for the new object is zeroed, *pnEntry updated to
84414 ** reflect the new size of the array and a pointer to the new allocation
84415 ** returned. *pIdx is set to the index of the new array entry in this case.
84416 **
84417 ** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
84418 ** unchanged and a copy of pArray returned.
84419 */
84420 SQLITE_PRIVATE void *sqlite3ArrayAllocate(
84421 sqlite3 *db, /* Connection to notify of malloc failures */
84422 void *pArray, /* Array of objects. Might be reallocated */
84423 int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
86010 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
86011 pWInfo = sqlite3WhereBegin(
86012 pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
86013 );
86014 if( pWInfo==0 ) goto delete_from_cleanup;
86015 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
86016 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
86017 if( db->flags & SQLITE_CountRows ){
86018 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
86019 }
86020 sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
87830 FUNCTION(min, 0, 0, 1, 0 ),
87831 AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
87832 FUNCTION(max, -1, 1, 1, minmaxFunc ),
87833 FUNCTION(max, 0, 1, 1, 0 ),
87834 AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87835 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
87836 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
87837 FUNCTION(substr, 2, 0, 0, substrFunc ),
87838 FUNCTION(substr, 3, 0, 0, substrFunc ),
87839 FUNCTION(abs, 1, 0, 0, absFunc ),
87840 #ifndef SQLITE_OMIT_FLOATING_POINT
87841 FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
87843 #endif
87844 FUNCTION(upper, 1, 0, 0, upperFunc ),
87845 FUNCTION(lower, 1, 0, 0, lowerFunc ),
87846 FUNCTION(coalesce, 1, 0, 0, 0 ),
87847 FUNCTION(coalesce, 0, 0, 0, 0 ),
87848 FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
 
87849 FUNCTION(hex, 1, 0, 0, hexFunc ),
87850 FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
 
87851 FUNCTION(random, 0, 0, 0, randomFunc ),
87852 FUNCTION(randomblob, 1, 0, 0, randomBlob ),
87853 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
87854 FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
87855 FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
90282 int j1; /* Addresss of jump instruction */
90283 int j2 = 0, j3; /* Addresses of jump instructions */
90284 int regData; /* Register containing first data column */
90285 int iCur; /* Table cursor number */
90286 Index *pIdx; /* Pointer to one of the indices */
90287 sqlite3 *db; /* Database connection */
90288 int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
90289 int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
90290
90291 db = pParse->db;
90292 v = sqlite3GetVdbe(pParse);
90293 assert( v!=0 );
90294 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90295 nCol = pTab->nCol;
90296 regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
90319 case OE_Rollback:
90320 case OE_Fail: {
90321 char *zMsg;
90322 sqlite3VdbeAddOp3(v, OP_HaltIfNull,
90323 SQLITE_CONSTRAINT, onError, regData+i);
90324 zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL",
90325 pTab->zName, pTab->aCol[i].zName);
90326 sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
90327 break;
90328 }
90329 case OE_Ignore: {
@@ -90170,22 +90341,31 @@
90341 }
90342
90343 /* Test all CHECK constraints
90344 */
90345 #ifndef SQLITE_OMIT_CHECK
90346 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
90347 ExprList *pCheck = pTab->pCheck;
90348 pParse->ckBase = regData;
 
90349 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90350 for(i=0; i<pCheck->nExpr; i++){
90351 int allOk = sqlite3VdbeMakeLabel(v);
90352 sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
90353 if( onError==OE_Ignore ){
90354 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90355 }else{
90356 char *zConsName = pCheck->a[i].zName;
90357 if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90358 if( zConsName ){
90359 zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
90360 }else{
90361 zConsName = 0;
90362 }
90363 sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
90364 }
90365 sqlite3VdbeResolveLabel(v, allOk);
90366 }
 
90367 }
90368 #endif /* !defined(SQLITE_OMIT_CHECK) */
90369
90370 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90371 ** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
90417 **
90418 ** to run without a statement journal if there are no indexes on the
90419 ** table.
90420 */
90421 Trigger *pTrigger = 0;
90422 if( db->flags&SQLITE_RecTriggers ){
90423 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90424 }
90425 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
90426 sqlite3MultiWrite(pParse);
90427 sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
90506 StrAccum errMsg;
90507 const char *zSep;
90508 char *zErr;
90509
90510 sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90511 errMsg.db = db;
90512 zSep = pIdx->nColumn>1 ? "columns " : "column ";
90513 for(j=0; j<pIdx->nColumn; j++){
90514 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
90515 sqlite3StrAccumAppend(&errMsg, zSep, -1);
90516 zSep = ", ";
@@ -90350,11 +90530,11 @@
90530 }
90531 default: {
90532 Trigger *pTrigger = 0;
90533 assert( onError==OE_Replace );
90534 sqlite3MultiWrite(pParse);
90535 if( db->flags&SQLITE_RecTriggers ){
90536 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90537 }
90538 sqlite3GenerateRowDelete(
90539 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
90540 );
@@ -90680,11 +90860,11 @@
90860 if( pSrcIdx==0 ){
90861 return 0; /* pDestIdx has no corresponding index in pSrc */
90862 }
90863 }
90864 #ifndef SQLITE_OMIT_CHECK
90865 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
90866 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
90867 }
90868 #endif
90869 #ifndef SQLITE_OMIT_FOREIGN_KEY
90870 /* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
95933 int nCol; /* Number of columns in the result set */
95934 Expr *p; /* Expression for a single result column */
95935 char *zName; /* Column name */
95936 int nName; /* Size of name in zName[] */
95937
95938 if( pEList ){
95939 nCol = pEList->nExpr;
95940 aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95941 testcase( aCol==0 );
95942 }else{
95943 nCol = 0;
95944 aCol = 0;
95945 }
95946 *pnCol = nCol;
95947 *paCol = aCol;
95948
95949 for(i=0, pCol=aCol; i<nCol; i++, pCol++){
95950 /* Get an appropriate name for the column
95951 */
95952 p = pEList->a[i].pExpr;
95953 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
98911 if( pCol->iSorterColumn>=j ){
98912 int r1 = j + regBase;
98913 int r2;
98914
98915 r2 = sqlite3ExprCodeGetColumn(pParse,
98916 pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
98917 if( r1!=r2 ){
98918 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
98919 }
98920 j++;
98921 }
@@ -103212,11 +103400,14 @@
103400 #ifdef SQLITE_EBCDIC
103401 if( *pnoCase ) return 0;
103402 #endif
103403 pList = pExpr->x.pList;
103404 pLeft = pList->a[1].pExpr;
103405 if( pLeft->op!=TK_COLUMN
103406 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
103407 || IsVirtual(pLeft->pTab)
103408 ){
103409 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103410 ** be the name of an indexed column with TEXT affinity. */
103411 return 0;
103412 }
103413 assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
107100 );
107101 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
107102 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
107103 int r;
107104 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
107105 regRowid, 0);
107106 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
107107 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
107108 }
107109 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
107110
@@ -107822,11 +108013,11 @@
108013 ** An instance of this structure is used to store the LIKE,
108014 ** GLOB, NOT LIKE, and NOT GLOB operators.
108015 */
108016 struct LikeOp {
108017 Token eOperator; /* "like" or "glob" or "regexp" */
108018 int bNot; /* True if the NOT keyword is present */
108019 };
108020
108021 /*
108022 ** An instance of the following structure describes the event of a
108023 ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108192 #endif
108193 #define sqlite3ParserARG_SDECL Parse *pParse;
108194 #define sqlite3ParserARG_PDECL ,Parse *pParse
108195 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108196 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
108197 #define YYNSTATE 627
108198 #define YYNRULE 325
108199 #define YYFALLBACK 1
108200 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108201 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108202 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108203
@@ -108072,480 +108263,478 @@
108263 ** shifting terminals.
108264 ** yy_reduce_ofst[] For each state, the offset into yy_action for
108265 ** shifting non-terminals after a reduce.
108266 ** yy_default[] Default action for each state.
108267 */
108268 #define YY_ACTTAB_COUNT (1561)
108269 static const YYACTIONTYPE yy_action[] = {
108270 /* 0 */ 310, 328, 573, 572, 15, 171, 185, 595, 56, 56,
108271 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108272 /* 20 */ 52, 52, 51, 233, 52, 52, 52, 51, 233, 624,
108273 /* 30 */ 588, 582, 56, 56, 56, 56, 314, 54, 54, 54,
108274 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 299, 57,
108275 /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108276 /* 60 */ 56, 56, 569, 54, 54, 54, 54, 53, 53, 52,
108277 /* 70 */ 52, 52, 51, 233, 310, 595, 326, 575, 663, 65,
108278 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108279 /* 90 */ 51, 233, 53, 53, 52, 52, 52, 51, 233, 489,
108280 /* 100 */ 663, 440, 663, 235, 588, 582, 553, 297, 363, 59,
108281 /* 110 */ 481, 67, 360, 1, 618, 351, 618, 620, 619, 207,
108282 /* 120 */ 6, 441, 442, 57, 58, 48, 580, 579, 581, 581,
108283 /* 130 */ 55, 55, 56, 56, 56, 56, 605, 54, 54, 54,
108284 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
108285 /* 150 */ 50, 47, 146, 598, 138, 281, 385, 276, 384, 168,
108286 /* 160 */ 489, 552, 620, 619, 620, 619, 272, 214, 440, 411,
108287 /* 170 */ 551, 604, 67, 165, 7, 618, 352, 353, 588, 582,
108288 /* 180 */ 443, 569, 192, 618, 414, 617, 616, 668, 441, 336,
108289 /* 190 */ 669, 62, 618, 599, 92, 382, 346, 57, 58, 48,
108290 /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108291 /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108292 /* 220 */ 51, 233, 310, 465, 232, 231, 373, 132, 514, 513,
108293 /* 230 */ 617, 616, 617, 616, 398, 437, 411, 66, 280, 388,
108294 /* 240 */ 411, 595, 439, 220, 438, 620, 619, 337, 569, 279,
108295 /* 250 */ 201, 414, 588, 582, 166, 414, 546, 167, 68, 234,
108296 /* 260 */ 599, 92, 620, 619, 599, 92, 19, 570, 570, 466,
108297 /* 270 */ 564, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108298 /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108299 /* 290 */ 53, 52, 52, 52, 51, 233, 310, 411, 524, 232,
108300 /* 300 */ 231, 398, 593, 547, 559, 398, 348, 202, 175, 595,
108301 /* 310 */ 399, 315, 414, 617, 616, 387, 272, 255, 347, 254,
108302 /* 320 */ 558, 599, 74, 620, 619, 45, 588, 582, 235, 466,
108303 /* 330 */ 617, 616, 511, 591, 591, 591, 557, 578, 402, 545,
108304 /* 340 */ 600, 598, 570, 570, 601, 57, 58, 48, 580, 579,
108305 /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 550, 54,
108306 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108307 /* 370 */ 310, 309, 411, 145, 566, 490, 213, 255, 347, 254,
108308 /* 380 */ 196, 195, 194, 587, 586, 531, 600, 414, 235, 174,
108309 /* 390 */ 601, 617, 616, 411, 620, 619, 599, 91, 547, 574,
108310 /* 400 */ 588, 582, 50, 47, 146, 584, 583, 471, 414, 249,
108311 /* 410 */ 565, 542, 186, 39, 304, 424, 562, 599, 16, 57,
108312 /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108313 /* 430 */ 56, 56, 585, 54, 54, 54, 54, 53, 53, 52,
108314 /* 440 */ 52, 52, 51, 233, 310, 559, 290, 530, 529, 345,
108315 /* 450 */ 533, 576, 540, 246, 170, 248, 411, 396, 411, 422,
108316 /* 460 */ 199, 558, 617, 616, 165, 563, 50, 47, 146, 181,
108317 /* 470 */ 498, 414, 166, 414, 588, 582, 269, 557, 166, 518,
108318 /* 480 */ 599, 92, 599, 92, 561, 595, 469, 36, 173, 409,
108319 /* 490 */ 517, 577, 577, 57, 58, 48, 580, 579, 581, 581,
108320 /* 500 */ 55, 55, 56, 56, 56, 56, 338, 54, 54, 54,
108321 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 304,
108322 /* 520 */ 423, 394, 526, 318, 869, 235, 167, 180, 473, 547,
108323 /* 530 */ 503, 247, 474, 381, 378, 377, 409, 351, 577, 577,
108324 /* 540 */ 409, 560, 577, 577, 376, 383, 364, 603, 588, 582,
108325 /* 550 */ 620, 619, 502, 595, 409, 494, 577, 577, 409, 266,
108326 /* 560 */ 577, 577, 421, 943, 422, 943, 198, 57, 58, 48,
108327 /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108328 /* 580 */ 315, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108329 /* 590 */ 51, 233, 310, 390, 421, 942, 509, 942, 556, 145,
108330 /* 600 */ 598, 391, 324, 262, 549, 264, 411, 425, 407, 573,
108331 /* 610 */ 572, 12, 197, 143, 489, 50, 47, 146, 617, 616,
108332 /* 620 */ 206, 414, 588, 582, 547, 429, 67, 212, 143, 618,
108333 /* 630 */ 599, 73, 504, 505, 207, 434, 475, 475, 366, 425,
108334 /* 640 */ 35, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108335 /* 650 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108336 /* 660 */ 53, 52, 52, 52, 51, 233, 310, 260, 598, 569,
108337 /* 670 */ 268, 615, 614, 613, 171, 411, 595, 11, 411, 350,
108338 /* 680 */ 411, 32, 618, 953, 183, 419, 2, 627, 625, 330,
108339 /* 690 */ 414, 352, 552, 414, 538, 414, 588, 582, 188, 599,
108340 /* 700 */ 69, 551, 599, 94, 599, 97, 374, 544, 166, 618,
108341 /* 710 */ 334, 359, 50, 47, 146, 57, 58, 48, 580, 579,
108342 /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108343 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108344 /* 740 */ 310, 411, 129, 414, 595, 22, 273, 156, 411, 566,
108345 /* 750 */ 406, 213, 599, 95, 570, 570, 414, 327, 169, 332,
108346 /* 760 */ 411, 618, 536, 414, 358, 599, 104, 483, 508, 356,
108347 /* 770 */ 588, 582, 599, 103, 484, 414, 470, 357, 166, 618,
108348 /* 780 */ 626, 2, 204, 323, 599, 105, 40, 528, 38, 57,
108349 /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108350 /* 800 */ 56, 56, 411, 54, 54, 54, 54, 53, 53, 52,
108351 /* 810 */ 52, 52, 51, 233, 310, 411, 598, 414, 411, 260,
108352 /* 820 */ 273, 273, 273, 273, 426, 305, 599, 106, 520, 519,
108353 /* 830 */ 414, 411, 142, 414, 618, 618, 618, 618, 618, 599,
108354 /* 840 */ 133, 339, 599, 134, 588, 582, 414, 21, 30, 316,
108355 /* 850 */ 147, 459, 221, 170, 527, 599, 98, 222, 322, 321,
108356 /* 860 */ 320, 141, 259, 57, 58, 48, 580, 579, 581, 581,
108357 /* 870 */ 55, 55, 56, 56, 56, 56, 411, 54, 54, 54,
108358 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 411,
108359 /* 890 */ 260, 414, 411, 458, 200, 35, 411, 358, 211, 228,
108360 /* 900 */ 599, 102, 468, 519, 414, 618, 28, 414, 538, 501,
108361 /* 910 */ 411, 414, 618, 599, 101, 358, 599, 93, 588, 582,
108362 /* 920 */ 599, 100, 522, 618, 427, 414, 306, 271, 598, 380,
108363 /* 930 */ 618, 602, 598, 452, 599, 77, 210, 57, 58, 48,
108364 /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108365 /* 950 */ 411, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108366 /* 960 */ 51, 233, 310, 411, 621, 414, 411, 127, 609, 270,
108367 /* 970 */ 598, 365, 51, 233, 599, 96, 625, 330, 414, 618,
108368 /* 980 */ 126, 414, 411, 618, 411, 253, 608, 599, 137, 27,
108369 /* 990 */ 599, 136, 588, 582, 375, 260, 125, 414, 164, 414,
108370 /* 1000 */ 371, 618, 279, 219, 542, 542, 599, 135, 599, 76,
108371 /* 1010 */ 618, 57, 46, 48, 580, 579, 581, 581, 55, 55,
108372 /* 1020 */ 56, 56, 56, 56, 411, 54, 54, 54, 54, 53,
108373 /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 411, 450, 414,
108374 /* 1040 */ 411, 260, 542, 229, 285, 607, 479, 184, 599, 90,
108375 /* 1050 */ 367, 122, 414, 476, 121, 414, 618, 170, 411, 353,
108376 /* 1060 */ 618, 599, 89, 410, 599, 75, 588, 582, 472, 257,
108377 /* 1070 */ 538, 120, 159, 414, 618, 14, 464, 158, 618, 157,
108378 /* 1080 */ 461, 283, 599, 88, 449, 618, 58, 48, 580, 579,
108379 /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108380 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108381 /* 1110 */ 310, 411, 260, 414, 411, 592, 260, 118, 25, 400,
108382 /* 1120 */ 10, 24, 599, 87, 117, 216, 414, 618, 349, 414,
108383 /* 1130 */ 618, 618, 411, 319, 618, 599, 99, 555, 599, 86,
108384 /* 1140 */ 588, 582, 4, 260, 457, 455, 115, 414, 251, 154,
108385 /* 1150 */ 451, 108, 618, 110, 436, 448, 599, 17, 618, 218,
108386 /* 1160 */ 107, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108387 /* 1170 */ 56, 56, 435, 54, 54, 54, 54, 53, 53, 52,
108388 /* 1180 */ 52, 52, 51, 233, 44, 405, 217, 3, 411, 260,
108389 /* 1190 */ 543, 415, 619, 445, 64, 149, 539, 237, 333, 329,
108390 /* 1200 */ 203, 187, 408, 414, 618, 618, 420, 44, 405, 411,
108391 /* 1210 */ 3, 618, 599, 85, 415, 619, 148, 227, 622, 179,
108392 /* 1220 */ 313, 403, 312, 612, 414, 408, 611, 124, 417, 178,
108393 /* 1230 */ 610, 564, 243, 599, 84, 537, 8, 176, 235, 416,
108394 /* 1240 */ 294, 418, 623, 30, 403, 597, 411, 236, 293, 123,
108395 /* 1250 */ 618, 41, 42, 532, 564, 205, 292, 275, 43, 413,
108396 /* 1260 */ 412, 414, 395, 593, 507, 274, 31, 397, 291, 37,
108397 /* 1270 */ 599, 83, 618, 491, 41, 42, 267, 411, 265, 618,
108398 /* 1280 */ 618, 43, 413, 412, 596, 263, 593, 60, 618, 598,
108399 /* 1290 */ 261, 618, 414, 618, 591, 591, 591, 590, 589, 13,
108400 /* 1300 */ 618, 599, 72, 554, 235, 618, 44, 405, 256, 3,
108401 /* 1310 */ 361, 172, 340, 415, 619, 230, 411, 591, 591, 591,
108402 /* 1320 */ 590, 589, 13, 618, 408, 618, 182, 411, 286, 34,
108403 /* 1330 */ 405, 414, 3, 411, 463, 411, 415, 619, 29, 331,
108404 /* 1340 */ 599, 71, 414, 403, 392, 386, 284, 408, 414, 618,
108405 /* 1350 */ 414, 599, 82, 564, 411, 462, 354, 599, 81, 599,
108406 /* 1360 */ 80, 541, 250, 535, 282, 521, 403, 534, 516, 414,
108407 /* 1370 */ 618, 618, 454, 41, 42, 411, 564, 618, 599, 70,
108408 /* 1380 */ 43, 413, 412, 444, 515, 593, 242, 618, 325, 61,
108409 /* 1390 */ 414, 277, 239, 620, 619, 238, 41, 42, 618, 599,
108410 /* 1400 */ 18, 618, 512, 43, 413, 412, 511, 618, 593, 430,
108411 /* 1410 */ 618, 411, 128, 510, 308, 226, 591, 591, 591, 590,
108412 /* 1420 */ 589, 13, 215, 289, 618, 225, 414, 302, 301, 300,
108413 /* 1430 */ 177, 298, 411, 564, 453, 599, 79, 224, 618, 591,
108414 /* 1440 */ 591, 591, 590, 589, 13, 389, 492, 414, 150, 144,
108415 /* 1450 */ 241, 393, 288, 191, 190, 193, 599, 78, 165, 240,
108416 /* 1460 */ 414, 524, 487, 307, 618, 593, 618, 618, 486, 599,
108417 /* 1470 */ 9, 163, 152, 485, 466, 372, 480, 162, 153, 370,
108418 /* 1480 */ 161, 151, 209, 478, 258, 368, 477, 26, 160, 467,
108419 /* 1490 */ 140, 362, 131, 119, 116, 456, 591, 591, 591, 155,
108420 /* 1500 */ 114, 344, 343, 113, 112, 111, 447, 109, 130, 23,
108421 /* 1510 */ 317, 433, 20, 432, 431, 428, 606, 594, 63, 189,
108422 /* 1520 */ 404, 571, 255, 342, 244, 295, 287, 278, 311, 508,
108423 /* 1530 */ 496, 497, 495, 235, 493, 568, 379, 355, 460, 245,
108424 /* 1540 */ 341, 446, 303, 567, 5, 252, 548, 208, 139, 506,
108425 /* 1550 */ 369, 401, 500, 499, 296, 525, 335, 488, 482, 523,
108426 /* 1560 */ 233,
 
108427 };
108428 static const YYCODETYPE yy_lookahead[] = {
108429 /* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108430 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108431 /* 20 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 1,
108432 /* 30 */ 49, 50, 77, 78, 79, 80, 155, 82, 83, 84,
108433 /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 15, 68,
108434 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108435 /* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108436 /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 1, 25,
108437 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108438 /* 90 */ 91, 92, 86, 87, 88, 89, 90, 91, 92, 150,
108439 /* 100 */ 23, 150, 25, 116, 49, 50, 177, 158, 227, 54,
108440 /* 110 */ 161, 162, 231, 22, 165, 128, 165, 26, 27, 160,
108441 /* 120 */ 22, 170, 171, 68, 69, 70, 71, 72, 73, 74,
108442 /* 130 */ 75, 76, 77, 78, 79, 80, 23, 82, 83, 84,
108443 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108444 /* 150 */ 221, 222, 223, 194, 97, 98, 99, 100, 101, 102,
108445 /* 160 */ 150, 32, 26, 27, 26, 27, 109, 22, 150, 150,
108446 /* 170 */ 41, 161, 162, 96, 76, 165, 217, 150, 49, 50,
108447 /* 180 */ 229, 230, 172, 165, 165, 94, 95, 118, 170, 171,
108448 /* 190 */ 118, 232, 165, 174, 175, 185, 237, 68, 69, 70,
108449 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108450 /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108451 /* 220 */ 91, 92, 19, 11, 86, 87, 19, 24, 7, 8,
108452 /* 230 */ 94, 95, 94, 95, 215, 97, 150, 22, 98, 220,
108453 /* 240 */ 150, 26, 104, 216, 106, 26, 27, 229, 230, 109,
108454 /* 250 */ 160, 165, 49, 50, 25, 165, 120, 50, 22, 197,
108455 /* 260 */ 174, 175, 26, 27, 174, 175, 204, 129, 130, 57,
108456 /* 270 */ 66, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108457 /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108458 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 94, 86,
108459 /* 300 */ 87, 215, 98, 25, 12, 215, 220, 160, 118, 94,
108460 /* 310 */ 220, 104, 165, 94, 95, 88, 109, 105, 106, 107,
108461 /* 320 */ 28, 174, 175, 26, 27, 22, 49, 50, 116, 57,
108462 /* 330 */ 94, 95, 103, 129, 130, 131, 44, 113, 46, 120,
108463 /* 340 */ 113, 194, 129, 130, 117, 68, 69, 70, 71, 72,
108464 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 177, 82,
108465 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108466 /* 370 */ 19, 163, 150, 95, 166, 167, 168, 105, 106, 107,
108467 /* 380 */ 105, 106, 107, 49, 50, 88, 113, 165, 116, 118,
108468 /* 390 */ 117, 94, 95, 150, 26, 27, 174, 175, 120, 23,
108469 /* 400 */ 49, 50, 221, 222, 223, 71, 72, 21, 165, 16,
108470 /* 410 */ 23, 166, 22, 136, 22, 23, 11, 174, 175, 68,
108471 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108472 /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
108473 /* 440 */ 89, 90, 91, 92, 19, 12, 224, 23, 23, 63,
108474 /* 450 */ 205, 23, 23, 60, 25, 62, 150, 214, 150, 67,
108475 /* 460 */ 22, 28, 94, 95, 96, 23, 221, 222, 223, 23,
108476 /* 470 */ 23, 165, 25, 165, 49, 50, 23, 44, 25, 46,
108477 /* 480 */ 174, 175, 174, 175, 23, 26, 100, 136, 25, 112,
108478 /* 490 */ 57, 114, 115, 68, 69, 70, 71, 72, 73, 74,
108479 /* 500 */ 75, 76, 77, 78, 79, 80, 97, 82, 83, 84,
108480 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 22,
108481 /* 520 */ 23, 215, 23, 215, 138, 116, 50, 23, 30, 25,
108482 /* 530 */ 36, 138, 34, 99, 100, 101, 112, 128, 114, 115,
108483 /* 540 */ 112, 23, 114, 115, 110, 51, 48, 173, 49, 50,
108484 /* 550 */ 26, 27, 58, 94, 112, 181, 114, 115, 112, 16,
108485 /* 560 */ 114, 115, 22, 23, 67, 25, 160, 68, 69, 70,
108486 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108487 /* 580 */ 104, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108488 /* 590 */ 91, 92, 19, 19, 22, 23, 23, 25, 23, 95,
108489 /* 600 */ 194, 27, 108, 60, 25, 62, 150, 67, 169, 170,
108490 /* 610 */ 171, 35, 206, 207, 150, 221, 222, 223, 94, 95,
108491 /* 620 */ 160, 165, 49, 50, 120, 161, 162, 206, 207, 165,
108492 /* 630 */ 174, 175, 97, 98, 160, 241, 105, 106, 107, 67,
108493 /* 640 */ 25, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108494 /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108495 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 230,
108496 /* 670 */ 23, 7, 8, 9, 24, 150, 26, 35, 150, 219,
108497 /* 680 */ 150, 25, 165, 142, 143, 144, 145, 0, 1, 2,
108498 /* 690 */ 165, 217, 32, 165, 150, 165, 49, 50, 119, 174,
108499 /* 700 */ 175, 41, 174, 175, 174, 175, 23, 120, 25, 165,
108500 /* 710 */ 193, 237, 221, 222, 223, 68, 69, 70, 71, 72,
108501 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108502 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108503 /* 740 */ 19, 150, 22, 165, 94, 24, 150, 25, 150, 166,
108504 /* 750 */ 167, 168, 174, 175, 129, 130, 165, 213, 35, 242,
108505 /* 760 */ 150, 165, 27, 165, 150, 174, 175, 181, 182, 19,
108506 /* 770 */ 49, 50, 174, 175, 188, 165, 23, 27, 25, 165,
108507 /* 780 */ 144, 145, 160, 187, 174, 175, 135, 23, 137, 68,
108508 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108509 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108510 /* 810 */ 89, 90, 91, 92, 19, 150, 194, 165, 150, 150,
108511 /* 820 */ 150, 150, 150, 150, 247, 248, 174, 175, 190, 191,
108512 /* 830 */ 165, 150, 118, 165, 165, 165, 165, 165, 165, 174,
108513 /* 840 */ 175, 219, 174, 175, 49, 50, 165, 52, 126, 245,
108514 /* 850 */ 246, 23, 238, 25, 23, 174, 175, 187, 187, 187,
108515 /* 860 */ 187, 39, 193, 68, 69, 70, 71, 72, 73, 74,
108516 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108517 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108518 /* 890 */ 150, 165, 150, 23, 160, 25, 150, 150, 160, 52,
108519 /* 900 */ 174, 175, 190, 191, 165, 165, 22, 165, 150, 29,
108520 /* 910 */ 150, 165, 165, 174, 175, 150, 174, 175, 49, 50,
108521 /* 920 */ 174, 175, 165, 165, 23, 165, 25, 25, 194, 52,
108522 /* 930 */ 165, 174, 194, 193, 174, 175, 160, 68, 69, 70,
108523 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108524 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108525 /* 960 */ 91, 92, 19, 150, 150, 165, 150, 22, 150, 23,
108526 /* 970 */ 194, 213, 91, 92, 174, 175, 1, 2, 165, 165,
108527 /* 980 */ 22, 165, 150, 165, 150, 238, 150, 174, 175, 22,
108528 /* 990 */ 174, 175, 49, 50, 52, 150, 22, 165, 102, 165,
108529 /* 1000 */ 19, 165, 109, 238, 166, 166, 174, 175, 174, 175,
108530 /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108531 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108532 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108533 /* 1040 */ 150, 150, 166, 205, 205, 150, 20, 24, 174, 175,
108534 /* 1050 */ 43, 104, 165, 59, 53, 165, 165, 25, 150, 150,
108535 /* 1060 */ 165, 174, 175, 150, 174, 175, 49, 50, 53, 138,
108536 /* 1070 */ 150, 22, 104, 165, 165, 5, 1, 118, 165, 35,
108537 /* 1080 */ 27, 205, 174, 175, 193, 165, 69, 70, 71, 72,
108538 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108539 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108540 /* 1110 */ 19, 150, 150, 165, 150, 150, 150, 108, 76, 150,
108541 /* 1120 */ 22, 76, 174, 175, 127, 216, 165, 165, 25, 165,
108542 /* 1130 */ 165, 165, 150, 213, 165, 174, 175, 150, 174, 175,
108543 /* 1140 */ 49, 50, 22, 150, 23, 1, 119, 165, 16, 121,
108544 /* 1150 */ 20, 108, 165, 119, 23, 193, 174, 175, 165, 193,
108545 /* 1160 */ 127, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108546 /* 1170 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108547 /* 1180 */ 89, 90, 91, 92, 19, 20, 193, 22, 150, 150,
108548 /* 1190 */ 150, 26, 27, 128, 16, 15, 150, 140, 65, 3,
108549 /* 1200 */ 164, 22, 37, 165, 165, 165, 4, 19, 20, 150,
108550 /* 1210 */ 22, 165, 174, 175, 26, 27, 246, 180, 149, 6,
108551 /* 1220 */ 249, 56, 249, 149, 165, 37, 149, 180, 149, 151,
108552 /* 1230 */ 13, 66, 193, 174, 175, 150, 25, 151, 116, 159,
108553 /* 1240 */ 199, 146, 147, 126, 56, 194, 150, 152, 200, 154,
108554 /* 1250 */ 165, 86, 87, 88, 66, 160, 201, 150, 93, 94,
108555 /* 1260 */ 95, 165, 123, 98, 150, 150, 124, 122, 202, 135,
108556 /* 1270 */ 174, 175, 165, 150, 86, 87, 150, 150, 150, 165,
108557 /* 1280 */ 165, 93, 94, 95, 203, 150, 98, 125, 165, 194,
108558 /* 1290 */ 150, 165, 165, 165, 129, 130, 131, 132, 133, 134,
108559 /* 1300 */ 165, 174, 175, 157, 116, 165, 19, 20, 150, 22,
108560 /* 1310 */ 150, 118, 217, 26, 27, 225, 150, 129, 130, 131,
108561 /* 1320 */ 132, 133, 134, 165, 37, 165, 157, 150, 210, 19,
108562 /* 1330 */ 20, 165, 22, 150, 150, 150, 26, 27, 104, 244,
108563 /* 1340 */ 174, 175, 165, 56, 121, 104, 210, 37, 165, 165,
108564 /* 1350 */ 165, 174, 175, 66, 150, 150, 150, 174, 175, 174,
108565 /* 1360 */ 175, 211, 150, 211, 210, 176, 56, 211, 176, 165,
108566 /* 1370 */ 165, 165, 150, 86, 87, 150, 66, 165, 174, 175,
108567 /* 1380 */ 93, 94, 95, 150, 184, 98, 150, 165, 47, 22,
108568 /* 1390 */ 165, 176, 150, 26, 27, 150, 86, 87, 165, 174,
108569 /* 1400 */ 175, 165, 178, 93, 94, 95, 103, 165, 98, 150,
108570 /* 1410 */ 165, 150, 22, 176, 179, 228, 129, 130, 131, 132,
108571 /* 1420 */ 133, 134, 5, 150, 165, 92, 165, 10, 11, 12,
108572 /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 228, 165, 129,
108573 /* 1440 */ 130, 131, 132, 133, 134, 150, 184, 165, 31, 150,
108574 /* 1450 */ 33, 150, 150, 86, 87, 172, 174, 175, 96, 42,
108575 /* 1460 */ 165, 94, 176, 179, 165, 98, 165, 165, 176, 174,
108576 /* 1470 */ 175, 156, 55, 176, 57, 18, 157, 156, 61, 157,
108577 /* 1480 */ 156, 64, 157, 157, 235, 45, 236, 135, 156, 189,
108578 /* 1490 */ 68, 157, 218, 189, 22, 199, 129, 130, 131, 156,
108579 /* 1500 */ 192, 157, 18, 192, 192, 192, 199, 189, 218, 240,
108580 /* 1510 */ 157, 40, 240, 157, 157, 38, 153, 166, 243, 196,
108581 /* 1520 */ 226, 230, 105, 106, 107, 198, 209, 177, 111, 182,
108582 /* 1530 */ 166, 177, 177, 116, 166, 230, 178, 239, 199, 209,
108583 /* 1540 */ 209, 199, 148, 166, 196, 239, 208, 233, 172, 183,
108584 /* 1550 */ 234, 191, 183, 183, 195, 174, 139, 186, 186, 174,
108585 /* 1560 */ 92,
 
108586 };
108587 #define YY_SHIFT_USE_DFLT (-70)
108588 #define YY_SHIFT_COUNT (418)
108589 #define YY_SHIFT_MIN (-69)
108590 #define YY_SHIFT_MAX (1484)
108591 static const short yy_shift_ofst[] = {
108592 /* 0 */ 975, 1188, 1417, 1188, 1287, 1287, 138, 138, 368, -19,
108593 /* 10 */ 1287, 1287, 1287, 1287, 272, 524, 129, 129, 795, 1165,
108594 /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108595 /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108596 /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108597 /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108598 /* 60 */ 1287, 1287, 212, 524, 524, 213, 213, 459, 1122, 55,
108599 /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108600 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108601 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108602 /* 100 */ -45, -45, -45, -45, -1, 6, -64, 524, 524, 524,
108603 /* 110 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108604 /* 120 */ 524, 524, 524, 386, 207, 524, 524, 524, 524, 524,
108605 /* 130 */ 409, -13, 459, 881, 1468, -70, -70, -70, 1367, 57,
108606 /* 140 */ 433, 433, 297, 236, 219, 136, 91, 572, 540, 524,
108607 /* 150 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108608 /* 160 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108609 /* 170 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108610 /* 180 */ 650, 650, 650, 687, 1122, 1122, 1122, -70, -70, -70,
108611 /* 190 */ 204, 204, 434, 434, 494, 494, 494, 504, 446, 292,
108612 /* 200 */ 442, 428, 424, 77, 377, 377, 377, 377, 531, 498,
108613 /* 210 */ 377, 377, 278, 215, 227, 664, 722, 574, 574, 750,
108614 /* 220 */ 722, 750, 229, 459, 660, 459, 660, 476, 660, 574,
108615 /* 230 */ 651, 625, 625, 459, 579, 273, -18, 1477, 1193, 1193,
108616 /* 240 */ 1471, 1471, 1193, 1472, 1422, 1117, 1484, 1484, 1484, 1484,
108617 /* 250 */ 1193, 1457, 1117, 1472, 1422, 1422, 1193, 1457, 1352, 1440,
108618 /* 260 */ 1193, 1193, 1457, 1193, 1457, 1193, 1457, 1390, 1241, 1241,
108619 /* 270 */ 1241, 1362, 1341, 1333, 1333, 1390, 1241, 1303, 1241, 1341,
108620 /* 280 */ 1241, 1241, 1223, 1234, 1223, 1234, 1223, 1234, 1193, 1193,
108621 /* 290 */ 1134, 1162, 1145, 1142, 1139, 1117, 1122, 1211, 1217, 1217,
108622 /* 300 */ 1213, 1213, 1213, 1213, -70, -70, -70, -70, -70, -70,
108623 /* 310 */ 334, 393, 497, 392, 543, 275, 901, 98, 870, 828,
108624 /* 320 */ 753, 683, 453, 447, 535, 221, 140, 429, 54, 1202,
108625 /* 330 */ 1196, 1179, 1057, 1180, 1133, 1178, 1149, 1131, 1065, 1103,
108626 /* 340 */ 1033, 1043, 1034, 1130, 1028, 1132, 1144, 1027, 1121, 1120,
108627 /* 350 */ 1103, 1098, 997, 1045, 1042, 1009, 1053, 1044, 959, 1075,
108628 /* 360 */ 1070, 1049, 968, 931, 1015, 1032, 1001, 994, 1007, 947,
108629 /* 370 */ 1023, 1026, 981, 893, 896, 974, 942, 967, 958, 946,
108630 /* 380 */ 945, 877, 902, 880, 884, 847, 822, 831, 764, 714,
108631 /* 390 */ 735, 723, 720, 587, 615, 642, 656, 576, 615, 575,
108632 /* 400 */ 518, 463, 461, 438, 405, 390, 387, 376, 303, 224,
108633 /* 410 */ 271, 190, 92, 72, 69, 145, 113, 33, 28,
108634 };
108635 #define YY_REDUCE_USE_DFLT (-169)
108636 #define YY_REDUCE_COUNT (309)
108637 #define YY_REDUCE_MIN (-168)
108638 #define YY_REDUCE_MAX (1394)
108639 static const short yy_reduce_ofst[] = {
108640 /* 0 */ 541, 90, 1095, 147, 86, 19, 18, -49, 10, 245,
108641 /* 10 */ 308, 306, 243, 222, -41, -51, 181, -71, 394, 1295,
108642 /* 20 */ 1282, 1261, 1225, 1204, 1185, 1183, 1177, 1166, 1127, 1096,
108643 /* 30 */ 1059, 1038, 982, 964, 961, 948, 908, 890, 887, 874,
108644 /* 40 */ 834, 832, 816, 813, 800, 760, 746, 742, 739, 726,
108645 /* 50 */ 681, 668, 665, 652, 610, 598, 591, 578, 530, 528,
108646 /* 60 */ 525, 456, 474, 464, 517, 439, -168, 208, 406, 491,
108647 /* 70 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108648 /* 80 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108649 /* 90 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108650 /* 100 */ 491, 491, 491, 491, 491, 491, 491, 1039, 909, 993,
108651 /* 110 */ 966, 962, 891, 845, 740, 765, 920, 747, 27, 614,
108652 /* 120 */ 673, 758, 669, -119, 586, 672, 671, 670, 596, 544,
108653 /* 130 */ 622, 460, 583, 491, 491, 491, 491, 491, 757, 374,
108654 /* 140 */ 712, 638, 913, 1302, 1301, 1299, 1273, 577, 577, 1259,
108655 /* 150 */ 1245, 1242, 1236, 1233, 1222, 1212, 1206, 1205, 1184, 1160,
108656 /* 160 */ 1158, 1140, 1135, 1128, 1126, 1123, 1115, 1114, 1107, 1085,
108657 /* 170 */ 1046, 1040, 987, 969, 965, 913, 895, 836, 818, 814,
108658 /* 180 */ 876, 839, 838, 636, 776, 738, 734, 604, 421, 62,
108659 /* 190 */ 1385, 1381, 1372, 1371, 1370, 1369, 1366, 1338, 1359, 1360,
108660 /* 200 */ 1359, 1359, 1359, 1376, 1359, 1359, 1359, 1359, 1316, 1314,
108661 /* 210 */ 1359, 1359, 1338, 1377, 1348, 1394, 1342, 1331, 1330, 1306,
108662 /* 220 */ 1339, 1298, 1358, 1368, 1355, 1364, 1354, 1347, 1350, 1317,
108663 /* 230 */ 1294, 1305, 1291, 1351, 1327, 1323, 1363, 1275, 1357, 1356,
108664 /* 240 */ 1272, 1269, 1353, 1290, 1318, 1307, 1313, 1312, 1311, 1308,
108665 /* 250 */ 1344, 1343, 1296, 1274, 1304, 1300, 1334, 1332, 1250, 1249,
108666 /* 260 */ 1326, 1325, 1324, 1322, 1321, 1319, 1315, 1284, 1297, 1292,
108667 /* 270 */ 1286, 1283, 1262, 1209, 1187, 1235, 1237, 1224, 1215, 1200,
108668 /* 280 */ 1192, 1189, 1156, 1154, 1152, 1136, 1150, 1118, 1169, 1146,
108669 /* 290 */ 1090, 1081, 1066, 1055, 1048, 1041, 1051, 1080, 1086, 1078,
108670 /* 300 */ 1079, 1077, 1074, 1069, 973, 971, 970, 1047, 1037, 1036,
108671 };
108672 static const YYACTIONTYPE yy_default[] = {
108673 /* 0 */ 632, 864, 952, 952, 864, 864, 952, 952, 683, 754,
108674 /* 10 */ 952, 952, 952, 862, 952, 952, 782, 782, 926, 952,
108675 /* 20 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108676 /* 30 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108677 /* 40 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108678 /* 50 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108679 /* 60 */ 952, 952, 952, 952, 952, 952, 952, 671, 758, 788,
108680 /* 70 */ 952, 952, 952, 952, 952, 952, 952, 952, 925, 927,
108681 /* 80 */ 796, 795, 905, 769, 793, 786, 790, 865, 858, 859,
108682 /* 90 */ 857, 861, 866, 952, 789, 825, 842, 824, 836, 841,
108683 /* 100 */ 848, 840, 837, 827, 826, 828, 829, 952, 952, 952,
108684 /* 110 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108685 /* 120 */ 952, 952, 952, 658, 723, 952, 952, 952, 952, 952,
108686 /* 130 */ 952, 952, 952, 830, 831, 845, 844, 843, 952, 952,
108687 /* 140 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108688 /* 150 */ 932, 930, 952, 877, 952, 952, 952, 952, 952, 952,
108689 /* 160 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108690 /* 170 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 638,
108691 /* 180 */ 754, 754, 754, 632, 952, 952, 952, 944, 758, 748,
108692 /* 190 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108693 /* 200 */ 952, 952, 952, 683, 798, 737, 915, 917, 952, 898,
108694 /* 210 */ 735, 660, 756, 673, 746, 640, 792, 771, 771, 910,
108695 /* 220 */ 792, 910, 697, 952, 782, 952, 782, 694, 782, 771,
108696 /* 230 */ 860, 952, 952, 952, 755, 746, 952, 937, 762, 762,
108697 /* 240 */ 929, 929, 762, 804, 727, 792, 734, 734, 734, 734,
108698 /* 250 */ 762, 655, 792, 804, 727, 727, 762, 655, 904, 902,
108699 /* 260 */ 762, 762, 655, 762, 655, 762, 655, 870, 725, 725,
108700 /* 270 */ 725, 683, 712, 874, 874, 870, 725, 697, 725, 712,
108701 /* 280 */ 725, 725, 775, 770, 775, 770, 775, 770, 762, 762,
108702 /* 290 */ 952, 787, 776, 785, 783, 792, 952, 715, 648, 648,
108703 /* 300 */ 637, 637, 637, 637, 949, 949, 944, 699, 699, 681,
108704 /* 310 */ 952, 952, 952, 952, 952, 952, 952, 879, 952, 952,
108705 /* 320 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108706 /* 330 */ 633, 939, 952, 952, 936, 952, 952, 952, 952, 797,
108707 /* 340 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108708 /* 350 */ 914, 952, 952, 952, 952, 952, 952, 952, 908, 952,
108709 /* 360 */ 952, 952, 952, 952, 952, 901, 900, 952, 952, 952,
108710 /* 370 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108711 /* 380 */ 952, 952, 716, 952, 952, 952, 952, 952, 952, 952,
108712 /* 390 */ 952, 952, 952, 952, 784, 952, 777, 952, 863, 952,
108713 /* 400 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 740,
108714 /* 410 */ 813, 952, 812, 816, 811, 665, 952, 646, 952, 629,
108715 /* 420 */ 634, 948, 951, 950, 947, 946, 945, 940, 938, 935,
108716 /* 430 */ 934, 933, 931, 928, 924, 883, 881, 888, 887, 886,
108717 /* 440 */ 885, 884, 882, 880, 878, 799, 794, 791, 923, 876,
108718 /* 450 */ 736, 733, 732, 654, 941, 907, 916, 803, 802, 805,
108719 /* 460 */ 913, 912, 911, 909, 906, 893, 801, 800, 728, 868,
108720 /* 470 */ 867, 657, 897, 896, 895, 899, 903, 894, 764, 656,
108721 /* 480 */ 653, 662, 718, 724, 722, 721, 720, 719, 717, 664,
108722 /* 490 */ 672, 682, 711, 696, 695, 873, 875, 872, 871, 704,
108723 /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
108724 /* 510 */ 692, 698, 691, 714, 713, 710, 690, 731, 730, 729,
108725 /* 520 */ 726, 689, 688, 687, 816, 686, 685, 822, 821, 809,
108726 /* 530 */ 852, 751, 750, 749, 761, 760, 773, 772, 807, 806,
108727 /* 540 */ 774, 759, 753, 752, 768, 767, 766, 765, 757, 747,
108728 /* 550 */ 779, 781, 780, 778, 854, 763, 851, 922, 921, 920,
108729 /* 560 */ 919, 918, 856, 855, 823, 820, 676, 677, 891, 890,
108730 /* 570 */ 892, 889, 679, 678, 675, 674, 853, 742, 741, 849,
108731 /* 580 */ 846, 838, 834, 850, 847, 839, 835, 833, 832, 818,
108732 /* 590 */ 817, 815, 814, 810, 819, 667, 743, 739, 738, 808,
108733 /* 600 */ 745, 744, 684, 680, 661, 659, 652, 650, 649, 651,
108734 /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
108735 /* 620 */ 665, 639, 636, 635, 631, 630, 628,
108736 };
108737
108738 /* The next table maps tokens into fallback tokens. If a construct
108739 ** like the following:
108740 **
@@ -108744,11 +108933,11 @@
108933 "create_table", "create_table_args", "createkw", "temp",
108934 "ifnotexists", "dbnm", "columnlist", "conslist_opt",
108935 "select", "column", "columnid", "type",
108936 "carglist", "id", "ids", "typetoken",
108937 "typename", "signed", "plus_num", "minus_num",
108938 "cname", "ccons", "term", "expr",
108939 "onconf", "sortorder", "autoinc", "idxlist_opt",
108940 "refargs", "defer_subclause", "refarg", "refact",
108941 "init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108942 "defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108943 "ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
109013 /* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
109014 /* 49 */ "typename ::= ids",
109015 /* 50 */ "typename ::= typename ids",
109016 /* 51 */ "signed ::= plus_num",
109017 /* 52 */ "signed ::= minus_num",
109018 /* 53 */ "carglist ::= carglist cname ccons",
109019 /* 54 */ "carglist ::=",
109020 /* 55 */ "cname ::= CONSTRAINT nm",
109021 /* 56 */ "cname ::=",
109022 /* 57 */ "ccons ::= DEFAULT term",
109023 /* 58 */ "ccons ::= DEFAULT LP expr RP",
109024 /* 59 */ "ccons ::= DEFAULT PLUS term",
109025 /* 60 */ "ccons ::= DEFAULT MINUS term",
109026 /* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
109050 /* 85 */ "init_deferred_pred_opt ::=",
109051 /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
109052 /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
109053 /* 88 */ "conslist_opt ::=",
109054 /* 89 */ "conslist_opt ::= COMMA conslist",
109055 /* 90 */ "conslist ::= conslist COMMA cname tcons",
109056 /* 91 */ "conslist ::= cname tcons",
109057 /* 92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
109058 /* 93 */ "tcons ::= UNIQUE LP idxlist RP onconf",
109059 /* 94 */ "tcons ::= CHECK LP expr RP onconf",
109060 /* 95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
109061 /* 96 */ "defer_subclause_opt ::=",
109062 /* 97 */ "defer_subclause_opt ::= defer_subclause",
109063 /* 98 */ "onconf ::=",
109064 /* 99 */ "onconf ::= ON CONFLICT resolvetype",
109065 /* 100 */ "orconf ::=",
109066 /* 101 */ "orconf ::= OR resolvetype",
109067 /* 102 */ "resolvetype ::= raisetype",
109068 /* 103 */ "resolvetype ::= IGNORE",
109069 /* 104 */ "resolvetype ::= REPLACE",
109070 /* 105 */ "cmd ::= DROP TABLE ifexists fullname",
109071 /* 106 */ "ifexists ::= IF EXISTS",
109072 /* 107 */ "ifexists ::=",
109073 /* 108 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
109074 /* 109 */ "cmd ::= DROP VIEW ifexists fullname",
109075 /* 110 */ "cmd ::= select",
109076 /* 111 */ "select ::= oneselect",
109077 /* 112 */ "select ::= select multiselect_op oneselect",
109078 /* 113 */ "multiselect_op ::= UNION",
109079 /* 114 */ "multiselect_op ::= UNION ALL",
109080 /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT",
109081 /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
109082 /* 117 */ "distinct ::= DISTINCT",
109083 /* 118 */ "distinct ::= ALL",
109084 /* 119 */ "distinct ::=",
109085 /* 120 */ "sclp ::= selcollist COMMA",
109086 /* 121 */ "sclp ::=",
109087 /* 122 */ "selcollist ::= sclp expr as",
109088 /* 123 */ "selcollist ::= sclp STAR",
109089 /* 124 */ "selcollist ::= sclp nm DOT STAR",
109090 /* 125 */ "as ::= AS nm",
109091 /* 126 */ "as ::= ids",
109092 /* 127 */ "as ::=",
109093 /* 128 */ "from ::=",
109094 /* 129 */ "from ::= FROM seltablist",
109095 /* 130 */ "stl_prefix ::= seltablist joinop",
109096 /* 131 */ "stl_prefix ::=",
109097 /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
109098 /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
109099 /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
109100 /* 135 */ "dbnm ::=",
109101 /* 136 */ "dbnm ::= DOT nm",
109102 /* 137 */ "fullname ::= nm dbnm",
109103 /* 138 */ "joinop ::= COMMA|JOIN",
109104 /* 139 */ "joinop ::= JOIN_KW JOIN",
109105 /* 140 */ "joinop ::= JOIN_KW nm JOIN",
109106 /* 141 */ "joinop ::= JOIN_KW nm nm JOIN",
109107 /* 142 */ "on_opt ::= ON expr",
109108 /* 143 */ "on_opt ::=",
109109 /* 144 */ "indexed_opt ::=",
109110 /* 145 */ "indexed_opt ::= INDEXED BY nm",
109111 /* 146 */ "indexed_opt ::= NOT INDEXED",
109112 /* 147 */ "using_opt ::= USING LP inscollist RP",
109113 /* 148 */ "using_opt ::=",
109114 /* 149 */ "orderby_opt ::=",
109115 /* 150 */ "orderby_opt ::= ORDER BY sortlist",
109116 /* 151 */ "sortlist ::= sortlist COMMA expr sortorder",
109117 /* 152 */ "sortlist ::= expr sortorder",
109118 /* 153 */ "sortorder ::= ASC",
109119 /* 154 */ "sortorder ::= DESC",
109120 /* 155 */ "sortorder ::=",
109121 /* 156 */ "groupby_opt ::=",
109122 /* 157 */ "groupby_opt ::= GROUP BY nexprlist",
109123 /* 158 */ "having_opt ::=",
109124 /* 159 */ "having_opt ::= HAVING expr",
109125 /* 160 */ "limit_opt ::=",
109126 /* 161 */ "limit_opt ::= LIMIT expr",
109127 /* 162 */ "limit_opt ::= LIMIT expr OFFSET expr",
109128 /* 163 */ "limit_opt ::= LIMIT expr COMMA expr",
109129 /* 164 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
109130 /* 165 */ "where_opt ::=",
109131 /* 166 */ "where_opt ::= WHERE expr",
109132 /* 167 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
109133 /* 168 */ "setlist ::= setlist COMMA nm EQ expr",
109134 /* 169 */ "setlist ::= nm EQ expr",
109135 /* 170 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
109136 /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
109137 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
109138 /* 173 */ "insert_cmd ::= INSERT orconf",
109139 /* 174 */ "insert_cmd ::= REPLACE",
109140 /* 175 */ "valuelist ::= VALUES LP nexprlist RP",
109141 /* 176 */ "valuelist ::= valuelist COMMA LP exprlist RP",
109142 /* 177 */ "inscollist_opt ::=",
109143 /* 178 */ "inscollist_opt ::= LP inscollist RP",
109144 /* 179 */ "inscollist ::= inscollist COMMA nm",
109145 /* 180 */ "inscollist ::= nm",
109146 /* 181 */ "expr ::= term",
109147 /* 182 */ "expr ::= LP expr RP",
109148 /* 183 */ "term ::= NULL",
109149 /* 184 */ "expr ::= id",
109150 /* 185 */ "expr ::= JOIN_KW",
109151 /* 186 */ "expr ::= nm DOT nm",
109152 /* 187 */ "expr ::= nm DOT nm DOT nm",
109153 /* 188 */ "term ::= INTEGER|FLOAT|BLOB",
109154 /* 189 */ "term ::= STRING",
109155 /* 190 */ "expr ::= REGISTER",
109156 /* 191 */ "expr ::= VARIABLE",
109157 /* 192 */ "expr ::= expr COLLATE ids",
109158 /* 193 */ "expr ::= CAST LP expr AS typetoken RP",
109159 /* 194 */ "expr ::= ID LP distinct exprlist RP",
109160 /* 195 */ "expr ::= ID LP STAR RP",
109161 /* 196 */ "term ::= CTIME_KW",
109162 /* 197 */ "expr ::= expr AND expr",
109163 /* 198 */ "expr ::= expr OR expr",
109164 /* 199 */ "expr ::= expr LT|GT|GE|LE expr",
109165 /* 200 */ "expr ::= expr EQ|NE expr",
109166 /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
109167 /* 202 */ "expr ::= expr PLUS|MINUS expr",
109168 /* 203 */ "expr ::= expr STAR|SLASH|REM expr",
109169 /* 204 */ "expr ::= expr CONCAT expr",
109170 /* 205 */ "likeop ::= LIKE_KW",
109171 /* 206 */ "likeop ::= NOT LIKE_KW",
109172 /* 207 */ "likeop ::= MATCH",
109173 /* 208 */ "likeop ::= NOT MATCH",
109174 /* 209 */ "expr ::= expr likeop expr",
109175 /* 210 */ "expr ::= expr likeop expr ESCAPE expr",
109176 /* 211 */ "expr ::= expr ISNULL|NOTNULL",
109177 /* 212 */ "expr ::= expr NOT NULL",
109178 /* 213 */ "expr ::= expr IS expr",
109179 /* 214 */ "expr ::= expr IS NOT expr",
109180 /* 215 */ "expr ::= NOT expr",
109181 /* 216 */ "expr ::= BITNOT expr",
109182 /* 217 */ "expr ::= MINUS expr",
109183 /* 218 */ "expr ::= PLUS expr",
109184 /* 219 */ "between_op ::= BETWEEN",
109185 /* 220 */ "between_op ::= NOT BETWEEN",
109186 /* 221 */ "expr ::= expr between_op expr AND expr",
109187 /* 222 */ "in_op ::= IN",
109188 /* 223 */ "in_op ::= NOT IN",
109189 /* 224 */ "expr ::= expr in_op LP exprlist RP",
109190 /* 225 */ "expr ::= LP select RP",
109191 /* 226 */ "expr ::= expr in_op LP select RP",
109192 /* 227 */ "expr ::= expr in_op nm dbnm",
109193 /* 228 */ "expr ::= EXISTS LP select RP",
109194 /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END",
109195 /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109196 /* 231 */ "case_exprlist ::= WHEN expr THEN expr",
109197 /* 232 */ "case_else ::= ELSE expr",
109198 /* 233 */ "case_else ::=",
109199 /* 234 */ "case_operand ::= expr",
109200 /* 235 */ "case_operand ::=",
109201 /* 236 */ "exprlist ::= nexprlist",
109202 /* 237 */ "exprlist ::=",
109203 /* 238 */ "nexprlist ::= nexprlist COMMA expr",
109204 /* 239 */ "nexprlist ::= expr",
109205 /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109206 /* 241 */ "uniqueflag ::= UNIQUE",
109207 /* 242 */ "uniqueflag ::=",
109208 /* 243 */ "idxlist_opt ::=",
109209 /* 244 */ "idxlist_opt ::= LP idxlist RP",
109210 /* 245 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109211 /* 246 */ "idxlist ::= nm collate sortorder",
109212 /* 247 */ "collate ::=",
109213 /* 248 */ "collate ::= COLLATE ids",
109214 /* 249 */ "cmd ::= DROP INDEX ifexists fullname",
109215 /* 250 */ "cmd ::= VACUUM",
109216 /* 251 */ "cmd ::= VACUUM nm",
109217 /* 252 */ "cmd ::= PRAGMA nm dbnm",
109218 /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109219 /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109220 /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109221 /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109222 /* 257 */ "nmnum ::= plus_num",
109223 /* 258 */ "nmnum ::= nm",
109224 /* 259 */ "nmnum ::= ON",
109225 /* 260 */ "nmnum ::= DELETE",
109226 /* 261 */ "nmnum ::= DEFAULT",
109227 /* 262 */ "plus_num ::= PLUS number",
109228 /* 263 */ "plus_num ::= number",
109229 /* 264 */ "minus_num ::= MINUS number",
109230 /* 265 */ "number ::= INTEGER|FLOAT",
109231 /* 266 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109232 /* 267 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109233 /* 268 */ "trigger_time ::= BEFORE",
109234 /* 269 */ "trigger_time ::= AFTER",
109235 /* 270 */ "trigger_time ::= INSTEAD OF",
109236 /* 271 */ "trigger_time ::=",
109237 /* 272 */ "trigger_event ::= DELETE|INSERT",
109238 /* 273 */ "trigger_event ::= UPDATE",
109239 /* 274 */ "trigger_event ::= UPDATE OF inscollist",
109240 /* 275 */ "foreach_clause ::=",
109241 /* 276 */ "foreach_clause ::= FOR EACH ROW",
109242 /* 277 */ "when_clause ::=",
109243 /* 278 */ "when_clause ::= WHEN expr",
109244 /* 279 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109245 /* 280 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109246 /* 281 */ "trnm ::= nm",
109247 /* 282 */ "trnm ::= nm DOT nm",
109248 /* 283 */ "tridxby ::=",
109249 /* 284 */ "tridxby ::= INDEXED BY nm",
109250 /* 285 */ "tridxby ::= NOT INDEXED",
109251 /* 286 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109252 /* 287 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109253 /* 288 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109254 /* 289 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109255 /* 290 */ "trigger_cmd ::= select",
109256 /* 291 */ "expr ::= RAISE LP IGNORE RP",
109257 /* 292 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109258 /* 293 */ "raisetype ::= ROLLBACK",
109259 /* 294 */ "raisetype ::= ABORT",
109260 /* 295 */ "raisetype ::= FAIL",
109261 /* 296 */ "cmd ::= DROP TRIGGER ifexists fullname",
109262 /* 297 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109263 /* 298 */ "cmd ::= DETACH database_kw_opt expr",
109264 /* 299 */ "key_opt ::=",
109265 /* 300 */ "key_opt ::= KEY expr",
109266 /* 301 */ "database_kw_opt ::= DATABASE",
109267 /* 302 */ "database_kw_opt ::=",
109268 /* 303 */ "cmd ::= REINDEX",
109269 /* 304 */ "cmd ::= REINDEX nm dbnm",
109270 /* 305 */ "cmd ::= ANALYZE",
109271 /* 306 */ "cmd ::= ANALYZE nm dbnm",
109272 /* 307 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109273 /* 308 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109274 /* 309 */ "add_column_fullname ::= fullname",
109275 /* 310 */ "kwcolumn_opt ::=",
109276 /* 311 */ "kwcolumn_opt ::= COLUMNKW",
109277 /* 312 */ "cmd ::= create_vtab",
109278 /* 313 */ "cmd ::= create_vtab LP vtabarglist RP",
109279 /* 314 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109280 /* 315 */ "vtabarglist ::= vtabarg",
109281 /* 316 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109282 /* 317 */ "vtabarg ::=",
109283 /* 318 */ "vtabarg ::= vtabarg vtabargtoken",
109284 /* 319 */ "vtabargtoken ::= ANY",
109285 /* 320 */ "vtabargtoken ::= lp anylist RP",
109286 /* 321 */ "lp ::= LP",
109287 /* 322 */ "anylist ::=",
109288 /* 323 */ "anylist ::= anylist LP anylist RP",
109289 /* 324 */ "anylist ::= anylist ANY",
 
 
109290 };
109291 #endif /* NDEBUG */
109292
109293
109294 #if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109730 { 167, 6 },
109731 { 168, 1 },
109732 { 168, 2 },
109733 { 169, 1 },
109734 { 169, 1 },
109735 { 164, 3 },
109736 { 164, 0 },
109737 { 172, 2 },
109738 { 172, 0 },
109739 { 173, 2 },
109740 { 173, 4 },
109741 { 173, 3 },
109742 { 173, 3 },
109743 { 173, 2 },
@@ -109580,14 +109767,12 @@
109767 { 184, 0 },
109768 { 184, 2 },
109769 { 184, 2 },
109770 { 159, 0 },
109771 { 159, 2 },
109772 { 185, 4 },
109773 { 185, 2 },
 
 
109774 { 186, 7 },
109775 { 186, 5 },
109776 { 186, 5 },
109777 { 186, 10 },
109778 { 188, 0 },
@@ -109892,12 +110077,12 @@
110077 {yygotominor.yy392 = TK_DEFERRED;}
110078 break;
110079 case 14: /* transtype ::= DEFERRED */
110080 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
110081 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
110082 case 113: /* multiselect_op ::= UNION */ yytestcase(yyruleno==113);
110083 case 115: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==115);
110084 {yygotominor.yy392 = yymsp[0].major;}
110085 break;
110086 case 17: /* cmd ::= COMMIT trans_opt */
110087 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
110088 {sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
110120 case 31: /* temp ::= */ yytestcase(yyruleno==31);
110121 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
110122 case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
110123 case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
110124 case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
110125 case 96: /* defer_subclause_opt ::= */ yytestcase(yyruleno==96);
110126 case 107: /* ifexists ::= */ yytestcase(yyruleno==107);
110127 case 118: /* distinct ::= ALL */ yytestcase(yyruleno==118);
110128 case 119: /* distinct ::= */ yytestcase(yyruleno==119);
110129 case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219);
110130 case 222: /* in_op ::= IN */ yytestcase(yyruleno==222);
110131 {yygotominor.yy392 = 0;}
110132 break;
110133 case 29: /* ifnotexists ::= IF NOT EXISTS */
110134 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
110135 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
110136 case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
110137 case 106: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==106);
110138 case 117: /* distinct ::= DISTINCT */ yytestcase(yyruleno==117);
110139 case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220);
110140 case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223);
110141 {yygotominor.yy392 = 1;}
110142 break;
110143 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
110144 {
110145 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
110169 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
110170 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
110171 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
110172 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
110173 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
110174 case 125: /* as ::= AS nm */ yytestcase(yyruleno==125);
110175 case 126: /* as ::= ids */ yytestcase(yyruleno==126);
110176 case 136: /* dbnm ::= DOT nm */ yytestcase(yyruleno==136);
110177 case 145: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==145);
110178 case 248: /* collate ::= COLLATE ids */ yytestcase(yyruleno==248);
110179 case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257);
110180 case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258);
110181 case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259);
110182 case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260);
110183 case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261);
110184 case 262: /* plus_num ::= PLUS number */ yytestcase(yyruleno==262);
110185 case 263: /* plus_num ::= number */ yytestcase(yyruleno==263);
110186 case 264: /* minus_num ::= MINUS number */ yytestcase(yyruleno==264);
110187 case 265: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==265);
110188 case 281: /* trnm ::= nm */ yytestcase(yyruleno==281);
110189 {yygotominor.yy0 = yymsp[0].minor.yy0;}
110190 break;
110191 case 45: /* type ::= typetoken */
110192 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110193 break;
@@ -110018,10 +110203,16 @@
110203 yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110204 }
110205 break;
110206 case 50: /* typename ::= typename ids */
110207 {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
110208 break;
110209 case 55: /* cname ::= CONSTRAINT nm */
110210 {pParse->constraintName = yymsp[0].minor.yy0;}
110211 break;
110212 case 56: /* cname ::= */
110213 {pParse->constraintName.n = 0;}
110214 break;
110215 case 57: /* ccons ::= DEFAULT term */
110216 case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110217 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110218 break;
@@ -110095,80 +110286,80 @@
110286 break;
110287 case 82: /* refact ::= NO ACTION */
110288 { yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110289 break;
110290 case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110291 case 97: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==97);
110292 case 99: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==99);
110293 case 102: /* resolvetype ::= raisetype */ yytestcase(yyruleno==102);
110294 {yygotominor.yy392 = yymsp[0].minor.yy392;}
110295 break;
110296 case 88: /* conslist_opt ::= */
110297 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110298 break;
110299 case 89: /* conslist_opt ::= COMMA conslist */
110300 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
110301 break;
110302 case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110303 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110304 break;
110305 case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */
110306 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110307 break;
110308 case 94: /* tcons ::= CHECK LP expr RP onconf */
110309 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110310 break;
110311 case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110312 {
110313 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110314 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110315 }
110316 break;
110317 case 98: /* onconf ::= */
110318 {yygotominor.yy392 = OE_Default;}
110319 break;
110320 case 100: /* orconf ::= */
110321 {yygotominor.yy258 = OE_Default;}
110322 break;
110323 case 101: /* orconf ::= OR resolvetype */
110324 {yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110325 break;
110326 case 103: /* resolvetype ::= IGNORE */
110327 {yygotominor.yy392 = OE_Ignore;}
110328 break;
110329 case 104: /* resolvetype ::= REPLACE */
110330 {yygotominor.yy392 = OE_Replace;}
110331 break;
110332 case 105: /* cmd ::= DROP TABLE ifexists fullname */
110333 {
110334 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110335 }
110336 break;
110337 case 108: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110338 {
110339 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110340 }
110341 break;
110342 case 109: /* cmd ::= DROP VIEW ifexists fullname */
110343 {
110344 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110345 }
110346 break;
110347 case 110: /* cmd ::= select */
110348 {
110349 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110350 sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110351 sqlite3ExplainBegin(pParse->pVdbe);
110352 sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110353 sqlite3ExplainFinish(pParse->pVdbe);
110354 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110355 }
110356 break;
110357 case 111: /* select ::= oneselect */
110358 {yygotominor.yy159 = yymsp[0].minor.yy159;}
110359 break;
110360 case 112: /* select ::= select multiselect_op oneselect */
110361 {
110362 if( yymsp[0].minor.yy159 ){
110363 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110364 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110365 }else{
@@ -110175,83 +110366,83 @@
110366 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110367 }
110368 yygotominor.yy159 = yymsp[0].minor.yy159;
110369 }
110370 break;
110371 case 114: /* multiselect_op ::= UNION ALL */
110372 {yygotominor.yy392 = TK_ALL;}
110373 break;
110374 case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110375 {
110376 yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110377 }
110378 break;
110379 case 120: /* sclp ::= selcollist COMMA */
110380 case 244: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==244);
110381 {yygotominor.yy442 = yymsp[-1].minor.yy442;}
110382 break;
110383 case 121: /* sclp ::= */
110384 case 149: /* orderby_opt ::= */ yytestcase(yyruleno==149);
110385 case 156: /* groupby_opt ::= */ yytestcase(yyruleno==156);
110386 case 237: /* exprlist ::= */ yytestcase(yyruleno==237);
110387 case 243: /* idxlist_opt ::= */ yytestcase(yyruleno==243);
110388 {yygotominor.yy442 = 0;}
110389 break;
110390 case 122: /* selcollist ::= sclp expr as */
110391 {
110392 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110393 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110394 sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110395 }
110396 break;
110397 case 123: /* selcollist ::= sclp STAR */
110398 {
110399 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110400 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110401 }
110402 break;
110403 case 124: /* selcollist ::= sclp nm DOT STAR */
110404 {
110405 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110406 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110407 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110408 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110409 }
110410 break;
110411 case 127: /* as ::= */
110412 {yygotominor.yy0.n = 0;}
110413 break;
110414 case 128: /* from ::= */
110415 {yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110416 break;
110417 case 129: /* from ::= FROM seltablist */
110418 {
110419 yygotominor.yy347 = yymsp[0].minor.yy347;
110420 sqlite3SrcListShiftJoinType(yygotominor.yy347);
110421 }
110422 break;
110423 case 130: /* stl_prefix ::= seltablist joinop */
110424 {
110425 yygotominor.yy347 = yymsp[-1].minor.yy347;
110426 if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110427 }
110428 break;
110429 case 131: /* stl_prefix ::= */
110430 {yygotominor.yy347 = 0;}
110431 break;
110432 case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110433 {
110434 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110435 sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110436 }
110437 break;
110438 case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110439 {
110440 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110441 }
110442 break;
110443 case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110444 {
110445 if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110446 yygotominor.yy347 = yymsp[-4].minor.yy347;
110447 }else{
110448 Select *pSubquery;
@@ -110259,137 +110450,137 @@
110450 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110451 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110452 }
110453 }
110454 break;
110455 case 135: /* dbnm ::= */
110456 case 144: /* indexed_opt ::= */ yytestcase(yyruleno==144);
110457 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110458 break;
110459 case 137: /* fullname ::= nm dbnm */
110460 {yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110461 break;
110462 case 138: /* joinop ::= COMMA|JOIN */
110463 { yygotominor.yy392 = JT_INNER; }
110464 break;
110465 case 139: /* joinop ::= JOIN_KW JOIN */
110466 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110467 break;
110468 case 140: /* joinop ::= JOIN_KW nm JOIN */
110469 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110470 break;
110471 case 141: /* joinop ::= JOIN_KW nm nm JOIN */
110472 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110473 break;
110474 case 142: /* on_opt ::= ON expr */
110475 case 159: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==159);
110476 case 166: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==166);
110477 case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232);
110478 case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234);
110479 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110480 break;
110481 case 143: /* on_opt ::= */
110482 case 158: /* having_opt ::= */ yytestcase(yyruleno==158);
110483 case 165: /* where_opt ::= */ yytestcase(yyruleno==165);
110484 case 233: /* case_else ::= */ yytestcase(yyruleno==233);
110485 case 235: /* case_operand ::= */ yytestcase(yyruleno==235);
110486 {yygotominor.yy122 = 0;}
110487 break;
110488 case 146: /* indexed_opt ::= NOT INDEXED */
110489 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110490 break;
110491 case 147: /* using_opt ::= USING LP inscollist RP */
110492 case 178: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==178);
110493 {yygotominor.yy180 = yymsp[-1].minor.yy180;}
110494 break;
110495 case 148: /* using_opt ::= */
110496 case 177: /* inscollist_opt ::= */ yytestcase(yyruleno==177);
110497 {yygotominor.yy180 = 0;}
110498 break;
110499 case 150: /* orderby_opt ::= ORDER BY sortlist */
110500 case 157: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==157);
110501 case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236);
110502 {yygotominor.yy442 = yymsp[0].minor.yy442;}
110503 break;
110504 case 151: /* sortlist ::= sortlist COMMA expr sortorder */
110505 {
110506 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110507 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110508 }
110509 break;
110510 case 152: /* sortlist ::= expr sortorder */
110511 {
110512 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110513 if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110514 }
110515 break;
110516 case 153: /* sortorder ::= ASC */
110517 case 155: /* sortorder ::= */ yytestcase(yyruleno==155);
110518 {yygotominor.yy392 = SQLITE_SO_ASC;}
110519 break;
110520 case 154: /* sortorder ::= DESC */
110521 {yygotominor.yy392 = SQLITE_SO_DESC;}
110522 break;
110523 case 160: /* limit_opt ::= */
110524 {yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110525 break;
110526 case 161: /* limit_opt ::= LIMIT expr */
110527 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110528 break;
110529 case 162: /* limit_opt ::= LIMIT expr OFFSET expr */
110530 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110531 break;
110532 case 163: /* limit_opt ::= LIMIT expr COMMA expr */
110533 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110534 break;
110535 case 164: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110536 {
110537 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110538 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110539 }
110540 break;
110541 case 167: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110542 {
110543 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110544 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110545 sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110546 }
110547 break;
110548 case 168: /* setlist ::= setlist COMMA nm EQ expr */
110549 {
110550 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110551 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110552 }
110553 break;
110554 case 169: /* setlist ::= nm EQ expr */
110555 {
110556 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110557 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110558 }
110559 break;
110560 case 170: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110561 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110562 break;
110563 case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110564 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110565 break;
110566 case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110567 {sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110568 break;
110569 case 173: /* insert_cmd ::= INSERT orconf */
110570 {yygotominor.yy258 = yymsp[0].minor.yy258;}
110571 break;
110572 case 174: /* insert_cmd ::= REPLACE */
110573 {yygotominor.yy258 = OE_Replace;}
110574 break;
110575 case 175: /* valuelist ::= VALUES LP nexprlist RP */
110576 {
110577 yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110578 yygotominor.yy487.pSelect = 0;
110579 }
110580 break;
110581 case 176: /* valuelist ::= valuelist COMMA LP exprlist RP */
110582 {
110583 Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110584 if( yymsp[-4].minor.yy487.pList ){
110585 yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110586 yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110597 pRight->pPrior->selFlags |= SF_Values;
110598 yygotominor.yy487.pSelect = pRight;
110599 }
110600 }
110601 break;
110602 case 179: /* inscollist ::= inscollist COMMA nm */
110603 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110604 break;
110605 case 180: /* inscollist ::= nm */
110606 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110607 break;
110608 case 181: /* expr ::= term */
110609 {yygotominor.yy342 = yymsp[0].minor.yy342;}
110610 break;
110611 case 182: /* expr ::= LP expr RP */
110612 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110613 break;
110614 case 183: /* term ::= NULL */
110615 case 188: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==188);
110616 case 189: /* term ::= STRING */ yytestcase(yyruleno==189);
110617 {spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110618 break;
110619 case 184: /* expr ::= id */
110620 case 185: /* expr ::= JOIN_KW */ yytestcase(yyruleno==185);
110621 {spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110622 break;
110623 case 186: /* expr ::= nm DOT nm */
110624 {
110625 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110626 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110627 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110628 spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110629 }
110630 break;
110631 case 187: /* expr ::= nm DOT nm DOT nm */
110632 {
110633 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110634 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110635 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110636 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110637 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110638 spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110639 }
110640 break;
110641 case 190: /* expr ::= REGISTER */
110642 {
110643 /* When doing a nested parse, one can include terms in an expression
110644 ** that look like this: #1 #2 ... These terms refer to registers
110645 ** in the virtual machine. #N is the N-th register. */
110646 if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110651 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110652 }
110653 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110654 }
110655 break;
110656 case 191: /* expr ::= VARIABLE */
110657 {
110658 spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110659 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110660 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110661 }
110662 break;
110663 case 192: /* expr ::= expr COLLATE ids */
110664 {
110665 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110666 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110667 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110668 }
110669 break;
110670 case 193: /* expr ::= CAST LP expr AS typetoken RP */
110671 {
110672 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110673 spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110674 }
110675 break;
110676 case 194: /* expr ::= ID LP distinct exprlist RP */
110677 {
110678 if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110679 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110680 }
110681 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110683 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110684 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110685 }
110686 }
110687 break;
110688 case 195: /* expr ::= ID LP STAR RP */
110689 {
110690 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110691 spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110692 }
110693 break;
110694 case 196: /* term ::= CTIME_KW */
110695 {
110696 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110697 ** treated as functions that return constants */
110698 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110699 if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110700 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110701 }
110702 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110703 }
110704 break;
110705 case 197: /* expr ::= expr AND expr */
110706 case 198: /* expr ::= expr OR expr */ yytestcase(yyruleno==198);
110707 case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
110708 case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
110709 case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
110710 case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
110711 case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
110712 case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
110713 {spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110714 break;
110715 case 205: /* likeop ::= LIKE_KW */
110716 case 207: /* likeop ::= MATCH */ yytestcase(yyruleno==207);
110717 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;}
110718 break;
110719 case 206: /* likeop ::= NOT LIKE_KW */
110720 case 208: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==208);
110721 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;}
110722 break;
110723 case 209: /* expr ::= expr likeop expr */
110724 {
110725 ExprList *pList;
110726 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110727 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110728 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110729 if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110730 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110731 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110732 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110733 }
110734 break;
110735 case 210: /* expr ::= expr likeop expr ESCAPE expr */
110736 {
110737 ExprList *pList;
110738 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110739 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110740 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110741 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110742 if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110743 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110744 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110745 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110746 }
110747 break;
110748 case 211: /* expr ::= expr ISNULL|NOTNULL */
110749 {spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110750 break;
110751 case 212: /* expr ::= expr NOT NULL */
110752 {spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110753 break;
110754 case 213: /* expr ::= expr IS expr */
110755 {
110756 spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110757 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110758 }
110759 break;
110760 case 214: /* expr ::= expr IS NOT expr */
110761 {
110762 spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110763 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110764 }
110765 break;
110766 case 215: /* expr ::= NOT expr */
110767 case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216);
110768 {spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110769 break;
110770 case 217: /* expr ::= MINUS expr */
110771 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110772 break;
110773 case 218: /* expr ::= PLUS expr */
110774 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110775 break;
110776 case 221: /* expr ::= expr between_op expr AND expr */
110777 {
110778 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110779 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110780 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110781 if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110786 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110787 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110788 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110789 }
110790 break;
110791 case 224: /* expr ::= expr in_op LP exprlist RP */
110792 {
110793 if( yymsp[-1].minor.yy442==0 ){
110794 /* Expressions of the form
110795 **
110796 ** expr1 IN ()
@@ -110622,11 +110813,11 @@
110813 }
110814 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110815 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110816 }
110817 break;
110818 case 225: /* expr ::= LP select RP */
110819 {
110820 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110821 if( yygotominor.yy342.pExpr ){
110822 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110823 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110827 }
110828 yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110829 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110830 }
110831 break;
110832 case 226: /* expr ::= expr in_op LP select RP */
110833 {
110834 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110835 if( yygotominor.yy342.pExpr ){
110836 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110837 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110842 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110843 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110844 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110845 }
110846 break;
110847 case 227: /* expr ::= expr in_op nm dbnm */
110848 {
110849 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110850 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110851 if( yygotominor.yy342.pExpr ){
110852 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110858 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110859 yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110860 yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110861 }
110862 break;
110863 case 228: /* expr ::= EXISTS LP select RP */
110864 {
110865 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110866 if( p ){
110867 p->x.pSelect = yymsp[-1].minor.yy159;
110868 ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110872 }
110873 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110874 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110875 }
110876 break;
110877 case 229: /* expr ::= CASE case_operand case_exprlist case_else END */
110878 {
110879 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110880 if( yygotominor.yy342.pExpr ){
110881 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110882 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110885 }
110886 yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110887 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110888 }
110889 break;
110890 case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110891 {
110892 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110893 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110894 }
110895 break;
110896 case 231: /* case_exprlist ::= WHEN expr THEN expr */
110897 {
110898 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110899 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110900 }
110901 break;
110902 case 238: /* nexprlist ::= nexprlist COMMA expr */
110903 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110904 break;
110905 case 239: /* nexprlist ::= expr */
110906 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110907 break;
110908 case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110909 {
110910 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110911 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110912 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110913 }
110914 break;
110915 case 241: /* uniqueflag ::= UNIQUE */
110916 case 294: /* raisetype ::= ABORT */ yytestcase(yyruleno==294);
110917 {yygotominor.yy392 = OE_Abort;}
110918 break;
110919 case 242: /* uniqueflag ::= */
110920 {yygotominor.yy392 = OE_None;}
110921 break;
110922 case 245: /* idxlist ::= idxlist COMMA nm collate sortorder */
110923 {
110924 Expr *p = 0;
110925 if( yymsp[-1].minor.yy0.n>0 ){
110926 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110927 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110930 sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110931 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110932 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110933 }
110934 break;
110935 case 246: /* idxlist ::= nm collate sortorder */
110936 {
110937 Expr *p = 0;
110938 if( yymsp[-1].minor.yy0.n>0 ){
110939 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110940 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110943 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110944 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110945 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110946 }
110947 break;
110948 case 247: /* collate ::= */
110949 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110950 break;
110951 case 249: /* cmd ::= DROP INDEX ifexists fullname */
110952 {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110953 break;
110954 case 250: /* cmd ::= VACUUM */
110955 case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251);
110956 {sqlite3Vacuum(pParse);}
110957 break;
110958 case 252: /* cmd ::= PRAGMA nm dbnm */
110959 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110960 break;
110961 case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110962 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110963 break;
110964 case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110965 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110966 break;
110967 case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110968 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110969 break;
110970 case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110971 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110972 break;
110973 case 266: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110974 {
110975 Token all;
110976 all.z = yymsp[-3].minor.yy0.z;
110977 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110978 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110979 }
110980 break;
110981 case 267: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110982 {
110983 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110984 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110985 }
110986 break;
110987 case 268: /* trigger_time ::= BEFORE */
110988 case 271: /* trigger_time ::= */ yytestcase(yyruleno==271);
110989 { yygotominor.yy392 = TK_BEFORE; }
110990 break;
110991 case 269: /* trigger_time ::= AFTER */
110992 { yygotominor.yy392 = TK_AFTER; }
110993 break;
110994 case 270: /* trigger_time ::= INSTEAD OF */
110995 { yygotominor.yy392 = TK_INSTEAD;}
110996 break;
110997 case 272: /* trigger_event ::= DELETE|INSERT */
110998 case 273: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==273);
110999 {yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
111000 break;
111001 case 274: /* trigger_event ::= UPDATE OF inscollist */
111002 {yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
111003 break;
111004 case 277: /* when_clause ::= */
111005 case 299: /* key_opt ::= */ yytestcase(yyruleno==299);
111006 { yygotominor.yy122 = 0; }
111007 break;
111008 case 278: /* when_clause ::= WHEN expr */
111009 case 300: /* key_opt ::= KEY expr */ yytestcase(yyruleno==300);
111010 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
111011 break;
111012 case 279: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
111013 {
111014 assert( yymsp[-2].minor.yy327!=0 );
111015 yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
111016 yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
111017 yygotominor.yy327 = yymsp[-2].minor.yy327;
111018 }
111019 break;
111020 case 280: /* trigger_cmd_list ::= trigger_cmd SEMI */
111021 {
111022 assert( yymsp[-1].minor.yy327!=0 );
111023 yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
111024 yygotominor.yy327 = yymsp[-1].minor.yy327;
111025 }
111026 break;
111027 case 282: /* trnm ::= nm DOT nm */
111028 {
111029 yygotominor.yy0 = yymsp[0].minor.yy0;
111030 sqlite3ErrorMsg(pParse,
111031 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
111032 "statements within triggers");
111033 }
111034 break;
111035 case 284: /* tridxby ::= INDEXED BY nm */
111036 {
111037 sqlite3ErrorMsg(pParse,
111038 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
111039 "within triggers");
111040 }
111041 break;
111042 case 285: /* tridxby ::= NOT INDEXED */
111043 {
111044 sqlite3ErrorMsg(pParse,
111045 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
111046 "within triggers");
111047 }
111048 break;
111049 case 286: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
111050 { yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
111051 break;
111052 case 287: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
111053 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
111054 break;
111055 case 288: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
111056 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
111057 break;
111058 case 289: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
111059 {yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
111060 break;
111061 case 290: /* trigger_cmd ::= select */
111062 {yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
111063 break;
111064 case 291: /* expr ::= RAISE LP IGNORE RP */
111065 {
111066 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
111067 if( yygotominor.yy342.pExpr ){
111068 yygotominor.yy342.pExpr->affinity = OE_Ignore;
111069 }
111070 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
111071 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
111072 }
111073 break;
111074 case 292: /* expr ::= RAISE LP raisetype COMMA nm RP */
111075 {
111076 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
111077 if( yygotominor.yy342.pExpr ) {
111078 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
111079 }
111080 yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
111081 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
111082 }
111083 break;
111084 case 293: /* raisetype ::= ROLLBACK */
111085 {yygotominor.yy392 = OE_Rollback;}
111086 break;
111087 case 295: /* raisetype ::= FAIL */
111088 {yygotominor.yy392 = OE_Fail;}
111089 break;
111090 case 296: /* cmd ::= DROP TRIGGER ifexists fullname */
111091 {
111092 sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
111093 }
111094 break;
111095 case 297: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
111096 {
111097 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
111098 }
111099 break;
111100 case 298: /* cmd ::= DETACH database_kw_opt expr */
111101 {
111102 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
111103 }
111104 break;
111105 case 303: /* cmd ::= REINDEX */
111106 {sqlite3Reindex(pParse, 0, 0);}
111107 break;
111108 case 304: /* cmd ::= REINDEX nm dbnm */
111109 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
111110 break;
111111 case 305: /* cmd ::= ANALYZE */
111112 {sqlite3Analyze(pParse, 0, 0);}
111113 break;
111114 case 306: /* cmd ::= ANALYZE nm dbnm */
111115 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
111116 break;
111117 case 307: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
111118 {
111119 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
111120 }
111121 break;
111122 case 308: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
111123 {
111124 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
111125 }
111126 break;
111127 case 309: /* add_column_fullname ::= fullname */
111128 {
111129 pParse->db->lookaside.bEnabled = 0;
111130 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
111131 }
111132 break;
111133 case 312: /* cmd ::= create_vtab */
111134 {sqlite3VtabFinishParse(pParse,0);}
111135 break;
111136 case 313: /* cmd ::= create_vtab LP vtabarglist RP */
111137 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
111138 break;
111139 case 314: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111140 {
111141 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
111142 }
111143 break;
111144 case 317: /* vtabarg ::= */
111145 {sqlite3VtabArgInit(pParse);}
111146 break;
111147 case 319: /* vtabargtoken ::= ANY */
111148 case 320: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==320);
111149 case 321: /* lp ::= LP */ yytestcase(yyruleno==321);
111150 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
111151 break;
111152 default:
111153 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
111154 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
111164 /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
111165 /* (35) columnlist ::= column */ yytestcase(yyruleno==35);
111166 /* (44) type ::= */ yytestcase(yyruleno==44);
111167 /* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
111168 /* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
111169 /* (53) carglist ::= carglist cname ccons */ yytestcase(yyruleno==53);
111170 /* (54) carglist ::= */ yytestcase(yyruleno==54);
 
 
111171 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
111172 /* (90) conslist ::= conslist COMMA cname tcons */ yytestcase(yyruleno==90);
111173 /* (91) conslist ::= cname tcons */ yytestcase(yyruleno==91);
111174 /* (275) foreach_clause ::= */ yytestcase(yyruleno==275);
111175 /* (276) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==276);
111176 /* (283) tridxby ::= */ yytestcase(yyruleno==283);
111177 /* (301) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==301);
111178 /* (302) database_kw_opt ::= */ yytestcase(yyruleno==302);
111179 /* (310) kwcolumn_opt ::= */ yytestcase(yyruleno==310);
111180 /* (311) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==311);
111181 /* (315) vtabarglist ::= vtabarg */ yytestcase(yyruleno==315);
111182 /* (316) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==316);
111183 /* (318) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==318);
111184 /* (322) anylist ::= */ yytestcase(yyruleno==322);
111185 /* (323) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==323);
111186 /* (324) anylist ::= anylist ANY */ yytestcase(yyruleno==324);
 
 
111187 break;
111188 };
111189 yygoto = yyRuleInfo[yyruleno].lhs;
111190 yysize = yyRuleInfo[yyruleno].nrhs;
111191 yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
116076 ** option. But that functionality is no longer supported.
116077 **
116078 ** A doclist is stored like this:
116079 **
116080 ** array {
116081 ** varint docid; (delta from previous doclist)
116082 ** array { (position list for column 0)
116083 ** varint position; (2 more than the delta from previous position)
116084 ** }
116085 ** array {
116086 ** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
116107 ** The 123 value is the first docid. For column zero in this document
116108 ** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
116109 ** at D signals the start of a new column; the 1 at E indicates that the
116110 ** new column is column number 1. There are two positions at 12 and 45
116111 ** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
116112 ** 234 at I is the delta to next docid (357). It has one position 70
116113 ** (72-2) and then terminates with the 0 at K.
116114 **
116115 ** A "position-list" is the list of positions for multiple columns for
116116 ** a single docid. A "column-list" is the set of positions for a single
116117 ** column. Hence, a position-list consists of one or more column-lists,
116118 ** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116643
116644
116645 #ifndef MIN
116646 # define MIN(x,y) ((x)<(y)?(x):(y))
116647 #endif
116648 #ifndef MAX
116649 # define MAX(x,y) ((x)>(y)?(x):(y))
116650 #endif
116651
116652 /*
116653 ** Maximum length of a varint encoded integer. The varint format is different
116654 ** from that used by SQLite, so the maximum length is 10, not 9.
116655 */
@@ -116510,20 +116700,21 @@
116700 #ifdef SQLITE_COVERAGE_TEST
116701 # define ALWAYS(x) (1)
116702 # define NEVER(X) (0)
116703 #else
116704 # define ALWAYS(x) (x)
116705 # define NEVER(x) (x)
116706 #endif
116707
116708 /*
116709 ** Internal types used by SQLite.
116710 */
116711 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116712 typedef short int i16; /* 2-byte (or larger) signed integer */
116713 typedef unsigned int u32; /* 4-byte unsigned integer */
116714 typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
116715 typedef sqlite3_int64 i64; /* 8-byte signed integer */
116716
116717 /*
116718 ** Macro used to suppress compiler warnings for unused parameters.
116719 */
116720 #define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116773 int nColumn; /* number of named columns in virtual table */
116774 char **azColumn; /* column names. malloced */
116775 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116776 char *zContentTbl; /* content=xxx option, or NULL */
116777 char *zLanguageid; /* languageid=xxx option, or NULL */
116778 u8 bAutoincrmerge; /* True if automerge=1 */
116779 u32 nLeafAdd; /* Number of leaf blocks added this trans */
116780
116781 /* Precompiled statements used by the implementation. Each of these
116782 ** statements is run and reset within a single virtual table API call.
116783 */
116784 sqlite3_stmt *aStmt[37];
116785
116786 char *zReadExprlist;
116787 char *zWriteExprlist;
116788
116789 int nNodeSize; /* Soft limit for node size */
116790 u8 bFts4; /* True for FTS4, false for FTS3 */
116791 u8 bHasStat; /* True if %_stat table exists */
116792 u8 bHasDocsize; /* True if %_docsize table exists */
116793 u8 bDescIdx; /* True if doclists are in reverse order */
116794 u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */
116795 int nPgsz; /* Page size for host database */
116796 char *zSegmentsTbl; /* Name of %_segments table */
116797 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116798
116799 /*
 
116800 ** The following array of hash tables is used to buffer pending index
116801 ** updates during transactions. All pending updates buffered at any one
116802 ** time must share a common language-id (see the FTS4 langid= feature).
116803 ** The current language id is stored in variable iPrevLangid.
 
 
116804 **
116805 ** A single FTS4 table may have multiple full-text indexes. For each index
116806 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116807 ** terms that appear in the document set. Each subsequent index in aIndex[]
116808 ** is an index of prefixes of a specific length.
116809 **
116810 ** Variable nPendingData contains an estimate the memory consumed by the
116811 ** pending data structures, including hash table overhead, but not including
116812 ** malloc overhead. When nPendingData exceeds nMaxPendingData, all hash
116813 ** tables are flushed to disk. Variable iPrevDocid is the docid of the most
116814 ** recently inserted record.
116815 */
116816 int nIndex; /* Size of aIndex[] */
116817 struct Fts3Index {
116818 int nPrefix; /* Prefix length (0 for main terms index) */
116819 Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
117008 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
117009 SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
117010 SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
117011 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
117012 SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
117013 SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);
117014
117015 /* Special values interpreted by sqlite3SegReaderCursor() */
117016 #define FTS3_SEGCURSOR_PENDING -1
117017 #define FTS3_SEGCURSOR_ALL -2
117018
@@ -116861,19 +117060,22 @@
117060 int nTerm; /* Size of zTerm in bytes */
117061 char *aDoclist; /* Pointer to doclist buffer */
117062 int nDoclist; /* Size of aDoclist[] in bytes */
117063 };
117064
117065 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
117066
117067 /* fts3.c */
117068 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
117069 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
117070 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
117071 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
117072 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
117073 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
117074 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
117075 SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
117076 SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);
117077
117078 /* fts3_tokenizer.c */
117079 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
117080 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
117081 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117400 sqlite3_free(zSql);
117401 sqlite3_free(zCols);
117402 *pRc = rc;
117403 }
117404 }
117405
117406 /*
117407 ** Create the %_stat table if it does not already exist.
117408 */
117409 SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){
117410 fts3DbExec(pRc, p->db,
117411 "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
117412 "(id INTEGER PRIMARY KEY, value BLOB);",
117413 p->zDb, p->zName
117414 );
117415 if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;
117416 }
117417
117418 /*
117419 ** Create the backing store tables (%_content, %_segments and %_segdir)
117420 ** required by the FTS3 table passed as the only argument. This is done
117421 ** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117473 fts3DbExec(&rc, db,
117474 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117475 p->zDb, p->zName
117476 );
117477 }
117478 assert( p->bHasStat==p->bFts4 );
117479 if( p->bHasStat ){
117480 sqlite3Fts3CreateStatTable(&rc, p);
 
 
 
117481 }
117482 return rc;
117483 }
117484
117485 /*
@@ -117370,11 +117582,11 @@
117582 ** memory.
117583 */
117584 static char *fts3QuoteId(char const *zInput){
117585 int nRet;
117586 char *zRet;
117587 nRet = 2 + (int)strlen(zInput)*2 + 1;
117588 zRet = sqlite3_malloc(nRet);
117589 if( zRet ){
117590 int i;
117591 char *z = zRet;
117592 *(z++) = '"';
@@ -117626,11 +117838,11 @@
117838 ** space required to store a copy of each column name, including the
117839 ** nul-terminator byte. */
117840 nCol = sqlite3_column_count(pStmt);
117841 for(i=0; i<nCol; i++){
117842 const char *zCol = sqlite3_column_name(pStmt, i);
117843 nStr += (int)strlen(zCol) + 1;
117844 }
117845
117846 /* Allocate and populate the array to return. */
117847 azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117848 if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117849 rc = SQLITE_NOMEM;
117850 }else{
117851 char *p = (char *)&azCol[nCol];
117852 for(i=0; i<nCol; i++){
117853 const char *zCol = sqlite3_column_name(pStmt, i);
117854 int n = (int)strlen(zCol)+1;
117855 memcpy(p, zCol, n);
117856 azCol[i] = p;
117857 p += n;
117858 }
117859 }
@@ -117852,11 +118064,12 @@
118064 ** column from the aCol[] array. */
118065 if( rc==SQLITE_OK && zLanguageid ){
118066 int j;
118067 for(j=0; j<nCol; j++){
118068 if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
118069 int k;
118070 for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];
118071 nCol--;
118072 break;
118073 }
118074 }
118075 }
@@ -117903,11 +118116,13 @@
118116 p->azColumn = (char **)&p[1];
118117 p->pTokenizer = pTokenizer;
118118 p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
118119 p->bHasDocsize = (isFts4 && bNoDocsize==0);
118120 p->bHasStat = isFts4;
118121 p->bFts4 = isFts4;
118122 p->bDescIdx = bDescIdx;
118123 p->bAutoincrmerge = 0xff; /* 0xff means setting unknown */
118124 p->zContentTbl = zContent;
118125 p->zLanguageid = zLanguageid;
118126 zContent = 0;
118127 zLanguageid = 0;
118128 TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
118170 ** database. TODO: For xConnect(), it could verify that said tables exist.
118171 */
118172 if( isCreate ){
118173 rc = fts3CreateTables(p);
118174 }
118175
118176 /* Check to see if a legacy fts3 table has been "upgraded" by the
118177 ** addition of a %_stat table so that it can use incremental merge.
118178 */
118179 if( !isFts4 && !isCreate ){
118180 int rc2 = SQLITE_OK;
118181 fts3DbExec(&rc2, db, "SELECT 1 FROM %Q.'%q_stat' WHERE id=2",
118182 p->zDb, p->zName);
118183 if( rc2==SQLITE_OK ) p->bHasStat = 1;
118184 }
118185
118186 /* Figure out the page-size for the database. This is required in order to
118187 ** estimate the cost of loading large doclists from the database. */
118188 fts3DatabasePageSize(&rc, p);
118189 p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
119184 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119185 }
119186 }
119187
119188 *paOut = aOut;
119189 *pnOut = (int)(p-aOut);
119190 assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
119191 return SQLITE_OK;
119192 }
119193
119194 /*
@@ -119023,11 +119248,11 @@
119248 fts3PoslistCopy(0, &p2);
119249 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119250 }
119251 }
119252
119253 *pnRight = (int)(p - aOut);
119254 }
119255
119256 /*
119257 ** Argument pList points to a position list nList bytes in size. This
119258 ** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119524 ** Set up a cursor object for iterating through a full-text index or a
119525 ** single level therein.
119526 */
119527 SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119528 Fts3Table *p, /* FTS3 table handle */
119529 int iLangid, /* Language-id to search */
119530 int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119531 int iLevel, /* Level of segments to scan */
119532 const char *zTerm, /* Term to query for */
119533 int nTerm, /* Size of zTerm in bytes */
119534 int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119542 );
119543 assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119544 assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119545 assert( isPrefix==0 || isScan==0 );
119546
 
 
 
 
119547 memset(pCsr, 0, sizeof(Fts3MultiSegReader));
 
119548 return fts3SegReaderCursor(
119549 p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119550 );
119551 }
119552
@@ -119587,11 +119807,11 @@
119807
119808 pCsr->iLangid = 0;
119809 if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119810
119811 rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119812 p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119813 );
119814 if( rc!=SQLITE_OK ){
119815 if( rc==SQLITE_ERROR ){
119816 static const char *zErr = "malformed MATCH expression: [%s]";
119817 p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119950 /*
119951 ** Implementation of xSync() method. Flush the contents of the pending-terms
119952 ** hash-table to the database.
119953 */
119954 static int fts3SyncMethod(sqlite3_vtab *pVtab){
119955
119956 /* Following an incremental-merge operation, assuming that the input
119957 ** segments are not completely consumed (the usual case), they are updated
119958 ** in place to remove the entries that have already been merged. This
119959 ** involves updating the leaf block that contains the smallest unmerged
119960 ** entry and each block (if any) between the leaf and the root node. So
119961 ** if the height of the input segment b-trees is N, and input segments
119962 ** are merged eight at a time, updating the input segments at the end
119963 ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually
119964 ** small - often between 0 and 2. So the overhead of the incremental
119965 ** merge is somewhere between 8 and 24 blocks. To avoid this overhead
119966 ** dwarfing the actual productive work accomplished, the incremental merge
119967 ** is only attempted if it will write at least 64 leaf blocks. Hence
119968 ** nMinMerge.
119969 **
119970 ** Of course, updating the input segments also involves deleting a bunch
119971 ** of blocks from the segments table. But this is not considered overhead
119972 ** as it would also be required by a crisis-merge that used the same input
119973 ** segments.
119974 */
119975 const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
119976
119977 Fts3Table *p = (Fts3Table*)pVtab;
119978 int rc = sqlite3Fts3PendingTermsFlush(p);
119979
119980 if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){
119981 int mxLevel = 0; /* Maximum relative level value in db */
119982 int A; /* Incr-merge parameter A */
119983
119984 rc = sqlite3Fts3MaxLevel(p, &mxLevel);
119985 assert( rc==SQLITE_OK || mxLevel==0 );
119986 A = p->nLeafAdd * mxLevel;
119987 A += (A/2);
119988 if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);
119989 }
119990 sqlite3Fts3SegmentsClose(p);
119991 return rc;
119992 }
119993
119994 /*
119995 ** Implementation of xBegin() method. This is a no-op.
119996 */
119997 static int fts3BeginMethod(sqlite3_vtab *pVtab){
119998 Fts3Table *p = (Fts3Table*)pVtab;
119999 UNUSED_PARAMETER(pVtab);
120000 assert( p->pSegments==0 );
120001 assert( p->nPendingData==0 );
120002 assert( p->inTransaction!=1 );
120003 TESTONLY( p->inTransaction = 1 );
120004 TESTONLY( p->mxSavepoint = -1; );
120005 p->nLeafAdd = 0;
120006 return SQLITE_OK;
120007 }
120008
120009 /*
120010 ** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120295 ** The xSavepoint() method.
120296 **
120297 ** Flush the contents of the pending-terms table to disk.
120298 */
120299 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
120300 int rc = SQLITE_OK;
120301 UNUSED_PARAMETER(iSavepoint);
120302 assert( ((Fts3Table *)pVtab)->inTransaction );
120303 assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120304 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120305 if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
120306 rc = fts3SyncMethod(pVtab);
120307 }
120308 return rc;
120309 }
120310
120311 /*
120312 ** The xRelease() method.
120313 **
@@ -120404,11 +120663,11 @@
120663
120664 assert( iPrev>=0 );
120665 fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120666 sqlite3_free(aPoslist);
120667 aPoslist = pList;
120668 nPoslist = (int)(aOut - aPoslist);
120669 if( nPoslist==0 ){
120670 sqlite3_free(aPoslist);
120671 pPhrase->doclist.pList = 0;
120672 pPhrase->doclist.nList = 0;
120673 return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120707 }
120708
120709 pPhrase->doclist.pList = aOut;
120710 if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120711 pPhrase->doclist.bFreeList = 1;
120712 pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);
120713 }else{
120714 sqlite3_free(aOut);
120715 pPhrase->doclist.pList = 0;
120716 pPhrase->doclist.nList = 0;
120717 }
@@ -120544,11 +120803,11 @@
120803 fts3PoslistCopy(0, &pDocid);
120804 while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120805 iMul = (bDescIdx ? -1 : 1);
120806 }
120807
120808 *pnList = (int)(pEnd - pNext);
120809 *ppIter = pNext;
120810 *piDocid = iDocid;
120811 }else{
120812 int iMul = (bDescIdx ? -1 : 1);
120813 sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120817 if( p==aDoclist ){
120818 *pbEof = 1;
120819 }else{
120820 char *pSave = p;
120821 fts3ReversePoslist(aDoclist, &p);
120822 *pnList = (int)(pSave - p);
120823 }
120824 *ppIter = p;
120825 }
120826 }
120827
@@ -120618,11 +120877,11 @@
120877 }else{
120878 pDL->iDocid -= iDelta;
120879 }
120880 pDL->pList = pIter;
120881 fts3PoslistCopy(0, &pIter);
120882 pDL->nList = (int)(pIter - pDL->pList);
120883
120884 /* pIter now points just past the 0x00 that terminates the position-
120885 ** list for document pDL->iDocid. However, if this position-list was
120886 ** edited in place by fts3EvalNearTrim(), then pIter may not actually
120887 ** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
121218
121219 /* Allocate a MultiSegReader for each token in the expression. */
121220 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
121221
121222 /* Determine which, if any, tokens in the expression should be deferred. */
121223 if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
121224 Fts3TokenAndCost *aTC;
121225 Fts3Expr **apOr;
121226 aTC = (Fts3TokenAndCost *)sqlite3_malloc(
121227 sizeof(Fts3TokenAndCost) * nToken
121228 + sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
121235 int ii;
121236 Fts3TokenAndCost *pTC = aTC;
121237 Fts3Expr **ppOr = apOr;
121238
121239 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
121240 nToken = (int)(pTC-aTC);
121241 nOr = (int)(ppOr-apOr);
121242
121243 if( rc==SQLITE_OK ){
121244 rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
121245 for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
121246 rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121308 p2 = pOut = pPhrase->doclist.pList;
121309 res = fts3PoslistNearMerge(
121310 &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121311 );
121312 if( res ){
121313 nNew = (int)(pOut - pPhrase->doclist.pList) - 1;
121314 assert( pPhrase->doclist.pList[nNew]=='\0' );
121315 assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121316 memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121317 pPhrase->doclist.nList = nNew;
121318 *paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
122033 fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
122034 pPhrase->aToken[i].pSegcsr = 0;
122035 }
122036 }
122037 }
122038
122039
122040 /*
122041 ** Return SQLITE_CORRUPT_VTAB.
122042 */
122043 #ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
122142 );
122143 return SQLITE_ERROR;
122144 }
122145
122146 zDb = argv[1];
122147 nDb = (int)strlen(zDb);
122148 zFts3 = argv[3];
122149 nFts3 = (int)strlen(zFts3);
122150
122151 rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
122152 if( rc!=SQLITE_OK ) return rc;
122153
122154 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125334
125335 /* #include <string.h> */
125336 /* #include <assert.h> */
125337 /* #include <stdlib.h> */
125338
125339
125340 #define FTS_MAX_APPENDABLE_HEIGHT 16
125341
125342 /*
125343 ** When full-text index nodes are loaded from disk, the buffer that they
125344 ** are loaded into has the following number of bytes of padding at the end
125345 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125346 ** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125375 # define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125376 #else
125377 # define FTS3_NODE_CHUNKSIZE (4*1024)
125378 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125379 #endif
125380
125381 /*
125382 ** The two values that may be meaningfully bound to the :1 parameter in
125383 ** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
125384 */
125385 #define FTS_STAT_DOCTOTAL 0
125386 #define FTS_STAT_INCRMERGEHINT 1
125387 #define FTS_STAT_AUTOINCRMERGE 2
125388
125389 /*
125390 ** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic
125391 ** and incremental merge operation that takes place. This is used for
125392 ** debugging FTS only, it should not usually be turned on in production
125393 ** systems.
125394 */
125395 #ifdef FTS3_LOG_MERGES
125396 static void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){
125397 sqlite3_log(SQLITE_OK, "%d-way merge from level %d", nMerge, (int)iAbsLevel);
125398 }
125399 #else
125400 #define fts3LogMerge(x, y)
125401 #endif
125402
125403
125404 typedef struct PendingList PendingList;
125405 typedef struct SegmentNode SegmentNode;
125406 typedef struct SegmentWriter SegmentWriter;
125407
@@ -125274,19 +125560,26 @@
125560 #define SQL_DELETE_SEGMENTS_RANGE 17
125561 #define SQL_CONTENT_INSERT 18
125562 #define SQL_DELETE_DOCSIZE 19
125563 #define SQL_REPLACE_DOCSIZE 20
125564 #define SQL_SELECT_DOCSIZE 21
125565 #define SQL_SELECT_STAT 22
125566 #define SQL_REPLACE_STAT 23
125567
125568 #define SQL_SELECT_ALL_PREFIX_LEVEL 24
125569 #define SQL_DELETE_ALL_TERMS_SEGDIR 25
 
125570 #define SQL_DELETE_SEGDIR_RANGE 26
 
125571 #define SQL_SELECT_ALL_LANGID 27
125572 #define SQL_FIND_MERGE_LEVEL 28
125573 #define SQL_MAX_LEAF_NODE_ESTIMATE 29
125574 #define SQL_DELETE_SEGDIR_ENTRY 30
125575 #define SQL_SHIFT_SEGDIR_ENTRY 31
125576 #define SQL_SELECT_SEGDIR 32
125577 #define SQL_CHOMP_SEGDIR 33
125578 #define SQL_SEGMENT_IS_APPENDABLE 34
125579 #define SQL_SELECT_INDEXES 35
125580 #define SQL_SELECT_MXLEVEL 36
125581
125582 /*
125583 ** This function is used to obtain an SQLite prepared statement handle
125584 ** for the statement identified by the second argument. If successful,
125585 ** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125604 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
125605 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
125606 /* 6 */ "DELETE FROM %Q.'%q_stat'",
125607 /* 7 */ "SELECT %s WHERE rowid=?",
125608 /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125609 /* 9 */ "REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125610 /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125611 /* 11 */ "REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125612
125613 /* Return segments in order from oldest to newest.*/
125614 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125615 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125616 /* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125624 /* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125625 /* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125626 /* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125627 /* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125628 /* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125629 /* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=?",
125630 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
125631 /* 24 */ "",
125632 /* 25 */ "",
125633
125634 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125635 /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125636
125637 /* This statement is used to determine which level to read the input from
125638 ** when performing an incremental merge. It returns the absolute level number
125639 ** of the oldest level in the db that contains at least ? segments. Or,
125640 ** if no level in the FTS index contains more than ? segments, the statement
125641 ** returns zero rows. */
125642 /* 28 */ "SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?"
125643 " ORDER BY (level %% 1024) ASC LIMIT 1",
125644
125645 /* Estimate the upper limit on the number of leaf nodes in a new segment
125646 ** created by merging the oldest :2 segments from absolute level :1. See
125647 ** function sqlite3Fts3Incrmerge() for details. */
125648 /* 29 */ "SELECT 2 * total(1 + leaves_end_block - start_block) "
125649 " FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?",
125650
125651 /* SQL_DELETE_SEGDIR_ENTRY
125652 ** Delete the %_segdir entry on absolute level :1 with index :2. */
125653 /* 30 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125654
125655 /* SQL_SHIFT_SEGDIR_ENTRY
125656 ** Modify the idx value for the segment with idx=:3 on absolute level :2
125657 ** to :1. */
125658 /* 31 */ "UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?",
125659
125660 /* SQL_SELECT_SEGDIR
125661 ** Read a single entry from the %_segdir table. The entry from absolute
125662 ** level :1 with index value :2. */
125663 /* 32 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125664 "FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125665
125666 /* SQL_CHOMP_SEGDIR
125667 ** Update the start_block (:1) and root (:2) fields of the %_segdir
125668 ** entry located on absolute level :3 with index :4. */
125669 /* 33 */ "UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?"
125670 "WHERE level = ? AND idx = ?",
125671
125672 /* SQL_SEGMENT_IS_APPENDABLE
125673 ** Return a single row if the segment with end_block=? is appendable. Or
125674 ** no rows otherwise. */
125675 /* 34 */ "SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL",
125676
125677 /* SQL_SELECT_INDEXES
125678 ** Return the list of valid segment indexes for absolute level ? */
125679 /* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
125680
125681 /* SQL_SELECT_MXLEVEL
125682 ** Return the largest relative level in the FTS index or indexes. */
125683 /* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'"
125684 };
125685 int rc = SQLITE_OK;
125686 sqlite3_stmt *pStmt;
125687
125688 assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125715 }
125716 }
125717 *pp = pStmt;
125718 return rc;
125719 }
125720
125721
125722 static int fts3SelectDocsize(
125723 Fts3Table *pTab, /* FTS3 table handle */
 
125724 sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125725 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125726 ){
125727 sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125728 int rc; /* Return code */
125729
125730 rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);
 
 
125731 if( rc==SQLITE_OK ){
125732 sqlite3_bind_int64(pStmt, 1, iDocid);
 
 
125733 rc = sqlite3_step(pStmt);
125734 if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125735 rc = sqlite3_reset(pStmt);
125736 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125737 pStmt = 0;
@@ -125410,19 +125746,33 @@
125746
125747 SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125748 Fts3Table *pTab, /* Fts3 table handle */
125749 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125750 ){
125751 sqlite3_stmt *pStmt = 0;
125752 int rc;
125753 rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);
125754 if( rc==SQLITE_OK ){
125755 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
125756 if( sqlite3_step(pStmt)!=SQLITE_ROW
125757 || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB
125758 ){
125759 rc = sqlite3_reset(pStmt);
125760 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125761 pStmt = 0;
125762 }
125763 }
125764 *ppStmt = pStmt;
125765 return rc;
125766 }
125767
125768 SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125769 Fts3Table *pTab, /* Fts3 table handle */
125770 sqlite3_int64 iDocid, /* Docid to read size data for */
125771 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125772 ){
125773 return fts3SelectDocsize(pTab, iDocid, ppStmt);
125774 }
125775
125776 /*
125777 ** Similar to fts3SqlStmt(). Except, after binding the parameters in
125778 ** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125834 }
125835
125836 return rc;
125837 }
125838
125839 /*
125840 ** FTS maintains a separate indexes for each language-id (a 32-bit integer).
125841 ** Within each language id, a separate index is maintained to store the
125842 ** document terms, and each configured prefix size (configured the FTS
125843 ** "prefix=" option). And each index consists of multiple levels ("relative
125844 ** levels").
125845 **
125846 ** All three of these values (the language id, the specific index and the
125847 ** level within the index) are encoded in 64-bit integer values stored
125848 ** in the %_segdir table on disk. This function is used to convert three
125849 ** separate component values into the single 64-bit integer value that
125850 ** can be used to query the %_segdir table.
125851 **
125852 ** Specifically, each language-id/index combination is allocated 1024
125853 ** 64-bit integer level values ("absolute levels"). The main terms index
125854 ** for language-id 0 is allocate values 0-1023. The first prefix index
125855 ** (if any) for language-id 0 is allocated values 1024-2047. And so on.
125856 ** Language 1 indexes are allocated immediately following language 0.
125857 **
125858 ** So, for a system with nPrefix prefix indexes configured, the block of
125859 ** absolute levels that corresponds to language-id iLangid and index
125860 ** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).
125861 */
125862 static sqlite3_int64 getAbsoluteLevel(
125863 Fts3Table *p, /* FTS3 table handle */
125864 int iLangid, /* Language id */
125865 int iIndex, /* Index in p->aIndex[] */
125866 int iLevel /* Level of segments */
125867 ){
125868 sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
125869 assert( iLangid>=0 );
125870 assert( p->nIndex>0 );
125871 assert( iIndex>=0 && iIndex<p->nIndex );
125872
125873 iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;
125874 return iBase + iLevel;
125875 }
 
125876
125877 /*
125878 ** Set *ppStmt to a statement handle that may be used to iterate through
125879 ** all rows in the %_segdir table, from oldest to newest. If successful,
125880 ** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125893 */
125894 SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125895 Fts3Table *p, /* FTS3 table */
125896 int iLangid, /* Language being queried */
125897 int iIndex, /* Index for p->aIndex[] */
125898 int iLevel, /* Level to select (relative level) */
125899 sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125900 ){
125901 int rc;
125902 sqlite3_stmt *pStmt = 0;
125903
@@ -125533,19 +125908,19 @@
125908 if( iLevel<0 ){
125909 /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125910 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125911 if( rc==SQLITE_OK ){
125912 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125913 sqlite3_bind_int64(pStmt, 2,
125914 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125915 );
125916 }
125917 }else{
125918 /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125919 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125920 if( rc==SQLITE_OK ){
125921 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
125922 }
125923 }
125924 *ppStmt = pStmt;
125925 return rc;
125926 }
@@ -126062,10 +126437,11 @@
126437 ** full, merge all segments in level iLevel into a single iLevel+1
126438 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126439 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126440 */
126441 if( iNext>=FTS3_MERGE_COUNT ){
126442 fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
126443 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126444 *piIdx = 0;
126445 }else{
126446 *piIdx = iNext;
126447 }
@@ -126109,11 +126485,11 @@
126485 int *pnLoad /* OUT: Bytes actually loaded */
126486 ){
126487 int rc; /* Return code */
126488
126489 /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126490 assert( pnBlob );
126491
126492 if( p->pSegments ){
126493 rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126494 }else{
126495 if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126826 int nOvfl = 0;
126827 int ii;
126828 int rc = SQLITE_OK;
126829 int pgsz = p->nPgsz;
126830
126831 assert( p->bFts4 );
126832 assert( pgsz>0 );
126833
126834 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126835 Fts3SegReader *pReader = pMsr->apSegment[ii];
126836 if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
127183 sqlite3_step(pStmt);
127184 rc = sqlite3_reset(pStmt);
127185 }
127186 return rc;
127187 }
127188
127189 /*
127190 ** Find the largest relative level number in the table. If successful, set
127191 ** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
127192 ** set *pnMax to zero and return an SQLite error code.
127193 */
127194 SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){
127195 int rc;
127196 int mxLevel = 0;
127197 sqlite3_stmt *pStmt = 0;
127198
127199 rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
127200 if( rc==SQLITE_OK ){
127201 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127202 mxLevel = sqlite3_column_int(pStmt, 0);
127203 }
127204 rc = sqlite3_reset(pStmt);
127205 }
127206 *pnMax = mxLevel;
127207 return rc;
127208 }
127209
127210 /*
127211 ** Insert a record into the %_segdir table.
127212 */
127213 static int fts3WriteSegdir(
127214 Fts3Table *p, /* Virtual table handle */
127215 sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */
127216 int iIdx, /* Value for "idx" field */
127217 sqlite3_int64 iStartBlock, /* Value for "start_block" field */
127218 sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
127219 sqlite3_int64 iEndBlock, /* Value for "end_block" field */
127220 char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
127221 int nRoot /* Number of bytes in buffer zRoot */
127222 ){
127223 sqlite3_stmt *pStmt;
127224 int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
127225 if( rc==SQLITE_OK ){
127226 sqlite3_bind_int64(pStmt, 1, iLevel);
127227 sqlite3_bind_int(pStmt, 2, iIdx);
127228 sqlite3_bind_int64(pStmt, 3, iStartBlock);
127229 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
127230 sqlite3_bind_int64(pStmt, 5, iEndBlock);
127231 sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127521 int rc;
127522
127523 /* The current leaf node is full. Write it out to the database. */
127524 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127525 if( rc!=SQLITE_OK ) return rc;
127526 p->nLeafAdd++;
127527
127528 /* Add the current term to the interior node tree. The term added to
127529 ** the interior tree must:
127530 **
127531 ** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127605 ** returned. Otherwise, an SQLite error code.
127606 */
127607 static int fts3SegWriterFlush(
127608 Fts3Table *p, /* Virtual table handle */
127609 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127610 sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */
127611 int iIdx /* Value for 'idx' column of %_segdir */
127612 ){
127613 int rc; /* Return code */
127614 if( pWriter->pTree ){
127615 sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127630 }else{
127631 /* The entire tree fits on the root node. Write it to the segdir table. */
127632 rc = fts3WriteSegdir(
127633 p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127634 }
127635 p->nLeafAdd++;
127636 return rc;
127637 }
127638
127639 /*
127640 ** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127688 */
127689 static int fts3SegmentMaxLevel(
127690 Fts3Table *p,
127691 int iLangid,
127692 int iIndex,
127693 sqlite3_int64 *pnMax
127694 ){
127695 sqlite3_stmt *pStmt;
127696 int rc;
127697 assert( iIndex>=0 && iIndex<p->nIndex );
127698
@@ -127303,19 +127702,42 @@
127702 **
127703 ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127704 */
127705 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127706 if( rc!=SQLITE_OK ) return rc;
127707 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127708 sqlite3_bind_int64(pStmt, 2,
127709 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127710 );
127711 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127712 *pnMax = sqlite3_column_int64(pStmt, 0);
127713 }
127714 return sqlite3_reset(pStmt);
127715 }
127716
127717 /*
127718 ** Delete all entries in the %_segments table associated with the segment
127719 ** opened with seg-reader pSeg. This function does not affect the contents
127720 ** of the %_segdir table.
127721 */
127722 static int fts3DeleteSegment(
127723 Fts3Table *p, /* FTS table handle */
127724 Fts3SegReader *pSeg /* Segment to delete */
127725 ){
127726 int rc = SQLITE_OK; /* Return code */
127727 if( pSeg->iStartBlock ){
127728 sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127729 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127730 if( rc==SQLITE_OK ){
127731 sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);
127732 sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);
127733 sqlite3_step(pDelete);
127734 rc = sqlite3_reset(pDelete);
127735 }
127736 }
127737 return rc;
127738 }
127739
127740 /*
127741 ** This function is used after merging multiple segments into a single large
127742 ** segment to delete the old, now redundant, segment b-trees. Specifically,
127743 ** it:
@@ -127335,41 +127757,36 @@
127757 int iIndex, /* Index for p->aIndex */
127758 int iLevel, /* Level of %_segdir entries to delete */
127759 Fts3SegReader **apSegment, /* Array of SegReader objects */
127760 int nReader /* Size of array apSegment */
127761 ){
127762 int rc = SQLITE_OK; /* Return Code */
127763 int i; /* Iterator variable */
127764 sqlite3_stmt *pDelete = 0; /* SQL statement to delete rows */
127765
 
127766 for(i=0; rc==SQLITE_OK && i<nReader; i++){
127767 rc = fts3DeleteSegment(p, apSegment[i]);
 
 
 
 
 
 
127768 }
127769 if( rc!=SQLITE_OK ){
127770 return rc;
127771 }
127772
127773 assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127774 if( iLevel==FTS3_SEGCURSOR_ALL ){
127775 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127776 if( rc==SQLITE_OK ){
127777 sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127778 sqlite3_bind_int64(pDelete, 2,
127779 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127780 );
127781 }
127782 }else{
127783 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127784 if( rc==SQLITE_OK ){
127785 sqlite3_bind_int64(
127786 pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)
127787 );
127788 }
127789 }
127790
127791 if( rc==SQLITE_OK ){
127792 sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
128259 int iIndex, /* Index in p->aIndex[] to merge */
128260 int iLevel /* Level to merge */
128261 ){
128262 int rc; /* Return code */
128263 int iIdx = 0; /* Index of new segment */
128264 sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */
128265 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
128266 Fts3SegFilter filter; /* Segment term filter condition */
128267 Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
128268 int bIgnoreEmpty = 0; /* True to ignore empty segments */
128269
@@ -127921,15 +128338,32 @@
128338 ** Flush the contents of pendingTerms to level 0 segments.
128339 */
128340 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
128341 int rc = SQLITE_OK;
128342 int i;
128343
128344 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
128345 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
128346 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
128347 }
128348 sqlite3Fts3PendingTermsClear(p);
128349
128350 /* Determine the auto-incr-merge setting if unknown. If enabled,
128351 ** estimate the number of leaf blocks of content to be written
128352 */
128353 if( rc==SQLITE_OK && p->bHasStat
128354 && p->bAutoincrmerge==0xff && p->nLeafAdd>0
128355 ){
128356 sqlite3_stmt *pStmt = 0;
128357 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128358 if( rc==SQLITE_OK ){
128359 sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
128360 rc = sqlite3_step(pStmt);
128361 p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
128362 rc = sqlite3_reset(pStmt);
128363 }
128364 }
128365 return rc;
128366 }
128367
128368 /*
128369 ** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128470 if( a==0 ){
128471 *pRC = SQLITE_NOMEM;
128472 return;
128473 }
128474 pBlob = (char*)&a[nStat];
128475 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128476 if( rc ){
128477 sqlite3_free(a);
128478 *pRC = rc;
128479 return;
128480 }
128481 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128482 if( sqlite3_step(pStmt)==SQLITE_ROW ){
128483 fts3DecodeIntArray(nStat, a,
128484 sqlite3_column_blob(pStmt, 0),
128485 sqlite3_column_bytes(pStmt, 0));
128486 }else{
@@ -128065,17 +128500,18 @@
128500 x = x + aSzIns[i] - aSzDel[i];
128501 }
128502 a[i+1] = x;
128503 }
128504 fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128505 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
128506 if( rc ){
128507 sqlite3_free(a);
128508 *pRC = rc;
128509 return;
128510 }
128511 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128512 sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);
128513 sqlite3_step(pStmt);
128514 *pRC = sqlite3_reset(pStmt);
128515 sqlite3_free(a);
128516 }
128517
@@ -128176,11 +128612,11 @@
128612 for(iCol=0; iCol<=p->nColumn; iCol++){
128613 aSzIns[iCol] += aSz[iCol];
128614 }
128615 }
128616 }
128617 if( p->bFts4 ){
128618 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128619 }
128620 sqlite3_free(aSz);
128621
128622 if( pStmt ){
@@ -128192,10 +128628,1692 @@
128628 }
128629
128630 return rc;
128631 }
128632
128633
128634 /*
128635 ** This function opens a cursor used to read the input data for an
128636 ** incremental merge operation. Specifically, it opens a cursor to scan
128637 ** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute
128638 ** level iAbsLevel.
128639 */
128640 static int fts3IncrmergeCsr(
128641 Fts3Table *p, /* FTS3 table handle */
128642 sqlite3_int64 iAbsLevel, /* Absolute level to open */
128643 int nSeg, /* Number of segments to merge */
128644 Fts3MultiSegReader *pCsr /* Cursor object to populate */
128645 ){
128646 int rc; /* Return Code */
128647 sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */
128648 int nByte; /* Bytes allocated at pCsr->apSegment[] */
128649
128650 /* Allocate space for the Fts3MultiSegReader.aCsr[] array */
128651 memset(pCsr, 0, sizeof(*pCsr));
128652 nByte = sizeof(Fts3SegReader *) * nSeg;
128653 pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);
128654
128655 if( pCsr->apSegment==0 ){
128656 rc = SQLITE_NOMEM;
128657 }else{
128658 memset(pCsr->apSegment, 0, nByte);
128659 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
128660 }
128661 if( rc==SQLITE_OK ){
128662 int i;
128663 int rc2;
128664 sqlite3_bind_int64(pStmt, 1, iAbsLevel);
128665 assert( pCsr->nSegment==0 );
128666 for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){
128667 rc = sqlite3Fts3SegReaderNew(i, 0,
128668 sqlite3_column_int64(pStmt, 1), /* segdir.start_block */
128669 sqlite3_column_int64(pStmt, 2), /* segdir.leaves_end_block */
128670 sqlite3_column_int64(pStmt, 3), /* segdir.end_block */
128671 sqlite3_column_blob(pStmt, 4), /* segdir.root */
128672 sqlite3_column_bytes(pStmt, 4), /* segdir.root */
128673 &pCsr->apSegment[i]
128674 );
128675 pCsr->nSegment++;
128676 }
128677 rc2 = sqlite3_reset(pStmt);
128678 if( rc==SQLITE_OK ) rc = rc2;
128679 }
128680
128681 return rc;
128682 }
128683
128684 typedef struct IncrmergeWriter IncrmergeWriter;
128685 typedef struct NodeWriter NodeWriter;
128686 typedef struct Blob Blob;
128687 typedef struct NodeReader NodeReader;
128688
128689 /*
128690 ** An instance of the following structure is used as a dynamic buffer
128691 ** to build up nodes or other blobs of data in.
128692 **
128693 ** The function blobGrowBuffer() is used to extend the allocation.
128694 */
128695 struct Blob {
128696 char *a; /* Pointer to allocation */
128697 int n; /* Number of valid bytes of data in a[] */
128698 int nAlloc; /* Allocated size of a[] (nAlloc>=n) */
128699 };
128700
128701 /*
128702 ** This structure is used to build up buffers containing segment b-tree
128703 ** nodes (blocks).
128704 */
128705 struct NodeWriter {
128706 sqlite3_int64 iBlock; /* Current block id */
128707 Blob key; /* Last key written to the current block */
128708 Blob block; /* Current block image */
128709 };
128710
128711 /*
128712 ** An object of this type contains the state required to create or append
128713 ** to an appendable b-tree segment.
128714 */
128715 struct IncrmergeWriter {
128716 int nLeafEst; /* Space allocated for leaf blocks */
128717 int nWork; /* Number of leaf pages flushed */
128718 sqlite3_int64 iAbsLevel; /* Absolute level of input segments */
128719 int iIdx; /* Index of *output* segment in iAbsLevel+1 */
128720 sqlite3_int64 iStart; /* Block number of first allocated block */
128721 sqlite3_int64 iEnd; /* Block number of last allocated block */
128722 NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];
128723 };
128724
128725 /*
128726 ** An object of the following type is used to read data from a single
128727 ** FTS segment node. See the following functions:
128728 **
128729 ** nodeReaderInit()
128730 ** nodeReaderNext()
128731 ** nodeReaderRelease()
128732 */
128733 struct NodeReader {
128734 const char *aNode;
128735 int nNode;
128736 int iOff; /* Current offset within aNode[] */
128737
128738 /* Output variables. Containing the current node entry. */
128739 sqlite3_int64 iChild; /* Pointer to child node */
128740 Blob term; /* Current term */
128741 const char *aDoclist; /* Pointer to doclist */
128742 int nDoclist; /* Size of doclist in bytes */
128743 };
128744
128745 /*
128746 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
128747 ** Otherwise, if the allocation at pBlob->a is not already at least nMin
128748 ** bytes in size, extend (realloc) it to be so.
128749 **
128750 ** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a
128751 ** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc
128752 ** to reflect the new size of the pBlob->a[] buffer.
128753 */
128754 static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){
128755 if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){
128756 int nAlloc = nMin;
128757 char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);
128758 if( a ){
128759 pBlob->nAlloc = nAlloc;
128760 pBlob->a = a;
128761 }else{
128762 *pRc = SQLITE_NOMEM;
128763 }
128764 }
128765 }
128766
128767 /*
128768 ** Attempt to advance the node-reader object passed as the first argument to
128769 ** the next entry on the node.
128770 **
128771 ** Return an error code if an error occurs (SQLITE_NOMEM is possible).
128772 ** Otherwise return SQLITE_OK. If there is no next entry on the node
128773 ** (e.g. because the current entry is the last) set NodeReader->aNode to
128774 ** NULL to indicate EOF. Otherwise, populate the NodeReader structure output
128775 ** variables for the new entry.
128776 */
128777 static int nodeReaderNext(NodeReader *p){
128778 int bFirst = (p->term.n==0); /* True for first term on the node */
128779 int nPrefix = 0; /* Bytes to copy from previous term */
128780 int nSuffix = 0; /* Bytes to append to the prefix */
128781 int rc = SQLITE_OK; /* Return code */
128782
128783 assert( p->aNode );
128784 if( p->iChild && bFirst==0 ) p->iChild++;
128785 if( p->iOff>=p->nNode ){
128786 /* EOF */
128787 p->aNode = 0;
128788 }else{
128789 if( bFirst==0 ){
128790 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
128791 }
128792 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
128793
128794 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
128795 if( rc==SQLITE_OK ){
128796 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
128797 p->term.n = nPrefix+nSuffix;
128798 p->iOff += nSuffix;
128799 if( p->iChild==0 ){
128800 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
128801 p->aDoclist = &p->aNode[p->iOff];
128802 p->iOff += p->nDoclist;
128803 }
128804 }
128805 }
128806
128807 assert( p->iOff<=p->nNode );
128808
128809 return rc;
128810 }
128811
128812 /*
128813 ** Release all dynamic resources held by node-reader object *p.
128814 */
128815 static void nodeReaderRelease(NodeReader *p){
128816 sqlite3_free(p->term.a);
128817 }
128818
128819 /*
128820 ** Initialize a node-reader object to read the node in buffer aNode/nNode.
128821 **
128822 ** If successful, SQLITE_OK is returned and the NodeReader object set to
128823 ** point to the first entry on the node (if any). Otherwise, an SQLite
128824 ** error code is returned.
128825 */
128826 static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){
128827 memset(p, 0, sizeof(NodeReader));
128828 p->aNode = aNode;
128829 p->nNode = nNode;
128830
128831 /* Figure out if this is a leaf or an internal node. */
128832 if( p->aNode[0] ){
128833 /* An internal node. */
128834 p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);
128835 }else{
128836 p->iOff = 1;
128837 }
128838
128839 return nodeReaderNext(p);
128840 }
128841
128842 /*
128843 ** This function is called while writing an FTS segment each time a leaf o
128844 ** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed
128845 ** to be greater than the largest key on the node just written, but smaller
128846 ** than or equal to the first key that will be written to the next leaf
128847 ** node.
128848 **
128849 ** The block id of the leaf node just written to disk may be found in
128850 ** (pWriter->aNodeWriter[0].iBlock) when this function is called.
128851 */
128852 static int fts3IncrmergePush(
128853 Fts3Table *p, /* Fts3 table handle */
128854 IncrmergeWriter *pWriter, /* Writer object */
128855 const char *zTerm, /* Term to write to internal node */
128856 int nTerm /* Bytes at zTerm */
128857 ){
128858 sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
128859 int iLayer;
128860
128861 assert( nTerm>0 );
128862 for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){
128863 sqlite3_int64 iNextPtr = 0;
128864 NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
128865 int rc = SQLITE_OK;
128866 int nPrefix;
128867 int nSuffix;
128868 int nSpace;
128869
128870 /* Figure out how much space the key will consume if it is written to
128871 ** the current node of layer iLayer. Due to the prefix compression,
128872 ** the space required changes depending on which node the key is to
128873 ** be added to. */
128874 nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
128875 nSuffix = nTerm - nPrefix;
128876 nSpace = sqlite3Fts3VarintLen(nPrefix);
128877 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
128878
128879 if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
128880 /* If the current node of layer iLayer contains zero keys, or if adding
128881 ** the key to it will not cause it to grow to larger than nNodeSize
128882 ** bytes in size, write the key here. */
128883
128884 Blob *pBlk = &pNode->block;
128885 if( pBlk->n==0 ){
128886 blobGrowBuffer(pBlk, p->nNodeSize, &rc);
128887 if( rc==SQLITE_OK ){
128888 pBlk->a[0] = (char)iLayer;
128889 pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);
128890 }
128891 }
128892 blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);
128893 blobGrowBuffer(&pNode->key, nTerm, &rc);
128894
128895 if( rc==SQLITE_OK ){
128896 if( pNode->key.n ){
128897 pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);
128898 }
128899 pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);
128900 memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);
128901 pBlk->n += nSuffix;
128902
128903 memcpy(pNode->key.a, zTerm, nTerm);
128904 pNode->key.n = nTerm;
128905 }
128906 }else{
128907 /* Otherwise, flush the the current node of layer iLayer to disk.
128908 ** Then allocate a new, empty sibling node. The key will be written
128909 ** into the parent of this node. */
128910 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
128911
128912 assert( pNode->block.nAlloc>=p->nNodeSize );
128913 pNode->block.a[0] = (char)iLayer;
128914 pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);
128915
128916 iNextPtr = pNode->iBlock;
128917 pNode->iBlock++;
128918 pNode->key.n = 0;
128919 }
128920
128921 if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;
128922 iPtr = iNextPtr;
128923 }
128924
128925 assert( 0 );
128926 return 0;
128927 }
128928
128929 /*
128930 ** Append a term and (optionally) doclist to the FTS segment node currently
128931 ** stored in blob *pNode. The node need not contain any terms, but the
128932 ** header must be written before this function is called.
128933 **
128934 ** A node header is a single 0x00 byte for a leaf node, or a height varint
128935 ** followed by the left-hand-child varint for an internal node.
128936 **
128937 ** The term to be appended is passed via arguments zTerm/nTerm. For a
128938 ** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal
128939 ** node, both aDoclist and nDoclist must be passed 0.
128940 **
128941 ** If the size of the value in blob pPrev is zero, then this is the first
128942 ** term written to the node. Otherwise, pPrev contains a copy of the
128943 ** previous term. Before this function returns, it is updated to contain a
128944 ** copy of zTerm/nTerm.
128945 **
128946 ** It is assumed that the buffer associated with pNode is already large
128947 ** enough to accommodate the new entry. The buffer associated with pPrev
128948 ** is extended by this function if requrired.
128949 **
128950 ** If an error (i.e. OOM condition) occurs, an SQLite error code is
128951 ** returned. Otherwise, SQLITE_OK.
128952 */
128953 static int fts3AppendToNode(
128954 Blob *pNode, /* Current node image to append to */
128955 Blob *pPrev, /* Buffer containing previous term written */
128956 const char *zTerm, /* New term to write */
128957 int nTerm, /* Size of zTerm in bytes */
128958 const char *aDoclist, /* Doclist (or NULL) to write */
128959 int nDoclist /* Size of aDoclist in bytes */
128960 ){
128961 int rc = SQLITE_OK; /* Return code */
128962 int bFirst = (pPrev->n==0); /* True if this is the first term written */
128963 int nPrefix; /* Size of term prefix in bytes */
128964 int nSuffix; /* Size of term suffix in bytes */
128965
128966 /* Node must have already been started. There must be a doclist for a
128967 ** leaf node, and there must not be a doclist for an internal node. */
128968 assert( pNode->n>0 );
128969 assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
128970
128971 blobGrowBuffer(pPrev, nTerm, &rc);
128972 if( rc!=SQLITE_OK ) return rc;
128973
128974 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
128975 nSuffix = nTerm - nPrefix;
128976 memcpy(pPrev->a, zTerm, nTerm);
128977 pPrev->n = nTerm;
128978
128979 if( bFirst==0 ){
128980 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
128981 }
128982 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);
128983 memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);
128984 pNode->n += nSuffix;
128985
128986 if( aDoclist ){
128987 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);
128988 memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);
128989 pNode->n += nDoclist;
128990 }
128991
128992 assert( pNode->n<=pNode->nAlloc );
128993
128994 return SQLITE_OK;
128995 }
128996
128997 /*
128998 ** Append the current term and doclist pointed to by cursor pCsr to the
128999 ** appendable b-tree segment opened for writing by pWriter.
129000 **
129001 ** Return SQLITE_OK if successful, or an SQLite error code otherwise.
129002 */
129003 static int fts3IncrmergeAppend(
129004 Fts3Table *p, /* Fts3 table handle */
129005 IncrmergeWriter *pWriter, /* Writer object */
129006 Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */
129007 ){
129008 const char *zTerm = pCsr->zTerm;
129009 int nTerm = pCsr->nTerm;
129010 const char *aDoclist = pCsr->aDoclist;
129011 int nDoclist = pCsr->nDoclist;
129012 int rc = SQLITE_OK; /* Return code */
129013 int nSpace; /* Total space in bytes required on leaf */
129014 int nPrefix; /* Size of prefix shared with previous term */
129015 int nSuffix; /* Size of suffix (nTerm - nPrefix) */
129016 NodeWriter *pLeaf; /* Object used to write leaf nodes */
129017
129018 pLeaf = &pWriter->aNodeWriter[0];
129019 nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);
129020 nSuffix = nTerm - nPrefix;
129021
129022 nSpace = sqlite3Fts3VarintLen(nPrefix);
129023 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129024 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129025
129026 /* If the current block is not empty, and if adding this term/doclist
129027 ** to the current block would make it larger than Fts3Table.nNodeSize
129028 ** bytes, write this block out to the database. */
129029 if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){
129030 rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
129031 pWriter->nWork++;
129032
129033 /* Add the current term to the parent node. The term added to the
129034 ** parent must:
129035 **
129036 ** a) be greater than the largest term on the leaf node just written
129037 ** to the database (still available in pLeaf->key), and
129038 **
129039 ** b) be less than or equal to the term about to be added to the new
129040 ** leaf node (zTerm/nTerm).
129041 **
129042 ** In other words, it must be the prefix of zTerm 1 byte longer than
129043 ** the common prefix (if any) of zTerm and pWriter->zTerm.
129044 */
129045 if( rc==SQLITE_OK ){
129046 rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
129047 }
129048
129049 /* Advance to the next output block */
129050 pLeaf->iBlock++;
129051 pLeaf->key.n = 0;
129052 pLeaf->block.n = 0;
129053
129054 nPrefix = 0;
129055 nSuffix = nTerm;
129056 nSpace = 1;
129057 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129058 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129059 }
129060
129061 blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);
129062
129063 if( rc==SQLITE_OK ){
129064 if( pLeaf->block.n==0 ){
129065 pLeaf->block.n = 1;
129066 pLeaf->block.a[0] = '\0';
129067 }
129068 rc = fts3AppendToNode(
129069 &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist
129070 );
129071 }
129072
129073 return rc;
129074 }
129075
129076 /*
129077 ** This function is called to release all dynamic resources held by the
129078 ** merge-writer object pWriter, and if no error has occurred, to flush
129079 ** all outstanding node buffers held by pWriter to disk.
129080 **
129081 ** If *pRc is not SQLITE_OK when this function is called, then no attempt
129082 ** is made to write any data to disk. Instead, this function serves only
129083 ** to release outstanding resources.
129084 **
129085 ** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while
129086 ** flushing buffers to disk, *pRc is set to an SQLite error code before
129087 ** returning.
129088 */
129089 static void fts3IncrmergeRelease(
129090 Fts3Table *p, /* FTS3 table handle */
129091 IncrmergeWriter *pWriter, /* Merge-writer object */
129092 int *pRc /* IN/OUT: Error code */
129093 ){
129094 int i; /* Used to iterate through non-root layers */
129095 int iRoot; /* Index of root in pWriter->aNodeWriter */
129096 NodeWriter *pRoot; /* NodeWriter for root node */
129097 int rc = *pRc; /* Error code */
129098
129099 /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment
129100 ** root node. If the segment fits entirely on a single leaf node, iRoot
129101 ** will be set to 0. If the root node is the parent of the leaves, iRoot
129102 ** will be 1. And so on. */
129103 for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){
129104 NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
129105 if( pNode->block.n>0 ) break;
129106 assert( *pRc || pNode->block.nAlloc==0 );
129107 assert( *pRc || pNode->key.nAlloc==0 );
129108 sqlite3_free(pNode->block.a);
129109 sqlite3_free(pNode->key.a);
129110 }
129111
129112 /* Empty output segment. This is a no-op. */
129113 if( iRoot<0 ) return;
129114
129115 /* The entire output segment fits on a single node. Normally, this means
129116 ** the node would be stored as a blob in the "root" column of the %_segdir
129117 ** table. However, this is not permitted in this case. The problem is that
129118 ** space has already been reserved in the %_segments table, and so the
129119 ** start_block and end_block fields of the %_segdir table must be populated.
129120 ** And, by design or by accident, released versions of FTS cannot handle
129121 ** segments that fit entirely on the root node with start_block!=0.
129122 **
129123 ** Instead, create a synthetic root node that contains nothing but a
129124 ** pointer to the single content node. So that the segment consists of a
129125 ** single leaf and a single interior (root) node.
129126 **
129127 ** Todo: Better might be to defer allocating space in the %_segments
129128 ** table until we are sure it is needed.
129129 */
129130 if( iRoot==0 ){
129131 Blob *pBlock = &pWriter->aNodeWriter[1].block;
129132 blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);
129133 if( rc==SQLITE_OK ){
129134 pBlock->a[0] = 0x01;
129135 pBlock->n = 1 + sqlite3Fts3PutVarint(
129136 &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
129137 );
129138 }
129139 iRoot = 1;
129140 }
129141 pRoot = &pWriter->aNodeWriter[iRoot];
129142
129143 /* Flush all currently outstanding nodes to disk. */
129144 for(i=0; i<iRoot; i++){
129145 NodeWriter *pNode = &pWriter->aNodeWriter[i];
129146 if( pNode->block.n>0 && rc==SQLITE_OK ){
129147 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
129148 }
129149 sqlite3_free(pNode->block.a);
129150 sqlite3_free(pNode->key.a);
129151 }
129152
129153 /* Write the %_segdir record. */
129154 if( rc==SQLITE_OK ){
129155 rc = fts3WriteSegdir(p,
129156 pWriter->iAbsLevel+1, /* level */
129157 pWriter->iIdx, /* idx */
129158 pWriter->iStart, /* start_block */
129159 pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
129160 pWriter->iEnd, /* end_block */
129161 pRoot->block.a, pRoot->block.n /* root */
129162 );
129163 }
129164 sqlite3_free(pRoot->block.a);
129165 sqlite3_free(pRoot->key.a);
129166
129167 *pRc = rc;
129168 }
129169
129170 /*
129171 ** Compare the term in buffer zLhs (size in bytes nLhs) with that in
129172 ** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of
129173 ** the other, it is considered to be smaller than the other.
129174 **
129175 ** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve
129176 ** if it is greater.
129177 */
129178 static int fts3TermCmp(
129179 const char *zLhs, int nLhs, /* LHS of comparison */
129180 const char *zRhs, int nRhs /* RHS of comparison */
129181 ){
129182 int nCmp = MIN(nLhs, nRhs);
129183 int res;
129184
129185 res = memcmp(zLhs, zRhs, nCmp);
129186 if( res==0 ) res = nLhs - nRhs;
129187
129188 return res;
129189 }
129190
129191
129192 /*
129193 ** Query to see if the entry in the %_segments table with blockid iEnd is
129194 ** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before
129195 ** returning. Otherwise, set *pbRes to 0.
129196 **
129197 ** Or, if an error occurs while querying the database, return an SQLite
129198 ** error code. The final value of *pbRes is undefined in this case.
129199 **
129200 ** This is used to test if a segment is an "appendable" segment. If it
129201 ** is, then a NULL entry has been inserted into the %_segments table
129202 ** with blockid %_segdir.end_block.
129203 */
129204 static int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){
129205 int bRes = 0; /* Result to set *pbRes to */
129206 sqlite3_stmt *pCheck = 0; /* Statement to query database with */
129207 int rc; /* Return code */
129208
129209 rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
129210 if( rc==SQLITE_OK ){
129211 sqlite3_bind_int64(pCheck, 1, iEnd);
129212 if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
129213 rc = sqlite3_reset(pCheck);
129214 }
129215
129216 *pbRes = bRes;
129217 return rc;
129218 }
129219
129220 /*
129221 ** This function is called when initializing an incremental-merge operation.
129222 ** It checks if the existing segment with index value iIdx at absolute level
129223 ** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the
129224 ** merge-writer object *pWriter is initialized to write to it.
129225 **
129226 ** An existing segment can be appended to by an incremental merge if:
129227 **
129228 ** * It was initially created as an appendable segment (with all required
129229 ** space pre-allocated), and
129230 **
129231 ** * The first key read from the input (arguments zKey and nKey) is
129232 ** greater than the largest key currently stored in the potential
129233 ** output segment.
129234 */
129235 static int fts3IncrmergeLoad(
129236 Fts3Table *p, /* Fts3 table handle */
129237 sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129238 int iIdx, /* Index of candidate output segment */
129239 const char *zKey, /* First key to write */
129240 int nKey, /* Number of bytes in nKey */
129241 IncrmergeWriter *pWriter /* Populate this object */
129242 ){
129243 int rc; /* Return code */
129244 sqlite3_stmt *pSelect = 0; /* SELECT to read %_segdir entry */
129245
129246 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);
129247 if( rc==SQLITE_OK ){
129248 sqlite3_int64 iStart = 0; /* Value of %_segdir.start_block */
129249 sqlite3_int64 iLeafEnd = 0; /* Value of %_segdir.leaves_end_block */
129250 sqlite3_int64 iEnd = 0; /* Value of %_segdir.end_block */
129251 const char *aRoot = 0; /* Pointer to %_segdir.root buffer */
129252 int nRoot = 0; /* Size of aRoot[] in bytes */
129253 int rc2; /* Return code from sqlite3_reset() */
129254 int bAppendable = 0; /* Set to true if segment is appendable */
129255
129256 /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */
129257 sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);
129258 sqlite3_bind_int(pSelect, 2, iIdx);
129259 if( sqlite3_step(pSelect)==SQLITE_ROW ){
129260 iStart = sqlite3_column_int64(pSelect, 1);
129261 iLeafEnd = sqlite3_column_int64(pSelect, 2);
129262 iEnd = sqlite3_column_int64(pSelect, 3);
129263 nRoot = sqlite3_column_bytes(pSelect, 4);
129264 aRoot = sqlite3_column_blob(pSelect, 4);
129265 }else{
129266 return sqlite3_reset(pSelect);
129267 }
129268
129269 /* Check for the zero-length marker in the %_segments table */
129270 rc = fts3IsAppendable(p, iEnd, &bAppendable);
129271
129272 /* Check that zKey/nKey is larger than the largest key the candidate */
129273 if( rc==SQLITE_OK && bAppendable ){
129274 char *aLeaf = 0;
129275 int nLeaf = 0;
129276
129277 rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);
129278 if( rc==SQLITE_OK ){
129279 NodeReader reader;
129280 for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);
129281 rc==SQLITE_OK && reader.aNode;
129282 rc = nodeReaderNext(&reader)
129283 ){
129284 assert( reader.aNode );
129285 }
129286 if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){
129287 bAppendable = 0;
129288 }
129289 nodeReaderRelease(&reader);
129290 }
129291 sqlite3_free(aLeaf);
129292 }
129293
129294 if( rc==SQLITE_OK && bAppendable ){
129295 /* It is possible to append to this segment. Set up the IncrmergeWriter
129296 ** object to do so. */
129297 int i;
129298 int nHeight = (int)aRoot[0];
129299 NodeWriter *pNode;
129300
129301 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
129302 pWriter->iStart = iStart;
129303 pWriter->iEnd = iEnd;
129304 pWriter->iAbsLevel = iAbsLevel;
129305 pWriter->iIdx = iIdx;
129306
129307 for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129308 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129309 }
129310
129311 pNode = &pWriter->aNodeWriter[nHeight];
129312 pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
129313 blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
129314 if( rc==SQLITE_OK ){
129315 memcpy(pNode->block.a, aRoot, nRoot);
129316 pNode->block.n = nRoot;
129317 }
129318
129319 for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
129320 NodeReader reader;
129321 pNode = &pWriter->aNodeWriter[i];
129322
129323 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
129324 while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
129325 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
129326 if( rc==SQLITE_OK ){
129327 memcpy(pNode->key.a, reader.term.a, reader.term.n);
129328 pNode->key.n = reader.term.n;
129329 if( i>0 ){
129330 char *aBlock = 0;
129331 int nBlock = 0;
129332 pNode = &pWriter->aNodeWriter[i-1];
129333 pNode->iBlock = reader.iChild;
129334 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
129335 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
129336 if( rc==SQLITE_OK ){
129337 memcpy(pNode->block.a, aBlock, nBlock);
129338 pNode->block.n = nBlock;
129339 }
129340 sqlite3_free(aBlock);
129341 }
129342 }
129343 nodeReaderRelease(&reader);
129344 }
129345 }
129346
129347 rc2 = sqlite3_reset(pSelect);
129348 if( rc==SQLITE_OK ) rc = rc2;
129349 }
129350
129351 return rc;
129352 }
129353
129354 /*
129355 ** Determine the largest segment index value that exists within absolute
129356 ** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus
129357 ** one before returning SQLITE_OK. Or, if there are no segments at all
129358 ** within level iAbsLevel, set *piIdx to zero.
129359 **
129360 ** If an error occurs, return an SQLite error code. The final value of
129361 ** *piIdx is undefined in this case.
129362 */
129363 static int fts3IncrmergeOutputIdx(
129364 Fts3Table *p, /* FTS Table handle */
129365 sqlite3_int64 iAbsLevel, /* Absolute index of input segments */
129366 int *piIdx /* OUT: Next free index at iAbsLevel+1 */
129367 ){
129368 int rc;
129369 sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */
129370
129371 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);
129372 if( rc==SQLITE_OK ){
129373 sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);
129374 sqlite3_step(pOutputIdx);
129375 *piIdx = sqlite3_column_int(pOutputIdx, 0);
129376 rc = sqlite3_reset(pOutputIdx);
129377 }
129378
129379 return rc;
129380 }
129381
129382 /*
129383 ** Allocate an appendable output segment on absolute level iAbsLevel+1
129384 ** with idx value iIdx.
129385 **
129386 ** In the %_segdir table, a segment is defined by the values in three
129387 ** columns:
129388 **
129389 ** start_block
129390 ** leaves_end_block
129391 ** end_block
129392 **
129393 ** When an appendable segment is allocated, it is estimated that the
129394 ** maximum number of leaf blocks that may be required is the sum of the
129395 ** number of leaf blocks consumed by the input segments, plus the number
129396 ** of input segments, multiplied by two. This value is stored in stack
129397 ** variable nLeafEst.
129398 **
129399 ** A total of 16*nLeafEst blocks are allocated when an appendable segment
129400 ** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous
129401 ** array of leaf nodes starts at the first block allocated. The array
129402 ** of interior nodes that are parents of the leaf nodes start at block
129403 ** (start_block + (1 + end_block - start_block) / 16). And so on.
129404 **
129405 ** In the actual code below, the value "16" is replaced with the
129406 ** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.
129407 */
129408 static int fts3IncrmergeWriter(
129409 Fts3Table *p, /* Fts3 table handle */
129410 sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129411 int iIdx, /* Index of new output segment */
129412 Fts3MultiSegReader *pCsr, /* Cursor that data will be read from */
129413 IncrmergeWriter *pWriter /* Populate this object */
129414 ){
129415 int rc; /* Return Code */
129416 int i; /* Iterator variable */
129417 int nLeafEst = 0; /* Blocks allocated for leaf nodes */
129418 sqlite3_stmt *pLeafEst = 0; /* SQL used to determine nLeafEst */
129419 sqlite3_stmt *pFirstBlock = 0; /* SQL used to determine first block */
129420
129421 /* Calculate nLeafEst. */
129422 rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);
129423 if( rc==SQLITE_OK ){
129424 sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);
129425 sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);
129426 if( SQLITE_ROW==sqlite3_step(pLeafEst) ){
129427 nLeafEst = sqlite3_column_int(pLeafEst, 0);
129428 }
129429 rc = sqlite3_reset(pLeafEst);
129430 }
129431 if( rc!=SQLITE_OK ) return rc;
129432
129433 /* Calculate the first block to use in the output segment */
129434 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);
129435 if( rc==SQLITE_OK ){
129436 if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){
129437 pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
129438 pWriter->iEnd = pWriter->iStart - 1;
129439 pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
129440 }
129441 rc = sqlite3_reset(pFirstBlock);
129442 }
129443 if( rc!=SQLITE_OK ) return rc;
129444
129445 /* Insert the marker in the %_segments table to make sure nobody tries
129446 ** to steal the space just allocated. This is also used to identify
129447 ** appendable segments. */
129448 rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
129449 if( rc!=SQLITE_OK ) return rc;
129450
129451 pWriter->iAbsLevel = iAbsLevel;
129452 pWriter->nLeafEst = nLeafEst;
129453 pWriter->iIdx = iIdx;
129454
129455 /* Set up the array of NodeWriter objects */
129456 for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129457 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129458 }
129459 return SQLITE_OK;
129460 }
129461
129462 /*
129463 ** Remove an entry from the %_segdir table. This involves running the
129464 ** following two statements:
129465 **
129466 ** DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx
129467 ** UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx
129468 **
129469 ** The DELETE statement removes the specific %_segdir level. The UPDATE
129470 ** statement ensures that the remaining segments have contiguously allocated
129471 ** idx values.
129472 */
129473 static int fts3RemoveSegdirEntry(
129474 Fts3Table *p, /* FTS3 table handle */
129475 sqlite3_int64 iAbsLevel, /* Absolute level to delete from */
129476 int iIdx /* Index of %_segdir entry to delete */
129477 ){
129478 int rc; /* Return code */
129479 sqlite3_stmt *pDelete = 0; /* DELETE statement */
129480
129481 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);
129482 if( rc==SQLITE_OK ){
129483 sqlite3_bind_int64(pDelete, 1, iAbsLevel);
129484 sqlite3_bind_int(pDelete, 2, iIdx);
129485 sqlite3_step(pDelete);
129486 rc = sqlite3_reset(pDelete);
129487 }
129488
129489 return rc;
129490 }
129491
129492 /*
129493 ** One or more segments have just been removed from absolute level iAbsLevel.
129494 ** Update the 'idx' values of the remaining segments in the level so that
129495 ** the idx values are a contiguous sequence starting from 0.
129496 */
129497 static int fts3RepackSegdirLevel(
129498 Fts3Table *p, /* FTS3 table handle */
129499 sqlite3_int64 iAbsLevel /* Absolute level to repack */
129500 ){
129501 int rc; /* Return code */
129502 int *aIdx = 0; /* Array of remaining idx values */
129503 int nIdx = 0; /* Valid entries in aIdx[] */
129504 int nAlloc = 0; /* Allocated size of aIdx[] */
129505 int i; /* Iterator variable */
129506 sqlite3_stmt *pSelect = 0; /* Select statement to read idx values */
129507 sqlite3_stmt *pUpdate = 0; /* Update statement to modify idx values */
129508
129509 rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);
129510 if( rc==SQLITE_OK ){
129511 int rc2;
129512 sqlite3_bind_int64(pSelect, 1, iAbsLevel);
129513 while( SQLITE_ROW==sqlite3_step(pSelect) ){
129514 if( nIdx>=nAlloc ){
129515 int *aNew;
129516 nAlloc += 16;
129517 aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));
129518 if( !aNew ){
129519 rc = SQLITE_NOMEM;
129520 break;
129521 }
129522 aIdx = aNew;
129523 }
129524 aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);
129525 }
129526 rc2 = sqlite3_reset(pSelect);
129527 if( rc==SQLITE_OK ) rc = rc2;
129528 }
129529
129530 if( rc==SQLITE_OK ){
129531 rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);
129532 }
129533 if( rc==SQLITE_OK ){
129534 sqlite3_bind_int64(pUpdate, 2, iAbsLevel);
129535 }
129536
129537 assert( p->bIgnoreSavepoint==0 );
129538 p->bIgnoreSavepoint = 1;
129539 for(i=0; rc==SQLITE_OK && i<nIdx; i++){
129540 if( aIdx[i]!=i ){
129541 sqlite3_bind_int(pUpdate, 3, aIdx[i]);
129542 sqlite3_bind_int(pUpdate, 1, i);
129543 sqlite3_step(pUpdate);
129544 rc = sqlite3_reset(pUpdate);
129545 }
129546 }
129547 p->bIgnoreSavepoint = 0;
129548
129549 sqlite3_free(aIdx);
129550 return rc;
129551 }
129552
129553 static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){
129554 pNode->a[0] = (char)iHeight;
129555 if( iChild ){
129556 assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );
129557 pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);
129558 }else{
129559 assert( pNode->nAlloc>=1 );
129560 pNode->n = 1;
129561 }
129562 }
129563
129564 /*
129565 ** The first two arguments are a pointer to and the size of a segment b-tree
129566 ** node. The node may be a leaf or an internal node.
129567 **
129568 ** This function creates a new node image in blob object *pNew by copying
129569 ** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)
129570 ** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.
129571 */
129572 static int fts3TruncateNode(
129573 const char *aNode, /* Current node image */
129574 int nNode, /* Size of aNode in bytes */
129575 Blob *pNew, /* OUT: Write new node image here */
129576 const char *zTerm, /* Omit all terms smaller than this */
129577 int nTerm, /* Size of zTerm in bytes */
129578 sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
129579 ){
129580 NodeReader reader; /* Reader object */
129581 Blob prev = {0, 0, 0}; /* Previous term written to new node */
129582 int rc = SQLITE_OK; /* Return code */
129583 int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
129584
129585 /* Allocate required output space */
129586 blobGrowBuffer(pNew, nNode, &rc);
129587 if( rc!=SQLITE_OK ) return rc;
129588 pNew->n = 0;
129589
129590 /* Populate new node buffer */
129591 for(rc = nodeReaderInit(&reader, aNode, nNode);
129592 rc==SQLITE_OK && reader.aNode;
129593 rc = nodeReaderNext(&reader)
129594 ){
129595 if( pNew->n==0 ){
129596 int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);
129597 if( res<0 || (bLeaf==0 && res==0) ) continue;
129598 fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129599 *piBlock = reader.iChild;
129600 }
129601 rc = fts3AppendToNode(
129602 pNew, &prev, reader.term.a, reader.term.n,
129603 reader.aDoclist, reader.nDoclist
129604 );
129605 if( rc!=SQLITE_OK ) break;
129606 }
129607 if( pNew->n==0 ){
129608 fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129609 *piBlock = reader.iChild;
129610 }
129611 assert( pNew->n<=pNew->nAlloc );
129612
129613 nodeReaderRelease(&reader);
129614 sqlite3_free(prev.a);
129615 return rc;
129616 }
129617
129618 /*
129619 ** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute
129620 ** level iAbsLevel. This may involve deleting entries from the %_segments
129621 ** table, and modifying existing entries in both the %_segments and %_segdir
129622 ** tables.
129623 **
129624 ** SQLITE_OK is returned if the segment is updated successfully. Or an
129625 ** SQLite error code otherwise.
129626 */
129627 static int fts3TruncateSegment(
129628 Fts3Table *p, /* FTS3 table handle */
129629 sqlite3_int64 iAbsLevel, /* Absolute level of segment to modify */
129630 int iIdx, /* Index within level of segment to modify */
129631 const char *zTerm, /* Remove terms smaller than this */
129632 int nTerm /* Number of bytes in buffer zTerm */
129633 ){
129634 int rc = SQLITE_OK; /* Return code */
129635 Blob root = {0,0,0}; /* New root page image */
129636 Blob block = {0,0,0}; /* Buffer used for any other block */
129637 sqlite3_int64 iBlock = 0; /* Block id */
129638 sqlite3_int64 iNewStart = 0; /* New value for iStartBlock */
129639 sqlite3_int64 iOldStart = 0; /* Old value for iStartBlock */
129640 sqlite3_stmt *pFetch = 0; /* Statement used to fetch segdir */
129641
129642 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);
129643 if( rc==SQLITE_OK ){
129644 int rc2; /* sqlite3_reset() return code */
129645 sqlite3_bind_int64(pFetch, 1, iAbsLevel);
129646 sqlite3_bind_int(pFetch, 2, iIdx);
129647 if( SQLITE_ROW==sqlite3_step(pFetch) ){
129648 const char *aRoot = sqlite3_column_blob(pFetch, 4);
129649 int nRoot = sqlite3_column_bytes(pFetch, 4);
129650 iOldStart = sqlite3_column_int64(pFetch, 1);
129651 rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);
129652 }
129653 rc2 = sqlite3_reset(pFetch);
129654 if( rc==SQLITE_OK ) rc = rc2;
129655 }
129656
129657 while( rc==SQLITE_OK && iBlock ){
129658 char *aBlock = 0;
129659 int nBlock = 0;
129660 iNewStart = iBlock;
129661
129662 rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);
129663 if( rc==SQLITE_OK ){
129664 rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);
129665 }
129666 if( rc==SQLITE_OK ){
129667 rc = fts3WriteSegment(p, iNewStart, block.a, block.n);
129668 }
129669 sqlite3_free(aBlock);
129670 }
129671
129672 /* Variable iNewStart now contains the first valid leaf node. */
129673 if( rc==SQLITE_OK && iNewStart ){
129674 sqlite3_stmt *pDel = 0;
129675 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);
129676 if( rc==SQLITE_OK ){
129677 sqlite3_bind_int64(pDel, 1, iOldStart);
129678 sqlite3_bind_int64(pDel, 2, iNewStart-1);
129679 sqlite3_step(pDel);
129680 rc = sqlite3_reset(pDel);
129681 }
129682 }
129683
129684 if( rc==SQLITE_OK ){
129685 sqlite3_stmt *pChomp = 0;
129686 rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);
129687 if( rc==SQLITE_OK ){
129688 sqlite3_bind_int64(pChomp, 1, iNewStart);
129689 sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);
129690 sqlite3_bind_int64(pChomp, 3, iAbsLevel);
129691 sqlite3_bind_int(pChomp, 4, iIdx);
129692 sqlite3_step(pChomp);
129693 rc = sqlite3_reset(pChomp);
129694 }
129695 }
129696
129697 sqlite3_free(root.a);
129698 sqlite3_free(block.a);
129699 return rc;
129700 }
129701
129702 /*
129703 ** This function is called after an incrmental-merge operation has run to
129704 ** merge (or partially merge) two or more segments from absolute level
129705 ** iAbsLevel.
129706 **
129707 ** Each input segment is either removed from the db completely (if all of
129708 ** its data was copied to the output segment by the incrmerge operation)
129709 ** or modified in place so that it no longer contains those entries that
129710 ** have been duplicated in the output segment.
129711 */
129712 static int fts3IncrmergeChomp(
129713 Fts3Table *p, /* FTS table handle */
129714 sqlite3_int64 iAbsLevel, /* Absolute level containing segments */
129715 Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */
129716 int *pnRem /* Number of segments not deleted */
129717 ){
129718 int i;
129719 int nRem = 0;
129720 int rc = SQLITE_OK;
129721
129722 for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){
129723 Fts3SegReader *pSeg = 0;
129724 int j;
129725
129726 /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding
129727 ** somewhere in the pCsr->apSegment[] array. */
129728 for(j=0; ALWAYS(j<pCsr->nSegment); j++){
129729 pSeg = pCsr->apSegment[j];
129730 if( pSeg->iIdx==i ) break;
129731 }
129732 assert( j<pCsr->nSegment && pSeg->iIdx==i );
129733
129734 if( pSeg->aNode==0 ){
129735 /* Seg-reader is at EOF. Remove the entire input segment. */
129736 rc = fts3DeleteSegment(p, pSeg);
129737 if( rc==SQLITE_OK ){
129738 rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);
129739 }
129740 *pnRem = 0;
129741 }else{
129742 /* The incremental merge did not copy all the data from this
129743 ** segment to the upper level. The segment is modified in place
129744 ** so that it contains no keys smaller than zTerm/nTerm. */
129745 const char *zTerm = pSeg->zTerm;
129746 int nTerm = pSeg->nTerm;
129747 rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);
129748 nRem++;
129749 }
129750 }
129751
129752 if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){
129753 rc = fts3RepackSegdirLevel(p, iAbsLevel);
129754 }
129755
129756 *pnRem = nRem;
129757 return rc;
129758 }
129759
129760 /*
129761 ** Store an incr-merge hint in the database.
129762 */
129763 static int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){
129764 sqlite3_stmt *pReplace = 0;
129765 int rc; /* Return code */
129766
129767 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
129768 if( rc==SQLITE_OK ){
129769 sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);
129770 sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);
129771 sqlite3_step(pReplace);
129772 rc = sqlite3_reset(pReplace);
129773 }
129774
129775 return rc;
129776 }
129777
129778 /*
129779 ** Load an incr-merge hint from the database. The incr-merge hint, if one
129780 ** exists, is stored in the rowid==1 row of the %_stat table.
129781 **
129782 ** If successful, populate blob *pHint with the value read from the %_stat
129783 ** table and return SQLITE_OK. Otherwise, if an error occurs, return an
129784 ** SQLite error code.
129785 */
129786 static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){
129787 sqlite3_stmt *pSelect = 0;
129788 int rc;
129789
129790 pHint->n = 0;
129791 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
129792 if( rc==SQLITE_OK ){
129793 int rc2;
129794 sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
129795 if( SQLITE_ROW==sqlite3_step(pSelect) ){
129796 const char *aHint = sqlite3_column_blob(pSelect, 0);
129797 int nHint = sqlite3_column_bytes(pSelect, 0);
129798 if( aHint ){
129799 blobGrowBuffer(pHint, nHint, &rc);
129800 if( rc==SQLITE_OK ){
129801 memcpy(pHint->a, aHint, nHint);
129802 pHint->n = nHint;
129803 }
129804 }
129805 }
129806 rc2 = sqlite3_reset(pSelect);
129807 if( rc==SQLITE_OK ) rc = rc2;
129808 }
129809
129810 return rc;
129811 }
129812
129813 /*
129814 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
129815 ** Otherwise, append an entry to the hint stored in blob *pHint. Each entry
129816 ** consists of two varints, the absolute level number of the input segments
129817 ** and the number of input segments.
129818 **
129819 ** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,
129820 ** set *pRc to an SQLite error code before returning.
129821 */
129822 static void fts3IncrmergeHintPush(
129823 Blob *pHint, /* Hint blob to append to */
129824 i64 iAbsLevel, /* First varint to store in hint */
129825 int nInput, /* Second varint to store in hint */
129826 int *pRc /* IN/OUT: Error code */
129827 ){
129828 blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);
129829 if( *pRc==SQLITE_OK ){
129830 pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);
129831 pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);
129832 }
129833 }
129834
129835 /*
129836 ** Read the last entry (most recently pushed) from the hint blob *pHint
129837 ** and then remove the entry. Write the two values read to *piAbsLevel and
129838 ** *pnInput before returning.
129839 **
129840 ** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does
129841 ** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.
129842 */
129843 static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
129844 const int nHint = pHint->n;
129845 int i;
129846
129847 i = pHint->n-2;
129848 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129849 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129850
129851 pHint->n = i;
129852 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
129853 i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
129854 if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
129855
129856 return SQLITE_OK;
129857 }
129858
129859
129860 /*
129861 ** Attempt an incremental merge that writes nMerge leaf blocks.
129862 **
129863 ** Incremental merges happen nMin segments at a time. The two
129864 ** segments to be merged are the nMin oldest segments (the ones with
129865 ** the smallest indexes) in the highest level that contains at least
129866 ** nMin segments. Multiple merges might occur in an attempt to write the
129867 ** quota of nMerge leaf blocks.
129868 */
129869 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){
129870 int rc; /* Return code */
129871 int nRem = nMerge; /* Number of leaf pages yet to be written */
129872 Fts3MultiSegReader *pCsr; /* Cursor used to read input data */
129873 Fts3SegFilter *pFilter; /* Filter used with cursor pCsr */
129874 IncrmergeWriter *pWriter; /* Writer object */
129875 int nSeg = 0; /* Number of input segments */
129876 sqlite3_int64 iAbsLevel = 0; /* Absolute level number to work on */
129877 Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
129878 int bDirtyHint = 0; /* True if blob 'hint' has been modified */
129879
129880 /* Allocate space for the cursor, filter and writer objects */
129881 const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
129882 pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
129883 if( !pWriter ) return SQLITE_NOMEM;
129884 pFilter = (Fts3SegFilter *)&pWriter[1];
129885 pCsr = (Fts3MultiSegReader *)&pFilter[1];
129886
129887 rc = fts3IncrmergeHintLoad(p, &hint);
129888 while( rc==SQLITE_OK && nRem>0 ){
129889 const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;
129890 sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */
129891 int bUseHint = 0; /* True if attempting to append */
129892
129893 /* Search the %_segdir table for the absolute level with the smallest
129894 ** relative level number that contains at least nMin segments, if any.
129895 ** If one is found, set iAbsLevel to the absolute level number and
129896 ** nSeg to nMin. If no level with at least nMin segments can be found,
129897 ** set nSeg to -1.
129898 */
129899 rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);
129900 sqlite3_bind_int(pFindLevel, 1, nMin);
129901 if( sqlite3_step(pFindLevel)==SQLITE_ROW ){
129902 iAbsLevel = sqlite3_column_int64(pFindLevel, 0);
129903 nSeg = nMin;
129904 }else{
129905 nSeg = -1;
129906 }
129907 rc = sqlite3_reset(pFindLevel);
129908
129909 /* If the hint read from the %_stat table is not empty, check if the
129910 ** last entry in it specifies a relative level smaller than or equal
129911 ** to the level identified by the block above (if any). If so, this
129912 ** iteration of the loop will work on merging at the hinted level.
129913 */
129914 if( rc==SQLITE_OK && hint.n ){
129915 int nHint = hint.n;
129916 sqlite3_int64 iHintAbsLevel = 0; /* Hint level */
129917 int nHintSeg = 0; /* Hint number of segments */
129918
129919 rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);
129920 if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){
129921 iAbsLevel = iHintAbsLevel;
129922 nSeg = nHintSeg;
129923 bUseHint = 1;
129924 bDirtyHint = 1;
129925 }else{
129926 /* This undoes the effect of the HintPop() above - so that no entry
129927 ** is removed from the hint blob. */
129928 hint.n = nHint;
129929 }
129930 }
129931
129932 /* If nSeg is less that zero, then there is no level with at least
129933 ** nMin segments and no hint in the %_stat table. No work to do.
129934 ** Exit early in this case. */
129935 if( nSeg<0 ) break;
129936
129937 /* Open a cursor to iterate through the contents of the oldest nSeg
129938 ** indexes of absolute level iAbsLevel. If this cursor is opened using
129939 ** the 'hint' parameters, it is possible that there are less than nSeg
129940 ** segments available in level iAbsLevel. In this case, no work is
129941 ** done on iAbsLevel - fall through to the next iteration of the loop
129942 ** to start work on some other level. */
129943 memset(pWriter, 0, nAlloc);
129944 pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;
129945 if( rc==SQLITE_OK ){
129946 rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
129947 }
129948 if( SQLITE_OK==rc && pCsr->nSegment==nSeg
129949 && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
129950 && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
129951 ){
129952 int iIdx = 0; /* Largest idx in level (iAbsLevel+1) */
129953 rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);
129954 if( rc==SQLITE_OK ){
129955 if( bUseHint && iIdx>0 ){
129956 const char *zKey = pCsr->zTerm;
129957 int nKey = pCsr->nTerm;
129958 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
129959 }else{
129960 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
129961 }
129962 }
129963
129964 if( rc==SQLITE_OK && pWriter->nLeafEst ){
129965 fts3LogMerge(nSeg, iAbsLevel);
129966 do {
129967 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
129968 if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
129969 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
129970 }while( rc==SQLITE_ROW );
129971
129972 /* Update or delete the input segments */
129973 if( rc==SQLITE_OK ){
129974 nRem -= (1 + pWriter->nWork);
129975 rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
129976 if( nSeg!=0 ){
129977 bDirtyHint = 1;
129978 fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);
129979 }
129980 }
129981 }
129982
129983 fts3IncrmergeRelease(p, pWriter, &rc);
129984 }
129985
129986 sqlite3Fts3SegReaderFinish(pCsr);
129987 }
129988
129989 /* Write the hint values into the %_stat table for the next incr-merger */
129990 if( bDirtyHint && rc==SQLITE_OK ){
129991 rc = fts3IncrmergeHintStore(p, &hint);
129992 }
129993
129994 sqlite3_free(pWriter);
129995 sqlite3_free(hint.a);
129996 return rc;
129997 }
129998
129999 /*
130000 ** Convert the text beginning at *pz into an integer and return
130001 ** its value. Advance *pz to point to the first character past
130002 ** the integer.
130003 */
130004 static int fts3Getint(const char **pz){
130005 const char *z = *pz;
130006 int i = 0;
130007 while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0';
130008 *pz = z;
130009 return i;
130010 }
130011
130012 /*
130013 ** Process statements of the form:
130014 **
130015 ** INSERT INTO table(table) VALUES('merge=A,B');
130016 **
130017 ** A and B are integers that decode to be the number of leaf pages
130018 ** written for the merge, and the minimum number of segments on a level
130019 ** before it will be selected for a merge, respectively.
130020 */
130021 static int fts3DoIncrmerge(
130022 Fts3Table *p, /* FTS3 table handle */
130023 const char *zParam /* Nul-terminated string containing "A,B" */
130024 ){
130025 int rc;
130026 int nMin = (FTS3_MERGE_COUNT / 2);
130027 int nMerge = 0;
130028 const char *z = zParam;
130029
130030 /* Read the first integer value */
130031 nMerge = fts3Getint(&z);
130032
130033 /* If the first integer value is followed by a ',', read the second
130034 ** integer value. */
130035 if( z[0]==',' && z[1]!='\0' ){
130036 z++;
130037 nMin = fts3Getint(&z);
130038 }
130039
130040 if( z[0]!='\0' || nMin<2 ){
130041 rc = SQLITE_ERROR;
130042 }else{
130043 rc = SQLITE_OK;
130044 if( !p->bHasStat ){
130045 assert( p->bFts4==0 );
130046 sqlite3Fts3CreateStatTable(&rc, p);
130047 }
130048 if( rc==SQLITE_OK ){
130049 rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);
130050 }
130051 sqlite3Fts3SegmentsClose(p);
130052 }
130053 return rc;
130054 }
130055
130056 /*
130057 ** Process statements of the form:
130058 **
130059 ** INSERT INTO table(table) VALUES('automerge=X');
130060 **
130061 ** where X is an integer. X==0 means to turn automerge off. X!=0 means
130062 ** turn it on. The setting is persistent.
130063 */
130064 static int fts3DoAutoincrmerge(
130065 Fts3Table *p, /* FTS3 table handle */
130066 const char *zParam /* Nul-terminated string containing boolean */
130067 ){
130068 int rc = SQLITE_OK;
130069 sqlite3_stmt *pStmt = 0;
130070 p->bAutoincrmerge = fts3Getint(&zParam)!=0;
130071 if( !p->bHasStat ){
130072 assert( p->bFts4==0 );
130073 sqlite3Fts3CreateStatTable(&rc, p);
130074 if( rc ) return rc;
130075 }
130076 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
130077 if( rc ) return rc;;
130078 sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
130079 sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);
130080 sqlite3_step(pStmt);
130081 rc = sqlite3_reset(pStmt);
130082 return rc;
130083 }
130084
130085 /*
130086 ** Return a 64-bit checksum for the FTS index entry specified by the
130087 ** arguments to this function.
130088 */
130089 static u64 fts3ChecksumEntry(
130090 const char *zTerm, /* Pointer to buffer containing term */
130091 int nTerm, /* Size of zTerm in bytes */
130092 int iLangid, /* Language id for current row */
130093 int iIndex, /* Index (0..Fts3Table.nIndex-1) */
130094 i64 iDocid, /* Docid for current row. */
130095 int iCol, /* Column number */
130096 int iPos /* Position */
130097 ){
130098 int i;
130099 u64 ret = (u64)iDocid;
130100
130101 ret += (ret<<3) + iLangid;
130102 ret += (ret<<3) + iIndex;
130103 ret += (ret<<3) + iCol;
130104 ret += (ret<<3) + iPos;
130105 for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];
130106
130107 return ret;
130108 }
130109
130110 /*
130111 ** Return a checksum of all entries in the FTS index that correspond to
130112 ** language id iLangid. The checksum is calculated by XORing the checksums
130113 ** of each individual entry (see fts3ChecksumEntry()) together.
130114 **
130115 ** If successful, the checksum value is returned and *pRc set to SQLITE_OK.
130116 ** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The
130117 ** return value is undefined in this case.
130118 */
130119 static u64 fts3ChecksumIndex(
130120 Fts3Table *p, /* FTS3 table handle */
130121 int iLangid, /* Language id to return cksum for */
130122 int iIndex, /* Index to cksum (0..p->nIndex-1) */
130123 int *pRc /* OUT: Return code */
130124 ){
130125 Fts3SegFilter filter;
130126 Fts3MultiSegReader csr;
130127 int rc;
130128 u64 cksum = 0;
130129
130130 assert( *pRc==SQLITE_OK );
130131
130132 memset(&filter, 0, sizeof(filter));
130133 memset(&csr, 0, sizeof(csr));
130134 filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
130135 filter.flags |= FTS3_SEGMENT_SCAN;
130136
130137 rc = sqlite3Fts3SegReaderCursor(
130138 p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr
130139 );
130140 if( rc==SQLITE_OK ){
130141 rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
130142 }
130143
130144 if( rc==SQLITE_OK ){
130145 while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){
130146 char *pCsr = csr.aDoclist;
130147 char *pEnd = &pCsr[csr.nDoclist];
130148
130149 i64 iDocid = 0;
130150 i64 iCol = 0;
130151 i64 iPos = 0;
130152
130153 pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
130154 while( pCsr<pEnd ){
130155 i64 iVal = 0;
130156 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130157 if( pCsr<pEnd ){
130158 if( iVal==0 || iVal==1 ){
130159 iCol = 0;
130160 iPos = 0;
130161 if( iVal ){
130162 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
130163 }else{
130164 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130165 iDocid += iVal;
130166 }
130167 }else{
130168 iPos += (iVal - 2);
130169 cksum = cksum ^ fts3ChecksumEntry(
130170 csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
130171 (int)iCol, (int)iPos
130172 );
130173 }
130174 }
130175 }
130176 }
130177 }
130178 sqlite3Fts3SegReaderFinish(&csr);
130179
130180 *pRc = rc;
130181 return cksum;
130182 }
130183
130184 /*
130185 ** Check if the contents of the FTS index match the current contents of the
130186 ** content table. If no error occurs and the contents do match, set *pbOk
130187 ** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk
130188 ** to false before returning.
130189 **
130190 ** If an error occurs (e.g. an OOM or IO error), return an SQLite error
130191 ** code. The final value of *pbOk is undefined in this case.
130192 */
130193 static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
130194 int rc = SQLITE_OK; /* Return code */
130195 u64 cksum1 = 0; /* Checksum based on FTS index contents */
130196 u64 cksum2 = 0; /* Checksum based on %_content contents */
130197 sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */
130198
130199 /* This block calculates the checksum according to the FTS index. */
130200 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130201 if( rc==SQLITE_OK ){
130202 int rc2;
130203 sqlite3_bind_int(pAllLangid, 1, p->nIndex);
130204 while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
130205 int iLangid = sqlite3_column_int(pAllLangid, 0);
130206 int i;
130207 for(i=0; i<p->nIndex; i++){
130208 cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
130209 }
130210 }
130211 rc2 = sqlite3_reset(pAllLangid);
130212 if( rc==SQLITE_OK ) rc = rc2;
130213 }
130214
130215 /* This block calculates the checksum according to the %_content table */
130216 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130217 if( rc==SQLITE_OK ){
130218 sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
130219 sqlite3_stmt *pStmt = 0;
130220 char *zSql;
130221
130222 zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist);
130223 if( !zSql ){
130224 rc = SQLITE_NOMEM;
130225 }else{
130226 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
130227 sqlite3_free(zSql);
130228 }
130229
130230 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
130231 i64 iDocid = sqlite3_column_int64(pStmt, 0);
130232 int iLang = langidFromSelect(p, pStmt);
130233 int iCol;
130234
130235 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
130236 const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
130237 int nText = sqlite3_column_bytes(pStmt, iCol+1);
130238 sqlite3_tokenizer_cursor *pT = 0;
130239
130240 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130241 while( rc==SQLITE_OK ){
130242 char const *zToken; /* Buffer containing token */
130243 int nToken; /* Number of bytes in token */
130244 int iDum1, iDum2; /* Dummy variables */
130245 int iPos; /* Position of token in zText */
130246
130247 rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130248 if( rc==SQLITE_OK ){
130249 int i;
130250 cksum2 = cksum2 ^ fts3ChecksumEntry(
130251 zToken, nToken, iLang, 0, iDocid, iCol, iPos
130252 );
130253 for(i=1; i<p->nIndex; i++){
130254 if( p->aIndex[i].nPrefix<=nToken ){
130255 cksum2 = cksum2 ^ fts3ChecksumEntry(
130256 zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
130257 );
130258 }
130259 }
130260 }
130261 }
130262 if( pT ) pModule->xClose(pT);
130263 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
130264 }
130265 }
130266
130267 sqlite3_finalize(pStmt);
130268 }
130269
130270 *pbOk = (cksum1==cksum2);
130271 return rc;
130272 }
130273
130274 /*
130275 ** Run the integrity-check. If no error occurs and the current contents of
130276 ** the FTS index are correct, return SQLITE_OK. Or, if the contents of the
130277 ** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.
130278 **
130279 ** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite
130280 ** error code.
130281 **
130282 ** The integrity-check works as follows. For each token and indexed token
130283 ** prefix in the document set, a 64-bit checksum is calculated (by code
130284 ** in fts3ChecksumEntry()) based on the following:
130285 **
130286 ** + The index number (0 for the main index, 1 for the first prefix
130287 ** index etc.),
130288 ** + The token (or token prefix) text itself,
130289 ** + The language-id of the row it appears in,
130290 ** + The docid of the row it appears in,
130291 ** + The column it appears in, and
130292 ** + The tokens position within that column.
130293 **
130294 ** The checksums for all entries in the index are XORed together to create
130295 ** a single checksum for the entire index.
130296 **
130297 ** The integrity-check code calculates the same checksum in two ways:
130298 **
130299 ** 1. By scanning the contents of the FTS index, and
130300 ** 2. By scanning and tokenizing the content table.
130301 **
130302 ** If the two checksums are identical, the integrity-check is deemed to have
130303 ** passed.
130304 */
130305 static int fts3DoIntegrityCheck(
130306 Fts3Table *p /* FTS3 table handle */
130307 ){
130308 int rc;
130309 int bOk = 0;
130310 rc = fts3IntegrityCheck(p, &bOk);
130311 if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
130312 return rc;
130313 }
130314
130315 /*
130316 ** Handle a 'special' INSERT of the form:
130317 **
130318 ** "INSERT INTO tbl(tbl) VALUES(<expr>)"
130319 **
@@ -128211,10 +130329,16 @@
130329 return SQLITE_NOMEM;
130330 }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
130331 rc = fts3DoOptimize(p, 0);
130332 }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
130333 rc = fts3DoRebuild(p);
130334 }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, "integrity-check", 15) ){
130335 rc = fts3DoIntegrityCheck(p);
130336 }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
130337 rc = fts3DoIncrmerge(p, &zVal[6]);
130338 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
130339 rc = fts3DoAutoincrmerge(p, &zVal[10]);
130340 #ifdef SQLITE_TEST
130341 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
130342 p->nNodeSize = atoi(&zVal[9]);
130343 rc = SQLITE_OK;
130344 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
130530 /*
130531 ** This function does the work for the xUpdate method of FTS3 virtual
130532 ** tables. The schema of the virtual table being:
130533 **
130534 ** CREATE TABLE <table name>(
130535 ** <user columns>,
130536 ** <table name> HIDDEN,
130537 ** docid HIDDEN,
130538 ** <langid> HIDDEN
130539 ** );
130540 **
@@ -128538,11 +130662,11 @@
130662 fts3InsertDocsize(&rc, p, aSzIns);
130663 }
130664 nChng++;
130665 }
130666
130667 if( p->bFts4 ){
130668 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
130669 }
130670
130671 update_out:
130672 sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
131493 char cArg,
131494 char **pzErr
131495 ){
131496 if( (cArg==FTS3_MATCHINFO_NPHRASE)
131497 || (cArg==FTS3_MATCHINFO_NCOL)
131498 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
131499 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
131500 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
131501 || (cArg==FTS3_MATCHINFO_LCS)
131502 || (cArg==FTS3_MATCHINFO_HITS)
131503 ){
131504 return SQLITE_OK;
@@ -133134,12 +135258,12 @@
135258 }
135259
135260 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
135261
135262 /* Allocate the sqlite3_vtab structure */
135263 nDb = (int)strlen(argv[1]);
135264 nName = (int)strlen(argv[2]);
135265 pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
135266 if( !pRtree ){
135267 return SQLITE_NOMEM;
135268 }
135269 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
135354 RtreeCell cell;
135355 int jj;
135356
135357 nodeGetCell(&tree, &node, ii, &cell);
135358 sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
135359 nCell = (int)strlen(zCell);
135360 for(jj=0; jj<tree.nDim*2; jj++){
135361 sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
135362 nCell = (int)strlen(zCell);
135363 }
135364
135365 if( zText ){
135366 char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
135367 sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
136100 int iInput = 0;
136101 int iOut = 0;
136102
136103 *ppCursor = 0;
136104
136105 if( zInput==0 ){
136106 nInput = 0;
136107 zInput = "";
136108 }else if( nInput<0 ){
136109 nInput = strlen(zInput);
136110 }
136111 nChar = nInput+1;
136112 pCsr = (IcuCursor *)sqlite3_malloc(
136113 sizeof(IcuCursor) + /* IcuCursor */
136114
+3292 -1165
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
11
/******************************************************************************
22
** This file is an amalgamation of many separate C source files from SQLite
3
-** version 3.7.11. By combining all the individual C code files into this
3
+** version 3.7.12. By combining all the individual C code files into this
44
** single large file, the entire code can be compiled as a single translation
55
** unit. This allows many compilers to do optimizations that would not be
66
** possible if the files were compiled separately. Performance improvements
77
** of 5% or more are commonly seen when SQLite is compiled as a single
88
** translation unit.
@@ -655,13 +655,13 @@
655655
**
656656
** See also: [sqlite3_libversion()],
657657
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658658
** [sqlite_version()] and [sqlite_source_id()].
659659
*/
660
-#define SQLITE_VERSION "3.7.11"
661
-#define SQLITE_VERSION_NUMBER 3007011
662
-#define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
660
+#define SQLITE_VERSION "3.7.12"
661
+#define SQLITE_VERSION_NUMBER 3007012
662
+#define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
663663
664664
/*
665665
** CAPI3REF: Run-Time Library Version Numbers
666666
** KEYWORDS: sqlite3_version, sqlite3_sourceid
667667
**
@@ -6554,10 +6554,21 @@
65546554
** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
65556555
** <dd>This parameter returns the number of pager cache misses that have
65566556
** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
65576557
** is always 0.
65586558
** </dd>
6559
+**
6560
+** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6561
+** <dd>This parameter returns the number of dirty cache entries that have
6562
+** been written to disk. Specifically, the number of pages written to the
6563
+** wal file in wal mode databases, or the number of pages written to the
6564
+** database file in rollback mode databases. Any pages written as part of
6565
+** transaction rollback or database recovery operations are not included.
6566
+** If an IO or other error occurs while writing a page to disk, the effect
6567
+** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6568
+** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6569
+** </dd>
65596570
** </dl>
65606571
*/
65616572
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
65626573
#define SQLITE_DBSTATUS_CACHE_USED 1
65636574
#define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
65656576
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
65666577
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
65676578
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
65686579
#define SQLITE_DBSTATUS_CACHE_HIT 7
65696580
#define SQLITE_DBSTATUS_CACHE_MISS 8
6570
-#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
6581
+#define SQLITE_DBSTATUS_CACHE_WRITE 9
6582
+#define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
65716583
65726584
65736585
/*
65746586
** CAPI3REF: Prepared Statement Status
65756587
**
@@ -9919,18 +9931,22 @@
99199931
void (*xDestroy)(void *);
99209932
void *pUserData;
99219933
};
99229934
99239935
/*
9924
-** Possible values for FuncDef.flags
9936
+** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF
9937
+** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There
9938
+** are assert() statements in the code to verify this.
99259939
*/
99269940
#define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
99279941
#define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
99289942
#define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
99299943
#define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9930
-#define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */
9931
-#define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
9944
+#define SQLITE_FUNC_COUNT 0x10 /* Built-in count(*) aggregate */
9945
+#define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */
9946
+#define SQLITE_FUNC_LENGTH 0x40 /* Built-in length() function */
9947
+#define SQLITE_FUNC_TYPEOF 0x80 /* Built-in typeof() function */
99329948
99339949
/*
99349950
** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
99359951
** used to create the initializers for the FuncDef structures.
99369952
**
@@ -9954,11 +9970,14 @@
99549970
** available as the function user-data (sqlite3_user_data()). The
99559971
** FuncDef.flags variable is set to the value passed as the flags
99569972
** parameter.
99579973
*/
99589974
#define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9959
- {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9975
+ {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \
9976
+ SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9977
+#define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
9978
+ {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
99609979
SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
99619980
#define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
99629981
{nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
99639982
pArg, 0, xFunc, 0, 0, #zName, 0, 0}
99649983
#define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
1018410203
u8 tabFlags; /* Mask of TF_* values */
1018510204
u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
1018610205
FKey *pFKey; /* Linked list of all foreign keys in this table */
1018710206
char *zColAff; /* String defining the affinity of each column */
1018810207
#ifndef SQLITE_OMIT_CHECK
10189
- Expr *pCheck; /* The AND of all CHECK constraints */
10208
+ ExprList *pCheck; /* All CHECK constraints */
1019010209
#endif
1019110210
#ifndef SQLITE_OMIT_ALTERTABLE
1019210211
int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
1019310212
#endif
1019410213
#ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
1057710596
** TK_VARIABLE: variable number (always >= 1). */
1057810597
i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
1057910598
i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
1058010599
u8 flags2; /* Second set of flags. EP2_... */
1058110600
u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
10601
+ /* If TK_COLUMN, the value of p5 for OP_Column */
1058210602
AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
1058310603
Table *pTab; /* Table for TK_COLUMN expressions. */
1058410604
#if SQLITE_MAX_EXPR_DEPTH>0
1058510605
int nHeight; /* Height of the tree headed by this node */
1058610606
#endif
@@ -10599,11 +10619,11 @@
1059910619
#define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
1060010620
#define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
1060110621
#define EP_FixedDest 0x0200 /* Result needed in a specific register */
1060210622
#define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
1060310623
#define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10604
-#define EP_Hint 0x1000 /* Optimizer hint. Not required for correctness */
10624
+#define EP_Hint 0x1000 /* Not used */
1060510625
#define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
1060610626
#define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
1060710627
#define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
1060810628
1060910629
/*
@@ -11118,10 +11138,11 @@
1111811138
int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
1111911139
int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
1112011140
int regRowid; /* Register holding rowid of CREATE TABLE entry */
1112111141
int regRoot; /* Register holding root page number for new objects */
1112211142
int nMaxArg; /* Max args passed to user function by sub-program */
11143
+ Token constraintName;/* Name of the constraint currently being parsed */
1112311144
#ifndef SQLITE_OMIT_SHARED_CACHE
1112411145
int nTableLock; /* Number of locks in aTableLock */
1112511146
TableLock *aTableLock; /* Required table locks for shared-cache mode */
1112611147
#endif
1112711148
AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
1118611207
const char *zAuthContext; /* Put saved Parse.zAuthContext here */
1118711208
Parse *pParse; /* The Parse structure */
1118811209
};
1118911210
1119011211
/*
11191
-** Bitfield flags for P5 value in OP_Insert and OP_Delete
11212
+** Bitfield flags for P5 value in various opcodes.
1119211213
*/
1119311214
#define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
1119411215
#define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
1119511216
#define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
1119611217
#define OPFLAG_APPEND 0x08 /* This is likely to be an append */
1119711218
#define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
1119811219
#define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
11220
+#define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
11221
+#define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
1119911222
1120011223
/*
1120111224
* Each trigger present in the database schema is stored as an instance of
1120211225
* struct Trigger.
1120311226
*
@@ -11677,11 +11700,11 @@
1167711700
#endif
1167811701
SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
1167911702
SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
1168011703
SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
1168111704
SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11682
-SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
11705
+SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
1168311706
SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
1168411707
SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
1168511708
SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
1168611709
SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
1168711710
SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
1350913532
** Set *pCurrent to the total cache hits or misses encountered by all
1351013533
** pagers the database handle is connected to. *pHighwater is always set
1351113534
** to zero.
1351213535
*/
1351313536
case SQLITE_DBSTATUS_CACHE_HIT:
13514
- case SQLITE_DBSTATUS_CACHE_MISS: {
13537
+ case SQLITE_DBSTATUS_CACHE_MISS:
13538
+ case SQLITE_DBSTATUS_CACHE_WRITE:{
1351513539
int i;
1351613540
int nRet = 0;
1351713541
assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
13542
+ assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );
1351813543
1351913544
for(i=0; i<db->nDb; i++){
1352013545
if( db->aDb[i].pBt ){
1352113546
Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
1352213547
sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
2125921284
2126021285
/*
2126121286
** Some systems have stricmp(). Others have strcasecmp(). Because
2126221287
** there is no consistency, we will define our own.
2126321288
**
21264
-** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows
21265
-** applications and extensions to compare the contents of two buffers
21266
-** containing UTF-8 strings in a case-independent fashion, using the same
21267
-** definition of case independence that SQLite uses internally when
21268
-** comparing identifiers.
21289
+** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
21290
+** sqlite3_strnicmp() APIs allow applications and extensions to compare
21291
+** the contents of two buffers containing UTF-8 strings in a
21292
+** case-independent fashion, using the same definition of "case
21293
+** independence" that SQLite uses internally when comparing identifiers.
2126921294
*/
2127021295
SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
2127121296
register unsigned char *a, *b;
2127221297
a = (unsigned char *)zLeft;
2127321298
b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
3372733752
}
3372833753
sqlite3_free(pFile->zDeleteOnClose);
3372933754
}
3373033755
#endif
3373133756
OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
33757
+ if( rc ){
33758
+ pFile->h = NULL;
33759
+ }
3373233760
OpenCounter(-1);
3373333761
return rc ? SQLITE_OK
3373433762
: winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
3373533763
"winClose", pFile->zPath);
3373633764
}
@@ -33744,22 +33772,33 @@
3374433772
sqlite3_file *id, /* File to read from */
3374533773
void *pBuf, /* Write content into this buffer */
3374633774
int amt, /* Number of bytes to read */
3374733775
sqlite3_int64 offset /* Begin reading at this offset */
3374833776
){
33777
+#if !SQLITE_OS_WINCE
33778
+ OVERLAPPED overlapped; /* The offset for ReadFile. */
33779
+#endif
3374933780
winFile *pFile = (winFile*)id; /* file handle */
3375033781
DWORD nRead; /* Number of bytes actually read from file */
3375133782
int nRetry = 0; /* Number of retrys */
3375233783
3375333784
assert( id!=0 );
3375433785
SimulateIOError(return SQLITE_IOERR_READ);
3375533786
OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
3375633787
33788
+#if SQLITE_OS_WINCE
3375733789
if( seekWinFile(pFile, offset) ){
3375833790
return SQLITE_FULL;
3375933791
}
3376033792
while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
33793
+#else
33794
+ memset(&overlapped, 0, sizeof(OVERLAPPED));
33795
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33796
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33797
+ while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
33798
+ osGetLastError()!=ERROR_HANDLE_EOF ){
33799
+#endif
3376133800
DWORD lastErrno;
3376233801
if( retryIoerr(&nRetry, &lastErrno) ) continue;
3376333802
pFile->lastErrno = lastErrno;
3376433803
return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
3376533804
"winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
3378233821
sqlite3_file *id, /* File to write into */
3378333822
const void *pBuf, /* The bytes to be written */
3378433823
int amt, /* Number of bytes to write */
3378533824
sqlite3_int64 offset /* Offset into the file to begin writing at */
3378633825
){
33787
- int rc; /* True if error has occured, else false */
33826
+ int rc = 0; /* True if error has occured, else false */
3378833827
winFile *pFile = (winFile*)id; /* File handle */
3378933828
int nRetry = 0; /* Number of retries */
3379033829
3379133830
assert( amt>0 );
3379233831
assert( pFile );
@@ -33793,23 +33832,48 @@
3379333832
SimulateIOError(return SQLITE_IOERR_WRITE);
3379433833
SimulateDiskfullError(return SQLITE_FULL);
3379533834
3379633835
OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
3379733836
33837
+#if SQLITE_OS_WINCE
3379833838
rc = seekWinFile(pFile, offset);
3379933839
if( rc==0 ){
33840
+#else
33841
+ {
33842
+#endif
33843
+#if !SQLITE_OS_WINCE
33844
+ OVERLAPPED overlapped; /* The offset for WriteFile. */
33845
+#endif
3380033846
u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
3380133847
int nRem = amt; /* Number of bytes yet to be written */
3380233848
DWORD nWrite; /* Bytes written by each WriteFile() call */
3380333849
DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
33850
+
33851
+#if !SQLITE_OS_WINCE
33852
+ memset(&overlapped, 0, sizeof(OVERLAPPED));
33853
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33854
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33855
+#endif
3380433856
3380533857
while( nRem>0 ){
33858
+#if SQLITE_OS_WINCE
3380633859
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
33860
+#else
33861
+ if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
33862
+#endif
3380733863
if( retryIoerr(&nRetry, &lastErrno) ) continue;
3380833864
break;
3380933865
}
33810
- if( nWrite<=0 ) break;
33866
+ if( nWrite<=0 ){
33867
+ lastErrno = osGetLastError();
33868
+ break;
33869
+ }
33870
+#if !SQLITE_OS_WINCE
33871
+ offset += nWrite;
33872
+ overlapped.Offset = (LONG)(offset & 0xffffffff);
33873
+ overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33874
+#endif
3381133875
aRem += nWrite;
3381233876
nRem -= nWrite;
3381333877
}
3381433878
if( nRem>0 ){
3381533879
pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
3909439158
i64 journalSizeLimit; /* Size limit for persistent journal files */
3909539159
char *zFilename; /* Name of the database file */
3909639160
char *zJournal; /* Name of the journal file */
3909739161
int (*xBusyHandler)(void*); /* Function to call when busy */
3909839162
void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39099
- int nHit, nMiss; /* Total cache hits and misses */
39163
+ int aStat[3]; /* Total cache hits, misses and writes */
3910039164
#ifdef SQLITE_TEST
39101
- int nRead, nWrite; /* Database pages read/written */
39165
+ int nRead; /* Database pages read */
3910239166
#endif
3910339167
void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
3910439168
#ifdef SQLITE_HAS_CODEC
3910539169
void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
3910639170
void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
3911339177
Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
3911439178
char *zWal; /* File name for write-ahead log */
3911539179
#endif
3911639180
};
3911739181
39182
+/*
39183
+** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
39184
+** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS
39185
+** or CACHE_WRITE to sqlite3_db_status().
39186
+*/
39187
+#define PAGER_STAT_HIT 0
39188
+#define PAGER_STAT_MISS 1
39189
+#define PAGER_STAT_WRITE 2
39190
+
3911839191
/*
3911939192
** The following global variables hold counters used for
3912039193
** testing purposes only. These variables do not exist in
3912139194
** a non-testing build. These variables are not thread-safe.
3912239195
*/
@@ -41395,10 +41468,11 @@
4139541468
PgHdr *pList, /* List of frames to log */
4139641469
Pgno nTruncate, /* Database size after this commit */
4139741470
int isCommit /* True if this is a commit */
4139841471
){
4139941472
int rc; /* Return code */
41473
+ int nList; /* Number of pages in pList */
4140041474
#if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
4140141475
PgHdr *p; /* For looping over pages */
4140241476
#endif
4140341477
4140441478
assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
4140841482
for(p=pList; p && p->pDirty; p=p->pDirty){
4140941483
assert( p->pgno < p->pDirty->pgno );
4141041484
}
4141141485
#endif
4141241486
41487
+ assert( pList->pDirty==0 || isCommit );
4141341488
if( isCommit ){
4141441489
/* If a WAL transaction is being committed, there is no point in writing
4141541490
** any pages with page numbers greater than nTruncate into the WAL file.
4141641491
** They will never be read by any client. So remove them from the pDirty
4141741492
** list here. */
4141841493
PgHdr *p;
4141941494
PgHdr **ppNext = &pList;
41495
+ nList = 0;
4142041496
for(p=pList; (*ppNext = p); p=p->pDirty){
41421
- if( p->pgno<=nTruncate ) ppNext = &p->pDirty;
41497
+ if( p->pgno<=nTruncate ){
41498
+ ppNext = &p->pDirty;
41499
+ nList++;
41500
+ }
4142241501
}
4142341502
assert( pList );
41503
+ }else{
41504
+ nList = 1;
4142441505
}
41506
+ pPager->aStat[PAGER_STAT_WRITE] += nList;
4142541507
4142641508
if( pList->pgno==1 ) pager_write_changecounter(pList);
4142741509
rc = sqlite3WalFrames(pPager->pWal,
4142841510
pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
4142941511
);
@@ -42487,19 +42569,19 @@
4248742569
memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
4248842570
}
4248942571
if( pgno>pPager->dbFileSize ){
4249042572
pPager->dbFileSize = pgno;
4249142573
}
42574
+ pPager->aStat[PAGER_STAT_WRITE]++;
4249242575
4249342576
/* Update any backup objects copying the contents of this pager. */
4249442577
sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
4249542578
4249642579
PAGERTRACE(("STORE %d page %d hash(%08x)\n",
4249742580
PAGERID(pPager), pgno, pager_pagehash(pList)));
4249842581
IOTRACE(("PGOUT %p %d\n", pPager, pgno));
4249942582
PAGER_INCR(sqlite3_pager_writedb_count);
42500
- PAGER_INCR(pPager->nWrite);
4250142583
}else{
4250242584
PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
4250342585
}
4250442586
pager_set_pagehash(pList);
4250542587
pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
4345343535
4345443536
if( (*ppPage)->pPager && !noContent ){
4345543537
/* In this case the pcache already contains an initialized copy of
4345643538
** the page. Return without further ado. */
4345743539
assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43458
- pPager->nHit++;
43540
+ pPager->aStat[PAGER_STAT_HIT]++;
4345943541
return SQLITE_OK;
4346043542
4346143543
}else{
4346243544
/* The pager cache has created a new page. Its content needs to
4346343545
** be initialized. */
@@ -43495,11 +43577,11 @@
4349543577
}
4349643578
memset(pPg->pData, 0, pPager->pageSize);
4349743579
IOTRACE(("ZERO %p %d\n", pPager, pgno));
4349843580
}else{
4349943581
assert( pPg->pPager==pPager );
43500
- pPager->nMiss++;
43582
+ pPager->aStat[PAGER_STAT_MISS]++;
4350143583
rc = readDbPage(pPg);
4350243584
if( rc!=SQLITE_OK ){
4350343585
goto pager_acquire_err;
4350443586
}
4350543587
}
@@ -44080,10 +44162,11 @@
4408044162
const void *zBuf;
4408144163
assert( pPager->dbFileSize>0 );
4408244164
CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
4408344165
if( rc==SQLITE_OK ){
4408444166
rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
44167
+ pPager->aStat[PAGER_STAT_WRITE]++;
4408544168
}
4408644169
if( rc==SQLITE_OK ){
4408744170
pPager->changeCountDone = 1;
4408844171
}
4408944172
}else{
@@ -44523,15 +44606,15 @@
4452344606
a[1] = sqlite3PcachePagecount(pPager->pPCache);
4452444607
a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
4452544608
a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
4452644609
a[4] = pPager->eState;
4452744610
a[5] = pPager->errCode;
44528
- a[6] = pPager->nHit;
44529
- a[7] = pPager->nMiss;
44611
+ a[6] = pPager->aStat[PAGER_STAT_HIT];
44612
+ a[7] = pPager->aStat[PAGER_STAT_MISS];
4453044613
a[8] = 0; /* Used to be pPager->nOvfl */
4453144614
a[9] = pPager->nRead;
44532
- a[10] = pPager->nWrite;
44615
+ a[10] = pPager->aStat[PAGER_STAT_WRITE];
4453344616
return a;
4453444617
}
4453544618
#endif
4453644619
4453744620
/*
@@ -44540,24 +44623,23 @@
4454044623
** current cache hit or miss count, according to the value of eStat. If the
4454144624
** reset parameter is non-zero, the cache hit or miss count is zeroed before
4454244625
** returning.
4454344626
*/
4454444627
SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
44545
- int *piStat;
4454644628
4454744629
assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
4454844630
|| eStat==SQLITE_DBSTATUS_CACHE_MISS
44631
+ || eStat==SQLITE_DBSTATUS_CACHE_WRITE
4454944632
);
44550
- if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){
44551
- piStat = &pPager->nHit;
44552
- }else{
44553
- piStat = &pPager->nMiss;
44554
- }
4455544633
44556
- *pnVal += *piStat;
44634
+ assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );
44635
+ assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );
44636
+ assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );
44637
+
44638
+ *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];
4455744639
if( reset ){
44558
- *piStat = 0;
44640
+ pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;
4455944641
}
4456044642
}
4456144643
4456244644
/*
4456344645
** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
5615156233
** keys with no associated data. If the cursor was opened expecting an
5615256234
** intkey table, the caller should be inserting integer keys with a
5615356235
** blob of associated data. */
5615456236
assert( (pKey==0)==(pCur->pKeyInfo==0) );
5615556237
56156
- /* If this is an insert into a table b-tree, invalidate any incrblob
56157
- ** cursors open on the row being replaced (assuming this is a replace
56158
- ** operation - if it is not, the following is a no-op). */
56159
- if( pCur->pKeyInfo==0 ){
56160
- invalidateIncrblobCursors(p, nKey, 0);
56161
- }
56162
-
5616356238
/* Save the positions of any other cursors open on this table.
5616456239
**
5616556240
** In some cases, the call to btreeMoveto() below is a no-op. For
5616656241
** example, when inserting data into a table with auto-generated integer
5616756242
** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
5617156246
** doing any work. To avoid thwarting these optimizations, it is important
5617256247
** not to clear the cursor here.
5617356248
*/
5617456249
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
5617556250
if( rc ) return rc;
56251
+
56252
+ /* If this is an insert into a table b-tree, invalidate any incrblob
56253
+ ** cursors open on the row being replaced (assuming this is a replace
56254
+ ** operation - if it is not, the following is a no-op). */
56255
+ if( pCur->pKeyInfo==0 ){
56256
+ invalidateIncrblobCursors(p, nKey, 0);
56257
+ }
56258
+
5617656259
if( !loc ){
5617756260
rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
5617856261
if( rc ) return rc;
5617956262
}
5618056263
assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
5628156364
|| NEVER(pCur->eState!=CURSOR_VALID)
5628256365
){
5628356366
return SQLITE_ERROR; /* Something has gone awry. */
5628456367
}
5628556368
56286
- /* If this is a delete operation to remove a row from a table b-tree,
56287
- ** invalidate any incrblob cursors open on the row being deleted. */
56288
- if( pCur->pKeyInfo==0 ){
56289
- invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56290
- }
56291
-
5629256369
iCellDepth = pCur->iPage;
5629356370
iCellIdx = pCur->aiIdx[iCellDepth];
5629456371
pPage = pCur->apPage[iCellDepth];
5629556372
pCell = findCell(pPage, iCellIdx);
5629656373
@@ -56312,10 +56389,17 @@
5631256389
** deleted writable. Then free any overflow pages associated with the
5631356390
** entry and finally remove the cell itself from within the page.
5631456391
*/
5631556392
rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
5631656393
if( rc ) return rc;
56394
+
56395
+ /* If this is a delete operation to remove a row from a table b-tree,
56396
+ ** invalidate any incrblob cursors open on the row being deleted. */
56397
+ if( pCur->pKeyInfo==0 ){
56398
+ invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56399
+ }
56400
+
5631756401
rc = sqlite3PagerWrite(pPage->pDbPage);
5631856402
if( rc ) return rc;
5631956403
rc = clearCell(pPage, pCell);
5632056404
dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
5632156405
if( rc ) return rc;
@@ -56593,17 +56677,17 @@
5659356677
int rc;
5659456678
BtShared *pBt = p->pBt;
5659556679
sqlite3BtreeEnter(p);
5659656680
assert( p->inTrans==TRANS_WRITE );
5659756681
56598
- /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56599
- ** is the root of a table b-tree - if it is not, the following call is
56600
- ** a no-op). */
56601
- invalidateIncrblobCursors(p, 0, 1);
56602
-
5660356682
rc = saveAllCursors(pBt, (Pgno)iTable, 0);
56683
+
5660456684
if( SQLITE_OK==rc ){
56685
+ /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56686
+ ** is the root of a table b-tree - if it is not, the following call is
56687
+ ** a no-op). */
56688
+ invalidateIncrblobCursors(p, 0, 1);
5660556689
rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
5660656690
}
5660756691
sqlite3BtreeLeave(p);
5660856692
return rc;
5660956693
}
@@ -58411,14 +58495,14 @@
5841158495
5841258496
/*
5841358497
** Make sure pMem->z points to a writable allocation of at least
5841458498
** n bytes.
5841558499
**
58416
-** If the memory cell currently contains string or blob data
58417
-** and the third argument passed to this function is true, the
58418
-** current content of the cell is preserved. Otherwise, it may
58419
-** be discarded.
58500
+** If the third argument passed to this function is true, then memory
58501
+** cell pMem must contain a string or blob. In this case the content is
58502
+** preserved. Otherwise, if the third parameter to this function is false,
58503
+** any current string or blob value may be discarded.
5842058504
**
5842158505
** This function sets the MEM_Dyn flag and clears any xDel callback.
5842258506
** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
5842358507
** not set, Mem.n is zeroed.
5842458508
*/
@@ -58428,10 +58512,14 @@
5842858512
(((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
5842958513
((pMem->flags&MEM_Ephem) ? 1 : 0) +
5843058514
((pMem->flags&MEM_Static) ? 1 : 0)
5843158515
);
5843258516
assert( (pMem->flags&MEM_RowSet)==0 );
58517
+
58518
+ /* If the preserve flag is set to true, then the memory cell must already
58519
+ ** contain a valid string or blob value. */
58520
+ assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
5843358521
5843458522
if( n<32 ) n = 32;
5843558523
if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
5843658524
if( preserve && pMem->z==pMem->zMalloc ){
5843758525
pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
6074760835
int nByte = (nSub+1)*sizeof(SubProgram*);
6074860836
int j;
6074960837
for(j=0; j<nSub; j++){
6075060838
if( apSub[j]==pOp->p4.pProgram ) break;
6075160839
}
60752
- if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){
60840
+ if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
6075360841
apSub = (SubProgram **)pSub->z;
6075460842
apSub[nSub++] = pOp->p4.pProgram;
6075560843
pSub->flags |= MEM_Blob;
6075660844
pSub->n = nSub*sizeof(SubProgram*);
6075760845
}
@@ -66996,10 +67084,15 @@
6699667084
**
6699767085
** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
6699867086
** then the cache of the cursor is reset prior to extracting the column.
6699967087
** The first OP_Column against a pseudo-table after the value of the content
6700067088
** register has changed should have this bit set.
67089
+**
67090
+** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when
67091
+** the result is guaranteed to only be used as the argument of a length()
67092
+** or typeof() function, respectively. The loading of large blobs can be
67093
+** skipped for length() and all content loading can be skipped for typeof().
6700167094
*/
6700267095
case OP_Column: {
6700367096
#if 0 /* local variables moved into u.an */
6700467097
u32 payloadSize; /* Number of bytes in the record */
6700567098
i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
6713867231
u.an.pC->aRow = (u8*)u.an.zData;
6713967232
}else{
6714067233
u.an.pC->aRow = 0;
6714167234
}
6714267235
}
67143
- /* The following assert is true in all cases accept when
67236
+ /* The following assert is true in all cases except when
6714467237
** the database file has been corrupted externally.
6714567238
** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
6714667239
u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
6714767240
6714867241
/* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
6721367306
if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
6721467307
u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
6721567308
break;
6721667309
}
6721767310
}else{
67218
- /* If u.an.i is less that u.an.nField, then there are less fields in this
67311
+ /* If u.an.i is less that u.an.nField, then there are fewer fields in this
6721967312
** record than SetNumColumns indicated there are columns in the
6722067313
** table. Set the u.an.offset for any extra columns not present in
67221
- ** the record to 0. This tells code below to store a NULL
67222
- ** instead of deserializing a value from the record.
67314
+ ** the record to 0. This tells code below to store the default value
67315
+ ** for the column instead of deserializing a value from the record.
6722367316
*/
6722467317
u.an.aOffset[u.an.i] = 0;
6722567318
}
6722667319
}
6722767320
sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
6724767340
** a pointer to a Mem object.
6724867341
*/
6724967342
if( u.an.aOffset[u.an.p2] ){
6725067343
assert( rc==SQLITE_OK );
6725167344
if( u.an.zRec ){
67345
+ /* This is the common case where the whole row fits on a single page */
6725267346
VdbeMemRelease(u.an.pDest);
6725367347
sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
6725467348
}else{
67255
- u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67256
- sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67257
- rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67258
- if( rc!=SQLITE_OK ){
67259
- goto op_column_out;
67260
- }
67261
- u.an.zData = u.an.sMem.z;
67262
- sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
67349
+ /* This branch happens only when the row overflows onto multiple pages */
67350
+ u.an.t = u.an.aType[u.an.p2];
67351
+ if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
67352
+ && ((u.an.t>=12 && (u.an.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)
67353
+ ){
67354
+ /* Content is irrelevant for the typeof() function and for
67355
+ ** the length(X) function if X is a blob. So we might as well use
67356
+ ** bogus content rather than reading content from disk. NULL works
67357
+ ** for text and blob and whatever is in the u.an.payloadSize64 variable
67358
+ ** will work for everything else. */
67359
+ u.an.zData = u.an.t<12 ? (char*)&u.an.payloadSize64 : 0;
67360
+ }else{
67361
+ u.an.len = sqlite3VdbeSerialTypeLen(u.an.t);
67362
+ sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67363
+ rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex,
67364
+ &u.an.sMem);
67365
+ if( rc!=SQLITE_OK ){
67366
+ goto op_column_out;
67367
+ }
67368
+ u.an.zData = u.an.sMem.z;
67369
+ }
67370
+ sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.t, u.an.pDest);
6726367371
}
6726467372
u.an.pDest->enc = encoding;
6726567373
}else{
6726667374
if( pOp->p4type==P4_MEM ){
6726767375
sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
6759367701
}
6759467702
db->isTransactionSavepoint = 0;
6759567703
rc = p->rc;
6759667704
}else{
6759767705
u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67598
- for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67599
- sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67706
+ if( u.ar.p1==SAVEPOINT_ROLLBACK ){
67707
+ for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67708
+ sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67709
+ }
6760067710
}
6760167711
for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
6760267712
rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
6760367713
if( rc!=SQLITE_OK ){
6760467714
goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
7487374983
int op, /* Expression opcode */
7487474984
Expr *pLeft, /* Left operand */
7487574985
Expr *pRight, /* Right operand */
7487674986
const Token *pToken /* Argument token */
7487774987
){
74878
- Expr *p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74879
- sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74988
+ Expr *p;
74989
+ if( op==TK_AND && pLeft && pRight ){
74990
+ /* Take advantage of short-circuit false optimization for AND */
74991
+ p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
74992
+ }else{
74993
+ p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74994
+ sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74995
+ }
7488074996
if( p ) {
7488174997
sqlite3ExprCheckHeight(pParse, p->nHeight);
7488274998
}
7488374999
return p;
7488475000
}
75001
+
75002
+/*
75003
+** Return 1 if an expression must be FALSE in all cases and 0 if the
75004
+** expression might be true. This is an optimization. If is OK to
75005
+** return 0 here even if the expression really is always false (a
75006
+** false negative). But it is a bug to return 1 if the expression
75007
+** might be true in some rare circumstances (a false positive.)
75008
+**
75009
+** Note that if the expression is part of conditional for a
75010
+** LEFT JOIN, then we cannot determine at compile-time whether or not
75011
+** is it true or false, so always return 0.
75012
+*/
75013
+static int exprAlwaysFalse(Expr *p){
75014
+ int v = 0;
75015
+ if( ExprHasProperty(p, EP_FromJoin) ) return 0;
75016
+ if( !sqlite3ExprIsInteger(p, &v) ) return 0;
75017
+ return v==0;
75018
+}
7488575019
7488675020
/*
7488775021
** Join two expressions using an AND operator. If either expression is
7488875022
** NULL, then just return the other expression.
75023
+**
75024
+** If one side or the other of the AND is known to be false, then instead
75025
+** of returning an AND expression, just return a constant expression with
75026
+** a value of false.
7488975027
*/
7489075028
SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
7489175029
if( pLeft==0 ){
7489275030
return pRight;
7489375031
}else if( pRight==0 ){
7489475032
return pLeft;
75033
+ }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){
75034
+ sqlite3ExprDelete(db, pLeft);
75035
+ sqlite3ExprDelete(db, pRight);
75036
+ return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);
7489575037
}else{
7489675038
Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
7489775039
sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
7489875040
return pNew;
7489975041
}
@@ -76421,19 +76563,10 @@
7642176563
** Actually, the way the column cache is currently used, we are guaranteed
7642276564
** that the object will never already be in cache. Verify this guarantee.
7642376565
*/
7642476566
#ifndef NDEBUG
7642576567
for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
76426
-#if 0 /* This code wold remove the entry from the cache if it existed */
76427
- if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
76428
- cacheEntryClear(pParse, p);
76429
- p->iLevel = pParse->iCacheLevel;
76430
- p->iReg = iReg;
76431
- p->lru = pParse->iCacheCnt++;
76432
- return;
76433
- }
76434
-#endif
7643576568
assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
7643676569
}
7643776570
#endif
7643876571
7643976572
/* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
7656476697
SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
7656576698
Parse *pParse, /* Parsing and code generating context */
7656676699
Table *pTab, /* Description of the table we are reading from */
7656776700
int iColumn, /* Index of the table column */
7656876701
int iTable, /* The cursor pointing to the table */
76569
- int iReg /* Store results here */
76702
+ int iReg, /* Store results here */
76703
+ u8 p5 /* P5 value for OP_Column */
7657076704
){
7657176705
Vdbe *v = pParse->pVdbe;
7657276706
int i;
7657376707
struct yColCache *p;
7657476708
@@ -76579,11 +76713,15 @@
7657976713
return p->iReg;
7658076714
}
7658176715
}
7658276716
assert( v!=0 );
7658376717
sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76584
- sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76718
+ if( p5 ){
76719
+ sqlite3VdbeChangeP5(v, p5);
76720
+ }else{
76721
+ sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76722
+ }
7658576723
return iReg;
7658676724
}
7658776725
7658876726
/*
7658976727
** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
7670776845
/* This only happens when coding check constraints */
7670876846
assert( pParse->ckBase>0 );
7670976847
inReg = pExpr->iColumn + pParse->ckBase;
7671076848
}else{
7671176849
inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76712
- pExpr->iColumn, pExpr->iTable, target);
76850
+ pExpr->iColumn, pExpr->iTable, target,
76851
+ pExpr->op2);
7671376852
}
7671476853
break;
7671576854
}
7671676855
case TK_INTEGER: {
7671776856
codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
7698477123
}
7698577124
7698677125
7698777126
if( pFarg ){
7698877127
r1 = sqlite3GetTempRange(pParse, nFarg);
77128
+
77129
+ /* For length() and typeof() functions with a column argument,
77130
+ ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
77131
+ ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
77132
+ ** loading.
77133
+ */
77134
+ if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
77135
+ u8 exprOp;
77136
+ assert( nFarg==1 );
77137
+ assert( pFarg->a[0].pExpr!=0 );
77138
+ exprOp = pFarg->a[0].pExpr->op;
77139
+ if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){
77140
+ assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
77141
+ assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
77142
+ testcase( pDef->flags==SQLITE_FUNC_LENGTH );
77143
+ pFarg->a[0].pExpr->op2 = pDef->flags;
77144
+ }
77145
+ }
77146
+
7698977147
sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
7699077148
sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
7699177149
sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
7699277150
}else{
7699377151
r1 = 0;
@@ -80189,10 +80347,11 @@
8018980347
Index *pPrevIdx = 0; /* Previous index in the loop */
8019080348
int idx = 0; /* slot in pIdx->aSample[] for next sample */
8019180349
int eType; /* Datatype of a sample */
8019280350
IndexSample *pSample; /* A slot in pIdx->aSample[] */
8019380351
80352
+ assert( db->lookaside.bEnabled==0 );
8019480353
if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
8019580354
return SQLITE_OK;
8019680355
}
8019780356
8019880357
zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
8021580374
nSample = sqlite3_column_int(pStmt, 1);
8021680375
pIdx = sqlite3FindIndex(db, zIndex, zDb);
8021780376
if( pIdx==0 ) continue;
8021880377
assert( pIdx->nSample==0 );
8021980378
pIdx->nSample = nSample;
80220
- pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) );
80379
+ pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));
8022180380
pIdx->avgEq = pIdx->aiRowEst[1];
8022280381
if( pIdx->aSample==0 ){
8022380382
db->mallocFailed = 1;
8022480383
sqlite3_finalize(pStmt);
8022580384
return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
8028880447
int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
8028980448
pSample->nByte = n;
8029080449
if( n < 1){
8029180450
pSample->u.z = 0;
8029280451
}else{
80293
- pSample->u.z = sqlite3Malloc(n);
80452
+ pSample->u.z = sqlite3DbMallocRaw(db, n);
8029480453
if( pSample->u.z==0 ){
8029580454
db->mallocFailed = 1;
8029680455
sqlite3_finalize(pStmt);
8029780456
return SQLITE_NOMEM;
8029880457
}
@@ -80364,11 +80523,14 @@
8036480523
8036580524
8036680525
/* Load the statistics from the sqlite_stat3 table. */
8036780526
#ifdef SQLITE_ENABLE_STAT3
8036880527
if( rc==SQLITE_OK ){
80528
+ int lookasideEnabled = db->lookaside.bEnabled;
80529
+ db->lookaside.bEnabled = 0;
8036980530
rc = loadStat3(db, sInfo.zDatabase);
80531
+ db->lookaside.bEnabled = lookasideEnabled;
8037080532
}
8037180533
#endif
8037280534
8037380535
if( rc==SQLITE_NOMEM ){
8037480536
db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
8172781889
sqliteDeleteColumnNames(db, pTable);
8172881890
sqlite3DbFree(db, pTable->zName);
8172981891
sqlite3DbFree(db, pTable->zColAff);
8173081892
sqlite3SelectDelete(db, pTable->pSelect);
8173181893
#ifndef SQLITE_OMIT_CHECK
81732
- sqlite3ExprDelete(db, pTable->pCheck);
81894
+ sqlite3ExprListDelete(db, pTable->pCheck);
8173381895
#endif
8173481896
#ifndef SQLITE_OMIT_VIRTUALTABLE
8173581897
sqlite3VtabClear(db, pTable);
8173681898
#endif
8173781899
sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
8239082552
*/
8239182553
SQLITE_PRIVATE void sqlite3AddCheckConstraint(
8239282554
Parse *pParse, /* Parsing context */
8239382555
Expr *pCheckExpr /* The check expression */
8239482556
){
82395
- sqlite3 *db = pParse->db;
8239682557
#ifndef SQLITE_OMIT_CHECK
8239782558
Table *pTab = pParse->pNewTable;
8239882559
if( pTab && !IN_DECLARE_VTAB ){
82399
- pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, pCheckExpr);
82560
+ pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
82561
+ if( pParse->constraintName.n ){
82562
+ sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
82563
+ }
8240082564
}else
8240182565
#endif
8240282566
{
82403
- sqlite3ExprDelete(db, pCheckExpr);
82567
+ sqlite3ExprDelete(pParse->db, pCheckExpr);
8240482568
}
8240582569
}
8240682570
8240782571
/*
8240882572
** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
8266882832
/* Resolve names in all CHECK constraint expressions.
8266982833
*/
8267082834
if( p->pCheck ){
8267182835
SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
8267282836
NameContext sNC; /* Name context for pParse->pNewTable */
82837
+ ExprList *pList; /* List of all CHECK constraints */
82838
+ int i; /* Loop counter */
8267382839
8267482840
memset(&sNC, 0, sizeof(sNC));
8267582841
memset(&sSrc, 0, sizeof(sSrc));
8267682842
sSrc.nSrc = 1;
8267782843
sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
8267882844
sSrc.a[0].pTab = p;
8267982845
sSrc.a[0].iCursor = -1;
8268082846
sNC.pParse = pParse;
8268182847
sNC.pSrcList = &sSrc;
8268282848
sNC.isCheck = 1;
82683
- if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){
82684
- return;
82849
+ pList = p->pCheck;
82850
+ for(i=0; i<pList->nExpr; i++){
82851
+ if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
82852
+ return;
82853
+ }
8268582854
}
8268682855
}
8268782856
#endif /* !defined(SQLITE_OMIT_CHECK) */
8268882857
8268982858
/* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
8423084399
exit_drop_index:
8423184400
sqlite3SrcListDelete(db, pName);
8423284401
}
8423384402
8423484403
/*
84235
-** pArray is a pointer to an array of objects. Each object in the
84236
-** array is szEntry bytes in size. This routine allocates a new
84237
-** object on the end of the array.
84238
-**
84239
-** *pnEntry is the number of entries already in use. *pnAlloc is
84240
-** the previously allocated size of the array. initSize is the
84241
-** suggested initial array size allocation.
84242
-**
84243
-** The index of the new entry is returned in *pIdx.
84244
-**
84245
-** This routine returns a pointer to the array of objects. This
84246
-** might be the same as the pArray parameter or it might be a different
84247
-** pointer if the array was resized.
84404
+** pArray is a pointer to an array of objects. Each object in the
84405
+** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()
84406
+** to extend the array so that there is space for a new object at the end.
84407
+**
84408
+** When this function is called, *pnEntry contains the current size of
84409
+** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes
84410
+** in total).
84411
+**
84412
+** If the realloc() is successful (i.e. if no OOM condition occurs), the
84413
+** space allocated for the new object is zeroed, *pnEntry updated to
84414
+** reflect the new size of the array and a pointer to the new allocation
84415
+** returned. *pIdx is set to the index of the new array entry in this case.
84416
+**
84417
+** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
84418
+** unchanged and a copy of pArray returned.
8424884419
*/
8424984420
SQLITE_PRIVATE void *sqlite3ArrayAllocate(
8425084421
sqlite3 *db, /* Connection to notify of malloc failures */
8425184422
void *pArray, /* Array of objects. Might be reallocated */
8425284423
int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
8583986010
sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
8584086011
pWInfo = sqlite3WhereBegin(
8584186012
pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
8584286013
);
8584386014
if( pWInfo==0 ) goto delete_from_cleanup;
85844
- regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
86015
+ regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
8584586016
sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
8584686017
if( db->flags & SQLITE_CountRows ){
8584786018
sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
8584886019
}
8584986020
sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
8765987830
FUNCTION(min, 0, 0, 1, 0 ),
8766087831
AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
8766187832
FUNCTION(max, -1, 1, 1, minmaxFunc ),
8766287833
FUNCTION(max, 0, 1, 1, 0 ),
8766387834
AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87664
- FUNCTION(typeof, 1, 0, 0, typeofFunc ),
87665
- FUNCTION(length, 1, 0, 0, lengthFunc ),
87835
+ FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
87836
+ FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
8766687837
FUNCTION(substr, 2, 0, 0, substrFunc ),
8766787838
FUNCTION(substr, 3, 0, 0, substrFunc ),
8766887839
FUNCTION(abs, 1, 0, 0, absFunc ),
8766987840
#ifndef SQLITE_OMIT_FLOATING_POINT
8767087841
FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
8767287843
#endif
8767387844
FUNCTION(upper, 1, 0, 0, upperFunc ),
8767487845
FUNCTION(lower, 1, 0, 0, lowerFunc ),
8767587846
FUNCTION(coalesce, 1, 0, 0, 0 ),
8767687847
FUNCTION(coalesce, 0, 0, 0, 0 ),
87677
-/* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */
87678
- {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0},
87848
+ FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
8767987849
FUNCTION(hex, 1, 0, 0, hexFunc ),
87680
-/* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */
87681
- {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0},
87850
+ FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
8768287851
FUNCTION(random, 0, 0, 0, randomFunc ),
8768387852
FUNCTION(randomblob, 1, 0, 0, randomBlob ),
8768487853
FUNCTION(nullif, 2, 0, 1, nullifFunc ),
8768587854
FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
8768687855
FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
9011390282
int j1; /* Addresss of jump instruction */
9011490283
int j2 = 0, j3; /* Addresses of jump instructions */
9011590284
int regData; /* Register containing first data column */
9011690285
int iCur; /* Table cursor number */
9011790286
Index *pIdx; /* Pointer to one of the indices */
90287
+ sqlite3 *db; /* Database connection */
9011890288
int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
9011990289
int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
9012090290
90291
+ db = pParse->db;
9012190292
v = sqlite3GetVdbe(pParse);
9012290293
assert( v!=0 );
9012390294
assert( pTab->pSelect==0 ); /* This table is not a VIEW */
9012490295
nCol = pTab->nCol;
9012590296
regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
9014890319
case OE_Rollback:
9014990320
case OE_Fail: {
9015090321
char *zMsg;
9015190322
sqlite3VdbeAddOp3(v, OP_HaltIfNull,
9015290323
SQLITE_CONSTRAINT, onError, regData+i);
90153
- zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
90324
+ zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL",
9015490325
pTab->zName, pTab->aCol[i].zName);
9015590326
sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
9015690327
break;
9015790328
}
9015890329
case OE_Ignore: {
@@ -90170,22 +90341,31 @@
9017090341
}
9017190342
9017290343
/* Test all CHECK constraints
9017390344
*/
9017490345
#ifndef SQLITE_OMIT_CHECK
90175
- if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){
90176
- int allOk = sqlite3VdbeMakeLabel(v);
90346
+ if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
90347
+ ExprList *pCheck = pTab->pCheck;
9017790348
pParse->ckBase = regData;
90178
- sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL);
9017990349
onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90180
- if( onError==OE_Ignore ){
90181
- sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90182
- }else{
90183
- if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90184
- sqlite3HaltConstraint(pParse, onError, 0, 0);
90350
+ for(i=0; i<pCheck->nExpr; i++){
90351
+ int allOk = sqlite3VdbeMakeLabel(v);
90352
+ sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
90353
+ if( onError==OE_Ignore ){
90354
+ sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90355
+ }else{
90356
+ char *zConsName = pCheck->a[i].zName;
90357
+ if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90358
+ if( zConsName ){
90359
+ zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
90360
+ }else{
90361
+ zConsName = 0;
90362
+ }
90363
+ sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
90364
+ }
90365
+ sqlite3VdbeResolveLabel(v, allOk);
9018590366
}
90186
- sqlite3VdbeResolveLabel(v, allOk);
9018790367
}
9018890368
#endif /* !defined(SQLITE_OMIT_CHECK) */
9018990369
9019090370
/* If we have an INTEGER PRIMARY KEY, make sure the primary key
9019190371
** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
9023790417
**
9023890418
** to run without a statement journal if there are no indexes on the
9023990419
** table.
9024090420
*/
9024190421
Trigger *pTrigger = 0;
90242
- if( pParse->db->flags&SQLITE_RecTriggers ){
90422
+ if( db->flags&SQLITE_RecTriggers ){
9024390423
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
9024490424
}
9024590425
if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
9024690426
sqlite3MultiWrite(pParse);
9024790427
sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
9032690506
StrAccum errMsg;
9032790507
const char *zSep;
9032890508
char *zErr;
9032990509
9033090510
sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90331
- errMsg.db = pParse->db;
90511
+ errMsg.db = db;
9033290512
zSep = pIdx->nColumn>1 ? "columns " : "column ";
9033390513
for(j=0; j<pIdx->nColumn; j++){
9033490514
char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
9033590515
sqlite3StrAccumAppend(&errMsg, zSep, -1);
9033690516
zSep = ", ";
@@ -90350,11 +90530,11 @@
9035090530
}
9035190531
default: {
9035290532
Trigger *pTrigger = 0;
9035390533
assert( onError==OE_Replace );
9035490534
sqlite3MultiWrite(pParse);
90355
- if( pParse->db->flags&SQLITE_RecTriggers ){
90535
+ if( db->flags&SQLITE_RecTriggers ){
9035690536
pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
9035790537
}
9035890538
sqlite3GenerateRowDelete(
9035990539
pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
9036090540
);
@@ -90680,11 +90860,11 @@
9068090860
if( pSrcIdx==0 ){
9068190861
return 0; /* pDestIdx has no corresponding index in pSrc */
9068290862
}
9068390863
}
9068490864
#ifndef SQLITE_OMIT_CHECK
90685
- if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){
90865
+ if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
9068690866
return 0; /* Tables have different CHECK constraints. Ticket #2252 */
9068790867
}
9068890868
#endif
9068990869
#ifndef SQLITE_OMIT_FOREIGN_KEY
9069090870
/* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
9575395933
int nCol; /* Number of columns in the result set */
9575495934
Expr *p; /* Expression for a single result column */
9575595935
char *zName; /* Column name */
9575695936
int nName; /* Size of name in zName[] */
9575795937
95758
- *pnCol = nCol = pEList ? pEList->nExpr : 0;
95759
- aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95760
- if( aCol==0 ) return SQLITE_NOMEM;
95938
+ if( pEList ){
95939
+ nCol = pEList->nExpr;
95940
+ aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95941
+ testcase( aCol==0 );
95942
+ }else{
95943
+ nCol = 0;
95944
+ aCol = 0;
95945
+ }
95946
+ *pnCol = nCol;
95947
+ *paCol = aCol;
95948
+
9576195949
for(i=0, pCol=aCol; i<nCol; i++, pCol++){
9576295950
/* Get an appropriate name for the column
9576395951
*/
9576495952
p = pEList->a[i].pExpr;
9576595953
assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
9872398911
if( pCol->iSorterColumn>=j ){
9872498912
int r1 = j + regBase;
9872598913
int r2;
9872698914
9872798915
r2 = sqlite3ExprCodeGetColumn(pParse,
98728
- pCol->pTab, pCol->iColumn, pCol->iTable, r1);
98916
+ pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
9872998917
if( r1!=r2 ){
9873098918
sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
9873198919
}
9873298920
j++;
9873398921
}
@@ -103212,11 +103400,14 @@
103212103400
#ifdef SQLITE_EBCDIC
103213103401
if( *pnoCase ) return 0;
103214103402
#endif
103215103403
pList = pExpr->x.pList;
103216103404
pLeft = pList->a[1].pExpr;
103217
- if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){
103405
+ if( pLeft->op!=TK_COLUMN
103406
+ || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
103407
+ || IsVirtual(pLeft->pTab)
103408
+ ){
103218103409
/* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103219103410
** be the name of an indexed column with TEXT affinity. */
103220103411
return 0;
103221103412
}
103222103413
assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
106909107100
);
106910107101
if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
106911107102
int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
106912107103
int r;
106913107104
r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
106914
- regRowid);
107105
+ regRowid, 0);
106915107106
sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
106916107107
sqlite3VdbeCurrentAddr(v)+2, r, iSet);
106917107108
}
106918107109
sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
106919107110
@@ -107822,11 +108013,11 @@
107822108013
** An instance of this structure is used to store the LIKE,
107823108014
** GLOB, NOT LIKE, and NOT GLOB operators.
107824108015
*/
107825108016
struct LikeOp {
107826108017
Token eOperator; /* "like" or "glob" or "regexp" */
107827
- int not; /* True if the NOT keyword is present */
108018
+ int bNot; /* True if the NOT keyword is present */
107828108019
};
107829108020
107830108021
/*
107831108022
** An instance of the following structure describes the event of a
107832108023
** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108001108192
#endif
108002108193
#define sqlite3ParserARG_SDECL Parse *pParse;
108003108194
#define sqlite3ParserARG_PDECL ,Parse *pParse
108004108195
#define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108005108196
#define sqlite3ParserARG_STORE yypParser->pParse = pParse
108006
-#define YYNSTATE 629
108007
-#define YYNRULE 327
108197
+#define YYNSTATE 627
108198
+#define YYNRULE 325
108008108199
#define YYFALLBACK 1
108009108200
#define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108010108201
#define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108011108202
#define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108012108203
@@ -108072,480 +108263,478 @@
108072108263
** shifting terminals.
108073108264
** yy_reduce_ofst[] For each state, the offset into yy_action for
108074108265
** shifting non-terminals after a reduce.
108075108266
** yy_default[] Default action for each state.
108076108267
*/
108077
-#define YY_ACTTAB_COUNT (1580)
108268
+#define YY_ACTTAB_COUNT (1561)
108078108269
static const YYACTIONTYPE yy_action[] = {
108079
- /* 0 */ 310, 328, 574, 573, 15, 172, 187, 596, 56, 56,
108270
+ /* 0 */ 310, 328, 573, 572, 15, 171, 185, 595, 56, 56,
108080108271
/* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108081
- /* 20 */ 52, 52, 51, 234, 622, 621, 626, 622, 621, 299,
108082
- /* 30 */ 589, 583, 56, 56, 56, 56, 236, 54, 54, 54,
108083
- /* 40 */ 54, 53, 53, 52, 52, 52, 51, 234, 351, 57,
108084
- /* 50 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108085
- /* 60 */ 56, 56, 570, 54, 54, 54, 54, 53, 53, 52,
108086
- /* 70 */ 52, 52, 51, 234, 310, 596, 326, 607, 233, 232,
108272
+ /* 20 */ 52, 52, 51, 233, 52, 52, 52, 51, 233, 624,
108273
+ /* 30 */ 588, 582, 56, 56, 56, 56, 314, 54, 54, 54,
108274
+ /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 299, 57,
108275
+ /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108276
+ /* 60 */ 56, 56, 569, 54, 54, 54, 54, 53, 53, 52,
108277
+ /* 70 */ 52, 52, 51, 233, 310, 595, 326, 575, 663, 65,
108087108278
/* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108088
- /* 90 */ 51, 234, 619, 618, 326, 619, 618, 166, 605, 492,
108089
- /* 100 */ 381, 378, 377, 235, 589, 583, 554, 495, 1, 59,
108090
- /* 110 */ 19, 376, 622, 621, 53, 53, 52, 52, 52, 51,
108091
- /* 120 */ 234, 571, 571, 57, 58, 48, 581, 580, 582, 582,
108092
- /* 130 */ 55, 55, 56, 56, 56, 56, 215, 54, 54, 54,
108093
- /* 140 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 224,
108094
- /* 150 */ 50, 47, 147, 177, 139, 281, 384, 276, 383, 169,
108095
- /* 160 */ 408, 553, 578, 578, 622, 621, 272, 224, 439, 550,
108096
- /* 170 */ 552, 410, 139, 281, 384, 276, 383, 169, 589, 583,
108097
- /* 180 */ 619, 618, 280, 620, 272, 195, 413, 309, 440, 441,
108098
- /* 190 */ 567, 491, 214, 279, 560, 600, 92, 57, 58, 48,
108099
- /* 200 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108100
- /* 210 */ 559, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108101
- /* 220 */ 51, 234, 310, 464, 233, 232, 558, 133, 519, 50,
108102
- /* 230 */ 47, 147, 619, 618, 565, 436, 397, 515, 514, 518,
108103
- /* 240 */ 410, 387, 438, 389, 437, 622, 621, 442, 570, 433,
108104
- /* 250 */ 203, 390, 589, 583, 6, 413, 166, 670, 250, 381,
108105
- /* 260 */ 378, 377, 525, 190, 600, 92, 594, 571, 571, 465,
108106
- /* 270 */ 376, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108107
- /* 280 */ 56, 56, 56, 56, 599, 54, 54, 54, 54, 53,
108108
- /* 290 */ 53, 52, 52, 52, 51, 234, 310, 592, 592, 592,
108109
- /* 300 */ 490, 182, 247, 548, 249, 397, 273, 410, 7, 439,
108110
- /* 310 */ 398, 606, 67, 619, 618, 620, 472, 256, 347, 255,
108111
- /* 320 */ 473, 620, 413, 576, 620, 65, 589, 583, 236, 440,
108112
- /* 330 */ 336, 600, 92, 68, 364, 192, 481, 622, 621, 547,
108113
- /* 340 */ 622, 621, 560, 323, 207, 57, 58, 48, 581, 580,
108114
- /* 350 */ 582, 582, 55, 55, 56, 56, 56, 56, 559, 54,
108115
- /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108116
- /* 370 */ 310, 410, 397, 146, 558, 531, 401, 348, 599, 166,
108117
- /* 380 */ 248, 204, 381, 378, 377, 541, 413, 171, 337, 570,
108118
- /* 390 */ 622, 621, 40, 376, 38, 600, 74, 465, 548, 490,
108119
- /* 400 */ 589, 583, 532, 350, 579, 619, 618, 297, 619, 618,
108120
- /* 410 */ 480, 67, 470, 39, 620, 599, 406, 574, 573, 57,
108121
- /* 420 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108122
- /* 430 */ 56, 56, 577, 54, 54, 54, 54, 53, 53, 52,
108123
- /* 440 */ 52, 52, 51, 234, 310, 256, 347, 255, 530, 52,
108124
- /* 450 */ 52, 52, 51, 234, 345, 564, 236, 386, 619, 618,
108125
- /* 460 */ 957, 185, 418, 2, 408, 410, 578, 578, 198, 197,
108126
- /* 470 */ 196, 499, 183, 167, 589, 583, 671, 570, 505, 506,
108127
- /* 480 */ 413, 267, 601, 672, 546, 208, 602, 36, 601, 600,
108128
- /* 490 */ 91, 468, 602, 57, 58, 48, 581, 580, 582, 582,
108129
- /* 500 */ 55, 55, 56, 56, 56, 56, 202, 54, 54, 54,
108130
- /* 510 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 599,
108131
- /* 520 */ 157, 408, 527, 578, 578, 263, 490, 265, 410, 873,
108132
- /* 530 */ 410, 474, 474, 366, 373, 410, 504, 428, 67, 290,
108133
- /* 540 */ 599, 620, 352, 413, 408, 413, 578, 578, 589, 583,
108134
- /* 550 */ 413, 382, 600, 92, 600, 16, 543, 62, 503, 600,
108135
- /* 560 */ 92, 408, 346, 578, 578, 168, 45, 57, 58, 48,
108136
- /* 570 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108137
- /* 580 */ 200, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108138
- /* 590 */ 51, 234, 310, 393, 395, 534, 510, 617, 616, 615,
108139
- /* 600 */ 318, 314, 172, 66, 596, 410, 338, 596, 324, 571,
108140
- /* 610 */ 571, 50, 47, 147, 599, 629, 627, 330, 539, 315,
108141
- /* 620 */ 413, 30, 589, 583, 272, 236, 199, 144, 176, 600,
108142
- /* 630 */ 73, 420, 947, 620, 947, 420, 946, 351, 946, 175,
108143
- /* 640 */ 596, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108144
- /* 650 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108145
- /* 660 */ 53, 52, 52, 52, 51, 234, 310, 261, 410, 413,
108146
- /* 670 */ 269, 208, 596, 363, 410, 596, 424, 360, 600, 69,
108147
- /* 680 */ 424, 327, 620, 413, 50, 47, 147, 410, 358, 413,
108148
- /* 690 */ 575, 553, 600, 94, 483, 509, 589, 583, 600, 97,
108149
- /* 700 */ 552, 484, 413, 620, 188, 599, 551, 563, 596, 566,
108150
- /* 710 */ 334, 600, 95, 205, 201, 57, 58, 48, 581, 580,
108151
- /* 720 */ 582, 582, 55, 55, 56, 56, 56, 56, 352, 54,
108152
- /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108153
- /* 740 */ 310, 410, 261, 410, 167, 22, 356, 599, 359, 623,
108154
- /* 750 */ 50, 47, 147, 548, 357, 562, 413, 620, 413, 332,
108155
- /* 760 */ 523, 270, 410, 167, 620, 600, 104, 600, 103, 603,
108156
- /* 770 */ 589, 583, 339, 539, 304, 423, 222, 413, 174, 304,
108157
- /* 780 */ 422, 561, 567, 405, 214, 260, 600, 106, 620, 57,
108158
- /* 790 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108159
- /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
108160
- /* 810 */ 52, 52, 51, 234, 310, 410, 557, 413, 410, 421,
108161
- /* 820 */ 273, 35, 512, 146, 421, 12, 600, 107, 213, 144,
108162
- /* 830 */ 413, 410, 32, 413, 410, 620, 365, 353, 358, 600,
108163
- /* 840 */ 134, 11, 600, 135, 589, 583, 413, 21, 548, 413,
108164
- /* 850 */ 316, 148, 620, 620, 170, 600, 98, 223, 600, 102,
108165
- /* 860 */ 374, 168, 167, 57, 58, 48, 581, 580, 582, 582,
108166
- /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
108167
- /* 880 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 410,
108168
- /* 890 */ 273, 413, 410, 273, 212, 469, 410, 167, 628, 2,
108169
- /* 900 */ 600, 101, 545, 221, 413, 620, 130, 413, 620, 410,
108170
- /* 910 */ 539, 413, 537, 600, 93, 315, 600, 100, 589, 583,
108171
- /* 920 */ 600, 77, 425, 305, 413, 620, 254, 322, 599, 458,
108172
- /* 930 */ 320, 171, 543, 600, 96, 521, 520, 57, 58, 48,
108173
- /* 940 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108174
- /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108175
- /* 960 */ 51, 234, 310, 410, 273, 413, 410, 457, 358, 35,
108176
- /* 970 */ 426, 230, 306, 319, 600, 138, 467, 520, 413, 620,
108177
- /* 980 */ 143, 413, 410, 620, 410, 353, 529, 600, 137, 142,
108178
- /* 990 */ 600, 136, 589, 583, 604, 261, 528, 413, 229, 413,
108179
- /* 1000 */ 620, 321, 495, 28, 543, 543, 600, 76, 600, 90,
108180
- /* 1010 */ 620, 57, 46, 48, 581, 580, 582, 582, 55, 55,
108181
- /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108182
- /* 1030 */ 53, 52, 52, 52, 51, 234, 310, 261, 451, 413,
108183
- /* 1040 */ 410, 211, 611, 285, 283, 610, 609, 502, 600, 89,
108184
- /* 1050 */ 380, 217, 620, 128, 140, 413, 220, 620, 410, 409,
108185
- /* 1060 */ 620, 620, 588, 587, 600, 75, 589, 583, 271, 620,
108186
- /* 1070 */ 51, 234, 127, 413, 620, 599, 627, 330, 27, 375,
108187
- /* 1080 */ 449, 279, 600, 88, 585, 584, 58, 48, 581, 580,
108188
- /* 1090 */ 582, 582, 55, 55, 56, 56, 56, 56, 410, 54,
108189
- /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108190
- /* 1110 */ 310, 586, 410, 413, 410, 261, 593, 165, 399, 556,
108191
- /* 1120 */ 126, 371, 600, 87, 478, 186, 123, 413, 367, 413,
108192
- /* 1130 */ 620, 620, 410, 620, 620, 410, 600, 99, 600, 86,
108193
- /* 1140 */ 589, 583, 475, 122, 258, 171, 471, 413, 160, 121,
108194
- /* 1150 */ 413, 14, 159, 463, 25, 24, 600, 17, 448, 600,
108195
- /* 1160 */ 85, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108196
- /* 1170 */ 56, 56, 158, 54, 54, 54, 54, 53, 53, 52,
108197
- /* 1180 */ 52, 52, 51, 234, 44, 404, 261, 3, 544, 261,
108198
- /* 1190 */ 540, 414, 621, 460, 119, 118, 538, 275, 10, 349,
108199
- /* 1200 */ 4, 620, 407, 620, 620, 620, 116, 44, 404, 410,
108200
- /* 1210 */ 3, 620, 620, 410, 414, 621, 456, 454, 252, 450,
108201
- /* 1220 */ 508, 402, 111, 109, 413, 407, 155, 444, 413, 447,
108202
- /* 1230 */ 435, 565, 219, 600, 84, 620, 108, 600, 83, 64,
108203
- /* 1240 */ 434, 417, 625, 150, 402, 333, 410, 237, 238, 124,
108204
- /* 1250 */ 274, 41, 42, 533, 565, 206, 189, 261, 43, 412,
108205
- /* 1260 */ 411, 413, 261, 594, 488, 620, 329, 149, 419, 268,
108206
- /* 1270 */ 600, 72, 620, 266, 41, 42, 181, 620, 410, 620,
108207
- /* 1280 */ 105, 43, 412, 411, 620, 624, 594, 614, 620, 599,
108208
- /* 1290 */ 228, 125, 313, 413, 592, 592, 592, 591, 590, 13,
108209
- /* 1300 */ 218, 410, 600, 71, 236, 244, 44, 404, 264, 3,
108210
- /* 1310 */ 312, 613, 340, 414, 621, 180, 413, 592, 592, 592,
108211
- /* 1320 */ 591, 590, 13, 620, 407, 600, 82, 410, 416, 34,
108212
- /* 1330 */ 404, 410, 3, 410, 262, 410, 414, 621, 612, 331,
108213
- /* 1340 */ 178, 415, 413, 402, 8, 236, 413, 407, 413, 620,
108214
- /* 1350 */ 413, 600, 81, 565, 257, 600, 80, 600, 70, 600,
108215
- /* 1360 */ 18, 598, 361, 462, 461, 30, 402, 294, 31, 620,
108216
- /* 1370 */ 293, 354, 251, 41, 42, 410, 565, 620, 620, 620,
108217
- /* 1380 */ 43, 412, 411, 453, 396, 594, 620, 620, 394, 61,
108218
- /* 1390 */ 413, 292, 443, 622, 621, 243, 41, 42, 620, 600,
108219
- /* 1400 */ 79, 597, 291, 43, 412, 411, 60, 620, 594, 240,
108220
- /* 1410 */ 620, 410, 231, 37, 555, 173, 592, 592, 592, 591,
108221
- /* 1420 */ 590, 13, 216, 239, 620, 184, 413, 302, 301, 300,
108222
- /* 1430 */ 179, 298, 388, 565, 452, 600, 78, 286, 620, 592,
108223
- /* 1440 */ 592, 592, 591, 590, 13, 429, 29, 413, 151, 289,
108224
- /* 1450 */ 242, 145, 392, 194, 193, 288, 600, 9, 542, 241,
108225
- /* 1460 */ 620, 525, 391, 284, 620, 594, 620, 620, 522, 536,
108226
- /* 1470 */ 620, 535, 153, 385, 465, 516, 282, 325, 154, 517,
108227
- /* 1480 */ 277, 152, 512, 511, 513, 129, 226, 308, 487, 486,
108228
- /* 1490 */ 485, 164, 372, 493, 307, 227, 592, 592, 592, 225,
108229
- /* 1500 */ 479, 163, 368, 370, 162, 476, 210, 477, 26, 259,
108230
- /* 1510 */ 161, 466, 362, 141, 132, 120, 117, 455, 156, 115,
108231
- /* 1520 */ 344, 343, 256, 342, 245, 114, 113, 446, 311, 112,
108232
- /* 1530 */ 23, 317, 432, 236, 131, 431, 110, 430, 20, 427,
108233
- /* 1540 */ 608, 595, 295, 63, 379, 287, 509, 191, 278, 403,
108234
- /* 1550 */ 572, 569, 497, 498, 496, 494, 335, 459, 445, 303,
108235
- /* 1560 */ 296, 246, 341, 355, 5, 568, 369, 507, 253, 549,
108236
- /* 1570 */ 526, 209, 400, 501, 500, 524, 234, 958, 489, 482,
108279
+ /* 90 */ 51, 233, 53, 53, 52, 52, 52, 51, 233, 489,
108280
+ /* 100 */ 663, 440, 663, 235, 588, 582, 553, 297, 363, 59,
108281
+ /* 110 */ 481, 67, 360, 1, 618, 351, 618, 620, 619, 207,
108282
+ /* 120 */ 6, 441, 442, 57, 58, 48, 580, 579, 581, 581,
108283
+ /* 130 */ 55, 55, 56, 56, 56, 56, 605, 54, 54, 54,
108284
+ /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
108285
+ /* 150 */ 50, 47, 146, 598, 138, 281, 385, 276, 384, 168,
108286
+ /* 160 */ 489, 552, 620, 619, 620, 619, 272, 214, 440, 411,
108287
+ /* 170 */ 551, 604, 67, 165, 7, 618, 352, 353, 588, 582,
108288
+ /* 180 */ 443, 569, 192, 618, 414, 617, 616, 668, 441, 336,
108289
+ /* 190 */ 669, 62, 618, 599, 92, 382, 346, 57, 58, 48,
108290
+ /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108291
+ /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108292
+ /* 220 */ 51, 233, 310, 465, 232, 231, 373, 132, 514, 513,
108293
+ /* 230 */ 617, 616, 617, 616, 398, 437, 411, 66, 280, 388,
108294
+ /* 240 */ 411, 595, 439, 220, 438, 620, 619, 337, 569, 279,
108295
+ /* 250 */ 201, 414, 588, 582, 166, 414, 546, 167, 68, 234,
108296
+ /* 260 */ 599, 92, 620, 619, 599, 92, 19, 570, 570, 466,
108297
+ /* 270 */ 564, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108298
+ /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108299
+ /* 290 */ 53, 52, 52, 52, 51, 233, 310, 411, 524, 232,
108300
+ /* 300 */ 231, 398, 593, 547, 559, 398, 348, 202, 175, 595,
108301
+ /* 310 */ 399, 315, 414, 617, 616, 387, 272, 255, 347, 254,
108302
+ /* 320 */ 558, 599, 74, 620, 619, 45, 588, 582, 235, 466,
108303
+ /* 330 */ 617, 616, 511, 591, 591, 591, 557, 578, 402, 545,
108304
+ /* 340 */ 600, 598, 570, 570, 601, 57, 58, 48, 580, 579,
108305
+ /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 550, 54,
108306
+ /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108307
+ /* 370 */ 310, 309, 411, 145, 566, 490, 213, 255, 347, 254,
108308
+ /* 380 */ 196, 195, 194, 587, 586, 531, 600, 414, 235, 174,
108309
+ /* 390 */ 601, 617, 616, 411, 620, 619, 599, 91, 547, 574,
108310
+ /* 400 */ 588, 582, 50, 47, 146, 584, 583, 471, 414, 249,
108311
+ /* 410 */ 565, 542, 186, 39, 304, 424, 562, 599, 16, 57,
108312
+ /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108313
+ /* 430 */ 56, 56, 585, 54, 54, 54, 54, 53, 53, 52,
108314
+ /* 440 */ 52, 52, 51, 233, 310, 559, 290, 530, 529, 345,
108315
+ /* 450 */ 533, 576, 540, 246, 170, 248, 411, 396, 411, 422,
108316
+ /* 460 */ 199, 558, 617, 616, 165, 563, 50, 47, 146, 181,
108317
+ /* 470 */ 498, 414, 166, 414, 588, 582, 269, 557, 166, 518,
108318
+ /* 480 */ 599, 92, 599, 92, 561, 595, 469, 36, 173, 409,
108319
+ /* 490 */ 517, 577, 577, 57, 58, 48, 580, 579, 581, 581,
108320
+ /* 500 */ 55, 55, 56, 56, 56, 56, 338, 54, 54, 54,
108321
+ /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 304,
108322
+ /* 520 */ 423, 394, 526, 318, 869, 235, 167, 180, 473, 547,
108323
+ /* 530 */ 503, 247, 474, 381, 378, 377, 409, 351, 577, 577,
108324
+ /* 540 */ 409, 560, 577, 577, 376, 383, 364, 603, 588, 582,
108325
+ /* 550 */ 620, 619, 502, 595, 409, 494, 577, 577, 409, 266,
108326
+ /* 560 */ 577, 577, 421, 943, 422, 943, 198, 57, 58, 48,
108327
+ /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108328
+ /* 580 */ 315, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108329
+ /* 590 */ 51, 233, 310, 390, 421, 942, 509, 942, 556, 145,
108330
+ /* 600 */ 598, 391, 324, 262, 549, 264, 411, 425, 407, 573,
108331
+ /* 610 */ 572, 12, 197, 143, 489, 50, 47, 146, 617, 616,
108332
+ /* 620 */ 206, 414, 588, 582, 547, 429, 67, 212, 143, 618,
108333
+ /* 630 */ 599, 73, 504, 505, 207, 434, 475, 475, 366, 425,
108334
+ /* 640 */ 35, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108335
+ /* 650 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108336
+ /* 660 */ 53, 52, 52, 52, 51, 233, 310, 260, 598, 569,
108337
+ /* 670 */ 268, 615, 614, 613, 171, 411, 595, 11, 411, 350,
108338
+ /* 680 */ 411, 32, 618, 953, 183, 419, 2, 627, 625, 330,
108339
+ /* 690 */ 414, 352, 552, 414, 538, 414, 588, 582, 188, 599,
108340
+ /* 700 */ 69, 551, 599, 94, 599, 97, 374, 544, 166, 618,
108341
+ /* 710 */ 334, 359, 50, 47, 146, 57, 58, 48, 580, 579,
108342
+ /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108343
+ /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108344
+ /* 740 */ 310, 411, 129, 414, 595, 22, 273, 156, 411, 566,
108345
+ /* 750 */ 406, 213, 599, 95, 570, 570, 414, 327, 169, 332,
108346
+ /* 760 */ 411, 618, 536, 414, 358, 599, 104, 483, 508, 356,
108347
+ /* 770 */ 588, 582, 599, 103, 484, 414, 470, 357, 166, 618,
108348
+ /* 780 */ 626, 2, 204, 323, 599, 105, 40, 528, 38, 57,
108349
+ /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108350
+ /* 800 */ 56, 56, 411, 54, 54, 54, 54, 53, 53, 52,
108351
+ /* 810 */ 52, 52, 51, 233, 310, 411, 598, 414, 411, 260,
108352
+ /* 820 */ 273, 273, 273, 273, 426, 305, 599, 106, 520, 519,
108353
+ /* 830 */ 414, 411, 142, 414, 618, 618, 618, 618, 618, 599,
108354
+ /* 840 */ 133, 339, 599, 134, 588, 582, 414, 21, 30, 316,
108355
+ /* 850 */ 147, 459, 221, 170, 527, 599, 98, 222, 322, 321,
108356
+ /* 860 */ 320, 141, 259, 57, 58, 48, 580, 579, 581, 581,
108357
+ /* 870 */ 55, 55, 56, 56, 56, 56, 411, 54, 54, 54,
108358
+ /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 411,
108359
+ /* 890 */ 260, 414, 411, 458, 200, 35, 411, 358, 211, 228,
108360
+ /* 900 */ 599, 102, 468, 519, 414, 618, 28, 414, 538, 501,
108361
+ /* 910 */ 411, 414, 618, 599, 101, 358, 599, 93, 588, 582,
108362
+ /* 920 */ 599, 100, 522, 618, 427, 414, 306, 271, 598, 380,
108363
+ /* 930 */ 618, 602, 598, 452, 599, 77, 210, 57, 58, 48,
108364
+ /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108365
+ /* 950 */ 411, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108366
+ /* 960 */ 51, 233, 310, 411, 621, 414, 411, 127, 609, 270,
108367
+ /* 970 */ 598, 365, 51, 233, 599, 96, 625, 330, 414, 618,
108368
+ /* 980 */ 126, 414, 411, 618, 411, 253, 608, 599, 137, 27,
108369
+ /* 990 */ 599, 136, 588, 582, 375, 260, 125, 414, 164, 414,
108370
+ /* 1000 */ 371, 618, 279, 219, 542, 542, 599, 135, 599, 76,
108371
+ /* 1010 */ 618, 57, 46, 48, 580, 579, 581, 581, 55, 55,
108372
+ /* 1020 */ 56, 56, 56, 56, 411, 54, 54, 54, 54, 53,
108373
+ /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 411, 450, 414,
108374
+ /* 1040 */ 411, 260, 542, 229, 285, 607, 479, 184, 599, 90,
108375
+ /* 1050 */ 367, 122, 414, 476, 121, 414, 618, 170, 411, 353,
108376
+ /* 1060 */ 618, 599, 89, 410, 599, 75, 588, 582, 472, 257,
108377
+ /* 1070 */ 538, 120, 159, 414, 618, 14, 464, 158, 618, 157,
108378
+ /* 1080 */ 461, 283, 599, 88, 449, 618, 58, 48, 580, 579,
108379
+ /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108380
+ /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108381
+ /* 1110 */ 310, 411, 260, 414, 411, 592, 260, 118, 25, 400,
108382
+ /* 1120 */ 10, 24, 599, 87, 117, 216, 414, 618, 349, 414,
108383
+ /* 1130 */ 618, 618, 411, 319, 618, 599, 99, 555, 599, 86,
108384
+ /* 1140 */ 588, 582, 4, 260, 457, 455, 115, 414, 251, 154,
108385
+ /* 1150 */ 451, 108, 618, 110, 436, 448, 599, 17, 618, 218,
108386
+ /* 1160 */ 107, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108387
+ /* 1170 */ 56, 56, 435, 54, 54, 54, 54, 53, 53, 52,
108388
+ /* 1180 */ 52, 52, 51, 233, 44, 405, 217, 3, 411, 260,
108389
+ /* 1190 */ 543, 415, 619, 445, 64, 149, 539, 237, 333, 329,
108390
+ /* 1200 */ 203, 187, 408, 414, 618, 618, 420, 44, 405, 411,
108391
+ /* 1210 */ 3, 618, 599, 85, 415, 619, 148, 227, 622, 179,
108392
+ /* 1220 */ 313, 403, 312, 612, 414, 408, 611, 124, 417, 178,
108393
+ /* 1230 */ 610, 564, 243, 599, 84, 537, 8, 176, 235, 416,
108394
+ /* 1240 */ 294, 418, 623, 30, 403, 597, 411, 236, 293, 123,
108395
+ /* 1250 */ 618, 41, 42, 532, 564, 205, 292, 275, 43, 413,
108396
+ /* 1260 */ 412, 414, 395, 593, 507, 274, 31, 397, 291, 37,
108397
+ /* 1270 */ 599, 83, 618, 491, 41, 42, 267, 411, 265, 618,
108398
+ /* 1280 */ 618, 43, 413, 412, 596, 263, 593, 60, 618, 598,
108399
+ /* 1290 */ 261, 618, 414, 618, 591, 591, 591, 590, 589, 13,
108400
+ /* 1300 */ 618, 599, 72, 554, 235, 618, 44, 405, 256, 3,
108401
+ /* 1310 */ 361, 172, 340, 415, 619, 230, 411, 591, 591, 591,
108402
+ /* 1320 */ 590, 589, 13, 618, 408, 618, 182, 411, 286, 34,
108403
+ /* 1330 */ 405, 414, 3, 411, 463, 411, 415, 619, 29, 331,
108404
+ /* 1340 */ 599, 71, 414, 403, 392, 386, 284, 408, 414, 618,
108405
+ /* 1350 */ 414, 599, 82, 564, 411, 462, 354, 599, 81, 599,
108406
+ /* 1360 */ 80, 541, 250, 535, 282, 521, 403, 534, 516, 414,
108407
+ /* 1370 */ 618, 618, 454, 41, 42, 411, 564, 618, 599, 70,
108408
+ /* 1380 */ 43, 413, 412, 444, 515, 593, 242, 618, 325, 61,
108409
+ /* 1390 */ 414, 277, 239, 620, 619, 238, 41, 42, 618, 599,
108410
+ /* 1400 */ 18, 618, 512, 43, 413, 412, 511, 618, 593, 430,
108411
+ /* 1410 */ 618, 411, 128, 510, 308, 226, 591, 591, 591, 590,
108412
+ /* 1420 */ 589, 13, 215, 289, 618, 225, 414, 302, 301, 300,
108413
+ /* 1430 */ 177, 298, 411, 564, 453, 599, 79, 224, 618, 591,
108414
+ /* 1440 */ 591, 591, 590, 589, 13, 389, 492, 414, 150, 144,
108415
+ /* 1450 */ 241, 393, 288, 191, 190, 193, 599, 78, 165, 240,
108416
+ /* 1460 */ 414, 524, 487, 307, 618, 593, 618, 618, 486, 599,
108417
+ /* 1470 */ 9, 163, 152, 485, 466, 372, 480, 162, 153, 370,
108418
+ /* 1480 */ 161, 151, 209, 478, 258, 368, 477, 26, 160, 467,
108419
+ /* 1490 */ 140, 362, 131, 119, 116, 456, 591, 591, 591, 155,
108420
+ /* 1500 */ 114, 344, 343, 113, 112, 111, 447, 109, 130, 23,
108421
+ /* 1510 */ 317, 433, 20, 432, 431, 428, 606, 594, 63, 189,
108422
+ /* 1520 */ 404, 571, 255, 342, 244, 295, 287, 278, 311, 508,
108423
+ /* 1530 */ 496, 497, 495, 235, 493, 568, 379, 355, 460, 245,
108424
+ /* 1540 */ 341, 446, 303, 567, 5, 252, 548, 208, 139, 506,
108425
+ /* 1550 */ 369, 401, 500, 499, 296, 525, 335, 488, 482, 523,
108426
+ /* 1560 */ 233,
108237108427
};
108238108428
static const YYCODETYPE yy_lookahead[] = {
108239108429
/* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108240108430
/* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108241
- /* 20 */ 89, 90, 91, 92, 26, 27, 1, 26, 27, 15,
108242
- /* 30 */ 49, 50, 77, 78, 79, 80, 116, 82, 83, 84,
108243
- /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 128, 68,
108431
+ /* 20 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 1,
108432
+ /* 30 */ 49, 50, 77, 78, 79, 80, 155, 82, 83, 84,
108433
+ /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 15, 68,
108244108434
/* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108245108435
/* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108246
- /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 86, 87,
108436
+ /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 1, 25,
108247108437
/* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108248
- /* 90 */ 91, 92, 94, 95, 19, 94, 95, 96, 172, 173,
108249
- /* 100 */ 99, 100, 101, 197, 49, 50, 177, 181, 22, 54,
108250
- /* 110 */ 204, 110, 26, 27, 86, 87, 88, 89, 90, 91,
108251
- /* 120 */ 92, 129, 130, 68, 69, 70, 71, 72, 73, 74,
108252
- /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84,
108438
+ /* 90 */ 91, 92, 86, 87, 88, 89, 90, 91, 92, 150,
108439
+ /* 100 */ 23, 150, 25, 116, 49, 50, 177, 158, 227, 54,
108440
+ /* 110 */ 161, 162, 231, 22, 165, 128, 165, 26, 27, 160,
108441
+ /* 120 */ 22, 170, 171, 68, 69, 70, 71, 72, 73, 74,
108442
+ /* 130 */ 75, 76, 77, 78, 79, 80, 23, 82, 83, 84,
108253108443
/* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108254
- /* 150 */ 221, 222, 223, 96, 97, 98, 99, 100, 101, 102,
108255
- /* 160 */ 112, 32, 114, 115, 26, 27, 109, 92, 150, 25,
108256
- /* 170 */ 41, 150, 97, 98, 99, 100, 101, 102, 49, 50,
108257
- /* 180 */ 94, 95, 98, 165, 109, 25, 165, 163, 170, 171,
108258
- /* 190 */ 166, 167, 168, 109, 12, 174, 175, 68, 69, 70,
108444
+ /* 150 */ 221, 222, 223, 194, 97, 98, 99, 100, 101, 102,
108445
+ /* 160 */ 150, 32, 26, 27, 26, 27, 109, 22, 150, 150,
108446
+ /* 170 */ 41, 161, 162, 96, 76, 165, 217, 150, 49, 50,
108447
+ /* 180 */ 229, 230, 172, 165, 165, 94, 95, 118, 170, 171,
108448
+ /* 190 */ 118, 232, 165, 174, 175, 185, 237, 68, 69, 70,
108259108449
/* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108260
- /* 210 */ 28, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108261
- /* 220 */ 91, 92, 19, 11, 86, 87, 44, 24, 46, 221,
108262
- /* 230 */ 222, 223, 94, 95, 66, 97, 215, 7, 8, 57,
108263
- /* 240 */ 150, 220, 104, 19, 106, 26, 27, 229, 230, 241,
108264
- /* 250 */ 160, 27, 49, 50, 22, 165, 96, 118, 16, 99,
108265
- /* 260 */ 100, 101, 94, 119, 174, 175, 98, 129, 130, 57,
108266
- /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108450
+ /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108451
+ /* 220 */ 91, 92, 19, 11, 86, 87, 19, 24, 7, 8,
108452
+ /* 230 */ 94, 95, 94, 95, 215, 97, 150, 22, 98, 220,
108453
+ /* 240 */ 150, 26, 104, 216, 106, 26, 27, 229, 230, 109,
108454
+ /* 250 */ 160, 165, 49, 50, 25, 165, 120, 50, 22, 197,
108455
+ /* 260 */ 174, 175, 26, 27, 174, 175, 204, 129, 130, 57,
108456
+ /* 270 */ 66, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108267108457
/* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108268
- /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
108269
- /* 300 */ 150, 23, 60, 25, 62, 215, 150, 150, 76, 150,
108270
- /* 310 */ 220, 161, 162, 94, 95, 165, 30, 105, 106, 107,
108271
- /* 320 */ 34, 165, 165, 23, 165, 25, 49, 50, 116, 170,
108272
- /* 330 */ 171, 174, 175, 22, 48, 185, 186, 26, 27, 120,
108273
- /* 340 */ 26, 27, 12, 187, 160, 68, 69, 70, 71, 72,
108274
- /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 28, 82,
108458
+ /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 94, 86,
108459
+ /* 300 */ 87, 215, 98, 25, 12, 215, 220, 160, 118, 94,
108460
+ /* 310 */ 220, 104, 165, 94, 95, 88, 109, 105, 106, 107,
108461
+ /* 320 */ 28, 174, 175, 26, 27, 22, 49, 50, 116, 57,
108462
+ /* 330 */ 94, 95, 103, 129, 130, 131, 44, 113, 46, 120,
108463
+ /* 340 */ 113, 194, 129, 130, 117, 68, 69, 70, 71, 72,
108464
+ /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 177, 82,
108275108465
/* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108276
- /* 370 */ 19, 150, 215, 95, 44, 23, 46, 220, 194, 96,
108277
- /* 380 */ 138, 160, 99, 100, 101, 23, 165, 25, 229, 230,
108278
- /* 390 */ 26, 27, 135, 110, 137, 174, 175, 57, 120, 150,
108279
- /* 400 */ 49, 50, 88, 219, 113, 94, 95, 158, 94, 95,
108280
- /* 410 */ 161, 162, 21, 136, 165, 194, 169, 170, 171, 68,
108466
+ /* 370 */ 19, 163, 150, 95, 166, 167, 168, 105, 106, 107,
108467
+ /* 380 */ 105, 106, 107, 49, 50, 88, 113, 165, 116, 118,
108468
+ /* 390 */ 117, 94, 95, 150, 26, 27, 174, 175, 120, 23,
108469
+ /* 400 */ 49, 50, 221, 222, 223, 71, 72, 21, 165, 16,
108470
+ /* 410 */ 23, 166, 22, 136, 22, 23, 11, 174, 175, 68,
108281108471
/* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108282
- /* 430 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108283
- /* 440 */ 89, 90, 91, 92, 19, 105, 106, 107, 23, 88,
108284
- /* 450 */ 89, 90, 91, 92, 63, 23, 116, 88, 94, 95,
108285
- /* 460 */ 142, 143, 144, 145, 112, 150, 114, 115, 105, 106,
108286
- /* 470 */ 107, 23, 23, 25, 49, 50, 118, 230, 97, 98,
108287
- /* 480 */ 165, 16, 113, 118, 120, 160, 117, 136, 113, 174,
108288
- /* 490 */ 175, 100, 117, 68, 69, 70, 71, 72, 73, 74,
108289
- /* 500 */ 75, 76, 77, 78, 79, 80, 160, 82, 83, 84,
108290
- /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 194,
108291
- /* 520 */ 25, 112, 23, 114, 115, 60, 150, 62, 150, 138,
108292
- /* 530 */ 150, 105, 106, 107, 19, 150, 36, 161, 162, 224,
108293
- /* 540 */ 194, 165, 217, 165, 112, 165, 114, 115, 49, 50,
108294
- /* 550 */ 165, 51, 174, 175, 174, 175, 166, 232, 58, 174,
108295
- /* 560 */ 175, 112, 237, 114, 115, 50, 22, 68, 69, 70,
108472
+ /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
108473
+ /* 440 */ 89, 90, 91, 92, 19, 12, 224, 23, 23, 63,
108474
+ /* 450 */ 205, 23, 23, 60, 25, 62, 150, 214, 150, 67,
108475
+ /* 460 */ 22, 28, 94, 95, 96, 23, 221, 222, 223, 23,
108476
+ /* 470 */ 23, 165, 25, 165, 49, 50, 23, 44, 25, 46,
108477
+ /* 480 */ 174, 175, 174, 175, 23, 26, 100, 136, 25, 112,
108478
+ /* 490 */ 57, 114, 115, 68, 69, 70, 71, 72, 73, 74,
108479
+ /* 500 */ 75, 76, 77, 78, 79, 80, 97, 82, 83, 84,
108480
+ /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 22,
108481
+ /* 520 */ 23, 215, 23, 215, 138, 116, 50, 23, 30, 25,
108482
+ /* 530 */ 36, 138, 34, 99, 100, 101, 112, 128, 114, 115,
108483
+ /* 540 */ 112, 23, 114, 115, 110, 51, 48, 173, 49, 50,
108484
+ /* 550 */ 26, 27, 58, 94, 112, 181, 114, 115, 112, 16,
108485
+ /* 560 */ 114, 115, 22, 23, 67, 25, 160, 68, 69, 70,
108296108486
/* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108297
- /* 580 */ 160, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108298
- /* 590 */ 91, 92, 19, 215, 214, 205, 23, 7, 8, 9,
108299
- /* 600 */ 215, 155, 24, 22, 26, 150, 97, 26, 108, 129,
108300
- /* 610 */ 130, 221, 222, 223, 194, 0, 1, 2, 150, 104,
108301
- /* 620 */ 165, 126, 49, 50, 109, 116, 206, 207, 118, 174,
108302
- /* 630 */ 175, 22, 23, 165, 25, 22, 23, 128, 25, 118,
108303
- /* 640 */ 26, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108304
- /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108305
- /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
108306
- /* 670 */ 23, 160, 94, 227, 150, 94, 67, 231, 174, 175,
108307
- /* 680 */ 67, 213, 165, 165, 221, 222, 223, 150, 150, 165,
108308
- /* 690 */ 23, 32, 174, 175, 181, 182, 49, 50, 174, 175,
108309
- /* 700 */ 41, 188, 165, 165, 22, 194, 177, 11, 94, 23,
108310
- /* 710 */ 193, 174, 175, 160, 22, 68, 69, 70, 71, 72,
108311
- /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 217, 82,
108487
+ /* 580 */ 104, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108488
+ /* 590 */ 91, 92, 19, 19, 22, 23, 23, 25, 23, 95,
108489
+ /* 600 */ 194, 27, 108, 60, 25, 62, 150, 67, 169, 170,
108490
+ /* 610 */ 171, 35, 206, 207, 150, 221, 222, 223, 94, 95,
108491
+ /* 620 */ 160, 165, 49, 50, 120, 161, 162, 206, 207, 165,
108492
+ /* 630 */ 174, 175, 97, 98, 160, 241, 105, 106, 107, 67,
108493
+ /* 640 */ 25, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108494
+ /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108495
+ /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 230,
108496
+ /* 670 */ 23, 7, 8, 9, 24, 150, 26, 35, 150, 219,
108497
+ /* 680 */ 150, 25, 165, 142, 143, 144, 145, 0, 1, 2,
108498
+ /* 690 */ 165, 217, 32, 165, 150, 165, 49, 50, 119, 174,
108499
+ /* 700 */ 175, 41, 174, 175, 174, 175, 23, 120, 25, 165,
108500
+ /* 710 */ 193, 237, 221, 222, 223, 68, 69, 70, 71, 72,
108501
+ /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108312108502
/* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108313
- /* 740 */ 19, 150, 150, 150, 25, 24, 19, 194, 237, 150,
108314
- /* 750 */ 221, 222, 223, 25, 27, 23, 165, 165, 165, 242,
108315
- /* 760 */ 165, 23, 150, 25, 165, 174, 175, 174, 175, 174,
108316
- /* 770 */ 49, 50, 219, 150, 22, 23, 238, 165, 25, 22,
108317
- /* 780 */ 23, 23, 166, 167, 168, 193, 174, 175, 165, 68,
108503
+ /* 740 */ 19, 150, 22, 165, 94, 24, 150, 25, 150, 166,
108504
+ /* 750 */ 167, 168, 174, 175, 129, 130, 165, 213, 35, 242,
108505
+ /* 760 */ 150, 165, 27, 165, 150, 174, 175, 181, 182, 19,
108506
+ /* 770 */ 49, 50, 174, 175, 188, 165, 23, 27, 25, 165,
108507
+ /* 780 */ 144, 145, 160, 187, 174, 175, 135, 23, 137, 68,
108318108508
/* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108319108509
/* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108320
- /* 810 */ 89, 90, 91, 92, 19, 150, 23, 165, 150, 67,
108321
- /* 820 */ 150, 25, 103, 95, 67, 35, 174, 175, 206, 207,
108322
- /* 830 */ 165, 150, 25, 165, 150, 165, 213, 150, 150, 174,
108323
- /* 840 */ 175, 35, 174, 175, 49, 50, 165, 52, 120, 165,
108324
- /* 850 */ 245, 246, 165, 165, 35, 174, 175, 187, 174, 175,
108325
- /* 860 */ 23, 50, 25, 68, 69, 70, 71, 72, 73, 74,
108510
+ /* 810 */ 89, 90, 91, 92, 19, 150, 194, 165, 150, 150,
108511
+ /* 820 */ 150, 150, 150, 150, 247, 248, 174, 175, 190, 191,
108512
+ /* 830 */ 165, 150, 118, 165, 165, 165, 165, 165, 165, 174,
108513
+ /* 840 */ 175, 219, 174, 175, 49, 50, 165, 52, 126, 245,
108514
+ /* 850 */ 246, 23, 238, 25, 23, 174, 175, 187, 187, 187,
108515
+ /* 860 */ 187, 39, 193, 68, 69, 70, 71, 72, 73, 74,
108326108516
/* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108327108517
/* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108328
- /* 890 */ 150, 165, 150, 150, 160, 23, 150, 25, 144, 145,
108329
- /* 900 */ 174, 175, 120, 216, 165, 165, 22, 165, 165, 150,
108330
- /* 910 */ 150, 165, 27, 174, 175, 104, 174, 175, 49, 50,
108331
- /* 920 */ 174, 175, 247, 248, 165, 165, 238, 187, 194, 23,
108332
- /* 930 */ 187, 25, 166, 174, 175, 190, 191, 68, 69, 70,
108518
+ /* 890 */ 150, 165, 150, 23, 160, 25, 150, 150, 160, 52,
108519
+ /* 900 */ 174, 175, 190, 191, 165, 165, 22, 165, 150, 29,
108520
+ /* 910 */ 150, 165, 165, 174, 175, 150, 174, 175, 49, 50,
108521
+ /* 920 */ 174, 175, 165, 165, 23, 165, 25, 25, 194, 52,
108522
+ /* 930 */ 165, 174, 194, 193, 174, 175, 160, 68, 69, 70,
108333108523
/* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108334108524
/* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108335
- /* 960 */ 91, 92, 19, 150, 150, 165, 150, 23, 150, 25,
108336
- /* 970 */ 23, 205, 25, 213, 174, 175, 190, 191, 165, 165,
108337
- /* 980 */ 118, 165, 150, 165, 150, 150, 23, 174, 175, 39,
108338
- /* 990 */ 174, 175, 49, 50, 173, 150, 23, 165, 52, 165,
108339
- /* 1000 */ 165, 187, 181, 22, 166, 166, 174, 175, 174, 175,
108525
+ /* 960 */ 91, 92, 19, 150, 150, 165, 150, 22, 150, 23,
108526
+ /* 970 */ 194, 213, 91, 92, 174, 175, 1, 2, 165, 165,
108527
+ /* 980 */ 22, 165, 150, 165, 150, 238, 150, 174, 175, 22,
108528
+ /* 990 */ 174, 175, 49, 50, 52, 150, 22, 165, 102, 165,
108529
+ /* 1000 */ 19, 165, 109, 238, 166, 166, 174, 175, 174, 175,
108340108530
/* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108341108531
/* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108342108532
/* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108343
- /* 1040 */ 150, 160, 150, 205, 205, 150, 150, 29, 174, 175,
108344
- /* 1050 */ 52, 216, 165, 22, 150, 165, 238, 165, 150, 150,
108345
- /* 1060 */ 165, 165, 49, 50, 174, 175, 49, 50, 23, 165,
108346
- /* 1070 */ 91, 92, 22, 165, 165, 194, 1, 2, 22, 52,
108347
- /* 1080 */ 193, 109, 174, 175, 71, 72, 69, 70, 71, 72,
108533
+ /* 1040 */ 150, 150, 166, 205, 205, 150, 20, 24, 174, 175,
108534
+ /* 1050 */ 43, 104, 165, 59, 53, 165, 165, 25, 150, 150,
108535
+ /* 1060 */ 165, 174, 175, 150, 174, 175, 49, 50, 53, 138,
108536
+ /* 1070 */ 150, 22, 104, 165, 165, 5, 1, 118, 165, 35,
108537
+ /* 1080 */ 27, 205, 174, 175, 193, 165, 69, 70, 71, 72,
108348108538
/* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108349108539
/* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108350
- /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 102, 150, 150,
108351
- /* 1120 */ 22, 19, 174, 175, 20, 24, 104, 165, 43, 165,
108352
- /* 1130 */ 165, 165, 150, 165, 165, 150, 174, 175, 174, 175,
108353
- /* 1140 */ 49, 50, 59, 53, 138, 25, 53, 165, 104, 22,
108354
- /* 1150 */ 165, 5, 118, 1, 76, 76, 174, 175, 193, 174,
108355
- /* 1160 */ 175, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108356
- /* 1170 */ 79, 80, 35, 82, 83, 84, 85, 86, 87, 88,
108357
- /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 150,
108358
- /* 1190 */ 150, 26, 27, 27, 108, 127, 150, 150, 22, 25,
108359
- /* 1200 */ 22, 165, 37, 165, 165, 165, 119, 19, 20, 150,
108360
- /* 1210 */ 22, 165, 165, 150, 26, 27, 23, 1, 16, 20,
108361
- /* 1220 */ 150, 56, 119, 108, 165, 37, 121, 128, 165, 193,
108362
- /* 1230 */ 23, 66, 193, 174, 175, 165, 127, 174, 175, 16,
108363
- /* 1240 */ 23, 146, 147, 15, 56, 65, 150, 152, 140, 154,
108364
- /* 1250 */ 150, 86, 87, 88, 66, 160, 22, 150, 93, 94,
108365
- /* 1260 */ 95, 165, 150, 98, 150, 165, 3, 246, 4, 150,
108366
- /* 1270 */ 174, 175, 165, 150, 86, 87, 6, 165, 150, 165,
108367
- /* 1280 */ 164, 93, 94, 95, 165, 149, 98, 149, 165, 194,
108368
- /* 1290 */ 180, 180, 249, 165, 129, 130, 131, 132, 133, 134,
108369
- /* 1300 */ 193, 150, 174, 175, 116, 193, 19, 20, 150, 22,
108370
- /* 1310 */ 249, 149, 217, 26, 27, 151, 165, 129, 130, 131,
108371
- /* 1320 */ 132, 133, 134, 165, 37, 174, 175, 150, 149, 19,
108372
- /* 1330 */ 20, 150, 22, 150, 150, 150, 26, 27, 13, 244,
108373
- /* 1340 */ 151, 159, 165, 56, 25, 116, 165, 37, 165, 165,
108374
- /* 1350 */ 165, 174, 175, 66, 150, 174, 175, 174, 175, 174,
108375
- /* 1360 */ 175, 194, 150, 150, 150, 126, 56, 199, 124, 165,
108376
- /* 1370 */ 200, 150, 150, 86, 87, 150, 66, 165, 165, 165,
108377
- /* 1380 */ 93, 94, 95, 150, 122, 98, 165, 165, 123, 22,
108378
- /* 1390 */ 165, 201, 150, 26, 27, 150, 86, 87, 165, 174,
108379
- /* 1400 */ 175, 203, 202, 93, 94, 95, 125, 165, 98, 150,
108380
- /* 1410 */ 165, 150, 225, 135, 157, 118, 129, 130, 131, 132,
108381
- /* 1420 */ 133, 134, 5, 150, 165, 157, 165, 10, 11, 12,
108382
- /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 210, 165, 129,
108383
- /* 1440 */ 130, 131, 132, 133, 134, 150, 104, 165, 31, 150,
108384
- /* 1450 */ 33, 150, 150, 86, 87, 150, 174, 175, 211, 42,
108385
- /* 1460 */ 165, 94, 121, 210, 165, 98, 165, 165, 176, 211,
108386
- /* 1470 */ 165, 211, 55, 104, 57, 184, 210, 47, 61, 176,
108387
- /* 1480 */ 176, 64, 103, 176, 178, 22, 92, 179, 176, 176,
108388
- /* 1490 */ 176, 156, 18, 184, 179, 228, 129, 130, 131, 228,
108389
- /* 1500 */ 157, 156, 45, 157, 156, 236, 157, 157, 135, 235,
108390
- /* 1510 */ 156, 189, 157, 68, 218, 189, 22, 199, 156, 192,
108391
- /* 1520 */ 157, 18, 105, 106, 107, 192, 192, 199, 111, 192,
108392
- /* 1530 */ 240, 157, 40, 116, 218, 157, 189, 157, 240, 38,
108393
- /* 1540 */ 153, 166, 198, 243, 178, 209, 182, 196, 177, 226,
108394
- /* 1550 */ 230, 230, 166, 177, 177, 166, 139, 199, 199, 148,
108395
- /* 1560 */ 195, 209, 209, 239, 196, 166, 234, 183, 239, 208,
108396
- /* 1570 */ 174, 233, 191, 183, 183, 174, 92, 250, 186, 186,
108540
+ /* 1110 */ 19, 150, 150, 165, 150, 150, 150, 108, 76, 150,
108541
+ /* 1120 */ 22, 76, 174, 175, 127, 216, 165, 165, 25, 165,
108542
+ /* 1130 */ 165, 165, 150, 213, 165, 174, 175, 150, 174, 175,
108543
+ /* 1140 */ 49, 50, 22, 150, 23, 1, 119, 165, 16, 121,
108544
+ /* 1150 */ 20, 108, 165, 119, 23, 193, 174, 175, 165, 193,
108545
+ /* 1160 */ 127, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108546
+ /* 1170 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108547
+ /* 1180 */ 89, 90, 91, 92, 19, 20, 193, 22, 150, 150,
108548
+ /* 1190 */ 150, 26, 27, 128, 16, 15, 150, 140, 65, 3,
108549
+ /* 1200 */ 164, 22, 37, 165, 165, 165, 4, 19, 20, 150,
108550
+ /* 1210 */ 22, 165, 174, 175, 26, 27, 246, 180, 149, 6,
108551
+ /* 1220 */ 249, 56, 249, 149, 165, 37, 149, 180, 149, 151,
108552
+ /* 1230 */ 13, 66, 193, 174, 175, 150, 25, 151, 116, 159,
108553
+ /* 1240 */ 199, 146, 147, 126, 56, 194, 150, 152, 200, 154,
108554
+ /* 1250 */ 165, 86, 87, 88, 66, 160, 201, 150, 93, 94,
108555
+ /* 1260 */ 95, 165, 123, 98, 150, 150, 124, 122, 202, 135,
108556
+ /* 1270 */ 174, 175, 165, 150, 86, 87, 150, 150, 150, 165,
108557
+ /* 1280 */ 165, 93, 94, 95, 203, 150, 98, 125, 165, 194,
108558
+ /* 1290 */ 150, 165, 165, 165, 129, 130, 131, 132, 133, 134,
108559
+ /* 1300 */ 165, 174, 175, 157, 116, 165, 19, 20, 150, 22,
108560
+ /* 1310 */ 150, 118, 217, 26, 27, 225, 150, 129, 130, 131,
108561
+ /* 1320 */ 132, 133, 134, 165, 37, 165, 157, 150, 210, 19,
108562
+ /* 1330 */ 20, 165, 22, 150, 150, 150, 26, 27, 104, 244,
108563
+ /* 1340 */ 174, 175, 165, 56, 121, 104, 210, 37, 165, 165,
108564
+ /* 1350 */ 165, 174, 175, 66, 150, 150, 150, 174, 175, 174,
108565
+ /* 1360 */ 175, 211, 150, 211, 210, 176, 56, 211, 176, 165,
108566
+ /* 1370 */ 165, 165, 150, 86, 87, 150, 66, 165, 174, 175,
108567
+ /* 1380 */ 93, 94, 95, 150, 184, 98, 150, 165, 47, 22,
108568
+ /* 1390 */ 165, 176, 150, 26, 27, 150, 86, 87, 165, 174,
108569
+ /* 1400 */ 175, 165, 178, 93, 94, 95, 103, 165, 98, 150,
108570
+ /* 1410 */ 165, 150, 22, 176, 179, 228, 129, 130, 131, 132,
108571
+ /* 1420 */ 133, 134, 5, 150, 165, 92, 165, 10, 11, 12,
108572
+ /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 228, 165, 129,
108573
+ /* 1440 */ 130, 131, 132, 133, 134, 150, 184, 165, 31, 150,
108574
+ /* 1450 */ 33, 150, 150, 86, 87, 172, 174, 175, 96, 42,
108575
+ /* 1460 */ 165, 94, 176, 179, 165, 98, 165, 165, 176, 174,
108576
+ /* 1470 */ 175, 156, 55, 176, 57, 18, 157, 156, 61, 157,
108577
+ /* 1480 */ 156, 64, 157, 157, 235, 45, 236, 135, 156, 189,
108578
+ /* 1490 */ 68, 157, 218, 189, 22, 199, 129, 130, 131, 156,
108579
+ /* 1500 */ 192, 157, 18, 192, 192, 192, 199, 189, 218, 240,
108580
+ /* 1510 */ 157, 40, 240, 157, 157, 38, 153, 166, 243, 196,
108581
+ /* 1520 */ 226, 230, 105, 106, 107, 198, 209, 177, 111, 182,
108582
+ /* 1530 */ 166, 177, 177, 116, 166, 230, 178, 239, 199, 209,
108583
+ /* 1540 */ 209, 199, 148, 166, 196, 239, 208, 233, 172, 183,
108584
+ /* 1550 */ 234, 191, 183, 183, 195, 174, 139, 186, 186, 174,
108585
+ /* 1560 */ 92,
108397108586
};
108398
-#define YY_SHIFT_USE_DFLT (-81)
108399
-#define YY_SHIFT_COUNT (417)
108400
-#define YY_SHIFT_MIN (-80)
108401
-#define YY_SHIFT_MAX (1503)
108587
+#define YY_SHIFT_USE_DFLT (-70)
108588
+#define YY_SHIFT_COUNT (418)
108589
+#define YY_SHIFT_MIN (-69)
108590
+#define YY_SHIFT_MAX (1484)
108402108591
static const short yy_shift_ofst[] = {
108403
- /* 0 */ 1075, 1188, 1417, 1188, 1287, 1287, 138, 138, 1, -19,
108404
- /* 10 */ 1287, 1287, 1287, 1287, 340, -2, 129, 129, 795, 1165,
108592
+ /* 0 */ 975, 1188, 1417, 1188, 1287, 1287, 138, 138, 368, -19,
108593
+ /* 10 */ 1287, 1287, 1287, 1287, 272, 524, 129, 129, 795, 1165,
108405108594
/* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108406108595
/* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108407108596
/* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108408108597
/* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108409
- /* 60 */ 1287, 1287, 212, -2, -2, -8, -8, 614, 1229, 55,
108598
+ /* 60 */ 1287, 1287, 212, 524, 524, 213, 213, 459, 1122, 55,
108410108599
/* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108411108600
/* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108412108601
/* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108413
- /* 100 */ -45, -45, -45, -45, -1, 57, 28, 361, -2, -2,
108414
- /* 110 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108415
- /* 120 */ -2, -2, -2, -2, 391, 515, -2, -2, -2, -2,
108416
- /* 130 */ -2, 509, -80, 614, 979, 1484, -81, -81, -81, 1367,
108417
- /* 140 */ 75, 182, 182, 314, 311, 364, 219, 86, 613, 609,
108418
- /* 150 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108419
- /* 160 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108420
- /* 170 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108421
- /* 180 */ -2, -2, 578, 578, 578, 615, 1229, 1229, 1229, -81,
108422
- /* 190 */ -81, -81, 160, 168, 168, 283, 500, 500, 500, 278,
108423
- /* 200 */ 449, 330, 432, 409, 352, 48, 48, 48, 48, 426,
108424
- /* 210 */ 286, 48, 48, 728, 581, 369, 590, 495, 224, 224,
108425
- /* 220 */ 727, 495, 727, 719, 614, 659, 614, 659, 811, 659,
108426
- /* 230 */ 224, 257, 480, 480, 614, 144, 375, -18, 1501, 1297,
108427
- /* 240 */ 1297, 1492, 1492, 1297, 1494, 1445, 1239, 1503, 1503, 1503,
108428
- /* 250 */ 1503, 1297, 1474, 1239, 1494, 1445, 1445, 1297, 1474, 1373,
108429
- /* 260 */ 1457, 1297, 1297, 1474, 1297, 1474, 1297, 1474, 1463, 1369,
108430
- /* 270 */ 1369, 1369, 1430, 1394, 1394, 1463, 1369, 1379, 1369, 1430,
108431
- /* 280 */ 1369, 1369, 1341, 1342, 1341, 1342, 1341, 1342, 1297, 1297,
108432
- /* 290 */ 1278, 1281, 1262, 1244, 1265, 1239, 1229, 1319, 1325, 1325,
108433
- /* 300 */ 1270, 1270, 1270, 1270, -81, -81, -81, -81, -81, -81,
108434
- /* 310 */ 1013, 242, 757, 752, 465, 363, 947, 232, 944, 906,
108435
- /* 320 */ 872, 837, 738, 448, 381, 230, 84, 362, 300, 1264,
108436
- /* 330 */ 1263, 1234, 1108, 1228, 1180, 1223, 1217, 1207, 1099, 1174,
108437
- /* 340 */ 1109, 1115, 1103, 1199, 1105, 1202, 1216, 1087, 1193, 1178,
108438
- /* 350 */ 1174, 1176, 1068, 1079, 1078, 1086, 1166, 1137, 1034, 1152,
108439
- /* 360 */ 1146, 1127, 1044, 1006, 1093, 1120, 1090, 1083, 1085, 1022,
108440
- /* 370 */ 1101, 1104, 1102, 972, 1015, 1098, 1027, 1056, 1050, 1045,
108441
- /* 380 */ 1031, 998, 1018, 981, 946, 950, 973, 963, 862, 885,
108442
- /* 390 */ 819, 884, 782, 796, 806, 807, 790, 796, 793, 758,
108443
- /* 400 */ 753, 732, 692, 696, 682, 686, 667, 544, 291, 521,
108444
- /* 410 */ 510, 365, 358, 139, 114, 54, 14, 25,
108602
+ /* 100 */ -45, -45, -45, -45, -1, 6, -64, 524, 524, 524,
108603
+ /* 110 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108604
+ /* 120 */ 524, 524, 524, 386, 207, 524, 524, 524, 524, 524,
108605
+ /* 130 */ 409, -13, 459, 881, 1468, -70, -70, -70, 1367, 57,
108606
+ /* 140 */ 433, 433, 297, 236, 219, 136, 91, 572, 540, 524,
108607
+ /* 150 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108608
+ /* 160 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108609
+ /* 170 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108610
+ /* 180 */ 650, 650, 650, 687, 1122, 1122, 1122, -70, -70, -70,
108611
+ /* 190 */ 204, 204, 434, 434, 494, 494, 494, 504, 446, 292,
108612
+ /* 200 */ 442, 428, 424, 77, 377, 377, 377, 377, 531, 498,
108613
+ /* 210 */ 377, 377, 278, 215, 227, 664, 722, 574, 574, 750,
108614
+ /* 220 */ 722, 750, 229, 459, 660, 459, 660, 476, 660, 574,
108615
+ /* 230 */ 651, 625, 625, 459, 579, 273, -18, 1477, 1193, 1193,
108616
+ /* 240 */ 1471, 1471, 1193, 1472, 1422, 1117, 1484, 1484, 1484, 1484,
108617
+ /* 250 */ 1193, 1457, 1117, 1472, 1422, 1422, 1193, 1457, 1352, 1440,
108618
+ /* 260 */ 1193, 1193, 1457, 1193, 1457, 1193, 1457, 1390, 1241, 1241,
108619
+ /* 270 */ 1241, 1362, 1341, 1333, 1333, 1390, 1241, 1303, 1241, 1341,
108620
+ /* 280 */ 1241, 1241, 1223, 1234, 1223, 1234, 1223, 1234, 1193, 1193,
108621
+ /* 290 */ 1134, 1162, 1145, 1142, 1139, 1117, 1122, 1211, 1217, 1217,
108622
+ /* 300 */ 1213, 1213, 1213, 1213, -70, -70, -70, -70, -70, -70,
108623
+ /* 310 */ 334, 393, 497, 392, 543, 275, 901, 98, 870, 828,
108624
+ /* 320 */ 753, 683, 453, 447, 535, 221, 140, 429, 54, 1202,
108625
+ /* 330 */ 1196, 1179, 1057, 1180, 1133, 1178, 1149, 1131, 1065, 1103,
108626
+ /* 340 */ 1033, 1043, 1034, 1130, 1028, 1132, 1144, 1027, 1121, 1120,
108627
+ /* 350 */ 1103, 1098, 997, 1045, 1042, 1009, 1053, 1044, 959, 1075,
108628
+ /* 360 */ 1070, 1049, 968, 931, 1015, 1032, 1001, 994, 1007, 947,
108629
+ /* 370 */ 1023, 1026, 981, 893, 896, 974, 942, 967, 958, 946,
108630
+ /* 380 */ 945, 877, 902, 880, 884, 847, 822, 831, 764, 714,
108631
+ /* 390 */ 735, 723, 720, 587, 615, 642, 656, 576, 615, 575,
108632
+ /* 400 */ 518, 463, 461, 438, 405, 390, 387, 376, 303, 224,
108633
+ /* 410 */ 271, 190, 92, 72, 69, 145, 113, 33, 28,
108445108634
};
108446108635
#define YY_REDUCE_USE_DFLT (-169)
108447108636
#define YY_REDUCE_COUNT (309)
108448108637
#define YY_REDUCE_MIN (-168)
108449
-#define YY_REDUCE_MAX (1411)
108638
+#define YY_REDUCE_MAX (1394)
108450108639
static const short yy_reduce_ofst[] = {
108451
- /* 0 */ 318, 90, 1095, 221, 157, 21, 159, 18, 150, 390,
108452
- /* 10 */ 385, 378, 380, 315, 325, 249, 529, -71, 8, 1282,
108453
- /* 20 */ 1261, 1225, 1185, 1183, 1181, 1177, 1151, 1128, 1096, 1063,
108454
- /* 30 */ 1059, 985, 982, 964, 962, 948, 908, 890, 874, 834,
108455
- /* 40 */ 832, 816, 813, 800, 759, 746, 742, 739, 726, 684,
108456
- /* 50 */ 681, 668, 665, 652, 612, 593, 591, 537, 524, 518,
108457
- /* 60 */ 504, 455, 511, 376, 517, 247, -168, 24, 420, 463,
108458
- /* 70 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108459
- /* 80 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108460
- /* 90 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108461
- /* 100 */ 463, 463, 463, 463, 463, -74, 463, 463, 1112, 835,
108462
- /* 110 */ 1107, 1039, 1036, 965, 887, 845, 818, 760, 688, 687,
108463
- /* 120 */ 538, 743, 623, 592, 446, 513, 814, 740, 670, 156,
108464
- /* 130 */ 468, 553, 184, 616, 463, 463, 463, 463, 463, 595,
108465
- /* 140 */ 821, 786, 745, 909, 1305, 1302, 1301, 1299, 675, 675,
108466
- /* 150 */ 1295, 1273, 1259, 1245, 1242, 1233, 1222, 1221, 1214, 1213,
108467
- /* 160 */ 1212, 1204, 1184, 1158, 1123, 1119, 1114, 1100, 1070, 1047,
108468
- /* 170 */ 1046, 1040, 1038, 969, 968, 966, 909, 904, 896, 895,
108469
- /* 180 */ 892, 599, 839, 838, 766, 754, 881, 734, 346, 605,
108470
- /* 190 */ 622, -94, 1393, 1401, 1396, 1392, 1391, 1390, 1384, 1361,
108471
- /* 200 */ 1365, 1381, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1332,
108472
- /* 210 */ 1338, 1365, 1365, 1361, 1399, 1368, 1411, 1359, 1353, 1352,
108473
- /* 220 */ 1329, 1358, 1324, 1366, 1389, 1377, 1386, 1376, 1364, 1371,
108474
- /* 230 */ 1336, 1323, 1321, 1320, 1375, 1344, 1351, 1387, 1300, 1380,
108475
- /* 240 */ 1378, 1298, 1290, 1374, 1316, 1347, 1328, 1337, 1334, 1333,
108476
- /* 250 */ 1327, 1363, 1362, 1318, 1296, 1326, 1322, 1355, 1354, 1269,
108477
- /* 260 */ 1274, 1350, 1349, 1348, 1346, 1345, 1343, 1335, 1315, 1314,
108478
- /* 270 */ 1313, 1312, 1309, 1271, 1267, 1308, 1307, 1306, 1304, 1291,
108479
- /* 280 */ 1303, 1292, 1260, 1266, 1258, 1253, 1247, 1227, 1268, 1257,
108480
- /* 290 */ 1187, 1198, 1200, 1190, 1170, 1168, 1167, 1182, 1189, 1164,
108481
- /* 300 */ 1179, 1162, 1138, 1136, 1061, 1043, 1021, 1111, 1110, 1116,
108640
+ /* 0 */ 541, 90, 1095, 147, 86, 19, 18, -49, 10, 245,
108641
+ /* 10 */ 308, 306, 243, 222, -41, -51, 181, -71, 394, 1295,
108642
+ /* 20 */ 1282, 1261, 1225, 1204, 1185, 1183, 1177, 1166, 1127, 1096,
108643
+ /* 30 */ 1059, 1038, 982, 964, 961, 948, 908, 890, 887, 874,
108644
+ /* 40 */ 834, 832, 816, 813, 800, 760, 746, 742, 739, 726,
108645
+ /* 50 */ 681, 668, 665, 652, 610, 598, 591, 578, 530, 528,
108646
+ /* 60 */ 525, 456, 474, 464, 517, 439, -168, 208, 406, 491,
108647
+ /* 70 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108648
+ /* 80 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108649
+ /* 90 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108650
+ /* 100 */ 491, 491, 491, 491, 491, 491, 491, 1039, 909, 993,
108651
+ /* 110 */ 966, 962, 891, 845, 740, 765, 920, 747, 27, 614,
108652
+ /* 120 */ 673, 758, 669, -119, 586, 672, 671, 670, 596, 544,
108653
+ /* 130 */ 622, 460, 583, 491, 491, 491, 491, 491, 757, 374,
108654
+ /* 140 */ 712, 638, 913, 1302, 1301, 1299, 1273, 577, 577, 1259,
108655
+ /* 150 */ 1245, 1242, 1236, 1233, 1222, 1212, 1206, 1205, 1184, 1160,
108656
+ /* 160 */ 1158, 1140, 1135, 1128, 1126, 1123, 1115, 1114, 1107, 1085,
108657
+ /* 170 */ 1046, 1040, 987, 969, 965, 913, 895, 836, 818, 814,
108658
+ /* 180 */ 876, 839, 838, 636, 776, 738, 734, 604, 421, 62,
108659
+ /* 190 */ 1385, 1381, 1372, 1371, 1370, 1369, 1366, 1338, 1359, 1360,
108660
+ /* 200 */ 1359, 1359, 1359, 1376, 1359, 1359, 1359, 1359, 1316, 1314,
108661
+ /* 210 */ 1359, 1359, 1338, 1377, 1348, 1394, 1342, 1331, 1330, 1306,
108662
+ /* 220 */ 1339, 1298, 1358, 1368, 1355, 1364, 1354, 1347, 1350, 1317,
108663
+ /* 230 */ 1294, 1305, 1291, 1351, 1327, 1323, 1363, 1275, 1357, 1356,
108664
+ /* 240 */ 1272, 1269, 1353, 1290, 1318, 1307, 1313, 1312, 1311, 1308,
108665
+ /* 250 */ 1344, 1343, 1296, 1274, 1304, 1300, 1334, 1332, 1250, 1249,
108666
+ /* 260 */ 1326, 1325, 1324, 1322, 1321, 1319, 1315, 1284, 1297, 1292,
108667
+ /* 270 */ 1286, 1283, 1262, 1209, 1187, 1235, 1237, 1224, 1215, 1200,
108668
+ /* 280 */ 1192, 1189, 1156, 1154, 1152, 1136, 1150, 1118, 1169, 1146,
108669
+ /* 290 */ 1090, 1081, 1066, 1055, 1048, 1041, 1051, 1080, 1086, 1078,
108670
+ /* 300 */ 1079, 1077, 1074, 1069, 973, 971, 970, 1047, 1037, 1036,
108482108671
};
108483108672
static const YYACTIONTYPE yy_default[] = {
108484
- /* 0 */ 634, 868, 956, 956, 868, 868, 956, 956, 956, 758,
108485
- /* 10 */ 956, 956, 956, 866, 956, 956, 786, 786, 930, 956,
108486
- /* 20 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108487
- /* 30 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108488
- /* 40 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108489
- /* 50 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108490
- /* 60 */ 956, 956, 956, 956, 956, 956, 956, 673, 762, 792,
108491
- /* 70 */ 956, 956, 956, 956, 956, 956, 956, 956, 929, 931,
108492
- /* 80 */ 800, 799, 909, 773, 797, 790, 794, 869, 862, 863,
108493
- /* 90 */ 861, 865, 870, 956, 793, 829, 846, 828, 840, 845,
108494
- /* 100 */ 852, 844, 841, 831, 830, 665, 832, 833, 956, 956,
108495
- /* 110 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108496
- /* 120 */ 956, 956, 956, 956, 660, 727, 956, 956, 956, 956,
108497
- /* 130 */ 956, 956, 956, 956, 834, 835, 849, 848, 847, 956,
108498
- /* 140 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108499
- /* 150 */ 956, 936, 934, 956, 881, 956, 956, 956, 956, 956,
108500
- /* 160 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108501
- /* 170 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108502
- /* 180 */ 956, 640, 758, 758, 758, 634, 956, 956, 956, 948,
108503
- /* 190 */ 762, 752, 718, 956, 956, 956, 956, 956, 956, 956,
108504
- /* 200 */ 956, 956, 956, 956, 956, 802, 741, 919, 921, 956,
108505
- /* 210 */ 902, 739, 662, 760, 675, 750, 642, 796, 775, 775,
108506
- /* 220 */ 914, 796, 914, 699, 956, 786, 956, 786, 696, 786,
108507
- /* 230 */ 775, 864, 956, 956, 956, 759, 750, 956, 941, 766,
108508
- /* 240 */ 766, 933, 933, 766, 808, 731, 796, 738, 738, 738,
108509
- /* 250 */ 738, 766, 657, 796, 808, 731, 731, 766, 657, 908,
108510
- /* 260 */ 906, 766, 766, 657, 766, 657, 766, 657, 874, 729,
108511
- /* 270 */ 729, 729, 714, 878, 878, 874, 729, 699, 729, 714,
108512
- /* 280 */ 729, 729, 779, 774, 779, 774, 779, 774, 766, 766,
108513
- /* 290 */ 956, 791, 780, 789, 787, 796, 956, 717, 650, 650,
108514
- /* 300 */ 639, 639, 639, 639, 953, 953, 948, 701, 701, 683,
108515
- /* 310 */ 956, 956, 956, 956, 956, 956, 956, 883, 956, 956,
108516
- /* 320 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108517
- /* 330 */ 635, 943, 956, 956, 940, 956, 956, 956, 956, 801,
108518
- /* 340 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108519
- /* 350 */ 918, 956, 956, 956, 956, 956, 956, 956, 912, 956,
108520
- /* 360 */ 956, 956, 956, 956, 956, 905, 904, 956, 956, 956,
108521
- /* 370 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108522
- /* 380 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108523
- /* 390 */ 956, 956, 956, 788, 956, 781, 956, 867, 956, 956,
108524
- /* 400 */ 956, 956, 956, 956, 956, 956, 956, 956, 744, 817,
108525
- /* 410 */ 956, 816, 820, 815, 667, 956, 648, 956, 631, 636,
108526
- /* 420 */ 952, 955, 954, 951, 950, 949, 944, 942, 939, 938,
108527
- /* 430 */ 937, 935, 932, 928, 887, 885, 892, 891, 890, 889,
108528
- /* 440 */ 888, 886, 884, 882, 803, 798, 795, 927, 880, 740,
108529
- /* 450 */ 737, 736, 656, 945, 911, 920, 807, 806, 809, 917,
108530
- /* 460 */ 916, 915, 913, 910, 897, 805, 804, 732, 872, 871,
108531
- /* 470 */ 659, 901, 900, 899, 903, 907, 898, 768, 658, 655,
108532
- /* 480 */ 664, 721, 720, 728, 726, 725, 724, 723, 722, 719,
108533
- /* 490 */ 666, 674, 685, 713, 698, 697, 877, 879, 876, 875,
108534
- /* 500 */ 706, 705, 711, 710, 709, 708, 707, 704, 703, 702,
108535
- /* 510 */ 695, 694, 700, 693, 716, 715, 712, 692, 735, 734,
108536
- /* 520 */ 733, 730, 691, 690, 689, 820, 688, 687, 826, 825,
108537
- /* 530 */ 813, 856, 755, 754, 753, 765, 764, 777, 776, 811,
108538
- /* 540 */ 810, 778, 763, 757, 756, 772, 771, 770, 769, 761,
108539
- /* 550 */ 751, 783, 785, 784, 782, 858, 767, 855, 926, 925,
108540
- /* 560 */ 924, 923, 922, 860, 859, 827, 824, 678, 679, 895,
108541
- /* 570 */ 894, 896, 893, 681, 680, 677, 676, 857, 746, 745,
108542
- /* 580 */ 853, 850, 842, 838, 854, 851, 843, 839, 837, 836,
108543
- /* 590 */ 822, 821, 819, 818, 814, 823, 669, 747, 743, 742,
108544
- /* 600 */ 812, 749, 748, 686, 684, 682, 663, 661, 654, 652,
108545
- /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
108546
- /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
108673
+ /* 0 */ 632, 864, 952, 952, 864, 864, 952, 952, 683, 754,
108674
+ /* 10 */ 952, 952, 952, 862, 952, 952, 782, 782, 926, 952,
108675
+ /* 20 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108676
+ /* 30 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108677
+ /* 40 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108678
+ /* 50 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108679
+ /* 60 */ 952, 952, 952, 952, 952, 952, 952, 671, 758, 788,
108680
+ /* 70 */ 952, 952, 952, 952, 952, 952, 952, 952, 925, 927,
108681
+ /* 80 */ 796, 795, 905, 769, 793, 786, 790, 865, 858, 859,
108682
+ /* 90 */ 857, 861, 866, 952, 789, 825, 842, 824, 836, 841,
108683
+ /* 100 */ 848, 840, 837, 827, 826, 828, 829, 952, 952, 952,
108684
+ /* 110 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108685
+ /* 120 */ 952, 952, 952, 658, 723, 952, 952, 952, 952, 952,
108686
+ /* 130 */ 952, 952, 952, 830, 831, 845, 844, 843, 952, 952,
108687
+ /* 140 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108688
+ /* 150 */ 932, 930, 952, 877, 952, 952, 952, 952, 952, 952,
108689
+ /* 160 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108690
+ /* 170 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 638,
108691
+ /* 180 */ 754, 754, 754, 632, 952, 952, 952, 944, 758, 748,
108692
+ /* 190 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108693
+ /* 200 */ 952, 952, 952, 683, 798, 737, 915, 917, 952, 898,
108694
+ /* 210 */ 735, 660, 756, 673, 746, 640, 792, 771, 771, 910,
108695
+ /* 220 */ 792, 910, 697, 952, 782, 952, 782, 694, 782, 771,
108696
+ /* 230 */ 860, 952, 952, 952, 755, 746, 952, 937, 762, 762,
108697
+ /* 240 */ 929, 929, 762, 804, 727, 792, 734, 734, 734, 734,
108698
+ /* 250 */ 762, 655, 792, 804, 727, 727, 762, 655, 904, 902,
108699
+ /* 260 */ 762, 762, 655, 762, 655, 762, 655, 870, 725, 725,
108700
+ /* 270 */ 725, 683, 712, 874, 874, 870, 725, 697, 725, 712,
108701
+ /* 280 */ 725, 725, 775, 770, 775, 770, 775, 770, 762, 762,
108702
+ /* 290 */ 952, 787, 776, 785, 783, 792, 952, 715, 648, 648,
108703
+ /* 300 */ 637, 637, 637, 637, 949, 949, 944, 699, 699, 681,
108704
+ /* 310 */ 952, 952, 952, 952, 952, 952, 952, 879, 952, 952,
108705
+ /* 320 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108706
+ /* 330 */ 633, 939, 952, 952, 936, 952, 952, 952, 952, 797,
108707
+ /* 340 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108708
+ /* 350 */ 914, 952, 952, 952, 952, 952, 952, 952, 908, 952,
108709
+ /* 360 */ 952, 952, 952, 952, 952, 901, 900, 952, 952, 952,
108710
+ /* 370 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108711
+ /* 380 */ 952, 952, 716, 952, 952, 952, 952, 952, 952, 952,
108712
+ /* 390 */ 952, 952, 952, 952, 784, 952, 777, 952, 863, 952,
108713
+ /* 400 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 740,
108714
+ /* 410 */ 813, 952, 812, 816, 811, 665, 952, 646, 952, 629,
108715
+ /* 420 */ 634, 948, 951, 950, 947, 946, 945, 940, 938, 935,
108716
+ /* 430 */ 934, 933, 931, 928, 924, 883, 881, 888, 887, 886,
108717
+ /* 440 */ 885, 884, 882, 880, 878, 799, 794, 791, 923, 876,
108718
+ /* 450 */ 736, 733, 732, 654, 941, 907, 916, 803, 802, 805,
108719
+ /* 460 */ 913, 912, 911, 909, 906, 893, 801, 800, 728, 868,
108720
+ /* 470 */ 867, 657, 897, 896, 895, 899, 903, 894, 764, 656,
108721
+ /* 480 */ 653, 662, 718, 724, 722, 721, 720, 719, 717, 664,
108722
+ /* 490 */ 672, 682, 711, 696, 695, 873, 875, 872, 871, 704,
108723
+ /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
108724
+ /* 510 */ 692, 698, 691, 714, 713, 710, 690, 731, 730, 729,
108725
+ /* 520 */ 726, 689, 688, 687, 816, 686, 685, 822, 821, 809,
108726
+ /* 530 */ 852, 751, 750, 749, 761, 760, 773, 772, 807, 806,
108727
+ /* 540 */ 774, 759, 753, 752, 768, 767, 766, 765, 757, 747,
108728
+ /* 550 */ 779, 781, 780, 778, 854, 763, 851, 922, 921, 920,
108729
+ /* 560 */ 919, 918, 856, 855, 823, 820, 676, 677, 891, 890,
108730
+ /* 570 */ 892, 889, 679, 678, 675, 674, 853, 742, 741, 849,
108731
+ /* 580 */ 846, 838, 834, 850, 847, 839, 835, 833, 832, 818,
108732
+ /* 590 */ 817, 815, 814, 810, 819, 667, 743, 739, 738, 808,
108733
+ /* 600 */ 745, 744, 684, 680, 661, 659, 652, 650, 649, 651,
108734
+ /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
108735
+ /* 620 */ 665, 639, 636, 635, 631, 630, 628,
108547108736
};
108548108737
108549108738
/* The next table maps tokens into fallback tokens. If a construct
108550108739
** like the following:
108551108740
**
@@ -108744,11 +108933,11 @@
108744108933
"create_table", "create_table_args", "createkw", "temp",
108745108934
"ifnotexists", "dbnm", "columnlist", "conslist_opt",
108746108935
"select", "column", "columnid", "type",
108747108936
"carglist", "id", "ids", "typetoken",
108748108937
"typename", "signed", "plus_num", "minus_num",
108749
- "carg", "ccons", "term", "expr",
108938
+ "cname", "ccons", "term", "expr",
108750108939
"onconf", "sortorder", "autoinc", "idxlist_opt",
108751108940
"refargs", "defer_subclause", "refarg", "refact",
108752108941
"init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108753108942
"defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108754108943
"ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
108824109013
/* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
108825109014
/* 49 */ "typename ::= ids",
108826109015
/* 50 */ "typename ::= typename ids",
108827109016
/* 51 */ "signed ::= plus_num",
108828109017
/* 52 */ "signed ::= minus_num",
108829
- /* 53 */ "carglist ::= carglist carg",
109018
+ /* 53 */ "carglist ::= carglist cname ccons",
108830109019
/* 54 */ "carglist ::=",
108831
- /* 55 */ "carg ::= CONSTRAINT nm ccons",
108832
- /* 56 */ "carg ::= ccons",
109020
+ /* 55 */ "cname ::= CONSTRAINT nm",
109021
+ /* 56 */ "cname ::=",
108833109022
/* 57 */ "ccons ::= DEFAULT term",
108834109023
/* 58 */ "ccons ::= DEFAULT LP expr RP",
108835109024
/* 59 */ "ccons ::= DEFAULT PLUS term",
108836109025
/* 60 */ "ccons ::= DEFAULT MINUS term",
108837109026
/* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
108861109050
/* 85 */ "init_deferred_pred_opt ::=",
108862109051
/* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
108863109052
/* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
108864109053
/* 88 */ "conslist_opt ::=",
108865109054
/* 89 */ "conslist_opt ::= COMMA conslist",
108866
- /* 90 */ "conslist ::= conslist COMMA tcons",
108867
- /* 91 */ "conslist ::= conslist tcons",
108868
- /* 92 */ "conslist ::= tcons",
108869
- /* 93 */ "tcons ::= CONSTRAINT nm",
108870
- /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
108871
- /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
108872
- /* 96 */ "tcons ::= CHECK LP expr RP onconf",
108873
- /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
108874
- /* 98 */ "defer_subclause_opt ::=",
108875
- /* 99 */ "defer_subclause_opt ::= defer_subclause",
108876
- /* 100 */ "onconf ::=",
108877
- /* 101 */ "onconf ::= ON CONFLICT resolvetype",
108878
- /* 102 */ "orconf ::=",
108879
- /* 103 */ "orconf ::= OR resolvetype",
108880
- /* 104 */ "resolvetype ::= raisetype",
108881
- /* 105 */ "resolvetype ::= IGNORE",
108882
- /* 106 */ "resolvetype ::= REPLACE",
108883
- /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
108884
- /* 108 */ "ifexists ::= IF EXISTS",
108885
- /* 109 */ "ifexists ::=",
108886
- /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
108887
- /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
108888
- /* 112 */ "cmd ::= select",
108889
- /* 113 */ "select ::= oneselect",
108890
- /* 114 */ "select ::= select multiselect_op oneselect",
108891
- /* 115 */ "multiselect_op ::= UNION",
108892
- /* 116 */ "multiselect_op ::= UNION ALL",
108893
- /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
108894
- /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
108895
- /* 119 */ "distinct ::= DISTINCT",
108896
- /* 120 */ "distinct ::= ALL",
108897
- /* 121 */ "distinct ::=",
108898
- /* 122 */ "sclp ::= selcollist COMMA",
108899
- /* 123 */ "sclp ::=",
108900
- /* 124 */ "selcollist ::= sclp expr as",
108901
- /* 125 */ "selcollist ::= sclp STAR",
108902
- /* 126 */ "selcollist ::= sclp nm DOT STAR",
108903
- /* 127 */ "as ::= AS nm",
108904
- /* 128 */ "as ::= ids",
108905
- /* 129 */ "as ::=",
108906
- /* 130 */ "from ::=",
108907
- /* 131 */ "from ::= FROM seltablist",
108908
- /* 132 */ "stl_prefix ::= seltablist joinop",
108909
- /* 133 */ "stl_prefix ::=",
108910
- /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
108911
- /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
108912
- /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
108913
- /* 137 */ "dbnm ::=",
108914
- /* 138 */ "dbnm ::= DOT nm",
108915
- /* 139 */ "fullname ::= nm dbnm",
108916
- /* 140 */ "joinop ::= COMMA|JOIN",
108917
- /* 141 */ "joinop ::= JOIN_KW JOIN",
108918
- /* 142 */ "joinop ::= JOIN_KW nm JOIN",
108919
- /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
108920
- /* 144 */ "on_opt ::= ON expr",
108921
- /* 145 */ "on_opt ::=",
108922
- /* 146 */ "indexed_opt ::=",
108923
- /* 147 */ "indexed_opt ::= INDEXED BY nm",
108924
- /* 148 */ "indexed_opt ::= NOT INDEXED",
108925
- /* 149 */ "using_opt ::= USING LP inscollist RP",
108926
- /* 150 */ "using_opt ::=",
108927
- /* 151 */ "orderby_opt ::=",
108928
- /* 152 */ "orderby_opt ::= ORDER BY sortlist",
108929
- /* 153 */ "sortlist ::= sortlist COMMA expr sortorder",
108930
- /* 154 */ "sortlist ::= expr sortorder",
108931
- /* 155 */ "sortorder ::= ASC",
108932
- /* 156 */ "sortorder ::= DESC",
108933
- /* 157 */ "sortorder ::=",
108934
- /* 158 */ "groupby_opt ::=",
108935
- /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
108936
- /* 160 */ "having_opt ::=",
108937
- /* 161 */ "having_opt ::= HAVING expr",
108938
- /* 162 */ "limit_opt ::=",
108939
- /* 163 */ "limit_opt ::= LIMIT expr",
108940
- /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
108941
- /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
108942
- /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
108943
- /* 167 */ "where_opt ::=",
108944
- /* 168 */ "where_opt ::= WHERE expr",
108945
- /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
108946
- /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
108947
- /* 171 */ "setlist ::= nm EQ expr",
108948
- /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
108949
- /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
108950
- /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
108951
- /* 175 */ "insert_cmd ::= INSERT orconf",
108952
- /* 176 */ "insert_cmd ::= REPLACE",
108953
- /* 177 */ "valuelist ::= VALUES LP nexprlist RP",
108954
- /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP",
108955
- /* 179 */ "inscollist_opt ::=",
108956
- /* 180 */ "inscollist_opt ::= LP inscollist RP",
108957
- /* 181 */ "inscollist ::= inscollist COMMA nm",
108958
- /* 182 */ "inscollist ::= nm",
108959
- /* 183 */ "expr ::= term",
108960
- /* 184 */ "expr ::= LP expr RP",
108961
- /* 185 */ "term ::= NULL",
108962
- /* 186 */ "expr ::= id",
108963
- /* 187 */ "expr ::= JOIN_KW",
108964
- /* 188 */ "expr ::= nm DOT nm",
108965
- /* 189 */ "expr ::= nm DOT nm DOT nm",
108966
- /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
108967
- /* 191 */ "term ::= STRING",
108968
- /* 192 */ "expr ::= REGISTER",
108969
- /* 193 */ "expr ::= VARIABLE",
108970
- /* 194 */ "expr ::= expr COLLATE ids",
108971
- /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
108972
- /* 196 */ "expr ::= ID LP distinct exprlist RP",
108973
- /* 197 */ "expr ::= ID LP STAR RP",
108974
- /* 198 */ "term ::= CTIME_KW",
108975
- /* 199 */ "expr ::= expr AND expr",
108976
- /* 200 */ "expr ::= expr OR expr",
108977
- /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
108978
- /* 202 */ "expr ::= expr EQ|NE expr",
108979
- /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
108980
- /* 204 */ "expr ::= expr PLUS|MINUS expr",
108981
- /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
108982
- /* 206 */ "expr ::= expr CONCAT expr",
108983
- /* 207 */ "likeop ::= LIKE_KW",
108984
- /* 208 */ "likeop ::= NOT LIKE_KW",
108985
- /* 209 */ "likeop ::= MATCH",
108986
- /* 210 */ "likeop ::= NOT MATCH",
108987
- /* 211 */ "expr ::= expr likeop expr",
108988
- /* 212 */ "expr ::= expr likeop expr ESCAPE expr",
108989
- /* 213 */ "expr ::= expr ISNULL|NOTNULL",
108990
- /* 214 */ "expr ::= expr NOT NULL",
108991
- /* 215 */ "expr ::= expr IS expr",
108992
- /* 216 */ "expr ::= expr IS NOT expr",
108993
- /* 217 */ "expr ::= NOT expr",
108994
- /* 218 */ "expr ::= BITNOT expr",
108995
- /* 219 */ "expr ::= MINUS expr",
108996
- /* 220 */ "expr ::= PLUS expr",
108997
- /* 221 */ "between_op ::= BETWEEN",
108998
- /* 222 */ "between_op ::= NOT BETWEEN",
108999
- /* 223 */ "expr ::= expr between_op expr AND expr",
109000
- /* 224 */ "in_op ::= IN",
109001
- /* 225 */ "in_op ::= NOT IN",
109002
- /* 226 */ "expr ::= expr in_op LP exprlist RP",
109003
- /* 227 */ "expr ::= LP select RP",
109004
- /* 228 */ "expr ::= expr in_op LP select RP",
109005
- /* 229 */ "expr ::= expr in_op nm dbnm",
109006
- /* 230 */ "expr ::= EXISTS LP select RP",
109007
- /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END",
109008
- /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109009
- /* 233 */ "case_exprlist ::= WHEN expr THEN expr",
109010
- /* 234 */ "case_else ::= ELSE expr",
109011
- /* 235 */ "case_else ::=",
109012
- /* 236 */ "case_operand ::= expr",
109013
- /* 237 */ "case_operand ::=",
109014
- /* 238 */ "exprlist ::= nexprlist",
109015
- /* 239 */ "exprlist ::=",
109016
- /* 240 */ "nexprlist ::= nexprlist COMMA expr",
109017
- /* 241 */ "nexprlist ::= expr",
109018
- /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109019
- /* 243 */ "uniqueflag ::= UNIQUE",
109020
- /* 244 */ "uniqueflag ::=",
109021
- /* 245 */ "idxlist_opt ::=",
109022
- /* 246 */ "idxlist_opt ::= LP idxlist RP",
109023
- /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109024
- /* 248 */ "idxlist ::= nm collate sortorder",
109025
- /* 249 */ "collate ::=",
109026
- /* 250 */ "collate ::= COLLATE ids",
109027
- /* 251 */ "cmd ::= DROP INDEX ifexists fullname",
109028
- /* 252 */ "cmd ::= VACUUM",
109029
- /* 253 */ "cmd ::= VACUUM nm",
109030
- /* 254 */ "cmd ::= PRAGMA nm dbnm",
109031
- /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109032
- /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109033
- /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109034
- /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109035
- /* 259 */ "nmnum ::= plus_num",
109036
- /* 260 */ "nmnum ::= nm",
109037
- /* 261 */ "nmnum ::= ON",
109038
- /* 262 */ "nmnum ::= DELETE",
109039
- /* 263 */ "nmnum ::= DEFAULT",
109040
- /* 264 */ "plus_num ::= PLUS number",
109041
- /* 265 */ "plus_num ::= number",
109042
- /* 266 */ "minus_num ::= MINUS number",
109043
- /* 267 */ "number ::= INTEGER|FLOAT",
109044
- /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109045
- /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109046
- /* 270 */ "trigger_time ::= BEFORE",
109047
- /* 271 */ "trigger_time ::= AFTER",
109048
- /* 272 */ "trigger_time ::= INSTEAD OF",
109049
- /* 273 */ "trigger_time ::=",
109050
- /* 274 */ "trigger_event ::= DELETE|INSERT",
109051
- /* 275 */ "trigger_event ::= UPDATE",
109052
- /* 276 */ "trigger_event ::= UPDATE OF inscollist",
109053
- /* 277 */ "foreach_clause ::=",
109054
- /* 278 */ "foreach_clause ::= FOR EACH ROW",
109055
- /* 279 */ "when_clause ::=",
109056
- /* 280 */ "when_clause ::= WHEN expr",
109057
- /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109058
- /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109059
- /* 283 */ "trnm ::= nm",
109060
- /* 284 */ "trnm ::= nm DOT nm",
109061
- /* 285 */ "tridxby ::=",
109062
- /* 286 */ "tridxby ::= INDEXED BY nm",
109063
- /* 287 */ "tridxby ::= NOT INDEXED",
109064
- /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109065
- /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109066
- /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109067
- /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109068
- /* 292 */ "trigger_cmd ::= select",
109069
- /* 293 */ "expr ::= RAISE LP IGNORE RP",
109070
- /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109071
- /* 295 */ "raisetype ::= ROLLBACK",
109072
- /* 296 */ "raisetype ::= ABORT",
109073
- /* 297 */ "raisetype ::= FAIL",
109074
- /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname",
109075
- /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109076
- /* 300 */ "cmd ::= DETACH database_kw_opt expr",
109077
- /* 301 */ "key_opt ::=",
109078
- /* 302 */ "key_opt ::= KEY expr",
109079
- /* 303 */ "database_kw_opt ::= DATABASE",
109080
- /* 304 */ "database_kw_opt ::=",
109081
- /* 305 */ "cmd ::= REINDEX",
109082
- /* 306 */ "cmd ::= REINDEX nm dbnm",
109083
- /* 307 */ "cmd ::= ANALYZE",
109084
- /* 308 */ "cmd ::= ANALYZE nm dbnm",
109085
- /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109086
- /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109087
- /* 311 */ "add_column_fullname ::= fullname",
109088
- /* 312 */ "kwcolumn_opt ::=",
109089
- /* 313 */ "kwcolumn_opt ::= COLUMNKW",
109090
- /* 314 */ "cmd ::= create_vtab",
109091
- /* 315 */ "cmd ::= create_vtab LP vtabarglist RP",
109092
- /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109093
- /* 317 */ "vtabarglist ::= vtabarg",
109094
- /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109095
- /* 319 */ "vtabarg ::=",
109096
- /* 320 */ "vtabarg ::= vtabarg vtabargtoken",
109097
- /* 321 */ "vtabargtoken ::= ANY",
109098
- /* 322 */ "vtabargtoken ::= lp anylist RP",
109099
- /* 323 */ "lp ::= LP",
109100
- /* 324 */ "anylist ::=",
109101
- /* 325 */ "anylist ::= anylist LP anylist RP",
109102
- /* 326 */ "anylist ::= anylist ANY",
109055
+ /* 90 */ "conslist ::= conslist COMMA cname tcons",
109056
+ /* 91 */ "conslist ::= cname tcons",
109057
+ /* 92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
109058
+ /* 93 */ "tcons ::= UNIQUE LP idxlist RP onconf",
109059
+ /* 94 */ "tcons ::= CHECK LP expr RP onconf",
109060
+ /* 95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
109061
+ /* 96 */ "defer_subclause_opt ::=",
109062
+ /* 97 */ "defer_subclause_opt ::= defer_subclause",
109063
+ /* 98 */ "onconf ::=",
109064
+ /* 99 */ "onconf ::= ON CONFLICT resolvetype",
109065
+ /* 100 */ "orconf ::=",
109066
+ /* 101 */ "orconf ::= OR resolvetype",
109067
+ /* 102 */ "resolvetype ::= raisetype",
109068
+ /* 103 */ "resolvetype ::= IGNORE",
109069
+ /* 104 */ "resolvetype ::= REPLACE",
109070
+ /* 105 */ "cmd ::= DROP TABLE ifexists fullname",
109071
+ /* 106 */ "ifexists ::= IF EXISTS",
109072
+ /* 107 */ "ifexists ::=",
109073
+ /* 108 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
109074
+ /* 109 */ "cmd ::= DROP VIEW ifexists fullname",
109075
+ /* 110 */ "cmd ::= select",
109076
+ /* 111 */ "select ::= oneselect",
109077
+ /* 112 */ "select ::= select multiselect_op oneselect",
109078
+ /* 113 */ "multiselect_op ::= UNION",
109079
+ /* 114 */ "multiselect_op ::= UNION ALL",
109080
+ /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT",
109081
+ /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
109082
+ /* 117 */ "distinct ::= DISTINCT",
109083
+ /* 118 */ "distinct ::= ALL",
109084
+ /* 119 */ "distinct ::=",
109085
+ /* 120 */ "sclp ::= selcollist COMMA",
109086
+ /* 121 */ "sclp ::=",
109087
+ /* 122 */ "selcollist ::= sclp expr as",
109088
+ /* 123 */ "selcollist ::= sclp STAR",
109089
+ /* 124 */ "selcollist ::= sclp nm DOT STAR",
109090
+ /* 125 */ "as ::= AS nm",
109091
+ /* 126 */ "as ::= ids",
109092
+ /* 127 */ "as ::=",
109093
+ /* 128 */ "from ::=",
109094
+ /* 129 */ "from ::= FROM seltablist",
109095
+ /* 130 */ "stl_prefix ::= seltablist joinop",
109096
+ /* 131 */ "stl_prefix ::=",
109097
+ /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
109098
+ /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
109099
+ /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
109100
+ /* 135 */ "dbnm ::=",
109101
+ /* 136 */ "dbnm ::= DOT nm",
109102
+ /* 137 */ "fullname ::= nm dbnm",
109103
+ /* 138 */ "joinop ::= COMMA|JOIN",
109104
+ /* 139 */ "joinop ::= JOIN_KW JOIN",
109105
+ /* 140 */ "joinop ::= JOIN_KW nm JOIN",
109106
+ /* 141 */ "joinop ::= JOIN_KW nm nm JOIN",
109107
+ /* 142 */ "on_opt ::= ON expr",
109108
+ /* 143 */ "on_opt ::=",
109109
+ /* 144 */ "indexed_opt ::=",
109110
+ /* 145 */ "indexed_opt ::= INDEXED BY nm",
109111
+ /* 146 */ "indexed_opt ::= NOT INDEXED",
109112
+ /* 147 */ "using_opt ::= USING LP inscollist RP",
109113
+ /* 148 */ "using_opt ::=",
109114
+ /* 149 */ "orderby_opt ::=",
109115
+ /* 150 */ "orderby_opt ::= ORDER BY sortlist",
109116
+ /* 151 */ "sortlist ::= sortlist COMMA expr sortorder",
109117
+ /* 152 */ "sortlist ::= expr sortorder",
109118
+ /* 153 */ "sortorder ::= ASC",
109119
+ /* 154 */ "sortorder ::= DESC",
109120
+ /* 155 */ "sortorder ::=",
109121
+ /* 156 */ "groupby_opt ::=",
109122
+ /* 157 */ "groupby_opt ::= GROUP BY nexprlist",
109123
+ /* 158 */ "having_opt ::=",
109124
+ /* 159 */ "having_opt ::= HAVING expr",
109125
+ /* 160 */ "limit_opt ::=",
109126
+ /* 161 */ "limit_opt ::= LIMIT expr",
109127
+ /* 162 */ "limit_opt ::= LIMIT expr OFFSET expr",
109128
+ /* 163 */ "limit_opt ::= LIMIT expr COMMA expr",
109129
+ /* 164 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
109130
+ /* 165 */ "where_opt ::=",
109131
+ /* 166 */ "where_opt ::= WHERE expr",
109132
+ /* 167 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
109133
+ /* 168 */ "setlist ::= setlist COMMA nm EQ expr",
109134
+ /* 169 */ "setlist ::= nm EQ expr",
109135
+ /* 170 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
109136
+ /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
109137
+ /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
109138
+ /* 173 */ "insert_cmd ::= INSERT orconf",
109139
+ /* 174 */ "insert_cmd ::= REPLACE",
109140
+ /* 175 */ "valuelist ::= VALUES LP nexprlist RP",
109141
+ /* 176 */ "valuelist ::= valuelist COMMA LP exprlist RP",
109142
+ /* 177 */ "inscollist_opt ::=",
109143
+ /* 178 */ "inscollist_opt ::= LP inscollist RP",
109144
+ /* 179 */ "inscollist ::= inscollist COMMA nm",
109145
+ /* 180 */ "inscollist ::= nm",
109146
+ /* 181 */ "expr ::= term",
109147
+ /* 182 */ "expr ::= LP expr RP",
109148
+ /* 183 */ "term ::= NULL",
109149
+ /* 184 */ "expr ::= id",
109150
+ /* 185 */ "expr ::= JOIN_KW",
109151
+ /* 186 */ "expr ::= nm DOT nm",
109152
+ /* 187 */ "expr ::= nm DOT nm DOT nm",
109153
+ /* 188 */ "term ::= INTEGER|FLOAT|BLOB",
109154
+ /* 189 */ "term ::= STRING",
109155
+ /* 190 */ "expr ::= REGISTER",
109156
+ /* 191 */ "expr ::= VARIABLE",
109157
+ /* 192 */ "expr ::= expr COLLATE ids",
109158
+ /* 193 */ "expr ::= CAST LP expr AS typetoken RP",
109159
+ /* 194 */ "expr ::= ID LP distinct exprlist RP",
109160
+ /* 195 */ "expr ::= ID LP STAR RP",
109161
+ /* 196 */ "term ::= CTIME_KW",
109162
+ /* 197 */ "expr ::= expr AND expr",
109163
+ /* 198 */ "expr ::= expr OR expr",
109164
+ /* 199 */ "expr ::= expr LT|GT|GE|LE expr",
109165
+ /* 200 */ "expr ::= expr EQ|NE expr",
109166
+ /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
109167
+ /* 202 */ "expr ::= expr PLUS|MINUS expr",
109168
+ /* 203 */ "expr ::= expr STAR|SLASH|REM expr",
109169
+ /* 204 */ "expr ::= expr CONCAT expr",
109170
+ /* 205 */ "likeop ::= LIKE_KW",
109171
+ /* 206 */ "likeop ::= NOT LIKE_KW",
109172
+ /* 207 */ "likeop ::= MATCH",
109173
+ /* 208 */ "likeop ::= NOT MATCH",
109174
+ /* 209 */ "expr ::= expr likeop expr",
109175
+ /* 210 */ "expr ::= expr likeop expr ESCAPE expr",
109176
+ /* 211 */ "expr ::= expr ISNULL|NOTNULL",
109177
+ /* 212 */ "expr ::= expr NOT NULL",
109178
+ /* 213 */ "expr ::= expr IS expr",
109179
+ /* 214 */ "expr ::= expr IS NOT expr",
109180
+ /* 215 */ "expr ::= NOT expr",
109181
+ /* 216 */ "expr ::= BITNOT expr",
109182
+ /* 217 */ "expr ::= MINUS expr",
109183
+ /* 218 */ "expr ::= PLUS expr",
109184
+ /* 219 */ "between_op ::= BETWEEN",
109185
+ /* 220 */ "between_op ::= NOT BETWEEN",
109186
+ /* 221 */ "expr ::= expr between_op expr AND expr",
109187
+ /* 222 */ "in_op ::= IN",
109188
+ /* 223 */ "in_op ::= NOT IN",
109189
+ /* 224 */ "expr ::= expr in_op LP exprlist RP",
109190
+ /* 225 */ "expr ::= LP select RP",
109191
+ /* 226 */ "expr ::= expr in_op LP select RP",
109192
+ /* 227 */ "expr ::= expr in_op nm dbnm",
109193
+ /* 228 */ "expr ::= EXISTS LP select RP",
109194
+ /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END",
109195
+ /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109196
+ /* 231 */ "case_exprlist ::= WHEN expr THEN expr",
109197
+ /* 232 */ "case_else ::= ELSE expr",
109198
+ /* 233 */ "case_else ::=",
109199
+ /* 234 */ "case_operand ::= expr",
109200
+ /* 235 */ "case_operand ::=",
109201
+ /* 236 */ "exprlist ::= nexprlist",
109202
+ /* 237 */ "exprlist ::=",
109203
+ /* 238 */ "nexprlist ::= nexprlist COMMA expr",
109204
+ /* 239 */ "nexprlist ::= expr",
109205
+ /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109206
+ /* 241 */ "uniqueflag ::= UNIQUE",
109207
+ /* 242 */ "uniqueflag ::=",
109208
+ /* 243 */ "idxlist_opt ::=",
109209
+ /* 244 */ "idxlist_opt ::= LP idxlist RP",
109210
+ /* 245 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109211
+ /* 246 */ "idxlist ::= nm collate sortorder",
109212
+ /* 247 */ "collate ::=",
109213
+ /* 248 */ "collate ::= COLLATE ids",
109214
+ /* 249 */ "cmd ::= DROP INDEX ifexists fullname",
109215
+ /* 250 */ "cmd ::= VACUUM",
109216
+ /* 251 */ "cmd ::= VACUUM nm",
109217
+ /* 252 */ "cmd ::= PRAGMA nm dbnm",
109218
+ /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109219
+ /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109220
+ /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109221
+ /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109222
+ /* 257 */ "nmnum ::= plus_num",
109223
+ /* 258 */ "nmnum ::= nm",
109224
+ /* 259 */ "nmnum ::= ON",
109225
+ /* 260 */ "nmnum ::= DELETE",
109226
+ /* 261 */ "nmnum ::= DEFAULT",
109227
+ /* 262 */ "plus_num ::= PLUS number",
109228
+ /* 263 */ "plus_num ::= number",
109229
+ /* 264 */ "minus_num ::= MINUS number",
109230
+ /* 265 */ "number ::= INTEGER|FLOAT",
109231
+ /* 266 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109232
+ /* 267 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109233
+ /* 268 */ "trigger_time ::= BEFORE",
109234
+ /* 269 */ "trigger_time ::= AFTER",
109235
+ /* 270 */ "trigger_time ::= INSTEAD OF",
109236
+ /* 271 */ "trigger_time ::=",
109237
+ /* 272 */ "trigger_event ::= DELETE|INSERT",
109238
+ /* 273 */ "trigger_event ::= UPDATE",
109239
+ /* 274 */ "trigger_event ::= UPDATE OF inscollist",
109240
+ /* 275 */ "foreach_clause ::=",
109241
+ /* 276 */ "foreach_clause ::= FOR EACH ROW",
109242
+ /* 277 */ "when_clause ::=",
109243
+ /* 278 */ "when_clause ::= WHEN expr",
109244
+ /* 279 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109245
+ /* 280 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109246
+ /* 281 */ "trnm ::= nm",
109247
+ /* 282 */ "trnm ::= nm DOT nm",
109248
+ /* 283 */ "tridxby ::=",
109249
+ /* 284 */ "tridxby ::= INDEXED BY nm",
109250
+ /* 285 */ "tridxby ::= NOT INDEXED",
109251
+ /* 286 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109252
+ /* 287 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109253
+ /* 288 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109254
+ /* 289 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109255
+ /* 290 */ "trigger_cmd ::= select",
109256
+ /* 291 */ "expr ::= RAISE LP IGNORE RP",
109257
+ /* 292 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109258
+ /* 293 */ "raisetype ::= ROLLBACK",
109259
+ /* 294 */ "raisetype ::= ABORT",
109260
+ /* 295 */ "raisetype ::= FAIL",
109261
+ /* 296 */ "cmd ::= DROP TRIGGER ifexists fullname",
109262
+ /* 297 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109263
+ /* 298 */ "cmd ::= DETACH database_kw_opt expr",
109264
+ /* 299 */ "key_opt ::=",
109265
+ /* 300 */ "key_opt ::= KEY expr",
109266
+ /* 301 */ "database_kw_opt ::= DATABASE",
109267
+ /* 302 */ "database_kw_opt ::=",
109268
+ /* 303 */ "cmd ::= REINDEX",
109269
+ /* 304 */ "cmd ::= REINDEX nm dbnm",
109270
+ /* 305 */ "cmd ::= ANALYZE",
109271
+ /* 306 */ "cmd ::= ANALYZE nm dbnm",
109272
+ /* 307 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109273
+ /* 308 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109274
+ /* 309 */ "add_column_fullname ::= fullname",
109275
+ /* 310 */ "kwcolumn_opt ::=",
109276
+ /* 311 */ "kwcolumn_opt ::= COLUMNKW",
109277
+ /* 312 */ "cmd ::= create_vtab",
109278
+ /* 313 */ "cmd ::= create_vtab LP vtabarglist RP",
109279
+ /* 314 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109280
+ /* 315 */ "vtabarglist ::= vtabarg",
109281
+ /* 316 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109282
+ /* 317 */ "vtabarg ::=",
109283
+ /* 318 */ "vtabarg ::= vtabarg vtabargtoken",
109284
+ /* 319 */ "vtabargtoken ::= ANY",
109285
+ /* 320 */ "vtabargtoken ::= lp anylist RP",
109286
+ /* 321 */ "lp ::= LP",
109287
+ /* 322 */ "anylist ::=",
109288
+ /* 323 */ "anylist ::= anylist LP anylist RP",
109289
+ /* 324 */ "anylist ::= anylist ANY",
109103109290
};
109104109291
#endif /* NDEBUG */
109105109292
109106109293
109107109294
#if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109543109730
{ 167, 6 },
109544109731
{ 168, 1 },
109545109732
{ 168, 2 },
109546109733
{ 169, 1 },
109547109734
{ 169, 1 },
109548
- { 164, 2 },
109735
+ { 164, 3 },
109549109736
{ 164, 0 },
109550
- { 172, 3 },
109551
- { 172, 1 },
109737
+ { 172, 2 },
109738
+ { 172, 0 },
109552109739
{ 173, 2 },
109553109740
{ 173, 4 },
109554109741
{ 173, 3 },
109555109742
{ 173, 3 },
109556109743
{ 173, 2 },
@@ -109580,14 +109767,12 @@
109580109767
{ 184, 0 },
109581109768
{ 184, 2 },
109582109769
{ 184, 2 },
109583109770
{ 159, 0 },
109584109771
{ 159, 2 },
109585
- { 185, 3 },
109772
+ { 185, 4 },
109586109773
{ 185, 2 },
109587
- { 185, 1 },
109588
- { 186, 2 },
109589109774
{ 186, 7 },
109590109775
{ 186, 5 },
109591109776
{ 186, 5 },
109592109777
{ 186, 10 },
109593109778
{ 188, 0 },
@@ -109892,12 +110077,12 @@
109892110077
{yygotominor.yy392 = TK_DEFERRED;}
109893110078
break;
109894110079
case 14: /* transtype ::= DEFERRED */
109895110080
case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
109896110081
case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
109897
- case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
109898
- case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
110082
+ case 113: /* multiselect_op ::= UNION */ yytestcase(yyruleno==113);
110083
+ case 115: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==115);
109899110084
{yygotominor.yy392 = yymsp[0].major;}
109900110085
break;
109901110086
case 17: /* cmd ::= COMMIT trans_opt */
109902110087
case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
109903110088
{sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
109935110120
case 31: /* temp ::= */ yytestcase(yyruleno==31);
109936110121
case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
109937110122
case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
109938110123
case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
109939110124
case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
109940
- case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
109941
- case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
109942
- case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
109943
- case 121: /* distinct ::= */ yytestcase(yyruleno==121);
109944
- case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221);
109945
- case 224: /* in_op ::= IN */ yytestcase(yyruleno==224);
110125
+ case 96: /* defer_subclause_opt ::= */ yytestcase(yyruleno==96);
110126
+ case 107: /* ifexists ::= */ yytestcase(yyruleno==107);
110127
+ case 118: /* distinct ::= ALL */ yytestcase(yyruleno==118);
110128
+ case 119: /* distinct ::= */ yytestcase(yyruleno==119);
110129
+ case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219);
110130
+ case 222: /* in_op ::= IN */ yytestcase(yyruleno==222);
109946110131
{yygotominor.yy392 = 0;}
109947110132
break;
109948110133
case 29: /* ifnotexists ::= IF NOT EXISTS */
109949110134
case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
109950110135
case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
109951110136
case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
109952
- case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
109953
- case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
109954
- case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222);
109955
- case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225);
110137
+ case 106: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==106);
110138
+ case 117: /* distinct ::= DISTINCT */ yytestcase(yyruleno==117);
110139
+ case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220);
110140
+ case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223);
109956110141
{yygotominor.yy392 = 1;}
109957110142
break;
109958110143
case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
109959110144
{
109960110145
sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
109984110169
case 41: /* nm ::= id */ yytestcase(yyruleno==41);
109985110170
case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
109986110171
case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
109987110172
case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
109988110173
case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
109989
- case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
109990
- case 128: /* as ::= ids */ yytestcase(yyruleno==128);
109991
- case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
109992
- case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
109993
- case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250);
109994
- case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259);
109995
- case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260);
109996
- case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261);
109997
- case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262);
109998
- case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263);
109999
- case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264);
110000
- case 265: /* plus_num ::= number */ yytestcase(yyruleno==265);
110001
- case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
110002
- case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
110003
- case 283: /* trnm ::= nm */ yytestcase(yyruleno==283);
110174
+ case 125: /* as ::= AS nm */ yytestcase(yyruleno==125);
110175
+ case 126: /* as ::= ids */ yytestcase(yyruleno==126);
110176
+ case 136: /* dbnm ::= DOT nm */ yytestcase(yyruleno==136);
110177
+ case 145: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==145);
110178
+ case 248: /* collate ::= COLLATE ids */ yytestcase(yyruleno==248);
110179
+ case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257);
110180
+ case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258);
110181
+ case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259);
110182
+ case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260);
110183
+ case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261);
110184
+ case 262: /* plus_num ::= PLUS number */ yytestcase(yyruleno==262);
110185
+ case 263: /* plus_num ::= number */ yytestcase(yyruleno==263);
110186
+ case 264: /* minus_num ::= MINUS number */ yytestcase(yyruleno==264);
110187
+ case 265: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==265);
110188
+ case 281: /* trnm ::= nm */ yytestcase(yyruleno==281);
110004110189
{yygotominor.yy0 = yymsp[0].minor.yy0;}
110005110190
break;
110006110191
case 45: /* type ::= typetoken */
110007110192
{sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110008110193
break;
@@ -110018,10 +110203,16 @@
110018110203
yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110019110204
}
110020110205
break;
110021110206
case 50: /* typename ::= typename ids */
110022110207
{yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
110208
+ break;
110209
+ case 55: /* cname ::= CONSTRAINT nm */
110210
+{pParse->constraintName = yymsp[0].minor.yy0;}
110211
+ break;
110212
+ case 56: /* cname ::= */
110213
+{pParse->constraintName.n = 0;}
110023110214
break;
110024110215
case 57: /* ccons ::= DEFAULT term */
110025110216
case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110026110217
{sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110027110218
break;
@@ -110095,80 +110286,80 @@
110095110286
break;
110096110287
case 82: /* refact ::= NO ACTION */
110097110288
{ yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110098110289
break;
110099110290
case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110100
- case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
110101
- case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
110102
- case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
110291
+ case 97: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==97);
110292
+ case 99: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==99);
110293
+ case 102: /* resolvetype ::= raisetype */ yytestcase(yyruleno==102);
110103110294
{yygotominor.yy392 = yymsp[0].minor.yy392;}
110104110295
break;
110105110296
case 88: /* conslist_opt ::= */
110106110297
{yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110107110298
break;
110108110299
case 89: /* conslist_opt ::= COMMA conslist */
110109110300
{yygotominor.yy0 = yymsp[-1].minor.yy0;}
110110110301
break;
110111
- case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110302
+ case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110112110303
{sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110113110304
break;
110114
- case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
110305
+ case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */
110115110306
{sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110116110307
break;
110117
- case 96: /* tcons ::= CHECK LP expr RP onconf */
110308
+ case 94: /* tcons ::= CHECK LP expr RP onconf */
110118110309
{sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110119110310
break;
110120
- case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110311
+ case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110121110312
{
110122110313
sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110123110314
sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110124110315
}
110125110316
break;
110126
- case 100: /* onconf ::= */
110317
+ case 98: /* onconf ::= */
110127110318
{yygotominor.yy392 = OE_Default;}
110128110319
break;
110129
- case 102: /* orconf ::= */
110320
+ case 100: /* orconf ::= */
110130110321
{yygotominor.yy258 = OE_Default;}
110131110322
break;
110132
- case 103: /* orconf ::= OR resolvetype */
110323
+ case 101: /* orconf ::= OR resolvetype */
110133110324
{yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110134110325
break;
110135
- case 105: /* resolvetype ::= IGNORE */
110326
+ case 103: /* resolvetype ::= IGNORE */
110136110327
{yygotominor.yy392 = OE_Ignore;}
110137110328
break;
110138
- case 106: /* resolvetype ::= REPLACE */
110329
+ case 104: /* resolvetype ::= REPLACE */
110139110330
{yygotominor.yy392 = OE_Replace;}
110140110331
break;
110141
- case 107: /* cmd ::= DROP TABLE ifexists fullname */
110332
+ case 105: /* cmd ::= DROP TABLE ifexists fullname */
110142110333
{
110143110334
sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110144110335
}
110145110336
break;
110146
- case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110337
+ case 108: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110147110338
{
110148110339
sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110149110340
}
110150110341
break;
110151
- case 111: /* cmd ::= DROP VIEW ifexists fullname */
110342
+ case 109: /* cmd ::= DROP VIEW ifexists fullname */
110152110343
{
110153110344
sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110154110345
}
110155110346
break;
110156
- case 112: /* cmd ::= select */
110347
+ case 110: /* cmd ::= select */
110157110348
{
110158110349
SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110159110350
sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110160110351
sqlite3ExplainBegin(pParse->pVdbe);
110161110352
sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110162110353
sqlite3ExplainFinish(pParse->pVdbe);
110163110354
sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110164110355
}
110165110356
break;
110166
- case 113: /* select ::= oneselect */
110357
+ case 111: /* select ::= oneselect */
110167110358
{yygotominor.yy159 = yymsp[0].minor.yy159;}
110168110359
break;
110169
- case 114: /* select ::= select multiselect_op oneselect */
110360
+ case 112: /* select ::= select multiselect_op oneselect */
110170110361
{
110171110362
if( yymsp[0].minor.yy159 ){
110172110363
yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110173110364
yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110174110365
}else{
@@ -110175,83 +110366,83 @@
110175110366
sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110176110367
}
110177110368
yygotominor.yy159 = yymsp[0].minor.yy159;
110178110369
}
110179110370
break;
110180
- case 116: /* multiselect_op ::= UNION ALL */
110371
+ case 114: /* multiselect_op ::= UNION ALL */
110181110372
{yygotominor.yy392 = TK_ALL;}
110182110373
break;
110183
- case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110374
+ case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110184110375
{
110185110376
yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110186110377
}
110187110378
break;
110188
- case 122: /* sclp ::= selcollist COMMA */
110189
- case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246);
110379
+ case 120: /* sclp ::= selcollist COMMA */
110380
+ case 244: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==244);
110190110381
{yygotominor.yy442 = yymsp[-1].minor.yy442;}
110191110382
break;
110192
- case 123: /* sclp ::= */
110193
- case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
110194
- case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
110195
- case 239: /* exprlist ::= */ yytestcase(yyruleno==239);
110196
- case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245);
110383
+ case 121: /* sclp ::= */
110384
+ case 149: /* orderby_opt ::= */ yytestcase(yyruleno==149);
110385
+ case 156: /* groupby_opt ::= */ yytestcase(yyruleno==156);
110386
+ case 237: /* exprlist ::= */ yytestcase(yyruleno==237);
110387
+ case 243: /* idxlist_opt ::= */ yytestcase(yyruleno==243);
110197110388
{yygotominor.yy442 = 0;}
110198110389
break;
110199
- case 124: /* selcollist ::= sclp expr as */
110390
+ case 122: /* selcollist ::= sclp expr as */
110200110391
{
110201110392
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110202110393
if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110203110394
sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110204110395
}
110205110396
break;
110206
- case 125: /* selcollist ::= sclp STAR */
110397
+ case 123: /* selcollist ::= sclp STAR */
110207110398
{
110208110399
Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110209110400
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110210110401
}
110211110402
break;
110212
- case 126: /* selcollist ::= sclp nm DOT STAR */
110403
+ case 124: /* selcollist ::= sclp nm DOT STAR */
110213110404
{
110214110405
Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110215110406
Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110216110407
Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110217110408
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110218110409
}
110219110410
break;
110220
- case 129: /* as ::= */
110411
+ case 127: /* as ::= */
110221110412
{yygotominor.yy0.n = 0;}
110222110413
break;
110223
- case 130: /* from ::= */
110414
+ case 128: /* from ::= */
110224110415
{yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110225110416
break;
110226
- case 131: /* from ::= FROM seltablist */
110417
+ case 129: /* from ::= FROM seltablist */
110227110418
{
110228110419
yygotominor.yy347 = yymsp[0].minor.yy347;
110229110420
sqlite3SrcListShiftJoinType(yygotominor.yy347);
110230110421
}
110231110422
break;
110232
- case 132: /* stl_prefix ::= seltablist joinop */
110423
+ case 130: /* stl_prefix ::= seltablist joinop */
110233110424
{
110234110425
yygotominor.yy347 = yymsp[-1].minor.yy347;
110235110426
if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110236110427
}
110237110428
break;
110238
- case 133: /* stl_prefix ::= */
110429
+ case 131: /* stl_prefix ::= */
110239110430
{yygotominor.yy347 = 0;}
110240110431
break;
110241
- case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110432
+ case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110242110433
{
110243110434
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110244110435
sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110245110436
}
110246110437
break;
110247
- case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110438
+ case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110248110439
{
110249110440
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110250110441
}
110251110442
break;
110252
- case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110443
+ case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110253110444
{
110254110445
if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110255110446
yygotominor.yy347 = yymsp[-4].minor.yy347;
110256110447
}else{
110257110448
Select *pSubquery;
@@ -110259,137 +110450,137 @@
110259110450
pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110260110451
yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110261110452
}
110262110453
}
110263110454
break;
110264
- case 137: /* dbnm ::= */
110265
- case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
110455
+ case 135: /* dbnm ::= */
110456
+ case 144: /* indexed_opt ::= */ yytestcase(yyruleno==144);
110266110457
{yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110267110458
break;
110268
- case 139: /* fullname ::= nm dbnm */
110459
+ case 137: /* fullname ::= nm dbnm */
110269110460
{yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110270110461
break;
110271
- case 140: /* joinop ::= COMMA|JOIN */
110462
+ case 138: /* joinop ::= COMMA|JOIN */
110272110463
{ yygotominor.yy392 = JT_INNER; }
110273110464
break;
110274
- case 141: /* joinop ::= JOIN_KW JOIN */
110465
+ case 139: /* joinop ::= JOIN_KW JOIN */
110275110466
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110276110467
break;
110277
- case 142: /* joinop ::= JOIN_KW nm JOIN */
110468
+ case 140: /* joinop ::= JOIN_KW nm JOIN */
110278110469
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110279110470
break;
110280
- case 143: /* joinop ::= JOIN_KW nm nm JOIN */
110471
+ case 141: /* joinop ::= JOIN_KW nm nm JOIN */
110281110472
{ yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110282110473
break;
110283
- case 144: /* on_opt ::= ON expr */
110284
- case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
110285
- case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
110286
- case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234);
110287
- case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236);
110474
+ case 142: /* on_opt ::= ON expr */
110475
+ case 159: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==159);
110476
+ case 166: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==166);
110477
+ case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232);
110478
+ case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234);
110288110479
{yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110289110480
break;
110290
- case 145: /* on_opt ::= */
110291
- case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
110292
- case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
110293
- case 235: /* case_else ::= */ yytestcase(yyruleno==235);
110294
- case 237: /* case_operand ::= */ yytestcase(yyruleno==237);
110481
+ case 143: /* on_opt ::= */
110482
+ case 158: /* having_opt ::= */ yytestcase(yyruleno==158);
110483
+ case 165: /* where_opt ::= */ yytestcase(yyruleno==165);
110484
+ case 233: /* case_else ::= */ yytestcase(yyruleno==233);
110485
+ case 235: /* case_operand ::= */ yytestcase(yyruleno==235);
110295110486
{yygotominor.yy122 = 0;}
110296110487
break;
110297
- case 148: /* indexed_opt ::= NOT INDEXED */
110488
+ case 146: /* indexed_opt ::= NOT INDEXED */
110298110489
{yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110299110490
break;
110300
- case 149: /* using_opt ::= USING LP inscollist RP */
110301
- case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
110491
+ case 147: /* using_opt ::= USING LP inscollist RP */
110492
+ case 178: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==178);
110302110493
{yygotominor.yy180 = yymsp[-1].minor.yy180;}
110303110494
break;
110304
- case 150: /* using_opt ::= */
110305
- case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
110495
+ case 148: /* using_opt ::= */
110496
+ case 177: /* inscollist_opt ::= */ yytestcase(yyruleno==177);
110306110497
{yygotominor.yy180 = 0;}
110307110498
break;
110308
- case 152: /* orderby_opt ::= ORDER BY sortlist */
110309
- case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
110310
- case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238);
110499
+ case 150: /* orderby_opt ::= ORDER BY sortlist */
110500
+ case 157: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==157);
110501
+ case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236);
110311110502
{yygotominor.yy442 = yymsp[0].minor.yy442;}
110312110503
break;
110313
- case 153: /* sortlist ::= sortlist COMMA expr sortorder */
110504
+ case 151: /* sortlist ::= sortlist COMMA expr sortorder */
110314110505
{
110315110506
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110316110507
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110317110508
}
110318110509
break;
110319
- case 154: /* sortlist ::= expr sortorder */
110510
+ case 152: /* sortlist ::= expr sortorder */
110320110511
{
110321110512
yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110322110513
if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110323110514
}
110324110515
break;
110325
- case 155: /* sortorder ::= ASC */
110326
- case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
110516
+ case 153: /* sortorder ::= ASC */
110517
+ case 155: /* sortorder ::= */ yytestcase(yyruleno==155);
110327110518
{yygotominor.yy392 = SQLITE_SO_ASC;}
110328110519
break;
110329
- case 156: /* sortorder ::= DESC */
110520
+ case 154: /* sortorder ::= DESC */
110330110521
{yygotominor.yy392 = SQLITE_SO_DESC;}
110331110522
break;
110332
- case 162: /* limit_opt ::= */
110523
+ case 160: /* limit_opt ::= */
110333110524
{yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110334110525
break;
110335
- case 163: /* limit_opt ::= LIMIT expr */
110526
+ case 161: /* limit_opt ::= LIMIT expr */
110336110527
{yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110337110528
break;
110338
- case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
110529
+ case 162: /* limit_opt ::= LIMIT expr OFFSET expr */
110339110530
{yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110340110531
break;
110341
- case 165: /* limit_opt ::= LIMIT expr COMMA expr */
110532
+ case 163: /* limit_opt ::= LIMIT expr COMMA expr */
110342110533
{yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110343110534
break;
110344
- case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110535
+ case 164: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110345110536
{
110346110537
sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110347110538
sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110348110539
}
110349110540
break;
110350
- case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110541
+ case 167: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110351110542
{
110352110543
sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110353110544
sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110354110545
sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110355110546
}
110356110547
break;
110357
- case 170: /* setlist ::= setlist COMMA nm EQ expr */
110548
+ case 168: /* setlist ::= setlist COMMA nm EQ expr */
110358110549
{
110359110550
yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110360110551
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110361110552
}
110362110553
break;
110363
- case 171: /* setlist ::= nm EQ expr */
110554
+ case 169: /* setlist ::= nm EQ expr */
110364110555
{
110365110556
yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110366110557
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110367110558
}
110368110559
break;
110369
- case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110560
+ case 170: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110370110561
{sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110371110562
break;
110372
- case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110563
+ case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110373110564
{sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110374110565
break;
110375
- case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110566
+ case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110376110567
{sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110377110568
break;
110378
- case 175: /* insert_cmd ::= INSERT orconf */
110569
+ case 173: /* insert_cmd ::= INSERT orconf */
110379110570
{yygotominor.yy258 = yymsp[0].minor.yy258;}
110380110571
break;
110381
- case 176: /* insert_cmd ::= REPLACE */
110572
+ case 174: /* insert_cmd ::= REPLACE */
110382110573
{yygotominor.yy258 = OE_Replace;}
110383110574
break;
110384
- case 177: /* valuelist ::= VALUES LP nexprlist RP */
110575
+ case 175: /* valuelist ::= VALUES LP nexprlist RP */
110385110576
{
110386110577
yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110387110578
yygotominor.yy487.pSelect = 0;
110388110579
}
110389110580
break;
110390
- case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */
110581
+ case 176: /* valuelist ::= valuelist COMMA LP exprlist RP */
110391110582
{
110392110583
Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110393110584
if( yymsp[-4].minor.yy487.pList ){
110394110585
yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110395110586
yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110406110597
pRight->pPrior->selFlags |= SF_Values;
110407110598
yygotominor.yy487.pSelect = pRight;
110408110599
}
110409110600
}
110410110601
break;
110411
- case 181: /* inscollist ::= inscollist COMMA nm */
110602
+ case 179: /* inscollist ::= inscollist COMMA nm */
110412110603
{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110413110604
break;
110414
- case 182: /* inscollist ::= nm */
110605
+ case 180: /* inscollist ::= nm */
110415110606
{yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110416110607
break;
110417
- case 183: /* expr ::= term */
110608
+ case 181: /* expr ::= term */
110418110609
{yygotominor.yy342 = yymsp[0].minor.yy342;}
110419110610
break;
110420
- case 184: /* expr ::= LP expr RP */
110611
+ case 182: /* expr ::= LP expr RP */
110421110612
{yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110422110613
break;
110423
- case 185: /* term ::= NULL */
110424
- case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
110425
- case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
110614
+ case 183: /* term ::= NULL */
110615
+ case 188: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==188);
110616
+ case 189: /* term ::= STRING */ yytestcase(yyruleno==189);
110426110617
{spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110427110618
break;
110428
- case 186: /* expr ::= id */
110429
- case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
110619
+ case 184: /* expr ::= id */
110620
+ case 185: /* expr ::= JOIN_KW */ yytestcase(yyruleno==185);
110430110621
{spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110431110622
break;
110432
- case 188: /* expr ::= nm DOT nm */
110623
+ case 186: /* expr ::= nm DOT nm */
110433110624
{
110434110625
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110435110626
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110436110627
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110437110628
spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110438110629
}
110439110630
break;
110440
- case 189: /* expr ::= nm DOT nm DOT nm */
110631
+ case 187: /* expr ::= nm DOT nm DOT nm */
110441110632
{
110442110633
Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110443110634
Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110444110635
Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110445110636
Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110446110637
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110447110638
spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110448110639
}
110449110640
break;
110450
- case 192: /* expr ::= REGISTER */
110641
+ case 190: /* expr ::= REGISTER */
110451110642
{
110452110643
/* When doing a nested parse, one can include terms in an expression
110453110644
** that look like this: #1 #2 ... These terms refer to registers
110454110645
** in the virtual machine. #N is the N-th register. */
110455110646
if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110460110651
if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110461110652
}
110462110653
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110463110654
}
110464110655
break;
110465
- case 193: /* expr ::= VARIABLE */
110656
+ case 191: /* expr ::= VARIABLE */
110466110657
{
110467110658
spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110468110659
sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110469110660
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110470110661
}
110471110662
break;
110472
- case 194: /* expr ::= expr COLLATE ids */
110663
+ case 192: /* expr ::= expr COLLATE ids */
110473110664
{
110474110665
yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110475110666
yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110476110667
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110477110668
}
110478110669
break;
110479
- case 195: /* expr ::= CAST LP expr AS typetoken RP */
110670
+ case 193: /* expr ::= CAST LP expr AS typetoken RP */
110480110671
{
110481110672
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110482110673
spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110483110674
}
110484110675
break;
110485
- case 196: /* expr ::= ID LP distinct exprlist RP */
110676
+ case 194: /* expr ::= ID LP distinct exprlist RP */
110486110677
{
110487110678
if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110488110679
sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110489110680
}
110490110681
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110492110683
if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110493110684
yygotominor.yy342.pExpr->flags |= EP_Distinct;
110494110685
}
110495110686
}
110496110687
break;
110497
- case 197: /* expr ::= ID LP STAR RP */
110688
+ case 195: /* expr ::= ID LP STAR RP */
110498110689
{
110499110690
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110500110691
spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110501110692
}
110502110693
break;
110503
- case 198: /* term ::= CTIME_KW */
110694
+ case 196: /* term ::= CTIME_KW */
110504110695
{
110505110696
/* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110506110697
** treated as functions that return constants */
110507110698
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110508110699
if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110509110700
yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110510110701
}
110511110702
spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110512110703
}
110513110704
break;
110514
- case 199: /* expr ::= expr AND expr */
110515
- case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
110516
- case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
110517
- case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
110518
- case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
110519
- case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
110520
- case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
110521
- case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
110705
+ case 197: /* expr ::= expr AND expr */
110706
+ case 198: /* expr ::= expr OR expr */ yytestcase(yyruleno==198);
110707
+ case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
110708
+ case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
110709
+ case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
110710
+ case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
110711
+ case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
110712
+ case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
110522110713
{spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110523110714
break;
110524
- case 207: /* likeop ::= LIKE_KW */
110525
- case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
110526
-{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 0;}
110527
- break;
110528
- case 208: /* likeop ::= NOT LIKE_KW */
110529
- case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
110530
-{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 1;}
110531
- break;
110532
- case 211: /* expr ::= expr likeop expr */
110715
+ case 205: /* likeop ::= LIKE_KW */
110716
+ case 207: /* likeop ::= MATCH */ yytestcase(yyruleno==207);
110717
+{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;}
110718
+ break;
110719
+ case 206: /* likeop ::= NOT LIKE_KW */
110720
+ case 208: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==208);
110721
+{yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;}
110722
+ break;
110723
+ case 209: /* expr ::= expr likeop expr */
110533110724
{
110534110725
ExprList *pList;
110535110726
pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110536110727
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110537110728
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110538
- if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110729
+ if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110539110730
yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110540110731
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110541110732
if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110542110733
}
110543110734
break;
110544
- case 212: /* expr ::= expr likeop expr ESCAPE expr */
110735
+ case 210: /* expr ::= expr likeop expr ESCAPE expr */
110545110736
{
110546110737
ExprList *pList;
110547110738
pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110548110739
pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110549110740
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110550110741
yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110551
- if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110742
+ if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110552110743
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110553110744
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110554110745
if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110555110746
}
110556110747
break;
110557
- case 213: /* expr ::= expr ISNULL|NOTNULL */
110748
+ case 211: /* expr ::= expr ISNULL|NOTNULL */
110558110749
{spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110559110750
break;
110560
- case 214: /* expr ::= expr NOT NULL */
110751
+ case 212: /* expr ::= expr NOT NULL */
110561110752
{spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110562110753
break;
110563
- case 215: /* expr ::= expr IS expr */
110754
+ case 213: /* expr ::= expr IS expr */
110564110755
{
110565110756
spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110566110757
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110567110758
}
110568110759
break;
110569
- case 216: /* expr ::= expr IS NOT expr */
110760
+ case 214: /* expr ::= expr IS NOT expr */
110570110761
{
110571110762
spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110572110763
binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110573110764
}
110574110765
break;
110575
- case 217: /* expr ::= NOT expr */
110576
- case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218);
110766
+ case 215: /* expr ::= NOT expr */
110767
+ case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216);
110577110768
{spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110578110769
break;
110579
- case 219: /* expr ::= MINUS expr */
110770
+ case 217: /* expr ::= MINUS expr */
110580110771
{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110581110772
break;
110582
- case 220: /* expr ::= PLUS expr */
110773
+ case 218: /* expr ::= PLUS expr */
110583110774
{spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110584110775
break;
110585
- case 223: /* expr ::= expr between_op expr AND expr */
110776
+ case 221: /* expr ::= expr between_op expr AND expr */
110586110777
{
110587110778
ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110588110779
pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110589110780
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110590110781
if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110595110786
if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110596110787
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110597110788
yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110598110789
}
110599110790
break;
110600
- case 226: /* expr ::= expr in_op LP exprlist RP */
110791
+ case 224: /* expr ::= expr in_op LP exprlist RP */
110601110792
{
110602110793
if( yymsp[-1].minor.yy442==0 ){
110603110794
/* Expressions of the form
110604110795
**
110605110796
** expr1 IN ()
@@ -110622,11 +110813,11 @@
110622110813
}
110623110814
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110624110815
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110625110816
}
110626110817
break;
110627
- case 227: /* expr ::= LP select RP */
110818
+ case 225: /* expr ::= LP select RP */
110628110819
{
110629110820
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110630110821
if( yygotominor.yy342.pExpr ){
110631110822
yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110632110823
ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110636110827
}
110637110828
yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110638110829
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110639110830
}
110640110831
break;
110641
- case 228: /* expr ::= expr in_op LP select RP */
110832
+ case 226: /* expr ::= expr in_op LP select RP */
110642110833
{
110643110834
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110644110835
if( yygotominor.yy342.pExpr ){
110645110836
yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110646110837
ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110651110842
if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110652110843
yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110653110844
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110654110845
}
110655110846
break;
110656
- case 229: /* expr ::= expr in_op nm dbnm */
110847
+ case 227: /* expr ::= expr in_op nm dbnm */
110657110848
{
110658110849
SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110659110850
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110660110851
if( yygotominor.yy342.pExpr ){
110661110852
yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110667110858
if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110668110859
yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110669110860
yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110670110861
}
110671110862
break;
110672
- case 230: /* expr ::= EXISTS LP select RP */
110863
+ case 228: /* expr ::= EXISTS LP select RP */
110673110864
{
110674110865
Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110675110866
if( p ){
110676110867
p->x.pSelect = yymsp[-1].minor.yy159;
110677110868
ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110681110872
}
110682110873
yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110683110874
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110684110875
}
110685110876
break;
110686
- case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
110877
+ case 229: /* expr ::= CASE case_operand case_exprlist case_else END */
110687110878
{
110688110879
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110689110880
if( yygotominor.yy342.pExpr ){
110690110881
yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110691110882
sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110694110885
}
110695110886
yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110696110887
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110697110888
}
110698110889
break;
110699
- case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110890
+ case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110700110891
{
110701110892
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110702110893
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110703110894
}
110704110895
break;
110705
- case 233: /* case_exprlist ::= WHEN expr THEN expr */
110896
+ case 231: /* case_exprlist ::= WHEN expr THEN expr */
110706110897
{
110707110898
yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110708110899
yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110709110900
}
110710110901
break;
110711
- case 240: /* nexprlist ::= nexprlist COMMA expr */
110902
+ case 238: /* nexprlist ::= nexprlist COMMA expr */
110712110903
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110713110904
break;
110714
- case 241: /* nexprlist ::= expr */
110905
+ case 239: /* nexprlist ::= expr */
110715110906
{yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110716110907
break;
110717
- case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110908
+ case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110718110909
{
110719110910
sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110720110911
sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110721110912
&yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110722110913
}
110723110914
break;
110724
- case 243: /* uniqueflag ::= UNIQUE */
110725
- case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
110915
+ case 241: /* uniqueflag ::= UNIQUE */
110916
+ case 294: /* raisetype ::= ABORT */ yytestcase(yyruleno==294);
110726110917
{yygotominor.yy392 = OE_Abort;}
110727110918
break;
110728
- case 244: /* uniqueflag ::= */
110919
+ case 242: /* uniqueflag ::= */
110729110920
{yygotominor.yy392 = OE_None;}
110730110921
break;
110731
- case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */
110922
+ case 245: /* idxlist ::= idxlist COMMA nm collate sortorder */
110732110923
{
110733110924
Expr *p = 0;
110734110925
if( yymsp[-1].minor.yy0.n>0 ){
110735110926
p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110736110927
sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110739110930
sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110740110931
sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110741110932
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110742110933
}
110743110934
break;
110744
- case 248: /* idxlist ::= nm collate sortorder */
110935
+ case 246: /* idxlist ::= nm collate sortorder */
110745110936
{
110746110937
Expr *p = 0;
110747110938
if( yymsp[-1].minor.yy0.n>0 ){
110748110939
p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110749110940
sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110752110943
sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110753110944
sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110754110945
if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110755110946
}
110756110947
break;
110757
- case 249: /* collate ::= */
110948
+ case 247: /* collate ::= */
110758110949
{yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110759110950
break;
110760
- case 251: /* cmd ::= DROP INDEX ifexists fullname */
110951
+ case 249: /* cmd ::= DROP INDEX ifexists fullname */
110761110952
{sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110762110953
break;
110763
- case 252: /* cmd ::= VACUUM */
110764
- case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253);
110954
+ case 250: /* cmd ::= VACUUM */
110955
+ case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251);
110765110956
{sqlite3Vacuum(pParse);}
110766110957
break;
110767
- case 254: /* cmd ::= PRAGMA nm dbnm */
110958
+ case 252: /* cmd ::= PRAGMA nm dbnm */
110768110959
{sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110769110960
break;
110770
- case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110961
+ case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110771110962
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110772110963
break;
110773
- case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110964
+ case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110774110965
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110775110966
break;
110776
- case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110967
+ case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110777110968
{sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110778110969
break;
110779
- case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110970
+ case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110780110971
{sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110781110972
break;
110782
- case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110973
+ case 266: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110783110974
{
110784110975
Token all;
110785110976
all.z = yymsp[-3].minor.yy0.z;
110786110977
all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110787110978
sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110788110979
}
110789110980
break;
110790
- case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110981
+ case 267: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110791110982
{
110792110983
sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110793110984
yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110794110985
}
110795110986
break;
110796
- case 270: /* trigger_time ::= BEFORE */
110797
- case 273: /* trigger_time ::= */ yytestcase(yyruleno==273);
110987
+ case 268: /* trigger_time ::= BEFORE */
110988
+ case 271: /* trigger_time ::= */ yytestcase(yyruleno==271);
110798110989
{ yygotominor.yy392 = TK_BEFORE; }
110799110990
break;
110800
- case 271: /* trigger_time ::= AFTER */
110991
+ case 269: /* trigger_time ::= AFTER */
110801110992
{ yygotominor.yy392 = TK_AFTER; }
110802110993
break;
110803
- case 272: /* trigger_time ::= INSTEAD OF */
110994
+ case 270: /* trigger_time ::= INSTEAD OF */
110804110995
{ yygotominor.yy392 = TK_INSTEAD;}
110805110996
break;
110806
- case 274: /* trigger_event ::= DELETE|INSERT */
110807
- case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275);
110997
+ case 272: /* trigger_event ::= DELETE|INSERT */
110998
+ case 273: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==273);
110808110999
{yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
110809111000
break;
110810
- case 276: /* trigger_event ::= UPDATE OF inscollist */
111001
+ case 274: /* trigger_event ::= UPDATE OF inscollist */
110811111002
{yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
110812111003
break;
110813
- case 279: /* when_clause ::= */
110814
- case 301: /* key_opt ::= */ yytestcase(yyruleno==301);
111004
+ case 277: /* when_clause ::= */
111005
+ case 299: /* key_opt ::= */ yytestcase(yyruleno==299);
110815111006
{ yygotominor.yy122 = 0; }
110816111007
break;
110817
- case 280: /* when_clause ::= WHEN expr */
110818
- case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302);
111008
+ case 278: /* when_clause ::= WHEN expr */
111009
+ case 300: /* key_opt ::= KEY expr */ yytestcase(yyruleno==300);
110819111010
{ yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110820111011
break;
110821
- case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
111012
+ case 279: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
110822111013
{
110823111014
assert( yymsp[-2].minor.yy327!=0 );
110824111015
yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
110825111016
yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
110826111017
yygotominor.yy327 = yymsp[-2].minor.yy327;
110827111018
}
110828111019
break;
110829
- case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
111020
+ case 280: /* trigger_cmd_list ::= trigger_cmd SEMI */
110830111021
{
110831111022
assert( yymsp[-1].minor.yy327!=0 );
110832111023
yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
110833111024
yygotominor.yy327 = yymsp[-1].minor.yy327;
110834111025
}
110835111026
break;
110836
- case 284: /* trnm ::= nm DOT nm */
111027
+ case 282: /* trnm ::= nm DOT nm */
110837111028
{
110838111029
yygotominor.yy0 = yymsp[0].minor.yy0;
110839111030
sqlite3ErrorMsg(pParse,
110840111031
"qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110841111032
"statements within triggers");
110842111033
}
110843111034
break;
110844
- case 286: /* tridxby ::= INDEXED BY nm */
111035
+ case 284: /* tridxby ::= INDEXED BY nm */
110845111036
{
110846111037
sqlite3ErrorMsg(pParse,
110847111038
"the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
110848111039
"within triggers");
110849111040
}
110850111041
break;
110851
- case 287: /* tridxby ::= NOT INDEXED */
111042
+ case 285: /* tridxby ::= NOT INDEXED */
110852111043
{
110853111044
sqlite3ErrorMsg(pParse,
110854111045
"the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
110855111046
"within triggers");
110856111047
}
110857111048
break;
110858
- case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
111049
+ case 286: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
110859111050
{ yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
110860111051
break;
110861
- case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
111052
+ case 287: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
110862111053
{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
110863111054
break;
110864
- case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
111055
+ case 288: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
110865111056
{yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
110866111057
break;
110867
- case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
111058
+ case 289: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
110868111059
{yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
110869111060
break;
110870
- case 292: /* trigger_cmd ::= select */
111061
+ case 290: /* trigger_cmd ::= select */
110871111062
{yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
110872111063
break;
110873
- case 293: /* expr ::= RAISE LP IGNORE RP */
111064
+ case 291: /* expr ::= RAISE LP IGNORE RP */
110874111065
{
110875111066
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110876111067
if( yygotominor.yy342.pExpr ){
110877111068
yygotominor.yy342.pExpr->affinity = OE_Ignore;
110878111069
}
110879111070
yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110880111071
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110881111072
}
110882111073
break;
110883
- case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */
111074
+ case 292: /* expr ::= RAISE LP raisetype COMMA nm RP */
110884111075
{
110885111076
yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110886111077
if( yygotominor.yy342.pExpr ) {
110887111078
yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110888111079
}
110889111080
yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
110890111081
yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110891111082
}
110892111083
break;
110893
- case 295: /* raisetype ::= ROLLBACK */
111084
+ case 293: /* raisetype ::= ROLLBACK */
110894111085
{yygotominor.yy392 = OE_Rollback;}
110895111086
break;
110896
- case 297: /* raisetype ::= FAIL */
111087
+ case 295: /* raisetype ::= FAIL */
110897111088
{yygotominor.yy392 = OE_Fail;}
110898111089
break;
110899
- case 298: /* cmd ::= DROP TRIGGER ifexists fullname */
111090
+ case 296: /* cmd ::= DROP TRIGGER ifexists fullname */
110900111091
{
110901111092
sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
110902111093
}
110903111094
break;
110904
- case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
111095
+ case 297: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
110905111096
{
110906111097
sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110907111098
}
110908111099
break;
110909
- case 300: /* cmd ::= DETACH database_kw_opt expr */
111100
+ case 298: /* cmd ::= DETACH database_kw_opt expr */
110910111101
{
110911111102
sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
110912111103
}
110913111104
break;
110914
- case 305: /* cmd ::= REINDEX */
111105
+ case 303: /* cmd ::= REINDEX */
110915111106
{sqlite3Reindex(pParse, 0, 0);}
110916111107
break;
110917
- case 306: /* cmd ::= REINDEX nm dbnm */
111108
+ case 304: /* cmd ::= REINDEX nm dbnm */
110918111109
{sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110919111110
break;
110920
- case 307: /* cmd ::= ANALYZE */
111111
+ case 305: /* cmd ::= ANALYZE */
110921111112
{sqlite3Analyze(pParse, 0, 0);}
110922111113
break;
110923
- case 308: /* cmd ::= ANALYZE nm dbnm */
111114
+ case 306: /* cmd ::= ANALYZE nm dbnm */
110924111115
{sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110925111116
break;
110926
- case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
111117
+ case 307: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110927111118
{
110928111119
sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
110929111120
}
110930111121
break;
110931
- case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
111122
+ case 308: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110932111123
{
110933111124
sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
110934111125
}
110935111126
break;
110936
- case 311: /* add_column_fullname ::= fullname */
111127
+ case 309: /* add_column_fullname ::= fullname */
110937111128
{
110938111129
pParse->db->lookaside.bEnabled = 0;
110939111130
sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
110940111131
}
110941111132
break;
110942
- case 314: /* cmd ::= create_vtab */
111133
+ case 312: /* cmd ::= create_vtab */
110943111134
{sqlite3VtabFinishParse(pParse,0);}
110944111135
break;
110945
- case 315: /* cmd ::= create_vtab LP vtabarglist RP */
111136
+ case 313: /* cmd ::= create_vtab LP vtabarglist RP */
110946111137
{sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
110947111138
break;
110948
- case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111139
+ case 314: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
110949111140
{
110950111141
sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
110951111142
}
110952111143
break;
110953
- case 319: /* vtabarg ::= */
111144
+ case 317: /* vtabarg ::= */
110954111145
{sqlite3VtabArgInit(pParse);}
110955111146
break;
110956
- case 321: /* vtabargtoken ::= ANY */
110957
- case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322);
110958
- case 323: /* lp ::= LP */ yytestcase(yyruleno==323);
111147
+ case 319: /* vtabargtoken ::= ANY */
111148
+ case 320: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==320);
111149
+ case 321: /* lp ::= LP */ yytestcase(yyruleno==321);
110959111150
{sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
110960111151
break;
110961111152
default:
110962111153
/* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
110963111154
/* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
110973111164
/* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
110974111165
/* (35) columnlist ::= column */ yytestcase(yyruleno==35);
110975111166
/* (44) type ::= */ yytestcase(yyruleno==44);
110976111167
/* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
110977111168
/* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
110978
- /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
111169
+ /* (53) carglist ::= carglist cname ccons */ yytestcase(yyruleno==53);
110979111170
/* (54) carglist ::= */ yytestcase(yyruleno==54);
110980
- /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
110981
- /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
110982111171
/* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
110983
- /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
110984
- /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
110985
- /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
110986
- /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
110987
- /* (277) foreach_clause ::= */ yytestcase(yyruleno==277);
110988
- /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278);
110989
- /* (285) tridxby ::= */ yytestcase(yyruleno==285);
110990
- /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
110991
- /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304);
110992
- /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312);
110993
- /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313);
110994
- /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317);
110995
- /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318);
110996
- /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320);
110997
- /* (324) anylist ::= */ yytestcase(yyruleno==324);
110998
- /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110999
- /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
111172
+ /* (90) conslist ::= conslist COMMA cname tcons */ yytestcase(yyruleno==90);
111173
+ /* (91) conslist ::= cname tcons */ yytestcase(yyruleno==91);
111174
+ /* (275) foreach_clause ::= */ yytestcase(yyruleno==275);
111175
+ /* (276) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==276);
111176
+ /* (283) tridxby ::= */ yytestcase(yyruleno==283);
111177
+ /* (301) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==301);
111178
+ /* (302) database_kw_opt ::= */ yytestcase(yyruleno==302);
111179
+ /* (310) kwcolumn_opt ::= */ yytestcase(yyruleno==310);
111180
+ /* (311) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==311);
111181
+ /* (315) vtabarglist ::= vtabarg */ yytestcase(yyruleno==315);
111182
+ /* (316) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==316);
111183
+ /* (318) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==318);
111184
+ /* (322) anylist ::= */ yytestcase(yyruleno==322);
111185
+ /* (323) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==323);
111186
+ /* (324) anylist ::= anylist ANY */ yytestcase(yyruleno==324);
111000111187
break;
111001111188
};
111002111189
yygoto = yyRuleInfo[yyruleno].lhs;
111003111190
yysize = yyRuleInfo[yyruleno].nrhs;
111004111191
yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
115889116076
** option. But that functionality is no longer supported.
115890116077
**
115891116078
** A doclist is stored like this:
115892116079
**
115893116080
** array {
115894
-** varint docid;
116081
+** varint docid; (delta from previous doclist)
115895116082
** array { (position list for column 0)
115896116083
** varint position; (2 more than the delta from previous position)
115897116084
** }
115898116085
** array {
115899116086
** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
115920116107
** The 123 value is the first docid. For column zero in this document
115921116108
** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
115922116109
** at D signals the start of a new column; the 1 at E indicates that the
115923116110
** new column is column number 1. There are two positions at 12 and 45
115924116111
** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
115925
-** 234 at I is the next docid. It has one position 72 (72-2) and then
115926
-** terminates with the 0 at K.
116112
+** 234 at I is the delta to next docid (357). It has one position 70
116113
+** (72-2) and then terminates with the 0 at K.
115927116114
**
115928116115
** A "position-list" is the list of positions for multiple columns for
115929116116
** a single docid. A "column-list" is the set of positions for a single
115930116117
** column. Hence, a position-list consists of one or more column-lists,
115931116118
** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116456116643
116457116644
116458116645
#ifndef MIN
116459116646
# define MIN(x,y) ((x)<(y)?(x):(y))
116460116647
#endif
116648
+#ifndef MAX
116649
+# define MAX(x,y) ((x)>(y)?(x):(y))
116650
+#endif
116461116651
116462116652
/*
116463116653
** Maximum length of a varint encoded integer. The varint format is different
116464116654
** from that used by SQLite, so the maximum length is 10, not 9.
116465116655
*/
@@ -116510,20 +116700,21 @@
116510116700
#ifdef SQLITE_COVERAGE_TEST
116511116701
# define ALWAYS(x) (1)
116512116702
# define NEVER(X) (0)
116513116703
#else
116514116704
# define ALWAYS(x) (x)
116515
-# define NEVER(X) (x)
116705
+# define NEVER(x) (x)
116516116706
#endif
116517116707
116518116708
/*
116519116709
** Internal types used by SQLite.
116520116710
*/
116521116711
typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116522116712
typedef short int i16; /* 2-byte (or larger) signed integer */
116523116713
typedef unsigned int u32; /* 4-byte unsigned integer */
116524116714
typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
116715
+typedef sqlite3_int64 i64; /* 8-byte signed integer */
116525116716
116526116717
/*
116527116718
** Macro used to suppress compiler warnings for unused parameters.
116528116719
*/
116529116720
#define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116582116773
int nColumn; /* number of named columns in virtual table */
116583116774
char **azColumn; /* column names. malloced */
116584116775
sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116585116776
char *zContentTbl; /* content=xxx option, or NULL */
116586116777
char *zLanguageid; /* languageid=xxx option, or NULL */
116778
+ u8 bAutoincrmerge; /* True if automerge=1 */
116779
+ u32 nLeafAdd; /* Number of leaf blocks added this trans */
116587116780
116588116781
/* Precompiled statements used by the implementation. Each of these
116589116782
** statements is run and reset within a single virtual table API call.
116590116783
*/
116591
- sqlite3_stmt *aStmt[28];
116784
+ sqlite3_stmt *aStmt[37];
116592116785
116593116786
char *zReadExprlist;
116594116787
char *zWriteExprlist;
116595116788
116596116789
int nNodeSize; /* Soft limit for node size */
116790
+ u8 bFts4; /* True for FTS4, false for FTS3 */
116597116791
u8 bHasStat; /* True if %_stat table exists */
116598116792
u8 bHasDocsize; /* True if %_docsize table exists */
116599116793
u8 bDescIdx; /* True if doclists are in reverse order */
116794
+ u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */
116600116795
int nPgsz; /* Page size for host database */
116601116796
char *zSegmentsTbl; /* Name of %_segments table */
116602116797
sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116603116798
116604
- /* TODO: Fix the first paragraph of this comment.
116605
- **
116799
+ /*
116606116800
** The following array of hash tables is used to buffer pending index
116607
- ** updates during transactions. Variable nPendingData estimates the memory
116608
- ** size of the pending data, including hash table overhead, not including
116609
- ** malloc overhead. When nPendingData exceeds nMaxPendingData, the buffer
116610
- ** is flushed automatically. Variable iPrevDocid is the docid of the most
116611
- ** recently inserted record.
116801
+ ** updates during transactions. All pending updates buffered at any one
116802
+ ** time must share a common language-id (see the FTS4 langid= feature).
116803
+ ** The current language id is stored in variable iPrevLangid.
116612116804
**
116613116805
** A single FTS4 table may have multiple full-text indexes. For each index
116614116806
** there is an entry in the aIndex[] array. Index 0 is an index of all the
116615116807
** terms that appear in the document set. Each subsequent index in aIndex[]
116616116808
** is an index of prefixes of a specific length.
116809
+ **
116810
+ ** Variable nPendingData contains an estimate the memory consumed by the
116811
+ ** pending data structures, including hash table overhead, but not including
116812
+ ** malloc overhead. When nPendingData exceeds nMaxPendingData, all hash
116813
+ ** tables are flushed to disk. Variable iPrevDocid is the docid of the most
116814
+ ** recently inserted record.
116617116815
*/
116618116816
int nIndex; /* Size of aIndex[] */
116619116817
struct Fts3Index {
116620116818
int nPrefix; /* Prefix length (0 for main terms index) */
116621116819
Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
116810117008
SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
116811117009
SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
116812117010
SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
116813117011
SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
116814117012
SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
117013
+SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);
116815117014
116816117015
/* Special values interpreted by sqlite3SegReaderCursor() */
116817117016
#define FTS3_SEGCURSOR_PENDING -1
116818117017
#define FTS3_SEGCURSOR_ALL -2
116819117018
@@ -116861,19 +117060,22 @@
116861117060
int nTerm; /* Size of zTerm in bytes */
116862117061
char *aDoclist; /* Pointer to doclist buffer */
116863117062
int nDoclist; /* Size of aDoclist[] in bytes */
116864117063
};
116865117064
117065
+SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
117066
+
116866117067
/* fts3.c */
116867117068
SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
116868117069
SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
116869117070
SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
116870117071
SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
116871117072
SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
116872117073
SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
116873117074
SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
116874117075
SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
117076
+SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);
116875117077
116876117078
/* fts3_tokenizer.c */
116877117079
SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
116878117080
SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
116879117081
SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117198117400
sqlite3_free(zSql);
117199117401
sqlite3_free(zCols);
117200117402
*pRc = rc;
117201117403
}
117202117404
}
117405
+
117406
+/*
117407
+** Create the %_stat table if it does not already exist.
117408
+*/
117409
+SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){
117410
+ fts3DbExec(pRc, p->db,
117411
+ "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
117412
+ "(id INTEGER PRIMARY KEY, value BLOB);",
117413
+ p->zDb, p->zName
117414
+ );
117415
+ if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;
117416
+}
117203117417
117204117418
/*
117205117419
** Create the backing store tables (%_content, %_segments and %_segdir)
117206117420
** required by the FTS3 table passed as the only argument. This is done
117207117421
** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117259117473
fts3DbExec(&rc, db,
117260117474
"CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117261117475
p->zDb, p->zName
117262117476
);
117263117477
}
117478
+ assert( p->bHasStat==p->bFts4 );
117264117479
if( p->bHasStat ){
117265
- fts3DbExec(&rc, db,
117266
- "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117267
- p->zDb, p->zName
117268
- );
117480
+ sqlite3Fts3CreateStatTable(&rc, p);
117269117481
}
117270117482
return rc;
117271117483
}
117272117484
117273117485
/*
@@ -117370,11 +117582,11 @@
117370117582
** memory.
117371117583
*/
117372117584
static char *fts3QuoteId(char const *zInput){
117373117585
int nRet;
117374117586
char *zRet;
117375
- nRet = 2 + strlen(zInput)*2 + 1;
117587
+ nRet = 2 + (int)strlen(zInput)*2 + 1;
117376117588
zRet = sqlite3_malloc(nRet);
117377117589
if( zRet ){
117378117590
int i;
117379117591
char *z = zRet;
117380117592
*(z++) = '"';
@@ -117626,11 +117838,11 @@
117626117838
** space required to store a copy of each column name, including the
117627117839
** nul-terminator byte. */
117628117840
nCol = sqlite3_column_count(pStmt);
117629117841
for(i=0; i<nCol; i++){
117630117842
const char *zCol = sqlite3_column_name(pStmt, i);
117631
- nStr += strlen(zCol) + 1;
117843
+ nStr += (int)strlen(zCol) + 1;
117632117844
}
117633117845
117634117846
/* Allocate and populate the array to return. */
117635117847
azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117636117848
if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117637117849
rc = SQLITE_NOMEM;
117638117850
}else{
117639117851
char *p = (char *)&azCol[nCol];
117640117852
for(i=0; i<nCol; i++){
117641117853
const char *zCol = sqlite3_column_name(pStmt, i);
117642
- int n = strlen(zCol)+1;
117854
+ int n = (int)strlen(zCol)+1;
117643117855
memcpy(p, zCol, n);
117644117856
azCol[i] = p;
117645117857
p += n;
117646117858
}
117647117859
}
@@ -117852,11 +118064,12 @@
117852118064
** column from the aCol[] array. */
117853118065
if( rc==SQLITE_OK && zLanguageid ){
117854118066
int j;
117855118067
for(j=0; j<nCol; j++){
117856118068
if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
117857
- memmove(&aCol[j], &aCol[j+1], (nCol-j) * sizeof(aCol[0]));
118069
+ int k;
118070
+ for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];
117858118071
nCol--;
117859118072
break;
117860118073
}
117861118074
}
117862118075
}
@@ -117903,11 +118116,13 @@
117903118116
p->azColumn = (char **)&p[1];
117904118117
p->pTokenizer = pTokenizer;
117905118118
p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
117906118119
p->bHasDocsize = (isFts4 && bNoDocsize==0);
117907118120
p->bHasStat = isFts4;
118121
+ p->bFts4 = isFts4;
117908118122
p->bDescIdx = bDescIdx;
118123
+ p->bAutoincrmerge = 0xff; /* 0xff means setting unknown */
117909118124
p->zContentTbl = zContent;
117910118125
p->zLanguageid = zLanguageid;
117911118126
zContent = 0;
117912118127
zLanguageid = 0;
117913118128
TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
117955118170
** database. TODO: For xConnect(), it could verify that said tables exist.
117956118171
*/
117957118172
if( isCreate ){
117958118173
rc = fts3CreateTables(p);
117959118174
}
118175
+
118176
+ /* Check to see if a legacy fts3 table has been "upgraded" by the
118177
+ ** addition of a %_stat table so that it can use incremental merge.
118178
+ */
118179
+ if( !isFts4 && !isCreate ){
118180
+ int rc2 = SQLITE_OK;
118181
+ fts3DbExec(&rc2, db, "SELECT 1 FROM %Q.'%q_stat' WHERE id=2",
118182
+ p->zDb, p->zName);
118183
+ if( rc2==SQLITE_OK ) p->bHasStat = 1;
118184
+ }
117960118185
117961118186
/* Figure out the page-size for the database. This is required in order to
117962118187
** estimate the cost of loading large doclists from the database. */
117963118188
fts3DatabasePageSize(&rc, p);
117964118189
p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
118959119184
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
118960119185
}
118961119186
}
118962119187
118963119188
*paOut = aOut;
118964
- *pnOut = (p-aOut);
119189
+ *pnOut = (int)(p-aOut);
118965119190
assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
118966119191
return SQLITE_OK;
118967119192
}
118968119193
118969119194
/*
@@ -119023,11 +119248,11 @@
119023119248
fts3PoslistCopy(0, &p2);
119024119249
fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119025119250
}
119026119251
}
119027119252
119028
- *pnRight = p - aOut;
119253
+ *pnRight = (int)(p - aOut);
119029119254
}
119030119255
119031119256
/*
119032119257
** Argument pList points to a position list nList bytes in size. This
119033119258
** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119299119524
** Set up a cursor object for iterating through a full-text index or a
119300119525
** single level therein.
119301119526
*/
119302119527
SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119303119528
Fts3Table *p, /* FTS3 table handle */
119304
- int iLangid,
119529
+ int iLangid, /* Language-id to search */
119305119530
int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119306119531
int iLevel, /* Level of segments to scan */
119307119532
const char *zTerm, /* Term to query for */
119308119533
int nTerm, /* Size of zTerm in bytes */
119309119534
int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119317119542
);
119318119543
assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119319119544
assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119320119545
assert( isPrefix==0 || isScan==0 );
119321119546
119322
- /* "isScan" is only set to true by the ft4aux module, an ordinary
119323
- ** full-text tables. */
119324
- assert( isScan==0 || p->aIndex==0 );
119325
-
119326119547
memset(pCsr, 0, sizeof(Fts3MultiSegReader));
119327
-
119328119548
return fts3SegReaderCursor(
119329119549
p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119330119550
);
119331119551
}
119332119552
@@ -119587,11 +119807,11 @@
119587119807
119588119808
pCsr->iLangid = 0;
119589119809
if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119590119810
119591119811
rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119592
- p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119812
+ p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119593119813
);
119594119814
if( rc!=SQLITE_OK ){
119595119815
if( rc==SQLITE_ERROR ){
119596119816
static const char *zErr = "malformed MATCH expression: [%s]";
119597119817
p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119730119950
/*
119731119951
** Implementation of xSync() method. Flush the contents of the pending-terms
119732119952
** hash-table to the database.
119733119953
*/
119734119954
static int fts3SyncMethod(sqlite3_vtab *pVtab){
119735
- int rc = sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab);
119736
- sqlite3Fts3SegmentsClose((Fts3Table *)pVtab);
119955
+
119956
+ /* Following an incremental-merge operation, assuming that the input
119957
+ ** segments are not completely consumed (the usual case), they are updated
119958
+ ** in place to remove the entries that have already been merged. This
119959
+ ** involves updating the leaf block that contains the smallest unmerged
119960
+ ** entry and each block (if any) between the leaf and the root node. So
119961
+ ** if the height of the input segment b-trees is N, and input segments
119962
+ ** are merged eight at a time, updating the input segments at the end
119963
+ ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually
119964
+ ** small - often between 0 and 2. So the overhead of the incremental
119965
+ ** merge is somewhere between 8 and 24 blocks. To avoid this overhead
119966
+ ** dwarfing the actual productive work accomplished, the incremental merge
119967
+ ** is only attempted if it will write at least 64 leaf blocks. Hence
119968
+ ** nMinMerge.
119969
+ **
119970
+ ** Of course, updating the input segments also involves deleting a bunch
119971
+ ** of blocks from the segments table. But this is not considered overhead
119972
+ ** as it would also be required by a crisis-merge that used the same input
119973
+ ** segments.
119974
+ */
119975
+ const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
119976
+
119977
+ Fts3Table *p = (Fts3Table*)pVtab;
119978
+ int rc = sqlite3Fts3PendingTermsFlush(p);
119979
+
119980
+ if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){
119981
+ int mxLevel = 0; /* Maximum relative level value in db */
119982
+ int A; /* Incr-merge parameter A */
119983
+
119984
+ rc = sqlite3Fts3MaxLevel(p, &mxLevel);
119985
+ assert( rc==SQLITE_OK || mxLevel==0 );
119986
+ A = p->nLeafAdd * mxLevel;
119987
+ A += (A/2);
119988
+ if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);
119989
+ }
119990
+ sqlite3Fts3SegmentsClose(p);
119737119991
return rc;
119738119992
}
119739119993
119740119994
/*
119741119995
** Implementation of xBegin() method. This is a no-op.
119742119996
*/
119743119997
static int fts3BeginMethod(sqlite3_vtab *pVtab){
119744
- TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
119998
+ Fts3Table *p = (Fts3Table*)pVtab;
119745119999
UNUSED_PARAMETER(pVtab);
119746120000
assert( p->pSegments==0 );
119747120001
assert( p->nPendingData==0 );
119748120002
assert( p->inTransaction!=1 );
119749120003
TESTONLY( p->inTransaction = 1 );
119750120004
TESTONLY( p->mxSavepoint = -1; );
120005
+ p->nLeafAdd = 0;
119751120006
return SQLITE_OK;
119752120007
}
119753120008
119754120009
/*
119755120010
** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120040120295
** The xSavepoint() method.
120041120296
**
120042120297
** Flush the contents of the pending-terms table to disk.
120043120298
*/
120044120299
static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
120300
+ int rc = SQLITE_OK;
120045120301
UNUSED_PARAMETER(iSavepoint);
120046120302
assert( ((Fts3Table *)pVtab)->inTransaction );
120047120303
assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120048120304
TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120049
- return fts3SyncMethod(pVtab);
120305
+ if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
120306
+ rc = fts3SyncMethod(pVtab);
120307
+ }
120308
+ return rc;
120050120309
}
120051120310
120052120311
/*
120053120312
** The xRelease() method.
120054120313
**
@@ -120404,11 +120663,11 @@
120404120663
120405120664
assert( iPrev>=0 );
120406120665
fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120407120666
sqlite3_free(aPoslist);
120408120667
aPoslist = pList;
120409
- nPoslist = aOut - aPoslist;
120668
+ nPoslist = (int)(aOut - aPoslist);
120410120669
if( nPoslist==0 ){
120411120670
sqlite3_free(aPoslist);
120412120671
pPhrase->doclist.pList = 0;
120413120672
pPhrase->doclist.nList = 0;
120414120673
return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120448120707
}
120449120708
120450120709
pPhrase->doclist.pList = aOut;
120451120710
if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120452120711
pPhrase->doclist.bFreeList = 1;
120453
- pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList);
120712
+ pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);
120454120713
}else{
120455120714
sqlite3_free(aOut);
120456120715
pPhrase->doclist.pList = 0;
120457120716
pPhrase->doclist.nList = 0;
120458120717
}
@@ -120544,11 +120803,11 @@
120544120803
fts3PoslistCopy(0, &pDocid);
120545120804
while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120546120805
iMul = (bDescIdx ? -1 : 1);
120547120806
}
120548120807
120549
- *pnList = pEnd - pNext;
120808
+ *pnList = (int)(pEnd - pNext);
120550120809
*ppIter = pNext;
120551120810
*piDocid = iDocid;
120552120811
}else{
120553120812
int iMul = (bDescIdx ? -1 : 1);
120554120813
sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120558120817
if( p==aDoclist ){
120559120818
*pbEof = 1;
120560120819
}else{
120561120820
char *pSave = p;
120562120821
fts3ReversePoslist(aDoclist, &p);
120563
- *pnList = (pSave - p);
120822
+ *pnList = (int)(pSave - p);
120564120823
}
120565120824
*ppIter = p;
120566120825
}
120567120826
}
120568120827
@@ -120618,11 +120877,11 @@
120618120877
}else{
120619120878
pDL->iDocid -= iDelta;
120620120879
}
120621120880
pDL->pList = pIter;
120622120881
fts3PoslistCopy(0, &pIter);
120623
- pDL->nList = (pIter - pDL->pList);
120882
+ pDL->nList = (int)(pIter - pDL->pList);
120624120883
120625120884
/* pIter now points just past the 0x00 that terminates the position-
120626120885
** list for document pDL->iDocid. However, if this position-list was
120627120886
** edited in place by fts3EvalNearTrim(), then pIter may not actually
120628120887
** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
120959121218
120960121219
/* Allocate a MultiSegReader for each token in the expression. */
120961121220
fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
120962121221
120963121222
/* Determine which, if any, tokens in the expression should be deferred. */
120964
- if( rc==SQLITE_OK && nToken>1 && pTab->bHasStat ){
121223
+ if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
120965121224
Fts3TokenAndCost *aTC;
120966121225
Fts3Expr **apOr;
120967121226
aTC = (Fts3TokenAndCost *)sqlite3_malloc(
120968121227
sizeof(Fts3TokenAndCost) * nToken
120969121228
+ sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
120976121235
int ii;
120977121236
Fts3TokenAndCost *pTC = aTC;
120978121237
Fts3Expr **ppOr = apOr;
120979121238
120980121239
fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
120981
- nToken = pTC-aTC;
120982
- nOr = ppOr-apOr;
121240
+ nToken = (int)(pTC-aTC);
121241
+ nOr = (int)(ppOr-apOr);
120983121242
120984121243
if( rc==SQLITE_OK ){
120985121244
rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
120986121245
for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
120987121246
rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121049121308
p2 = pOut = pPhrase->doclist.pList;
121050121309
res = fts3PoslistNearMerge(
121051121310
&pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121052121311
);
121053121312
if( res ){
121054
- nNew = (pOut - pPhrase->doclist.pList) - 1;
121313
+ nNew = (int)(pOut - pPhrase->doclist.pList) - 1;
121055121314
assert( pPhrase->doclist.pList[nNew]=='\0' );
121056121315
assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121057121316
memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121058121317
pPhrase->doclist.nList = nNew;
121059121318
*paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
121774122033
fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
121775122034
pPhrase->aToken[i].pSegcsr = 0;
121776122035
}
121777122036
}
121778122037
}
122038
+
121779122039
121780122040
/*
121781122041
** Return SQLITE_CORRUPT_VTAB.
121782122042
*/
121783122043
#ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
121882122142
);
121883122143
return SQLITE_ERROR;
121884122144
}
121885122145
121886122146
zDb = argv[1];
121887
- nDb = strlen(zDb);
122147
+ nDb = (int)strlen(zDb);
121888122148
zFts3 = argv[3];
121889
- nFts3 = strlen(zFts3);
122149
+ nFts3 = (int)strlen(zFts3);
121890122150
121891122151
rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
121892122152
if( rc!=SQLITE_OK ) return rc;
121893122153
121894122154
nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125074125334
125075125335
/* #include <string.h> */
125076125336
/* #include <assert.h> */
125077125337
/* #include <stdlib.h> */
125078125338
125339
+
125340
+#define FTS_MAX_APPENDABLE_HEIGHT 16
125341
+
125079125342
/*
125080125343
** When full-text index nodes are loaded from disk, the buffer that they
125081125344
** are loaded into has the following number of bytes of padding at the end
125082125345
** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125083125346
** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125112125375
# define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125113125376
#else
125114125377
# define FTS3_NODE_CHUNKSIZE (4*1024)
125115125378
# define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125116125379
#endif
125380
+
125381
+/*
125382
+** The two values that may be meaningfully bound to the :1 parameter in
125383
+** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
125384
+*/
125385
+#define FTS_STAT_DOCTOTAL 0
125386
+#define FTS_STAT_INCRMERGEHINT 1
125387
+#define FTS_STAT_AUTOINCRMERGE 2
125388
+
125389
+/*
125390
+** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic
125391
+** and incremental merge operation that takes place. This is used for
125392
+** debugging FTS only, it should not usually be turned on in production
125393
+** systems.
125394
+*/
125395
+#ifdef FTS3_LOG_MERGES
125396
+static void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){
125397
+ sqlite3_log(SQLITE_OK, "%d-way merge from level %d", nMerge, (int)iAbsLevel);
125398
+}
125399
+#else
125400
+#define fts3LogMerge(x, y)
125401
+#endif
125402
+
125117125403
125118125404
typedef struct PendingList PendingList;
125119125405
typedef struct SegmentNode SegmentNode;
125120125406
typedef struct SegmentWriter SegmentWriter;
125121125407
@@ -125274,19 +125560,26 @@
125274125560
#define SQL_DELETE_SEGMENTS_RANGE 17
125275125561
#define SQL_CONTENT_INSERT 18
125276125562
#define SQL_DELETE_DOCSIZE 19
125277125563
#define SQL_REPLACE_DOCSIZE 20
125278125564
#define SQL_SELECT_DOCSIZE 21
125279
-#define SQL_SELECT_DOCTOTAL 22
125280
-#define SQL_REPLACE_DOCTOTAL 23
125565
+#define SQL_SELECT_STAT 22
125566
+#define SQL_REPLACE_STAT 23
125281125567
125282125568
#define SQL_SELECT_ALL_PREFIX_LEVEL 24
125283125569
#define SQL_DELETE_ALL_TERMS_SEGDIR 25
125284
-
125285125570
#define SQL_DELETE_SEGDIR_RANGE 26
125286
-
125287125571
#define SQL_SELECT_ALL_LANGID 27
125572
+#define SQL_FIND_MERGE_LEVEL 28
125573
+#define SQL_MAX_LEAF_NODE_ESTIMATE 29
125574
+#define SQL_DELETE_SEGDIR_ENTRY 30
125575
+#define SQL_SHIFT_SEGDIR_ENTRY 31
125576
+#define SQL_SELECT_SEGDIR 32
125577
+#define SQL_CHOMP_SEGDIR 33
125578
+#define SQL_SEGMENT_IS_APPENDABLE 34
125579
+#define SQL_SELECT_INDEXES 35
125580
+#define SQL_SELECT_MXLEVEL 36
125288125581
125289125582
/*
125290125583
** This function is used to obtain an SQLite prepared statement handle
125291125584
** for the statement identified by the second argument. If successful,
125292125585
** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125311125604
/* 4 */ "DELETE FROM %Q.'%q_segdir'",
125312125605
/* 5 */ "DELETE FROM %Q.'%q_docsize'",
125313125606
/* 6 */ "DELETE FROM %Q.'%q_stat'",
125314125607
/* 7 */ "SELECT %s WHERE rowid=?",
125315125608
/* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125316
-/* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125609
+/* 9 */ "REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125317125610
/* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125318
-/* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125611
+/* 11 */ "REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125319125612
125320125613
/* Return segments in order from oldest to newest.*/
125321125614
/* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125322125615
"FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125323125616
/* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125331125624
/* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125332125625
/* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125333125626
/* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125334125627
/* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125335125628
/* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125336
-/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=0",
125337
-/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(0,?)",
125629
+/* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=?",
125630
+/* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
125338125631
/* 24 */ "",
125339125632
/* 25 */ "",
125340125633
125341125634
/* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125342125635
/* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125343125636
125637
+/* This statement is used to determine which level to read the input from
125638
+** when performing an incremental merge. It returns the absolute level number
125639
+** of the oldest level in the db that contains at least ? segments. Or,
125640
+** if no level in the FTS index contains more than ? segments, the statement
125641
+** returns zero rows. */
125642
+/* 28 */ "SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?"
125643
+ " ORDER BY (level %% 1024) ASC LIMIT 1",
125644
+
125645
+/* Estimate the upper limit on the number of leaf nodes in a new segment
125646
+** created by merging the oldest :2 segments from absolute level :1. See
125647
+** function sqlite3Fts3Incrmerge() for details. */
125648
+/* 29 */ "SELECT 2 * total(1 + leaves_end_block - start_block) "
125649
+ " FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?",
125650
+
125651
+/* SQL_DELETE_SEGDIR_ENTRY
125652
+** Delete the %_segdir entry on absolute level :1 with index :2. */
125653
+/* 30 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125654
+
125655
+/* SQL_SHIFT_SEGDIR_ENTRY
125656
+** Modify the idx value for the segment with idx=:3 on absolute level :2
125657
+** to :1. */
125658
+/* 31 */ "UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?",
125659
+
125660
+/* SQL_SELECT_SEGDIR
125661
+** Read a single entry from the %_segdir table. The entry from absolute
125662
+** level :1 with index value :2. */
125663
+/* 32 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125664
+ "FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125665
+
125666
+/* SQL_CHOMP_SEGDIR
125667
+** Update the start_block (:1) and root (:2) fields of the %_segdir
125668
+** entry located on absolute level :3 with index :4. */
125669
+/* 33 */ "UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?"
125670
+ "WHERE level = ? AND idx = ?",
125671
+
125672
+/* SQL_SEGMENT_IS_APPENDABLE
125673
+** Return a single row if the segment with end_block=? is appendable. Or
125674
+** no rows otherwise. */
125675
+/* 34 */ "SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL",
125676
+
125677
+/* SQL_SELECT_INDEXES
125678
+** Return the list of valid segment indexes for absolute level ? */
125679
+/* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
125680
+
125681
+/* SQL_SELECT_MXLEVEL
125682
+** Return the largest relative level in the FTS index or indexes. */
125683
+/* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'"
125344125684
};
125345125685
int rc = SQLITE_OK;
125346125686
sqlite3_stmt *pStmt;
125347125687
125348125688
assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125375125715
}
125376125716
}
125377125717
*pp = pStmt;
125378125718
return rc;
125379125719
}
125720
+
125380125721
125381125722
static int fts3SelectDocsize(
125382125723
Fts3Table *pTab, /* FTS3 table handle */
125383
- int eStmt, /* Either SQL_SELECT_DOCSIZE or DOCTOTAL */
125384125724
sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125385125725
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125386125726
){
125387125727
sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125388125728
int rc; /* Return code */
125389125729
125390
- assert( eStmt==SQL_SELECT_DOCSIZE || eStmt==SQL_SELECT_DOCTOTAL );
125391
-
125392
- rc = fts3SqlStmt(pTab, eStmt, &pStmt, 0);
125730
+ rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);
125393125731
if( rc==SQLITE_OK ){
125394
- if( eStmt==SQL_SELECT_DOCSIZE ){
125395
- sqlite3_bind_int64(pStmt, 1, iDocid);
125396
- }
125732
+ sqlite3_bind_int64(pStmt, 1, iDocid);
125397125733
rc = sqlite3_step(pStmt);
125398125734
if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125399125735
rc = sqlite3_reset(pStmt);
125400125736
if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125401125737
pStmt = 0;
@@ -125410,19 +125746,33 @@
125410125746
125411125747
SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125412125748
Fts3Table *pTab, /* Fts3 table handle */
125413125749
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125414125750
){
125415
- return fts3SelectDocsize(pTab, SQL_SELECT_DOCTOTAL, 0, ppStmt);
125751
+ sqlite3_stmt *pStmt = 0;
125752
+ int rc;
125753
+ rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);
125754
+ if( rc==SQLITE_OK ){
125755
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
125756
+ if( sqlite3_step(pStmt)!=SQLITE_ROW
125757
+ || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB
125758
+ ){
125759
+ rc = sqlite3_reset(pStmt);
125760
+ if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125761
+ pStmt = 0;
125762
+ }
125763
+ }
125764
+ *ppStmt = pStmt;
125765
+ return rc;
125416125766
}
125417125767
125418125768
SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125419125769
Fts3Table *pTab, /* Fts3 table handle */
125420125770
sqlite3_int64 iDocid, /* Docid to read size data for */
125421125771
sqlite3_stmt **ppStmt /* OUT: Statement handle */
125422125772
){
125423
- return fts3SelectDocsize(pTab, SQL_SELECT_DOCSIZE, iDocid, ppStmt);
125773
+ return fts3SelectDocsize(pTab, iDocid, ppStmt);
125424125774
}
125425125775
125426125776
/*
125427125777
** Similar to fts3SqlStmt(). Except, after binding the parameters in
125428125778
** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125484125834
}
125485125835
125486125836
return rc;
125487125837
}
125488125838
125839
+/*
125840
+** FTS maintains a separate indexes for each language-id (a 32-bit integer).
125841
+** Within each language id, a separate index is maintained to store the
125842
+** document terms, and each configured prefix size (configured the FTS
125843
+** "prefix=" option). And each index consists of multiple levels ("relative
125844
+** levels").
125845
+**
125846
+** All three of these values (the language id, the specific index and the
125847
+** level within the index) are encoded in 64-bit integer values stored
125848
+** in the %_segdir table on disk. This function is used to convert three
125849
+** separate component values into the single 64-bit integer value that
125850
+** can be used to query the %_segdir table.
125851
+**
125852
+** Specifically, each language-id/index combination is allocated 1024
125853
+** 64-bit integer level values ("absolute levels"). The main terms index
125854
+** for language-id 0 is allocate values 0-1023. The first prefix index
125855
+** (if any) for language-id 0 is allocated values 1024-2047. And so on.
125856
+** Language 1 indexes are allocated immediately following language 0.
125857
+**
125858
+** So, for a system with nPrefix prefix indexes configured, the block of
125859
+** absolute levels that corresponds to language-id iLangid and index
125860
+** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).
125861
+*/
125489125862
static sqlite3_int64 getAbsoluteLevel(
125490
- Fts3Table *p,
125491
- int iLangid,
125492
- int iIndex,
125493
- int iLevel
125863
+ Fts3Table *p, /* FTS3 table handle */
125864
+ int iLangid, /* Language id */
125865
+ int iIndex, /* Index in p->aIndex[] */
125866
+ int iLevel /* Level of segments */
125494125867
){
125868
+ sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
125495125869
assert( iLangid>=0 );
125496125870
assert( p->nIndex>0 );
125497125871
assert( iIndex>=0 && iIndex<p->nIndex );
125498
- return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel;
125872
+
125873
+ iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;
125874
+ return iBase + iLevel;
125499125875
}
125500
-
125501125876
125502125877
/*
125503125878
** Set *ppStmt to a statement handle that may be used to iterate through
125504125879
** all rows in the %_segdir table, from oldest to newest. If successful,
125505125880
** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125518125893
*/
125519125894
SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125520125895
Fts3Table *p, /* FTS3 table */
125521125896
int iLangid, /* Language being queried */
125522125897
int iIndex, /* Index for p->aIndex[] */
125523
- int iLevel, /* Level to select */
125898
+ int iLevel, /* Level to select (relative level) */
125524125899
sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125525125900
){
125526125901
int rc;
125527125902
sqlite3_stmt *pStmt = 0;
125528125903
@@ -125533,19 +125908,19 @@
125533125908
if( iLevel<0 ){
125534125909
/* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125535125910
rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125536125911
if( rc==SQLITE_OK ){
125537125912
sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125538
- sqlite3_bind_int(pStmt, 2,
125913
+ sqlite3_bind_int64(pStmt, 2,
125539125914
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125540125915
);
125541125916
}
125542125917
}else{
125543125918
/* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125544125919
rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125545125920
if( rc==SQLITE_OK ){
125546
- sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
125921
+ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
125547125922
}
125548125923
}
125549125924
*ppStmt = pStmt;
125550125925
return rc;
125551125926
}
@@ -126062,10 +126437,11 @@
126062126437
** full, merge all segments in level iLevel into a single iLevel+1
126063126438
** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126064126439
** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126065126440
*/
126066126441
if( iNext>=FTS3_MERGE_COUNT ){
126442
+ fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
126067126443
rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126068126444
*piIdx = 0;
126069126445
}else{
126070126446
*piIdx = iNext;
126071126447
}
@@ -126109,11 +126485,11 @@
126109126485
int *pnLoad /* OUT: Bytes actually loaded */
126110126486
){
126111126487
int rc; /* Return code */
126112126488
126113126489
/* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126114
- assert( pnBlob);
126490
+ assert( pnBlob );
126115126491
126116126492
if( p->pSegments ){
126117126493
rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126118126494
}else{
126119126495
if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126450126826
int nOvfl = 0;
126451126827
int ii;
126452126828
int rc = SQLITE_OK;
126453126829
int pgsz = p->nPgsz;
126454126830
126455
- assert( p->bHasStat );
126831
+ assert( p->bFts4 );
126456126832
assert( pgsz>0 );
126457126833
126458126834
for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126459126835
Fts3SegReader *pReader = pMsr->apSegment[ii];
126460126836
if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
126807127183
sqlite3_step(pStmt);
126808127184
rc = sqlite3_reset(pStmt);
126809127185
}
126810127186
return rc;
126811127187
}
127188
+
127189
+/*
127190
+** Find the largest relative level number in the table. If successful, set
127191
+** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
127192
+** set *pnMax to zero and return an SQLite error code.
127193
+*/
127194
+SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){
127195
+ int rc;
127196
+ int mxLevel = 0;
127197
+ sqlite3_stmt *pStmt = 0;
127198
+
127199
+ rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
127200
+ if( rc==SQLITE_OK ){
127201
+ if( SQLITE_ROW==sqlite3_step(pStmt) ){
127202
+ mxLevel = sqlite3_column_int(pStmt, 0);
127203
+ }
127204
+ rc = sqlite3_reset(pStmt);
127205
+ }
127206
+ *pnMax = mxLevel;
127207
+ return rc;
127208
+}
126812127209
126813127210
/*
126814127211
** Insert a record into the %_segdir table.
126815127212
*/
126816127213
static int fts3WriteSegdir(
126817127214
Fts3Table *p, /* Virtual table handle */
126818
- int iLevel, /* Value for "level" field */
127215
+ sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */
126819127216
int iIdx, /* Value for "idx" field */
126820127217
sqlite3_int64 iStartBlock, /* Value for "start_block" field */
126821127218
sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
126822127219
sqlite3_int64 iEndBlock, /* Value for "end_block" field */
126823127220
char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
126824127221
int nRoot /* Number of bytes in buffer zRoot */
126825127222
){
126826127223
sqlite3_stmt *pStmt;
126827127224
int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
126828127225
if( rc==SQLITE_OK ){
126829
- sqlite3_bind_int(pStmt, 1, iLevel);
127226
+ sqlite3_bind_int64(pStmt, 1, iLevel);
126830127227
sqlite3_bind_int(pStmt, 2, iIdx);
126831127228
sqlite3_bind_int64(pStmt, 3, iStartBlock);
126832127229
sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
126833127230
sqlite3_bind_int64(pStmt, 5, iEndBlock);
126834127231
sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127124127521
int rc;
127125127522
127126127523
/* The current leaf node is full. Write it out to the database. */
127127127524
rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127128127525
if( rc!=SQLITE_OK ) return rc;
127526
+ p->nLeafAdd++;
127129127527
127130127528
/* Add the current term to the interior node tree. The term added to
127131127529
** the interior tree must:
127132127530
**
127133127531
** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127207127605
** returned. Otherwise, an SQLite error code.
127208127606
*/
127209127607
static int fts3SegWriterFlush(
127210127608
Fts3Table *p, /* Virtual table handle */
127211127609
SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127212
- int iLevel, /* Value for 'level' column of %_segdir */
127610
+ sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */
127213127611
int iIdx /* Value for 'idx' column of %_segdir */
127214127612
){
127215127613
int rc; /* Return code */
127216127614
if( pWriter->pTree ){
127217127615
sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127232127630
}else{
127233127631
/* The entire tree fits on the root node. Write it to the segdir table. */
127234127632
rc = fts3WriteSegdir(
127235127633
p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127236127634
}
127635
+ p->nLeafAdd++;
127237127636
return rc;
127238127637
}
127239127638
127240127639
/*
127241127640
** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127289127688
*/
127290127689
static int fts3SegmentMaxLevel(
127291127690
Fts3Table *p,
127292127691
int iLangid,
127293127692
int iIndex,
127294
- int *pnMax
127693
+ sqlite3_int64 *pnMax
127295127694
){
127296127695
sqlite3_stmt *pStmt;
127297127696
int rc;
127298127697
assert( iIndex>=0 && iIndex<p->nIndex );
127299127698
@@ -127303,19 +127702,42 @@
127303127702
**
127304127703
** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127305127704
*/
127306127705
rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127307127706
if( rc!=SQLITE_OK ) return rc;
127308
- sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127309
- sqlite3_bind_int(pStmt, 2,
127707
+ sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127708
+ sqlite3_bind_int64(pStmt, 2,
127310127709
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127311127710
);
127312127711
if( SQLITE_ROW==sqlite3_step(pStmt) ){
127313
- *pnMax = sqlite3_column_int(pStmt, 0);
127712
+ *pnMax = sqlite3_column_int64(pStmt, 0);
127314127713
}
127315127714
return sqlite3_reset(pStmt);
127316127715
}
127716
+
127717
+/*
127718
+** Delete all entries in the %_segments table associated with the segment
127719
+** opened with seg-reader pSeg. This function does not affect the contents
127720
+** of the %_segdir table.
127721
+*/
127722
+static int fts3DeleteSegment(
127723
+ Fts3Table *p, /* FTS table handle */
127724
+ Fts3SegReader *pSeg /* Segment to delete */
127725
+){
127726
+ int rc = SQLITE_OK; /* Return code */
127727
+ if( pSeg->iStartBlock ){
127728
+ sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127729
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127730
+ if( rc==SQLITE_OK ){
127731
+ sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);
127732
+ sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);
127733
+ sqlite3_step(pDelete);
127734
+ rc = sqlite3_reset(pDelete);
127735
+ }
127736
+ }
127737
+ return rc;
127738
+}
127317127739
127318127740
/*
127319127741
** This function is used after merging multiple segments into a single large
127320127742
** segment to delete the old, now redundant, segment b-trees. Specifically,
127321127743
** it:
@@ -127335,41 +127757,36 @@
127335127757
int iIndex, /* Index for p->aIndex */
127336127758
int iLevel, /* Level of %_segdir entries to delete */
127337127759
Fts3SegReader **apSegment, /* Array of SegReader objects */
127338127760
int nReader /* Size of array apSegment */
127339127761
){
127340
- int rc; /* Return Code */
127762
+ int rc = SQLITE_OK; /* Return Code */
127341127763
int i; /* Iterator variable */
127342
- sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127764
+ sqlite3_stmt *pDelete = 0; /* SQL statement to delete rows */
127343127765
127344
- rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127345127766
for(i=0; rc==SQLITE_OK && i<nReader; i++){
127346
- Fts3SegReader *pSegment = apSegment[i];
127347
- if( pSegment->iStartBlock ){
127348
- sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock);
127349
- sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock);
127350
- sqlite3_step(pDelete);
127351
- rc = sqlite3_reset(pDelete);
127352
- }
127767
+ rc = fts3DeleteSegment(p, apSegment[i]);
127353127768
}
127354127769
if( rc!=SQLITE_OK ){
127355127770
return rc;
127356127771
}
127357127772
127358127773
assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127359127774
if( iLevel==FTS3_SEGCURSOR_ALL ){
127360127775
rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127361127776
if( rc==SQLITE_OK ){
127362
- sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127363
- sqlite3_bind_int(pDelete, 2,
127777
+ sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127778
+ sqlite3_bind_int64(pDelete, 2,
127364127779
getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127365127780
);
127366127781
}
127367127782
}else{
127368127783
rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127369127784
if( rc==SQLITE_OK ){
127370
- sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
127785
+ sqlite3_bind_int64(
127786
+ pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)
127787
+ );
127371127788
}
127372127789
}
127373127790
127374127791
if( rc==SQLITE_OK ){
127375127792
sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
127842128259
int iIndex, /* Index in p->aIndex[] to merge */
127843128260
int iLevel /* Level to merge */
127844128261
){
127845128262
int rc; /* Return code */
127846128263
int iIdx = 0; /* Index of new segment */
127847
- int iNewLevel = 0; /* Level/index to create new segment at */
128264
+ sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */
127848128265
SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
127849128266
Fts3SegFilter filter; /* Segment term filter condition */
127850128267
Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
127851128268
int bIgnoreEmpty = 0; /* True to ignore empty segments */
127852128269
@@ -127921,15 +128338,32 @@
127921128338
** Flush the contents of pendingTerms to level 0 segments.
127922128339
*/
127923128340
SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
127924128341
int rc = SQLITE_OK;
127925128342
int i;
128343
+
127926128344
for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
127927128345
rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
127928128346
if( rc==SQLITE_DONE ) rc = SQLITE_OK;
127929128347
}
127930128348
sqlite3Fts3PendingTermsClear(p);
128349
+
128350
+ /* Determine the auto-incr-merge setting if unknown. If enabled,
128351
+ ** estimate the number of leaf blocks of content to be written
128352
+ */
128353
+ if( rc==SQLITE_OK && p->bHasStat
128354
+ && p->bAutoincrmerge==0xff && p->nLeafAdd>0
128355
+ ){
128356
+ sqlite3_stmt *pStmt = 0;
128357
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128358
+ if( rc==SQLITE_OK ){
128359
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
128360
+ rc = sqlite3_step(pStmt);
128361
+ p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
128362
+ rc = sqlite3_reset(pStmt);
128363
+ }
128364
+ }
127931128365
return rc;
127932128366
}
127933128367
127934128368
/*
127935128369
** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128036128470
if( a==0 ){
128037128471
*pRC = SQLITE_NOMEM;
128038128472
return;
128039128473
}
128040128474
pBlob = (char*)&a[nStat];
128041
- rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0);
128475
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128042128476
if( rc ){
128043128477
sqlite3_free(a);
128044128478
*pRC = rc;
128045128479
return;
128046128480
}
128481
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128047128482
if( sqlite3_step(pStmt)==SQLITE_ROW ){
128048128483
fts3DecodeIntArray(nStat, a,
128049128484
sqlite3_column_blob(pStmt, 0),
128050128485
sqlite3_column_bytes(pStmt, 0));
128051128486
}else{
@@ -128065,17 +128500,18 @@
128065128500
x = x + aSzIns[i] - aSzDel[i];
128066128501
}
128067128502
a[i+1] = x;
128068128503
}
128069128504
fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128070
- rc = fts3SqlStmt(p, SQL_REPLACE_DOCTOTAL, &pStmt, 0);
128505
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
128071128506
if( rc ){
128072128507
sqlite3_free(a);
128073128508
*pRC = rc;
128074128509
return;
128075128510
}
128076
- sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
128511
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128512
+ sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);
128077128513
sqlite3_step(pStmt);
128078128514
*pRC = sqlite3_reset(pStmt);
128079128515
sqlite3_free(a);
128080128516
}
128081128517
@@ -128176,11 +128612,11 @@
128176128612
for(iCol=0; iCol<=p->nColumn; iCol++){
128177128613
aSzIns[iCol] += aSz[iCol];
128178128614
}
128179128615
}
128180128616
}
128181
- if( p->bHasStat ){
128617
+ if( p->bFts4 ){
128182128618
fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128183128619
}
128184128620
sqlite3_free(aSz);
128185128621
128186128622
if( pStmt ){
@@ -128192,10 +128628,1692 @@
128192128628
}
128193128629
128194128630
return rc;
128195128631
}
128196128632
128633
+
128634
+/*
128635
+** This function opens a cursor used to read the input data for an
128636
+** incremental merge operation. Specifically, it opens a cursor to scan
128637
+** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute
128638
+** level iAbsLevel.
128639
+*/
128640
+static int fts3IncrmergeCsr(
128641
+ Fts3Table *p, /* FTS3 table handle */
128642
+ sqlite3_int64 iAbsLevel, /* Absolute level to open */
128643
+ int nSeg, /* Number of segments to merge */
128644
+ Fts3MultiSegReader *pCsr /* Cursor object to populate */
128645
+){
128646
+ int rc; /* Return Code */
128647
+ sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */
128648
+ int nByte; /* Bytes allocated at pCsr->apSegment[] */
128649
+
128650
+ /* Allocate space for the Fts3MultiSegReader.aCsr[] array */
128651
+ memset(pCsr, 0, sizeof(*pCsr));
128652
+ nByte = sizeof(Fts3SegReader *) * nSeg;
128653
+ pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);
128654
+
128655
+ if( pCsr->apSegment==0 ){
128656
+ rc = SQLITE_NOMEM;
128657
+ }else{
128658
+ memset(pCsr->apSegment, 0, nByte);
128659
+ rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
128660
+ }
128661
+ if( rc==SQLITE_OK ){
128662
+ int i;
128663
+ int rc2;
128664
+ sqlite3_bind_int64(pStmt, 1, iAbsLevel);
128665
+ assert( pCsr->nSegment==0 );
128666
+ for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){
128667
+ rc = sqlite3Fts3SegReaderNew(i, 0,
128668
+ sqlite3_column_int64(pStmt, 1), /* segdir.start_block */
128669
+ sqlite3_column_int64(pStmt, 2), /* segdir.leaves_end_block */
128670
+ sqlite3_column_int64(pStmt, 3), /* segdir.end_block */
128671
+ sqlite3_column_blob(pStmt, 4), /* segdir.root */
128672
+ sqlite3_column_bytes(pStmt, 4), /* segdir.root */
128673
+ &pCsr->apSegment[i]
128674
+ );
128675
+ pCsr->nSegment++;
128676
+ }
128677
+ rc2 = sqlite3_reset(pStmt);
128678
+ if( rc==SQLITE_OK ) rc = rc2;
128679
+ }
128680
+
128681
+ return rc;
128682
+}
128683
+
128684
+typedef struct IncrmergeWriter IncrmergeWriter;
128685
+typedef struct NodeWriter NodeWriter;
128686
+typedef struct Blob Blob;
128687
+typedef struct NodeReader NodeReader;
128688
+
128689
+/*
128690
+** An instance of the following structure is used as a dynamic buffer
128691
+** to build up nodes or other blobs of data in.
128692
+**
128693
+** The function blobGrowBuffer() is used to extend the allocation.
128694
+*/
128695
+struct Blob {
128696
+ char *a; /* Pointer to allocation */
128697
+ int n; /* Number of valid bytes of data in a[] */
128698
+ int nAlloc; /* Allocated size of a[] (nAlloc>=n) */
128699
+};
128700
+
128701
+/*
128702
+** This structure is used to build up buffers containing segment b-tree
128703
+** nodes (blocks).
128704
+*/
128705
+struct NodeWriter {
128706
+ sqlite3_int64 iBlock; /* Current block id */
128707
+ Blob key; /* Last key written to the current block */
128708
+ Blob block; /* Current block image */
128709
+};
128710
+
128711
+/*
128712
+** An object of this type contains the state required to create or append
128713
+** to an appendable b-tree segment.
128714
+*/
128715
+struct IncrmergeWriter {
128716
+ int nLeafEst; /* Space allocated for leaf blocks */
128717
+ int nWork; /* Number of leaf pages flushed */
128718
+ sqlite3_int64 iAbsLevel; /* Absolute level of input segments */
128719
+ int iIdx; /* Index of *output* segment in iAbsLevel+1 */
128720
+ sqlite3_int64 iStart; /* Block number of first allocated block */
128721
+ sqlite3_int64 iEnd; /* Block number of last allocated block */
128722
+ NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];
128723
+};
128724
+
128725
+/*
128726
+** An object of the following type is used to read data from a single
128727
+** FTS segment node. See the following functions:
128728
+**
128729
+** nodeReaderInit()
128730
+** nodeReaderNext()
128731
+** nodeReaderRelease()
128732
+*/
128733
+struct NodeReader {
128734
+ const char *aNode;
128735
+ int nNode;
128736
+ int iOff; /* Current offset within aNode[] */
128737
+
128738
+ /* Output variables. Containing the current node entry. */
128739
+ sqlite3_int64 iChild; /* Pointer to child node */
128740
+ Blob term; /* Current term */
128741
+ const char *aDoclist; /* Pointer to doclist */
128742
+ int nDoclist; /* Size of doclist in bytes */
128743
+};
128744
+
128745
+/*
128746
+** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
128747
+** Otherwise, if the allocation at pBlob->a is not already at least nMin
128748
+** bytes in size, extend (realloc) it to be so.
128749
+**
128750
+** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a
128751
+** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc
128752
+** to reflect the new size of the pBlob->a[] buffer.
128753
+*/
128754
+static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){
128755
+ if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){
128756
+ int nAlloc = nMin;
128757
+ char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);
128758
+ if( a ){
128759
+ pBlob->nAlloc = nAlloc;
128760
+ pBlob->a = a;
128761
+ }else{
128762
+ *pRc = SQLITE_NOMEM;
128763
+ }
128764
+ }
128765
+}
128766
+
128767
+/*
128768
+** Attempt to advance the node-reader object passed as the first argument to
128769
+** the next entry on the node.
128770
+**
128771
+** Return an error code if an error occurs (SQLITE_NOMEM is possible).
128772
+** Otherwise return SQLITE_OK. If there is no next entry on the node
128773
+** (e.g. because the current entry is the last) set NodeReader->aNode to
128774
+** NULL to indicate EOF. Otherwise, populate the NodeReader structure output
128775
+** variables for the new entry.
128776
+*/
128777
+static int nodeReaderNext(NodeReader *p){
128778
+ int bFirst = (p->term.n==0); /* True for first term on the node */
128779
+ int nPrefix = 0; /* Bytes to copy from previous term */
128780
+ int nSuffix = 0; /* Bytes to append to the prefix */
128781
+ int rc = SQLITE_OK; /* Return code */
128782
+
128783
+ assert( p->aNode );
128784
+ if( p->iChild && bFirst==0 ) p->iChild++;
128785
+ if( p->iOff>=p->nNode ){
128786
+ /* EOF */
128787
+ p->aNode = 0;
128788
+ }else{
128789
+ if( bFirst==0 ){
128790
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
128791
+ }
128792
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
128793
+
128794
+ blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
128795
+ if( rc==SQLITE_OK ){
128796
+ memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
128797
+ p->term.n = nPrefix+nSuffix;
128798
+ p->iOff += nSuffix;
128799
+ if( p->iChild==0 ){
128800
+ p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
128801
+ p->aDoclist = &p->aNode[p->iOff];
128802
+ p->iOff += p->nDoclist;
128803
+ }
128804
+ }
128805
+ }
128806
+
128807
+ assert( p->iOff<=p->nNode );
128808
+
128809
+ return rc;
128810
+}
128811
+
128812
+/*
128813
+** Release all dynamic resources held by node-reader object *p.
128814
+*/
128815
+static void nodeReaderRelease(NodeReader *p){
128816
+ sqlite3_free(p->term.a);
128817
+}
128818
+
128819
+/*
128820
+** Initialize a node-reader object to read the node in buffer aNode/nNode.
128821
+**
128822
+** If successful, SQLITE_OK is returned and the NodeReader object set to
128823
+** point to the first entry on the node (if any). Otherwise, an SQLite
128824
+** error code is returned.
128825
+*/
128826
+static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){
128827
+ memset(p, 0, sizeof(NodeReader));
128828
+ p->aNode = aNode;
128829
+ p->nNode = nNode;
128830
+
128831
+ /* Figure out if this is a leaf or an internal node. */
128832
+ if( p->aNode[0] ){
128833
+ /* An internal node. */
128834
+ p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);
128835
+ }else{
128836
+ p->iOff = 1;
128837
+ }
128838
+
128839
+ return nodeReaderNext(p);
128840
+}
128841
+
128842
+/*
128843
+** This function is called while writing an FTS segment each time a leaf o
128844
+** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed
128845
+** to be greater than the largest key on the node just written, but smaller
128846
+** than or equal to the first key that will be written to the next leaf
128847
+** node.
128848
+**
128849
+** The block id of the leaf node just written to disk may be found in
128850
+** (pWriter->aNodeWriter[0].iBlock) when this function is called.
128851
+*/
128852
+static int fts3IncrmergePush(
128853
+ Fts3Table *p, /* Fts3 table handle */
128854
+ IncrmergeWriter *pWriter, /* Writer object */
128855
+ const char *zTerm, /* Term to write to internal node */
128856
+ int nTerm /* Bytes at zTerm */
128857
+){
128858
+ sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
128859
+ int iLayer;
128860
+
128861
+ assert( nTerm>0 );
128862
+ for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){
128863
+ sqlite3_int64 iNextPtr = 0;
128864
+ NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
128865
+ int rc = SQLITE_OK;
128866
+ int nPrefix;
128867
+ int nSuffix;
128868
+ int nSpace;
128869
+
128870
+ /* Figure out how much space the key will consume if it is written to
128871
+ ** the current node of layer iLayer. Due to the prefix compression,
128872
+ ** the space required changes depending on which node the key is to
128873
+ ** be added to. */
128874
+ nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
128875
+ nSuffix = nTerm - nPrefix;
128876
+ nSpace = sqlite3Fts3VarintLen(nPrefix);
128877
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
128878
+
128879
+ if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
128880
+ /* If the current node of layer iLayer contains zero keys, or if adding
128881
+ ** the key to it will not cause it to grow to larger than nNodeSize
128882
+ ** bytes in size, write the key here. */
128883
+
128884
+ Blob *pBlk = &pNode->block;
128885
+ if( pBlk->n==0 ){
128886
+ blobGrowBuffer(pBlk, p->nNodeSize, &rc);
128887
+ if( rc==SQLITE_OK ){
128888
+ pBlk->a[0] = (char)iLayer;
128889
+ pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);
128890
+ }
128891
+ }
128892
+ blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);
128893
+ blobGrowBuffer(&pNode->key, nTerm, &rc);
128894
+
128895
+ if( rc==SQLITE_OK ){
128896
+ if( pNode->key.n ){
128897
+ pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);
128898
+ }
128899
+ pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);
128900
+ memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);
128901
+ pBlk->n += nSuffix;
128902
+
128903
+ memcpy(pNode->key.a, zTerm, nTerm);
128904
+ pNode->key.n = nTerm;
128905
+ }
128906
+ }else{
128907
+ /* Otherwise, flush the the current node of layer iLayer to disk.
128908
+ ** Then allocate a new, empty sibling node. The key will be written
128909
+ ** into the parent of this node. */
128910
+ rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
128911
+
128912
+ assert( pNode->block.nAlloc>=p->nNodeSize );
128913
+ pNode->block.a[0] = (char)iLayer;
128914
+ pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);
128915
+
128916
+ iNextPtr = pNode->iBlock;
128917
+ pNode->iBlock++;
128918
+ pNode->key.n = 0;
128919
+ }
128920
+
128921
+ if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;
128922
+ iPtr = iNextPtr;
128923
+ }
128924
+
128925
+ assert( 0 );
128926
+ return 0;
128927
+}
128928
+
128929
+/*
128930
+** Append a term and (optionally) doclist to the FTS segment node currently
128931
+** stored in blob *pNode. The node need not contain any terms, but the
128932
+** header must be written before this function is called.
128933
+**
128934
+** A node header is a single 0x00 byte for a leaf node, or a height varint
128935
+** followed by the left-hand-child varint for an internal node.
128936
+**
128937
+** The term to be appended is passed via arguments zTerm/nTerm. For a
128938
+** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal
128939
+** node, both aDoclist and nDoclist must be passed 0.
128940
+**
128941
+** If the size of the value in blob pPrev is zero, then this is the first
128942
+** term written to the node. Otherwise, pPrev contains a copy of the
128943
+** previous term. Before this function returns, it is updated to contain a
128944
+** copy of zTerm/nTerm.
128945
+**
128946
+** It is assumed that the buffer associated with pNode is already large
128947
+** enough to accommodate the new entry. The buffer associated with pPrev
128948
+** is extended by this function if requrired.
128949
+**
128950
+** If an error (i.e. OOM condition) occurs, an SQLite error code is
128951
+** returned. Otherwise, SQLITE_OK.
128952
+*/
128953
+static int fts3AppendToNode(
128954
+ Blob *pNode, /* Current node image to append to */
128955
+ Blob *pPrev, /* Buffer containing previous term written */
128956
+ const char *zTerm, /* New term to write */
128957
+ int nTerm, /* Size of zTerm in bytes */
128958
+ const char *aDoclist, /* Doclist (or NULL) to write */
128959
+ int nDoclist /* Size of aDoclist in bytes */
128960
+){
128961
+ int rc = SQLITE_OK; /* Return code */
128962
+ int bFirst = (pPrev->n==0); /* True if this is the first term written */
128963
+ int nPrefix; /* Size of term prefix in bytes */
128964
+ int nSuffix; /* Size of term suffix in bytes */
128965
+
128966
+ /* Node must have already been started. There must be a doclist for a
128967
+ ** leaf node, and there must not be a doclist for an internal node. */
128968
+ assert( pNode->n>0 );
128969
+ assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
128970
+
128971
+ blobGrowBuffer(pPrev, nTerm, &rc);
128972
+ if( rc!=SQLITE_OK ) return rc;
128973
+
128974
+ nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
128975
+ nSuffix = nTerm - nPrefix;
128976
+ memcpy(pPrev->a, zTerm, nTerm);
128977
+ pPrev->n = nTerm;
128978
+
128979
+ if( bFirst==0 ){
128980
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
128981
+ }
128982
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);
128983
+ memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);
128984
+ pNode->n += nSuffix;
128985
+
128986
+ if( aDoclist ){
128987
+ pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);
128988
+ memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);
128989
+ pNode->n += nDoclist;
128990
+ }
128991
+
128992
+ assert( pNode->n<=pNode->nAlloc );
128993
+
128994
+ return SQLITE_OK;
128995
+}
128996
+
128997
+/*
128998
+** Append the current term and doclist pointed to by cursor pCsr to the
128999
+** appendable b-tree segment opened for writing by pWriter.
129000
+**
129001
+** Return SQLITE_OK if successful, or an SQLite error code otherwise.
129002
+*/
129003
+static int fts3IncrmergeAppend(
129004
+ Fts3Table *p, /* Fts3 table handle */
129005
+ IncrmergeWriter *pWriter, /* Writer object */
129006
+ Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */
129007
+){
129008
+ const char *zTerm = pCsr->zTerm;
129009
+ int nTerm = pCsr->nTerm;
129010
+ const char *aDoclist = pCsr->aDoclist;
129011
+ int nDoclist = pCsr->nDoclist;
129012
+ int rc = SQLITE_OK; /* Return code */
129013
+ int nSpace; /* Total space in bytes required on leaf */
129014
+ int nPrefix; /* Size of prefix shared with previous term */
129015
+ int nSuffix; /* Size of suffix (nTerm - nPrefix) */
129016
+ NodeWriter *pLeaf; /* Object used to write leaf nodes */
129017
+
129018
+ pLeaf = &pWriter->aNodeWriter[0];
129019
+ nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);
129020
+ nSuffix = nTerm - nPrefix;
129021
+
129022
+ nSpace = sqlite3Fts3VarintLen(nPrefix);
129023
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129024
+ nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129025
+
129026
+ /* If the current block is not empty, and if adding this term/doclist
129027
+ ** to the current block would make it larger than Fts3Table.nNodeSize
129028
+ ** bytes, write this block out to the database. */
129029
+ if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){
129030
+ rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
129031
+ pWriter->nWork++;
129032
+
129033
+ /* Add the current term to the parent node. The term added to the
129034
+ ** parent must:
129035
+ **
129036
+ ** a) be greater than the largest term on the leaf node just written
129037
+ ** to the database (still available in pLeaf->key), and
129038
+ **
129039
+ ** b) be less than or equal to the term about to be added to the new
129040
+ ** leaf node (zTerm/nTerm).
129041
+ **
129042
+ ** In other words, it must be the prefix of zTerm 1 byte longer than
129043
+ ** the common prefix (if any) of zTerm and pWriter->zTerm.
129044
+ */
129045
+ if( rc==SQLITE_OK ){
129046
+ rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
129047
+ }
129048
+
129049
+ /* Advance to the next output block */
129050
+ pLeaf->iBlock++;
129051
+ pLeaf->key.n = 0;
129052
+ pLeaf->block.n = 0;
129053
+
129054
+ nPrefix = 0;
129055
+ nSuffix = nTerm;
129056
+ nSpace = 1;
129057
+ nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129058
+ nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129059
+ }
129060
+
129061
+ blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);
129062
+
129063
+ if( rc==SQLITE_OK ){
129064
+ if( pLeaf->block.n==0 ){
129065
+ pLeaf->block.n = 1;
129066
+ pLeaf->block.a[0] = '\0';
129067
+ }
129068
+ rc = fts3AppendToNode(
129069
+ &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist
129070
+ );
129071
+ }
129072
+
129073
+ return rc;
129074
+}
129075
+
129076
+/*
129077
+** This function is called to release all dynamic resources held by the
129078
+** merge-writer object pWriter, and if no error has occurred, to flush
129079
+** all outstanding node buffers held by pWriter to disk.
129080
+**
129081
+** If *pRc is not SQLITE_OK when this function is called, then no attempt
129082
+** is made to write any data to disk. Instead, this function serves only
129083
+** to release outstanding resources.
129084
+**
129085
+** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while
129086
+** flushing buffers to disk, *pRc is set to an SQLite error code before
129087
+** returning.
129088
+*/
129089
+static void fts3IncrmergeRelease(
129090
+ Fts3Table *p, /* FTS3 table handle */
129091
+ IncrmergeWriter *pWriter, /* Merge-writer object */
129092
+ int *pRc /* IN/OUT: Error code */
129093
+){
129094
+ int i; /* Used to iterate through non-root layers */
129095
+ int iRoot; /* Index of root in pWriter->aNodeWriter */
129096
+ NodeWriter *pRoot; /* NodeWriter for root node */
129097
+ int rc = *pRc; /* Error code */
129098
+
129099
+ /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment
129100
+ ** root node. If the segment fits entirely on a single leaf node, iRoot
129101
+ ** will be set to 0. If the root node is the parent of the leaves, iRoot
129102
+ ** will be 1. And so on. */
129103
+ for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){
129104
+ NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
129105
+ if( pNode->block.n>0 ) break;
129106
+ assert( *pRc || pNode->block.nAlloc==0 );
129107
+ assert( *pRc || pNode->key.nAlloc==0 );
129108
+ sqlite3_free(pNode->block.a);
129109
+ sqlite3_free(pNode->key.a);
129110
+ }
129111
+
129112
+ /* Empty output segment. This is a no-op. */
129113
+ if( iRoot<0 ) return;
129114
+
129115
+ /* The entire output segment fits on a single node. Normally, this means
129116
+ ** the node would be stored as a blob in the "root" column of the %_segdir
129117
+ ** table. However, this is not permitted in this case. The problem is that
129118
+ ** space has already been reserved in the %_segments table, and so the
129119
+ ** start_block and end_block fields of the %_segdir table must be populated.
129120
+ ** And, by design or by accident, released versions of FTS cannot handle
129121
+ ** segments that fit entirely on the root node with start_block!=0.
129122
+ **
129123
+ ** Instead, create a synthetic root node that contains nothing but a
129124
+ ** pointer to the single content node. So that the segment consists of a
129125
+ ** single leaf and a single interior (root) node.
129126
+ **
129127
+ ** Todo: Better might be to defer allocating space in the %_segments
129128
+ ** table until we are sure it is needed.
129129
+ */
129130
+ if( iRoot==0 ){
129131
+ Blob *pBlock = &pWriter->aNodeWriter[1].block;
129132
+ blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);
129133
+ if( rc==SQLITE_OK ){
129134
+ pBlock->a[0] = 0x01;
129135
+ pBlock->n = 1 + sqlite3Fts3PutVarint(
129136
+ &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
129137
+ );
129138
+ }
129139
+ iRoot = 1;
129140
+ }
129141
+ pRoot = &pWriter->aNodeWriter[iRoot];
129142
+
129143
+ /* Flush all currently outstanding nodes to disk. */
129144
+ for(i=0; i<iRoot; i++){
129145
+ NodeWriter *pNode = &pWriter->aNodeWriter[i];
129146
+ if( pNode->block.n>0 && rc==SQLITE_OK ){
129147
+ rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
129148
+ }
129149
+ sqlite3_free(pNode->block.a);
129150
+ sqlite3_free(pNode->key.a);
129151
+ }
129152
+
129153
+ /* Write the %_segdir record. */
129154
+ if( rc==SQLITE_OK ){
129155
+ rc = fts3WriteSegdir(p,
129156
+ pWriter->iAbsLevel+1, /* level */
129157
+ pWriter->iIdx, /* idx */
129158
+ pWriter->iStart, /* start_block */
129159
+ pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
129160
+ pWriter->iEnd, /* end_block */
129161
+ pRoot->block.a, pRoot->block.n /* root */
129162
+ );
129163
+ }
129164
+ sqlite3_free(pRoot->block.a);
129165
+ sqlite3_free(pRoot->key.a);
129166
+
129167
+ *pRc = rc;
129168
+}
129169
+
129170
+/*
129171
+** Compare the term in buffer zLhs (size in bytes nLhs) with that in
129172
+** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of
129173
+** the other, it is considered to be smaller than the other.
129174
+**
129175
+** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve
129176
+** if it is greater.
129177
+*/
129178
+static int fts3TermCmp(
129179
+ const char *zLhs, int nLhs, /* LHS of comparison */
129180
+ const char *zRhs, int nRhs /* RHS of comparison */
129181
+){
129182
+ int nCmp = MIN(nLhs, nRhs);
129183
+ int res;
129184
+
129185
+ res = memcmp(zLhs, zRhs, nCmp);
129186
+ if( res==0 ) res = nLhs - nRhs;
129187
+
129188
+ return res;
129189
+}
129190
+
129191
+
129192
+/*
129193
+** Query to see if the entry in the %_segments table with blockid iEnd is
129194
+** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before
129195
+** returning. Otherwise, set *pbRes to 0.
129196
+**
129197
+** Or, if an error occurs while querying the database, return an SQLite
129198
+** error code. The final value of *pbRes is undefined in this case.
129199
+**
129200
+** This is used to test if a segment is an "appendable" segment. If it
129201
+** is, then a NULL entry has been inserted into the %_segments table
129202
+** with blockid %_segdir.end_block.
129203
+*/
129204
+static int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){
129205
+ int bRes = 0; /* Result to set *pbRes to */
129206
+ sqlite3_stmt *pCheck = 0; /* Statement to query database with */
129207
+ int rc; /* Return code */
129208
+
129209
+ rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
129210
+ if( rc==SQLITE_OK ){
129211
+ sqlite3_bind_int64(pCheck, 1, iEnd);
129212
+ if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
129213
+ rc = sqlite3_reset(pCheck);
129214
+ }
129215
+
129216
+ *pbRes = bRes;
129217
+ return rc;
129218
+}
129219
+
129220
+/*
129221
+** This function is called when initializing an incremental-merge operation.
129222
+** It checks if the existing segment with index value iIdx at absolute level
129223
+** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the
129224
+** merge-writer object *pWriter is initialized to write to it.
129225
+**
129226
+** An existing segment can be appended to by an incremental merge if:
129227
+**
129228
+** * It was initially created as an appendable segment (with all required
129229
+** space pre-allocated), and
129230
+**
129231
+** * The first key read from the input (arguments zKey and nKey) is
129232
+** greater than the largest key currently stored in the potential
129233
+** output segment.
129234
+*/
129235
+static int fts3IncrmergeLoad(
129236
+ Fts3Table *p, /* Fts3 table handle */
129237
+ sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129238
+ int iIdx, /* Index of candidate output segment */
129239
+ const char *zKey, /* First key to write */
129240
+ int nKey, /* Number of bytes in nKey */
129241
+ IncrmergeWriter *pWriter /* Populate this object */
129242
+){
129243
+ int rc; /* Return code */
129244
+ sqlite3_stmt *pSelect = 0; /* SELECT to read %_segdir entry */
129245
+
129246
+ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);
129247
+ if( rc==SQLITE_OK ){
129248
+ sqlite3_int64 iStart = 0; /* Value of %_segdir.start_block */
129249
+ sqlite3_int64 iLeafEnd = 0; /* Value of %_segdir.leaves_end_block */
129250
+ sqlite3_int64 iEnd = 0; /* Value of %_segdir.end_block */
129251
+ const char *aRoot = 0; /* Pointer to %_segdir.root buffer */
129252
+ int nRoot = 0; /* Size of aRoot[] in bytes */
129253
+ int rc2; /* Return code from sqlite3_reset() */
129254
+ int bAppendable = 0; /* Set to true if segment is appendable */
129255
+
129256
+ /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */
129257
+ sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);
129258
+ sqlite3_bind_int(pSelect, 2, iIdx);
129259
+ if( sqlite3_step(pSelect)==SQLITE_ROW ){
129260
+ iStart = sqlite3_column_int64(pSelect, 1);
129261
+ iLeafEnd = sqlite3_column_int64(pSelect, 2);
129262
+ iEnd = sqlite3_column_int64(pSelect, 3);
129263
+ nRoot = sqlite3_column_bytes(pSelect, 4);
129264
+ aRoot = sqlite3_column_blob(pSelect, 4);
129265
+ }else{
129266
+ return sqlite3_reset(pSelect);
129267
+ }
129268
+
129269
+ /* Check for the zero-length marker in the %_segments table */
129270
+ rc = fts3IsAppendable(p, iEnd, &bAppendable);
129271
+
129272
+ /* Check that zKey/nKey is larger than the largest key the candidate */
129273
+ if( rc==SQLITE_OK && bAppendable ){
129274
+ char *aLeaf = 0;
129275
+ int nLeaf = 0;
129276
+
129277
+ rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);
129278
+ if( rc==SQLITE_OK ){
129279
+ NodeReader reader;
129280
+ for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);
129281
+ rc==SQLITE_OK && reader.aNode;
129282
+ rc = nodeReaderNext(&reader)
129283
+ ){
129284
+ assert( reader.aNode );
129285
+ }
129286
+ if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){
129287
+ bAppendable = 0;
129288
+ }
129289
+ nodeReaderRelease(&reader);
129290
+ }
129291
+ sqlite3_free(aLeaf);
129292
+ }
129293
+
129294
+ if( rc==SQLITE_OK && bAppendable ){
129295
+ /* It is possible to append to this segment. Set up the IncrmergeWriter
129296
+ ** object to do so. */
129297
+ int i;
129298
+ int nHeight = (int)aRoot[0];
129299
+ NodeWriter *pNode;
129300
+
129301
+ pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
129302
+ pWriter->iStart = iStart;
129303
+ pWriter->iEnd = iEnd;
129304
+ pWriter->iAbsLevel = iAbsLevel;
129305
+ pWriter->iIdx = iIdx;
129306
+
129307
+ for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129308
+ pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129309
+ }
129310
+
129311
+ pNode = &pWriter->aNodeWriter[nHeight];
129312
+ pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
129313
+ blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
129314
+ if( rc==SQLITE_OK ){
129315
+ memcpy(pNode->block.a, aRoot, nRoot);
129316
+ pNode->block.n = nRoot;
129317
+ }
129318
+
129319
+ for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
129320
+ NodeReader reader;
129321
+ pNode = &pWriter->aNodeWriter[i];
129322
+
129323
+ rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
129324
+ while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
129325
+ blobGrowBuffer(&pNode->key, reader.term.n, &rc);
129326
+ if( rc==SQLITE_OK ){
129327
+ memcpy(pNode->key.a, reader.term.a, reader.term.n);
129328
+ pNode->key.n = reader.term.n;
129329
+ if( i>0 ){
129330
+ char *aBlock = 0;
129331
+ int nBlock = 0;
129332
+ pNode = &pWriter->aNodeWriter[i-1];
129333
+ pNode->iBlock = reader.iChild;
129334
+ rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
129335
+ blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
129336
+ if( rc==SQLITE_OK ){
129337
+ memcpy(pNode->block.a, aBlock, nBlock);
129338
+ pNode->block.n = nBlock;
129339
+ }
129340
+ sqlite3_free(aBlock);
129341
+ }
129342
+ }
129343
+ nodeReaderRelease(&reader);
129344
+ }
129345
+ }
129346
+
129347
+ rc2 = sqlite3_reset(pSelect);
129348
+ if( rc==SQLITE_OK ) rc = rc2;
129349
+ }
129350
+
129351
+ return rc;
129352
+}
129353
+
129354
+/*
129355
+** Determine the largest segment index value that exists within absolute
129356
+** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus
129357
+** one before returning SQLITE_OK. Or, if there are no segments at all
129358
+** within level iAbsLevel, set *piIdx to zero.
129359
+**
129360
+** If an error occurs, return an SQLite error code. The final value of
129361
+** *piIdx is undefined in this case.
129362
+*/
129363
+static int fts3IncrmergeOutputIdx(
129364
+ Fts3Table *p, /* FTS Table handle */
129365
+ sqlite3_int64 iAbsLevel, /* Absolute index of input segments */
129366
+ int *piIdx /* OUT: Next free index at iAbsLevel+1 */
129367
+){
129368
+ int rc;
129369
+ sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */
129370
+
129371
+ rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);
129372
+ if( rc==SQLITE_OK ){
129373
+ sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);
129374
+ sqlite3_step(pOutputIdx);
129375
+ *piIdx = sqlite3_column_int(pOutputIdx, 0);
129376
+ rc = sqlite3_reset(pOutputIdx);
129377
+ }
129378
+
129379
+ return rc;
129380
+}
129381
+
129382
+/*
129383
+** Allocate an appendable output segment on absolute level iAbsLevel+1
129384
+** with idx value iIdx.
129385
+**
129386
+** In the %_segdir table, a segment is defined by the values in three
129387
+** columns:
129388
+**
129389
+** start_block
129390
+** leaves_end_block
129391
+** end_block
129392
+**
129393
+** When an appendable segment is allocated, it is estimated that the
129394
+** maximum number of leaf blocks that may be required is the sum of the
129395
+** number of leaf blocks consumed by the input segments, plus the number
129396
+** of input segments, multiplied by two. This value is stored in stack
129397
+** variable nLeafEst.
129398
+**
129399
+** A total of 16*nLeafEst blocks are allocated when an appendable segment
129400
+** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous
129401
+** array of leaf nodes starts at the first block allocated. The array
129402
+** of interior nodes that are parents of the leaf nodes start at block
129403
+** (start_block + (1 + end_block - start_block) / 16). And so on.
129404
+**
129405
+** In the actual code below, the value "16" is replaced with the
129406
+** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.
129407
+*/
129408
+static int fts3IncrmergeWriter(
129409
+ Fts3Table *p, /* Fts3 table handle */
129410
+ sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129411
+ int iIdx, /* Index of new output segment */
129412
+ Fts3MultiSegReader *pCsr, /* Cursor that data will be read from */
129413
+ IncrmergeWriter *pWriter /* Populate this object */
129414
+){
129415
+ int rc; /* Return Code */
129416
+ int i; /* Iterator variable */
129417
+ int nLeafEst = 0; /* Blocks allocated for leaf nodes */
129418
+ sqlite3_stmt *pLeafEst = 0; /* SQL used to determine nLeafEst */
129419
+ sqlite3_stmt *pFirstBlock = 0; /* SQL used to determine first block */
129420
+
129421
+ /* Calculate nLeafEst. */
129422
+ rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);
129423
+ if( rc==SQLITE_OK ){
129424
+ sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);
129425
+ sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);
129426
+ if( SQLITE_ROW==sqlite3_step(pLeafEst) ){
129427
+ nLeafEst = sqlite3_column_int(pLeafEst, 0);
129428
+ }
129429
+ rc = sqlite3_reset(pLeafEst);
129430
+ }
129431
+ if( rc!=SQLITE_OK ) return rc;
129432
+
129433
+ /* Calculate the first block to use in the output segment */
129434
+ rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);
129435
+ if( rc==SQLITE_OK ){
129436
+ if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){
129437
+ pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
129438
+ pWriter->iEnd = pWriter->iStart - 1;
129439
+ pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
129440
+ }
129441
+ rc = sqlite3_reset(pFirstBlock);
129442
+ }
129443
+ if( rc!=SQLITE_OK ) return rc;
129444
+
129445
+ /* Insert the marker in the %_segments table to make sure nobody tries
129446
+ ** to steal the space just allocated. This is also used to identify
129447
+ ** appendable segments. */
129448
+ rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
129449
+ if( rc!=SQLITE_OK ) return rc;
129450
+
129451
+ pWriter->iAbsLevel = iAbsLevel;
129452
+ pWriter->nLeafEst = nLeafEst;
129453
+ pWriter->iIdx = iIdx;
129454
+
129455
+ /* Set up the array of NodeWriter objects */
129456
+ for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129457
+ pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129458
+ }
129459
+ return SQLITE_OK;
129460
+}
129461
+
129462
+/*
129463
+** Remove an entry from the %_segdir table. This involves running the
129464
+** following two statements:
129465
+**
129466
+** DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx
129467
+** UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx
129468
+**
129469
+** The DELETE statement removes the specific %_segdir level. The UPDATE
129470
+** statement ensures that the remaining segments have contiguously allocated
129471
+** idx values.
129472
+*/
129473
+static int fts3RemoveSegdirEntry(
129474
+ Fts3Table *p, /* FTS3 table handle */
129475
+ sqlite3_int64 iAbsLevel, /* Absolute level to delete from */
129476
+ int iIdx /* Index of %_segdir entry to delete */
129477
+){
129478
+ int rc; /* Return code */
129479
+ sqlite3_stmt *pDelete = 0; /* DELETE statement */
129480
+
129481
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);
129482
+ if( rc==SQLITE_OK ){
129483
+ sqlite3_bind_int64(pDelete, 1, iAbsLevel);
129484
+ sqlite3_bind_int(pDelete, 2, iIdx);
129485
+ sqlite3_step(pDelete);
129486
+ rc = sqlite3_reset(pDelete);
129487
+ }
129488
+
129489
+ return rc;
129490
+}
129491
+
129492
+/*
129493
+** One or more segments have just been removed from absolute level iAbsLevel.
129494
+** Update the 'idx' values of the remaining segments in the level so that
129495
+** the idx values are a contiguous sequence starting from 0.
129496
+*/
129497
+static int fts3RepackSegdirLevel(
129498
+ Fts3Table *p, /* FTS3 table handle */
129499
+ sqlite3_int64 iAbsLevel /* Absolute level to repack */
129500
+){
129501
+ int rc; /* Return code */
129502
+ int *aIdx = 0; /* Array of remaining idx values */
129503
+ int nIdx = 0; /* Valid entries in aIdx[] */
129504
+ int nAlloc = 0; /* Allocated size of aIdx[] */
129505
+ int i; /* Iterator variable */
129506
+ sqlite3_stmt *pSelect = 0; /* Select statement to read idx values */
129507
+ sqlite3_stmt *pUpdate = 0; /* Update statement to modify idx values */
129508
+
129509
+ rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);
129510
+ if( rc==SQLITE_OK ){
129511
+ int rc2;
129512
+ sqlite3_bind_int64(pSelect, 1, iAbsLevel);
129513
+ while( SQLITE_ROW==sqlite3_step(pSelect) ){
129514
+ if( nIdx>=nAlloc ){
129515
+ int *aNew;
129516
+ nAlloc += 16;
129517
+ aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));
129518
+ if( !aNew ){
129519
+ rc = SQLITE_NOMEM;
129520
+ break;
129521
+ }
129522
+ aIdx = aNew;
129523
+ }
129524
+ aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);
129525
+ }
129526
+ rc2 = sqlite3_reset(pSelect);
129527
+ if( rc==SQLITE_OK ) rc = rc2;
129528
+ }
129529
+
129530
+ if( rc==SQLITE_OK ){
129531
+ rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);
129532
+ }
129533
+ if( rc==SQLITE_OK ){
129534
+ sqlite3_bind_int64(pUpdate, 2, iAbsLevel);
129535
+ }
129536
+
129537
+ assert( p->bIgnoreSavepoint==0 );
129538
+ p->bIgnoreSavepoint = 1;
129539
+ for(i=0; rc==SQLITE_OK && i<nIdx; i++){
129540
+ if( aIdx[i]!=i ){
129541
+ sqlite3_bind_int(pUpdate, 3, aIdx[i]);
129542
+ sqlite3_bind_int(pUpdate, 1, i);
129543
+ sqlite3_step(pUpdate);
129544
+ rc = sqlite3_reset(pUpdate);
129545
+ }
129546
+ }
129547
+ p->bIgnoreSavepoint = 0;
129548
+
129549
+ sqlite3_free(aIdx);
129550
+ return rc;
129551
+}
129552
+
129553
+static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){
129554
+ pNode->a[0] = (char)iHeight;
129555
+ if( iChild ){
129556
+ assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );
129557
+ pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);
129558
+ }else{
129559
+ assert( pNode->nAlloc>=1 );
129560
+ pNode->n = 1;
129561
+ }
129562
+}
129563
+
129564
+/*
129565
+** The first two arguments are a pointer to and the size of a segment b-tree
129566
+** node. The node may be a leaf or an internal node.
129567
+**
129568
+** This function creates a new node image in blob object *pNew by copying
129569
+** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)
129570
+** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.
129571
+*/
129572
+static int fts3TruncateNode(
129573
+ const char *aNode, /* Current node image */
129574
+ int nNode, /* Size of aNode in bytes */
129575
+ Blob *pNew, /* OUT: Write new node image here */
129576
+ const char *zTerm, /* Omit all terms smaller than this */
129577
+ int nTerm, /* Size of zTerm in bytes */
129578
+ sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
129579
+){
129580
+ NodeReader reader; /* Reader object */
129581
+ Blob prev = {0, 0, 0}; /* Previous term written to new node */
129582
+ int rc = SQLITE_OK; /* Return code */
129583
+ int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
129584
+
129585
+ /* Allocate required output space */
129586
+ blobGrowBuffer(pNew, nNode, &rc);
129587
+ if( rc!=SQLITE_OK ) return rc;
129588
+ pNew->n = 0;
129589
+
129590
+ /* Populate new node buffer */
129591
+ for(rc = nodeReaderInit(&reader, aNode, nNode);
129592
+ rc==SQLITE_OK && reader.aNode;
129593
+ rc = nodeReaderNext(&reader)
129594
+ ){
129595
+ if( pNew->n==0 ){
129596
+ int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);
129597
+ if( res<0 || (bLeaf==0 && res==0) ) continue;
129598
+ fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129599
+ *piBlock = reader.iChild;
129600
+ }
129601
+ rc = fts3AppendToNode(
129602
+ pNew, &prev, reader.term.a, reader.term.n,
129603
+ reader.aDoclist, reader.nDoclist
129604
+ );
129605
+ if( rc!=SQLITE_OK ) break;
129606
+ }
129607
+ if( pNew->n==0 ){
129608
+ fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129609
+ *piBlock = reader.iChild;
129610
+ }
129611
+ assert( pNew->n<=pNew->nAlloc );
129612
+
129613
+ nodeReaderRelease(&reader);
129614
+ sqlite3_free(prev.a);
129615
+ return rc;
129616
+}
129617
+
129618
+/*
129619
+** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute
129620
+** level iAbsLevel. This may involve deleting entries from the %_segments
129621
+** table, and modifying existing entries in both the %_segments and %_segdir
129622
+** tables.
129623
+**
129624
+** SQLITE_OK is returned if the segment is updated successfully. Or an
129625
+** SQLite error code otherwise.
129626
+*/
129627
+static int fts3TruncateSegment(
129628
+ Fts3Table *p, /* FTS3 table handle */
129629
+ sqlite3_int64 iAbsLevel, /* Absolute level of segment to modify */
129630
+ int iIdx, /* Index within level of segment to modify */
129631
+ const char *zTerm, /* Remove terms smaller than this */
129632
+ int nTerm /* Number of bytes in buffer zTerm */
129633
+){
129634
+ int rc = SQLITE_OK; /* Return code */
129635
+ Blob root = {0,0,0}; /* New root page image */
129636
+ Blob block = {0,0,0}; /* Buffer used for any other block */
129637
+ sqlite3_int64 iBlock = 0; /* Block id */
129638
+ sqlite3_int64 iNewStart = 0; /* New value for iStartBlock */
129639
+ sqlite3_int64 iOldStart = 0; /* Old value for iStartBlock */
129640
+ sqlite3_stmt *pFetch = 0; /* Statement used to fetch segdir */
129641
+
129642
+ rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);
129643
+ if( rc==SQLITE_OK ){
129644
+ int rc2; /* sqlite3_reset() return code */
129645
+ sqlite3_bind_int64(pFetch, 1, iAbsLevel);
129646
+ sqlite3_bind_int(pFetch, 2, iIdx);
129647
+ if( SQLITE_ROW==sqlite3_step(pFetch) ){
129648
+ const char *aRoot = sqlite3_column_blob(pFetch, 4);
129649
+ int nRoot = sqlite3_column_bytes(pFetch, 4);
129650
+ iOldStart = sqlite3_column_int64(pFetch, 1);
129651
+ rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);
129652
+ }
129653
+ rc2 = sqlite3_reset(pFetch);
129654
+ if( rc==SQLITE_OK ) rc = rc2;
129655
+ }
129656
+
129657
+ while( rc==SQLITE_OK && iBlock ){
129658
+ char *aBlock = 0;
129659
+ int nBlock = 0;
129660
+ iNewStart = iBlock;
129661
+
129662
+ rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);
129663
+ if( rc==SQLITE_OK ){
129664
+ rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);
129665
+ }
129666
+ if( rc==SQLITE_OK ){
129667
+ rc = fts3WriteSegment(p, iNewStart, block.a, block.n);
129668
+ }
129669
+ sqlite3_free(aBlock);
129670
+ }
129671
+
129672
+ /* Variable iNewStart now contains the first valid leaf node. */
129673
+ if( rc==SQLITE_OK && iNewStart ){
129674
+ sqlite3_stmt *pDel = 0;
129675
+ rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);
129676
+ if( rc==SQLITE_OK ){
129677
+ sqlite3_bind_int64(pDel, 1, iOldStart);
129678
+ sqlite3_bind_int64(pDel, 2, iNewStart-1);
129679
+ sqlite3_step(pDel);
129680
+ rc = sqlite3_reset(pDel);
129681
+ }
129682
+ }
129683
+
129684
+ if( rc==SQLITE_OK ){
129685
+ sqlite3_stmt *pChomp = 0;
129686
+ rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);
129687
+ if( rc==SQLITE_OK ){
129688
+ sqlite3_bind_int64(pChomp, 1, iNewStart);
129689
+ sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);
129690
+ sqlite3_bind_int64(pChomp, 3, iAbsLevel);
129691
+ sqlite3_bind_int(pChomp, 4, iIdx);
129692
+ sqlite3_step(pChomp);
129693
+ rc = sqlite3_reset(pChomp);
129694
+ }
129695
+ }
129696
+
129697
+ sqlite3_free(root.a);
129698
+ sqlite3_free(block.a);
129699
+ return rc;
129700
+}
129701
+
129702
+/*
129703
+** This function is called after an incrmental-merge operation has run to
129704
+** merge (or partially merge) two or more segments from absolute level
129705
+** iAbsLevel.
129706
+**
129707
+** Each input segment is either removed from the db completely (if all of
129708
+** its data was copied to the output segment by the incrmerge operation)
129709
+** or modified in place so that it no longer contains those entries that
129710
+** have been duplicated in the output segment.
129711
+*/
129712
+static int fts3IncrmergeChomp(
129713
+ Fts3Table *p, /* FTS table handle */
129714
+ sqlite3_int64 iAbsLevel, /* Absolute level containing segments */
129715
+ Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */
129716
+ int *pnRem /* Number of segments not deleted */
129717
+){
129718
+ int i;
129719
+ int nRem = 0;
129720
+ int rc = SQLITE_OK;
129721
+
129722
+ for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){
129723
+ Fts3SegReader *pSeg = 0;
129724
+ int j;
129725
+
129726
+ /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding
129727
+ ** somewhere in the pCsr->apSegment[] array. */
129728
+ for(j=0; ALWAYS(j<pCsr->nSegment); j++){
129729
+ pSeg = pCsr->apSegment[j];
129730
+ if( pSeg->iIdx==i ) break;
129731
+ }
129732
+ assert( j<pCsr->nSegment && pSeg->iIdx==i );
129733
+
129734
+ if( pSeg->aNode==0 ){
129735
+ /* Seg-reader is at EOF. Remove the entire input segment. */
129736
+ rc = fts3DeleteSegment(p, pSeg);
129737
+ if( rc==SQLITE_OK ){
129738
+ rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);
129739
+ }
129740
+ *pnRem = 0;
129741
+ }else{
129742
+ /* The incremental merge did not copy all the data from this
129743
+ ** segment to the upper level. The segment is modified in place
129744
+ ** so that it contains no keys smaller than zTerm/nTerm. */
129745
+ const char *zTerm = pSeg->zTerm;
129746
+ int nTerm = pSeg->nTerm;
129747
+ rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);
129748
+ nRem++;
129749
+ }
129750
+ }
129751
+
129752
+ if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){
129753
+ rc = fts3RepackSegdirLevel(p, iAbsLevel);
129754
+ }
129755
+
129756
+ *pnRem = nRem;
129757
+ return rc;
129758
+}
129759
+
129760
+/*
129761
+** Store an incr-merge hint in the database.
129762
+*/
129763
+static int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){
129764
+ sqlite3_stmt *pReplace = 0;
129765
+ int rc; /* Return code */
129766
+
129767
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
129768
+ if( rc==SQLITE_OK ){
129769
+ sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);
129770
+ sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);
129771
+ sqlite3_step(pReplace);
129772
+ rc = sqlite3_reset(pReplace);
129773
+ }
129774
+
129775
+ return rc;
129776
+}
129777
+
129778
+/*
129779
+** Load an incr-merge hint from the database. The incr-merge hint, if one
129780
+** exists, is stored in the rowid==1 row of the %_stat table.
129781
+**
129782
+** If successful, populate blob *pHint with the value read from the %_stat
129783
+** table and return SQLITE_OK. Otherwise, if an error occurs, return an
129784
+** SQLite error code.
129785
+*/
129786
+static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){
129787
+ sqlite3_stmt *pSelect = 0;
129788
+ int rc;
129789
+
129790
+ pHint->n = 0;
129791
+ rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
129792
+ if( rc==SQLITE_OK ){
129793
+ int rc2;
129794
+ sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
129795
+ if( SQLITE_ROW==sqlite3_step(pSelect) ){
129796
+ const char *aHint = sqlite3_column_blob(pSelect, 0);
129797
+ int nHint = sqlite3_column_bytes(pSelect, 0);
129798
+ if( aHint ){
129799
+ blobGrowBuffer(pHint, nHint, &rc);
129800
+ if( rc==SQLITE_OK ){
129801
+ memcpy(pHint->a, aHint, nHint);
129802
+ pHint->n = nHint;
129803
+ }
129804
+ }
129805
+ }
129806
+ rc2 = sqlite3_reset(pSelect);
129807
+ if( rc==SQLITE_OK ) rc = rc2;
129808
+ }
129809
+
129810
+ return rc;
129811
+}
129812
+
129813
+/*
129814
+** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
129815
+** Otherwise, append an entry to the hint stored in blob *pHint. Each entry
129816
+** consists of two varints, the absolute level number of the input segments
129817
+** and the number of input segments.
129818
+**
129819
+** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,
129820
+** set *pRc to an SQLite error code before returning.
129821
+*/
129822
+static void fts3IncrmergeHintPush(
129823
+ Blob *pHint, /* Hint blob to append to */
129824
+ i64 iAbsLevel, /* First varint to store in hint */
129825
+ int nInput, /* Second varint to store in hint */
129826
+ int *pRc /* IN/OUT: Error code */
129827
+){
129828
+ blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);
129829
+ if( *pRc==SQLITE_OK ){
129830
+ pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);
129831
+ pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);
129832
+ }
129833
+}
129834
+
129835
+/*
129836
+** Read the last entry (most recently pushed) from the hint blob *pHint
129837
+** and then remove the entry. Write the two values read to *piAbsLevel and
129838
+** *pnInput before returning.
129839
+**
129840
+** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does
129841
+** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.
129842
+*/
129843
+static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
129844
+ const int nHint = pHint->n;
129845
+ int i;
129846
+
129847
+ i = pHint->n-2;
129848
+ while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129849
+ while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129850
+
129851
+ pHint->n = i;
129852
+ i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
129853
+ i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
129854
+ if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
129855
+
129856
+ return SQLITE_OK;
129857
+}
129858
+
129859
+
129860
+/*
129861
+** Attempt an incremental merge that writes nMerge leaf blocks.
129862
+**
129863
+** Incremental merges happen nMin segments at a time. The two
129864
+** segments to be merged are the nMin oldest segments (the ones with
129865
+** the smallest indexes) in the highest level that contains at least
129866
+** nMin segments. Multiple merges might occur in an attempt to write the
129867
+** quota of nMerge leaf blocks.
129868
+*/
129869
+SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){
129870
+ int rc; /* Return code */
129871
+ int nRem = nMerge; /* Number of leaf pages yet to be written */
129872
+ Fts3MultiSegReader *pCsr; /* Cursor used to read input data */
129873
+ Fts3SegFilter *pFilter; /* Filter used with cursor pCsr */
129874
+ IncrmergeWriter *pWriter; /* Writer object */
129875
+ int nSeg = 0; /* Number of input segments */
129876
+ sqlite3_int64 iAbsLevel = 0; /* Absolute level number to work on */
129877
+ Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
129878
+ int bDirtyHint = 0; /* True if blob 'hint' has been modified */
129879
+
129880
+ /* Allocate space for the cursor, filter and writer objects */
129881
+ const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
129882
+ pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
129883
+ if( !pWriter ) return SQLITE_NOMEM;
129884
+ pFilter = (Fts3SegFilter *)&pWriter[1];
129885
+ pCsr = (Fts3MultiSegReader *)&pFilter[1];
129886
+
129887
+ rc = fts3IncrmergeHintLoad(p, &hint);
129888
+ while( rc==SQLITE_OK && nRem>0 ){
129889
+ const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;
129890
+ sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */
129891
+ int bUseHint = 0; /* True if attempting to append */
129892
+
129893
+ /* Search the %_segdir table for the absolute level with the smallest
129894
+ ** relative level number that contains at least nMin segments, if any.
129895
+ ** If one is found, set iAbsLevel to the absolute level number and
129896
+ ** nSeg to nMin. If no level with at least nMin segments can be found,
129897
+ ** set nSeg to -1.
129898
+ */
129899
+ rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);
129900
+ sqlite3_bind_int(pFindLevel, 1, nMin);
129901
+ if( sqlite3_step(pFindLevel)==SQLITE_ROW ){
129902
+ iAbsLevel = sqlite3_column_int64(pFindLevel, 0);
129903
+ nSeg = nMin;
129904
+ }else{
129905
+ nSeg = -1;
129906
+ }
129907
+ rc = sqlite3_reset(pFindLevel);
129908
+
129909
+ /* If the hint read from the %_stat table is not empty, check if the
129910
+ ** last entry in it specifies a relative level smaller than or equal
129911
+ ** to the level identified by the block above (if any). If so, this
129912
+ ** iteration of the loop will work on merging at the hinted level.
129913
+ */
129914
+ if( rc==SQLITE_OK && hint.n ){
129915
+ int nHint = hint.n;
129916
+ sqlite3_int64 iHintAbsLevel = 0; /* Hint level */
129917
+ int nHintSeg = 0; /* Hint number of segments */
129918
+
129919
+ rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);
129920
+ if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){
129921
+ iAbsLevel = iHintAbsLevel;
129922
+ nSeg = nHintSeg;
129923
+ bUseHint = 1;
129924
+ bDirtyHint = 1;
129925
+ }else{
129926
+ /* This undoes the effect of the HintPop() above - so that no entry
129927
+ ** is removed from the hint blob. */
129928
+ hint.n = nHint;
129929
+ }
129930
+ }
129931
+
129932
+ /* If nSeg is less that zero, then there is no level with at least
129933
+ ** nMin segments and no hint in the %_stat table. No work to do.
129934
+ ** Exit early in this case. */
129935
+ if( nSeg<0 ) break;
129936
+
129937
+ /* Open a cursor to iterate through the contents of the oldest nSeg
129938
+ ** indexes of absolute level iAbsLevel. If this cursor is opened using
129939
+ ** the 'hint' parameters, it is possible that there are less than nSeg
129940
+ ** segments available in level iAbsLevel. In this case, no work is
129941
+ ** done on iAbsLevel - fall through to the next iteration of the loop
129942
+ ** to start work on some other level. */
129943
+ memset(pWriter, 0, nAlloc);
129944
+ pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;
129945
+ if( rc==SQLITE_OK ){
129946
+ rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
129947
+ }
129948
+ if( SQLITE_OK==rc && pCsr->nSegment==nSeg
129949
+ && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
129950
+ && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
129951
+ ){
129952
+ int iIdx = 0; /* Largest idx in level (iAbsLevel+1) */
129953
+ rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);
129954
+ if( rc==SQLITE_OK ){
129955
+ if( bUseHint && iIdx>0 ){
129956
+ const char *zKey = pCsr->zTerm;
129957
+ int nKey = pCsr->nTerm;
129958
+ rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
129959
+ }else{
129960
+ rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
129961
+ }
129962
+ }
129963
+
129964
+ if( rc==SQLITE_OK && pWriter->nLeafEst ){
129965
+ fts3LogMerge(nSeg, iAbsLevel);
129966
+ do {
129967
+ rc = fts3IncrmergeAppend(p, pWriter, pCsr);
129968
+ if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
129969
+ if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
129970
+ }while( rc==SQLITE_ROW );
129971
+
129972
+ /* Update or delete the input segments */
129973
+ if( rc==SQLITE_OK ){
129974
+ nRem -= (1 + pWriter->nWork);
129975
+ rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
129976
+ if( nSeg!=0 ){
129977
+ bDirtyHint = 1;
129978
+ fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);
129979
+ }
129980
+ }
129981
+ }
129982
+
129983
+ fts3IncrmergeRelease(p, pWriter, &rc);
129984
+ }
129985
+
129986
+ sqlite3Fts3SegReaderFinish(pCsr);
129987
+ }
129988
+
129989
+ /* Write the hint values into the %_stat table for the next incr-merger */
129990
+ if( bDirtyHint && rc==SQLITE_OK ){
129991
+ rc = fts3IncrmergeHintStore(p, &hint);
129992
+ }
129993
+
129994
+ sqlite3_free(pWriter);
129995
+ sqlite3_free(hint.a);
129996
+ return rc;
129997
+}
129998
+
129999
+/*
130000
+** Convert the text beginning at *pz into an integer and return
130001
+** its value. Advance *pz to point to the first character past
130002
+** the integer.
130003
+*/
130004
+static int fts3Getint(const char **pz){
130005
+ const char *z = *pz;
130006
+ int i = 0;
130007
+ while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0';
130008
+ *pz = z;
130009
+ return i;
130010
+}
130011
+
130012
+/*
130013
+** Process statements of the form:
130014
+**
130015
+** INSERT INTO table(table) VALUES('merge=A,B');
130016
+**
130017
+** A and B are integers that decode to be the number of leaf pages
130018
+** written for the merge, and the minimum number of segments on a level
130019
+** before it will be selected for a merge, respectively.
130020
+*/
130021
+static int fts3DoIncrmerge(
130022
+ Fts3Table *p, /* FTS3 table handle */
130023
+ const char *zParam /* Nul-terminated string containing "A,B" */
130024
+){
130025
+ int rc;
130026
+ int nMin = (FTS3_MERGE_COUNT / 2);
130027
+ int nMerge = 0;
130028
+ const char *z = zParam;
130029
+
130030
+ /* Read the first integer value */
130031
+ nMerge = fts3Getint(&z);
130032
+
130033
+ /* If the first integer value is followed by a ',', read the second
130034
+ ** integer value. */
130035
+ if( z[0]==',' && z[1]!='\0' ){
130036
+ z++;
130037
+ nMin = fts3Getint(&z);
130038
+ }
130039
+
130040
+ if( z[0]!='\0' || nMin<2 ){
130041
+ rc = SQLITE_ERROR;
130042
+ }else{
130043
+ rc = SQLITE_OK;
130044
+ if( !p->bHasStat ){
130045
+ assert( p->bFts4==0 );
130046
+ sqlite3Fts3CreateStatTable(&rc, p);
130047
+ }
130048
+ if( rc==SQLITE_OK ){
130049
+ rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);
130050
+ }
130051
+ sqlite3Fts3SegmentsClose(p);
130052
+ }
130053
+ return rc;
130054
+}
130055
+
130056
+/*
130057
+** Process statements of the form:
130058
+**
130059
+** INSERT INTO table(table) VALUES('automerge=X');
130060
+**
130061
+** where X is an integer. X==0 means to turn automerge off. X!=0 means
130062
+** turn it on. The setting is persistent.
130063
+*/
130064
+static int fts3DoAutoincrmerge(
130065
+ Fts3Table *p, /* FTS3 table handle */
130066
+ const char *zParam /* Nul-terminated string containing boolean */
130067
+){
130068
+ int rc = SQLITE_OK;
130069
+ sqlite3_stmt *pStmt = 0;
130070
+ p->bAutoincrmerge = fts3Getint(&zParam)!=0;
130071
+ if( !p->bHasStat ){
130072
+ assert( p->bFts4==0 );
130073
+ sqlite3Fts3CreateStatTable(&rc, p);
130074
+ if( rc ) return rc;
130075
+ }
130076
+ rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
130077
+ if( rc ) return rc;;
130078
+ sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
130079
+ sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);
130080
+ sqlite3_step(pStmt);
130081
+ rc = sqlite3_reset(pStmt);
130082
+ return rc;
130083
+}
130084
+
130085
+/*
130086
+** Return a 64-bit checksum for the FTS index entry specified by the
130087
+** arguments to this function.
130088
+*/
130089
+static u64 fts3ChecksumEntry(
130090
+ const char *zTerm, /* Pointer to buffer containing term */
130091
+ int nTerm, /* Size of zTerm in bytes */
130092
+ int iLangid, /* Language id for current row */
130093
+ int iIndex, /* Index (0..Fts3Table.nIndex-1) */
130094
+ i64 iDocid, /* Docid for current row. */
130095
+ int iCol, /* Column number */
130096
+ int iPos /* Position */
130097
+){
130098
+ int i;
130099
+ u64 ret = (u64)iDocid;
130100
+
130101
+ ret += (ret<<3) + iLangid;
130102
+ ret += (ret<<3) + iIndex;
130103
+ ret += (ret<<3) + iCol;
130104
+ ret += (ret<<3) + iPos;
130105
+ for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];
130106
+
130107
+ return ret;
130108
+}
130109
+
130110
+/*
130111
+** Return a checksum of all entries in the FTS index that correspond to
130112
+** language id iLangid. The checksum is calculated by XORing the checksums
130113
+** of each individual entry (see fts3ChecksumEntry()) together.
130114
+**
130115
+** If successful, the checksum value is returned and *pRc set to SQLITE_OK.
130116
+** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The
130117
+** return value is undefined in this case.
130118
+*/
130119
+static u64 fts3ChecksumIndex(
130120
+ Fts3Table *p, /* FTS3 table handle */
130121
+ int iLangid, /* Language id to return cksum for */
130122
+ int iIndex, /* Index to cksum (0..p->nIndex-1) */
130123
+ int *pRc /* OUT: Return code */
130124
+){
130125
+ Fts3SegFilter filter;
130126
+ Fts3MultiSegReader csr;
130127
+ int rc;
130128
+ u64 cksum = 0;
130129
+
130130
+ assert( *pRc==SQLITE_OK );
130131
+
130132
+ memset(&filter, 0, sizeof(filter));
130133
+ memset(&csr, 0, sizeof(csr));
130134
+ filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
130135
+ filter.flags |= FTS3_SEGMENT_SCAN;
130136
+
130137
+ rc = sqlite3Fts3SegReaderCursor(
130138
+ p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr
130139
+ );
130140
+ if( rc==SQLITE_OK ){
130141
+ rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
130142
+ }
130143
+
130144
+ if( rc==SQLITE_OK ){
130145
+ while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){
130146
+ char *pCsr = csr.aDoclist;
130147
+ char *pEnd = &pCsr[csr.nDoclist];
130148
+
130149
+ i64 iDocid = 0;
130150
+ i64 iCol = 0;
130151
+ i64 iPos = 0;
130152
+
130153
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
130154
+ while( pCsr<pEnd ){
130155
+ i64 iVal = 0;
130156
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130157
+ if( pCsr<pEnd ){
130158
+ if( iVal==0 || iVal==1 ){
130159
+ iCol = 0;
130160
+ iPos = 0;
130161
+ if( iVal ){
130162
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
130163
+ }else{
130164
+ pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130165
+ iDocid += iVal;
130166
+ }
130167
+ }else{
130168
+ iPos += (iVal - 2);
130169
+ cksum = cksum ^ fts3ChecksumEntry(
130170
+ csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
130171
+ (int)iCol, (int)iPos
130172
+ );
130173
+ }
130174
+ }
130175
+ }
130176
+ }
130177
+ }
130178
+ sqlite3Fts3SegReaderFinish(&csr);
130179
+
130180
+ *pRc = rc;
130181
+ return cksum;
130182
+}
130183
+
130184
+/*
130185
+** Check if the contents of the FTS index match the current contents of the
130186
+** content table. If no error occurs and the contents do match, set *pbOk
130187
+** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk
130188
+** to false before returning.
130189
+**
130190
+** If an error occurs (e.g. an OOM or IO error), return an SQLite error
130191
+** code. The final value of *pbOk is undefined in this case.
130192
+*/
130193
+static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
130194
+ int rc = SQLITE_OK; /* Return code */
130195
+ u64 cksum1 = 0; /* Checksum based on FTS index contents */
130196
+ u64 cksum2 = 0; /* Checksum based on %_content contents */
130197
+ sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */
130198
+
130199
+ /* This block calculates the checksum according to the FTS index. */
130200
+ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130201
+ if( rc==SQLITE_OK ){
130202
+ int rc2;
130203
+ sqlite3_bind_int(pAllLangid, 1, p->nIndex);
130204
+ while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
130205
+ int iLangid = sqlite3_column_int(pAllLangid, 0);
130206
+ int i;
130207
+ for(i=0; i<p->nIndex; i++){
130208
+ cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
130209
+ }
130210
+ }
130211
+ rc2 = sqlite3_reset(pAllLangid);
130212
+ if( rc==SQLITE_OK ) rc = rc2;
130213
+ }
130214
+
130215
+ /* This block calculates the checksum according to the %_content table */
130216
+ rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130217
+ if( rc==SQLITE_OK ){
130218
+ sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
130219
+ sqlite3_stmt *pStmt = 0;
130220
+ char *zSql;
130221
+
130222
+ zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist);
130223
+ if( !zSql ){
130224
+ rc = SQLITE_NOMEM;
130225
+ }else{
130226
+ rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
130227
+ sqlite3_free(zSql);
130228
+ }
130229
+
130230
+ while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
130231
+ i64 iDocid = sqlite3_column_int64(pStmt, 0);
130232
+ int iLang = langidFromSelect(p, pStmt);
130233
+ int iCol;
130234
+
130235
+ for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
130236
+ const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
130237
+ int nText = sqlite3_column_bytes(pStmt, iCol+1);
130238
+ sqlite3_tokenizer_cursor *pT = 0;
130239
+
130240
+ rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130241
+ while( rc==SQLITE_OK ){
130242
+ char const *zToken; /* Buffer containing token */
130243
+ int nToken; /* Number of bytes in token */
130244
+ int iDum1, iDum2; /* Dummy variables */
130245
+ int iPos; /* Position of token in zText */
130246
+
130247
+ rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130248
+ if( rc==SQLITE_OK ){
130249
+ int i;
130250
+ cksum2 = cksum2 ^ fts3ChecksumEntry(
130251
+ zToken, nToken, iLang, 0, iDocid, iCol, iPos
130252
+ );
130253
+ for(i=1; i<p->nIndex; i++){
130254
+ if( p->aIndex[i].nPrefix<=nToken ){
130255
+ cksum2 = cksum2 ^ fts3ChecksumEntry(
130256
+ zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
130257
+ );
130258
+ }
130259
+ }
130260
+ }
130261
+ }
130262
+ if( pT ) pModule->xClose(pT);
130263
+ if( rc==SQLITE_DONE ) rc = SQLITE_OK;
130264
+ }
130265
+ }
130266
+
130267
+ sqlite3_finalize(pStmt);
130268
+ }
130269
+
130270
+ *pbOk = (cksum1==cksum2);
130271
+ return rc;
130272
+}
130273
+
130274
+/*
130275
+** Run the integrity-check. If no error occurs and the current contents of
130276
+** the FTS index are correct, return SQLITE_OK. Or, if the contents of the
130277
+** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.
130278
+**
130279
+** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite
130280
+** error code.
130281
+**
130282
+** The integrity-check works as follows. For each token and indexed token
130283
+** prefix in the document set, a 64-bit checksum is calculated (by code
130284
+** in fts3ChecksumEntry()) based on the following:
130285
+**
130286
+** + The index number (0 for the main index, 1 for the first prefix
130287
+** index etc.),
130288
+** + The token (or token prefix) text itself,
130289
+** + The language-id of the row it appears in,
130290
+** + The docid of the row it appears in,
130291
+** + The column it appears in, and
130292
+** + The tokens position within that column.
130293
+**
130294
+** The checksums for all entries in the index are XORed together to create
130295
+** a single checksum for the entire index.
130296
+**
130297
+** The integrity-check code calculates the same checksum in two ways:
130298
+**
130299
+** 1. By scanning the contents of the FTS index, and
130300
+** 2. By scanning and tokenizing the content table.
130301
+**
130302
+** If the two checksums are identical, the integrity-check is deemed to have
130303
+** passed.
130304
+*/
130305
+static int fts3DoIntegrityCheck(
130306
+ Fts3Table *p /* FTS3 table handle */
130307
+){
130308
+ int rc;
130309
+ int bOk = 0;
130310
+ rc = fts3IntegrityCheck(p, &bOk);
130311
+ if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
130312
+ return rc;
130313
+}
130314
+
128197130315
/*
128198130316
** Handle a 'special' INSERT of the form:
128199130317
**
128200130318
** "INSERT INTO tbl(tbl) VALUES(<expr>)"
128201130319
**
@@ -128211,10 +130329,16 @@
128211130329
return SQLITE_NOMEM;
128212130330
}else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
128213130331
rc = fts3DoOptimize(p, 0);
128214130332
}else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
128215130333
rc = fts3DoRebuild(p);
130334
+ }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, "integrity-check", 15) ){
130335
+ rc = fts3DoIntegrityCheck(p);
130336
+ }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
130337
+ rc = fts3DoIncrmerge(p, &zVal[6]);
130338
+ }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
130339
+ rc = fts3DoAutoincrmerge(p, &zVal[10]);
128216130340
#ifdef SQLITE_TEST
128217130341
}else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
128218130342
p->nNodeSize = atoi(&zVal[9]);
128219130343
rc = SQLITE_OK;
128220130344
}else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
128406130530
/*
128407130531
** This function does the work for the xUpdate method of FTS3 virtual
128408130532
** tables. The schema of the virtual table being:
128409130533
**
128410130534
** CREATE TABLE <table name>(
128411
-** <user COLUMns>,
130535
+** <user columns>,
128412130536
** <table name> HIDDEN,
128413130537
** docid HIDDEN,
128414130538
** <langid> HIDDEN
128415130539
** );
128416130540
**
@@ -128538,11 +130662,11 @@
128538130662
fts3InsertDocsize(&rc, p, aSzIns);
128539130663
}
128540130664
nChng++;
128541130665
}
128542130666
128543
- if( p->bHasStat ){
130667
+ if( p->bFts4 ){
128544130668
fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
128545130669
}
128546130670
128547130671
update_out:
128548130672
sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
129369131493
char cArg,
129370131494
char **pzErr
129371131495
){
129372131496
if( (cArg==FTS3_MATCHINFO_NPHRASE)
129373131497
|| (cArg==FTS3_MATCHINFO_NCOL)
129374
- || (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat)
129375
- || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat)
131498
+ || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
131499
+ || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
129376131500
|| (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
129377131501
|| (cArg==FTS3_MATCHINFO_LCS)
129378131502
|| (cArg==FTS3_MATCHINFO_HITS)
129379131503
){
129380131504
return SQLITE_OK;
@@ -133134,12 +135258,12 @@
133134135258
}
133135135259
133136135260
sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
133137135261
133138135262
/* Allocate the sqlite3_vtab structure */
133139
- nDb = strlen(argv[1]);
133140
- nName = strlen(argv[2]);
135263
+ nDb = (int)strlen(argv[1]);
135264
+ nName = (int)strlen(argv[2]);
133141135265
pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
133142135266
if( !pRtree ){
133143135267
return SQLITE_NOMEM;
133144135268
}
133145135269
memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
133230135354
RtreeCell cell;
133231135355
int jj;
133232135356
133233135357
nodeGetCell(&tree, &node, ii, &cell);
133234135358
sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
133235
- nCell = strlen(zCell);
135359
+ nCell = (int)strlen(zCell);
133236135360
for(jj=0; jj<tree.nDim*2; jj++){
133237135361
sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
133238
- nCell = strlen(zCell);
135362
+ nCell = (int)strlen(zCell);
133239135363
}
133240135364
133241135365
if( zText ){
133242135366
char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
133243135367
sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
133976136100
int iInput = 0;
133977136101
int iOut = 0;
133978136102
133979136103
*ppCursor = 0;
133980136104
133981
- if( nInput<0 ){
136105
+ if( zInput==0 ){
136106
+ nInput = 0;
136107
+ zInput = "";
136108
+ }else if( nInput<0 ){
133982136109
nInput = strlen(zInput);
133983136110
}
133984136111
nChar = nInput+1;
133985136112
pCsr = (IcuCursor *)sqlite3_malloc(
133986136113
sizeof(IcuCursor) + /* IcuCursor */
133987136114
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.7.11. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -655,13 +655,13 @@
655 **
656 ** See also: [sqlite3_libversion()],
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.11"
661 #define SQLITE_VERSION_NUMBER 3007011
662 #define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -6554,10 +6554,21 @@
6554 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6555 ** <dd>This parameter returns the number of pager cache misses that have
6556 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6557 ** is always 0.
6558 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
6559 ** </dl>
6560 */
6561 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6562 #define SQLITE_DBSTATUS_CACHE_USED 1
6563 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
6565 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6566 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6567 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6568 #define SQLITE_DBSTATUS_CACHE_HIT 7
6569 #define SQLITE_DBSTATUS_CACHE_MISS 8
6570 #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
 
6571
6572
6573 /*
6574 ** CAPI3REF: Prepared Statement Status
6575 **
@@ -9919,18 +9931,22 @@
9919 void (*xDestroy)(void *);
9920 void *pUserData;
9921 };
9922
9923 /*
9924 ** Possible values for FuncDef.flags
 
 
9925 */
9926 #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
9927 #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
9928 #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
9929 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9930 #define SQLITE_FUNC_COUNT 0x20 /* Built-in count(*) aggregate */
9931 #define SQLITE_FUNC_COALESCE 0x40 /* Built-in coalesce() or ifnull() function */
 
 
9932
9933 /*
9934 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
9935 ** used to create the initializers for the FuncDef structures.
9936 **
@@ -9954,11 +9970,14 @@
9954 ** available as the function user-data (sqlite3_user_data()). The
9955 ** FuncDef.flags variable is set to the value passed as the flags
9956 ** parameter.
9957 */
9958 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9959 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
 
 
 
9960 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9961 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
9962 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9963 pArg, 0, xFunc, 0, 0, #zName, 0, 0}
9964 #define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
10184 u8 tabFlags; /* Mask of TF_* values */
10185 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
10186 FKey *pFKey; /* Linked list of all foreign keys in this table */
10187 char *zColAff; /* String defining the affinity of each column */
10188 #ifndef SQLITE_OMIT_CHECK
10189 Expr *pCheck; /* The AND of all CHECK constraints */
10190 #endif
10191 #ifndef SQLITE_OMIT_ALTERTABLE
10192 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
10193 #endif
10194 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
10577 ** TK_VARIABLE: variable number (always >= 1). */
10578 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
10579 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
10580 u8 flags2; /* Second set of flags. EP2_... */
10581 u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
 
10582 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
10583 Table *pTab; /* Table for TK_COLUMN expressions. */
10584 #if SQLITE_MAX_EXPR_DEPTH>0
10585 int nHeight; /* Height of the tree headed by this node */
10586 #endif
@@ -10599,11 +10619,11 @@
10599 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
10600 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
10601 #define EP_FixedDest 0x0200 /* Result needed in a specific register */
10602 #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
10603 #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10604 #define EP_Hint 0x1000 /* Optimizer hint. Not required for correctness */
10605 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
10606 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
10607 #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
10608
10609 /*
@@ -11118,10 +11138,11 @@
11118 int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
11119 int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
11120 int regRowid; /* Register holding rowid of CREATE TABLE entry */
11121 int regRoot; /* Register holding root page number for new objects */
11122 int nMaxArg; /* Max args passed to user function by sub-program */
 
11123 #ifndef SQLITE_OMIT_SHARED_CACHE
11124 int nTableLock; /* Number of locks in aTableLock */
11125 TableLock *aTableLock; /* Required table locks for shared-cache mode */
11126 #endif
11127 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
11186 const char *zAuthContext; /* Put saved Parse.zAuthContext here */
11187 Parse *pParse; /* The Parse structure */
11188 };
11189
11190 /*
11191 ** Bitfield flags for P5 value in OP_Insert and OP_Delete
11192 */
11193 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
11194 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
11195 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
11196 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
11197 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
11198 #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
 
 
11199
11200 /*
11201 * Each trigger present in the database schema is stored as an instance of
11202 * struct Trigger.
11203 *
@@ -11677,11 +11700,11 @@
11677 #endif
11678 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
11679 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
11680 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
11681 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11682 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int);
11683 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
11684 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
11685 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
11686 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
11687 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
13509 ** Set *pCurrent to the total cache hits or misses encountered by all
13510 ** pagers the database handle is connected to. *pHighwater is always set
13511 ** to zero.
13512 */
13513 case SQLITE_DBSTATUS_CACHE_HIT:
13514 case SQLITE_DBSTATUS_CACHE_MISS: {
 
13515 int i;
13516 int nRet = 0;
13517 assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
 
13518
13519 for(i=0; i<db->nDb; i++){
13520 if( db->aDb[i].pBt ){
13521 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
13522 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
21259
21260 /*
21261 ** Some systems have stricmp(). Others have strcasecmp(). Because
21262 ** there is no consistency, we will define our own.
21263 **
21264 ** IMPLEMENTATION-OF: R-20522-24639 The sqlite3_strnicmp() API allows
21265 ** applications and extensions to compare the contents of two buffers
21266 ** containing UTF-8 strings in a case-independent fashion, using the same
21267 ** definition of case independence that SQLite uses internally when
21268 ** comparing identifiers.
21269 */
21270 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
21271 register unsigned char *a, *b;
21272 a = (unsigned char *)zLeft;
21273 b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
33727 }
33728 sqlite3_free(pFile->zDeleteOnClose);
33729 }
33730 #endif
33731 OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
 
 
 
33732 OpenCounter(-1);
33733 return rc ? SQLITE_OK
33734 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
33735 "winClose", pFile->zPath);
33736 }
@@ -33744,22 +33772,33 @@
33744 sqlite3_file *id, /* File to read from */
33745 void *pBuf, /* Write content into this buffer */
33746 int amt, /* Number of bytes to read */
33747 sqlite3_int64 offset /* Begin reading at this offset */
33748 ){
 
 
 
33749 winFile *pFile = (winFile*)id; /* file handle */
33750 DWORD nRead; /* Number of bytes actually read from file */
33751 int nRetry = 0; /* Number of retrys */
33752
33753 assert( id!=0 );
33754 SimulateIOError(return SQLITE_IOERR_READ);
33755 OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
33756
 
33757 if( seekWinFile(pFile, offset) ){
33758 return SQLITE_FULL;
33759 }
33760 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
 
 
 
 
 
 
 
33761 DWORD lastErrno;
33762 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33763 pFile->lastErrno = lastErrno;
33764 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
33765 "winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
33782 sqlite3_file *id, /* File to write into */
33783 const void *pBuf, /* The bytes to be written */
33784 int amt, /* Number of bytes to write */
33785 sqlite3_int64 offset /* Offset into the file to begin writing at */
33786 ){
33787 int rc; /* True if error has occured, else false */
33788 winFile *pFile = (winFile*)id; /* File handle */
33789 int nRetry = 0; /* Number of retries */
33790
33791 assert( amt>0 );
33792 assert( pFile );
@@ -33793,23 +33832,48 @@
33793 SimulateIOError(return SQLITE_IOERR_WRITE);
33794 SimulateDiskfullError(return SQLITE_FULL);
33795
33796 OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
33797
 
33798 rc = seekWinFile(pFile, offset);
33799 if( rc==0 ){
 
 
 
 
 
 
33800 u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
33801 int nRem = amt; /* Number of bytes yet to be written */
33802 DWORD nWrite; /* Bytes written by each WriteFile() call */
33803 DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
 
 
 
 
 
 
33804
33805 while( nRem>0 ){
 
33806 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
 
 
 
33807 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33808 break;
33809 }
33810 if( nWrite<=0 ) break;
 
 
 
 
 
 
 
 
33811 aRem += nWrite;
33812 nRem -= nWrite;
33813 }
33814 if( nRem>0 ){
33815 pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
39094 i64 journalSizeLimit; /* Size limit for persistent journal files */
39095 char *zFilename; /* Name of the database file */
39096 char *zJournal; /* Name of the journal file */
39097 int (*xBusyHandler)(void*); /* Function to call when busy */
39098 void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39099 int nHit, nMiss; /* Total cache hits and misses */
39100 #ifdef SQLITE_TEST
39101 int nRead, nWrite; /* Database pages read/written */
39102 #endif
39103 void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
39104 #ifdef SQLITE_HAS_CODEC
39105 void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
39106 void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
39113 Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
39114 char *zWal; /* File name for write-ahead log */
39115 #endif
39116 };
39117
 
 
 
 
 
 
 
 
 
39118 /*
39119 ** The following global variables hold counters used for
39120 ** testing purposes only. These variables do not exist in
39121 ** a non-testing build. These variables are not thread-safe.
39122 */
@@ -41395,10 +41468,11 @@
41395 PgHdr *pList, /* List of frames to log */
41396 Pgno nTruncate, /* Database size after this commit */
41397 int isCommit /* True if this is a commit */
41398 ){
41399 int rc; /* Return code */
 
41400 #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
41401 PgHdr *p; /* For looping over pages */
41402 #endif
41403
41404 assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
41408 for(p=pList; p && p->pDirty; p=p->pDirty){
41409 assert( p->pgno < p->pDirty->pgno );
41410 }
41411 #endif
41412
 
41413 if( isCommit ){
41414 /* If a WAL transaction is being committed, there is no point in writing
41415 ** any pages with page numbers greater than nTruncate into the WAL file.
41416 ** They will never be read by any client. So remove them from the pDirty
41417 ** list here. */
41418 PgHdr *p;
41419 PgHdr **ppNext = &pList;
 
41420 for(p=pList; (*ppNext = p); p=p->pDirty){
41421 if( p->pgno<=nTruncate ) ppNext = &p->pDirty;
 
 
 
41422 }
41423 assert( pList );
 
 
41424 }
 
41425
41426 if( pList->pgno==1 ) pager_write_changecounter(pList);
41427 rc = sqlite3WalFrames(pPager->pWal,
41428 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
41429 );
@@ -42487,19 +42569,19 @@
42487 memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
42488 }
42489 if( pgno>pPager->dbFileSize ){
42490 pPager->dbFileSize = pgno;
42491 }
 
42492
42493 /* Update any backup objects copying the contents of this pager. */
42494 sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
42495
42496 PAGERTRACE(("STORE %d page %d hash(%08x)\n",
42497 PAGERID(pPager), pgno, pager_pagehash(pList)));
42498 IOTRACE(("PGOUT %p %d\n", pPager, pgno));
42499 PAGER_INCR(sqlite3_pager_writedb_count);
42500 PAGER_INCR(pPager->nWrite);
42501 }else{
42502 PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
42503 }
42504 pager_set_pagehash(pList);
42505 pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
43453
43454 if( (*ppPage)->pPager && !noContent ){
43455 /* In this case the pcache already contains an initialized copy of
43456 ** the page. Return without further ado. */
43457 assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43458 pPager->nHit++;
43459 return SQLITE_OK;
43460
43461 }else{
43462 /* The pager cache has created a new page. Its content needs to
43463 ** be initialized. */
@@ -43495,11 +43577,11 @@
43495 }
43496 memset(pPg->pData, 0, pPager->pageSize);
43497 IOTRACE(("ZERO %p %d\n", pPager, pgno));
43498 }else{
43499 assert( pPg->pPager==pPager );
43500 pPager->nMiss++;
43501 rc = readDbPage(pPg);
43502 if( rc!=SQLITE_OK ){
43503 goto pager_acquire_err;
43504 }
43505 }
@@ -44080,10 +44162,11 @@
44080 const void *zBuf;
44081 assert( pPager->dbFileSize>0 );
44082 CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
44083 if( rc==SQLITE_OK ){
44084 rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
 
44085 }
44086 if( rc==SQLITE_OK ){
44087 pPager->changeCountDone = 1;
44088 }
44089 }else{
@@ -44523,15 +44606,15 @@
44523 a[1] = sqlite3PcachePagecount(pPager->pPCache);
44524 a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
44525 a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
44526 a[4] = pPager->eState;
44527 a[5] = pPager->errCode;
44528 a[6] = pPager->nHit;
44529 a[7] = pPager->nMiss;
44530 a[8] = 0; /* Used to be pPager->nOvfl */
44531 a[9] = pPager->nRead;
44532 a[10] = pPager->nWrite;
44533 return a;
44534 }
44535 #endif
44536
44537 /*
@@ -44540,24 +44623,23 @@
44540 ** current cache hit or miss count, according to the value of eStat. If the
44541 ** reset parameter is non-zero, the cache hit or miss count is zeroed before
44542 ** returning.
44543 */
44544 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
44545 int *piStat;
44546
44547 assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
44548 || eStat==SQLITE_DBSTATUS_CACHE_MISS
 
44549 );
44550 if( eStat==SQLITE_DBSTATUS_CACHE_HIT ){
44551 piStat = &pPager->nHit;
44552 }else{
44553 piStat = &pPager->nMiss;
44554 }
44555
44556 *pnVal += *piStat;
 
 
 
 
44557 if( reset ){
44558 *piStat = 0;
44559 }
44560 }
44561
44562 /*
44563 ** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
56151 ** keys with no associated data. If the cursor was opened expecting an
56152 ** intkey table, the caller should be inserting integer keys with a
56153 ** blob of associated data. */
56154 assert( (pKey==0)==(pCur->pKeyInfo==0) );
56155
56156 /* If this is an insert into a table b-tree, invalidate any incrblob
56157 ** cursors open on the row being replaced (assuming this is a replace
56158 ** operation - if it is not, the following is a no-op). */
56159 if( pCur->pKeyInfo==0 ){
56160 invalidateIncrblobCursors(p, nKey, 0);
56161 }
56162
56163 /* Save the positions of any other cursors open on this table.
56164 **
56165 ** In some cases, the call to btreeMoveto() below is a no-op. For
56166 ** example, when inserting data into a table with auto-generated integer
56167 ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
56171 ** doing any work. To avoid thwarting these optimizations, it is important
56172 ** not to clear the cursor here.
56173 */
56174 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56175 if( rc ) return rc;
 
 
 
 
 
 
 
 
56176 if( !loc ){
56177 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
56178 if( rc ) return rc;
56179 }
56180 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
56281 || NEVER(pCur->eState!=CURSOR_VALID)
56282 ){
56283 return SQLITE_ERROR; /* Something has gone awry. */
56284 }
56285
56286 /* If this is a delete operation to remove a row from a table b-tree,
56287 ** invalidate any incrblob cursors open on the row being deleted. */
56288 if( pCur->pKeyInfo==0 ){
56289 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56290 }
56291
56292 iCellDepth = pCur->iPage;
56293 iCellIdx = pCur->aiIdx[iCellDepth];
56294 pPage = pCur->apPage[iCellDepth];
56295 pCell = findCell(pPage, iCellIdx);
56296
@@ -56312,10 +56389,17 @@
56312 ** deleted writable. Then free any overflow pages associated with the
56313 ** entry and finally remove the cell itself from within the page.
56314 */
56315 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56316 if( rc ) return rc;
 
 
 
 
 
 
 
56317 rc = sqlite3PagerWrite(pPage->pDbPage);
56318 if( rc ) return rc;
56319 rc = clearCell(pPage, pCell);
56320 dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
56321 if( rc ) return rc;
@@ -56593,17 +56677,17 @@
56593 int rc;
56594 BtShared *pBt = p->pBt;
56595 sqlite3BtreeEnter(p);
56596 assert( p->inTrans==TRANS_WRITE );
56597
56598 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56599 ** is the root of a table b-tree - if it is not, the following call is
56600 ** a no-op). */
56601 invalidateIncrblobCursors(p, 0, 1);
56602
56603 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
 
56604 if( SQLITE_OK==rc ){
 
 
 
 
56605 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
56606 }
56607 sqlite3BtreeLeave(p);
56608 return rc;
56609 }
@@ -58411,14 +58495,14 @@
58411
58412 /*
58413 ** Make sure pMem->z points to a writable allocation of at least
58414 ** n bytes.
58415 **
58416 ** If the memory cell currently contains string or blob data
58417 ** and the third argument passed to this function is true, the
58418 ** current content of the cell is preserved. Otherwise, it may
58419 ** be discarded.
58420 **
58421 ** This function sets the MEM_Dyn flag and clears any xDel callback.
58422 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
58423 ** not set, Mem.n is zeroed.
58424 */
@@ -58428,10 +58512,14 @@
58428 (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
58429 ((pMem->flags&MEM_Ephem) ? 1 : 0) +
58430 ((pMem->flags&MEM_Static) ? 1 : 0)
58431 );
58432 assert( (pMem->flags&MEM_RowSet)==0 );
 
 
 
 
58433
58434 if( n<32 ) n = 32;
58435 if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
58436 if( preserve && pMem->z==pMem->zMalloc ){
58437 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
60747 int nByte = (nSub+1)*sizeof(SubProgram*);
60748 int j;
60749 for(j=0; j<nSub; j++){
60750 if( apSub[j]==pOp->p4.pProgram ) break;
60751 }
60752 if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, 1) ){
60753 apSub = (SubProgram **)pSub->z;
60754 apSub[nSub++] = pOp->p4.pProgram;
60755 pSub->flags |= MEM_Blob;
60756 pSub->n = nSub*sizeof(SubProgram*);
60757 }
@@ -66996,10 +67084,15 @@
66996 **
66997 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
66998 ** then the cache of the cursor is reset prior to extracting the column.
66999 ** The first OP_Column against a pseudo-table after the value of the content
67000 ** register has changed should have this bit set.
 
 
 
 
 
67001 */
67002 case OP_Column: {
67003 #if 0 /* local variables moved into u.an */
67004 u32 payloadSize; /* Number of bytes in the record */
67005 i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
67138 u.an.pC->aRow = (u8*)u.an.zData;
67139 }else{
67140 u.an.pC->aRow = 0;
67141 }
67142 }
67143 /* The following assert is true in all cases accept when
67144 ** the database file has been corrupted externally.
67145 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67146 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67147
67148 /* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
67213 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67214 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67215 break;
67216 }
67217 }else{
67218 /* If u.an.i is less that u.an.nField, then there are less fields in this
67219 ** record than SetNumColumns indicated there are columns in the
67220 ** table. Set the u.an.offset for any extra columns not present in
67221 ** the record to 0. This tells code below to store a NULL
67222 ** instead of deserializing a value from the record.
67223 */
67224 u.an.aOffset[u.an.i] = 0;
67225 }
67226 }
67227 sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
67247 ** a pointer to a Mem object.
67248 */
67249 if( u.an.aOffset[u.an.p2] ){
67250 assert( rc==SQLITE_OK );
67251 if( u.an.zRec ){
 
67252 VdbeMemRelease(u.an.pDest);
67253 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67254 }else{
67255 u.an.len = sqlite3VdbeSerialTypeLen(u.an.aType[u.an.p2]);
67256 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67257 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex, &u.an.sMem);
67258 if( rc!=SQLITE_OK ){
67259 goto op_column_out;
67260 }
67261 u.an.zData = u.an.sMem.z;
67262 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.aType[u.an.p2], u.an.pDest);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
67263 }
67264 u.an.pDest->enc = encoding;
67265 }else{
67266 if( pOp->p4type==P4_MEM ){
67267 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
67593 }
67594 db->isTransactionSavepoint = 0;
67595 rc = p->rc;
67596 }else{
67597 u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67598 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67599 sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
 
 
67600 }
67601 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67602 rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
67603 if( rc!=SQLITE_OK ){
67604 goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
74873 int op, /* Expression opcode */
74874 Expr *pLeft, /* Left operand */
74875 Expr *pRight, /* Right operand */
74876 const Token *pToken /* Argument token */
74877 ){
74878 Expr *p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74879 sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
 
 
 
 
 
 
74880 if( p ) {
74881 sqlite3ExprCheckHeight(pParse, p->nHeight);
74882 }
74883 return p;
74884 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74885
74886 /*
74887 ** Join two expressions using an AND operator. If either expression is
74888 ** NULL, then just return the other expression.
 
 
 
 
74889 */
74890 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
74891 if( pLeft==0 ){
74892 return pRight;
74893 }else if( pRight==0 ){
74894 return pLeft;
 
 
 
 
74895 }else{
74896 Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
74897 sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
74898 return pNew;
74899 }
@@ -76421,19 +76563,10 @@
76421 ** Actually, the way the column cache is currently used, we are guaranteed
76422 ** that the object will never already be in cache. Verify this guarantee.
76423 */
76424 #ifndef NDEBUG
76425 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
76426 #if 0 /* This code wold remove the entry from the cache if it existed */
76427 if( p->iReg && p->iTable==iTab && p->iColumn==iCol ){
76428 cacheEntryClear(pParse, p);
76429 p->iLevel = pParse->iCacheLevel;
76430 p->iReg = iReg;
76431 p->lru = pParse->iCacheCnt++;
76432 return;
76433 }
76434 #endif
76435 assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
76436 }
76437 #endif
76438
76439 /* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
76564 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
76565 Parse *pParse, /* Parsing and code generating context */
76566 Table *pTab, /* Description of the table we are reading from */
76567 int iColumn, /* Index of the table column */
76568 int iTable, /* The cursor pointing to the table */
76569 int iReg /* Store results here */
 
76570 ){
76571 Vdbe *v = pParse->pVdbe;
76572 int i;
76573 struct yColCache *p;
76574
@@ -76579,11 +76713,15 @@
76579 return p->iReg;
76580 }
76581 }
76582 assert( v!=0 );
76583 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76584 sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
 
 
 
 
76585 return iReg;
76586 }
76587
76588 /*
76589 ** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
76707 /* This only happens when coding check constraints */
76708 assert( pParse->ckBase>0 );
76709 inReg = pExpr->iColumn + pParse->ckBase;
76710 }else{
76711 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76712 pExpr->iColumn, pExpr->iTable, target);
 
76713 }
76714 break;
76715 }
76716 case TK_INTEGER: {
76717 codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
76984 }
76985
76986
76987 if( pFarg ){
76988 r1 = sqlite3GetTempRange(pParse, nFarg);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
76989 sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
76990 sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
76991 sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
76992 }else{
76993 r1 = 0;
@@ -80189,10 +80347,11 @@
80189 Index *pPrevIdx = 0; /* Previous index in the loop */
80190 int idx = 0; /* slot in pIdx->aSample[] for next sample */
80191 int eType; /* Datatype of a sample */
80192 IndexSample *pSample; /* A slot in pIdx->aSample[] */
80193
 
80194 if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
80195 return SQLITE_OK;
80196 }
80197
80198 zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
80215 nSample = sqlite3_column_int(pStmt, 1);
80216 pIdx = sqlite3FindIndex(db, zIndex, zDb);
80217 if( pIdx==0 ) continue;
80218 assert( pIdx->nSample==0 );
80219 pIdx->nSample = nSample;
80220 pIdx->aSample = sqlite3MallocZero( nSample*sizeof(IndexSample) );
80221 pIdx->avgEq = pIdx->aiRowEst[1];
80222 if( pIdx->aSample==0 ){
80223 db->mallocFailed = 1;
80224 sqlite3_finalize(pStmt);
80225 return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
80288 int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
80289 pSample->nByte = n;
80290 if( n < 1){
80291 pSample->u.z = 0;
80292 }else{
80293 pSample->u.z = sqlite3Malloc(n);
80294 if( pSample->u.z==0 ){
80295 db->mallocFailed = 1;
80296 sqlite3_finalize(pStmt);
80297 return SQLITE_NOMEM;
80298 }
@@ -80364,11 +80523,14 @@
80364
80365
80366 /* Load the statistics from the sqlite_stat3 table. */
80367 #ifdef SQLITE_ENABLE_STAT3
80368 if( rc==SQLITE_OK ){
 
 
80369 rc = loadStat3(db, sInfo.zDatabase);
 
80370 }
80371 #endif
80372
80373 if( rc==SQLITE_NOMEM ){
80374 db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
81727 sqliteDeleteColumnNames(db, pTable);
81728 sqlite3DbFree(db, pTable->zName);
81729 sqlite3DbFree(db, pTable->zColAff);
81730 sqlite3SelectDelete(db, pTable->pSelect);
81731 #ifndef SQLITE_OMIT_CHECK
81732 sqlite3ExprDelete(db, pTable->pCheck);
81733 #endif
81734 #ifndef SQLITE_OMIT_VIRTUALTABLE
81735 sqlite3VtabClear(db, pTable);
81736 #endif
81737 sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
82390 */
82391 SQLITE_PRIVATE void sqlite3AddCheckConstraint(
82392 Parse *pParse, /* Parsing context */
82393 Expr *pCheckExpr /* The check expression */
82394 ){
82395 sqlite3 *db = pParse->db;
82396 #ifndef SQLITE_OMIT_CHECK
82397 Table *pTab = pParse->pNewTable;
82398 if( pTab && !IN_DECLARE_VTAB ){
82399 pTab->pCheck = sqlite3ExprAnd(db, pTab->pCheck, pCheckExpr);
 
 
 
82400 }else
82401 #endif
82402 {
82403 sqlite3ExprDelete(db, pCheckExpr);
82404 }
82405 }
82406
82407 /*
82408 ** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
82668 /* Resolve names in all CHECK constraint expressions.
82669 */
82670 if( p->pCheck ){
82671 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
82672 NameContext sNC; /* Name context for pParse->pNewTable */
 
 
82673
82674 memset(&sNC, 0, sizeof(sNC));
82675 memset(&sSrc, 0, sizeof(sSrc));
82676 sSrc.nSrc = 1;
82677 sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
82678 sSrc.a[0].pTab = p;
82679 sSrc.a[0].iCursor = -1;
82680 sNC.pParse = pParse;
82681 sNC.pSrcList = &sSrc;
82682 sNC.isCheck = 1;
82683 if( sqlite3ResolveExprNames(&sNC, p->pCheck) ){
82684 return;
 
 
 
82685 }
82686 }
82687 #endif /* !defined(SQLITE_OMIT_CHECK) */
82688
82689 /* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
84230 exit_drop_index:
84231 sqlite3SrcListDelete(db, pName);
84232 }
84233
84234 /*
84235 ** pArray is a pointer to an array of objects. Each object in the
84236 ** array is szEntry bytes in size. This routine allocates a new
84237 ** object on the end of the array.
84238 **
84239 ** *pnEntry is the number of entries already in use. *pnAlloc is
84240 ** the previously allocated size of the array. initSize is the
84241 ** suggested initial array size allocation.
84242 **
84243 ** The index of the new entry is returned in *pIdx.
84244 **
84245 ** This routine returns a pointer to the array of objects. This
84246 ** might be the same as the pArray parameter or it might be a different
84247 ** pointer if the array was resized.
 
 
84248 */
84249 SQLITE_PRIVATE void *sqlite3ArrayAllocate(
84250 sqlite3 *db, /* Connection to notify of malloc failures */
84251 void *pArray, /* Array of objects. Might be reallocated */
84252 int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
85839 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
85840 pWInfo = sqlite3WhereBegin(
85841 pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
85842 );
85843 if( pWInfo==0 ) goto delete_from_cleanup;
85844 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid);
85845 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
85846 if( db->flags & SQLITE_CountRows ){
85847 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
85848 }
85849 sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
87659 FUNCTION(min, 0, 0, 1, 0 ),
87660 AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
87661 FUNCTION(max, -1, 1, 1, minmaxFunc ),
87662 FUNCTION(max, 0, 1, 1, 0 ),
87663 AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87664 FUNCTION(typeof, 1, 0, 0, typeofFunc ),
87665 FUNCTION(length, 1, 0, 0, lengthFunc ),
87666 FUNCTION(substr, 2, 0, 0, substrFunc ),
87667 FUNCTION(substr, 3, 0, 0, substrFunc ),
87668 FUNCTION(abs, 1, 0, 0, absFunc ),
87669 #ifndef SQLITE_OMIT_FLOATING_POINT
87670 FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
87672 #endif
87673 FUNCTION(upper, 1, 0, 0, upperFunc ),
87674 FUNCTION(lower, 1, 0, 0, lowerFunc ),
87675 FUNCTION(coalesce, 1, 0, 0, 0 ),
87676 FUNCTION(coalesce, 0, 0, 0, 0 ),
87677 /* FUNCTION(coalesce, -1, 0, 0, ifnullFunc ), */
87678 {-1,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"coalesce",0,0},
87679 FUNCTION(hex, 1, 0, 0, hexFunc ),
87680 /* FUNCTION(ifnull, 2, 0, 0, ifnullFunc ), */
87681 {2,SQLITE_UTF8,SQLITE_FUNC_COALESCE,0,0,ifnullFunc,0,0,"ifnull",0,0},
87682 FUNCTION(random, 0, 0, 0, randomFunc ),
87683 FUNCTION(randomblob, 1, 0, 0, randomBlob ),
87684 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
87685 FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
87686 FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
90113 int j1; /* Addresss of jump instruction */
90114 int j2 = 0, j3; /* Addresses of jump instructions */
90115 int regData; /* Register containing first data column */
90116 int iCur; /* Table cursor number */
90117 Index *pIdx; /* Pointer to one of the indices */
 
90118 int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
90119 int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
90120
 
90121 v = sqlite3GetVdbe(pParse);
90122 assert( v!=0 );
90123 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90124 nCol = pTab->nCol;
90125 regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
90148 case OE_Rollback:
90149 case OE_Fail: {
90150 char *zMsg;
90151 sqlite3VdbeAddOp3(v, OP_HaltIfNull,
90152 SQLITE_CONSTRAINT, onError, regData+i);
90153 zMsg = sqlite3MPrintf(pParse->db, "%s.%s may not be NULL",
90154 pTab->zName, pTab->aCol[i].zName);
90155 sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
90156 break;
90157 }
90158 case OE_Ignore: {
@@ -90170,22 +90341,31 @@
90170 }
90171
90172 /* Test all CHECK constraints
90173 */
90174 #ifndef SQLITE_OMIT_CHECK
90175 if( pTab->pCheck && (pParse->db->flags & SQLITE_IgnoreChecks)==0 ){
90176 int allOk = sqlite3VdbeMakeLabel(v);
90177 pParse->ckBase = regData;
90178 sqlite3ExprIfTrue(pParse, pTab->pCheck, allOk, SQLITE_JUMPIFNULL);
90179 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90180 if( onError==OE_Ignore ){
90181 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90182 }else{
90183 if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90184 sqlite3HaltConstraint(pParse, onError, 0, 0);
 
 
 
 
 
 
 
 
 
 
 
90185 }
90186 sqlite3VdbeResolveLabel(v, allOk);
90187 }
90188 #endif /* !defined(SQLITE_OMIT_CHECK) */
90189
90190 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90191 ** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
90237 **
90238 ** to run without a statement journal if there are no indexes on the
90239 ** table.
90240 */
90241 Trigger *pTrigger = 0;
90242 if( pParse->db->flags&SQLITE_RecTriggers ){
90243 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90244 }
90245 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
90246 sqlite3MultiWrite(pParse);
90247 sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
90326 StrAccum errMsg;
90327 const char *zSep;
90328 char *zErr;
90329
90330 sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90331 errMsg.db = pParse->db;
90332 zSep = pIdx->nColumn>1 ? "columns " : "column ";
90333 for(j=0; j<pIdx->nColumn; j++){
90334 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
90335 sqlite3StrAccumAppend(&errMsg, zSep, -1);
90336 zSep = ", ";
@@ -90350,11 +90530,11 @@
90350 }
90351 default: {
90352 Trigger *pTrigger = 0;
90353 assert( onError==OE_Replace );
90354 sqlite3MultiWrite(pParse);
90355 if( pParse->db->flags&SQLITE_RecTriggers ){
90356 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90357 }
90358 sqlite3GenerateRowDelete(
90359 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
90360 );
@@ -90680,11 +90860,11 @@
90680 if( pSrcIdx==0 ){
90681 return 0; /* pDestIdx has no corresponding index in pSrc */
90682 }
90683 }
90684 #ifndef SQLITE_OMIT_CHECK
90685 if( pDest->pCheck && sqlite3ExprCompare(pSrc->pCheck, pDest->pCheck) ){
90686 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
90687 }
90688 #endif
90689 #ifndef SQLITE_OMIT_FOREIGN_KEY
90690 /* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
95753 int nCol; /* Number of columns in the result set */
95754 Expr *p; /* Expression for a single result column */
95755 char *zName; /* Column name */
95756 int nName; /* Size of name in zName[] */
95757
95758 *pnCol = nCol = pEList ? pEList->nExpr : 0;
95759 aCol = *paCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95760 if( aCol==0 ) return SQLITE_NOMEM;
 
 
 
 
 
 
 
 
95761 for(i=0, pCol=aCol; i<nCol; i++, pCol++){
95762 /* Get an appropriate name for the column
95763 */
95764 p = pEList->a[i].pExpr;
95765 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
98723 if( pCol->iSorterColumn>=j ){
98724 int r1 = j + regBase;
98725 int r2;
98726
98727 r2 = sqlite3ExprCodeGetColumn(pParse,
98728 pCol->pTab, pCol->iColumn, pCol->iTable, r1);
98729 if( r1!=r2 ){
98730 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
98731 }
98732 j++;
98733 }
@@ -103212,11 +103400,14 @@
103212 #ifdef SQLITE_EBCDIC
103213 if( *pnoCase ) return 0;
103214 #endif
103215 pList = pExpr->x.pList;
103216 pLeft = pList->a[1].pExpr;
103217 if( pLeft->op!=TK_COLUMN || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT ){
 
 
 
103218 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103219 ** be the name of an indexed column with TEXT affinity. */
103220 return 0;
103221 }
103222 assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
106909 );
106910 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
106911 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
106912 int r;
106913 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
106914 regRowid);
106915 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
106916 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
106917 }
106918 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
106919
@@ -107822,11 +108013,11 @@
107822 ** An instance of this structure is used to store the LIKE,
107823 ** GLOB, NOT LIKE, and NOT GLOB operators.
107824 */
107825 struct LikeOp {
107826 Token eOperator; /* "like" or "glob" or "regexp" */
107827 int not; /* True if the NOT keyword is present */
107828 };
107829
107830 /*
107831 ** An instance of the following structure describes the event of a
107832 ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108001 #endif
108002 #define sqlite3ParserARG_SDECL Parse *pParse;
108003 #define sqlite3ParserARG_PDECL ,Parse *pParse
108004 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108005 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
108006 #define YYNSTATE 629
108007 #define YYNRULE 327
108008 #define YYFALLBACK 1
108009 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108010 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108011 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108012
@@ -108072,480 +108263,478 @@
108072 ** shifting terminals.
108073 ** yy_reduce_ofst[] For each state, the offset into yy_action for
108074 ** shifting non-terminals after a reduce.
108075 ** yy_default[] Default action for each state.
108076 */
108077 #define YY_ACTTAB_COUNT (1580)
108078 static const YYACTIONTYPE yy_action[] = {
108079 /* 0 */ 310, 328, 574, 573, 15, 172, 187, 596, 56, 56,
108080 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108081 /* 20 */ 52, 52, 51, 234, 622, 621, 626, 622, 621, 299,
108082 /* 30 */ 589, 583, 56, 56, 56, 56, 236, 54, 54, 54,
108083 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 234, 351, 57,
108084 /* 50 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108085 /* 60 */ 56, 56, 570, 54, 54, 54, 54, 53, 53, 52,
108086 /* 70 */ 52, 52, 51, 234, 310, 596, 326, 607, 233, 232,
108087 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108088 /* 90 */ 51, 234, 619, 618, 326, 619, 618, 166, 605, 492,
108089 /* 100 */ 381, 378, 377, 235, 589, 583, 554, 495, 1, 59,
108090 /* 110 */ 19, 376, 622, 621, 53, 53, 52, 52, 52, 51,
108091 /* 120 */ 234, 571, 571, 57, 58, 48, 581, 580, 582, 582,
108092 /* 130 */ 55, 55, 56, 56, 56, 56, 215, 54, 54, 54,
108093 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 224,
108094 /* 150 */ 50, 47, 147, 177, 139, 281, 384, 276, 383, 169,
108095 /* 160 */ 408, 553, 578, 578, 622, 621, 272, 224, 439, 550,
108096 /* 170 */ 552, 410, 139, 281, 384, 276, 383, 169, 589, 583,
108097 /* 180 */ 619, 618, 280, 620, 272, 195, 413, 309, 440, 441,
108098 /* 190 */ 567, 491, 214, 279, 560, 600, 92, 57, 58, 48,
108099 /* 200 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108100 /* 210 */ 559, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108101 /* 220 */ 51, 234, 310, 464, 233, 232, 558, 133, 519, 50,
108102 /* 230 */ 47, 147, 619, 618, 565, 436, 397, 515, 514, 518,
108103 /* 240 */ 410, 387, 438, 389, 437, 622, 621, 442, 570, 433,
108104 /* 250 */ 203, 390, 589, 583, 6, 413, 166, 670, 250, 381,
108105 /* 260 */ 378, 377, 525, 190, 600, 92, 594, 571, 571, 465,
108106 /* 270 */ 376, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108107 /* 280 */ 56, 56, 56, 56, 599, 54, 54, 54, 54, 53,
108108 /* 290 */ 53, 52, 52, 52, 51, 234, 310, 592, 592, 592,
108109 /* 300 */ 490, 182, 247, 548, 249, 397, 273, 410, 7, 439,
108110 /* 310 */ 398, 606, 67, 619, 618, 620, 472, 256, 347, 255,
108111 /* 320 */ 473, 620, 413, 576, 620, 65, 589, 583, 236, 440,
108112 /* 330 */ 336, 600, 92, 68, 364, 192, 481, 622, 621, 547,
108113 /* 340 */ 622, 621, 560, 323, 207, 57, 58, 48, 581, 580,
108114 /* 350 */ 582, 582, 55, 55, 56, 56, 56, 56, 559, 54,
108115 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108116 /* 370 */ 310, 410, 397, 146, 558, 531, 401, 348, 599, 166,
108117 /* 380 */ 248, 204, 381, 378, 377, 541, 413, 171, 337, 570,
108118 /* 390 */ 622, 621, 40, 376, 38, 600, 74, 465, 548, 490,
108119 /* 400 */ 589, 583, 532, 350, 579, 619, 618, 297, 619, 618,
108120 /* 410 */ 480, 67, 470, 39, 620, 599, 406, 574, 573, 57,
108121 /* 420 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108122 /* 430 */ 56, 56, 577, 54, 54, 54, 54, 53, 53, 52,
108123 /* 440 */ 52, 52, 51, 234, 310, 256, 347, 255, 530, 52,
108124 /* 450 */ 52, 52, 51, 234, 345, 564, 236, 386, 619, 618,
108125 /* 460 */ 957, 185, 418, 2, 408, 410, 578, 578, 198, 197,
108126 /* 470 */ 196, 499, 183, 167, 589, 583, 671, 570, 505, 506,
108127 /* 480 */ 413, 267, 601, 672, 546, 208, 602, 36, 601, 600,
108128 /* 490 */ 91, 468, 602, 57, 58, 48, 581, 580, 582, 582,
108129 /* 500 */ 55, 55, 56, 56, 56, 56, 202, 54, 54, 54,
108130 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 599,
108131 /* 520 */ 157, 408, 527, 578, 578, 263, 490, 265, 410, 873,
108132 /* 530 */ 410, 474, 474, 366, 373, 410, 504, 428, 67, 290,
108133 /* 540 */ 599, 620, 352, 413, 408, 413, 578, 578, 589, 583,
108134 /* 550 */ 413, 382, 600, 92, 600, 16, 543, 62, 503, 600,
108135 /* 560 */ 92, 408, 346, 578, 578, 168, 45, 57, 58, 48,
108136 /* 570 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108137 /* 580 */ 200, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108138 /* 590 */ 51, 234, 310, 393, 395, 534, 510, 617, 616, 615,
108139 /* 600 */ 318, 314, 172, 66, 596, 410, 338, 596, 324, 571,
108140 /* 610 */ 571, 50, 47, 147, 599, 629, 627, 330, 539, 315,
108141 /* 620 */ 413, 30, 589, 583, 272, 236, 199, 144, 176, 600,
108142 /* 630 */ 73, 420, 947, 620, 947, 420, 946, 351, 946, 175,
108143 /* 640 */ 596, 57, 58, 48, 581, 580, 582, 582, 55, 55,
108144 /* 650 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108145 /* 660 */ 53, 52, 52, 52, 51, 234, 310, 261, 410, 413,
108146 /* 670 */ 269, 208, 596, 363, 410, 596, 424, 360, 600, 69,
108147 /* 680 */ 424, 327, 620, 413, 50, 47, 147, 410, 358, 413,
108148 /* 690 */ 575, 553, 600, 94, 483, 509, 589, 583, 600, 97,
108149 /* 700 */ 552, 484, 413, 620, 188, 599, 551, 563, 596, 566,
108150 /* 710 */ 334, 600, 95, 205, 201, 57, 58, 48, 581, 580,
108151 /* 720 */ 582, 582, 55, 55, 56, 56, 56, 56, 352, 54,
108152 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108153 /* 740 */ 310, 410, 261, 410, 167, 22, 356, 599, 359, 623,
108154 /* 750 */ 50, 47, 147, 548, 357, 562, 413, 620, 413, 332,
108155 /* 760 */ 523, 270, 410, 167, 620, 600, 104, 600, 103, 603,
108156 /* 770 */ 589, 583, 339, 539, 304, 423, 222, 413, 174, 304,
108157 /* 780 */ 422, 561, 567, 405, 214, 260, 600, 106, 620, 57,
108158 /* 790 */ 58, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108159 /* 800 */ 56, 56, 410, 54, 54, 54, 54, 53, 53, 52,
108160 /* 810 */ 52, 52, 51, 234, 310, 410, 557, 413, 410, 421,
108161 /* 820 */ 273, 35, 512, 146, 421, 12, 600, 107, 213, 144,
108162 /* 830 */ 413, 410, 32, 413, 410, 620, 365, 353, 358, 600,
108163 /* 840 */ 134, 11, 600, 135, 589, 583, 413, 21, 548, 413,
108164 /* 850 */ 316, 148, 620, 620, 170, 600, 98, 223, 600, 102,
108165 /* 860 */ 374, 168, 167, 57, 58, 48, 581, 580, 582, 582,
108166 /* 870 */ 55, 55, 56, 56, 56, 56, 410, 54, 54, 54,
108167 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 234, 310, 410,
108168 /* 890 */ 273, 413, 410, 273, 212, 469, 410, 167, 628, 2,
108169 /* 900 */ 600, 101, 545, 221, 413, 620, 130, 413, 620, 410,
108170 /* 910 */ 539, 413, 537, 600, 93, 315, 600, 100, 589, 583,
108171 /* 920 */ 600, 77, 425, 305, 413, 620, 254, 322, 599, 458,
108172 /* 930 */ 320, 171, 543, 600, 96, 521, 520, 57, 58, 48,
108173 /* 940 */ 581, 580, 582, 582, 55, 55, 56, 56, 56, 56,
108174 /* 950 */ 410, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108175 /* 960 */ 51, 234, 310, 410, 273, 413, 410, 457, 358, 35,
108176 /* 970 */ 426, 230, 306, 319, 600, 138, 467, 520, 413, 620,
108177 /* 980 */ 143, 413, 410, 620, 410, 353, 529, 600, 137, 142,
108178 /* 990 */ 600, 136, 589, 583, 604, 261, 528, 413, 229, 413,
108179 /* 1000 */ 620, 321, 495, 28, 543, 543, 600, 76, 600, 90,
108180 /* 1010 */ 620, 57, 46, 48, 581, 580, 582, 582, 55, 55,
108181 /* 1020 */ 56, 56, 56, 56, 410, 54, 54, 54, 54, 53,
108182 /* 1030 */ 53, 52, 52, 52, 51, 234, 310, 261, 451, 413,
108183 /* 1040 */ 410, 211, 611, 285, 283, 610, 609, 502, 600, 89,
108184 /* 1050 */ 380, 217, 620, 128, 140, 413, 220, 620, 410, 409,
108185 /* 1060 */ 620, 620, 588, 587, 600, 75, 589, 583, 271, 620,
108186 /* 1070 */ 51, 234, 127, 413, 620, 599, 627, 330, 27, 375,
108187 /* 1080 */ 449, 279, 600, 88, 585, 584, 58, 48, 581, 580,
108188 /* 1090 */ 582, 582, 55, 55, 56, 56, 56, 56, 410, 54,
108189 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 234,
108190 /* 1110 */ 310, 586, 410, 413, 410, 261, 593, 165, 399, 556,
108191 /* 1120 */ 126, 371, 600, 87, 478, 186, 123, 413, 367, 413,
108192 /* 1130 */ 620, 620, 410, 620, 620, 410, 600, 99, 600, 86,
108193 /* 1140 */ 589, 583, 475, 122, 258, 171, 471, 413, 160, 121,
108194 /* 1150 */ 413, 14, 159, 463, 25, 24, 600, 17, 448, 600,
108195 /* 1160 */ 85, 48, 581, 580, 582, 582, 55, 55, 56, 56,
108196 /* 1170 */ 56, 56, 158, 54, 54, 54, 54, 53, 53, 52,
108197 /* 1180 */ 52, 52, 51, 234, 44, 404, 261, 3, 544, 261,
108198 /* 1190 */ 540, 414, 621, 460, 119, 118, 538, 275, 10, 349,
108199 /* 1200 */ 4, 620, 407, 620, 620, 620, 116, 44, 404, 410,
108200 /* 1210 */ 3, 620, 620, 410, 414, 621, 456, 454, 252, 450,
108201 /* 1220 */ 508, 402, 111, 109, 413, 407, 155, 444, 413, 447,
108202 /* 1230 */ 435, 565, 219, 600, 84, 620, 108, 600, 83, 64,
108203 /* 1240 */ 434, 417, 625, 150, 402, 333, 410, 237, 238, 124,
108204 /* 1250 */ 274, 41, 42, 533, 565, 206, 189, 261, 43, 412,
108205 /* 1260 */ 411, 413, 261, 594, 488, 620, 329, 149, 419, 268,
108206 /* 1270 */ 600, 72, 620, 266, 41, 42, 181, 620, 410, 620,
108207 /* 1280 */ 105, 43, 412, 411, 620, 624, 594, 614, 620, 599,
108208 /* 1290 */ 228, 125, 313, 413, 592, 592, 592, 591, 590, 13,
108209 /* 1300 */ 218, 410, 600, 71, 236, 244, 44, 404, 264, 3,
108210 /* 1310 */ 312, 613, 340, 414, 621, 180, 413, 592, 592, 592,
108211 /* 1320 */ 591, 590, 13, 620, 407, 600, 82, 410, 416, 34,
108212 /* 1330 */ 404, 410, 3, 410, 262, 410, 414, 621, 612, 331,
108213 /* 1340 */ 178, 415, 413, 402, 8, 236, 413, 407, 413, 620,
108214 /* 1350 */ 413, 600, 81, 565, 257, 600, 80, 600, 70, 600,
108215 /* 1360 */ 18, 598, 361, 462, 461, 30, 402, 294, 31, 620,
108216 /* 1370 */ 293, 354, 251, 41, 42, 410, 565, 620, 620, 620,
108217 /* 1380 */ 43, 412, 411, 453, 396, 594, 620, 620, 394, 61,
108218 /* 1390 */ 413, 292, 443, 622, 621, 243, 41, 42, 620, 600,
108219 /* 1400 */ 79, 597, 291, 43, 412, 411, 60, 620, 594, 240,
108220 /* 1410 */ 620, 410, 231, 37, 555, 173, 592, 592, 592, 591,
108221 /* 1420 */ 590, 13, 216, 239, 620, 184, 413, 302, 301, 300,
108222 /* 1430 */ 179, 298, 388, 565, 452, 600, 78, 286, 620, 592,
108223 /* 1440 */ 592, 592, 591, 590, 13, 429, 29, 413, 151, 289,
108224 /* 1450 */ 242, 145, 392, 194, 193, 288, 600, 9, 542, 241,
108225 /* 1460 */ 620, 525, 391, 284, 620, 594, 620, 620, 522, 536,
108226 /* 1470 */ 620, 535, 153, 385, 465, 516, 282, 325, 154, 517,
108227 /* 1480 */ 277, 152, 512, 511, 513, 129, 226, 308, 487, 486,
108228 /* 1490 */ 485, 164, 372, 493, 307, 227, 592, 592, 592, 225,
108229 /* 1500 */ 479, 163, 368, 370, 162, 476, 210, 477, 26, 259,
108230 /* 1510 */ 161, 466, 362, 141, 132, 120, 117, 455, 156, 115,
108231 /* 1520 */ 344, 343, 256, 342, 245, 114, 113, 446, 311, 112,
108232 /* 1530 */ 23, 317, 432, 236, 131, 431, 110, 430, 20, 427,
108233 /* 1540 */ 608, 595, 295, 63, 379, 287, 509, 191, 278, 403,
108234 /* 1550 */ 572, 569, 497, 498, 496, 494, 335, 459, 445, 303,
108235 /* 1560 */ 296, 246, 341, 355, 5, 568, 369, 507, 253, 549,
108236 /* 1570 */ 526, 209, 400, 501, 500, 524, 234, 958, 489, 482,
108237 };
108238 static const YYCODETYPE yy_lookahead[] = {
108239 /* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108240 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108241 /* 20 */ 89, 90, 91, 92, 26, 27, 1, 26, 27, 15,
108242 /* 30 */ 49, 50, 77, 78, 79, 80, 116, 82, 83, 84,
108243 /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 128, 68,
108244 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108245 /* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108246 /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 86, 87,
108247 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108248 /* 90 */ 91, 92, 94, 95, 19, 94, 95, 96, 172, 173,
108249 /* 100 */ 99, 100, 101, 197, 49, 50, 177, 181, 22, 54,
108250 /* 110 */ 204, 110, 26, 27, 86, 87, 88, 89, 90, 91,
108251 /* 120 */ 92, 129, 130, 68, 69, 70, 71, 72, 73, 74,
108252 /* 130 */ 75, 76, 77, 78, 79, 80, 22, 82, 83, 84,
108253 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108254 /* 150 */ 221, 222, 223, 96, 97, 98, 99, 100, 101, 102,
108255 /* 160 */ 112, 32, 114, 115, 26, 27, 109, 92, 150, 25,
108256 /* 170 */ 41, 150, 97, 98, 99, 100, 101, 102, 49, 50,
108257 /* 180 */ 94, 95, 98, 165, 109, 25, 165, 163, 170, 171,
108258 /* 190 */ 166, 167, 168, 109, 12, 174, 175, 68, 69, 70,
108259 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108260 /* 210 */ 28, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108261 /* 220 */ 91, 92, 19, 11, 86, 87, 44, 24, 46, 221,
108262 /* 230 */ 222, 223, 94, 95, 66, 97, 215, 7, 8, 57,
108263 /* 240 */ 150, 220, 104, 19, 106, 26, 27, 229, 230, 241,
108264 /* 250 */ 160, 27, 49, 50, 22, 165, 96, 118, 16, 99,
108265 /* 260 */ 100, 101, 94, 119, 174, 175, 98, 129, 130, 57,
108266 /* 270 */ 110, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108267 /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108268 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 129, 130, 131,
108269 /* 300 */ 150, 23, 60, 25, 62, 215, 150, 150, 76, 150,
108270 /* 310 */ 220, 161, 162, 94, 95, 165, 30, 105, 106, 107,
108271 /* 320 */ 34, 165, 165, 23, 165, 25, 49, 50, 116, 170,
108272 /* 330 */ 171, 174, 175, 22, 48, 185, 186, 26, 27, 120,
108273 /* 340 */ 26, 27, 12, 187, 160, 68, 69, 70, 71, 72,
108274 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 28, 82,
108275 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108276 /* 370 */ 19, 150, 215, 95, 44, 23, 46, 220, 194, 96,
108277 /* 380 */ 138, 160, 99, 100, 101, 23, 165, 25, 229, 230,
108278 /* 390 */ 26, 27, 135, 110, 137, 174, 175, 57, 120, 150,
108279 /* 400 */ 49, 50, 88, 219, 113, 94, 95, 158, 94, 95,
108280 /* 410 */ 161, 162, 21, 136, 165, 194, 169, 170, 171, 68,
108281 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108282 /* 430 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108283 /* 440 */ 89, 90, 91, 92, 19, 105, 106, 107, 23, 88,
108284 /* 450 */ 89, 90, 91, 92, 63, 23, 116, 88, 94, 95,
108285 /* 460 */ 142, 143, 144, 145, 112, 150, 114, 115, 105, 106,
108286 /* 470 */ 107, 23, 23, 25, 49, 50, 118, 230, 97, 98,
108287 /* 480 */ 165, 16, 113, 118, 120, 160, 117, 136, 113, 174,
108288 /* 490 */ 175, 100, 117, 68, 69, 70, 71, 72, 73, 74,
108289 /* 500 */ 75, 76, 77, 78, 79, 80, 160, 82, 83, 84,
108290 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 194,
108291 /* 520 */ 25, 112, 23, 114, 115, 60, 150, 62, 150, 138,
108292 /* 530 */ 150, 105, 106, 107, 19, 150, 36, 161, 162, 224,
108293 /* 540 */ 194, 165, 217, 165, 112, 165, 114, 115, 49, 50,
108294 /* 550 */ 165, 51, 174, 175, 174, 175, 166, 232, 58, 174,
108295 /* 560 */ 175, 112, 237, 114, 115, 50, 22, 68, 69, 70,
108296 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108297 /* 580 */ 160, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108298 /* 590 */ 91, 92, 19, 215, 214, 205, 23, 7, 8, 9,
108299 /* 600 */ 215, 155, 24, 22, 26, 150, 97, 26, 108, 129,
108300 /* 610 */ 130, 221, 222, 223, 194, 0, 1, 2, 150, 104,
108301 /* 620 */ 165, 126, 49, 50, 109, 116, 206, 207, 118, 174,
108302 /* 630 */ 175, 22, 23, 165, 25, 22, 23, 128, 25, 118,
108303 /* 640 */ 26, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108304 /* 650 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108305 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 150, 165,
108306 /* 670 */ 23, 160, 94, 227, 150, 94, 67, 231, 174, 175,
108307 /* 680 */ 67, 213, 165, 165, 221, 222, 223, 150, 150, 165,
108308 /* 690 */ 23, 32, 174, 175, 181, 182, 49, 50, 174, 175,
108309 /* 700 */ 41, 188, 165, 165, 22, 194, 177, 11, 94, 23,
108310 /* 710 */ 193, 174, 175, 160, 22, 68, 69, 70, 71, 72,
108311 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 217, 82,
108312 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108313 /* 740 */ 19, 150, 150, 150, 25, 24, 19, 194, 237, 150,
108314 /* 750 */ 221, 222, 223, 25, 27, 23, 165, 165, 165, 242,
108315 /* 760 */ 165, 23, 150, 25, 165, 174, 175, 174, 175, 174,
108316 /* 770 */ 49, 50, 219, 150, 22, 23, 238, 165, 25, 22,
108317 /* 780 */ 23, 23, 166, 167, 168, 193, 174, 175, 165, 68,
108318 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108319 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108320 /* 810 */ 89, 90, 91, 92, 19, 150, 23, 165, 150, 67,
108321 /* 820 */ 150, 25, 103, 95, 67, 35, 174, 175, 206, 207,
108322 /* 830 */ 165, 150, 25, 165, 150, 165, 213, 150, 150, 174,
108323 /* 840 */ 175, 35, 174, 175, 49, 50, 165, 52, 120, 165,
108324 /* 850 */ 245, 246, 165, 165, 35, 174, 175, 187, 174, 175,
108325 /* 860 */ 23, 50, 25, 68, 69, 70, 71, 72, 73, 74,
108326 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108327 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108328 /* 890 */ 150, 165, 150, 150, 160, 23, 150, 25, 144, 145,
108329 /* 900 */ 174, 175, 120, 216, 165, 165, 22, 165, 165, 150,
108330 /* 910 */ 150, 165, 27, 174, 175, 104, 174, 175, 49, 50,
108331 /* 920 */ 174, 175, 247, 248, 165, 165, 238, 187, 194, 23,
108332 /* 930 */ 187, 25, 166, 174, 175, 190, 191, 68, 69, 70,
108333 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108334 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108335 /* 960 */ 91, 92, 19, 150, 150, 165, 150, 23, 150, 25,
108336 /* 970 */ 23, 205, 25, 213, 174, 175, 190, 191, 165, 165,
108337 /* 980 */ 118, 165, 150, 165, 150, 150, 23, 174, 175, 39,
108338 /* 990 */ 174, 175, 49, 50, 173, 150, 23, 165, 52, 165,
108339 /* 1000 */ 165, 187, 181, 22, 166, 166, 174, 175, 174, 175,
108340 /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108341 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108342 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108343 /* 1040 */ 150, 160, 150, 205, 205, 150, 150, 29, 174, 175,
108344 /* 1050 */ 52, 216, 165, 22, 150, 165, 238, 165, 150, 150,
108345 /* 1060 */ 165, 165, 49, 50, 174, 175, 49, 50, 23, 165,
108346 /* 1070 */ 91, 92, 22, 165, 165, 194, 1, 2, 22, 52,
108347 /* 1080 */ 193, 109, 174, 175, 71, 72, 69, 70, 71, 72,
108348 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108349 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108350 /* 1110 */ 19, 98, 150, 165, 150, 150, 150, 102, 150, 150,
108351 /* 1120 */ 22, 19, 174, 175, 20, 24, 104, 165, 43, 165,
108352 /* 1130 */ 165, 165, 150, 165, 165, 150, 174, 175, 174, 175,
108353 /* 1140 */ 49, 50, 59, 53, 138, 25, 53, 165, 104, 22,
108354 /* 1150 */ 165, 5, 118, 1, 76, 76, 174, 175, 193, 174,
108355 /* 1160 */ 175, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108356 /* 1170 */ 79, 80, 35, 82, 83, 84, 85, 86, 87, 88,
108357 /* 1180 */ 89, 90, 91, 92, 19, 20, 150, 22, 150, 150,
108358 /* 1190 */ 150, 26, 27, 27, 108, 127, 150, 150, 22, 25,
108359 /* 1200 */ 22, 165, 37, 165, 165, 165, 119, 19, 20, 150,
108360 /* 1210 */ 22, 165, 165, 150, 26, 27, 23, 1, 16, 20,
108361 /* 1220 */ 150, 56, 119, 108, 165, 37, 121, 128, 165, 193,
108362 /* 1230 */ 23, 66, 193, 174, 175, 165, 127, 174, 175, 16,
108363 /* 1240 */ 23, 146, 147, 15, 56, 65, 150, 152, 140, 154,
108364 /* 1250 */ 150, 86, 87, 88, 66, 160, 22, 150, 93, 94,
108365 /* 1260 */ 95, 165, 150, 98, 150, 165, 3, 246, 4, 150,
108366 /* 1270 */ 174, 175, 165, 150, 86, 87, 6, 165, 150, 165,
108367 /* 1280 */ 164, 93, 94, 95, 165, 149, 98, 149, 165, 194,
108368 /* 1290 */ 180, 180, 249, 165, 129, 130, 131, 132, 133, 134,
108369 /* 1300 */ 193, 150, 174, 175, 116, 193, 19, 20, 150, 22,
108370 /* 1310 */ 249, 149, 217, 26, 27, 151, 165, 129, 130, 131,
108371 /* 1320 */ 132, 133, 134, 165, 37, 174, 175, 150, 149, 19,
108372 /* 1330 */ 20, 150, 22, 150, 150, 150, 26, 27, 13, 244,
108373 /* 1340 */ 151, 159, 165, 56, 25, 116, 165, 37, 165, 165,
108374 /* 1350 */ 165, 174, 175, 66, 150, 174, 175, 174, 175, 174,
108375 /* 1360 */ 175, 194, 150, 150, 150, 126, 56, 199, 124, 165,
108376 /* 1370 */ 200, 150, 150, 86, 87, 150, 66, 165, 165, 165,
108377 /* 1380 */ 93, 94, 95, 150, 122, 98, 165, 165, 123, 22,
108378 /* 1390 */ 165, 201, 150, 26, 27, 150, 86, 87, 165, 174,
108379 /* 1400 */ 175, 203, 202, 93, 94, 95, 125, 165, 98, 150,
108380 /* 1410 */ 165, 150, 225, 135, 157, 118, 129, 130, 131, 132,
108381 /* 1420 */ 133, 134, 5, 150, 165, 157, 165, 10, 11, 12,
108382 /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 210, 165, 129,
108383 /* 1440 */ 130, 131, 132, 133, 134, 150, 104, 165, 31, 150,
108384 /* 1450 */ 33, 150, 150, 86, 87, 150, 174, 175, 211, 42,
108385 /* 1460 */ 165, 94, 121, 210, 165, 98, 165, 165, 176, 211,
108386 /* 1470 */ 165, 211, 55, 104, 57, 184, 210, 47, 61, 176,
108387 /* 1480 */ 176, 64, 103, 176, 178, 22, 92, 179, 176, 176,
108388 /* 1490 */ 176, 156, 18, 184, 179, 228, 129, 130, 131, 228,
108389 /* 1500 */ 157, 156, 45, 157, 156, 236, 157, 157, 135, 235,
108390 /* 1510 */ 156, 189, 157, 68, 218, 189, 22, 199, 156, 192,
108391 /* 1520 */ 157, 18, 105, 106, 107, 192, 192, 199, 111, 192,
108392 /* 1530 */ 240, 157, 40, 116, 218, 157, 189, 157, 240, 38,
108393 /* 1540 */ 153, 166, 198, 243, 178, 209, 182, 196, 177, 226,
108394 /* 1550 */ 230, 230, 166, 177, 177, 166, 139, 199, 199, 148,
108395 /* 1560 */ 195, 209, 209, 239, 196, 166, 234, 183, 239, 208,
108396 /* 1570 */ 174, 233, 191, 183, 183, 174, 92, 250, 186, 186,
108397 };
108398 #define YY_SHIFT_USE_DFLT (-81)
108399 #define YY_SHIFT_COUNT (417)
108400 #define YY_SHIFT_MIN (-80)
108401 #define YY_SHIFT_MAX (1503)
108402 static const short yy_shift_ofst[] = {
108403 /* 0 */ 1075, 1188, 1417, 1188, 1287, 1287, 138, 138, 1, -19,
108404 /* 10 */ 1287, 1287, 1287, 1287, 340, -2, 129, 129, 795, 1165,
108405 /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108406 /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108407 /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108408 /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108409 /* 60 */ 1287, 1287, 212, -2, -2, -8, -8, 614, 1229, 55,
108410 /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108411 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108412 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108413 /* 100 */ -45, -45, -45, -45, -1, 57, 28, 361, -2, -2,
108414 /* 110 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108415 /* 120 */ -2, -2, -2, -2, 391, 515, -2, -2, -2, -2,
108416 /* 130 */ -2, 509, -80, 614, 979, 1484, -81, -81, -81, 1367,
108417 /* 140 */ 75, 182, 182, 314, 311, 364, 219, 86, 613, 609,
108418 /* 150 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108419 /* 160 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108420 /* 170 */ -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
108421 /* 180 */ -2, -2, 578, 578, 578, 615, 1229, 1229, 1229, -81,
108422 /* 190 */ -81, -81, 160, 168, 168, 283, 500, 500, 500, 278,
108423 /* 200 */ 449, 330, 432, 409, 352, 48, 48, 48, 48, 426,
108424 /* 210 */ 286, 48, 48, 728, 581, 369, 590, 495, 224, 224,
108425 /* 220 */ 727, 495, 727, 719, 614, 659, 614, 659, 811, 659,
108426 /* 230 */ 224, 257, 480, 480, 614, 144, 375, -18, 1501, 1297,
108427 /* 240 */ 1297, 1492, 1492, 1297, 1494, 1445, 1239, 1503, 1503, 1503,
108428 /* 250 */ 1503, 1297, 1474, 1239, 1494, 1445, 1445, 1297, 1474, 1373,
108429 /* 260 */ 1457, 1297, 1297, 1474, 1297, 1474, 1297, 1474, 1463, 1369,
108430 /* 270 */ 1369, 1369, 1430, 1394, 1394, 1463, 1369, 1379, 1369, 1430,
108431 /* 280 */ 1369, 1369, 1341, 1342, 1341, 1342, 1341, 1342, 1297, 1297,
108432 /* 290 */ 1278, 1281, 1262, 1244, 1265, 1239, 1229, 1319, 1325, 1325,
108433 /* 300 */ 1270, 1270, 1270, 1270, -81, -81, -81, -81, -81, -81,
108434 /* 310 */ 1013, 242, 757, 752, 465, 363, 947, 232, 944, 906,
108435 /* 320 */ 872, 837, 738, 448, 381, 230, 84, 362, 300, 1264,
108436 /* 330 */ 1263, 1234, 1108, 1228, 1180, 1223, 1217, 1207, 1099, 1174,
108437 /* 340 */ 1109, 1115, 1103, 1199, 1105, 1202, 1216, 1087, 1193, 1178,
108438 /* 350 */ 1174, 1176, 1068, 1079, 1078, 1086, 1166, 1137, 1034, 1152,
108439 /* 360 */ 1146, 1127, 1044, 1006, 1093, 1120, 1090, 1083, 1085, 1022,
108440 /* 370 */ 1101, 1104, 1102, 972, 1015, 1098, 1027, 1056, 1050, 1045,
108441 /* 380 */ 1031, 998, 1018, 981, 946, 950, 973, 963, 862, 885,
108442 /* 390 */ 819, 884, 782, 796, 806, 807, 790, 796, 793, 758,
108443 /* 400 */ 753, 732, 692, 696, 682, 686, 667, 544, 291, 521,
108444 /* 410 */ 510, 365, 358, 139, 114, 54, 14, 25,
108445 };
108446 #define YY_REDUCE_USE_DFLT (-169)
108447 #define YY_REDUCE_COUNT (309)
108448 #define YY_REDUCE_MIN (-168)
108449 #define YY_REDUCE_MAX (1411)
108450 static const short yy_reduce_ofst[] = {
108451 /* 0 */ 318, 90, 1095, 221, 157, 21, 159, 18, 150, 390,
108452 /* 10 */ 385, 378, 380, 315, 325, 249, 529, -71, 8, 1282,
108453 /* 20 */ 1261, 1225, 1185, 1183, 1181, 1177, 1151, 1128, 1096, 1063,
108454 /* 30 */ 1059, 985, 982, 964, 962, 948, 908, 890, 874, 834,
108455 /* 40 */ 832, 816, 813, 800, 759, 746, 742, 739, 726, 684,
108456 /* 50 */ 681, 668, 665, 652, 612, 593, 591, 537, 524, 518,
108457 /* 60 */ 504, 455, 511, 376, 517, 247, -168, 24, 420, 463,
108458 /* 70 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108459 /* 80 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108460 /* 90 */ 463, 463, 463, 463, 463, 463, 463, 463, 463, 463,
108461 /* 100 */ 463, 463, 463, 463, 463, -74, 463, 463, 1112, 835,
108462 /* 110 */ 1107, 1039, 1036, 965, 887, 845, 818, 760, 688, 687,
108463 /* 120 */ 538, 743, 623, 592, 446, 513, 814, 740, 670, 156,
108464 /* 130 */ 468, 553, 184, 616, 463, 463, 463, 463, 463, 595,
108465 /* 140 */ 821, 786, 745, 909, 1305, 1302, 1301, 1299, 675, 675,
108466 /* 150 */ 1295, 1273, 1259, 1245, 1242, 1233, 1222, 1221, 1214, 1213,
108467 /* 160 */ 1212, 1204, 1184, 1158, 1123, 1119, 1114, 1100, 1070, 1047,
108468 /* 170 */ 1046, 1040, 1038, 969, 968, 966, 909, 904, 896, 895,
108469 /* 180 */ 892, 599, 839, 838, 766, 754, 881, 734, 346, 605,
108470 /* 190 */ 622, -94, 1393, 1401, 1396, 1392, 1391, 1390, 1384, 1361,
108471 /* 200 */ 1365, 1381, 1365, 1365, 1365, 1365, 1365, 1365, 1365, 1332,
108472 /* 210 */ 1338, 1365, 1365, 1361, 1399, 1368, 1411, 1359, 1353, 1352,
108473 /* 220 */ 1329, 1358, 1324, 1366, 1389, 1377, 1386, 1376, 1364, 1371,
108474 /* 230 */ 1336, 1323, 1321, 1320, 1375, 1344, 1351, 1387, 1300, 1380,
108475 /* 240 */ 1378, 1298, 1290, 1374, 1316, 1347, 1328, 1337, 1334, 1333,
108476 /* 250 */ 1327, 1363, 1362, 1318, 1296, 1326, 1322, 1355, 1354, 1269,
108477 /* 260 */ 1274, 1350, 1349, 1348, 1346, 1345, 1343, 1335, 1315, 1314,
108478 /* 270 */ 1313, 1312, 1309, 1271, 1267, 1308, 1307, 1306, 1304, 1291,
108479 /* 280 */ 1303, 1292, 1260, 1266, 1258, 1253, 1247, 1227, 1268, 1257,
108480 /* 290 */ 1187, 1198, 1200, 1190, 1170, 1168, 1167, 1182, 1189, 1164,
108481 /* 300 */ 1179, 1162, 1138, 1136, 1061, 1043, 1021, 1111, 1110, 1116,
108482 };
108483 static const YYACTIONTYPE yy_default[] = {
108484 /* 0 */ 634, 868, 956, 956, 868, 868, 956, 956, 956, 758,
108485 /* 10 */ 956, 956, 956, 866, 956, 956, 786, 786, 930, 956,
108486 /* 20 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108487 /* 30 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108488 /* 40 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108489 /* 50 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108490 /* 60 */ 956, 956, 956, 956, 956, 956, 956, 673, 762, 792,
108491 /* 70 */ 956, 956, 956, 956, 956, 956, 956, 956, 929, 931,
108492 /* 80 */ 800, 799, 909, 773, 797, 790, 794, 869, 862, 863,
108493 /* 90 */ 861, 865, 870, 956, 793, 829, 846, 828, 840, 845,
108494 /* 100 */ 852, 844, 841, 831, 830, 665, 832, 833, 956, 956,
108495 /* 110 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108496 /* 120 */ 956, 956, 956, 956, 660, 727, 956, 956, 956, 956,
108497 /* 130 */ 956, 956, 956, 956, 834, 835, 849, 848, 847, 956,
108498 /* 140 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108499 /* 150 */ 956, 936, 934, 956, 881, 956, 956, 956, 956, 956,
108500 /* 160 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108501 /* 170 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108502 /* 180 */ 956, 640, 758, 758, 758, 634, 956, 956, 956, 948,
108503 /* 190 */ 762, 752, 718, 956, 956, 956, 956, 956, 956, 956,
108504 /* 200 */ 956, 956, 956, 956, 956, 802, 741, 919, 921, 956,
108505 /* 210 */ 902, 739, 662, 760, 675, 750, 642, 796, 775, 775,
108506 /* 220 */ 914, 796, 914, 699, 956, 786, 956, 786, 696, 786,
108507 /* 230 */ 775, 864, 956, 956, 956, 759, 750, 956, 941, 766,
108508 /* 240 */ 766, 933, 933, 766, 808, 731, 796, 738, 738, 738,
108509 /* 250 */ 738, 766, 657, 796, 808, 731, 731, 766, 657, 908,
108510 /* 260 */ 906, 766, 766, 657, 766, 657, 766, 657, 874, 729,
108511 /* 270 */ 729, 729, 714, 878, 878, 874, 729, 699, 729, 714,
108512 /* 280 */ 729, 729, 779, 774, 779, 774, 779, 774, 766, 766,
108513 /* 290 */ 956, 791, 780, 789, 787, 796, 956, 717, 650, 650,
108514 /* 300 */ 639, 639, 639, 639, 953, 953, 948, 701, 701, 683,
108515 /* 310 */ 956, 956, 956, 956, 956, 956, 956, 883, 956, 956,
108516 /* 320 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108517 /* 330 */ 635, 943, 956, 956, 940, 956, 956, 956, 956, 801,
108518 /* 340 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108519 /* 350 */ 918, 956, 956, 956, 956, 956, 956, 956, 912, 956,
108520 /* 360 */ 956, 956, 956, 956, 956, 905, 904, 956, 956, 956,
108521 /* 370 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108522 /* 380 */ 956, 956, 956, 956, 956, 956, 956, 956, 956, 956,
108523 /* 390 */ 956, 956, 956, 788, 956, 781, 956, 867, 956, 956,
108524 /* 400 */ 956, 956, 956, 956, 956, 956, 956, 956, 744, 817,
108525 /* 410 */ 956, 816, 820, 815, 667, 956, 648, 956, 631, 636,
108526 /* 420 */ 952, 955, 954, 951, 950, 949, 944, 942, 939, 938,
108527 /* 430 */ 937, 935, 932, 928, 887, 885, 892, 891, 890, 889,
108528 /* 440 */ 888, 886, 884, 882, 803, 798, 795, 927, 880, 740,
108529 /* 450 */ 737, 736, 656, 945, 911, 920, 807, 806, 809, 917,
108530 /* 460 */ 916, 915, 913, 910, 897, 805, 804, 732, 872, 871,
108531 /* 470 */ 659, 901, 900, 899, 903, 907, 898, 768, 658, 655,
108532 /* 480 */ 664, 721, 720, 728, 726, 725, 724, 723, 722, 719,
108533 /* 490 */ 666, 674, 685, 713, 698, 697, 877, 879, 876, 875,
108534 /* 500 */ 706, 705, 711, 710, 709, 708, 707, 704, 703, 702,
108535 /* 510 */ 695, 694, 700, 693, 716, 715, 712, 692, 735, 734,
108536 /* 520 */ 733, 730, 691, 690, 689, 820, 688, 687, 826, 825,
108537 /* 530 */ 813, 856, 755, 754, 753, 765, 764, 777, 776, 811,
108538 /* 540 */ 810, 778, 763, 757, 756, 772, 771, 770, 769, 761,
108539 /* 550 */ 751, 783, 785, 784, 782, 858, 767, 855, 926, 925,
108540 /* 560 */ 924, 923, 922, 860, 859, 827, 824, 678, 679, 895,
108541 /* 570 */ 894, 896, 893, 681, 680, 677, 676, 857, 746, 745,
108542 /* 580 */ 853, 850, 842, 838, 854, 851, 843, 839, 837, 836,
108543 /* 590 */ 822, 821, 819, 818, 814, 823, 669, 747, 743, 742,
108544 /* 600 */ 812, 749, 748, 686, 684, 682, 663, 661, 654, 652,
108545 /* 610 */ 651, 653, 649, 647, 646, 645, 644, 643, 672, 671,
108546 /* 620 */ 670, 668, 667, 641, 638, 637, 633, 632, 630,
108547 };
108548
108549 /* The next table maps tokens into fallback tokens. If a construct
108550 ** like the following:
108551 **
@@ -108744,11 +108933,11 @@
108744 "create_table", "create_table_args", "createkw", "temp",
108745 "ifnotexists", "dbnm", "columnlist", "conslist_opt",
108746 "select", "column", "columnid", "type",
108747 "carglist", "id", "ids", "typetoken",
108748 "typename", "signed", "plus_num", "minus_num",
108749 "carg", "ccons", "term", "expr",
108750 "onconf", "sortorder", "autoinc", "idxlist_opt",
108751 "refargs", "defer_subclause", "refarg", "refact",
108752 "init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108753 "defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108754 "ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
108824 /* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
108825 /* 49 */ "typename ::= ids",
108826 /* 50 */ "typename ::= typename ids",
108827 /* 51 */ "signed ::= plus_num",
108828 /* 52 */ "signed ::= minus_num",
108829 /* 53 */ "carglist ::= carglist carg",
108830 /* 54 */ "carglist ::=",
108831 /* 55 */ "carg ::= CONSTRAINT nm ccons",
108832 /* 56 */ "carg ::= ccons",
108833 /* 57 */ "ccons ::= DEFAULT term",
108834 /* 58 */ "ccons ::= DEFAULT LP expr RP",
108835 /* 59 */ "ccons ::= DEFAULT PLUS term",
108836 /* 60 */ "ccons ::= DEFAULT MINUS term",
108837 /* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
108861 /* 85 */ "init_deferred_pred_opt ::=",
108862 /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
108863 /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
108864 /* 88 */ "conslist_opt ::=",
108865 /* 89 */ "conslist_opt ::= COMMA conslist",
108866 /* 90 */ "conslist ::= conslist COMMA tcons",
108867 /* 91 */ "conslist ::= conslist tcons",
108868 /* 92 */ "conslist ::= tcons",
108869 /* 93 */ "tcons ::= CONSTRAINT nm",
108870 /* 94 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
108871 /* 95 */ "tcons ::= UNIQUE LP idxlist RP onconf",
108872 /* 96 */ "tcons ::= CHECK LP expr RP onconf",
108873 /* 97 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
108874 /* 98 */ "defer_subclause_opt ::=",
108875 /* 99 */ "defer_subclause_opt ::= defer_subclause",
108876 /* 100 */ "onconf ::=",
108877 /* 101 */ "onconf ::= ON CONFLICT resolvetype",
108878 /* 102 */ "orconf ::=",
108879 /* 103 */ "orconf ::= OR resolvetype",
108880 /* 104 */ "resolvetype ::= raisetype",
108881 /* 105 */ "resolvetype ::= IGNORE",
108882 /* 106 */ "resolvetype ::= REPLACE",
108883 /* 107 */ "cmd ::= DROP TABLE ifexists fullname",
108884 /* 108 */ "ifexists ::= IF EXISTS",
108885 /* 109 */ "ifexists ::=",
108886 /* 110 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
108887 /* 111 */ "cmd ::= DROP VIEW ifexists fullname",
108888 /* 112 */ "cmd ::= select",
108889 /* 113 */ "select ::= oneselect",
108890 /* 114 */ "select ::= select multiselect_op oneselect",
108891 /* 115 */ "multiselect_op ::= UNION",
108892 /* 116 */ "multiselect_op ::= UNION ALL",
108893 /* 117 */ "multiselect_op ::= EXCEPT|INTERSECT",
108894 /* 118 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
108895 /* 119 */ "distinct ::= DISTINCT",
108896 /* 120 */ "distinct ::= ALL",
108897 /* 121 */ "distinct ::=",
108898 /* 122 */ "sclp ::= selcollist COMMA",
108899 /* 123 */ "sclp ::=",
108900 /* 124 */ "selcollist ::= sclp expr as",
108901 /* 125 */ "selcollist ::= sclp STAR",
108902 /* 126 */ "selcollist ::= sclp nm DOT STAR",
108903 /* 127 */ "as ::= AS nm",
108904 /* 128 */ "as ::= ids",
108905 /* 129 */ "as ::=",
108906 /* 130 */ "from ::=",
108907 /* 131 */ "from ::= FROM seltablist",
108908 /* 132 */ "stl_prefix ::= seltablist joinop",
108909 /* 133 */ "stl_prefix ::=",
108910 /* 134 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
108911 /* 135 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
108912 /* 136 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
108913 /* 137 */ "dbnm ::=",
108914 /* 138 */ "dbnm ::= DOT nm",
108915 /* 139 */ "fullname ::= nm dbnm",
108916 /* 140 */ "joinop ::= COMMA|JOIN",
108917 /* 141 */ "joinop ::= JOIN_KW JOIN",
108918 /* 142 */ "joinop ::= JOIN_KW nm JOIN",
108919 /* 143 */ "joinop ::= JOIN_KW nm nm JOIN",
108920 /* 144 */ "on_opt ::= ON expr",
108921 /* 145 */ "on_opt ::=",
108922 /* 146 */ "indexed_opt ::=",
108923 /* 147 */ "indexed_opt ::= INDEXED BY nm",
108924 /* 148 */ "indexed_opt ::= NOT INDEXED",
108925 /* 149 */ "using_opt ::= USING LP inscollist RP",
108926 /* 150 */ "using_opt ::=",
108927 /* 151 */ "orderby_opt ::=",
108928 /* 152 */ "orderby_opt ::= ORDER BY sortlist",
108929 /* 153 */ "sortlist ::= sortlist COMMA expr sortorder",
108930 /* 154 */ "sortlist ::= expr sortorder",
108931 /* 155 */ "sortorder ::= ASC",
108932 /* 156 */ "sortorder ::= DESC",
108933 /* 157 */ "sortorder ::=",
108934 /* 158 */ "groupby_opt ::=",
108935 /* 159 */ "groupby_opt ::= GROUP BY nexprlist",
108936 /* 160 */ "having_opt ::=",
108937 /* 161 */ "having_opt ::= HAVING expr",
108938 /* 162 */ "limit_opt ::=",
108939 /* 163 */ "limit_opt ::= LIMIT expr",
108940 /* 164 */ "limit_opt ::= LIMIT expr OFFSET expr",
108941 /* 165 */ "limit_opt ::= LIMIT expr COMMA expr",
108942 /* 166 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
108943 /* 167 */ "where_opt ::=",
108944 /* 168 */ "where_opt ::= WHERE expr",
108945 /* 169 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
108946 /* 170 */ "setlist ::= setlist COMMA nm EQ expr",
108947 /* 171 */ "setlist ::= nm EQ expr",
108948 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
108949 /* 173 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
108950 /* 174 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
108951 /* 175 */ "insert_cmd ::= INSERT orconf",
108952 /* 176 */ "insert_cmd ::= REPLACE",
108953 /* 177 */ "valuelist ::= VALUES LP nexprlist RP",
108954 /* 178 */ "valuelist ::= valuelist COMMA LP exprlist RP",
108955 /* 179 */ "inscollist_opt ::=",
108956 /* 180 */ "inscollist_opt ::= LP inscollist RP",
108957 /* 181 */ "inscollist ::= inscollist COMMA nm",
108958 /* 182 */ "inscollist ::= nm",
108959 /* 183 */ "expr ::= term",
108960 /* 184 */ "expr ::= LP expr RP",
108961 /* 185 */ "term ::= NULL",
108962 /* 186 */ "expr ::= id",
108963 /* 187 */ "expr ::= JOIN_KW",
108964 /* 188 */ "expr ::= nm DOT nm",
108965 /* 189 */ "expr ::= nm DOT nm DOT nm",
108966 /* 190 */ "term ::= INTEGER|FLOAT|BLOB",
108967 /* 191 */ "term ::= STRING",
108968 /* 192 */ "expr ::= REGISTER",
108969 /* 193 */ "expr ::= VARIABLE",
108970 /* 194 */ "expr ::= expr COLLATE ids",
108971 /* 195 */ "expr ::= CAST LP expr AS typetoken RP",
108972 /* 196 */ "expr ::= ID LP distinct exprlist RP",
108973 /* 197 */ "expr ::= ID LP STAR RP",
108974 /* 198 */ "term ::= CTIME_KW",
108975 /* 199 */ "expr ::= expr AND expr",
108976 /* 200 */ "expr ::= expr OR expr",
108977 /* 201 */ "expr ::= expr LT|GT|GE|LE expr",
108978 /* 202 */ "expr ::= expr EQ|NE expr",
108979 /* 203 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
108980 /* 204 */ "expr ::= expr PLUS|MINUS expr",
108981 /* 205 */ "expr ::= expr STAR|SLASH|REM expr",
108982 /* 206 */ "expr ::= expr CONCAT expr",
108983 /* 207 */ "likeop ::= LIKE_KW",
108984 /* 208 */ "likeop ::= NOT LIKE_KW",
108985 /* 209 */ "likeop ::= MATCH",
108986 /* 210 */ "likeop ::= NOT MATCH",
108987 /* 211 */ "expr ::= expr likeop expr",
108988 /* 212 */ "expr ::= expr likeop expr ESCAPE expr",
108989 /* 213 */ "expr ::= expr ISNULL|NOTNULL",
108990 /* 214 */ "expr ::= expr NOT NULL",
108991 /* 215 */ "expr ::= expr IS expr",
108992 /* 216 */ "expr ::= expr IS NOT expr",
108993 /* 217 */ "expr ::= NOT expr",
108994 /* 218 */ "expr ::= BITNOT expr",
108995 /* 219 */ "expr ::= MINUS expr",
108996 /* 220 */ "expr ::= PLUS expr",
108997 /* 221 */ "between_op ::= BETWEEN",
108998 /* 222 */ "between_op ::= NOT BETWEEN",
108999 /* 223 */ "expr ::= expr between_op expr AND expr",
109000 /* 224 */ "in_op ::= IN",
109001 /* 225 */ "in_op ::= NOT IN",
109002 /* 226 */ "expr ::= expr in_op LP exprlist RP",
109003 /* 227 */ "expr ::= LP select RP",
109004 /* 228 */ "expr ::= expr in_op LP select RP",
109005 /* 229 */ "expr ::= expr in_op nm dbnm",
109006 /* 230 */ "expr ::= EXISTS LP select RP",
109007 /* 231 */ "expr ::= CASE case_operand case_exprlist case_else END",
109008 /* 232 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109009 /* 233 */ "case_exprlist ::= WHEN expr THEN expr",
109010 /* 234 */ "case_else ::= ELSE expr",
109011 /* 235 */ "case_else ::=",
109012 /* 236 */ "case_operand ::= expr",
109013 /* 237 */ "case_operand ::=",
109014 /* 238 */ "exprlist ::= nexprlist",
109015 /* 239 */ "exprlist ::=",
109016 /* 240 */ "nexprlist ::= nexprlist COMMA expr",
109017 /* 241 */ "nexprlist ::= expr",
109018 /* 242 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109019 /* 243 */ "uniqueflag ::= UNIQUE",
109020 /* 244 */ "uniqueflag ::=",
109021 /* 245 */ "idxlist_opt ::=",
109022 /* 246 */ "idxlist_opt ::= LP idxlist RP",
109023 /* 247 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109024 /* 248 */ "idxlist ::= nm collate sortorder",
109025 /* 249 */ "collate ::=",
109026 /* 250 */ "collate ::= COLLATE ids",
109027 /* 251 */ "cmd ::= DROP INDEX ifexists fullname",
109028 /* 252 */ "cmd ::= VACUUM",
109029 /* 253 */ "cmd ::= VACUUM nm",
109030 /* 254 */ "cmd ::= PRAGMA nm dbnm",
109031 /* 255 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109032 /* 256 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109033 /* 257 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109034 /* 258 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109035 /* 259 */ "nmnum ::= plus_num",
109036 /* 260 */ "nmnum ::= nm",
109037 /* 261 */ "nmnum ::= ON",
109038 /* 262 */ "nmnum ::= DELETE",
109039 /* 263 */ "nmnum ::= DEFAULT",
109040 /* 264 */ "plus_num ::= PLUS number",
109041 /* 265 */ "plus_num ::= number",
109042 /* 266 */ "minus_num ::= MINUS number",
109043 /* 267 */ "number ::= INTEGER|FLOAT",
109044 /* 268 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109045 /* 269 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109046 /* 270 */ "trigger_time ::= BEFORE",
109047 /* 271 */ "trigger_time ::= AFTER",
109048 /* 272 */ "trigger_time ::= INSTEAD OF",
109049 /* 273 */ "trigger_time ::=",
109050 /* 274 */ "trigger_event ::= DELETE|INSERT",
109051 /* 275 */ "trigger_event ::= UPDATE",
109052 /* 276 */ "trigger_event ::= UPDATE OF inscollist",
109053 /* 277 */ "foreach_clause ::=",
109054 /* 278 */ "foreach_clause ::= FOR EACH ROW",
109055 /* 279 */ "when_clause ::=",
109056 /* 280 */ "when_clause ::= WHEN expr",
109057 /* 281 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109058 /* 282 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109059 /* 283 */ "trnm ::= nm",
109060 /* 284 */ "trnm ::= nm DOT nm",
109061 /* 285 */ "tridxby ::=",
109062 /* 286 */ "tridxby ::= INDEXED BY nm",
109063 /* 287 */ "tridxby ::= NOT INDEXED",
109064 /* 288 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109065 /* 289 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109066 /* 290 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109067 /* 291 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109068 /* 292 */ "trigger_cmd ::= select",
109069 /* 293 */ "expr ::= RAISE LP IGNORE RP",
109070 /* 294 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109071 /* 295 */ "raisetype ::= ROLLBACK",
109072 /* 296 */ "raisetype ::= ABORT",
109073 /* 297 */ "raisetype ::= FAIL",
109074 /* 298 */ "cmd ::= DROP TRIGGER ifexists fullname",
109075 /* 299 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109076 /* 300 */ "cmd ::= DETACH database_kw_opt expr",
109077 /* 301 */ "key_opt ::=",
109078 /* 302 */ "key_opt ::= KEY expr",
109079 /* 303 */ "database_kw_opt ::= DATABASE",
109080 /* 304 */ "database_kw_opt ::=",
109081 /* 305 */ "cmd ::= REINDEX",
109082 /* 306 */ "cmd ::= REINDEX nm dbnm",
109083 /* 307 */ "cmd ::= ANALYZE",
109084 /* 308 */ "cmd ::= ANALYZE nm dbnm",
109085 /* 309 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109086 /* 310 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109087 /* 311 */ "add_column_fullname ::= fullname",
109088 /* 312 */ "kwcolumn_opt ::=",
109089 /* 313 */ "kwcolumn_opt ::= COLUMNKW",
109090 /* 314 */ "cmd ::= create_vtab",
109091 /* 315 */ "cmd ::= create_vtab LP vtabarglist RP",
109092 /* 316 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109093 /* 317 */ "vtabarglist ::= vtabarg",
109094 /* 318 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109095 /* 319 */ "vtabarg ::=",
109096 /* 320 */ "vtabarg ::= vtabarg vtabargtoken",
109097 /* 321 */ "vtabargtoken ::= ANY",
109098 /* 322 */ "vtabargtoken ::= lp anylist RP",
109099 /* 323 */ "lp ::= LP",
109100 /* 324 */ "anylist ::=",
109101 /* 325 */ "anylist ::= anylist LP anylist RP",
109102 /* 326 */ "anylist ::= anylist ANY",
109103 };
109104 #endif /* NDEBUG */
109105
109106
109107 #if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109543 { 167, 6 },
109544 { 168, 1 },
109545 { 168, 2 },
109546 { 169, 1 },
109547 { 169, 1 },
109548 { 164, 2 },
109549 { 164, 0 },
109550 { 172, 3 },
109551 { 172, 1 },
109552 { 173, 2 },
109553 { 173, 4 },
109554 { 173, 3 },
109555 { 173, 3 },
109556 { 173, 2 },
@@ -109580,14 +109767,12 @@
109580 { 184, 0 },
109581 { 184, 2 },
109582 { 184, 2 },
109583 { 159, 0 },
109584 { 159, 2 },
109585 { 185, 3 },
109586 { 185, 2 },
109587 { 185, 1 },
109588 { 186, 2 },
109589 { 186, 7 },
109590 { 186, 5 },
109591 { 186, 5 },
109592 { 186, 10 },
109593 { 188, 0 },
@@ -109892,12 +110077,12 @@
109892 {yygotominor.yy392 = TK_DEFERRED;}
109893 break;
109894 case 14: /* transtype ::= DEFERRED */
109895 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
109896 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
109897 case 115: /* multiselect_op ::= UNION */ yytestcase(yyruleno==115);
109898 case 117: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==117);
109899 {yygotominor.yy392 = yymsp[0].major;}
109900 break;
109901 case 17: /* cmd ::= COMMIT trans_opt */
109902 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
109903 {sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
109935 case 31: /* temp ::= */ yytestcase(yyruleno==31);
109936 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
109937 case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
109938 case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
109939 case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
109940 case 98: /* defer_subclause_opt ::= */ yytestcase(yyruleno==98);
109941 case 109: /* ifexists ::= */ yytestcase(yyruleno==109);
109942 case 120: /* distinct ::= ALL */ yytestcase(yyruleno==120);
109943 case 121: /* distinct ::= */ yytestcase(yyruleno==121);
109944 case 221: /* between_op ::= BETWEEN */ yytestcase(yyruleno==221);
109945 case 224: /* in_op ::= IN */ yytestcase(yyruleno==224);
109946 {yygotominor.yy392 = 0;}
109947 break;
109948 case 29: /* ifnotexists ::= IF NOT EXISTS */
109949 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
109950 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
109951 case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
109952 case 108: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==108);
109953 case 119: /* distinct ::= DISTINCT */ yytestcase(yyruleno==119);
109954 case 222: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==222);
109955 case 225: /* in_op ::= NOT IN */ yytestcase(yyruleno==225);
109956 {yygotominor.yy392 = 1;}
109957 break;
109958 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
109959 {
109960 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
109984 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
109985 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
109986 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
109987 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
109988 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
109989 case 127: /* as ::= AS nm */ yytestcase(yyruleno==127);
109990 case 128: /* as ::= ids */ yytestcase(yyruleno==128);
109991 case 138: /* dbnm ::= DOT nm */ yytestcase(yyruleno==138);
109992 case 147: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==147);
109993 case 250: /* collate ::= COLLATE ids */ yytestcase(yyruleno==250);
109994 case 259: /* nmnum ::= plus_num */ yytestcase(yyruleno==259);
109995 case 260: /* nmnum ::= nm */ yytestcase(yyruleno==260);
109996 case 261: /* nmnum ::= ON */ yytestcase(yyruleno==261);
109997 case 262: /* nmnum ::= DELETE */ yytestcase(yyruleno==262);
109998 case 263: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==263);
109999 case 264: /* plus_num ::= PLUS number */ yytestcase(yyruleno==264);
110000 case 265: /* plus_num ::= number */ yytestcase(yyruleno==265);
110001 case 266: /* minus_num ::= MINUS number */ yytestcase(yyruleno==266);
110002 case 267: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==267);
110003 case 283: /* trnm ::= nm */ yytestcase(yyruleno==283);
110004 {yygotominor.yy0 = yymsp[0].minor.yy0;}
110005 break;
110006 case 45: /* type ::= typetoken */
110007 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110008 break;
@@ -110018,10 +110203,16 @@
110018 yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110019 }
110020 break;
110021 case 50: /* typename ::= typename ids */
110022 {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
 
 
 
 
 
 
110023 break;
110024 case 57: /* ccons ::= DEFAULT term */
110025 case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110026 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110027 break;
@@ -110095,80 +110286,80 @@
110095 break;
110096 case 82: /* refact ::= NO ACTION */
110097 { yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110098 break;
110099 case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110100 case 99: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==99);
110101 case 101: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==101);
110102 case 104: /* resolvetype ::= raisetype */ yytestcase(yyruleno==104);
110103 {yygotominor.yy392 = yymsp[0].minor.yy392;}
110104 break;
110105 case 88: /* conslist_opt ::= */
110106 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110107 break;
110108 case 89: /* conslist_opt ::= COMMA conslist */
110109 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
110110 break;
110111 case 94: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110112 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110113 break;
110114 case 95: /* tcons ::= UNIQUE LP idxlist RP onconf */
110115 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110116 break;
110117 case 96: /* tcons ::= CHECK LP expr RP onconf */
110118 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110119 break;
110120 case 97: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110121 {
110122 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110123 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110124 }
110125 break;
110126 case 100: /* onconf ::= */
110127 {yygotominor.yy392 = OE_Default;}
110128 break;
110129 case 102: /* orconf ::= */
110130 {yygotominor.yy258 = OE_Default;}
110131 break;
110132 case 103: /* orconf ::= OR resolvetype */
110133 {yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110134 break;
110135 case 105: /* resolvetype ::= IGNORE */
110136 {yygotominor.yy392 = OE_Ignore;}
110137 break;
110138 case 106: /* resolvetype ::= REPLACE */
110139 {yygotominor.yy392 = OE_Replace;}
110140 break;
110141 case 107: /* cmd ::= DROP TABLE ifexists fullname */
110142 {
110143 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110144 }
110145 break;
110146 case 110: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110147 {
110148 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110149 }
110150 break;
110151 case 111: /* cmd ::= DROP VIEW ifexists fullname */
110152 {
110153 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110154 }
110155 break;
110156 case 112: /* cmd ::= select */
110157 {
110158 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110159 sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110160 sqlite3ExplainBegin(pParse->pVdbe);
110161 sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110162 sqlite3ExplainFinish(pParse->pVdbe);
110163 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110164 }
110165 break;
110166 case 113: /* select ::= oneselect */
110167 {yygotominor.yy159 = yymsp[0].minor.yy159;}
110168 break;
110169 case 114: /* select ::= select multiselect_op oneselect */
110170 {
110171 if( yymsp[0].minor.yy159 ){
110172 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110173 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110174 }else{
@@ -110175,83 +110366,83 @@
110175 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110176 }
110177 yygotominor.yy159 = yymsp[0].minor.yy159;
110178 }
110179 break;
110180 case 116: /* multiselect_op ::= UNION ALL */
110181 {yygotominor.yy392 = TK_ALL;}
110182 break;
110183 case 118: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110184 {
110185 yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110186 }
110187 break;
110188 case 122: /* sclp ::= selcollist COMMA */
110189 case 246: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==246);
110190 {yygotominor.yy442 = yymsp[-1].minor.yy442;}
110191 break;
110192 case 123: /* sclp ::= */
110193 case 151: /* orderby_opt ::= */ yytestcase(yyruleno==151);
110194 case 158: /* groupby_opt ::= */ yytestcase(yyruleno==158);
110195 case 239: /* exprlist ::= */ yytestcase(yyruleno==239);
110196 case 245: /* idxlist_opt ::= */ yytestcase(yyruleno==245);
110197 {yygotominor.yy442 = 0;}
110198 break;
110199 case 124: /* selcollist ::= sclp expr as */
110200 {
110201 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110202 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110203 sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110204 }
110205 break;
110206 case 125: /* selcollist ::= sclp STAR */
110207 {
110208 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110209 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110210 }
110211 break;
110212 case 126: /* selcollist ::= sclp nm DOT STAR */
110213 {
110214 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110215 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110216 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110217 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110218 }
110219 break;
110220 case 129: /* as ::= */
110221 {yygotominor.yy0.n = 0;}
110222 break;
110223 case 130: /* from ::= */
110224 {yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110225 break;
110226 case 131: /* from ::= FROM seltablist */
110227 {
110228 yygotominor.yy347 = yymsp[0].minor.yy347;
110229 sqlite3SrcListShiftJoinType(yygotominor.yy347);
110230 }
110231 break;
110232 case 132: /* stl_prefix ::= seltablist joinop */
110233 {
110234 yygotominor.yy347 = yymsp[-1].minor.yy347;
110235 if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110236 }
110237 break;
110238 case 133: /* stl_prefix ::= */
110239 {yygotominor.yy347 = 0;}
110240 break;
110241 case 134: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110242 {
110243 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110244 sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110245 }
110246 break;
110247 case 135: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110248 {
110249 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110250 }
110251 break;
110252 case 136: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110253 {
110254 if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110255 yygotominor.yy347 = yymsp[-4].minor.yy347;
110256 }else{
110257 Select *pSubquery;
@@ -110259,137 +110450,137 @@
110259 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110260 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110261 }
110262 }
110263 break;
110264 case 137: /* dbnm ::= */
110265 case 146: /* indexed_opt ::= */ yytestcase(yyruleno==146);
110266 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110267 break;
110268 case 139: /* fullname ::= nm dbnm */
110269 {yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110270 break;
110271 case 140: /* joinop ::= COMMA|JOIN */
110272 { yygotominor.yy392 = JT_INNER; }
110273 break;
110274 case 141: /* joinop ::= JOIN_KW JOIN */
110275 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110276 break;
110277 case 142: /* joinop ::= JOIN_KW nm JOIN */
110278 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110279 break;
110280 case 143: /* joinop ::= JOIN_KW nm nm JOIN */
110281 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110282 break;
110283 case 144: /* on_opt ::= ON expr */
110284 case 161: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==161);
110285 case 168: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==168);
110286 case 234: /* case_else ::= ELSE expr */ yytestcase(yyruleno==234);
110287 case 236: /* case_operand ::= expr */ yytestcase(yyruleno==236);
110288 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110289 break;
110290 case 145: /* on_opt ::= */
110291 case 160: /* having_opt ::= */ yytestcase(yyruleno==160);
110292 case 167: /* where_opt ::= */ yytestcase(yyruleno==167);
110293 case 235: /* case_else ::= */ yytestcase(yyruleno==235);
110294 case 237: /* case_operand ::= */ yytestcase(yyruleno==237);
110295 {yygotominor.yy122 = 0;}
110296 break;
110297 case 148: /* indexed_opt ::= NOT INDEXED */
110298 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110299 break;
110300 case 149: /* using_opt ::= USING LP inscollist RP */
110301 case 180: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==180);
110302 {yygotominor.yy180 = yymsp[-1].minor.yy180;}
110303 break;
110304 case 150: /* using_opt ::= */
110305 case 179: /* inscollist_opt ::= */ yytestcase(yyruleno==179);
110306 {yygotominor.yy180 = 0;}
110307 break;
110308 case 152: /* orderby_opt ::= ORDER BY sortlist */
110309 case 159: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==159);
110310 case 238: /* exprlist ::= nexprlist */ yytestcase(yyruleno==238);
110311 {yygotominor.yy442 = yymsp[0].minor.yy442;}
110312 break;
110313 case 153: /* sortlist ::= sortlist COMMA expr sortorder */
110314 {
110315 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110316 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110317 }
110318 break;
110319 case 154: /* sortlist ::= expr sortorder */
110320 {
110321 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110322 if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110323 }
110324 break;
110325 case 155: /* sortorder ::= ASC */
110326 case 157: /* sortorder ::= */ yytestcase(yyruleno==157);
110327 {yygotominor.yy392 = SQLITE_SO_ASC;}
110328 break;
110329 case 156: /* sortorder ::= DESC */
110330 {yygotominor.yy392 = SQLITE_SO_DESC;}
110331 break;
110332 case 162: /* limit_opt ::= */
110333 {yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110334 break;
110335 case 163: /* limit_opt ::= LIMIT expr */
110336 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110337 break;
110338 case 164: /* limit_opt ::= LIMIT expr OFFSET expr */
110339 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110340 break;
110341 case 165: /* limit_opt ::= LIMIT expr COMMA expr */
110342 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110343 break;
110344 case 166: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110345 {
110346 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110347 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110348 }
110349 break;
110350 case 169: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110351 {
110352 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110353 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110354 sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110355 }
110356 break;
110357 case 170: /* setlist ::= setlist COMMA nm EQ expr */
110358 {
110359 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110360 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110361 }
110362 break;
110363 case 171: /* setlist ::= nm EQ expr */
110364 {
110365 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110366 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110367 }
110368 break;
110369 case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110370 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110371 break;
110372 case 173: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110373 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110374 break;
110375 case 174: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110376 {sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110377 break;
110378 case 175: /* insert_cmd ::= INSERT orconf */
110379 {yygotominor.yy258 = yymsp[0].minor.yy258;}
110380 break;
110381 case 176: /* insert_cmd ::= REPLACE */
110382 {yygotominor.yy258 = OE_Replace;}
110383 break;
110384 case 177: /* valuelist ::= VALUES LP nexprlist RP */
110385 {
110386 yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110387 yygotominor.yy487.pSelect = 0;
110388 }
110389 break;
110390 case 178: /* valuelist ::= valuelist COMMA LP exprlist RP */
110391 {
110392 Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110393 if( yymsp[-4].minor.yy487.pList ){
110394 yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110395 yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110406 pRight->pPrior->selFlags |= SF_Values;
110407 yygotominor.yy487.pSelect = pRight;
110408 }
110409 }
110410 break;
110411 case 181: /* inscollist ::= inscollist COMMA nm */
110412 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110413 break;
110414 case 182: /* inscollist ::= nm */
110415 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110416 break;
110417 case 183: /* expr ::= term */
110418 {yygotominor.yy342 = yymsp[0].minor.yy342;}
110419 break;
110420 case 184: /* expr ::= LP expr RP */
110421 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110422 break;
110423 case 185: /* term ::= NULL */
110424 case 190: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==190);
110425 case 191: /* term ::= STRING */ yytestcase(yyruleno==191);
110426 {spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110427 break;
110428 case 186: /* expr ::= id */
110429 case 187: /* expr ::= JOIN_KW */ yytestcase(yyruleno==187);
110430 {spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110431 break;
110432 case 188: /* expr ::= nm DOT nm */
110433 {
110434 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110435 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110436 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110437 spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110438 }
110439 break;
110440 case 189: /* expr ::= nm DOT nm DOT nm */
110441 {
110442 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110443 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110444 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110445 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110446 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110447 spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110448 }
110449 break;
110450 case 192: /* expr ::= REGISTER */
110451 {
110452 /* When doing a nested parse, one can include terms in an expression
110453 ** that look like this: #1 #2 ... These terms refer to registers
110454 ** in the virtual machine. #N is the N-th register. */
110455 if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110460 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110461 }
110462 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110463 }
110464 break;
110465 case 193: /* expr ::= VARIABLE */
110466 {
110467 spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110468 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110469 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110470 }
110471 break;
110472 case 194: /* expr ::= expr COLLATE ids */
110473 {
110474 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110475 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110476 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110477 }
110478 break;
110479 case 195: /* expr ::= CAST LP expr AS typetoken RP */
110480 {
110481 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110482 spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110483 }
110484 break;
110485 case 196: /* expr ::= ID LP distinct exprlist RP */
110486 {
110487 if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110488 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110489 }
110490 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110492 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110493 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110494 }
110495 }
110496 break;
110497 case 197: /* expr ::= ID LP STAR RP */
110498 {
110499 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110500 spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110501 }
110502 break;
110503 case 198: /* term ::= CTIME_KW */
110504 {
110505 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110506 ** treated as functions that return constants */
110507 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110508 if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110509 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110510 }
110511 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110512 }
110513 break;
110514 case 199: /* expr ::= expr AND expr */
110515 case 200: /* expr ::= expr OR expr */ yytestcase(yyruleno==200);
110516 case 201: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==201);
110517 case 202: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==202);
110518 case 203: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==203);
110519 case 204: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==204);
110520 case 205: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==205);
110521 case 206: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==206);
110522 {spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110523 break;
110524 case 207: /* likeop ::= LIKE_KW */
110525 case 209: /* likeop ::= MATCH */ yytestcase(yyruleno==209);
110526 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 0;}
110527 break;
110528 case 208: /* likeop ::= NOT LIKE_KW */
110529 case 210: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==210);
110530 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.not = 1;}
110531 break;
110532 case 211: /* expr ::= expr likeop expr */
110533 {
110534 ExprList *pList;
110535 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110536 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110537 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110538 if( yymsp[-1].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110539 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110540 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110541 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110542 }
110543 break;
110544 case 212: /* expr ::= expr likeop expr ESCAPE expr */
110545 {
110546 ExprList *pList;
110547 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110548 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110549 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110550 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110551 if( yymsp[-3].minor.yy318.not ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110552 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110553 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110554 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110555 }
110556 break;
110557 case 213: /* expr ::= expr ISNULL|NOTNULL */
110558 {spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110559 break;
110560 case 214: /* expr ::= expr NOT NULL */
110561 {spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110562 break;
110563 case 215: /* expr ::= expr IS expr */
110564 {
110565 spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110566 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110567 }
110568 break;
110569 case 216: /* expr ::= expr IS NOT expr */
110570 {
110571 spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110572 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110573 }
110574 break;
110575 case 217: /* expr ::= NOT expr */
110576 case 218: /* expr ::= BITNOT expr */ yytestcase(yyruleno==218);
110577 {spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110578 break;
110579 case 219: /* expr ::= MINUS expr */
110580 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110581 break;
110582 case 220: /* expr ::= PLUS expr */
110583 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110584 break;
110585 case 223: /* expr ::= expr between_op expr AND expr */
110586 {
110587 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110588 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110589 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110590 if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110595 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110596 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110597 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110598 }
110599 break;
110600 case 226: /* expr ::= expr in_op LP exprlist RP */
110601 {
110602 if( yymsp[-1].minor.yy442==0 ){
110603 /* Expressions of the form
110604 **
110605 ** expr1 IN ()
@@ -110622,11 +110813,11 @@
110622 }
110623 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110624 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110625 }
110626 break;
110627 case 227: /* expr ::= LP select RP */
110628 {
110629 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110630 if( yygotominor.yy342.pExpr ){
110631 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110632 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110636 }
110637 yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110638 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110639 }
110640 break;
110641 case 228: /* expr ::= expr in_op LP select RP */
110642 {
110643 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110644 if( yygotominor.yy342.pExpr ){
110645 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110646 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110651 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110652 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110653 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110654 }
110655 break;
110656 case 229: /* expr ::= expr in_op nm dbnm */
110657 {
110658 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110659 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110660 if( yygotominor.yy342.pExpr ){
110661 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110667 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110668 yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110669 yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110670 }
110671 break;
110672 case 230: /* expr ::= EXISTS LP select RP */
110673 {
110674 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110675 if( p ){
110676 p->x.pSelect = yymsp[-1].minor.yy159;
110677 ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110681 }
110682 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110683 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110684 }
110685 break;
110686 case 231: /* expr ::= CASE case_operand case_exprlist case_else END */
110687 {
110688 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110689 if( yygotominor.yy342.pExpr ){
110690 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110691 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110694 }
110695 yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110696 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110697 }
110698 break;
110699 case 232: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110700 {
110701 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110702 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110703 }
110704 break;
110705 case 233: /* case_exprlist ::= WHEN expr THEN expr */
110706 {
110707 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110708 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110709 }
110710 break;
110711 case 240: /* nexprlist ::= nexprlist COMMA expr */
110712 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110713 break;
110714 case 241: /* nexprlist ::= expr */
110715 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110716 break;
110717 case 242: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110718 {
110719 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110720 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110721 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110722 }
110723 break;
110724 case 243: /* uniqueflag ::= UNIQUE */
110725 case 296: /* raisetype ::= ABORT */ yytestcase(yyruleno==296);
110726 {yygotominor.yy392 = OE_Abort;}
110727 break;
110728 case 244: /* uniqueflag ::= */
110729 {yygotominor.yy392 = OE_None;}
110730 break;
110731 case 247: /* idxlist ::= idxlist COMMA nm collate sortorder */
110732 {
110733 Expr *p = 0;
110734 if( yymsp[-1].minor.yy0.n>0 ){
110735 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110736 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110739 sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110740 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110741 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110742 }
110743 break;
110744 case 248: /* idxlist ::= nm collate sortorder */
110745 {
110746 Expr *p = 0;
110747 if( yymsp[-1].minor.yy0.n>0 ){
110748 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110749 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110752 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110753 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110754 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110755 }
110756 break;
110757 case 249: /* collate ::= */
110758 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110759 break;
110760 case 251: /* cmd ::= DROP INDEX ifexists fullname */
110761 {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110762 break;
110763 case 252: /* cmd ::= VACUUM */
110764 case 253: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==253);
110765 {sqlite3Vacuum(pParse);}
110766 break;
110767 case 254: /* cmd ::= PRAGMA nm dbnm */
110768 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110769 break;
110770 case 255: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110771 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110772 break;
110773 case 256: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110774 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110775 break;
110776 case 257: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110777 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110778 break;
110779 case 258: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110780 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110781 break;
110782 case 268: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110783 {
110784 Token all;
110785 all.z = yymsp[-3].minor.yy0.z;
110786 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110787 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110788 }
110789 break;
110790 case 269: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110791 {
110792 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110793 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110794 }
110795 break;
110796 case 270: /* trigger_time ::= BEFORE */
110797 case 273: /* trigger_time ::= */ yytestcase(yyruleno==273);
110798 { yygotominor.yy392 = TK_BEFORE; }
110799 break;
110800 case 271: /* trigger_time ::= AFTER */
110801 { yygotominor.yy392 = TK_AFTER; }
110802 break;
110803 case 272: /* trigger_time ::= INSTEAD OF */
110804 { yygotominor.yy392 = TK_INSTEAD;}
110805 break;
110806 case 274: /* trigger_event ::= DELETE|INSERT */
110807 case 275: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==275);
110808 {yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
110809 break;
110810 case 276: /* trigger_event ::= UPDATE OF inscollist */
110811 {yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
110812 break;
110813 case 279: /* when_clause ::= */
110814 case 301: /* key_opt ::= */ yytestcase(yyruleno==301);
110815 { yygotominor.yy122 = 0; }
110816 break;
110817 case 280: /* when_clause ::= WHEN expr */
110818 case 302: /* key_opt ::= KEY expr */ yytestcase(yyruleno==302);
110819 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
110820 break;
110821 case 281: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
110822 {
110823 assert( yymsp[-2].minor.yy327!=0 );
110824 yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
110825 yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
110826 yygotominor.yy327 = yymsp[-2].minor.yy327;
110827 }
110828 break;
110829 case 282: /* trigger_cmd_list ::= trigger_cmd SEMI */
110830 {
110831 assert( yymsp[-1].minor.yy327!=0 );
110832 yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
110833 yygotominor.yy327 = yymsp[-1].minor.yy327;
110834 }
110835 break;
110836 case 284: /* trnm ::= nm DOT nm */
110837 {
110838 yygotominor.yy0 = yymsp[0].minor.yy0;
110839 sqlite3ErrorMsg(pParse,
110840 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
110841 "statements within triggers");
110842 }
110843 break;
110844 case 286: /* tridxby ::= INDEXED BY nm */
110845 {
110846 sqlite3ErrorMsg(pParse,
110847 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
110848 "within triggers");
110849 }
110850 break;
110851 case 287: /* tridxby ::= NOT INDEXED */
110852 {
110853 sqlite3ErrorMsg(pParse,
110854 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
110855 "within triggers");
110856 }
110857 break;
110858 case 288: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
110859 { yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
110860 break;
110861 case 289: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
110862 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
110863 break;
110864 case 290: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
110865 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
110866 break;
110867 case 291: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
110868 {yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
110869 break;
110870 case 292: /* trigger_cmd ::= select */
110871 {yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
110872 break;
110873 case 293: /* expr ::= RAISE LP IGNORE RP */
110874 {
110875 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
110876 if( yygotominor.yy342.pExpr ){
110877 yygotominor.yy342.pExpr->affinity = OE_Ignore;
110878 }
110879 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110880 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110881 }
110882 break;
110883 case 294: /* expr ::= RAISE LP raisetype COMMA nm RP */
110884 {
110885 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
110886 if( yygotominor.yy342.pExpr ) {
110887 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
110888 }
110889 yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
110890 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110891 }
110892 break;
110893 case 295: /* raisetype ::= ROLLBACK */
110894 {yygotominor.yy392 = OE_Rollback;}
110895 break;
110896 case 297: /* raisetype ::= FAIL */
110897 {yygotominor.yy392 = OE_Fail;}
110898 break;
110899 case 298: /* cmd ::= DROP TRIGGER ifexists fullname */
110900 {
110901 sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
110902 }
110903 break;
110904 case 299: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
110905 {
110906 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
110907 }
110908 break;
110909 case 300: /* cmd ::= DETACH database_kw_opt expr */
110910 {
110911 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
110912 }
110913 break;
110914 case 305: /* cmd ::= REINDEX */
110915 {sqlite3Reindex(pParse, 0, 0);}
110916 break;
110917 case 306: /* cmd ::= REINDEX nm dbnm */
110918 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110919 break;
110920 case 307: /* cmd ::= ANALYZE */
110921 {sqlite3Analyze(pParse, 0, 0);}
110922 break;
110923 case 308: /* cmd ::= ANALYZE nm dbnm */
110924 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
110925 break;
110926 case 309: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
110927 {
110928 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
110929 }
110930 break;
110931 case 310: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
110932 {
110933 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
110934 }
110935 break;
110936 case 311: /* add_column_fullname ::= fullname */
110937 {
110938 pParse->db->lookaside.bEnabled = 0;
110939 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
110940 }
110941 break;
110942 case 314: /* cmd ::= create_vtab */
110943 {sqlite3VtabFinishParse(pParse,0);}
110944 break;
110945 case 315: /* cmd ::= create_vtab LP vtabarglist RP */
110946 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
110947 break;
110948 case 316: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
110949 {
110950 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
110951 }
110952 break;
110953 case 319: /* vtabarg ::= */
110954 {sqlite3VtabArgInit(pParse);}
110955 break;
110956 case 321: /* vtabargtoken ::= ANY */
110957 case 322: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==322);
110958 case 323: /* lp ::= LP */ yytestcase(yyruleno==323);
110959 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
110960 break;
110961 default:
110962 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
110963 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
110973 /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
110974 /* (35) columnlist ::= column */ yytestcase(yyruleno==35);
110975 /* (44) type ::= */ yytestcase(yyruleno==44);
110976 /* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
110977 /* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
110978 /* (53) carglist ::= carglist carg */ yytestcase(yyruleno==53);
110979 /* (54) carglist ::= */ yytestcase(yyruleno==54);
110980 /* (55) carg ::= CONSTRAINT nm ccons */ yytestcase(yyruleno==55);
110981 /* (56) carg ::= ccons */ yytestcase(yyruleno==56);
110982 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
110983 /* (90) conslist ::= conslist COMMA tcons */ yytestcase(yyruleno==90);
110984 /* (91) conslist ::= conslist tcons */ yytestcase(yyruleno==91);
110985 /* (92) conslist ::= tcons */ yytestcase(yyruleno==92);
110986 /* (93) tcons ::= CONSTRAINT nm */ yytestcase(yyruleno==93);
110987 /* (277) foreach_clause ::= */ yytestcase(yyruleno==277);
110988 /* (278) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==278);
110989 /* (285) tridxby ::= */ yytestcase(yyruleno==285);
110990 /* (303) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==303);
110991 /* (304) database_kw_opt ::= */ yytestcase(yyruleno==304);
110992 /* (312) kwcolumn_opt ::= */ yytestcase(yyruleno==312);
110993 /* (313) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==313);
110994 /* (317) vtabarglist ::= vtabarg */ yytestcase(yyruleno==317);
110995 /* (318) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==318);
110996 /* (320) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==320);
110997 /* (324) anylist ::= */ yytestcase(yyruleno==324);
110998 /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110999 /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
111000 break;
111001 };
111002 yygoto = yyRuleInfo[yyruleno].lhs;
111003 yysize = yyRuleInfo[yyruleno].nrhs;
111004 yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
115889 ** option. But that functionality is no longer supported.
115890 **
115891 ** A doclist is stored like this:
115892 **
115893 ** array {
115894 ** varint docid;
115895 ** array { (position list for column 0)
115896 ** varint position; (2 more than the delta from previous position)
115897 ** }
115898 ** array {
115899 ** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
115920 ** The 123 value is the first docid. For column zero in this document
115921 ** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
115922 ** at D signals the start of a new column; the 1 at E indicates that the
115923 ** new column is column number 1. There are two positions at 12 and 45
115924 ** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
115925 ** 234 at I is the next docid. It has one position 72 (72-2) and then
115926 ** terminates with the 0 at K.
115927 **
115928 ** A "position-list" is the list of positions for multiple columns for
115929 ** a single docid. A "column-list" is the set of positions for a single
115930 ** column. Hence, a position-list consists of one or more column-lists,
115931 ** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116456
116457
116458 #ifndef MIN
116459 # define MIN(x,y) ((x)<(y)?(x):(y))
116460 #endif
 
 
 
116461
116462 /*
116463 ** Maximum length of a varint encoded integer. The varint format is different
116464 ** from that used by SQLite, so the maximum length is 10, not 9.
116465 */
@@ -116510,20 +116700,21 @@
116510 #ifdef SQLITE_COVERAGE_TEST
116511 # define ALWAYS(x) (1)
116512 # define NEVER(X) (0)
116513 #else
116514 # define ALWAYS(x) (x)
116515 # define NEVER(X) (x)
116516 #endif
116517
116518 /*
116519 ** Internal types used by SQLite.
116520 */
116521 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116522 typedef short int i16; /* 2-byte (or larger) signed integer */
116523 typedef unsigned int u32; /* 4-byte unsigned integer */
116524 typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
 
116525
116526 /*
116527 ** Macro used to suppress compiler warnings for unused parameters.
116528 */
116529 #define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116582 int nColumn; /* number of named columns in virtual table */
116583 char **azColumn; /* column names. malloced */
116584 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116585 char *zContentTbl; /* content=xxx option, or NULL */
116586 char *zLanguageid; /* languageid=xxx option, or NULL */
 
 
116587
116588 /* Precompiled statements used by the implementation. Each of these
116589 ** statements is run and reset within a single virtual table API call.
116590 */
116591 sqlite3_stmt *aStmt[28];
116592
116593 char *zReadExprlist;
116594 char *zWriteExprlist;
116595
116596 int nNodeSize; /* Soft limit for node size */
 
116597 u8 bHasStat; /* True if %_stat table exists */
116598 u8 bHasDocsize; /* True if %_docsize table exists */
116599 u8 bDescIdx; /* True if doclists are in reverse order */
 
116600 int nPgsz; /* Page size for host database */
116601 char *zSegmentsTbl; /* Name of %_segments table */
116602 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116603
116604 /* TODO: Fix the first paragraph of this comment.
116605 **
116606 ** The following array of hash tables is used to buffer pending index
116607 ** updates during transactions. Variable nPendingData estimates the memory
116608 ** size of the pending data, including hash table overhead, not including
116609 ** malloc overhead. When nPendingData exceeds nMaxPendingData, the buffer
116610 ** is flushed automatically. Variable iPrevDocid is the docid of the most
116611 ** recently inserted record.
116612 **
116613 ** A single FTS4 table may have multiple full-text indexes. For each index
116614 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116615 ** terms that appear in the document set. Each subsequent index in aIndex[]
116616 ** is an index of prefixes of a specific length.
 
 
 
 
 
 
116617 */
116618 int nIndex; /* Size of aIndex[] */
116619 struct Fts3Index {
116620 int nPrefix; /* Prefix length (0 for main terms index) */
116621 Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
116810 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
116811 SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
116812 SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
116813 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
116814 SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
 
116815
116816 /* Special values interpreted by sqlite3SegReaderCursor() */
116817 #define FTS3_SEGCURSOR_PENDING -1
116818 #define FTS3_SEGCURSOR_ALL -2
116819
@@ -116861,19 +117060,22 @@
116861 int nTerm; /* Size of zTerm in bytes */
116862 char *aDoclist; /* Pointer to doclist buffer */
116863 int nDoclist; /* Size of aDoclist[] in bytes */
116864 };
116865
 
 
116866 /* fts3.c */
116867 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
116868 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
116869 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
116870 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
116871 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
116872 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
116873 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
116874 SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
 
116875
116876 /* fts3_tokenizer.c */
116877 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
116878 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
116879 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117198 sqlite3_free(zSql);
117199 sqlite3_free(zCols);
117200 *pRc = rc;
117201 }
117202 }
 
 
 
 
 
 
 
 
 
 
 
 
117203
117204 /*
117205 ** Create the backing store tables (%_content, %_segments and %_segdir)
117206 ** required by the FTS3 table passed as the only argument. This is done
117207 ** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117259 fts3DbExec(&rc, db,
117260 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117261 p->zDb, p->zName
117262 );
117263 }
 
117264 if( p->bHasStat ){
117265 fts3DbExec(&rc, db,
117266 "CREATE TABLE %Q.'%q_stat'(id INTEGER PRIMARY KEY, value BLOB);",
117267 p->zDb, p->zName
117268 );
117269 }
117270 return rc;
117271 }
117272
117273 /*
@@ -117370,11 +117582,11 @@
117370 ** memory.
117371 */
117372 static char *fts3QuoteId(char const *zInput){
117373 int nRet;
117374 char *zRet;
117375 nRet = 2 + strlen(zInput)*2 + 1;
117376 zRet = sqlite3_malloc(nRet);
117377 if( zRet ){
117378 int i;
117379 char *z = zRet;
117380 *(z++) = '"';
@@ -117626,11 +117838,11 @@
117626 ** space required to store a copy of each column name, including the
117627 ** nul-terminator byte. */
117628 nCol = sqlite3_column_count(pStmt);
117629 for(i=0; i<nCol; i++){
117630 const char *zCol = sqlite3_column_name(pStmt, i);
117631 nStr += strlen(zCol) + 1;
117632 }
117633
117634 /* Allocate and populate the array to return. */
117635 azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117636 if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117637 rc = SQLITE_NOMEM;
117638 }else{
117639 char *p = (char *)&azCol[nCol];
117640 for(i=0; i<nCol; i++){
117641 const char *zCol = sqlite3_column_name(pStmt, i);
117642 int n = strlen(zCol)+1;
117643 memcpy(p, zCol, n);
117644 azCol[i] = p;
117645 p += n;
117646 }
117647 }
@@ -117852,11 +118064,12 @@
117852 ** column from the aCol[] array. */
117853 if( rc==SQLITE_OK && zLanguageid ){
117854 int j;
117855 for(j=0; j<nCol; j++){
117856 if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
117857 memmove(&aCol[j], &aCol[j+1], (nCol-j) * sizeof(aCol[0]));
 
117858 nCol--;
117859 break;
117860 }
117861 }
117862 }
@@ -117903,11 +118116,13 @@
117903 p->azColumn = (char **)&p[1];
117904 p->pTokenizer = pTokenizer;
117905 p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
117906 p->bHasDocsize = (isFts4 && bNoDocsize==0);
117907 p->bHasStat = isFts4;
 
117908 p->bDescIdx = bDescIdx;
 
117909 p->zContentTbl = zContent;
117910 p->zLanguageid = zLanguageid;
117911 zContent = 0;
117912 zLanguageid = 0;
117913 TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
117955 ** database. TODO: For xConnect(), it could verify that said tables exist.
117956 */
117957 if( isCreate ){
117958 rc = fts3CreateTables(p);
117959 }
 
 
 
 
 
 
 
 
 
 
117960
117961 /* Figure out the page-size for the database. This is required in order to
117962 ** estimate the cost of loading large doclists from the database. */
117963 fts3DatabasePageSize(&rc, p);
117964 p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
118959 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
118960 }
118961 }
118962
118963 *paOut = aOut;
118964 *pnOut = (p-aOut);
118965 assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
118966 return SQLITE_OK;
118967 }
118968
118969 /*
@@ -119023,11 +119248,11 @@
119023 fts3PoslistCopy(0, &p2);
119024 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119025 }
119026 }
119027
119028 *pnRight = p - aOut;
119029 }
119030
119031 /*
119032 ** Argument pList points to a position list nList bytes in size. This
119033 ** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119299 ** Set up a cursor object for iterating through a full-text index or a
119300 ** single level therein.
119301 */
119302 SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119303 Fts3Table *p, /* FTS3 table handle */
119304 int iLangid,
119305 int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119306 int iLevel, /* Level of segments to scan */
119307 const char *zTerm, /* Term to query for */
119308 int nTerm, /* Size of zTerm in bytes */
119309 int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119317 );
119318 assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119319 assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119320 assert( isPrefix==0 || isScan==0 );
119321
119322 /* "isScan" is only set to true by the ft4aux module, an ordinary
119323 ** full-text tables. */
119324 assert( isScan==0 || p->aIndex==0 );
119325
119326 memset(pCsr, 0, sizeof(Fts3MultiSegReader));
119327
119328 return fts3SegReaderCursor(
119329 p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119330 );
119331 }
119332
@@ -119587,11 +119807,11 @@
119587
119588 pCsr->iLangid = 0;
119589 if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119590
119591 rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119592 p->azColumn, p->bHasStat, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119593 );
119594 if( rc!=SQLITE_OK ){
119595 if( rc==SQLITE_ERROR ){
119596 static const char *zErr = "malformed MATCH expression: [%s]";
119597 p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119730 /*
119731 ** Implementation of xSync() method. Flush the contents of the pending-terms
119732 ** hash-table to the database.
119733 */
119734 static int fts3SyncMethod(sqlite3_vtab *pVtab){
119735 int rc = sqlite3Fts3PendingTermsFlush((Fts3Table *)pVtab);
119736 sqlite3Fts3SegmentsClose((Fts3Table *)pVtab);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119737 return rc;
119738 }
119739
119740 /*
119741 ** Implementation of xBegin() method. This is a no-op.
119742 */
119743 static int fts3BeginMethod(sqlite3_vtab *pVtab){
119744 TESTONLY( Fts3Table *p = (Fts3Table*)pVtab );
119745 UNUSED_PARAMETER(pVtab);
119746 assert( p->pSegments==0 );
119747 assert( p->nPendingData==0 );
119748 assert( p->inTransaction!=1 );
119749 TESTONLY( p->inTransaction = 1 );
119750 TESTONLY( p->mxSavepoint = -1; );
 
119751 return SQLITE_OK;
119752 }
119753
119754 /*
119755 ** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120040 ** The xSavepoint() method.
120041 **
120042 ** Flush the contents of the pending-terms table to disk.
120043 */
120044 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
 
120045 UNUSED_PARAMETER(iSavepoint);
120046 assert( ((Fts3Table *)pVtab)->inTransaction );
120047 assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120048 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120049 return fts3SyncMethod(pVtab);
 
 
 
120050 }
120051
120052 /*
120053 ** The xRelease() method.
120054 **
@@ -120404,11 +120663,11 @@
120404
120405 assert( iPrev>=0 );
120406 fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120407 sqlite3_free(aPoslist);
120408 aPoslist = pList;
120409 nPoslist = aOut - aPoslist;
120410 if( nPoslist==0 ){
120411 sqlite3_free(aPoslist);
120412 pPhrase->doclist.pList = 0;
120413 pPhrase->doclist.nList = 0;
120414 return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120448 }
120449
120450 pPhrase->doclist.pList = aOut;
120451 if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120452 pPhrase->doclist.bFreeList = 1;
120453 pPhrase->doclist.nList = (aOut - pPhrase->doclist.pList);
120454 }else{
120455 sqlite3_free(aOut);
120456 pPhrase->doclist.pList = 0;
120457 pPhrase->doclist.nList = 0;
120458 }
@@ -120544,11 +120803,11 @@
120544 fts3PoslistCopy(0, &pDocid);
120545 while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120546 iMul = (bDescIdx ? -1 : 1);
120547 }
120548
120549 *pnList = pEnd - pNext;
120550 *ppIter = pNext;
120551 *piDocid = iDocid;
120552 }else{
120553 int iMul = (bDescIdx ? -1 : 1);
120554 sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120558 if( p==aDoclist ){
120559 *pbEof = 1;
120560 }else{
120561 char *pSave = p;
120562 fts3ReversePoslist(aDoclist, &p);
120563 *pnList = (pSave - p);
120564 }
120565 *ppIter = p;
120566 }
120567 }
120568
@@ -120618,11 +120877,11 @@
120618 }else{
120619 pDL->iDocid -= iDelta;
120620 }
120621 pDL->pList = pIter;
120622 fts3PoslistCopy(0, &pIter);
120623 pDL->nList = (pIter - pDL->pList);
120624
120625 /* pIter now points just past the 0x00 that terminates the position-
120626 ** list for document pDL->iDocid. However, if this position-list was
120627 ** edited in place by fts3EvalNearTrim(), then pIter may not actually
120628 ** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
120959
120960 /* Allocate a MultiSegReader for each token in the expression. */
120961 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
120962
120963 /* Determine which, if any, tokens in the expression should be deferred. */
120964 if( rc==SQLITE_OK && nToken>1 && pTab->bHasStat ){
120965 Fts3TokenAndCost *aTC;
120966 Fts3Expr **apOr;
120967 aTC = (Fts3TokenAndCost *)sqlite3_malloc(
120968 sizeof(Fts3TokenAndCost) * nToken
120969 + sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
120976 int ii;
120977 Fts3TokenAndCost *pTC = aTC;
120978 Fts3Expr **ppOr = apOr;
120979
120980 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
120981 nToken = pTC-aTC;
120982 nOr = ppOr-apOr;
120983
120984 if( rc==SQLITE_OK ){
120985 rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
120986 for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
120987 rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121049 p2 = pOut = pPhrase->doclist.pList;
121050 res = fts3PoslistNearMerge(
121051 &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121052 );
121053 if( res ){
121054 nNew = (pOut - pPhrase->doclist.pList) - 1;
121055 assert( pPhrase->doclist.pList[nNew]=='\0' );
121056 assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121057 memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121058 pPhrase->doclist.nList = nNew;
121059 *paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
121774 fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
121775 pPhrase->aToken[i].pSegcsr = 0;
121776 }
121777 }
121778 }
 
121779
121780 /*
121781 ** Return SQLITE_CORRUPT_VTAB.
121782 */
121783 #ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
121882 );
121883 return SQLITE_ERROR;
121884 }
121885
121886 zDb = argv[1];
121887 nDb = strlen(zDb);
121888 zFts3 = argv[3];
121889 nFts3 = strlen(zFts3);
121890
121891 rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
121892 if( rc!=SQLITE_OK ) return rc;
121893
121894 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125074
125075 /* #include <string.h> */
125076 /* #include <assert.h> */
125077 /* #include <stdlib.h> */
125078
 
 
 
125079 /*
125080 ** When full-text index nodes are loaded from disk, the buffer that they
125081 ** are loaded into has the following number of bytes of padding at the end
125082 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125083 ** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125112 # define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125113 #else
125114 # define FTS3_NODE_CHUNKSIZE (4*1024)
125115 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125116 #endif
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125117
125118 typedef struct PendingList PendingList;
125119 typedef struct SegmentNode SegmentNode;
125120 typedef struct SegmentWriter SegmentWriter;
125121
@@ -125274,19 +125560,26 @@
125274 #define SQL_DELETE_SEGMENTS_RANGE 17
125275 #define SQL_CONTENT_INSERT 18
125276 #define SQL_DELETE_DOCSIZE 19
125277 #define SQL_REPLACE_DOCSIZE 20
125278 #define SQL_SELECT_DOCSIZE 21
125279 #define SQL_SELECT_DOCTOTAL 22
125280 #define SQL_REPLACE_DOCTOTAL 23
125281
125282 #define SQL_SELECT_ALL_PREFIX_LEVEL 24
125283 #define SQL_DELETE_ALL_TERMS_SEGDIR 25
125284
125285 #define SQL_DELETE_SEGDIR_RANGE 26
125286
125287 #define SQL_SELECT_ALL_LANGID 27
 
 
 
 
 
 
 
 
 
125288
125289 /*
125290 ** This function is used to obtain an SQLite prepared statement handle
125291 ** for the statement identified by the second argument. If successful,
125292 ** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125311 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
125312 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
125313 /* 6 */ "DELETE FROM %Q.'%q_stat'",
125314 /* 7 */ "SELECT %s WHERE rowid=?",
125315 /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125316 /* 9 */ "INSERT INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125317 /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125318 /* 11 */ "INSERT INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125319
125320 /* Return segments in order from oldest to newest.*/
125321 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125322 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125323 /* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125331 /* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125332 /* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125333 /* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125334 /* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125335 /* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125336 /* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=0",
125337 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(0,?)",
125338 /* 24 */ "",
125339 /* 25 */ "",
125340
125341 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125342 /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125343
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125344 };
125345 int rc = SQLITE_OK;
125346 sqlite3_stmt *pStmt;
125347
125348 assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125375 }
125376 }
125377 *pp = pStmt;
125378 return rc;
125379 }
 
125380
125381 static int fts3SelectDocsize(
125382 Fts3Table *pTab, /* FTS3 table handle */
125383 int eStmt, /* Either SQL_SELECT_DOCSIZE or DOCTOTAL */
125384 sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125385 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125386 ){
125387 sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125388 int rc; /* Return code */
125389
125390 assert( eStmt==SQL_SELECT_DOCSIZE || eStmt==SQL_SELECT_DOCTOTAL );
125391
125392 rc = fts3SqlStmt(pTab, eStmt, &pStmt, 0);
125393 if( rc==SQLITE_OK ){
125394 if( eStmt==SQL_SELECT_DOCSIZE ){
125395 sqlite3_bind_int64(pStmt, 1, iDocid);
125396 }
125397 rc = sqlite3_step(pStmt);
125398 if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125399 rc = sqlite3_reset(pStmt);
125400 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125401 pStmt = 0;
@@ -125410,19 +125746,33 @@
125410
125411 SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125412 Fts3Table *pTab, /* Fts3 table handle */
125413 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125414 ){
125415 return fts3SelectDocsize(pTab, SQL_SELECT_DOCTOTAL, 0, ppStmt);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125416 }
125417
125418 SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125419 Fts3Table *pTab, /* Fts3 table handle */
125420 sqlite3_int64 iDocid, /* Docid to read size data for */
125421 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125422 ){
125423 return fts3SelectDocsize(pTab, SQL_SELECT_DOCSIZE, iDocid, ppStmt);
125424 }
125425
125426 /*
125427 ** Similar to fts3SqlStmt(). Except, after binding the parameters in
125428 ** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125484 }
125485
125486 return rc;
125487 }
125488
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
125489 static sqlite3_int64 getAbsoluteLevel(
125490 Fts3Table *p,
125491 int iLangid,
125492 int iIndex,
125493 int iLevel
125494 ){
 
125495 assert( iLangid>=0 );
125496 assert( p->nIndex>0 );
125497 assert( iIndex>=0 && iIndex<p->nIndex );
125498 return (iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL + iLevel;
 
 
125499 }
125500
125501
125502 /*
125503 ** Set *ppStmt to a statement handle that may be used to iterate through
125504 ** all rows in the %_segdir table, from oldest to newest. If successful,
125505 ** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125518 */
125519 SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125520 Fts3Table *p, /* FTS3 table */
125521 int iLangid, /* Language being queried */
125522 int iIndex, /* Index for p->aIndex[] */
125523 int iLevel, /* Level to select */
125524 sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125525 ){
125526 int rc;
125527 sqlite3_stmt *pStmt = 0;
125528
@@ -125533,19 +125908,19 @@
125533 if( iLevel<0 ){
125534 /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125535 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125536 if( rc==SQLITE_OK ){
125537 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125538 sqlite3_bind_int(pStmt, 2,
125539 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125540 );
125541 }
125542 }else{
125543 /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125544 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125545 if( rc==SQLITE_OK ){
125546 sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
125547 }
125548 }
125549 *ppStmt = pStmt;
125550 return rc;
125551 }
@@ -126062,10 +126437,11 @@
126062 ** full, merge all segments in level iLevel into a single iLevel+1
126063 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126064 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126065 */
126066 if( iNext>=FTS3_MERGE_COUNT ){
 
126067 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126068 *piIdx = 0;
126069 }else{
126070 *piIdx = iNext;
126071 }
@@ -126109,11 +126485,11 @@
126109 int *pnLoad /* OUT: Bytes actually loaded */
126110 ){
126111 int rc; /* Return code */
126112
126113 /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126114 assert( pnBlob);
126115
126116 if( p->pSegments ){
126117 rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126118 }else{
126119 if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126450 int nOvfl = 0;
126451 int ii;
126452 int rc = SQLITE_OK;
126453 int pgsz = p->nPgsz;
126454
126455 assert( p->bHasStat );
126456 assert( pgsz>0 );
126457
126458 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126459 Fts3SegReader *pReader = pMsr->apSegment[ii];
126460 if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
126807 sqlite3_step(pStmt);
126808 rc = sqlite3_reset(pStmt);
126809 }
126810 return rc;
126811 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126812
126813 /*
126814 ** Insert a record into the %_segdir table.
126815 */
126816 static int fts3WriteSegdir(
126817 Fts3Table *p, /* Virtual table handle */
126818 int iLevel, /* Value for "level" field */
126819 int iIdx, /* Value for "idx" field */
126820 sqlite3_int64 iStartBlock, /* Value for "start_block" field */
126821 sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
126822 sqlite3_int64 iEndBlock, /* Value for "end_block" field */
126823 char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
126824 int nRoot /* Number of bytes in buffer zRoot */
126825 ){
126826 sqlite3_stmt *pStmt;
126827 int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
126828 if( rc==SQLITE_OK ){
126829 sqlite3_bind_int(pStmt, 1, iLevel);
126830 sqlite3_bind_int(pStmt, 2, iIdx);
126831 sqlite3_bind_int64(pStmt, 3, iStartBlock);
126832 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
126833 sqlite3_bind_int64(pStmt, 5, iEndBlock);
126834 sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127124 int rc;
127125
127126 /* The current leaf node is full. Write it out to the database. */
127127 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127128 if( rc!=SQLITE_OK ) return rc;
 
127129
127130 /* Add the current term to the interior node tree. The term added to
127131 ** the interior tree must:
127132 **
127133 ** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127207 ** returned. Otherwise, an SQLite error code.
127208 */
127209 static int fts3SegWriterFlush(
127210 Fts3Table *p, /* Virtual table handle */
127211 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127212 int iLevel, /* Value for 'level' column of %_segdir */
127213 int iIdx /* Value for 'idx' column of %_segdir */
127214 ){
127215 int rc; /* Return code */
127216 if( pWriter->pTree ){
127217 sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127232 }else{
127233 /* The entire tree fits on the root node. Write it to the segdir table. */
127234 rc = fts3WriteSegdir(
127235 p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127236 }
 
127237 return rc;
127238 }
127239
127240 /*
127241 ** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127289 */
127290 static int fts3SegmentMaxLevel(
127291 Fts3Table *p,
127292 int iLangid,
127293 int iIndex,
127294 int *pnMax
127295 ){
127296 sqlite3_stmt *pStmt;
127297 int rc;
127298 assert( iIndex>=0 && iIndex<p->nIndex );
127299
@@ -127303,19 +127702,42 @@
127303 **
127304 ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127305 */
127306 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127307 if( rc!=SQLITE_OK ) return rc;
127308 sqlite3_bind_int(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127309 sqlite3_bind_int(pStmt, 2,
127310 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127311 );
127312 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127313 *pnMax = sqlite3_column_int(pStmt, 0);
127314 }
127315 return sqlite3_reset(pStmt);
127316 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127317
127318 /*
127319 ** This function is used after merging multiple segments into a single large
127320 ** segment to delete the old, now redundant, segment b-trees. Specifically,
127321 ** it:
@@ -127335,41 +127757,36 @@
127335 int iIndex, /* Index for p->aIndex */
127336 int iLevel, /* Level of %_segdir entries to delete */
127337 Fts3SegReader **apSegment, /* Array of SegReader objects */
127338 int nReader /* Size of array apSegment */
127339 ){
127340 int rc; /* Return Code */
127341 int i; /* Iterator variable */
127342 sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127343
127344 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127345 for(i=0; rc==SQLITE_OK && i<nReader; i++){
127346 Fts3SegReader *pSegment = apSegment[i];
127347 if( pSegment->iStartBlock ){
127348 sqlite3_bind_int64(pDelete, 1, pSegment->iStartBlock);
127349 sqlite3_bind_int64(pDelete, 2, pSegment->iEndBlock);
127350 sqlite3_step(pDelete);
127351 rc = sqlite3_reset(pDelete);
127352 }
127353 }
127354 if( rc!=SQLITE_OK ){
127355 return rc;
127356 }
127357
127358 assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127359 if( iLevel==FTS3_SEGCURSOR_ALL ){
127360 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127361 if( rc==SQLITE_OK ){
127362 sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127363 sqlite3_bind_int(pDelete, 2,
127364 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127365 );
127366 }
127367 }else{
127368 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127369 if( rc==SQLITE_OK ){
127370 sqlite3_bind_int(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
 
 
127371 }
127372 }
127373
127374 if( rc==SQLITE_OK ){
127375 sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
127842 int iIndex, /* Index in p->aIndex[] to merge */
127843 int iLevel /* Level to merge */
127844 ){
127845 int rc; /* Return code */
127846 int iIdx = 0; /* Index of new segment */
127847 int iNewLevel = 0; /* Level/index to create new segment at */
127848 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
127849 Fts3SegFilter filter; /* Segment term filter condition */
127850 Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
127851 int bIgnoreEmpty = 0; /* True to ignore empty segments */
127852
@@ -127921,15 +128338,32 @@
127921 ** Flush the contents of pendingTerms to level 0 segments.
127922 */
127923 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
127924 int rc = SQLITE_OK;
127925 int i;
 
127926 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
127927 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
127928 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
127929 }
127930 sqlite3Fts3PendingTermsClear(p);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
127931 return rc;
127932 }
127933
127934 /*
127935 ** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128036 if( a==0 ){
128037 *pRC = SQLITE_NOMEM;
128038 return;
128039 }
128040 pBlob = (char*)&a[nStat];
128041 rc = fts3SqlStmt(p, SQL_SELECT_DOCTOTAL, &pStmt, 0);
128042 if( rc ){
128043 sqlite3_free(a);
128044 *pRC = rc;
128045 return;
128046 }
 
128047 if( sqlite3_step(pStmt)==SQLITE_ROW ){
128048 fts3DecodeIntArray(nStat, a,
128049 sqlite3_column_blob(pStmt, 0),
128050 sqlite3_column_bytes(pStmt, 0));
128051 }else{
@@ -128065,17 +128500,18 @@
128065 x = x + aSzIns[i] - aSzDel[i];
128066 }
128067 a[i+1] = x;
128068 }
128069 fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128070 rc = fts3SqlStmt(p, SQL_REPLACE_DOCTOTAL, &pStmt, 0);
128071 if( rc ){
128072 sqlite3_free(a);
128073 *pRC = rc;
128074 return;
128075 }
128076 sqlite3_bind_blob(pStmt, 1, pBlob, nBlob, SQLITE_STATIC);
 
128077 sqlite3_step(pStmt);
128078 *pRC = sqlite3_reset(pStmt);
128079 sqlite3_free(a);
128080 }
128081
@@ -128176,11 +128612,11 @@
128176 for(iCol=0; iCol<=p->nColumn; iCol++){
128177 aSzIns[iCol] += aSz[iCol];
128178 }
128179 }
128180 }
128181 if( p->bHasStat ){
128182 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128183 }
128184 sqlite3_free(aSz);
128185
128186 if( pStmt ){
@@ -128192,10 +128628,1692 @@
128192 }
128193
128194 return rc;
128195 }
128196
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
128197 /*
128198 ** Handle a 'special' INSERT of the form:
128199 **
128200 ** "INSERT INTO tbl(tbl) VALUES(<expr>)"
128201 **
@@ -128211,10 +130329,16 @@
128211 return SQLITE_NOMEM;
128212 }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
128213 rc = fts3DoOptimize(p, 0);
128214 }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
128215 rc = fts3DoRebuild(p);
 
 
 
 
 
 
128216 #ifdef SQLITE_TEST
128217 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
128218 p->nNodeSize = atoi(&zVal[9]);
128219 rc = SQLITE_OK;
128220 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
128406 /*
128407 ** This function does the work for the xUpdate method of FTS3 virtual
128408 ** tables. The schema of the virtual table being:
128409 **
128410 ** CREATE TABLE <table name>(
128411 ** <user COLUMns>,
128412 ** <table name> HIDDEN,
128413 ** docid HIDDEN,
128414 ** <langid> HIDDEN
128415 ** );
128416 **
@@ -128538,11 +130662,11 @@
128538 fts3InsertDocsize(&rc, p, aSzIns);
128539 }
128540 nChng++;
128541 }
128542
128543 if( p->bHasStat ){
128544 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
128545 }
128546
128547 update_out:
128548 sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
129369 char cArg,
129370 char **pzErr
129371 ){
129372 if( (cArg==FTS3_MATCHINFO_NPHRASE)
129373 || (cArg==FTS3_MATCHINFO_NCOL)
129374 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bHasStat)
129375 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bHasStat)
129376 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
129377 || (cArg==FTS3_MATCHINFO_LCS)
129378 || (cArg==FTS3_MATCHINFO_HITS)
129379 ){
129380 return SQLITE_OK;
@@ -133134,12 +135258,12 @@
133134 }
133135
133136 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
133137
133138 /* Allocate the sqlite3_vtab structure */
133139 nDb = strlen(argv[1]);
133140 nName = strlen(argv[2]);
133141 pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
133142 if( !pRtree ){
133143 return SQLITE_NOMEM;
133144 }
133145 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
133230 RtreeCell cell;
133231 int jj;
133232
133233 nodeGetCell(&tree, &node, ii, &cell);
133234 sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
133235 nCell = strlen(zCell);
133236 for(jj=0; jj<tree.nDim*2; jj++){
133237 sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
133238 nCell = strlen(zCell);
133239 }
133240
133241 if( zText ){
133242 char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
133243 sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
133976 int iInput = 0;
133977 int iOut = 0;
133978
133979 *ppCursor = 0;
133980
133981 if( nInput<0 ){
 
 
 
133982 nInput = strlen(zInput);
133983 }
133984 nChar = nInput+1;
133985 pCsr = (IcuCursor *)sqlite3_malloc(
133986 sizeof(IcuCursor) + /* IcuCursor */
133987
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -1,8 +1,8 @@
1 /******************************************************************************
2 ** This file is an amalgamation of many separate C source files from SQLite
3 ** version 3.7.12. By combining all the individual C code files into this
4 ** single large file, the entire code can be compiled as a single translation
5 ** unit. This allows many compilers to do optimizations that would not be
6 ** possible if the files were compiled separately. Performance improvements
7 ** of 5% or more are commonly seen when SQLite is compiled as a single
8 ** translation unit.
@@ -655,13 +655,13 @@
655 **
656 ** See also: [sqlite3_libversion()],
657 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
658 ** [sqlite_version()] and [sqlite_source_id()].
659 */
660 #define SQLITE_VERSION "3.7.12"
661 #define SQLITE_VERSION_NUMBER 3007012
662 #define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
663
664 /*
665 ** CAPI3REF: Run-Time Library Version Numbers
666 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
667 **
@@ -6554,10 +6554,21 @@
6554 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6555 ** <dd>This parameter returns the number of pager cache misses that have
6556 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6557 ** is always 0.
6558 ** </dd>
6559 **
6560 ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6561 ** <dd>This parameter returns the number of dirty cache entries that have
6562 ** been written to disk. Specifically, the number of pages written to the
6563 ** wal file in wal mode databases, or the number of pages written to the
6564 ** database file in rollback mode databases. Any pages written as part of
6565 ** transaction rollback or database recovery operations are not included.
6566 ** If an IO or other error occurs while writing a page to disk, the effect
6567 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6568 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6569 ** </dd>
6570 ** </dl>
6571 */
6572 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6573 #define SQLITE_DBSTATUS_CACHE_USED 1
6574 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6565,11 +6576,12 @@
6576 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6577 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6578 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6579 #define SQLITE_DBSTATUS_CACHE_HIT 7
6580 #define SQLITE_DBSTATUS_CACHE_MISS 8
6581 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6582 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
6583
6584
6585 /*
6586 ** CAPI3REF: Prepared Statement Status
6587 **
@@ -9919,18 +9931,22 @@
9931 void (*xDestroy)(void *);
9932 void *pUserData;
9933 };
9934
9935 /*
9936 ** Possible values for FuncDef.flags. Note that the _LENGTH and _TYPEOF
9937 ** values must correspond to OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG. There
9938 ** are assert() statements in the code to verify this.
9939 */
9940 #define SQLITE_FUNC_LIKE 0x01 /* Candidate for the LIKE optimization */
9941 #define SQLITE_FUNC_CASE 0x02 /* Case-sensitive LIKE-type function */
9942 #define SQLITE_FUNC_EPHEM 0x04 /* Ephemeral. Delete with VDBE */
9943 #define SQLITE_FUNC_NEEDCOLL 0x08 /* sqlite3GetFuncCollSeq() might be called */
9944 #define SQLITE_FUNC_COUNT 0x10 /* Built-in count(*) aggregate */
9945 #define SQLITE_FUNC_COALESCE 0x20 /* Built-in coalesce() or ifnull() function */
9946 #define SQLITE_FUNC_LENGTH 0x40 /* Built-in length() function */
9947 #define SQLITE_FUNC_TYPEOF 0x80 /* Built-in typeof() function */
9948
9949 /*
9950 ** The following three macros, FUNCTION(), LIKEFUNC() and AGGREGATE() are
9951 ** used to create the initializers for the FuncDef structures.
9952 **
@@ -9954,11 +9970,14 @@
9970 ** available as the function user-data (sqlite3_user_data()). The
9971 ** FuncDef.flags variable is set to the value passed as the flags
9972 ** parameter.
9973 */
9974 #define FUNCTION(zName, nArg, iArg, bNC, xFunc) \
9975 {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL), \
9976 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9977 #define FUNCTION2(zName, nArg, iArg, bNC, xFunc, extraFlags) \
9978 {nArg, SQLITE_UTF8, (bNC*SQLITE_FUNC_NEEDCOLL)|extraFlags, \
9979 SQLITE_INT_TO_PTR(iArg), 0, xFunc, 0, 0, #zName, 0, 0}
9980 #define STR_FUNCTION(zName, nArg, pArg, bNC, xFunc) \
9981 {nArg, SQLITE_UTF8, bNC*SQLITE_FUNC_NEEDCOLL, \
9982 pArg, 0, xFunc, 0, 0, #zName, 0, 0}
9983 #define LIKEFUNC(zName, nArg, arg, flags) \
@@ -10184,11 +10203,11 @@
10203 u8 tabFlags; /* Mask of TF_* values */
10204 u8 keyConf; /* What to do in case of uniqueness conflict on iPKey */
10205 FKey *pFKey; /* Linked list of all foreign keys in this table */
10206 char *zColAff; /* String defining the affinity of each column */
10207 #ifndef SQLITE_OMIT_CHECK
10208 ExprList *pCheck; /* All CHECK constraints */
10209 #endif
10210 #ifndef SQLITE_OMIT_ALTERTABLE
10211 int addColOffset; /* Offset in CREATE TABLE stmt to add a new column */
10212 #endif
10213 #ifndef SQLITE_OMIT_VIRTUALTABLE
@@ -10577,10 +10596,11 @@
10596 ** TK_VARIABLE: variable number (always >= 1). */
10597 i16 iAgg; /* Which entry in pAggInfo->aCol[] or ->aFunc[] */
10598 i16 iRightJoinTable; /* If EP_FromJoin, the right table of the join */
10599 u8 flags2; /* Second set of flags. EP2_... */
10600 u8 op2; /* If a TK_REGISTER, the original value of Expr.op */
10601 /* If TK_COLUMN, the value of p5 for OP_Column */
10602 AggInfo *pAggInfo; /* Used by TK_AGG_COLUMN and TK_AGG_FUNCTION */
10603 Table *pTab; /* Table for TK_COLUMN expressions. */
10604 #if SQLITE_MAX_EXPR_DEPTH>0
10605 int nHeight; /* Height of the tree headed by this node */
10606 #endif
@@ -10599,11 +10619,11 @@
10619 #define EP_InfixFunc 0x0080 /* True for an infix function: LIKE, GLOB, etc */
10620 #define EP_ExpCollate 0x0100 /* Collating sequence specified explicitly */
10621 #define EP_FixedDest 0x0200 /* Result needed in a specific register */
10622 #define EP_IntValue 0x0400 /* Integer value contained in u.iValue */
10623 #define EP_xIsSelect 0x0800 /* x.pSelect is valid (otherwise x.pList is) */
10624 #define EP_Hint 0x1000 /* Not used */
10625 #define EP_Reduced 0x2000 /* Expr struct is EXPR_REDUCEDSIZE bytes only */
10626 #define EP_TokenOnly 0x4000 /* Expr struct is EXPR_TOKENONLYSIZE bytes only */
10627 #define EP_Static 0x8000 /* Held in memory not obtained from malloc() */
10628
10629 /*
@@ -11118,10 +11138,11 @@
11138 int cookieGoto; /* Address of OP_Goto to cookie verifier subroutine */
11139 int cookieValue[SQLITE_MAX_ATTACHED+2]; /* Values of cookies to verify */
11140 int regRowid; /* Register holding rowid of CREATE TABLE entry */
11141 int regRoot; /* Register holding root page number for new objects */
11142 int nMaxArg; /* Max args passed to user function by sub-program */
11143 Token constraintName;/* Name of the constraint currently being parsed */
11144 #ifndef SQLITE_OMIT_SHARED_CACHE
11145 int nTableLock; /* Number of locks in aTableLock */
11146 TableLock *aTableLock; /* Required table locks for shared-cache mode */
11147 #endif
11148 AutoincInfo *pAinc; /* Information about AUTOINCREMENT counters */
@@ -11186,18 +11207,20 @@
11207 const char *zAuthContext; /* Put saved Parse.zAuthContext here */
11208 Parse *pParse; /* The Parse structure */
11209 };
11210
11211 /*
11212 ** Bitfield flags for P5 value in various opcodes.
11213 */
11214 #define OPFLAG_NCHANGE 0x01 /* Set to update db->nChange */
11215 #define OPFLAG_LASTROWID 0x02 /* Set to update db->lastRowid */
11216 #define OPFLAG_ISUPDATE 0x04 /* This OP_Insert is an sql UPDATE */
11217 #define OPFLAG_APPEND 0x08 /* This is likely to be an append */
11218 #define OPFLAG_USESEEKRESULT 0x10 /* Try to avoid a seek in BtreeInsert() */
11219 #define OPFLAG_CLEARCACHE 0x20 /* Clear pseudo-table cache in OP_Column */
11220 #define OPFLAG_LENGTHARG 0x40 /* OP_Column only used for length() */
11221 #define OPFLAG_TYPEOFARG 0x80 /* OP_Column only used for typeof() */
11222
11223 /*
11224 * Each trigger present in the database schema is stored as an instance of
11225 * struct Trigger.
11226 *
@@ -11677,11 +11700,11 @@
11700 #endif
11701 SQLITE_PRIVATE void sqlite3DeleteFrom(Parse*, SrcList*, Expr*);
11702 SQLITE_PRIVATE void sqlite3Update(Parse*, SrcList*, ExprList*, Expr*, int);
11703 SQLITE_PRIVATE WhereInfo *sqlite3WhereBegin(Parse*, SrcList*, Expr*, ExprList**,ExprList*,u16);
11704 SQLITE_PRIVATE void sqlite3WhereEnd(WhereInfo*);
11705 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(Parse*, Table*, int, int, int, u8);
11706 SQLITE_PRIVATE void sqlite3ExprCodeGetColumnOfTable(Vdbe*, Table*, int, int, int);
11707 SQLITE_PRIVATE void sqlite3ExprCodeMove(Parse*, int, int, int);
11708 SQLITE_PRIVATE void sqlite3ExprCodeCopy(Parse*, int, int, int);
11709 SQLITE_PRIVATE void sqlite3ExprCacheStore(Parse*, int, int, int);
11710 SQLITE_PRIVATE void sqlite3ExprCachePush(Parse*);
@@ -13509,14 +13532,16 @@
13532 ** Set *pCurrent to the total cache hits or misses encountered by all
13533 ** pagers the database handle is connected to. *pHighwater is always set
13534 ** to zero.
13535 */
13536 case SQLITE_DBSTATUS_CACHE_HIT:
13537 case SQLITE_DBSTATUS_CACHE_MISS:
13538 case SQLITE_DBSTATUS_CACHE_WRITE:{
13539 int i;
13540 int nRet = 0;
13541 assert( SQLITE_DBSTATUS_CACHE_MISS==SQLITE_DBSTATUS_CACHE_HIT+1 );
13542 assert( SQLITE_DBSTATUS_CACHE_WRITE==SQLITE_DBSTATUS_CACHE_HIT+2 );
13543
13544 for(i=0; i<db->nDb; i++){
13545 if( db->aDb[i].pBt ){
13546 Pager *pPager = sqlite3BtreePager(db->aDb[i].pBt);
13547 sqlite3PagerCacheStat(pPager, op, resetFlag, &nRet);
@@ -21259,15 +21284,15 @@
21284
21285 /*
21286 ** Some systems have stricmp(). Others have strcasecmp(). Because
21287 ** there is no consistency, we will define our own.
21288 **
21289 ** IMPLEMENTATION-OF: R-30243-02494 The sqlite3_stricmp() and
21290 ** sqlite3_strnicmp() APIs allow applications and extensions to compare
21291 ** the contents of two buffers containing UTF-8 strings in a
21292 ** case-independent fashion, using the same definition of "case
21293 ** independence" that SQLite uses internally when comparing identifiers.
21294 */
21295 SQLITE_API int sqlite3_stricmp(const char *zLeft, const char *zRight){
21296 register unsigned char *a, *b;
21297 a = (unsigned char *)zLeft;
21298 b = (unsigned char *)zRight;
@@ -33727,10 +33752,13 @@
33752 }
33753 sqlite3_free(pFile->zDeleteOnClose);
33754 }
33755 #endif
33756 OSTRACE(("CLOSE %d %s\n", pFile->h, rc ? "ok" : "failed"));
33757 if( rc ){
33758 pFile->h = NULL;
33759 }
33760 OpenCounter(-1);
33761 return rc ? SQLITE_OK
33762 : winLogError(SQLITE_IOERR_CLOSE, osGetLastError(),
33763 "winClose", pFile->zPath);
33764 }
@@ -33744,22 +33772,33 @@
33772 sqlite3_file *id, /* File to read from */
33773 void *pBuf, /* Write content into this buffer */
33774 int amt, /* Number of bytes to read */
33775 sqlite3_int64 offset /* Begin reading at this offset */
33776 ){
33777 #if !SQLITE_OS_WINCE
33778 OVERLAPPED overlapped; /* The offset for ReadFile. */
33779 #endif
33780 winFile *pFile = (winFile*)id; /* file handle */
33781 DWORD nRead; /* Number of bytes actually read from file */
33782 int nRetry = 0; /* Number of retrys */
33783
33784 assert( id!=0 );
33785 SimulateIOError(return SQLITE_IOERR_READ);
33786 OSTRACE(("READ %d lock=%d\n", pFile->h, pFile->locktype));
33787
33788 #if SQLITE_OS_WINCE
33789 if( seekWinFile(pFile, offset) ){
33790 return SQLITE_FULL;
33791 }
33792 while( !osReadFile(pFile->h, pBuf, amt, &nRead, 0) ){
33793 #else
33794 memset(&overlapped, 0, sizeof(OVERLAPPED));
33795 overlapped.Offset = (LONG)(offset & 0xffffffff);
33796 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33797 while( !osReadFile(pFile->h, pBuf, amt, &nRead, &overlapped) &&
33798 osGetLastError()!=ERROR_HANDLE_EOF ){
33799 #endif
33800 DWORD lastErrno;
33801 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33802 pFile->lastErrno = lastErrno;
33803 return winLogError(SQLITE_IOERR_READ, pFile->lastErrno,
33804 "winRead", pFile->zPath);
@@ -33782,11 +33821,11 @@
33821 sqlite3_file *id, /* File to write into */
33822 const void *pBuf, /* The bytes to be written */
33823 int amt, /* Number of bytes to write */
33824 sqlite3_int64 offset /* Offset into the file to begin writing at */
33825 ){
33826 int rc = 0; /* True if error has occured, else false */
33827 winFile *pFile = (winFile*)id; /* File handle */
33828 int nRetry = 0; /* Number of retries */
33829
33830 assert( amt>0 );
33831 assert( pFile );
@@ -33793,23 +33832,48 @@
33832 SimulateIOError(return SQLITE_IOERR_WRITE);
33833 SimulateDiskfullError(return SQLITE_FULL);
33834
33835 OSTRACE(("WRITE %d lock=%d\n", pFile->h, pFile->locktype));
33836
33837 #if SQLITE_OS_WINCE
33838 rc = seekWinFile(pFile, offset);
33839 if( rc==0 ){
33840 #else
33841 {
33842 #endif
33843 #if !SQLITE_OS_WINCE
33844 OVERLAPPED overlapped; /* The offset for WriteFile. */
33845 #endif
33846 u8 *aRem = (u8 *)pBuf; /* Data yet to be written */
33847 int nRem = amt; /* Number of bytes yet to be written */
33848 DWORD nWrite; /* Bytes written by each WriteFile() call */
33849 DWORD lastErrno = NO_ERROR; /* Value returned by GetLastError() */
33850
33851 #if !SQLITE_OS_WINCE
33852 memset(&overlapped, 0, sizeof(OVERLAPPED));
33853 overlapped.Offset = (LONG)(offset & 0xffffffff);
33854 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33855 #endif
33856
33857 while( nRem>0 ){
33858 #if SQLITE_OS_WINCE
33859 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, 0) ){
33860 #else
33861 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
33862 #endif
33863 if( retryIoerr(&nRetry, &lastErrno) ) continue;
33864 break;
33865 }
33866 if( nWrite<=0 ){
33867 lastErrno = osGetLastError();
33868 break;
33869 }
33870 #if !SQLITE_OS_WINCE
33871 offset += nWrite;
33872 overlapped.Offset = (LONG)(offset & 0xffffffff);
33873 overlapped.OffsetHigh = (LONG)((offset>>32) & 0x7fffffff);
33874 #endif
33875 aRem += nWrite;
33876 nRem -= nWrite;
33877 }
33878 if( nRem>0 ){
33879 pFile->lastErrno = lastErrno;
@@ -39094,13 +39158,13 @@
39158 i64 journalSizeLimit; /* Size limit for persistent journal files */
39159 char *zFilename; /* Name of the database file */
39160 char *zJournal; /* Name of the journal file */
39161 int (*xBusyHandler)(void*); /* Function to call when busy */
39162 void *pBusyHandlerArg; /* Context argument for xBusyHandler */
39163 int aStat[3]; /* Total cache hits, misses and writes */
39164 #ifdef SQLITE_TEST
39165 int nRead; /* Database pages read */
39166 #endif
39167 void (*xReiniter)(DbPage*); /* Call this routine when reloading pages */
39168 #ifdef SQLITE_HAS_CODEC
39169 void *(*xCodec)(void*,void*,Pgno,int); /* Routine for en/decoding data */
39170 void (*xCodecSizeChng)(void*,int,int); /* Notify of page size changes */
@@ -39113,10 +39177,19 @@
39177 Wal *pWal; /* Write-ahead log used by "journal_mode=wal" */
39178 char *zWal; /* File name for write-ahead log */
39179 #endif
39180 };
39181
39182 /*
39183 ** Indexes for use with Pager.aStat[]. The Pager.aStat[] array contains
39184 ** the values accessed by passing SQLITE_DBSTATUS_CACHE_HIT, CACHE_MISS
39185 ** or CACHE_WRITE to sqlite3_db_status().
39186 */
39187 #define PAGER_STAT_HIT 0
39188 #define PAGER_STAT_MISS 1
39189 #define PAGER_STAT_WRITE 2
39190
39191 /*
39192 ** The following global variables hold counters used for
39193 ** testing purposes only. These variables do not exist in
39194 ** a non-testing build. These variables are not thread-safe.
39195 */
@@ -41395,10 +41468,11 @@
41468 PgHdr *pList, /* List of frames to log */
41469 Pgno nTruncate, /* Database size after this commit */
41470 int isCommit /* True if this is a commit */
41471 ){
41472 int rc; /* Return code */
41473 int nList; /* Number of pages in pList */
41474 #if defined(SQLITE_DEBUG) || defined(SQLITE_CHECK_PAGES)
41475 PgHdr *p; /* For looping over pages */
41476 #endif
41477
41478 assert( pPager->pWal );
@@ -41408,22 +41482,30 @@
41482 for(p=pList; p && p->pDirty; p=p->pDirty){
41483 assert( p->pgno < p->pDirty->pgno );
41484 }
41485 #endif
41486
41487 assert( pList->pDirty==0 || isCommit );
41488 if( isCommit ){
41489 /* If a WAL transaction is being committed, there is no point in writing
41490 ** any pages with page numbers greater than nTruncate into the WAL file.
41491 ** They will never be read by any client. So remove them from the pDirty
41492 ** list here. */
41493 PgHdr *p;
41494 PgHdr **ppNext = &pList;
41495 nList = 0;
41496 for(p=pList; (*ppNext = p); p=p->pDirty){
41497 if( p->pgno<=nTruncate ){
41498 ppNext = &p->pDirty;
41499 nList++;
41500 }
41501 }
41502 assert( pList );
41503 }else{
41504 nList = 1;
41505 }
41506 pPager->aStat[PAGER_STAT_WRITE] += nList;
41507
41508 if( pList->pgno==1 ) pager_write_changecounter(pList);
41509 rc = sqlite3WalFrames(pPager->pWal,
41510 pPager->pageSize, pList, nTruncate, isCommit, pPager->walSyncFlags
41511 );
@@ -42487,19 +42569,19 @@
42569 memcpy(&pPager->dbFileVers, &pData[24], sizeof(pPager->dbFileVers));
42570 }
42571 if( pgno>pPager->dbFileSize ){
42572 pPager->dbFileSize = pgno;
42573 }
42574 pPager->aStat[PAGER_STAT_WRITE]++;
42575
42576 /* Update any backup objects copying the contents of this pager. */
42577 sqlite3BackupUpdate(pPager->pBackup, pgno, (u8*)pList->pData);
42578
42579 PAGERTRACE(("STORE %d page %d hash(%08x)\n",
42580 PAGERID(pPager), pgno, pager_pagehash(pList)));
42581 IOTRACE(("PGOUT %p %d\n", pPager, pgno));
42582 PAGER_INCR(sqlite3_pager_writedb_count);
 
42583 }else{
42584 PAGERTRACE(("NOSTORE %d page %d\n", PAGERID(pPager), pgno));
42585 }
42586 pager_set_pagehash(pList);
42587 pList = pList->pDirty;
@@ -43453,11 +43535,11 @@
43535
43536 if( (*ppPage)->pPager && !noContent ){
43537 /* In this case the pcache already contains an initialized copy of
43538 ** the page. Return without further ado. */
43539 assert( pgno<=PAGER_MAX_PGNO && pgno!=PAGER_MJ_PGNO(pPager) );
43540 pPager->aStat[PAGER_STAT_HIT]++;
43541 return SQLITE_OK;
43542
43543 }else{
43544 /* The pager cache has created a new page. Its content needs to
43545 ** be initialized. */
@@ -43495,11 +43577,11 @@
43577 }
43578 memset(pPg->pData, 0, pPager->pageSize);
43579 IOTRACE(("ZERO %p %d\n", pPager, pgno));
43580 }else{
43581 assert( pPg->pPager==pPager );
43582 pPager->aStat[PAGER_STAT_MISS]++;
43583 rc = readDbPage(pPg);
43584 if( rc!=SQLITE_OK ){
43585 goto pager_acquire_err;
43586 }
43587 }
@@ -44080,10 +44162,11 @@
44162 const void *zBuf;
44163 assert( pPager->dbFileSize>0 );
44164 CODEC2(pPager, pPgHdr->pData, 1, 6, rc=SQLITE_NOMEM, zBuf);
44165 if( rc==SQLITE_OK ){
44166 rc = sqlite3OsWrite(pPager->fd, zBuf, pPager->pageSize, 0);
44167 pPager->aStat[PAGER_STAT_WRITE]++;
44168 }
44169 if( rc==SQLITE_OK ){
44170 pPager->changeCountDone = 1;
44171 }
44172 }else{
@@ -44523,15 +44606,15 @@
44606 a[1] = sqlite3PcachePagecount(pPager->pPCache);
44607 a[2] = sqlite3PcacheGetCachesize(pPager->pPCache);
44608 a[3] = pPager->eState==PAGER_OPEN ? -1 : (int) pPager->dbSize;
44609 a[4] = pPager->eState;
44610 a[5] = pPager->errCode;
44611 a[6] = pPager->aStat[PAGER_STAT_HIT];
44612 a[7] = pPager->aStat[PAGER_STAT_MISS];
44613 a[8] = 0; /* Used to be pPager->nOvfl */
44614 a[9] = pPager->nRead;
44615 a[10] = pPager->aStat[PAGER_STAT_WRITE];
44616 return a;
44617 }
44618 #endif
44619
44620 /*
@@ -44540,24 +44623,23 @@
44623 ** current cache hit or miss count, according to the value of eStat. If the
44624 ** reset parameter is non-zero, the cache hit or miss count is zeroed before
44625 ** returning.
44626 */
44627 SQLITE_PRIVATE void sqlite3PagerCacheStat(Pager *pPager, int eStat, int reset, int *pnVal){
 
44628
44629 assert( eStat==SQLITE_DBSTATUS_CACHE_HIT
44630 || eStat==SQLITE_DBSTATUS_CACHE_MISS
44631 || eStat==SQLITE_DBSTATUS_CACHE_WRITE
44632 );
 
 
 
 
 
44633
44634 assert( SQLITE_DBSTATUS_CACHE_HIT+1==SQLITE_DBSTATUS_CACHE_MISS );
44635 assert( SQLITE_DBSTATUS_CACHE_HIT+2==SQLITE_DBSTATUS_CACHE_WRITE );
44636 assert( PAGER_STAT_HIT==0 && PAGER_STAT_MISS==1 && PAGER_STAT_WRITE==2 );
44637
44638 *pnVal += pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT];
44639 if( reset ){
44640 pPager->aStat[eStat - SQLITE_DBSTATUS_CACHE_HIT] = 0;
44641 }
44642 }
44643
44644 /*
44645 ** Return true if this is an in-memory pager.
@@ -56151,17 +56233,10 @@
56233 ** keys with no associated data. If the cursor was opened expecting an
56234 ** intkey table, the caller should be inserting integer keys with a
56235 ** blob of associated data. */
56236 assert( (pKey==0)==(pCur->pKeyInfo==0) );
56237
 
 
 
 
 
 
 
56238 /* Save the positions of any other cursors open on this table.
56239 **
56240 ** In some cases, the call to btreeMoveto() below is a no-op. For
56241 ** example, when inserting data into a table with auto-generated integer
56242 ** keys, the VDBE layer invokes sqlite3BtreeLast() to figure out the
@@ -56171,10 +56246,18 @@
56246 ** doing any work. To avoid thwarting these optimizations, it is important
56247 ** not to clear the cursor here.
56248 */
56249 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56250 if( rc ) return rc;
56251
56252 /* If this is an insert into a table b-tree, invalidate any incrblob
56253 ** cursors open on the row being replaced (assuming this is a replace
56254 ** operation - if it is not, the following is a no-op). */
56255 if( pCur->pKeyInfo==0 ){
56256 invalidateIncrblobCursors(p, nKey, 0);
56257 }
56258
56259 if( !loc ){
56260 rc = btreeMoveto(pCur, pKey, nKey, appendBias, &loc);
56261 if( rc ) return rc;
56262 }
56263 assert( pCur->eState==CURSOR_VALID || (pCur->eState==CURSOR_INVALID && loc) );
@@ -56281,16 +56364,10 @@
56364 || NEVER(pCur->eState!=CURSOR_VALID)
56365 ){
56366 return SQLITE_ERROR; /* Something has gone awry. */
56367 }
56368
 
 
 
 
 
 
56369 iCellDepth = pCur->iPage;
56370 iCellIdx = pCur->aiIdx[iCellDepth];
56371 pPage = pCur->apPage[iCellDepth];
56372 pCell = findCell(pPage, iCellIdx);
56373
@@ -56312,10 +56389,17 @@
56389 ** deleted writable. Then free any overflow pages associated with the
56390 ** entry and finally remove the cell itself from within the page.
56391 */
56392 rc = saveAllCursors(pBt, pCur->pgnoRoot, pCur);
56393 if( rc ) return rc;
56394
56395 /* If this is a delete operation to remove a row from a table b-tree,
56396 ** invalidate any incrblob cursors open on the row being deleted. */
56397 if( pCur->pKeyInfo==0 ){
56398 invalidateIncrblobCursors(p, pCur->info.nKey, 0);
56399 }
56400
56401 rc = sqlite3PagerWrite(pPage->pDbPage);
56402 if( rc ) return rc;
56403 rc = clearCell(pPage, pCell);
56404 dropCell(pPage, iCellIdx, cellSizePtr(pPage, pCell), &rc);
56405 if( rc ) return rc;
@@ -56593,17 +56677,17 @@
56677 int rc;
56678 BtShared *pBt = p->pBt;
56679 sqlite3BtreeEnter(p);
56680 assert( p->inTrans==TRANS_WRITE );
56681
 
 
 
 
 
56682 rc = saveAllCursors(pBt, (Pgno)iTable, 0);
56683
56684 if( SQLITE_OK==rc ){
56685 /* Invalidate all incrblob cursors open on table iTable (assuming iTable
56686 ** is the root of a table b-tree - if it is not, the following call is
56687 ** a no-op). */
56688 invalidateIncrblobCursors(p, 0, 1);
56689 rc = clearDatabasePage(pBt, (Pgno)iTable, 0, pnChange);
56690 }
56691 sqlite3BtreeLeave(p);
56692 return rc;
56693 }
@@ -58411,14 +58495,14 @@
58495
58496 /*
58497 ** Make sure pMem->z points to a writable allocation of at least
58498 ** n bytes.
58499 **
58500 ** If the third argument passed to this function is true, then memory
58501 ** cell pMem must contain a string or blob. In this case the content is
58502 ** preserved. Otherwise, if the third parameter to this function is false,
58503 ** any current string or blob value may be discarded.
58504 **
58505 ** This function sets the MEM_Dyn flag and clears any xDel callback.
58506 ** It also clears MEM_Ephem and MEM_Static. If the preserve flag is
58507 ** not set, Mem.n is zeroed.
58508 */
@@ -58428,10 +58512,14 @@
58512 (((pMem->flags&MEM_Dyn)&&pMem->xDel) ? 1 : 0) +
58513 ((pMem->flags&MEM_Ephem) ? 1 : 0) +
58514 ((pMem->flags&MEM_Static) ? 1 : 0)
58515 );
58516 assert( (pMem->flags&MEM_RowSet)==0 );
58517
58518 /* If the preserve flag is set to true, then the memory cell must already
58519 ** contain a valid string or blob value. */
58520 assert( preserve==0 || pMem->flags&(MEM_Blob|MEM_Str) );
58521
58522 if( n<32 ) n = 32;
58523 if( sqlite3DbMallocSize(pMem->db, pMem->zMalloc)<n ){
58524 if( preserve && pMem->z==pMem->zMalloc ){
58525 pMem->z = pMem->zMalloc = sqlite3DbReallocOrFree(pMem->db, pMem->z, n);
@@ -60747,11 +60835,11 @@
60835 int nByte = (nSub+1)*sizeof(SubProgram*);
60836 int j;
60837 for(j=0; j<nSub; j++){
60838 if( apSub[j]==pOp->p4.pProgram ) break;
60839 }
60840 if( j==nSub && SQLITE_OK==sqlite3VdbeMemGrow(pSub, nByte, nSub!=0) ){
60841 apSub = (SubProgram **)pSub->z;
60842 apSub[nSub++] = pOp->p4.pProgram;
60843 pSub->flags |= MEM_Blob;
60844 pSub->n = nSub*sizeof(SubProgram*);
60845 }
@@ -66996,10 +67084,15 @@
67084 **
67085 ** If the OPFLAG_CLEARCACHE bit is set on P5 and P1 is a pseudo-table cursor,
67086 ** then the cache of the cursor is reset prior to extracting the column.
67087 ** The first OP_Column against a pseudo-table after the value of the content
67088 ** register has changed should have this bit set.
67089 **
67090 ** If the OPFLAG_LENGTHARG and OPFLAG_TYPEOFARG bits are set on P5 when
67091 ** the result is guaranteed to only be used as the argument of a length()
67092 ** or typeof() function, respectively. The loading of large blobs can be
67093 ** skipped for length() and all content loading can be skipped for typeof().
67094 */
67095 case OP_Column: {
67096 #if 0 /* local variables moved into u.an */
67097 u32 payloadSize; /* Number of bytes in the record */
67098 i64 payloadSize64; /* Number of bytes in the record */
@@ -67138,11 +67231,11 @@
67231 u.an.pC->aRow = (u8*)u.an.zData;
67232 }else{
67233 u.an.pC->aRow = 0;
67234 }
67235 }
67236 /* The following assert is true in all cases except when
67237 ** the database file has been corrupted externally.
67238 ** assert( u.an.zRec!=0 || u.an.avail>=u.an.payloadSize || u.an.avail>=9 ); */
67239 u.an.szHdr = getVarint32((u8*)u.an.zData, u.an.offset);
67240
67241 /* Make sure a corrupt database has not given us an oversize header.
@@ -67213,15 +67306,15 @@
67306 if( u.an.offset<u.an.szField ){ /* True if u.an.offset overflows */
67307 u.an.zIdx = &u.an.zEndHdr[1]; /* Forces SQLITE_CORRUPT return below */
67308 break;
67309 }
67310 }else{
67311 /* If u.an.i is less that u.an.nField, then there are fewer fields in this
67312 ** record than SetNumColumns indicated there are columns in the
67313 ** table. Set the u.an.offset for any extra columns not present in
67314 ** the record to 0. This tells code below to store the default value
67315 ** for the column instead of deserializing a value from the record.
67316 */
67317 u.an.aOffset[u.an.i] = 0;
67318 }
67319 }
67320 sqlite3VdbeMemRelease(&u.an.sMem);
@@ -67247,21 +67340,36 @@
67340 ** a pointer to a Mem object.
67341 */
67342 if( u.an.aOffset[u.an.p2] ){
67343 assert( rc==SQLITE_OK );
67344 if( u.an.zRec ){
67345 /* This is the common case where the whole row fits on a single page */
67346 VdbeMemRelease(u.an.pDest);
67347 sqlite3VdbeSerialGet((u8 *)&u.an.zRec[u.an.aOffset[u.an.p2]], u.an.aType[u.an.p2], u.an.pDest);
67348 }else{
67349 /* This branch happens only when the row overflows onto multiple pages */
67350 u.an.t = u.an.aType[u.an.p2];
67351 if( (pOp->p5 & (OPFLAG_LENGTHARG|OPFLAG_TYPEOFARG))!=0
67352 && ((u.an.t>=12 && (u.an.t&1)==0) || (pOp->p5 & OPFLAG_TYPEOFARG)!=0)
67353 ){
67354 /* Content is irrelevant for the typeof() function and for
67355 ** the length(X) function if X is a blob. So we might as well use
67356 ** bogus content rather than reading content from disk. NULL works
67357 ** for text and blob and whatever is in the u.an.payloadSize64 variable
67358 ** will work for everything else. */
67359 u.an.zData = u.an.t<12 ? (char*)&u.an.payloadSize64 : 0;
67360 }else{
67361 u.an.len = sqlite3VdbeSerialTypeLen(u.an.t);
67362 sqlite3VdbeMemMove(&u.an.sMem, u.an.pDest);
67363 rc = sqlite3VdbeMemFromBtree(u.an.pCrsr, u.an.aOffset[u.an.p2], u.an.len, u.an.pC->isIndex,
67364 &u.an.sMem);
67365 if( rc!=SQLITE_OK ){
67366 goto op_column_out;
67367 }
67368 u.an.zData = u.an.sMem.z;
67369 }
67370 sqlite3VdbeSerialGet((u8*)u.an.zData, u.an.t, u.an.pDest);
67371 }
67372 u.an.pDest->enc = encoding;
67373 }else{
67374 if( pOp->p4type==P4_MEM ){
67375 sqlite3VdbeMemShallowCopy(u.an.pDest, pOp->p4.pMem, MEM_Static);
@@ -67593,12 +67701,14 @@
67701 }
67702 db->isTransactionSavepoint = 0;
67703 rc = p->rc;
67704 }else{
67705 u.ar.iSavepoint = db->nSavepoint - u.ar.iSavepoint - 1;
67706 if( u.ar.p1==SAVEPOINT_ROLLBACK ){
67707 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67708 sqlite3BtreeTripAllCursors(db->aDb[u.ar.ii].pBt, SQLITE_ABORT);
67709 }
67710 }
67711 for(u.ar.ii=0; u.ar.ii<db->nDb; u.ar.ii++){
67712 rc = sqlite3BtreeSavepoint(db->aDb[u.ar.ii].pBt, u.ar.p1, u.ar.iSavepoint);
67713 if( rc!=SQLITE_OK ){
67714 goto abort_due_to_error;
@@ -74873,27 +74983,59 @@
74983 int op, /* Expression opcode */
74984 Expr *pLeft, /* Left operand */
74985 Expr *pRight, /* Right operand */
74986 const Token *pToken /* Argument token */
74987 ){
74988 Expr *p;
74989 if( op==TK_AND && pLeft && pRight ){
74990 /* Take advantage of short-circuit false optimization for AND */
74991 p = sqlite3ExprAnd(pParse->db, pLeft, pRight);
74992 }else{
74993 p = sqlite3ExprAlloc(pParse->db, op, pToken, 1);
74994 sqlite3ExprAttachSubtrees(pParse->db, p, pLeft, pRight);
74995 }
74996 if( p ) {
74997 sqlite3ExprCheckHeight(pParse, p->nHeight);
74998 }
74999 return p;
75000 }
75001
75002 /*
75003 ** Return 1 if an expression must be FALSE in all cases and 0 if the
75004 ** expression might be true. This is an optimization. If is OK to
75005 ** return 0 here even if the expression really is always false (a
75006 ** false negative). But it is a bug to return 1 if the expression
75007 ** might be true in some rare circumstances (a false positive.)
75008 **
75009 ** Note that if the expression is part of conditional for a
75010 ** LEFT JOIN, then we cannot determine at compile-time whether or not
75011 ** is it true or false, so always return 0.
75012 */
75013 static int exprAlwaysFalse(Expr *p){
75014 int v = 0;
75015 if( ExprHasProperty(p, EP_FromJoin) ) return 0;
75016 if( !sqlite3ExprIsInteger(p, &v) ) return 0;
75017 return v==0;
75018 }
75019
75020 /*
75021 ** Join two expressions using an AND operator. If either expression is
75022 ** NULL, then just return the other expression.
75023 **
75024 ** If one side or the other of the AND is known to be false, then instead
75025 ** of returning an AND expression, just return a constant expression with
75026 ** a value of false.
75027 */
75028 SQLITE_PRIVATE Expr *sqlite3ExprAnd(sqlite3 *db, Expr *pLeft, Expr *pRight){
75029 if( pLeft==0 ){
75030 return pRight;
75031 }else if( pRight==0 ){
75032 return pLeft;
75033 }else if( exprAlwaysFalse(pLeft) || exprAlwaysFalse(pRight) ){
75034 sqlite3ExprDelete(db, pLeft);
75035 sqlite3ExprDelete(db, pRight);
75036 return sqlite3ExprAlloc(db, TK_INTEGER, &sqlite3IntTokens[0], 0);
75037 }else{
75038 Expr *pNew = sqlite3ExprAlloc(db, TK_AND, 0, 0);
75039 sqlite3ExprAttachSubtrees(db, pNew, pLeft, pRight);
75040 return pNew;
75041 }
@@ -76421,19 +76563,10 @@
76563 ** Actually, the way the column cache is currently used, we are guaranteed
76564 ** that the object will never already be in cache. Verify this guarantee.
76565 */
76566 #ifndef NDEBUG
76567 for(i=0, p=pParse->aColCache; i<SQLITE_N_COLCACHE; i++, p++){
 
 
 
 
 
 
 
 
 
76568 assert( p->iReg==0 || p->iTable!=iTab || p->iColumn!=iCol );
76569 }
76570 #endif
76571
76572 /* Find an empty slot and replace it */
@@ -76564,11 +76697,12 @@
76697 SQLITE_PRIVATE int sqlite3ExprCodeGetColumn(
76698 Parse *pParse, /* Parsing and code generating context */
76699 Table *pTab, /* Description of the table we are reading from */
76700 int iColumn, /* Index of the table column */
76701 int iTable, /* The cursor pointing to the table */
76702 int iReg, /* Store results here */
76703 u8 p5 /* P5 value for OP_Column */
76704 ){
76705 Vdbe *v = pParse->pVdbe;
76706 int i;
76707 struct yColCache *p;
76708
@@ -76579,11 +76713,15 @@
76713 return p->iReg;
76714 }
76715 }
76716 assert( v!=0 );
76717 sqlite3ExprCodeGetColumnOfTable(v, pTab, iTable, iColumn, iReg);
76718 if( p5 ){
76719 sqlite3VdbeChangeP5(v, p5);
76720 }else{
76721 sqlite3ExprCacheStore(pParse, iTable, iColumn, iReg);
76722 }
76723 return iReg;
76724 }
76725
76726 /*
76727 ** Clear all column cache entries.
@@ -76707,11 +76845,12 @@
76845 /* This only happens when coding check constraints */
76846 assert( pParse->ckBase>0 );
76847 inReg = pExpr->iColumn + pParse->ckBase;
76848 }else{
76849 inReg = sqlite3ExprCodeGetColumn(pParse, pExpr->pTab,
76850 pExpr->iColumn, pExpr->iTable, target,
76851 pExpr->op2);
76852 }
76853 break;
76854 }
76855 case TK_INTEGER: {
76856 codeInteger(pParse, pExpr, 0, target);
@@ -76984,10 +77123,29 @@
77123 }
77124
77125
77126 if( pFarg ){
77127 r1 = sqlite3GetTempRange(pParse, nFarg);
77128
77129 /* For length() and typeof() functions with a column argument,
77130 ** set the P5 parameter to the OP_Column opcode to OPFLAG_LENGTHARG
77131 ** or OPFLAG_TYPEOFARG respectively, to avoid unnecessary data
77132 ** loading.
77133 */
77134 if( (pDef->flags & (SQLITE_FUNC_LENGTH|SQLITE_FUNC_TYPEOF))!=0 ){
77135 u8 exprOp;
77136 assert( nFarg==1 );
77137 assert( pFarg->a[0].pExpr!=0 );
77138 exprOp = pFarg->a[0].pExpr->op;
77139 if( exprOp==TK_COLUMN || exprOp==TK_AGG_COLUMN ){
77140 assert( SQLITE_FUNC_LENGTH==OPFLAG_LENGTHARG );
77141 assert( SQLITE_FUNC_TYPEOF==OPFLAG_TYPEOFARG );
77142 testcase( pDef->flags==SQLITE_FUNC_LENGTH );
77143 pFarg->a[0].pExpr->op2 = pDef->flags;
77144 }
77145 }
77146
77147 sqlite3ExprCachePush(pParse); /* Ticket 2ea2425d34be */
77148 sqlite3ExprCodeExprList(pParse, pFarg, r1, 1);
77149 sqlite3ExprCachePop(pParse, 1); /* Ticket 2ea2425d34be */
77150 }else{
77151 r1 = 0;
@@ -80189,10 +80347,11 @@
80347 Index *pPrevIdx = 0; /* Previous index in the loop */
80348 int idx = 0; /* slot in pIdx->aSample[] for next sample */
80349 int eType; /* Datatype of a sample */
80350 IndexSample *pSample; /* A slot in pIdx->aSample[] */
80351
80352 assert( db->lookaside.bEnabled==0 );
80353 if( !sqlite3FindTable(db, "sqlite_stat3", zDb) ){
80354 return SQLITE_OK;
80355 }
80356
80357 zSql = sqlite3MPrintf(db,
@@ -80215,11 +80374,11 @@
80374 nSample = sqlite3_column_int(pStmt, 1);
80375 pIdx = sqlite3FindIndex(db, zIndex, zDb);
80376 if( pIdx==0 ) continue;
80377 assert( pIdx->nSample==0 );
80378 pIdx->nSample = nSample;
80379 pIdx->aSample = sqlite3DbMallocZero(db, nSample*sizeof(IndexSample));
80380 pIdx->avgEq = pIdx->aiRowEst[1];
80381 if( pIdx->aSample==0 ){
80382 db->mallocFailed = 1;
80383 sqlite3_finalize(pStmt);
80384 return SQLITE_NOMEM;
@@ -80288,11 +80447,11 @@
80447 int n = z ? sqlite3_column_bytes(pStmt, 4) : 0;
80448 pSample->nByte = n;
80449 if( n < 1){
80450 pSample->u.z = 0;
80451 }else{
80452 pSample->u.z = sqlite3DbMallocRaw(db, n);
80453 if( pSample->u.z==0 ){
80454 db->mallocFailed = 1;
80455 sqlite3_finalize(pStmt);
80456 return SQLITE_NOMEM;
80457 }
@@ -80364,11 +80523,14 @@
80523
80524
80525 /* Load the statistics from the sqlite_stat3 table. */
80526 #ifdef SQLITE_ENABLE_STAT3
80527 if( rc==SQLITE_OK ){
80528 int lookasideEnabled = db->lookaside.bEnabled;
80529 db->lookaside.bEnabled = 0;
80530 rc = loadStat3(db, sInfo.zDatabase);
80531 db->lookaside.bEnabled = lookasideEnabled;
80532 }
80533 #endif
80534
80535 if( rc==SQLITE_NOMEM ){
80536 db->mallocFailed = 1;
@@ -81727,11 +81889,11 @@
81889 sqliteDeleteColumnNames(db, pTable);
81890 sqlite3DbFree(db, pTable->zName);
81891 sqlite3DbFree(db, pTable->zColAff);
81892 sqlite3SelectDelete(db, pTable->pSelect);
81893 #ifndef SQLITE_OMIT_CHECK
81894 sqlite3ExprListDelete(db, pTable->pCheck);
81895 #endif
81896 #ifndef SQLITE_OMIT_VIRTUALTABLE
81897 sqlite3VtabClear(db, pTable);
81898 #endif
81899 sqlite3DbFree(db, pTable);
@@ -82390,19 +82552,21 @@
82552 */
82553 SQLITE_PRIVATE void sqlite3AddCheckConstraint(
82554 Parse *pParse, /* Parsing context */
82555 Expr *pCheckExpr /* The check expression */
82556 ){
 
82557 #ifndef SQLITE_OMIT_CHECK
82558 Table *pTab = pParse->pNewTable;
82559 if( pTab && !IN_DECLARE_VTAB ){
82560 pTab->pCheck = sqlite3ExprListAppend(pParse, pTab->pCheck, pCheckExpr);
82561 if( pParse->constraintName.n ){
82562 sqlite3ExprListSetName(pParse, pTab->pCheck, &pParse->constraintName, 1);
82563 }
82564 }else
82565 #endif
82566 {
82567 sqlite3ExprDelete(pParse->db, pCheckExpr);
82568 }
82569 }
82570
82571 /*
82572 ** Set the collation function of the most recently parsed table column
@@ -82668,10 +82832,12 @@
82832 /* Resolve names in all CHECK constraint expressions.
82833 */
82834 if( p->pCheck ){
82835 SrcList sSrc; /* Fake SrcList for pParse->pNewTable */
82836 NameContext sNC; /* Name context for pParse->pNewTable */
82837 ExprList *pList; /* List of all CHECK constraints */
82838 int i; /* Loop counter */
82839
82840 memset(&sNC, 0, sizeof(sNC));
82841 memset(&sSrc, 0, sizeof(sSrc));
82842 sSrc.nSrc = 1;
82843 sSrc.a[0].zName = p->zName;
@@ -82678,12 +82844,15 @@
82844 sSrc.a[0].pTab = p;
82845 sSrc.a[0].iCursor = -1;
82846 sNC.pParse = pParse;
82847 sNC.pSrcList = &sSrc;
82848 sNC.isCheck = 1;
82849 pList = p->pCheck;
82850 for(i=0; i<pList->nExpr; i++){
82851 if( sqlite3ResolveExprNames(&sNC, pList->a[i].pExpr) ){
82852 return;
82853 }
82854 }
82855 }
82856 #endif /* !defined(SQLITE_OMIT_CHECK) */
82857
82858 /* If the db->init.busy is 1 it means we are reading the SQL off the
@@ -84230,23 +84399,25 @@
84399 exit_drop_index:
84400 sqlite3SrcListDelete(db, pName);
84401 }
84402
84403 /*
84404 ** pArray is a pointer to an array of objects. Each object in the
84405 ** array is szEntry bytes in size. This routine uses sqlite3DbRealloc()
84406 ** to extend the array so that there is space for a new object at the end.
84407 **
84408 ** When this function is called, *pnEntry contains the current size of
84409 ** the array (in entries - so the allocation is ((*pnEntry) * szEntry) bytes
84410 ** in total).
84411 **
84412 ** If the realloc() is successful (i.e. if no OOM condition occurs), the
84413 ** space allocated for the new object is zeroed, *pnEntry updated to
84414 ** reflect the new size of the array and a pointer to the new allocation
84415 ** returned. *pIdx is set to the index of the new array entry in this case.
84416 **
84417 ** Otherwise, if the realloc() fails, *pIdx is set to -1, *pnEntry remains
84418 ** unchanged and a copy of pArray returned.
84419 */
84420 SQLITE_PRIVATE void *sqlite3ArrayAllocate(
84421 sqlite3 *db, /* Connection to notify of malloc failures */
84422 void *pArray, /* Array of objects. Might be reallocated */
84423 int szEntry, /* Size of each object in the array */
@@ -85839,11 +86010,11 @@
86010 sqlite3VdbeAddOp2(v, OP_Null, 0, iRowSet);
86011 pWInfo = sqlite3WhereBegin(
86012 pParse, pTabList, pWhere, 0, 0, WHERE_DUPLICATES_OK
86013 );
86014 if( pWInfo==0 ) goto delete_from_cleanup;
86015 regRowid = sqlite3ExprCodeGetColumn(pParse, pTab, -1, iCur, iRowid, 0);
86016 sqlite3VdbeAddOp2(v, OP_RowSetAdd, iRowSet, regRowid);
86017 if( db->flags & SQLITE_CountRows ){
86018 sqlite3VdbeAddOp2(v, OP_AddImm, memCnt, 1);
86019 }
86020 sqlite3WhereEnd(pWInfo);
@@ -87659,12 +87830,12 @@
87830 FUNCTION(min, 0, 0, 1, 0 ),
87831 AGGREGATE(min, 1, 0, 1, minmaxStep, minMaxFinalize ),
87832 FUNCTION(max, -1, 1, 1, minmaxFunc ),
87833 FUNCTION(max, 0, 1, 1, 0 ),
87834 AGGREGATE(max, 1, 1, 1, minmaxStep, minMaxFinalize ),
87835 FUNCTION2(typeof, 1, 0, 0, typeofFunc, SQLITE_FUNC_TYPEOF),
87836 FUNCTION2(length, 1, 0, 0, lengthFunc, SQLITE_FUNC_LENGTH),
87837 FUNCTION(substr, 2, 0, 0, substrFunc ),
87838 FUNCTION(substr, 3, 0, 0, substrFunc ),
87839 FUNCTION(abs, 1, 0, 0, absFunc ),
87840 #ifndef SQLITE_OMIT_FLOATING_POINT
87841 FUNCTION(round, 1, 0, 0, roundFunc ),
@@ -87672,15 +87843,13 @@
87843 #endif
87844 FUNCTION(upper, 1, 0, 0, upperFunc ),
87845 FUNCTION(lower, 1, 0, 0, lowerFunc ),
87846 FUNCTION(coalesce, 1, 0, 0, 0 ),
87847 FUNCTION(coalesce, 0, 0, 0, 0 ),
87848 FUNCTION2(coalesce, -1, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
 
87849 FUNCTION(hex, 1, 0, 0, hexFunc ),
87850 FUNCTION2(ifnull, 2, 0, 0, ifnullFunc, SQLITE_FUNC_COALESCE),
 
87851 FUNCTION(random, 0, 0, 0, randomFunc ),
87852 FUNCTION(randomblob, 1, 0, 0, randomBlob ),
87853 FUNCTION(nullif, 2, 0, 1, nullifFunc ),
87854 FUNCTION(sqlite_version, 0, 0, 0, versionFunc ),
87855 FUNCTION(sqlite_source_id, 0, 0, 0, sourceidFunc ),
@@ -90113,13 +90282,15 @@
90282 int j1; /* Addresss of jump instruction */
90283 int j2 = 0, j3; /* Addresses of jump instructions */
90284 int regData; /* Register containing first data column */
90285 int iCur; /* Table cursor number */
90286 Index *pIdx; /* Pointer to one of the indices */
90287 sqlite3 *db; /* Database connection */
90288 int seenReplace = 0; /* True if REPLACE is used to resolve INT PK conflict */
90289 int regOldRowid = (rowidChng && isUpdate) ? rowidChng : regRowid;
90290
90291 db = pParse->db;
90292 v = sqlite3GetVdbe(pParse);
90293 assert( v!=0 );
90294 assert( pTab->pSelect==0 ); /* This table is not a VIEW */
90295 nCol = pTab->nCol;
90296 regData = regRowid + 1;
@@ -90148,11 +90319,11 @@
90319 case OE_Rollback:
90320 case OE_Fail: {
90321 char *zMsg;
90322 sqlite3VdbeAddOp3(v, OP_HaltIfNull,
90323 SQLITE_CONSTRAINT, onError, regData+i);
90324 zMsg = sqlite3MPrintf(db, "%s.%s may not be NULL",
90325 pTab->zName, pTab->aCol[i].zName);
90326 sqlite3VdbeChangeP4(v, -1, zMsg, P4_DYNAMIC);
90327 break;
90328 }
90329 case OE_Ignore: {
@@ -90170,22 +90341,31 @@
90341 }
90342
90343 /* Test all CHECK constraints
90344 */
90345 #ifndef SQLITE_OMIT_CHECK
90346 if( pTab->pCheck && (db->flags & SQLITE_IgnoreChecks)==0 ){
90347 ExprList *pCheck = pTab->pCheck;
90348 pParse->ckBase = regData;
 
90349 onError = overrideError!=OE_Default ? overrideError : OE_Abort;
90350 for(i=0; i<pCheck->nExpr; i++){
90351 int allOk = sqlite3VdbeMakeLabel(v);
90352 sqlite3ExprIfTrue(pParse, pCheck->a[i].pExpr, allOk, SQLITE_JUMPIFNULL);
90353 if( onError==OE_Ignore ){
90354 sqlite3VdbeAddOp2(v, OP_Goto, 0, ignoreDest);
90355 }else{
90356 char *zConsName = pCheck->a[i].zName;
90357 if( onError==OE_Replace ) onError = OE_Abort; /* IMP: R-15569-63625 */
90358 if( zConsName ){
90359 zConsName = sqlite3MPrintf(db, "constraint %s failed", zConsName);
90360 }else{
90361 zConsName = 0;
90362 }
90363 sqlite3HaltConstraint(pParse, onError, zConsName, P4_DYNAMIC);
90364 }
90365 sqlite3VdbeResolveLabel(v, allOk);
90366 }
 
90367 }
90368 #endif /* !defined(SQLITE_OMIT_CHECK) */
90369
90370 /* If we have an INTEGER PRIMARY KEY, make sure the primary key
90371 ** of the new record does not previously exist. Except, if this
@@ -90237,11 +90417,11 @@
90417 **
90418 ** to run without a statement journal if there are no indexes on the
90419 ** table.
90420 */
90421 Trigger *pTrigger = 0;
90422 if( db->flags&SQLITE_RecTriggers ){
90423 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90424 }
90425 if( pTrigger || sqlite3FkRequired(pParse, pTab, 0, 0) ){
90426 sqlite3MultiWrite(pParse);
90427 sqlite3GenerateRowDelete(
@@ -90326,11 +90506,11 @@
90506 StrAccum errMsg;
90507 const char *zSep;
90508 char *zErr;
90509
90510 sqlite3StrAccumInit(&errMsg, 0, 0, 200);
90511 errMsg.db = db;
90512 zSep = pIdx->nColumn>1 ? "columns " : "column ";
90513 for(j=0; j<pIdx->nColumn; j++){
90514 char *zCol = pTab->aCol[pIdx->aiColumn[j]].zName;
90515 sqlite3StrAccumAppend(&errMsg, zSep, -1);
90516 zSep = ", ";
@@ -90350,11 +90530,11 @@
90530 }
90531 default: {
90532 Trigger *pTrigger = 0;
90533 assert( onError==OE_Replace );
90534 sqlite3MultiWrite(pParse);
90535 if( db->flags&SQLITE_RecTriggers ){
90536 pTrigger = sqlite3TriggersExist(pParse, pTab, TK_DELETE, 0, 0);
90537 }
90538 sqlite3GenerateRowDelete(
90539 pParse, pTab, baseCur, regR, 0, pTrigger, OE_Replace
90540 );
@@ -90680,11 +90860,11 @@
90860 if( pSrcIdx==0 ){
90861 return 0; /* pDestIdx has no corresponding index in pSrc */
90862 }
90863 }
90864 #ifndef SQLITE_OMIT_CHECK
90865 if( pDest->pCheck && sqlite3ExprListCompare(pSrc->pCheck, pDest->pCheck) ){
90866 return 0; /* Tables have different CHECK constraints. Ticket #2252 */
90867 }
90868 #endif
90869 #ifndef SQLITE_OMIT_FOREIGN_KEY
90870 /* Disallow the transfer optimization if the destination table constains
@@ -95753,13 +95933,21 @@
95933 int nCol; /* Number of columns in the result set */
95934 Expr *p; /* Expression for a single result column */
95935 char *zName; /* Column name */
95936 int nName; /* Size of name in zName[] */
95937
95938 if( pEList ){
95939 nCol = pEList->nExpr;
95940 aCol = sqlite3DbMallocZero(db, sizeof(aCol[0])*nCol);
95941 testcase( aCol==0 );
95942 }else{
95943 nCol = 0;
95944 aCol = 0;
95945 }
95946 *pnCol = nCol;
95947 *paCol = aCol;
95948
95949 for(i=0, pCol=aCol; i<nCol; i++, pCol++){
95950 /* Get an appropriate name for the column
95951 */
95952 p = pEList->a[i].pExpr;
95953 assert( p->pRight==0 || ExprHasProperty(p->pRight, EP_IntValue)
@@ -98723,11 +98911,11 @@
98911 if( pCol->iSorterColumn>=j ){
98912 int r1 = j + regBase;
98913 int r2;
98914
98915 r2 = sqlite3ExprCodeGetColumn(pParse,
98916 pCol->pTab, pCol->iColumn, pCol->iTable, r1, 0);
98917 if( r1!=r2 ){
98918 sqlite3VdbeAddOp2(v, OP_SCopy, r2, r1);
98919 }
98920 j++;
98921 }
@@ -103212,11 +103400,14 @@
103400 #ifdef SQLITE_EBCDIC
103401 if( *pnoCase ) return 0;
103402 #endif
103403 pList = pExpr->x.pList;
103404 pLeft = pList->a[1].pExpr;
103405 if( pLeft->op!=TK_COLUMN
103406 || sqlite3ExprAffinity(pLeft)!=SQLITE_AFF_TEXT
103407 || IsVirtual(pLeft->pTab)
103408 ){
103409 /* IMP: R-02065-49465 The left-hand side of the LIKE or GLOB operator must
103410 ** be the name of an indexed column with TEXT affinity. */
103411 return 0;
103412 }
103413 assert( pLeft->iColumn!=(-1) ); /* Because IPK never has AFF_TEXT */
@@ -106909,11 +107100,11 @@
107100 );
107101 if( (wctrlFlags & WHERE_DUPLICATES_OK)==0 ){
107102 int iSet = ((ii==pOrWc->nTerm-1)?-1:ii);
107103 int r;
107104 r = sqlite3ExprCodeGetColumn(pParse, pTabItem->pTab, -1, iCur,
107105 regRowid, 0);
107106 sqlite3VdbeAddOp4Int(v, OP_RowSetTest, regRowset,
107107 sqlite3VdbeCurrentAddr(v)+2, r, iSet);
107108 }
107109 sqlite3VdbeAddOp2(v, OP_Gosub, regReturn, iLoopBody);
107110
@@ -107822,11 +108013,11 @@
108013 ** An instance of this structure is used to store the LIKE,
108014 ** GLOB, NOT LIKE, and NOT GLOB operators.
108015 */
108016 struct LikeOp {
108017 Token eOperator; /* "like" or "glob" or "regexp" */
108018 int bNot; /* True if the NOT keyword is present */
108019 };
108020
108021 /*
108022 ** An instance of the following structure describes the event of a
108023 ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT,
@@ -108001,12 +108192,12 @@
108192 #endif
108193 #define sqlite3ParserARG_SDECL Parse *pParse;
108194 #define sqlite3ParserARG_PDECL ,Parse *pParse
108195 #define sqlite3ParserARG_FETCH Parse *pParse = yypParser->pParse
108196 #define sqlite3ParserARG_STORE yypParser->pParse = pParse
108197 #define YYNSTATE 627
108198 #define YYNRULE 325
108199 #define YYFALLBACK 1
108200 #define YY_NO_ACTION (YYNSTATE+YYNRULE+2)
108201 #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1)
108202 #define YY_ERROR_ACTION (YYNSTATE+YYNRULE)
108203
@@ -108072,480 +108263,478 @@
108263 ** shifting terminals.
108264 ** yy_reduce_ofst[] For each state, the offset into yy_action for
108265 ** shifting non-terminals after a reduce.
108266 ** yy_default[] Default action for each state.
108267 */
108268 #define YY_ACTTAB_COUNT (1561)
108269 static const YYACTIONTYPE yy_action[] = {
108270 /* 0 */ 310, 328, 573, 572, 15, 171, 185, 595, 56, 56,
108271 /* 10 */ 56, 56, 49, 54, 54, 54, 54, 53, 53, 52,
108272 /* 20 */ 52, 52, 51, 233, 52, 52, 52, 51, 233, 624,
108273 /* 30 */ 588, 582, 56, 56, 56, 56, 314, 54, 54, 54,
108274 /* 40 */ 54, 53, 53, 52, 52, 52, 51, 233, 299, 57,
108275 /* 50 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108276 /* 60 */ 56, 56, 569, 54, 54, 54, 54, 53, 53, 52,
108277 /* 70 */ 52, 52, 51, 233, 310, 595, 326, 575, 663, 65,
108278 /* 80 */ 33, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108279 /* 90 */ 51, 233, 53, 53, 52, 52, 52, 51, 233, 489,
108280 /* 100 */ 663, 440, 663, 235, 588, 582, 553, 297, 363, 59,
108281 /* 110 */ 481, 67, 360, 1, 618, 351, 618, 620, 619, 207,
108282 /* 120 */ 6, 441, 442, 57, 58, 48, 580, 579, 581, 581,
108283 /* 130 */ 55, 55, 56, 56, 56, 56, 605, 54, 54, 54,
108284 /* 140 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 223,
108285 /* 150 */ 50, 47, 146, 598, 138, 281, 385, 276, 384, 168,
108286 /* 160 */ 489, 552, 620, 619, 620, 619, 272, 214, 440, 411,
108287 /* 170 */ 551, 604, 67, 165, 7, 618, 352, 353, 588, 582,
108288 /* 180 */ 443, 569, 192, 618, 414, 617, 616, 668, 441, 336,
108289 /* 190 */ 669, 62, 618, 599, 92, 382, 346, 57, 58, 48,
108290 /* 200 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108291 /* 210 */ 670, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108292 /* 220 */ 51, 233, 310, 465, 232, 231, 373, 132, 514, 513,
108293 /* 230 */ 617, 616, 617, 616, 398, 437, 411, 66, 280, 388,
108294 /* 240 */ 411, 595, 439, 220, 438, 620, 619, 337, 569, 279,
108295 /* 250 */ 201, 414, 588, 582, 166, 414, 546, 167, 68, 234,
108296 /* 260 */ 599, 92, 620, 619, 599, 92, 19, 570, 570, 466,
108297 /* 270 */ 564, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108298 /* 280 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108299 /* 290 */ 53, 52, 52, 52, 51, 233, 310, 411, 524, 232,
108300 /* 300 */ 231, 398, 593, 547, 559, 398, 348, 202, 175, 595,
108301 /* 310 */ 399, 315, 414, 617, 616, 387, 272, 255, 347, 254,
108302 /* 320 */ 558, 599, 74, 620, 619, 45, 588, 582, 235, 466,
108303 /* 330 */ 617, 616, 511, 591, 591, 591, 557, 578, 402, 545,
108304 /* 340 */ 600, 598, 570, 570, 601, 57, 58, 48, 580, 579,
108305 /* 350 */ 581, 581, 55, 55, 56, 56, 56, 56, 550, 54,
108306 /* 360 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108307 /* 370 */ 310, 309, 411, 145, 566, 490, 213, 255, 347, 254,
108308 /* 380 */ 196, 195, 194, 587, 586, 531, 600, 414, 235, 174,
108309 /* 390 */ 601, 617, 616, 411, 620, 619, 599, 91, 547, 574,
108310 /* 400 */ 588, 582, 50, 47, 146, 584, 583, 471, 414, 249,
108311 /* 410 */ 565, 542, 186, 39, 304, 424, 562, 599, 16, 57,
108312 /* 420 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108313 /* 430 */ 56, 56, 585, 54, 54, 54, 54, 53, 53, 52,
108314 /* 440 */ 52, 52, 51, 233, 310, 559, 290, 530, 529, 345,
108315 /* 450 */ 533, 576, 540, 246, 170, 248, 411, 396, 411, 422,
108316 /* 460 */ 199, 558, 617, 616, 165, 563, 50, 47, 146, 181,
108317 /* 470 */ 498, 414, 166, 414, 588, 582, 269, 557, 166, 518,
108318 /* 480 */ 599, 92, 599, 92, 561, 595, 469, 36, 173, 409,
108319 /* 490 */ 517, 577, 577, 57, 58, 48, 580, 579, 581, 581,
108320 /* 500 */ 55, 55, 56, 56, 56, 56, 338, 54, 54, 54,
108321 /* 510 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 304,
108322 /* 520 */ 423, 394, 526, 318, 869, 235, 167, 180, 473, 547,
108323 /* 530 */ 503, 247, 474, 381, 378, 377, 409, 351, 577, 577,
108324 /* 540 */ 409, 560, 577, 577, 376, 383, 364, 603, 588, 582,
108325 /* 550 */ 620, 619, 502, 595, 409, 494, 577, 577, 409, 266,
108326 /* 560 */ 577, 577, 421, 943, 422, 943, 198, 57, 58, 48,
108327 /* 570 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108328 /* 580 */ 315, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108329 /* 590 */ 51, 233, 310, 390, 421, 942, 509, 942, 556, 145,
108330 /* 600 */ 598, 391, 324, 262, 549, 264, 411, 425, 407, 573,
108331 /* 610 */ 572, 12, 197, 143, 489, 50, 47, 146, 617, 616,
108332 /* 620 */ 206, 414, 588, 582, 547, 429, 67, 212, 143, 618,
108333 /* 630 */ 599, 73, 504, 505, 207, 434, 475, 475, 366, 425,
108334 /* 640 */ 35, 57, 58, 48, 580, 579, 581, 581, 55, 55,
108335 /* 650 */ 56, 56, 56, 56, 598, 54, 54, 54, 54, 53,
108336 /* 660 */ 53, 52, 52, 52, 51, 233, 310, 260, 598, 569,
108337 /* 670 */ 268, 615, 614, 613, 171, 411, 595, 11, 411, 350,
108338 /* 680 */ 411, 32, 618, 953, 183, 419, 2, 627, 625, 330,
108339 /* 690 */ 414, 352, 552, 414, 538, 414, 588, 582, 188, 599,
108340 /* 700 */ 69, 551, 599, 94, 599, 97, 374, 544, 166, 618,
108341 /* 710 */ 334, 359, 50, 47, 146, 57, 58, 48, 580, 579,
108342 /* 720 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108343 /* 730 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108344 /* 740 */ 310, 411, 129, 414, 595, 22, 273, 156, 411, 566,
108345 /* 750 */ 406, 213, 599, 95, 570, 570, 414, 327, 169, 332,
108346 /* 760 */ 411, 618, 536, 414, 358, 599, 104, 483, 508, 356,
108347 /* 770 */ 588, 582, 599, 103, 484, 414, 470, 357, 166, 618,
108348 /* 780 */ 626, 2, 204, 323, 599, 105, 40, 528, 38, 57,
108349 /* 790 */ 58, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108350 /* 800 */ 56, 56, 411, 54, 54, 54, 54, 53, 53, 52,
108351 /* 810 */ 52, 52, 51, 233, 310, 411, 598, 414, 411, 260,
108352 /* 820 */ 273, 273, 273, 273, 426, 305, 599, 106, 520, 519,
108353 /* 830 */ 414, 411, 142, 414, 618, 618, 618, 618, 618, 599,
108354 /* 840 */ 133, 339, 599, 134, 588, 582, 414, 21, 30, 316,
108355 /* 850 */ 147, 459, 221, 170, 527, 599, 98, 222, 322, 321,
108356 /* 860 */ 320, 141, 259, 57, 58, 48, 580, 579, 581, 581,
108357 /* 870 */ 55, 55, 56, 56, 56, 56, 411, 54, 54, 54,
108358 /* 880 */ 54, 53, 53, 52, 52, 52, 51, 233, 310, 411,
108359 /* 890 */ 260, 414, 411, 458, 200, 35, 411, 358, 211, 228,
108360 /* 900 */ 599, 102, 468, 519, 414, 618, 28, 414, 538, 501,
108361 /* 910 */ 411, 414, 618, 599, 101, 358, 599, 93, 588, 582,
108362 /* 920 */ 599, 100, 522, 618, 427, 414, 306, 271, 598, 380,
108363 /* 930 */ 618, 602, 598, 452, 599, 77, 210, 57, 58, 48,
108364 /* 940 */ 580, 579, 581, 581, 55, 55, 56, 56, 56, 56,
108365 /* 950 */ 411, 54, 54, 54, 54, 53, 53, 52, 52, 52,
108366 /* 960 */ 51, 233, 310, 411, 621, 414, 411, 127, 609, 270,
108367 /* 970 */ 598, 365, 51, 233, 599, 96, 625, 330, 414, 618,
108368 /* 980 */ 126, 414, 411, 618, 411, 253, 608, 599, 137, 27,
108369 /* 990 */ 599, 136, 588, 582, 375, 260, 125, 414, 164, 414,
108370 /* 1000 */ 371, 618, 279, 219, 542, 542, 599, 135, 599, 76,
108371 /* 1010 */ 618, 57, 46, 48, 580, 579, 581, 581, 55, 55,
108372 /* 1020 */ 56, 56, 56, 56, 411, 54, 54, 54, 54, 53,
108373 /* 1030 */ 53, 52, 52, 52, 51, 233, 310, 411, 450, 414,
108374 /* 1040 */ 411, 260, 542, 229, 285, 607, 479, 184, 599, 90,
108375 /* 1050 */ 367, 122, 414, 476, 121, 414, 618, 170, 411, 353,
108376 /* 1060 */ 618, 599, 89, 410, 599, 75, 588, 582, 472, 257,
108377 /* 1070 */ 538, 120, 159, 414, 618, 14, 464, 158, 618, 157,
108378 /* 1080 */ 461, 283, 599, 88, 449, 618, 58, 48, 580, 579,
108379 /* 1090 */ 581, 581, 55, 55, 56, 56, 56, 56, 411, 54,
108380 /* 1100 */ 54, 54, 54, 53, 53, 52, 52, 52, 51, 233,
108381 /* 1110 */ 310, 411, 260, 414, 411, 592, 260, 118, 25, 400,
108382 /* 1120 */ 10, 24, 599, 87, 117, 216, 414, 618, 349, 414,
108383 /* 1130 */ 618, 618, 411, 319, 618, 599, 99, 555, 599, 86,
108384 /* 1140 */ 588, 582, 4, 260, 457, 455, 115, 414, 251, 154,
108385 /* 1150 */ 451, 108, 618, 110, 436, 448, 599, 17, 618, 218,
108386 /* 1160 */ 107, 48, 580, 579, 581, 581, 55, 55, 56, 56,
108387 /* 1170 */ 56, 56, 435, 54, 54, 54, 54, 53, 53, 52,
108388 /* 1180 */ 52, 52, 51, 233, 44, 405, 217, 3, 411, 260,
108389 /* 1190 */ 543, 415, 619, 445, 64, 149, 539, 237, 333, 329,
108390 /* 1200 */ 203, 187, 408, 414, 618, 618, 420, 44, 405, 411,
108391 /* 1210 */ 3, 618, 599, 85, 415, 619, 148, 227, 622, 179,
108392 /* 1220 */ 313, 403, 312, 612, 414, 408, 611, 124, 417, 178,
108393 /* 1230 */ 610, 564, 243, 599, 84, 537, 8, 176, 235, 416,
108394 /* 1240 */ 294, 418, 623, 30, 403, 597, 411, 236, 293, 123,
108395 /* 1250 */ 618, 41, 42, 532, 564, 205, 292, 275, 43, 413,
108396 /* 1260 */ 412, 414, 395, 593, 507, 274, 31, 397, 291, 37,
108397 /* 1270 */ 599, 83, 618, 491, 41, 42, 267, 411, 265, 618,
108398 /* 1280 */ 618, 43, 413, 412, 596, 263, 593, 60, 618, 598,
108399 /* 1290 */ 261, 618, 414, 618, 591, 591, 591, 590, 589, 13,
108400 /* 1300 */ 618, 599, 72, 554, 235, 618, 44, 405, 256, 3,
108401 /* 1310 */ 361, 172, 340, 415, 619, 230, 411, 591, 591, 591,
108402 /* 1320 */ 590, 589, 13, 618, 408, 618, 182, 411, 286, 34,
108403 /* 1330 */ 405, 414, 3, 411, 463, 411, 415, 619, 29, 331,
108404 /* 1340 */ 599, 71, 414, 403, 392, 386, 284, 408, 414, 618,
108405 /* 1350 */ 414, 599, 82, 564, 411, 462, 354, 599, 81, 599,
108406 /* 1360 */ 80, 541, 250, 535, 282, 521, 403, 534, 516, 414,
108407 /* 1370 */ 618, 618, 454, 41, 42, 411, 564, 618, 599, 70,
108408 /* 1380 */ 43, 413, 412, 444, 515, 593, 242, 618, 325, 61,
108409 /* 1390 */ 414, 277, 239, 620, 619, 238, 41, 42, 618, 599,
108410 /* 1400 */ 18, 618, 512, 43, 413, 412, 511, 618, 593, 430,
108411 /* 1410 */ 618, 411, 128, 510, 308, 226, 591, 591, 591, 590,
108412 /* 1420 */ 589, 13, 215, 289, 618, 225, 414, 302, 301, 300,
108413 /* 1430 */ 177, 298, 411, 564, 453, 599, 79, 224, 618, 591,
108414 /* 1440 */ 591, 591, 590, 589, 13, 389, 492, 414, 150, 144,
108415 /* 1450 */ 241, 393, 288, 191, 190, 193, 599, 78, 165, 240,
108416 /* 1460 */ 414, 524, 487, 307, 618, 593, 618, 618, 486, 599,
108417 /* 1470 */ 9, 163, 152, 485, 466, 372, 480, 162, 153, 370,
108418 /* 1480 */ 161, 151, 209, 478, 258, 368, 477, 26, 160, 467,
108419 /* 1490 */ 140, 362, 131, 119, 116, 456, 591, 591, 591, 155,
108420 /* 1500 */ 114, 344, 343, 113, 112, 111, 447, 109, 130, 23,
108421 /* 1510 */ 317, 433, 20, 432, 431, 428, 606, 594, 63, 189,
108422 /* 1520 */ 404, 571, 255, 342, 244, 295, 287, 278, 311, 508,
108423 /* 1530 */ 496, 497, 495, 235, 493, 568, 379, 355, 460, 245,
108424 /* 1540 */ 341, 446, 303, 567, 5, 252, 548, 208, 139, 506,
108425 /* 1550 */ 369, 401, 500, 499, 296, 525, 335, 488, 482, 523,
108426 /* 1560 */ 233,
 
108427 };
108428 static const YYCODETYPE yy_lookahead[] = {
108429 /* 0 */ 19, 169, 170, 171, 22, 24, 24, 26, 77, 78,
108430 /* 10 */ 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
108431 /* 20 */ 89, 90, 91, 92, 88, 89, 90, 91, 92, 1,
108432 /* 30 */ 49, 50, 77, 78, 79, 80, 155, 82, 83, 84,
108433 /* 40 */ 85, 86, 87, 88, 89, 90, 91, 92, 15, 68,
108434 /* 50 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108435 /* 60 */ 79, 80, 230, 82, 83, 84, 85, 86, 87, 88,
108436 /* 70 */ 89, 90, 91, 92, 19, 94, 19, 23, 1, 25,
108437 /* 80 */ 25, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108438 /* 90 */ 91, 92, 86, 87, 88, 89, 90, 91, 92, 150,
108439 /* 100 */ 23, 150, 25, 116, 49, 50, 177, 158, 227, 54,
108440 /* 110 */ 161, 162, 231, 22, 165, 128, 165, 26, 27, 160,
108441 /* 120 */ 22, 170, 171, 68, 69, 70, 71, 72, 73, 74,
108442 /* 130 */ 75, 76, 77, 78, 79, 80, 23, 82, 83, 84,
108443 /* 140 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 92,
108444 /* 150 */ 221, 222, 223, 194, 97, 98, 99, 100, 101, 102,
108445 /* 160 */ 150, 32, 26, 27, 26, 27, 109, 22, 150, 150,
108446 /* 170 */ 41, 161, 162, 96, 76, 165, 217, 150, 49, 50,
108447 /* 180 */ 229, 230, 172, 165, 165, 94, 95, 118, 170, 171,
108448 /* 190 */ 118, 232, 165, 174, 175, 185, 237, 68, 69, 70,
108449 /* 200 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108450 /* 210 */ 118, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108451 /* 220 */ 91, 92, 19, 11, 86, 87, 19, 24, 7, 8,
108452 /* 230 */ 94, 95, 94, 95, 215, 97, 150, 22, 98, 220,
108453 /* 240 */ 150, 26, 104, 216, 106, 26, 27, 229, 230, 109,
108454 /* 250 */ 160, 165, 49, 50, 25, 165, 120, 50, 22, 197,
108455 /* 260 */ 174, 175, 26, 27, 174, 175, 204, 129, 130, 57,
108456 /* 270 */ 66, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108457 /* 280 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108458 /* 290 */ 87, 88, 89, 90, 91, 92, 19, 150, 94, 86,
108459 /* 300 */ 87, 215, 98, 25, 12, 215, 220, 160, 118, 94,
108460 /* 310 */ 220, 104, 165, 94, 95, 88, 109, 105, 106, 107,
108461 /* 320 */ 28, 174, 175, 26, 27, 22, 49, 50, 116, 57,
108462 /* 330 */ 94, 95, 103, 129, 130, 131, 44, 113, 46, 120,
108463 /* 340 */ 113, 194, 129, 130, 117, 68, 69, 70, 71, 72,
108464 /* 350 */ 73, 74, 75, 76, 77, 78, 79, 80, 177, 82,
108465 /* 360 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108466 /* 370 */ 19, 163, 150, 95, 166, 167, 168, 105, 106, 107,
108467 /* 380 */ 105, 106, 107, 49, 50, 88, 113, 165, 116, 118,
108468 /* 390 */ 117, 94, 95, 150, 26, 27, 174, 175, 120, 23,
108469 /* 400 */ 49, 50, 221, 222, 223, 71, 72, 21, 165, 16,
108470 /* 410 */ 23, 166, 22, 136, 22, 23, 11, 174, 175, 68,
108471 /* 420 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108472 /* 430 */ 79, 80, 98, 82, 83, 84, 85, 86, 87, 88,
108473 /* 440 */ 89, 90, 91, 92, 19, 12, 224, 23, 23, 63,
108474 /* 450 */ 205, 23, 23, 60, 25, 62, 150, 214, 150, 67,
108475 /* 460 */ 22, 28, 94, 95, 96, 23, 221, 222, 223, 23,
108476 /* 470 */ 23, 165, 25, 165, 49, 50, 23, 44, 25, 46,
108477 /* 480 */ 174, 175, 174, 175, 23, 26, 100, 136, 25, 112,
108478 /* 490 */ 57, 114, 115, 68, 69, 70, 71, 72, 73, 74,
108479 /* 500 */ 75, 76, 77, 78, 79, 80, 97, 82, 83, 84,
108480 /* 510 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 22,
108481 /* 520 */ 23, 215, 23, 215, 138, 116, 50, 23, 30, 25,
108482 /* 530 */ 36, 138, 34, 99, 100, 101, 112, 128, 114, 115,
108483 /* 540 */ 112, 23, 114, 115, 110, 51, 48, 173, 49, 50,
108484 /* 550 */ 26, 27, 58, 94, 112, 181, 114, 115, 112, 16,
108485 /* 560 */ 114, 115, 22, 23, 67, 25, 160, 68, 69, 70,
108486 /* 570 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108487 /* 580 */ 104, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108488 /* 590 */ 91, 92, 19, 19, 22, 23, 23, 25, 23, 95,
108489 /* 600 */ 194, 27, 108, 60, 25, 62, 150, 67, 169, 170,
108490 /* 610 */ 171, 35, 206, 207, 150, 221, 222, 223, 94, 95,
108491 /* 620 */ 160, 165, 49, 50, 120, 161, 162, 206, 207, 165,
108492 /* 630 */ 174, 175, 97, 98, 160, 241, 105, 106, 107, 67,
108493 /* 640 */ 25, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108494 /* 650 */ 77, 78, 79, 80, 194, 82, 83, 84, 85, 86,
108495 /* 660 */ 87, 88, 89, 90, 91, 92, 19, 150, 194, 230,
108496 /* 670 */ 23, 7, 8, 9, 24, 150, 26, 35, 150, 219,
108497 /* 680 */ 150, 25, 165, 142, 143, 144, 145, 0, 1, 2,
108498 /* 690 */ 165, 217, 32, 165, 150, 165, 49, 50, 119, 174,
108499 /* 700 */ 175, 41, 174, 175, 174, 175, 23, 120, 25, 165,
108500 /* 710 */ 193, 237, 221, 222, 223, 68, 69, 70, 71, 72,
108501 /* 720 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108502 /* 730 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108503 /* 740 */ 19, 150, 22, 165, 94, 24, 150, 25, 150, 166,
108504 /* 750 */ 167, 168, 174, 175, 129, 130, 165, 213, 35, 242,
108505 /* 760 */ 150, 165, 27, 165, 150, 174, 175, 181, 182, 19,
108506 /* 770 */ 49, 50, 174, 175, 188, 165, 23, 27, 25, 165,
108507 /* 780 */ 144, 145, 160, 187, 174, 175, 135, 23, 137, 68,
108508 /* 790 */ 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108509 /* 800 */ 79, 80, 150, 82, 83, 84, 85, 86, 87, 88,
108510 /* 810 */ 89, 90, 91, 92, 19, 150, 194, 165, 150, 150,
108511 /* 820 */ 150, 150, 150, 150, 247, 248, 174, 175, 190, 191,
108512 /* 830 */ 165, 150, 118, 165, 165, 165, 165, 165, 165, 174,
108513 /* 840 */ 175, 219, 174, 175, 49, 50, 165, 52, 126, 245,
108514 /* 850 */ 246, 23, 238, 25, 23, 174, 175, 187, 187, 187,
108515 /* 860 */ 187, 39, 193, 68, 69, 70, 71, 72, 73, 74,
108516 /* 870 */ 75, 76, 77, 78, 79, 80, 150, 82, 83, 84,
108517 /* 880 */ 85, 86, 87, 88, 89, 90, 91, 92, 19, 150,
108518 /* 890 */ 150, 165, 150, 23, 160, 25, 150, 150, 160, 52,
108519 /* 900 */ 174, 175, 190, 191, 165, 165, 22, 165, 150, 29,
108520 /* 910 */ 150, 165, 165, 174, 175, 150, 174, 175, 49, 50,
108521 /* 920 */ 174, 175, 165, 165, 23, 165, 25, 25, 194, 52,
108522 /* 930 */ 165, 174, 194, 193, 174, 175, 160, 68, 69, 70,
108523 /* 940 */ 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
108524 /* 950 */ 150, 82, 83, 84, 85, 86, 87, 88, 89, 90,
108525 /* 960 */ 91, 92, 19, 150, 150, 165, 150, 22, 150, 23,
108526 /* 970 */ 194, 213, 91, 92, 174, 175, 1, 2, 165, 165,
108527 /* 980 */ 22, 165, 150, 165, 150, 238, 150, 174, 175, 22,
108528 /* 990 */ 174, 175, 49, 50, 52, 150, 22, 165, 102, 165,
108529 /* 1000 */ 19, 165, 109, 238, 166, 166, 174, 175, 174, 175,
108530 /* 1010 */ 165, 68, 69, 70, 71, 72, 73, 74, 75, 76,
108531 /* 1020 */ 77, 78, 79, 80, 150, 82, 83, 84, 85, 86,
108532 /* 1030 */ 87, 88, 89, 90, 91, 92, 19, 150, 193, 165,
108533 /* 1040 */ 150, 150, 166, 205, 205, 150, 20, 24, 174, 175,
108534 /* 1050 */ 43, 104, 165, 59, 53, 165, 165, 25, 150, 150,
108535 /* 1060 */ 165, 174, 175, 150, 174, 175, 49, 50, 53, 138,
108536 /* 1070 */ 150, 22, 104, 165, 165, 5, 1, 118, 165, 35,
108537 /* 1080 */ 27, 205, 174, 175, 193, 165, 69, 70, 71, 72,
108538 /* 1090 */ 73, 74, 75, 76, 77, 78, 79, 80, 150, 82,
108539 /* 1100 */ 83, 84, 85, 86, 87, 88, 89, 90, 91, 92,
108540 /* 1110 */ 19, 150, 150, 165, 150, 150, 150, 108, 76, 150,
108541 /* 1120 */ 22, 76, 174, 175, 127, 216, 165, 165, 25, 165,
108542 /* 1130 */ 165, 165, 150, 213, 165, 174, 175, 150, 174, 175,
108543 /* 1140 */ 49, 50, 22, 150, 23, 1, 119, 165, 16, 121,
108544 /* 1150 */ 20, 108, 165, 119, 23, 193, 174, 175, 165, 193,
108545 /* 1160 */ 127, 70, 71, 72, 73, 74, 75, 76, 77, 78,
108546 /* 1170 */ 79, 80, 23, 82, 83, 84, 85, 86, 87, 88,
108547 /* 1180 */ 89, 90, 91, 92, 19, 20, 193, 22, 150, 150,
108548 /* 1190 */ 150, 26, 27, 128, 16, 15, 150, 140, 65, 3,
108549 /* 1200 */ 164, 22, 37, 165, 165, 165, 4, 19, 20, 150,
108550 /* 1210 */ 22, 165, 174, 175, 26, 27, 246, 180, 149, 6,
108551 /* 1220 */ 249, 56, 249, 149, 165, 37, 149, 180, 149, 151,
108552 /* 1230 */ 13, 66, 193, 174, 175, 150, 25, 151, 116, 159,
108553 /* 1240 */ 199, 146, 147, 126, 56, 194, 150, 152, 200, 154,
108554 /* 1250 */ 165, 86, 87, 88, 66, 160, 201, 150, 93, 94,
108555 /* 1260 */ 95, 165, 123, 98, 150, 150, 124, 122, 202, 135,
108556 /* 1270 */ 174, 175, 165, 150, 86, 87, 150, 150, 150, 165,
108557 /* 1280 */ 165, 93, 94, 95, 203, 150, 98, 125, 165, 194,
108558 /* 1290 */ 150, 165, 165, 165, 129, 130, 131, 132, 133, 134,
108559 /* 1300 */ 165, 174, 175, 157, 116, 165, 19, 20, 150, 22,
108560 /* 1310 */ 150, 118, 217, 26, 27, 225, 150, 129, 130, 131,
108561 /* 1320 */ 132, 133, 134, 165, 37, 165, 157, 150, 210, 19,
108562 /* 1330 */ 20, 165, 22, 150, 150, 150, 26, 27, 104, 244,
108563 /* 1340 */ 174, 175, 165, 56, 121, 104, 210, 37, 165, 165,
108564 /* 1350 */ 165, 174, 175, 66, 150, 150, 150, 174, 175, 174,
108565 /* 1360 */ 175, 211, 150, 211, 210, 176, 56, 211, 176, 165,
108566 /* 1370 */ 165, 165, 150, 86, 87, 150, 66, 165, 174, 175,
108567 /* 1380 */ 93, 94, 95, 150, 184, 98, 150, 165, 47, 22,
108568 /* 1390 */ 165, 176, 150, 26, 27, 150, 86, 87, 165, 174,
108569 /* 1400 */ 175, 165, 178, 93, 94, 95, 103, 165, 98, 150,
108570 /* 1410 */ 165, 150, 22, 176, 179, 228, 129, 130, 131, 132,
108571 /* 1420 */ 133, 134, 5, 150, 165, 92, 165, 10, 11, 12,
108572 /* 1430 */ 13, 14, 150, 66, 17, 174, 175, 228, 165, 129,
108573 /* 1440 */ 130, 131, 132, 133, 134, 150, 184, 165, 31, 150,
108574 /* 1450 */ 33, 150, 150, 86, 87, 172, 174, 175, 96, 42,
108575 /* 1460 */ 165, 94, 176, 179, 165, 98, 165, 165, 176, 174,
108576 /* 1470 */ 175, 156, 55, 176, 57, 18, 157, 156, 61, 157,
108577 /* 1480 */ 156, 64, 157, 157, 235, 45, 236, 135, 156, 189,
108578 /* 1490 */ 68, 157, 218, 189, 22, 199, 129, 130, 131, 156,
108579 /* 1500 */ 192, 157, 18, 192, 192, 192, 199, 189, 218, 240,
108580 /* 1510 */ 157, 40, 240, 157, 157, 38, 153, 166, 243, 196,
108581 /* 1520 */ 226, 230, 105, 106, 107, 198, 209, 177, 111, 182,
108582 /* 1530 */ 166, 177, 177, 116, 166, 230, 178, 239, 199, 209,
108583 /* 1540 */ 209, 199, 148, 166, 196, 239, 208, 233, 172, 183,
108584 /* 1550 */ 234, 191, 183, 183, 195, 174, 139, 186, 186, 174,
108585 /* 1560 */ 92,
 
108586 };
108587 #define YY_SHIFT_USE_DFLT (-70)
108588 #define YY_SHIFT_COUNT (418)
108589 #define YY_SHIFT_MIN (-69)
108590 #define YY_SHIFT_MAX (1484)
108591 static const short yy_shift_ofst[] = {
108592 /* 0 */ 975, 1188, 1417, 1188, 1287, 1287, 138, 138, 368, -19,
108593 /* 10 */ 1287, 1287, 1287, 1287, 272, 524, 129, 129, 795, 1165,
108594 /* 20 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108595 /* 30 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108596 /* 40 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1310, 1287,
108597 /* 50 */ 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287, 1287,
108598 /* 60 */ 1287, 1287, 212, 524, 524, 213, 213, 459, 1122, 55,
108599 /* 70 */ 721, 647, 573, 499, 425, 351, 277, 203, 869, 869,
108600 /* 80 */ 869, 869, 869, 869, 869, 869, 869, 869, 869, 869,
108601 /* 90 */ 869, 869, 869, 943, 869, 1017, 1091, 1091, -69, -45,
108602 /* 100 */ -45, -45, -45, -45, -1, 6, -64, 524, 524, 524,
108603 /* 110 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108604 /* 120 */ 524, 524, 524, 386, 207, 524, 524, 524, 524, 524,
108605 /* 130 */ 409, -13, 459, 881, 1468, -70, -70, -70, 1367, 57,
108606 /* 140 */ 433, 433, 297, 236, 219, 136, 91, 572, 540, 524,
108607 /* 150 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108608 /* 160 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108609 /* 170 */ 524, 524, 524, 524, 524, 524, 524, 524, 524, 524,
108610 /* 180 */ 650, 650, 650, 687, 1122, 1122, 1122, -70, -70, -70,
108611 /* 190 */ 204, 204, 434, 434, 494, 494, 494, 504, 446, 292,
108612 /* 200 */ 442, 428, 424, 77, 377, 377, 377, 377, 531, 498,
108613 /* 210 */ 377, 377, 278, 215, 227, 664, 722, 574, 574, 750,
108614 /* 220 */ 722, 750, 229, 459, 660, 459, 660, 476, 660, 574,
108615 /* 230 */ 651, 625, 625, 459, 579, 273, -18, 1477, 1193, 1193,
108616 /* 240 */ 1471, 1471, 1193, 1472, 1422, 1117, 1484, 1484, 1484, 1484,
108617 /* 250 */ 1193, 1457, 1117, 1472, 1422, 1422, 1193, 1457, 1352, 1440,
108618 /* 260 */ 1193, 1193, 1457, 1193, 1457, 1193, 1457, 1390, 1241, 1241,
108619 /* 270 */ 1241, 1362, 1341, 1333, 1333, 1390, 1241, 1303, 1241, 1341,
108620 /* 280 */ 1241, 1241, 1223, 1234, 1223, 1234, 1223, 1234, 1193, 1193,
108621 /* 290 */ 1134, 1162, 1145, 1142, 1139, 1117, 1122, 1211, 1217, 1217,
108622 /* 300 */ 1213, 1213, 1213, 1213, -70, -70, -70, -70, -70, -70,
108623 /* 310 */ 334, 393, 497, 392, 543, 275, 901, 98, 870, 828,
108624 /* 320 */ 753, 683, 453, 447, 535, 221, 140, 429, 54, 1202,
108625 /* 330 */ 1196, 1179, 1057, 1180, 1133, 1178, 1149, 1131, 1065, 1103,
108626 /* 340 */ 1033, 1043, 1034, 1130, 1028, 1132, 1144, 1027, 1121, 1120,
108627 /* 350 */ 1103, 1098, 997, 1045, 1042, 1009, 1053, 1044, 959, 1075,
108628 /* 360 */ 1070, 1049, 968, 931, 1015, 1032, 1001, 994, 1007, 947,
108629 /* 370 */ 1023, 1026, 981, 893, 896, 974, 942, 967, 958, 946,
108630 /* 380 */ 945, 877, 902, 880, 884, 847, 822, 831, 764, 714,
108631 /* 390 */ 735, 723, 720, 587, 615, 642, 656, 576, 615, 575,
108632 /* 400 */ 518, 463, 461, 438, 405, 390, 387, 376, 303, 224,
108633 /* 410 */ 271, 190, 92, 72, 69, 145, 113, 33, 28,
108634 };
108635 #define YY_REDUCE_USE_DFLT (-169)
108636 #define YY_REDUCE_COUNT (309)
108637 #define YY_REDUCE_MIN (-168)
108638 #define YY_REDUCE_MAX (1394)
108639 static const short yy_reduce_ofst[] = {
108640 /* 0 */ 541, 90, 1095, 147, 86, 19, 18, -49, 10, 245,
108641 /* 10 */ 308, 306, 243, 222, -41, -51, 181, -71, 394, 1295,
108642 /* 20 */ 1282, 1261, 1225, 1204, 1185, 1183, 1177, 1166, 1127, 1096,
108643 /* 30 */ 1059, 1038, 982, 964, 961, 948, 908, 890, 887, 874,
108644 /* 40 */ 834, 832, 816, 813, 800, 760, 746, 742, 739, 726,
108645 /* 50 */ 681, 668, 665, 652, 610, 598, 591, 578, 530, 528,
108646 /* 60 */ 525, 456, 474, 464, 517, 439, -168, 208, 406, 491,
108647 /* 70 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108648 /* 80 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108649 /* 90 */ 491, 491, 491, 491, 491, 491, 491, 491, 491, 491,
108650 /* 100 */ 491, 491, 491, 491, 491, 491, 491, 1039, 909, 993,
108651 /* 110 */ 966, 962, 891, 845, 740, 765, 920, 747, 27, 614,
108652 /* 120 */ 673, 758, 669, -119, 586, 672, 671, 670, 596, 544,
108653 /* 130 */ 622, 460, 583, 491, 491, 491, 491, 491, 757, 374,
108654 /* 140 */ 712, 638, 913, 1302, 1301, 1299, 1273, 577, 577, 1259,
108655 /* 150 */ 1245, 1242, 1236, 1233, 1222, 1212, 1206, 1205, 1184, 1160,
108656 /* 160 */ 1158, 1140, 1135, 1128, 1126, 1123, 1115, 1114, 1107, 1085,
108657 /* 170 */ 1046, 1040, 987, 969, 965, 913, 895, 836, 818, 814,
108658 /* 180 */ 876, 839, 838, 636, 776, 738, 734, 604, 421, 62,
108659 /* 190 */ 1385, 1381, 1372, 1371, 1370, 1369, 1366, 1338, 1359, 1360,
108660 /* 200 */ 1359, 1359, 1359, 1376, 1359, 1359, 1359, 1359, 1316, 1314,
108661 /* 210 */ 1359, 1359, 1338, 1377, 1348, 1394, 1342, 1331, 1330, 1306,
108662 /* 220 */ 1339, 1298, 1358, 1368, 1355, 1364, 1354, 1347, 1350, 1317,
108663 /* 230 */ 1294, 1305, 1291, 1351, 1327, 1323, 1363, 1275, 1357, 1356,
108664 /* 240 */ 1272, 1269, 1353, 1290, 1318, 1307, 1313, 1312, 1311, 1308,
108665 /* 250 */ 1344, 1343, 1296, 1274, 1304, 1300, 1334, 1332, 1250, 1249,
108666 /* 260 */ 1326, 1325, 1324, 1322, 1321, 1319, 1315, 1284, 1297, 1292,
108667 /* 270 */ 1286, 1283, 1262, 1209, 1187, 1235, 1237, 1224, 1215, 1200,
108668 /* 280 */ 1192, 1189, 1156, 1154, 1152, 1136, 1150, 1118, 1169, 1146,
108669 /* 290 */ 1090, 1081, 1066, 1055, 1048, 1041, 1051, 1080, 1086, 1078,
108670 /* 300 */ 1079, 1077, 1074, 1069, 973, 971, 970, 1047, 1037, 1036,
108671 };
108672 static const YYACTIONTYPE yy_default[] = {
108673 /* 0 */ 632, 864, 952, 952, 864, 864, 952, 952, 683, 754,
108674 /* 10 */ 952, 952, 952, 862, 952, 952, 782, 782, 926, 952,
108675 /* 20 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108676 /* 30 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108677 /* 40 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108678 /* 50 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108679 /* 60 */ 952, 952, 952, 952, 952, 952, 952, 671, 758, 788,
108680 /* 70 */ 952, 952, 952, 952, 952, 952, 952, 952, 925, 927,
108681 /* 80 */ 796, 795, 905, 769, 793, 786, 790, 865, 858, 859,
108682 /* 90 */ 857, 861, 866, 952, 789, 825, 842, 824, 836, 841,
108683 /* 100 */ 848, 840, 837, 827, 826, 828, 829, 952, 952, 952,
108684 /* 110 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108685 /* 120 */ 952, 952, 952, 658, 723, 952, 952, 952, 952, 952,
108686 /* 130 */ 952, 952, 952, 830, 831, 845, 844, 843, 952, 952,
108687 /* 140 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108688 /* 150 */ 932, 930, 952, 877, 952, 952, 952, 952, 952, 952,
108689 /* 160 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108690 /* 170 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 638,
108691 /* 180 */ 754, 754, 754, 632, 952, 952, 952, 944, 758, 748,
108692 /* 190 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108693 /* 200 */ 952, 952, 952, 683, 798, 737, 915, 917, 952, 898,
108694 /* 210 */ 735, 660, 756, 673, 746, 640, 792, 771, 771, 910,
108695 /* 220 */ 792, 910, 697, 952, 782, 952, 782, 694, 782, 771,
108696 /* 230 */ 860, 952, 952, 952, 755, 746, 952, 937, 762, 762,
108697 /* 240 */ 929, 929, 762, 804, 727, 792, 734, 734, 734, 734,
108698 /* 250 */ 762, 655, 792, 804, 727, 727, 762, 655, 904, 902,
108699 /* 260 */ 762, 762, 655, 762, 655, 762, 655, 870, 725, 725,
108700 /* 270 */ 725, 683, 712, 874, 874, 870, 725, 697, 725, 712,
108701 /* 280 */ 725, 725, 775, 770, 775, 770, 775, 770, 762, 762,
108702 /* 290 */ 952, 787, 776, 785, 783, 792, 952, 715, 648, 648,
108703 /* 300 */ 637, 637, 637, 637, 949, 949, 944, 699, 699, 681,
108704 /* 310 */ 952, 952, 952, 952, 952, 952, 952, 879, 952, 952,
108705 /* 320 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108706 /* 330 */ 633, 939, 952, 952, 936, 952, 952, 952, 952, 797,
108707 /* 340 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108708 /* 350 */ 914, 952, 952, 952, 952, 952, 952, 952, 908, 952,
108709 /* 360 */ 952, 952, 952, 952, 952, 901, 900, 952, 952, 952,
108710 /* 370 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 952,
108711 /* 380 */ 952, 952, 716, 952, 952, 952, 952, 952, 952, 952,
108712 /* 390 */ 952, 952, 952, 952, 784, 952, 777, 952, 863, 952,
108713 /* 400 */ 952, 952, 952, 952, 952, 952, 952, 952, 952, 740,
108714 /* 410 */ 813, 952, 812, 816, 811, 665, 952, 646, 952, 629,
108715 /* 420 */ 634, 948, 951, 950, 947, 946, 945, 940, 938, 935,
108716 /* 430 */ 934, 933, 931, 928, 924, 883, 881, 888, 887, 886,
108717 /* 440 */ 885, 884, 882, 880, 878, 799, 794, 791, 923, 876,
108718 /* 450 */ 736, 733, 732, 654, 941, 907, 916, 803, 802, 805,
108719 /* 460 */ 913, 912, 911, 909, 906, 893, 801, 800, 728, 868,
108720 /* 470 */ 867, 657, 897, 896, 895, 899, 903, 894, 764, 656,
108721 /* 480 */ 653, 662, 718, 724, 722, 721, 720, 719, 717, 664,
108722 /* 490 */ 672, 682, 711, 696, 695, 873, 875, 872, 871, 704,
108723 /* 500 */ 703, 709, 708, 707, 706, 705, 702, 701, 700, 693,
108724 /* 510 */ 692, 698, 691, 714, 713, 710, 690, 731, 730, 729,
108725 /* 520 */ 726, 689, 688, 687, 816, 686, 685, 822, 821, 809,
108726 /* 530 */ 852, 751, 750, 749, 761, 760, 773, 772, 807, 806,
108727 /* 540 */ 774, 759, 753, 752, 768, 767, 766, 765, 757, 747,
108728 /* 550 */ 779, 781, 780, 778, 854, 763, 851, 922, 921, 920,
108729 /* 560 */ 919, 918, 856, 855, 823, 820, 676, 677, 891, 890,
108730 /* 570 */ 892, 889, 679, 678, 675, 674, 853, 742, 741, 849,
108731 /* 580 */ 846, 838, 834, 850, 847, 839, 835, 833, 832, 818,
108732 /* 590 */ 817, 815, 814, 810, 819, 667, 743, 739, 738, 808,
108733 /* 600 */ 745, 744, 684, 680, 661, 659, 652, 650, 649, 651,
108734 /* 610 */ 647, 645, 644, 643, 642, 641, 670, 669, 668, 666,
108735 /* 620 */ 665, 639, 636, 635, 631, 630, 628,
108736 };
108737
108738 /* The next table maps tokens into fallback tokens. If a construct
108739 ** like the following:
108740 **
@@ -108744,11 +108933,11 @@
108933 "create_table", "create_table_args", "createkw", "temp",
108934 "ifnotexists", "dbnm", "columnlist", "conslist_opt",
108935 "select", "column", "columnid", "type",
108936 "carglist", "id", "ids", "typetoken",
108937 "typename", "signed", "plus_num", "minus_num",
108938 "cname", "ccons", "term", "expr",
108939 "onconf", "sortorder", "autoinc", "idxlist_opt",
108940 "refargs", "defer_subclause", "refarg", "refact",
108941 "init_deferred_pred_opt", "conslist", "tcons", "idxlist",
108942 "defer_subclause_opt", "orconf", "resolvetype", "raisetype",
108943 "ifexists", "fullname", "oneselect", "multiselect_op",
@@ -108824,14 +109013,14 @@
109013 /* 48 */ "typetoken ::= typename LP signed COMMA signed RP",
109014 /* 49 */ "typename ::= ids",
109015 /* 50 */ "typename ::= typename ids",
109016 /* 51 */ "signed ::= plus_num",
109017 /* 52 */ "signed ::= minus_num",
109018 /* 53 */ "carglist ::= carglist cname ccons",
109019 /* 54 */ "carglist ::=",
109020 /* 55 */ "cname ::= CONSTRAINT nm",
109021 /* 56 */ "cname ::=",
109022 /* 57 */ "ccons ::= DEFAULT term",
109023 /* 58 */ "ccons ::= DEFAULT LP expr RP",
109024 /* 59 */ "ccons ::= DEFAULT PLUS term",
109025 /* 60 */ "ccons ::= DEFAULT MINUS term",
109026 /* 61 */ "ccons ::= DEFAULT id",
@@ -108861,247 +109050,245 @@
109050 /* 85 */ "init_deferred_pred_opt ::=",
109051 /* 86 */ "init_deferred_pred_opt ::= INITIALLY DEFERRED",
109052 /* 87 */ "init_deferred_pred_opt ::= INITIALLY IMMEDIATE",
109053 /* 88 */ "conslist_opt ::=",
109054 /* 89 */ "conslist_opt ::= COMMA conslist",
109055 /* 90 */ "conslist ::= conslist COMMA cname tcons",
109056 /* 91 */ "conslist ::= cname tcons",
109057 /* 92 */ "tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf",
109058 /* 93 */ "tcons ::= UNIQUE LP idxlist RP onconf",
109059 /* 94 */ "tcons ::= CHECK LP expr RP onconf",
109060 /* 95 */ "tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt",
109061 /* 96 */ "defer_subclause_opt ::=",
109062 /* 97 */ "defer_subclause_opt ::= defer_subclause",
109063 /* 98 */ "onconf ::=",
109064 /* 99 */ "onconf ::= ON CONFLICT resolvetype",
109065 /* 100 */ "orconf ::=",
109066 /* 101 */ "orconf ::= OR resolvetype",
109067 /* 102 */ "resolvetype ::= raisetype",
109068 /* 103 */ "resolvetype ::= IGNORE",
109069 /* 104 */ "resolvetype ::= REPLACE",
109070 /* 105 */ "cmd ::= DROP TABLE ifexists fullname",
109071 /* 106 */ "ifexists ::= IF EXISTS",
109072 /* 107 */ "ifexists ::=",
109073 /* 108 */ "cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select",
109074 /* 109 */ "cmd ::= DROP VIEW ifexists fullname",
109075 /* 110 */ "cmd ::= select",
109076 /* 111 */ "select ::= oneselect",
109077 /* 112 */ "select ::= select multiselect_op oneselect",
109078 /* 113 */ "multiselect_op ::= UNION",
109079 /* 114 */ "multiselect_op ::= UNION ALL",
109080 /* 115 */ "multiselect_op ::= EXCEPT|INTERSECT",
109081 /* 116 */ "oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt",
109082 /* 117 */ "distinct ::= DISTINCT",
109083 /* 118 */ "distinct ::= ALL",
109084 /* 119 */ "distinct ::=",
109085 /* 120 */ "sclp ::= selcollist COMMA",
109086 /* 121 */ "sclp ::=",
109087 /* 122 */ "selcollist ::= sclp expr as",
109088 /* 123 */ "selcollist ::= sclp STAR",
109089 /* 124 */ "selcollist ::= sclp nm DOT STAR",
109090 /* 125 */ "as ::= AS nm",
109091 /* 126 */ "as ::= ids",
109092 /* 127 */ "as ::=",
109093 /* 128 */ "from ::=",
109094 /* 129 */ "from ::= FROM seltablist",
109095 /* 130 */ "stl_prefix ::= seltablist joinop",
109096 /* 131 */ "stl_prefix ::=",
109097 /* 132 */ "seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt",
109098 /* 133 */ "seltablist ::= stl_prefix LP select RP as on_opt using_opt",
109099 /* 134 */ "seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt",
109100 /* 135 */ "dbnm ::=",
109101 /* 136 */ "dbnm ::= DOT nm",
109102 /* 137 */ "fullname ::= nm dbnm",
109103 /* 138 */ "joinop ::= COMMA|JOIN",
109104 /* 139 */ "joinop ::= JOIN_KW JOIN",
109105 /* 140 */ "joinop ::= JOIN_KW nm JOIN",
109106 /* 141 */ "joinop ::= JOIN_KW nm nm JOIN",
109107 /* 142 */ "on_opt ::= ON expr",
109108 /* 143 */ "on_opt ::=",
109109 /* 144 */ "indexed_opt ::=",
109110 /* 145 */ "indexed_opt ::= INDEXED BY nm",
109111 /* 146 */ "indexed_opt ::= NOT INDEXED",
109112 /* 147 */ "using_opt ::= USING LP inscollist RP",
109113 /* 148 */ "using_opt ::=",
109114 /* 149 */ "orderby_opt ::=",
109115 /* 150 */ "orderby_opt ::= ORDER BY sortlist",
109116 /* 151 */ "sortlist ::= sortlist COMMA expr sortorder",
109117 /* 152 */ "sortlist ::= expr sortorder",
109118 /* 153 */ "sortorder ::= ASC",
109119 /* 154 */ "sortorder ::= DESC",
109120 /* 155 */ "sortorder ::=",
109121 /* 156 */ "groupby_opt ::=",
109122 /* 157 */ "groupby_opt ::= GROUP BY nexprlist",
109123 /* 158 */ "having_opt ::=",
109124 /* 159 */ "having_opt ::= HAVING expr",
109125 /* 160 */ "limit_opt ::=",
109126 /* 161 */ "limit_opt ::= LIMIT expr",
109127 /* 162 */ "limit_opt ::= LIMIT expr OFFSET expr",
109128 /* 163 */ "limit_opt ::= LIMIT expr COMMA expr",
109129 /* 164 */ "cmd ::= DELETE FROM fullname indexed_opt where_opt",
109130 /* 165 */ "where_opt ::=",
109131 /* 166 */ "where_opt ::= WHERE expr",
109132 /* 167 */ "cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt",
109133 /* 168 */ "setlist ::= setlist COMMA nm EQ expr",
109134 /* 169 */ "setlist ::= nm EQ expr",
109135 /* 170 */ "cmd ::= insert_cmd INTO fullname inscollist_opt valuelist",
109136 /* 171 */ "cmd ::= insert_cmd INTO fullname inscollist_opt select",
109137 /* 172 */ "cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES",
109138 /* 173 */ "insert_cmd ::= INSERT orconf",
109139 /* 174 */ "insert_cmd ::= REPLACE",
109140 /* 175 */ "valuelist ::= VALUES LP nexprlist RP",
109141 /* 176 */ "valuelist ::= valuelist COMMA LP exprlist RP",
109142 /* 177 */ "inscollist_opt ::=",
109143 /* 178 */ "inscollist_opt ::= LP inscollist RP",
109144 /* 179 */ "inscollist ::= inscollist COMMA nm",
109145 /* 180 */ "inscollist ::= nm",
109146 /* 181 */ "expr ::= term",
109147 /* 182 */ "expr ::= LP expr RP",
109148 /* 183 */ "term ::= NULL",
109149 /* 184 */ "expr ::= id",
109150 /* 185 */ "expr ::= JOIN_KW",
109151 /* 186 */ "expr ::= nm DOT nm",
109152 /* 187 */ "expr ::= nm DOT nm DOT nm",
109153 /* 188 */ "term ::= INTEGER|FLOAT|BLOB",
109154 /* 189 */ "term ::= STRING",
109155 /* 190 */ "expr ::= REGISTER",
109156 /* 191 */ "expr ::= VARIABLE",
109157 /* 192 */ "expr ::= expr COLLATE ids",
109158 /* 193 */ "expr ::= CAST LP expr AS typetoken RP",
109159 /* 194 */ "expr ::= ID LP distinct exprlist RP",
109160 /* 195 */ "expr ::= ID LP STAR RP",
109161 /* 196 */ "term ::= CTIME_KW",
109162 /* 197 */ "expr ::= expr AND expr",
109163 /* 198 */ "expr ::= expr OR expr",
109164 /* 199 */ "expr ::= expr LT|GT|GE|LE expr",
109165 /* 200 */ "expr ::= expr EQ|NE expr",
109166 /* 201 */ "expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr",
109167 /* 202 */ "expr ::= expr PLUS|MINUS expr",
109168 /* 203 */ "expr ::= expr STAR|SLASH|REM expr",
109169 /* 204 */ "expr ::= expr CONCAT expr",
109170 /* 205 */ "likeop ::= LIKE_KW",
109171 /* 206 */ "likeop ::= NOT LIKE_KW",
109172 /* 207 */ "likeop ::= MATCH",
109173 /* 208 */ "likeop ::= NOT MATCH",
109174 /* 209 */ "expr ::= expr likeop expr",
109175 /* 210 */ "expr ::= expr likeop expr ESCAPE expr",
109176 /* 211 */ "expr ::= expr ISNULL|NOTNULL",
109177 /* 212 */ "expr ::= expr NOT NULL",
109178 /* 213 */ "expr ::= expr IS expr",
109179 /* 214 */ "expr ::= expr IS NOT expr",
109180 /* 215 */ "expr ::= NOT expr",
109181 /* 216 */ "expr ::= BITNOT expr",
109182 /* 217 */ "expr ::= MINUS expr",
109183 /* 218 */ "expr ::= PLUS expr",
109184 /* 219 */ "between_op ::= BETWEEN",
109185 /* 220 */ "between_op ::= NOT BETWEEN",
109186 /* 221 */ "expr ::= expr between_op expr AND expr",
109187 /* 222 */ "in_op ::= IN",
109188 /* 223 */ "in_op ::= NOT IN",
109189 /* 224 */ "expr ::= expr in_op LP exprlist RP",
109190 /* 225 */ "expr ::= LP select RP",
109191 /* 226 */ "expr ::= expr in_op LP select RP",
109192 /* 227 */ "expr ::= expr in_op nm dbnm",
109193 /* 228 */ "expr ::= EXISTS LP select RP",
109194 /* 229 */ "expr ::= CASE case_operand case_exprlist case_else END",
109195 /* 230 */ "case_exprlist ::= case_exprlist WHEN expr THEN expr",
109196 /* 231 */ "case_exprlist ::= WHEN expr THEN expr",
109197 /* 232 */ "case_else ::= ELSE expr",
109198 /* 233 */ "case_else ::=",
109199 /* 234 */ "case_operand ::= expr",
109200 /* 235 */ "case_operand ::=",
109201 /* 236 */ "exprlist ::= nexprlist",
109202 /* 237 */ "exprlist ::=",
109203 /* 238 */ "nexprlist ::= nexprlist COMMA expr",
109204 /* 239 */ "nexprlist ::= expr",
109205 /* 240 */ "cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP",
109206 /* 241 */ "uniqueflag ::= UNIQUE",
109207 /* 242 */ "uniqueflag ::=",
109208 /* 243 */ "idxlist_opt ::=",
109209 /* 244 */ "idxlist_opt ::= LP idxlist RP",
109210 /* 245 */ "idxlist ::= idxlist COMMA nm collate sortorder",
109211 /* 246 */ "idxlist ::= nm collate sortorder",
109212 /* 247 */ "collate ::=",
109213 /* 248 */ "collate ::= COLLATE ids",
109214 /* 249 */ "cmd ::= DROP INDEX ifexists fullname",
109215 /* 250 */ "cmd ::= VACUUM",
109216 /* 251 */ "cmd ::= VACUUM nm",
109217 /* 252 */ "cmd ::= PRAGMA nm dbnm",
109218 /* 253 */ "cmd ::= PRAGMA nm dbnm EQ nmnum",
109219 /* 254 */ "cmd ::= PRAGMA nm dbnm LP nmnum RP",
109220 /* 255 */ "cmd ::= PRAGMA nm dbnm EQ minus_num",
109221 /* 256 */ "cmd ::= PRAGMA nm dbnm LP minus_num RP",
109222 /* 257 */ "nmnum ::= plus_num",
109223 /* 258 */ "nmnum ::= nm",
109224 /* 259 */ "nmnum ::= ON",
109225 /* 260 */ "nmnum ::= DELETE",
109226 /* 261 */ "nmnum ::= DEFAULT",
109227 /* 262 */ "plus_num ::= PLUS number",
109228 /* 263 */ "plus_num ::= number",
109229 /* 264 */ "minus_num ::= MINUS number",
109230 /* 265 */ "number ::= INTEGER|FLOAT",
109231 /* 266 */ "cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END",
109232 /* 267 */ "trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause",
109233 /* 268 */ "trigger_time ::= BEFORE",
109234 /* 269 */ "trigger_time ::= AFTER",
109235 /* 270 */ "trigger_time ::= INSTEAD OF",
109236 /* 271 */ "trigger_time ::=",
109237 /* 272 */ "trigger_event ::= DELETE|INSERT",
109238 /* 273 */ "trigger_event ::= UPDATE",
109239 /* 274 */ "trigger_event ::= UPDATE OF inscollist",
109240 /* 275 */ "foreach_clause ::=",
109241 /* 276 */ "foreach_clause ::= FOR EACH ROW",
109242 /* 277 */ "when_clause ::=",
109243 /* 278 */ "when_clause ::= WHEN expr",
109244 /* 279 */ "trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI",
109245 /* 280 */ "trigger_cmd_list ::= trigger_cmd SEMI",
109246 /* 281 */ "trnm ::= nm",
109247 /* 282 */ "trnm ::= nm DOT nm",
109248 /* 283 */ "tridxby ::=",
109249 /* 284 */ "tridxby ::= INDEXED BY nm",
109250 /* 285 */ "tridxby ::= NOT INDEXED",
109251 /* 286 */ "trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt",
109252 /* 287 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist",
109253 /* 288 */ "trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select",
109254 /* 289 */ "trigger_cmd ::= DELETE FROM trnm tridxby where_opt",
109255 /* 290 */ "trigger_cmd ::= select",
109256 /* 291 */ "expr ::= RAISE LP IGNORE RP",
109257 /* 292 */ "expr ::= RAISE LP raisetype COMMA nm RP",
109258 /* 293 */ "raisetype ::= ROLLBACK",
109259 /* 294 */ "raisetype ::= ABORT",
109260 /* 295 */ "raisetype ::= FAIL",
109261 /* 296 */ "cmd ::= DROP TRIGGER ifexists fullname",
109262 /* 297 */ "cmd ::= ATTACH database_kw_opt expr AS expr key_opt",
109263 /* 298 */ "cmd ::= DETACH database_kw_opt expr",
109264 /* 299 */ "key_opt ::=",
109265 /* 300 */ "key_opt ::= KEY expr",
109266 /* 301 */ "database_kw_opt ::= DATABASE",
109267 /* 302 */ "database_kw_opt ::=",
109268 /* 303 */ "cmd ::= REINDEX",
109269 /* 304 */ "cmd ::= REINDEX nm dbnm",
109270 /* 305 */ "cmd ::= ANALYZE",
109271 /* 306 */ "cmd ::= ANALYZE nm dbnm",
109272 /* 307 */ "cmd ::= ALTER TABLE fullname RENAME TO nm",
109273 /* 308 */ "cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column",
109274 /* 309 */ "add_column_fullname ::= fullname",
109275 /* 310 */ "kwcolumn_opt ::=",
109276 /* 311 */ "kwcolumn_opt ::= COLUMNKW",
109277 /* 312 */ "cmd ::= create_vtab",
109278 /* 313 */ "cmd ::= create_vtab LP vtabarglist RP",
109279 /* 314 */ "create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm",
109280 /* 315 */ "vtabarglist ::= vtabarg",
109281 /* 316 */ "vtabarglist ::= vtabarglist COMMA vtabarg",
109282 /* 317 */ "vtabarg ::=",
109283 /* 318 */ "vtabarg ::= vtabarg vtabargtoken",
109284 /* 319 */ "vtabargtoken ::= ANY",
109285 /* 320 */ "vtabargtoken ::= lp anylist RP",
109286 /* 321 */ "lp ::= LP",
109287 /* 322 */ "anylist ::=",
109288 /* 323 */ "anylist ::= anylist LP anylist RP",
109289 /* 324 */ "anylist ::= anylist ANY",
 
 
109290 };
109291 #endif /* NDEBUG */
109292
109293
109294 #if YYSTACKDEPTH<=0
@@ -109543,14 +109730,14 @@
109730 { 167, 6 },
109731 { 168, 1 },
109732 { 168, 2 },
109733 { 169, 1 },
109734 { 169, 1 },
109735 { 164, 3 },
109736 { 164, 0 },
109737 { 172, 2 },
109738 { 172, 0 },
109739 { 173, 2 },
109740 { 173, 4 },
109741 { 173, 3 },
109742 { 173, 3 },
109743 { 173, 2 },
@@ -109580,14 +109767,12 @@
109767 { 184, 0 },
109768 { 184, 2 },
109769 { 184, 2 },
109770 { 159, 0 },
109771 { 159, 2 },
109772 { 185, 4 },
109773 { 185, 2 },
 
 
109774 { 186, 7 },
109775 { 186, 5 },
109776 { 186, 5 },
109777 { 186, 10 },
109778 { 188, 0 },
@@ -109892,12 +110077,12 @@
110077 {yygotominor.yy392 = TK_DEFERRED;}
110078 break;
110079 case 14: /* transtype ::= DEFERRED */
110080 case 15: /* transtype ::= IMMEDIATE */ yytestcase(yyruleno==15);
110081 case 16: /* transtype ::= EXCLUSIVE */ yytestcase(yyruleno==16);
110082 case 113: /* multiselect_op ::= UNION */ yytestcase(yyruleno==113);
110083 case 115: /* multiselect_op ::= EXCEPT|INTERSECT */ yytestcase(yyruleno==115);
110084 {yygotominor.yy392 = yymsp[0].major;}
110085 break;
110086 case 17: /* cmd ::= COMMIT trans_opt */
110087 case 18: /* cmd ::= END trans_opt */ yytestcase(yyruleno==18);
110088 {sqlite3CommitTransaction(pParse);}
@@ -109935,26 +110120,26 @@
110120 case 31: /* temp ::= */ yytestcase(yyruleno==31);
110121 case 70: /* autoinc ::= */ yytestcase(yyruleno==70);
110122 case 83: /* defer_subclause ::= NOT DEFERRABLE init_deferred_pred_opt */ yytestcase(yyruleno==83);
110123 case 85: /* init_deferred_pred_opt ::= */ yytestcase(yyruleno==85);
110124 case 87: /* init_deferred_pred_opt ::= INITIALLY IMMEDIATE */ yytestcase(yyruleno==87);
110125 case 96: /* defer_subclause_opt ::= */ yytestcase(yyruleno==96);
110126 case 107: /* ifexists ::= */ yytestcase(yyruleno==107);
110127 case 118: /* distinct ::= ALL */ yytestcase(yyruleno==118);
110128 case 119: /* distinct ::= */ yytestcase(yyruleno==119);
110129 case 219: /* between_op ::= BETWEEN */ yytestcase(yyruleno==219);
110130 case 222: /* in_op ::= IN */ yytestcase(yyruleno==222);
110131 {yygotominor.yy392 = 0;}
110132 break;
110133 case 29: /* ifnotexists ::= IF NOT EXISTS */
110134 case 30: /* temp ::= TEMP */ yytestcase(yyruleno==30);
110135 case 71: /* autoinc ::= AUTOINCR */ yytestcase(yyruleno==71);
110136 case 86: /* init_deferred_pred_opt ::= INITIALLY DEFERRED */ yytestcase(yyruleno==86);
110137 case 106: /* ifexists ::= IF EXISTS */ yytestcase(yyruleno==106);
110138 case 117: /* distinct ::= DISTINCT */ yytestcase(yyruleno==117);
110139 case 220: /* between_op ::= NOT BETWEEN */ yytestcase(yyruleno==220);
110140 case 223: /* in_op ::= NOT IN */ yytestcase(yyruleno==223);
110141 {yygotominor.yy392 = 1;}
110142 break;
110143 case 32: /* create_table_args ::= LP columnlist conslist_opt RP */
110144 {
110145 sqlite3EndTable(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0);
@@ -109984,25 +110169,25 @@
110169 case 41: /* nm ::= id */ yytestcase(yyruleno==41);
110170 case 42: /* nm ::= STRING */ yytestcase(yyruleno==42);
110171 case 43: /* nm ::= JOIN_KW */ yytestcase(yyruleno==43);
110172 case 46: /* typetoken ::= typename */ yytestcase(yyruleno==46);
110173 case 49: /* typename ::= ids */ yytestcase(yyruleno==49);
110174 case 125: /* as ::= AS nm */ yytestcase(yyruleno==125);
110175 case 126: /* as ::= ids */ yytestcase(yyruleno==126);
110176 case 136: /* dbnm ::= DOT nm */ yytestcase(yyruleno==136);
110177 case 145: /* indexed_opt ::= INDEXED BY nm */ yytestcase(yyruleno==145);
110178 case 248: /* collate ::= COLLATE ids */ yytestcase(yyruleno==248);
110179 case 257: /* nmnum ::= plus_num */ yytestcase(yyruleno==257);
110180 case 258: /* nmnum ::= nm */ yytestcase(yyruleno==258);
110181 case 259: /* nmnum ::= ON */ yytestcase(yyruleno==259);
110182 case 260: /* nmnum ::= DELETE */ yytestcase(yyruleno==260);
110183 case 261: /* nmnum ::= DEFAULT */ yytestcase(yyruleno==261);
110184 case 262: /* plus_num ::= PLUS number */ yytestcase(yyruleno==262);
110185 case 263: /* plus_num ::= number */ yytestcase(yyruleno==263);
110186 case 264: /* minus_num ::= MINUS number */ yytestcase(yyruleno==264);
110187 case 265: /* number ::= INTEGER|FLOAT */ yytestcase(yyruleno==265);
110188 case 281: /* trnm ::= nm */ yytestcase(yyruleno==281);
110189 {yygotominor.yy0 = yymsp[0].minor.yy0;}
110190 break;
110191 case 45: /* type ::= typetoken */
110192 {sqlite3AddColumnType(pParse,&yymsp[0].minor.yy0);}
110193 break;
@@ -110018,10 +110203,16 @@
110203 yygotominor.yy0.n = (int)(&yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] - yymsp[-5].minor.yy0.z);
110204 }
110205 break;
110206 case 50: /* typename ::= typename ids */
110207 {yygotominor.yy0.z=yymsp[-1].minor.yy0.z; yygotominor.yy0.n=yymsp[0].minor.yy0.n+(int)(yymsp[0].minor.yy0.z-yymsp[-1].minor.yy0.z);}
110208 break;
110209 case 55: /* cname ::= CONSTRAINT nm */
110210 {pParse->constraintName = yymsp[0].minor.yy0;}
110211 break;
110212 case 56: /* cname ::= */
110213 {pParse->constraintName.n = 0;}
110214 break;
110215 case 57: /* ccons ::= DEFAULT term */
110216 case 59: /* ccons ::= DEFAULT PLUS term */ yytestcase(yyruleno==59);
110217 {sqlite3AddDefaultValue(pParse,&yymsp[0].minor.yy342);}
110218 break;
@@ -110095,80 +110286,80 @@
110286 break;
110287 case 82: /* refact ::= NO ACTION */
110288 { yygotominor.yy392 = OE_None; /* EV: R-33326-45252 */}
110289 break;
110290 case 84: /* defer_subclause ::= DEFERRABLE init_deferred_pred_opt */
110291 case 97: /* defer_subclause_opt ::= defer_subclause */ yytestcase(yyruleno==97);
110292 case 99: /* onconf ::= ON CONFLICT resolvetype */ yytestcase(yyruleno==99);
110293 case 102: /* resolvetype ::= raisetype */ yytestcase(yyruleno==102);
110294 {yygotominor.yy392 = yymsp[0].minor.yy392;}
110295 break;
110296 case 88: /* conslist_opt ::= */
110297 {yygotominor.yy0.n = 0; yygotominor.yy0.z = 0;}
110298 break;
110299 case 89: /* conslist_opt ::= COMMA conslist */
110300 {yygotominor.yy0 = yymsp[-1].minor.yy0;}
110301 break;
110302 case 92: /* tcons ::= PRIMARY KEY LP idxlist autoinc RP onconf */
110303 {sqlite3AddPrimaryKey(pParse,yymsp[-3].minor.yy442,yymsp[0].minor.yy392,yymsp[-2].minor.yy392,0);}
110304 break;
110305 case 93: /* tcons ::= UNIQUE LP idxlist RP onconf */
110306 {sqlite3CreateIndex(pParse,0,0,0,yymsp[-2].minor.yy442,yymsp[0].minor.yy392,0,0,0,0);}
110307 break;
110308 case 94: /* tcons ::= CHECK LP expr RP onconf */
110309 {sqlite3AddCheckConstraint(pParse,yymsp[-2].minor.yy342.pExpr);}
110310 break;
110311 case 95: /* tcons ::= FOREIGN KEY LP idxlist RP REFERENCES nm idxlist_opt refargs defer_subclause_opt */
110312 {
110313 sqlite3CreateForeignKey(pParse, yymsp[-6].minor.yy442, &yymsp[-3].minor.yy0, yymsp[-2].minor.yy442, yymsp[-1].minor.yy392);
110314 sqlite3DeferForeignKey(pParse, yymsp[0].minor.yy392);
110315 }
110316 break;
110317 case 98: /* onconf ::= */
110318 {yygotominor.yy392 = OE_Default;}
110319 break;
110320 case 100: /* orconf ::= */
110321 {yygotominor.yy258 = OE_Default;}
110322 break;
110323 case 101: /* orconf ::= OR resolvetype */
110324 {yygotominor.yy258 = (u8)yymsp[0].minor.yy392;}
110325 break;
110326 case 103: /* resolvetype ::= IGNORE */
110327 {yygotominor.yy392 = OE_Ignore;}
110328 break;
110329 case 104: /* resolvetype ::= REPLACE */
110330 {yygotominor.yy392 = OE_Replace;}
110331 break;
110332 case 105: /* cmd ::= DROP TABLE ifexists fullname */
110333 {
110334 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 0, yymsp[-1].minor.yy392);
110335 }
110336 break;
110337 case 108: /* cmd ::= createkw temp VIEW ifnotexists nm dbnm AS select */
110338 {
110339 sqlite3CreateView(pParse, &yymsp[-7].minor.yy0, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, yymsp[0].minor.yy159, yymsp[-6].minor.yy392, yymsp[-4].minor.yy392);
110340 }
110341 break;
110342 case 109: /* cmd ::= DROP VIEW ifexists fullname */
110343 {
110344 sqlite3DropTable(pParse, yymsp[0].minor.yy347, 1, yymsp[-1].minor.yy392);
110345 }
110346 break;
110347 case 110: /* cmd ::= select */
110348 {
110349 SelectDest dest = {SRT_Output, 0, 0, 0, 0};
110350 sqlite3Select(pParse, yymsp[0].minor.yy159, &dest);
110351 sqlite3ExplainBegin(pParse->pVdbe);
110352 sqlite3ExplainSelect(pParse->pVdbe, yymsp[0].minor.yy159);
110353 sqlite3ExplainFinish(pParse->pVdbe);
110354 sqlite3SelectDelete(pParse->db, yymsp[0].minor.yy159);
110355 }
110356 break;
110357 case 111: /* select ::= oneselect */
110358 {yygotominor.yy159 = yymsp[0].minor.yy159;}
110359 break;
110360 case 112: /* select ::= select multiselect_op oneselect */
110361 {
110362 if( yymsp[0].minor.yy159 ){
110363 yymsp[0].minor.yy159->op = (u8)yymsp[-1].minor.yy392;
110364 yymsp[0].minor.yy159->pPrior = yymsp[-2].minor.yy159;
110365 }else{
@@ -110175,83 +110366,83 @@
110366 sqlite3SelectDelete(pParse->db, yymsp[-2].minor.yy159);
110367 }
110368 yygotominor.yy159 = yymsp[0].minor.yy159;
110369 }
110370 break;
110371 case 114: /* multiselect_op ::= UNION ALL */
110372 {yygotominor.yy392 = TK_ALL;}
110373 break;
110374 case 116: /* oneselect ::= SELECT distinct selcollist from where_opt groupby_opt having_opt orderby_opt limit_opt */
110375 {
110376 yygotominor.yy159 = sqlite3SelectNew(pParse,yymsp[-6].minor.yy442,yymsp[-5].minor.yy347,yymsp[-4].minor.yy122,yymsp[-3].minor.yy442,yymsp[-2].minor.yy122,yymsp[-1].minor.yy442,yymsp[-7].minor.yy392,yymsp[0].minor.yy64.pLimit,yymsp[0].minor.yy64.pOffset);
110377 }
110378 break;
110379 case 120: /* sclp ::= selcollist COMMA */
110380 case 244: /* idxlist_opt ::= LP idxlist RP */ yytestcase(yyruleno==244);
110381 {yygotominor.yy442 = yymsp[-1].minor.yy442;}
110382 break;
110383 case 121: /* sclp ::= */
110384 case 149: /* orderby_opt ::= */ yytestcase(yyruleno==149);
110385 case 156: /* groupby_opt ::= */ yytestcase(yyruleno==156);
110386 case 237: /* exprlist ::= */ yytestcase(yyruleno==237);
110387 case 243: /* idxlist_opt ::= */ yytestcase(yyruleno==243);
110388 {yygotominor.yy442 = 0;}
110389 break;
110390 case 122: /* selcollist ::= sclp expr as */
110391 {
110392 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-2].minor.yy442, yymsp[-1].minor.yy342.pExpr);
110393 if( yymsp[0].minor.yy0.n>0 ) sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[0].minor.yy0, 1);
110394 sqlite3ExprListSetSpan(pParse,yygotominor.yy442,&yymsp[-1].minor.yy342);
110395 }
110396 break;
110397 case 123: /* selcollist ::= sclp STAR */
110398 {
110399 Expr *p = sqlite3Expr(pParse->db, TK_ALL, 0);
110400 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-1].minor.yy442, p);
110401 }
110402 break;
110403 case 124: /* selcollist ::= sclp nm DOT STAR */
110404 {
110405 Expr *pRight = sqlite3PExpr(pParse, TK_ALL, 0, 0, &yymsp[0].minor.yy0);
110406 Expr *pLeft = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110407 Expr *pDot = sqlite3PExpr(pParse, TK_DOT, pLeft, pRight, 0);
110408 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442, pDot);
110409 }
110410 break;
110411 case 127: /* as ::= */
110412 {yygotominor.yy0.n = 0;}
110413 break;
110414 case 128: /* from ::= */
110415 {yygotominor.yy347 = sqlite3DbMallocZero(pParse->db, sizeof(*yygotominor.yy347));}
110416 break;
110417 case 129: /* from ::= FROM seltablist */
110418 {
110419 yygotominor.yy347 = yymsp[0].minor.yy347;
110420 sqlite3SrcListShiftJoinType(yygotominor.yy347);
110421 }
110422 break;
110423 case 130: /* stl_prefix ::= seltablist joinop */
110424 {
110425 yygotominor.yy347 = yymsp[-1].minor.yy347;
110426 if( ALWAYS(yygotominor.yy347 && yygotominor.yy347->nSrc>0) ) yygotominor.yy347->a[yygotominor.yy347->nSrc-1].jointype = (u8)yymsp[0].minor.yy392;
110427 }
110428 break;
110429 case 131: /* stl_prefix ::= */
110430 {yygotominor.yy347 = 0;}
110431 break;
110432 case 132: /* seltablist ::= stl_prefix nm dbnm as indexed_opt on_opt using_opt */
110433 {
110434 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,&yymsp[-5].minor.yy0,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,0,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110435 sqlite3SrcListIndexedBy(pParse, yygotominor.yy347, &yymsp[-2].minor.yy0);
110436 }
110437 break;
110438 case 133: /* seltablist ::= stl_prefix LP select RP as on_opt using_opt */
110439 {
110440 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,yymsp[-4].minor.yy159,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110441 }
110442 break;
110443 case 134: /* seltablist ::= stl_prefix LP seltablist RP as on_opt using_opt */
110444 {
110445 if( yymsp[-6].minor.yy347==0 && yymsp[-2].minor.yy0.n==0 && yymsp[-1].minor.yy122==0 && yymsp[0].minor.yy180==0 ){
110446 yygotominor.yy347 = yymsp[-4].minor.yy347;
110447 }else{
110448 Select *pSubquery;
@@ -110259,137 +110450,137 @@
110450 pSubquery = sqlite3SelectNew(pParse,0,yymsp[-4].minor.yy347,0,0,0,0,0,0,0);
110451 yygotominor.yy347 = sqlite3SrcListAppendFromTerm(pParse,yymsp[-6].minor.yy347,0,0,&yymsp[-2].minor.yy0,pSubquery,yymsp[-1].minor.yy122,yymsp[0].minor.yy180);
110452 }
110453 }
110454 break;
110455 case 135: /* dbnm ::= */
110456 case 144: /* indexed_opt ::= */ yytestcase(yyruleno==144);
110457 {yygotominor.yy0.z=0; yygotominor.yy0.n=0;}
110458 break;
110459 case 137: /* fullname ::= nm dbnm */
110460 {yygotominor.yy347 = sqlite3SrcListAppend(pParse->db,0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);}
110461 break;
110462 case 138: /* joinop ::= COMMA|JOIN */
110463 { yygotominor.yy392 = JT_INNER; }
110464 break;
110465 case 139: /* joinop ::= JOIN_KW JOIN */
110466 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-1].minor.yy0,0,0); }
110467 break;
110468 case 140: /* joinop ::= JOIN_KW nm JOIN */
110469 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0,0); }
110470 break;
110471 case 141: /* joinop ::= JOIN_KW nm nm JOIN */
110472 { yygotominor.yy392 = sqlite3JoinType(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[-1].minor.yy0); }
110473 break;
110474 case 142: /* on_opt ::= ON expr */
110475 case 159: /* having_opt ::= HAVING expr */ yytestcase(yyruleno==159);
110476 case 166: /* where_opt ::= WHERE expr */ yytestcase(yyruleno==166);
110477 case 232: /* case_else ::= ELSE expr */ yytestcase(yyruleno==232);
110478 case 234: /* case_operand ::= expr */ yytestcase(yyruleno==234);
110479 {yygotominor.yy122 = yymsp[0].minor.yy342.pExpr;}
110480 break;
110481 case 143: /* on_opt ::= */
110482 case 158: /* having_opt ::= */ yytestcase(yyruleno==158);
110483 case 165: /* where_opt ::= */ yytestcase(yyruleno==165);
110484 case 233: /* case_else ::= */ yytestcase(yyruleno==233);
110485 case 235: /* case_operand ::= */ yytestcase(yyruleno==235);
110486 {yygotominor.yy122 = 0;}
110487 break;
110488 case 146: /* indexed_opt ::= NOT INDEXED */
110489 {yygotominor.yy0.z=0; yygotominor.yy0.n=1;}
110490 break;
110491 case 147: /* using_opt ::= USING LP inscollist RP */
110492 case 178: /* inscollist_opt ::= LP inscollist RP */ yytestcase(yyruleno==178);
110493 {yygotominor.yy180 = yymsp[-1].minor.yy180;}
110494 break;
110495 case 148: /* using_opt ::= */
110496 case 177: /* inscollist_opt ::= */ yytestcase(yyruleno==177);
110497 {yygotominor.yy180 = 0;}
110498 break;
110499 case 150: /* orderby_opt ::= ORDER BY sortlist */
110500 case 157: /* groupby_opt ::= GROUP BY nexprlist */ yytestcase(yyruleno==157);
110501 case 236: /* exprlist ::= nexprlist */ yytestcase(yyruleno==236);
110502 {yygotominor.yy442 = yymsp[0].minor.yy442;}
110503 break;
110504 case 151: /* sortlist ::= sortlist COMMA expr sortorder */
110505 {
110506 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-3].minor.yy442,yymsp[-1].minor.yy342.pExpr);
110507 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110508 }
110509 break;
110510 case 152: /* sortlist ::= expr sortorder */
110511 {
110512 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[-1].minor.yy342.pExpr);
110513 if( yygotominor.yy442 && ALWAYS(yygotominor.yy442->a) ) yygotominor.yy442->a[0].sortOrder = (u8)yymsp[0].minor.yy392;
110514 }
110515 break;
110516 case 153: /* sortorder ::= ASC */
110517 case 155: /* sortorder ::= */ yytestcase(yyruleno==155);
110518 {yygotominor.yy392 = SQLITE_SO_ASC;}
110519 break;
110520 case 154: /* sortorder ::= DESC */
110521 {yygotominor.yy392 = SQLITE_SO_DESC;}
110522 break;
110523 case 160: /* limit_opt ::= */
110524 {yygotominor.yy64.pLimit = 0; yygotominor.yy64.pOffset = 0;}
110525 break;
110526 case 161: /* limit_opt ::= LIMIT expr */
110527 {yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr; yygotominor.yy64.pOffset = 0;}
110528 break;
110529 case 162: /* limit_opt ::= LIMIT expr OFFSET expr */
110530 {yygotominor.yy64.pLimit = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pOffset = yymsp[0].minor.yy342.pExpr;}
110531 break;
110532 case 163: /* limit_opt ::= LIMIT expr COMMA expr */
110533 {yygotominor.yy64.pOffset = yymsp[-2].minor.yy342.pExpr; yygotominor.yy64.pLimit = yymsp[0].minor.yy342.pExpr;}
110534 break;
110535 case 164: /* cmd ::= DELETE FROM fullname indexed_opt where_opt */
110536 {
110537 sqlite3SrcListIndexedBy(pParse, yymsp[-2].minor.yy347, &yymsp[-1].minor.yy0);
110538 sqlite3DeleteFrom(pParse,yymsp[-2].minor.yy347,yymsp[0].minor.yy122);
110539 }
110540 break;
110541 case 167: /* cmd ::= UPDATE orconf fullname indexed_opt SET setlist where_opt */
110542 {
110543 sqlite3SrcListIndexedBy(pParse, yymsp[-4].minor.yy347, &yymsp[-3].minor.yy0);
110544 sqlite3ExprListCheckLength(pParse,yymsp[-1].minor.yy442,"set list");
110545 sqlite3Update(pParse,yymsp[-4].minor.yy347,yymsp[-1].minor.yy442,yymsp[0].minor.yy122,yymsp[-5].minor.yy258);
110546 }
110547 break;
110548 case 168: /* setlist ::= setlist COMMA nm EQ expr */
110549 {
110550 yygotominor.yy442 = sqlite3ExprListAppend(pParse, yymsp[-4].minor.yy442, yymsp[0].minor.yy342.pExpr);
110551 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110552 }
110553 break;
110554 case 169: /* setlist ::= nm EQ expr */
110555 {
110556 yygotominor.yy442 = sqlite3ExprListAppend(pParse, 0, yymsp[0].minor.yy342.pExpr);
110557 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110558 }
110559 break;
110560 case 170: /* cmd ::= insert_cmd INTO fullname inscollist_opt valuelist */
110561 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110562 break;
110563 case 171: /* cmd ::= insert_cmd INTO fullname inscollist_opt select */
110564 {sqlite3Insert(pParse, yymsp[-2].minor.yy347, 0, yymsp[0].minor.yy159, yymsp[-1].minor.yy180, yymsp[-4].minor.yy258);}
110565 break;
110566 case 172: /* cmd ::= insert_cmd INTO fullname inscollist_opt DEFAULT VALUES */
110567 {sqlite3Insert(pParse, yymsp[-3].minor.yy347, 0, 0, yymsp[-2].minor.yy180, yymsp[-5].minor.yy258);}
110568 break;
110569 case 173: /* insert_cmd ::= INSERT orconf */
110570 {yygotominor.yy258 = yymsp[0].minor.yy258;}
110571 break;
110572 case 174: /* insert_cmd ::= REPLACE */
110573 {yygotominor.yy258 = OE_Replace;}
110574 break;
110575 case 175: /* valuelist ::= VALUES LP nexprlist RP */
110576 {
110577 yygotominor.yy487.pList = yymsp[-1].minor.yy442;
110578 yygotominor.yy487.pSelect = 0;
110579 }
110580 break;
110581 case 176: /* valuelist ::= valuelist COMMA LP exprlist RP */
110582 {
110583 Select *pRight = sqlite3SelectNew(pParse, yymsp[-1].minor.yy442, 0, 0, 0, 0, 0, 0, 0, 0);
110584 if( yymsp[-4].minor.yy487.pList ){
110585 yymsp[-4].minor.yy487.pSelect = sqlite3SelectNew(pParse, yymsp[-4].minor.yy487.pList, 0, 0, 0, 0, 0, 0, 0, 0);
110586 yymsp[-4].minor.yy487.pList = 0;
@@ -110406,50 +110597,50 @@
110597 pRight->pPrior->selFlags |= SF_Values;
110598 yygotominor.yy487.pSelect = pRight;
110599 }
110600 }
110601 break;
110602 case 179: /* inscollist ::= inscollist COMMA nm */
110603 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,yymsp[-2].minor.yy180,&yymsp[0].minor.yy0);}
110604 break;
110605 case 180: /* inscollist ::= nm */
110606 {yygotominor.yy180 = sqlite3IdListAppend(pParse->db,0,&yymsp[0].minor.yy0);}
110607 break;
110608 case 181: /* expr ::= term */
110609 {yygotominor.yy342 = yymsp[0].minor.yy342;}
110610 break;
110611 case 182: /* expr ::= LP expr RP */
110612 {yygotominor.yy342.pExpr = yymsp[-1].minor.yy342.pExpr; spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);}
110613 break;
110614 case 183: /* term ::= NULL */
110615 case 188: /* term ::= INTEGER|FLOAT|BLOB */ yytestcase(yyruleno==188);
110616 case 189: /* term ::= STRING */ yytestcase(yyruleno==189);
110617 {spanExpr(&yygotominor.yy342, pParse, yymsp[0].major, &yymsp[0].minor.yy0);}
110618 break;
110619 case 184: /* expr ::= id */
110620 case 185: /* expr ::= JOIN_KW */ yytestcase(yyruleno==185);
110621 {spanExpr(&yygotominor.yy342, pParse, TK_ID, &yymsp[0].minor.yy0);}
110622 break;
110623 case 186: /* expr ::= nm DOT nm */
110624 {
110625 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110626 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110627 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp2, 0);
110628 spanSet(&yygotominor.yy342,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0);
110629 }
110630 break;
110631 case 187: /* expr ::= nm DOT nm DOT nm */
110632 {
110633 Expr *temp1 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-4].minor.yy0);
110634 Expr *temp2 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[-2].minor.yy0);
110635 Expr *temp3 = sqlite3PExpr(pParse, TK_ID, 0, 0, &yymsp[0].minor.yy0);
110636 Expr *temp4 = sqlite3PExpr(pParse, TK_DOT, temp2, temp3, 0);
110637 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_DOT, temp1, temp4, 0);
110638 spanSet(&yygotominor.yy342,&yymsp[-4].minor.yy0,&yymsp[0].minor.yy0);
110639 }
110640 break;
110641 case 190: /* expr ::= REGISTER */
110642 {
110643 /* When doing a nested parse, one can include terms in an expression
110644 ** that look like this: #1 #2 ... These terms refer to registers
110645 ** in the virtual machine. #N is the N-th register. */
110646 if( pParse->nested==0 ){
@@ -110460,31 +110651,31 @@
110651 if( yygotominor.yy342.pExpr ) sqlite3GetInt32(&yymsp[0].minor.yy0.z[1], &yygotominor.yy342.pExpr->iTable);
110652 }
110653 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110654 }
110655 break;
110656 case 191: /* expr ::= VARIABLE */
110657 {
110658 spanExpr(&yygotominor.yy342, pParse, TK_VARIABLE, &yymsp[0].minor.yy0);
110659 sqlite3ExprAssignVarNumber(pParse, yygotominor.yy342.pExpr);
110660 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110661 }
110662 break;
110663 case 192: /* expr ::= expr COLLATE ids */
110664 {
110665 yygotominor.yy342.pExpr = sqlite3ExprSetCollByToken(pParse, yymsp[-2].minor.yy342.pExpr, &yymsp[0].minor.yy0);
110666 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110667 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110668 }
110669 break;
110670 case 193: /* expr ::= CAST LP expr AS typetoken RP */
110671 {
110672 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CAST, yymsp[-3].minor.yy342.pExpr, 0, &yymsp[-1].minor.yy0);
110673 spanSet(&yygotominor.yy342,&yymsp[-5].minor.yy0,&yymsp[0].minor.yy0);
110674 }
110675 break;
110676 case 194: /* expr ::= ID LP distinct exprlist RP */
110677 {
110678 if( yymsp[-1].minor.yy442 && yymsp[-1].minor.yy442->nExpr>pParse->db->aLimit[SQLITE_LIMIT_FUNCTION_ARG] ){
110679 sqlite3ErrorMsg(pParse, "too many arguments on function %T", &yymsp[-4].minor.yy0);
110680 }
110681 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, yymsp[-1].minor.yy442, &yymsp[-4].minor.yy0);
@@ -110492,17 +110683,17 @@
110683 if( yymsp[-2].minor.yy392 && yygotominor.yy342.pExpr ){
110684 yygotominor.yy342.pExpr->flags |= EP_Distinct;
110685 }
110686 }
110687 break;
110688 case 195: /* expr ::= ID LP STAR RP */
110689 {
110690 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0, &yymsp[-3].minor.yy0);
110691 spanSet(&yygotominor.yy342,&yymsp[-3].minor.yy0,&yymsp[0].minor.yy0);
110692 }
110693 break;
110694 case 196: /* term ::= CTIME_KW */
110695 {
110696 /* The CURRENT_TIME, CURRENT_DATE, and CURRENT_TIMESTAMP values are
110697 ** treated as functions that return constants */
110698 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, 0,&yymsp[0].minor.yy0);
110699 if( yygotominor.yy342.pExpr ){
@@ -110509,82 +110700,82 @@
110700 yygotominor.yy342.pExpr->op = TK_CONST_FUNC;
110701 }
110702 spanSet(&yygotominor.yy342, &yymsp[0].minor.yy0, &yymsp[0].minor.yy0);
110703 }
110704 break;
110705 case 197: /* expr ::= expr AND expr */
110706 case 198: /* expr ::= expr OR expr */ yytestcase(yyruleno==198);
110707 case 199: /* expr ::= expr LT|GT|GE|LE expr */ yytestcase(yyruleno==199);
110708 case 200: /* expr ::= expr EQ|NE expr */ yytestcase(yyruleno==200);
110709 case 201: /* expr ::= expr BITAND|BITOR|LSHIFT|RSHIFT expr */ yytestcase(yyruleno==201);
110710 case 202: /* expr ::= expr PLUS|MINUS expr */ yytestcase(yyruleno==202);
110711 case 203: /* expr ::= expr STAR|SLASH|REM expr */ yytestcase(yyruleno==203);
110712 case 204: /* expr ::= expr CONCAT expr */ yytestcase(yyruleno==204);
110713 {spanBinaryExpr(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);}
110714 break;
110715 case 205: /* likeop ::= LIKE_KW */
110716 case 207: /* likeop ::= MATCH */ yytestcase(yyruleno==207);
110717 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 0;}
110718 break;
110719 case 206: /* likeop ::= NOT LIKE_KW */
110720 case 208: /* likeop ::= NOT MATCH */ yytestcase(yyruleno==208);
110721 {yygotominor.yy318.eOperator = yymsp[0].minor.yy0; yygotominor.yy318.bNot = 1;}
110722 break;
110723 case 209: /* expr ::= expr likeop expr */
110724 {
110725 ExprList *pList;
110726 pList = sqlite3ExprListAppend(pParse,0, yymsp[0].minor.yy342.pExpr);
110727 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-2].minor.yy342.pExpr);
110728 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-1].minor.yy318.eOperator);
110729 if( yymsp[-1].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110730 yygotominor.yy342.zStart = yymsp[-2].minor.yy342.zStart;
110731 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110732 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110733 }
110734 break;
110735 case 210: /* expr ::= expr likeop expr ESCAPE expr */
110736 {
110737 ExprList *pList;
110738 pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110739 pList = sqlite3ExprListAppend(pParse,pList, yymsp[-4].minor.yy342.pExpr);
110740 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110741 yygotominor.yy342.pExpr = sqlite3ExprFunction(pParse, pList, &yymsp[-3].minor.yy318.eOperator);
110742 if( yymsp[-3].minor.yy318.bNot ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110743 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110744 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110745 if( yygotominor.yy342.pExpr ) yygotominor.yy342.pExpr->flags |= EP_InfixFunc;
110746 }
110747 break;
110748 case 211: /* expr ::= expr ISNULL|NOTNULL */
110749 {spanUnaryPostfix(&yygotominor.yy342,pParse,yymsp[0].major,&yymsp[-1].minor.yy342,&yymsp[0].minor.yy0);}
110750 break;
110751 case 212: /* expr ::= expr NOT NULL */
110752 {spanUnaryPostfix(&yygotominor.yy342,pParse,TK_NOTNULL,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy0);}
110753 break;
110754 case 213: /* expr ::= expr IS expr */
110755 {
110756 spanBinaryExpr(&yygotominor.yy342,pParse,TK_IS,&yymsp[-2].minor.yy342,&yymsp[0].minor.yy342);
110757 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_ISNULL);
110758 }
110759 break;
110760 case 214: /* expr ::= expr IS NOT expr */
110761 {
110762 spanBinaryExpr(&yygotominor.yy342,pParse,TK_ISNOT,&yymsp[-3].minor.yy342,&yymsp[0].minor.yy342);
110763 binaryToUnaryIfNull(pParse, yymsp[0].minor.yy342.pExpr, yygotominor.yy342.pExpr, TK_NOTNULL);
110764 }
110765 break;
110766 case 215: /* expr ::= NOT expr */
110767 case 216: /* expr ::= BITNOT expr */ yytestcase(yyruleno==216);
110768 {spanUnaryPrefix(&yygotominor.yy342,pParse,yymsp[-1].major,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110769 break;
110770 case 217: /* expr ::= MINUS expr */
110771 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UMINUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110772 break;
110773 case 218: /* expr ::= PLUS expr */
110774 {spanUnaryPrefix(&yygotominor.yy342,pParse,TK_UPLUS,&yymsp[0].minor.yy342,&yymsp[-1].minor.yy0);}
110775 break;
110776 case 221: /* expr ::= expr between_op expr AND expr */
110777 {
110778 ExprList *pList = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110779 pList = sqlite3ExprListAppend(pParse,pList, yymsp[0].minor.yy342.pExpr);
110780 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_BETWEEN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110781 if( yygotominor.yy342.pExpr ){
@@ -110595,11 +110786,11 @@
110786 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110787 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110788 yygotominor.yy342.zEnd = yymsp[0].minor.yy342.zEnd;
110789 }
110790 break;
110791 case 224: /* expr ::= expr in_op LP exprlist RP */
110792 {
110793 if( yymsp[-1].minor.yy442==0 ){
110794 /* Expressions of the form
110795 **
110796 ** expr1 IN ()
@@ -110622,11 +110813,11 @@
110813 }
110814 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110815 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110816 }
110817 break;
110818 case 225: /* expr ::= LP select RP */
110819 {
110820 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_SELECT, 0, 0, 0);
110821 if( yygotominor.yy342.pExpr ){
110822 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110823 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110636,11 +110827,11 @@
110827 }
110828 yygotominor.yy342.zStart = yymsp[-2].minor.yy0.z;
110829 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110830 }
110831 break;
110832 case 226: /* expr ::= expr in_op LP select RP */
110833 {
110834 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-4].minor.yy342.pExpr, 0, 0);
110835 if( yygotominor.yy342.pExpr ){
110836 yygotominor.yy342.pExpr->x.pSelect = yymsp[-1].minor.yy159;
110837 ExprSetProperty(yygotominor.yy342.pExpr, EP_xIsSelect);
@@ -110651,11 +110842,11 @@
110842 if( yymsp[-3].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110843 yygotominor.yy342.zStart = yymsp[-4].minor.yy342.zStart;
110844 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110845 }
110846 break;
110847 case 227: /* expr ::= expr in_op nm dbnm */
110848 {
110849 SrcList *pSrc = sqlite3SrcListAppend(pParse->db, 0,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0);
110850 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_IN, yymsp[-3].minor.yy342.pExpr, 0, 0);
110851 if( yygotominor.yy342.pExpr ){
110852 yygotominor.yy342.pExpr->x.pSelect = sqlite3SelectNew(pParse, 0,pSrc,0,0,0,0,0,0,0);
@@ -110667,11 +110858,11 @@
110858 if( yymsp[-2].minor.yy392 ) yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_NOT, yygotominor.yy342.pExpr, 0, 0);
110859 yygotominor.yy342.zStart = yymsp[-3].minor.yy342.zStart;
110860 yygotominor.yy342.zEnd = yymsp[0].minor.yy0.z ? &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n] : &yymsp[-1].minor.yy0.z[yymsp[-1].minor.yy0.n];
110861 }
110862 break;
110863 case 228: /* expr ::= EXISTS LP select RP */
110864 {
110865 Expr *p = yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_EXISTS, 0, 0, 0);
110866 if( p ){
110867 p->x.pSelect = yymsp[-1].minor.yy159;
110868 ExprSetProperty(p, EP_xIsSelect);
@@ -110681,11 +110872,11 @@
110872 }
110873 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
110874 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110875 }
110876 break;
110877 case 229: /* expr ::= CASE case_operand case_exprlist case_else END */
110878 {
110879 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_CASE, yymsp[-3].minor.yy122, yymsp[-1].minor.yy122, 0);
110880 if( yygotominor.yy342.pExpr ){
110881 yygotominor.yy342.pExpr->x.pList = yymsp[-2].minor.yy442;
110882 sqlite3ExprSetHeight(pParse, yygotominor.yy342.pExpr);
@@ -110694,43 +110885,43 @@
110885 }
110886 yygotominor.yy342.zStart = yymsp[-4].minor.yy0.z;
110887 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
110888 }
110889 break;
110890 case 230: /* case_exprlist ::= case_exprlist WHEN expr THEN expr */
110891 {
110892 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-4].minor.yy442, yymsp[-2].minor.yy342.pExpr);
110893 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110894 }
110895 break;
110896 case 231: /* case_exprlist ::= WHEN expr THEN expr */
110897 {
110898 yygotominor.yy442 = sqlite3ExprListAppend(pParse,0, yymsp[-2].minor.yy342.pExpr);
110899 yygotominor.yy442 = sqlite3ExprListAppend(pParse,yygotominor.yy442, yymsp[0].minor.yy342.pExpr);
110900 }
110901 break;
110902 case 238: /* nexprlist ::= nexprlist COMMA expr */
110903 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,yymsp[-2].minor.yy442,yymsp[0].minor.yy342.pExpr);}
110904 break;
110905 case 239: /* nexprlist ::= expr */
110906 {yygotominor.yy442 = sqlite3ExprListAppend(pParse,0,yymsp[0].minor.yy342.pExpr);}
110907 break;
110908 case 240: /* cmd ::= createkw uniqueflag INDEX ifnotexists nm dbnm ON nm LP idxlist RP */
110909 {
110910 sqlite3CreateIndex(pParse, &yymsp[-6].minor.yy0, &yymsp[-5].minor.yy0,
110911 sqlite3SrcListAppend(pParse->db,0,&yymsp[-3].minor.yy0,0), yymsp[-1].minor.yy442, yymsp[-9].minor.yy392,
110912 &yymsp[-10].minor.yy0, &yymsp[0].minor.yy0, SQLITE_SO_ASC, yymsp[-7].minor.yy392);
110913 }
110914 break;
110915 case 241: /* uniqueflag ::= UNIQUE */
110916 case 294: /* raisetype ::= ABORT */ yytestcase(yyruleno==294);
110917 {yygotominor.yy392 = OE_Abort;}
110918 break;
110919 case 242: /* uniqueflag ::= */
110920 {yygotominor.yy392 = OE_None;}
110921 break;
110922 case 245: /* idxlist ::= idxlist COMMA nm collate sortorder */
110923 {
110924 Expr *p = 0;
110925 if( yymsp[-1].minor.yy0.n>0 ){
110926 p = sqlite3Expr(pParse->db, TK_COLUMN, 0);
110927 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110739,11 +110930,11 @@
110930 sqlite3ExprListSetName(pParse,yygotominor.yy442,&yymsp[-2].minor.yy0,1);
110931 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110932 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110933 }
110934 break;
110935 case 246: /* idxlist ::= nm collate sortorder */
110936 {
110937 Expr *p = 0;
110938 if( yymsp[-1].minor.yy0.n>0 ){
110939 p = sqlite3PExpr(pParse, TK_COLUMN, 0, 0, 0);
110940 sqlite3ExprSetCollByToken(pParse, p, &yymsp[-1].minor.yy0);
@@ -110752,212 +110943,212 @@
110943 sqlite3ExprListSetName(pParse, yygotominor.yy442, &yymsp[-2].minor.yy0, 1);
110944 sqlite3ExprListCheckLength(pParse, yygotominor.yy442, "index");
110945 if( yygotominor.yy442 ) yygotominor.yy442->a[yygotominor.yy442->nExpr-1].sortOrder = (u8)yymsp[0].minor.yy392;
110946 }
110947 break;
110948 case 247: /* collate ::= */
110949 {yygotominor.yy0.z = 0; yygotominor.yy0.n = 0;}
110950 break;
110951 case 249: /* cmd ::= DROP INDEX ifexists fullname */
110952 {sqlite3DropIndex(pParse, yymsp[0].minor.yy347, yymsp[-1].minor.yy392);}
110953 break;
110954 case 250: /* cmd ::= VACUUM */
110955 case 251: /* cmd ::= VACUUM nm */ yytestcase(yyruleno==251);
110956 {sqlite3Vacuum(pParse);}
110957 break;
110958 case 252: /* cmd ::= PRAGMA nm dbnm */
110959 {sqlite3Pragma(pParse,&yymsp[-1].minor.yy0,&yymsp[0].minor.yy0,0,0);}
110960 break;
110961 case 253: /* cmd ::= PRAGMA nm dbnm EQ nmnum */
110962 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,0);}
110963 break;
110964 case 254: /* cmd ::= PRAGMA nm dbnm LP nmnum RP */
110965 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,0);}
110966 break;
110967 case 255: /* cmd ::= PRAGMA nm dbnm EQ minus_num */
110968 {sqlite3Pragma(pParse,&yymsp[-3].minor.yy0,&yymsp[-2].minor.yy0,&yymsp[0].minor.yy0,1);}
110969 break;
110970 case 256: /* cmd ::= PRAGMA nm dbnm LP minus_num RP */
110971 {sqlite3Pragma(pParse,&yymsp[-4].minor.yy0,&yymsp[-3].minor.yy0,&yymsp[-1].minor.yy0,1);}
110972 break;
110973 case 266: /* cmd ::= createkw trigger_decl BEGIN trigger_cmd_list END */
110974 {
110975 Token all;
110976 all.z = yymsp[-3].minor.yy0.z;
110977 all.n = (int)(yymsp[0].minor.yy0.z - yymsp[-3].minor.yy0.z) + yymsp[0].minor.yy0.n;
110978 sqlite3FinishTrigger(pParse, yymsp[-1].minor.yy327, &all);
110979 }
110980 break;
110981 case 267: /* trigger_decl ::= temp TRIGGER ifnotexists nm dbnm trigger_time trigger_event ON fullname foreach_clause when_clause */
110982 {
110983 sqlite3BeginTrigger(pParse, &yymsp[-7].minor.yy0, &yymsp[-6].minor.yy0, yymsp[-5].minor.yy392, yymsp[-4].minor.yy410.a, yymsp[-4].minor.yy410.b, yymsp[-2].minor.yy347, yymsp[0].minor.yy122, yymsp[-10].minor.yy392, yymsp[-8].minor.yy392);
110984 yygotominor.yy0 = (yymsp[-6].minor.yy0.n==0?yymsp[-7].minor.yy0:yymsp[-6].minor.yy0);
110985 }
110986 break;
110987 case 268: /* trigger_time ::= BEFORE */
110988 case 271: /* trigger_time ::= */ yytestcase(yyruleno==271);
110989 { yygotominor.yy392 = TK_BEFORE; }
110990 break;
110991 case 269: /* trigger_time ::= AFTER */
110992 { yygotominor.yy392 = TK_AFTER; }
110993 break;
110994 case 270: /* trigger_time ::= INSTEAD OF */
110995 { yygotominor.yy392 = TK_INSTEAD;}
110996 break;
110997 case 272: /* trigger_event ::= DELETE|INSERT */
110998 case 273: /* trigger_event ::= UPDATE */ yytestcase(yyruleno==273);
110999 {yygotominor.yy410.a = yymsp[0].major; yygotominor.yy410.b = 0;}
111000 break;
111001 case 274: /* trigger_event ::= UPDATE OF inscollist */
111002 {yygotominor.yy410.a = TK_UPDATE; yygotominor.yy410.b = yymsp[0].minor.yy180;}
111003 break;
111004 case 277: /* when_clause ::= */
111005 case 299: /* key_opt ::= */ yytestcase(yyruleno==299);
111006 { yygotominor.yy122 = 0; }
111007 break;
111008 case 278: /* when_clause ::= WHEN expr */
111009 case 300: /* key_opt ::= KEY expr */ yytestcase(yyruleno==300);
111010 { yygotominor.yy122 = yymsp[0].minor.yy342.pExpr; }
111011 break;
111012 case 279: /* trigger_cmd_list ::= trigger_cmd_list trigger_cmd SEMI */
111013 {
111014 assert( yymsp[-2].minor.yy327!=0 );
111015 yymsp[-2].minor.yy327->pLast->pNext = yymsp[-1].minor.yy327;
111016 yymsp[-2].minor.yy327->pLast = yymsp[-1].minor.yy327;
111017 yygotominor.yy327 = yymsp[-2].minor.yy327;
111018 }
111019 break;
111020 case 280: /* trigger_cmd_list ::= trigger_cmd SEMI */
111021 {
111022 assert( yymsp[-1].minor.yy327!=0 );
111023 yymsp[-1].minor.yy327->pLast = yymsp[-1].minor.yy327;
111024 yygotominor.yy327 = yymsp[-1].minor.yy327;
111025 }
111026 break;
111027 case 282: /* trnm ::= nm DOT nm */
111028 {
111029 yygotominor.yy0 = yymsp[0].minor.yy0;
111030 sqlite3ErrorMsg(pParse,
111031 "qualified table names are not allowed on INSERT, UPDATE, and DELETE "
111032 "statements within triggers");
111033 }
111034 break;
111035 case 284: /* tridxby ::= INDEXED BY nm */
111036 {
111037 sqlite3ErrorMsg(pParse,
111038 "the INDEXED BY clause is not allowed on UPDATE or DELETE statements "
111039 "within triggers");
111040 }
111041 break;
111042 case 285: /* tridxby ::= NOT INDEXED */
111043 {
111044 sqlite3ErrorMsg(pParse,
111045 "the NOT INDEXED clause is not allowed on UPDATE or DELETE statements "
111046 "within triggers");
111047 }
111048 break;
111049 case 286: /* trigger_cmd ::= UPDATE orconf trnm tridxby SET setlist where_opt */
111050 { yygotominor.yy327 = sqlite3TriggerUpdateStep(pParse->db, &yymsp[-4].minor.yy0, yymsp[-1].minor.yy442, yymsp[0].minor.yy122, yymsp[-5].minor.yy258); }
111051 break;
111052 case 287: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt valuelist */
111053 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, yymsp[0].minor.yy487.pList, yymsp[0].minor.yy487.pSelect, yymsp[-4].minor.yy258);}
111054 break;
111055 case 288: /* trigger_cmd ::= insert_cmd INTO trnm inscollist_opt select */
111056 {yygotominor.yy327 = sqlite3TriggerInsertStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[-1].minor.yy180, 0, yymsp[0].minor.yy159, yymsp[-4].minor.yy258);}
111057 break;
111058 case 289: /* trigger_cmd ::= DELETE FROM trnm tridxby where_opt */
111059 {yygotominor.yy327 = sqlite3TriggerDeleteStep(pParse->db, &yymsp[-2].minor.yy0, yymsp[0].minor.yy122);}
111060 break;
111061 case 290: /* trigger_cmd ::= select */
111062 {yygotominor.yy327 = sqlite3TriggerSelectStep(pParse->db, yymsp[0].minor.yy159); }
111063 break;
111064 case 291: /* expr ::= RAISE LP IGNORE RP */
111065 {
111066 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, 0);
111067 if( yygotominor.yy342.pExpr ){
111068 yygotominor.yy342.pExpr->affinity = OE_Ignore;
111069 }
111070 yygotominor.yy342.zStart = yymsp[-3].minor.yy0.z;
111071 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
111072 }
111073 break;
111074 case 292: /* expr ::= RAISE LP raisetype COMMA nm RP */
111075 {
111076 yygotominor.yy342.pExpr = sqlite3PExpr(pParse, TK_RAISE, 0, 0, &yymsp[-1].minor.yy0);
111077 if( yygotominor.yy342.pExpr ) {
111078 yygotominor.yy342.pExpr->affinity = (char)yymsp[-3].minor.yy392;
111079 }
111080 yygotominor.yy342.zStart = yymsp[-5].minor.yy0.z;
111081 yygotominor.yy342.zEnd = &yymsp[0].minor.yy0.z[yymsp[0].minor.yy0.n];
111082 }
111083 break;
111084 case 293: /* raisetype ::= ROLLBACK */
111085 {yygotominor.yy392 = OE_Rollback;}
111086 break;
111087 case 295: /* raisetype ::= FAIL */
111088 {yygotominor.yy392 = OE_Fail;}
111089 break;
111090 case 296: /* cmd ::= DROP TRIGGER ifexists fullname */
111091 {
111092 sqlite3DropTrigger(pParse,yymsp[0].minor.yy347,yymsp[-1].minor.yy392);
111093 }
111094 break;
111095 case 297: /* cmd ::= ATTACH database_kw_opt expr AS expr key_opt */
111096 {
111097 sqlite3Attach(pParse, yymsp[-3].minor.yy342.pExpr, yymsp[-1].minor.yy342.pExpr, yymsp[0].minor.yy122);
111098 }
111099 break;
111100 case 298: /* cmd ::= DETACH database_kw_opt expr */
111101 {
111102 sqlite3Detach(pParse, yymsp[0].minor.yy342.pExpr);
111103 }
111104 break;
111105 case 303: /* cmd ::= REINDEX */
111106 {sqlite3Reindex(pParse, 0, 0);}
111107 break;
111108 case 304: /* cmd ::= REINDEX nm dbnm */
111109 {sqlite3Reindex(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
111110 break;
111111 case 305: /* cmd ::= ANALYZE */
111112 {sqlite3Analyze(pParse, 0, 0);}
111113 break;
111114 case 306: /* cmd ::= ANALYZE nm dbnm */
111115 {sqlite3Analyze(pParse, &yymsp[-1].minor.yy0, &yymsp[0].minor.yy0);}
111116 break;
111117 case 307: /* cmd ::= ALTER TABLE fullname RENAME TO nm */
111118 {
111119 sqlite3AlterRenameTable(pParse,yymsp[-3].minor.yy347,&yymsp[0].minor.yy0);
111120 }
111121 break;
111122 case 308: /* cmd ::= ALTER TABLE add_column_fullname ADD kwcolumn_opt column */
111123 {
111124 sqlite3AlterFinishAddColumn(pParse, &yymsp[0].minor.yy0);
111125 }
111126 break;
111127 case 309: /* add_column_fullname ::= fullname */
111128 {
111129 pParse->db->lookaside.bEnabled = 0;
111130 sqlite3AlterBeginAddColumn(pParse, yymsp[0].minor.yy347);
111131 }
111132 break;
111133 case 312: /* cmd ::= create_vtab */
111134 {sqlite3VtabFinishParse(pParse,0);}
111135 break;
111136 case 313: /* cmd ::= create_vtab LP vtabarglist RP */
111137 {sqlite3VtabFinishParse(pParse,&yymsp[0].minor.yy0);}
111138 break;
111139 case 314: /* create_vtab ::= createkw VIRTUAL TABLE ifnotexists nm dbnm USING nm */
111140 {
111141 sqlite3VtabBeginParse(pParse, &yymsp[-3].minor.yy0, &yymsp[-2].minor.yy0, &yymsp[0].minor.yy0, yymsp[-4].minor.yy392);
111142 }
111143 break;
111144 case 317: /* vtabarg ::= */
111145 {sqlite3VtabArgInit(pParse);}
111146 break;
111147 case 319: /* vtabargtoken ::= ANY */
111148 case 320: /* vtabargtoken ::= lp anylist RP */ yytestcase(yyruleno==320);
111149 case 321: /* lp ::= LP */ yytestcase(yyruleno==321);
111150 {sqlite3VtabArgExtend(pParse,&yymsp[0].minor.yy0);}
111151 break;
111152 default:
111153 /* (0) input ::= cmdlist */ yytestcase(yyruleno==0);
111154 /* (1) cmdlist ::= cmdlist ecmd */ yytestcase(yyruleno==1);
@@ -110973,32 +111164,28 @@
111164 /* (34) columnlist ::= columnlist COMMA column */ yytestcase(yyruleno==34);
111165 /* (35) columnlist ::= column */ yytestcase(yyruleno==35);
111166 /* (44) type ::= */ yytestcase(yyruleno==44);
111167 /* (51) signed ::= plus_num */ yytestcase(yyruleno==51);
111168 /* (52) signed ::= minus_num */ yytestcase(yyruleno==52);
111169 /* (53) carglist ::= carglist cname ccons */ yytestcase(yyruleno==53);
111170 /* (54) carglist ::= */ yytestcase(yyruleno==54);
 
 
111171 /* (62) ccons ::= NULL onconf */ yytestcase(yyruleno==62);
111172 /* (90) conslist ::= conslist COMMA cname tcons */ yytestcase(yyruleno==90);
111173 /* (91) conslist ::= cname tcons */ yytestcase(yyruleno==91);
111174 /* (275) foreach_clause ::= */ yytestcase(yyruleno==275);
111175 /* (276) foreach_clause ::= FOR EACH ROW */ yytestcase(yyruleno==276);
111176 /* (283) tridxby ::= */ yytestcase(yyruleno==283);
111177 /* (301) database_kw_opt ::= DATABASE */ yytestcase(yyruleno==301);
111178 /* (302) database_kw_opt ::= */ yytestcase(yyruleno==302);
111179 /* (310) kwcolumn_opt ::= */ yytestcase(yyruleno==310);
111180 /* (311) kwcolumn_opt ::= COLUMNKW */ yytestcase(yyruleno==311);
111181 /* (315) vtabarglist ::= vtabarg */ yytestcase(yyruleno==315);
111182 /* (316) vtabarglist ::= vtabarglist COMMA vtabarg */ yytestcase(yyruleno==316);
111183 /* (318) vtabarg ::= vtabarg vtabargtoken */ yytestcase(yyruleno==318);
111184 /* (322) anylist ::= */ yytestcase(yyruleno==322);
111185 /* (323) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==323);
111186 /* (324) anylist ::= anylist ANY */ yytestcase(yyruleno==324);
 
 
111187 break;
111188 };
111189 yygoto = yyRuleInfo[yyruleno].lhs;
111190 yysize = yyRuleInfo[yyruleno].nrhs;
111191 yypParser->yyidx -= yysize;
@@ -115889,11 +116076,11 @@
116076 ** option. But that functionality is no longer supported.
116077 **
116078 ** A doclist is stored like this:
116079 **
116080 ** array {
116081 ** varint docid; (delta from previous doclist)
116082 ** array { (position list for column 0)
116083 ** varint position; (2 more than the delta from previous position)
116084 ** }
116085 ** array {
116086 ** varint POS_COLUMN; (marks start of position list for new column)
@@ -115920,12 +116107,12 @@
116107 ** The 123 value is the first docid. For column zero in this document
116108 ** there are two matches at positions 3 and 10 (5-2 and 9-2+3). The 1
116109 ** at D signals the start of a new column; the 1 at E indicates that the
116110 ** new column is column number 1. There are two positions at 12 and 45
116111 ** (14-2 and 35-2+12). The 0 at H indicate the end-of-document. The
116112 ** 234 at I is the delta to next docid (357). It has one position 70
116113 ** (72-2) and then terminates with the 0 at K.
116114 **
116115 ** A "position-list" is the list of positions for multiple columns for
116116 ** a single docid. A "column-list" is the set of positions for a single
116117 ** column. Hence, a position-list consists of one or more column-lists,
116118 ** a document record consists of a docid followed by a position-list and
@@ -116456,10 +116643,13 @@
116643
116644
116645 #ifndef MIN
116646 # define MIN(x,y) ((x)<(y)?(x):(y))
116647 #endif
116648 #ifndef MAX
116649 # define MAX(x,y) ((x)>(y)?(x):(y))
116650 #endif
116651
116652 /*
116653 ** Maximum length of a varint encoded integer. The varint format is different
116654 ** from that used by SQLite, so the maximum length is 10, not 9.
116655 */
@@ -116510,20 +116700,21 @@
116700 #ifdef SQLITE_COVERAGE_TEST
116701 # define ALWAYS(x) (1)
116702 # define NEVER(X) (0)
116703 #else
116704 # define ALWAYS(x) (x)
116705 # define NEVER(x) (x)
116706 #endif
116707
116708 /*
116709 ** Internal types used by SQLite.
116710 */
116711 typedef unsigned char u8; /* 1-byte (or larger) unsigned integer */
116712 typedef short int i16; /* 2-byte (or larger) signed integer */
116713 typedef unsigned int u32; /* 4-byte unsigned integer */
116714 typedef sqlite3_uint64 u64; /* 8-byte unsigned integer */
116715 typedef sqlite3_int64 i64; /* 8-byte signed integer */
116716
116717 /*
116718 ** Macro used to suppress compiler warnings for unused parameters.
116719 */
116720 #define UNUSED_PARAMETER(x) (void)(x)
@@ -116582,40 +116773,47 @@
116773 int nColumn; /* number of named columns in virtual table */
116774 char **azColumn; /* column names. malloced */
116775 sqlite3_tokenizer *pTokenizer; /* tokenizer for inserts and queries */
116776 char *zContentTbl; /* content=xxx option, or NULL */
116777 char *zLanguageid; /* languageid=xxx option, or NULL */
116778 u8 bAutoincrmerge; /* True if automerge=1 */
116779 u32 nLeafAdd; /* Number of leaf blocks added this trans */
116780
116781 /* Precompiled statements used by the implementation. Each of these
116782 ** statements is run and reset within a single virtual table API call.
116783 */
116784 sqlite3_stmt *aStmt[37];
116785
116786 char *zReadExprlist;
116787 char *zWriteExprlist;
116788
116789 int nNodeSize; /* Soft limit for node size */
116790 u8 bFts4; /* True for FTS4, false for FTS3 */
116791 u8 bHasStat; /* True if %_stat table exists */
116792 u8 bHasDocsize; /* True if %_docsize table exists */
116793 u8 bDescIdx; /* True if doclists are in reverse order */
116794 u8 bIgnoreSavepoint; /* True to ignore xSavepoint invocations */
116795 int nPgsz; /* Page size for host database */
116796 char *zSegmentsTbl; /* Name of %_segments table */
116797 sqlite3_blob *pSegments; /* Blob handle open on %_segments table */
116798
116799 /*
 
116800 ** The following array of hash tables is used to buffer pending index
116801 ** updates during transactions. All pending updates buffered at any one
116802 ** time must share a common language-id (see the FTS4 langid= feature).
116803 ** The current language id is stored in variable iPrevLangid.
 
 
116804 **
116805 ** A single FTS4 table may have multiple full-text indexes. For each index
116806 ** there is an entry in the aIndex[] array. Index 0 is an index of all the
116807 ** terms that appear in the document set. Each subsequent index in aIndex[]
116808 ** is an index of prefixes of a specific length.
116809 **
116810 ** Variable nPendingData contains an estimate the memory consumed by the
116811 ** pending data structures, including hash table overhead, but not including
116812 ** malloc overhead. When nPendingData exceeds nMaxPendingData, all hash
116813 ** tables are flushed to disk. Variable iPrevDocid is the docid of the most
116814 ** recently inserted record.
116815 */
116816 int nIndex; /* Size of aIndex[] */
116817 struct Fts3Index {
116818 int nPrefix; /* Prefix length (0 for main terms index) */
116819 Fts3Hash hPending; /* Pending terms table for this index */
@@ -116810,10 +117008,11 @@
117008 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredTokens(Fts3Cursor *);
117009 SQLITE_PRIVATE int sqlite3Fts3DeferToken(Fts3Cursor *, Fts3PhraseToken *, int);
117010 SQLITE_PRIVATE int sqlite3Fts3CacheDeferredDoclists(Fts3Cursor *);
117011 SQLITE_PRIVATE void sqlite3Fts3FreeDeferredDoclists(Fts3Cursor *);
117012 SQLITE_PRIVATE void sqlite3Fts3SegmentsClose(Fts3Table *);
117013 SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *, int *);
117014
117015 /* Special values interpreted by sqlite3SegReaderCursor() */
117016 #define FTS3_SEGCURSOR_PENDING -1
117017 #define FTS3_SEGCURSOR_ALL -2
117018
@@ -116861,19 +117060,22 @@
117060 int nTerm; /* Size of zTerm in bytes */
117061 char *aDoclist; /* Pointer to doclist buffer */
117062 int nDoclist; /* Size of aDoclist[] in bytes */
117063 };
117064
117065 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table*,int,int);
117066
117067 /* fts3.c */
117068 SQLITE_PRIVATE int sqlite3Fts3PutVarint(char *, sqlite3_int64);
117069 SQLITE_PRIVATE int sqlite3Fts3GetVarint(const char *, sqlite_int64 *);
117070 SQLITE_PRIVATE int sqlite3Fts3GetVarint32(const char *, int *);
117071 SQLITE_PRIVATE int sqlite3Fts3VarintLen(sqlite3_uint64);
117072 SQLITE_PRIVATE void sqlite3Fts3Dequote(char *);
117073 SQLITE_PRIVATE void sqlite3Fts3DoclistPrev(int,char*,int,char**,sqlite3_int64*,int*,u8*);
117074 SQLITE_PRIVATE int sqlite3Fts3EvalPhraseStats(Fts3Cursor *, Fts3Expr *, u32 *);
117075 SQLITE_PRIVATE int sqlite3Fts3FirstFilter(sqlite3_int64, char *, int, char *);
117076 SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int*, Fts3Table*);
117077
117078 /* fts3_tokenizer.c */
117079 SQLITE_PRIVATE const char *sqlite3Fts3NextToken(const char *, int *);
117080 SQLITE_PRIVATE int sqlite3Fts3InitHashTable(sqlite3 *, Fts3Hash *, const char *);
117081 SQLITE_PRIVATE int sqlite3Fts3InitTokenizer(Fts3Hash *pHash, const char *,
@@ -117198,10 +117400,22 @@
117400 sqlite3_free(zSql);
117401 sqlite3_free(zCols);
117402 *pRc = rc;
117403 }
117404 }
117405
117406 /*
117407 ** Create the %_stat table if it does not already exist.
117408 */
117409 SQLITE_PRIVATE void sqlite3Fts3CreateStatTable(int *pRc, Fts3Table *p){
117410 fts3DbExec(pRc, p->db,
117411 "CREATE TABLE IF NOT EXISTS %Q.'%q_stat'"
117412 "(id INTEGER PRIMARY KEY, value BLOB);",
117413 p->zDb, p->zName
117414 );
117415 if( (*pRc)==SQLITE_OK ) p->bHasStat = 1;
117416 }
117417
117418 /*
117419 ** Create the backing store tables (%_content, %_segments and %_segdir)
117420 ** required by the FTS3 table passed as the only argument. This is done
117421 ** as part of the vtab xCreate() method.
@@ -117259,15 +117473,13 @@
117473 fts3DbExec(&rc, db,
117474 "CREATE TABLE %Q.'%q_docsize'(docid INTEGER PRIMARY KEY, size BLOB);",
117475 p->zDb, p->zName
117476 );
117477 }
117478 assert( p->bHasStat==p->bFts4 );
117479 if( p->bHasStat ){
117480 sqlite3Fts3CreateStatTable(&rc, p);
 
 
 
117481 }
117482 return rc;
117483 }
117484
117485 /*
@@ -117370,11 +117582,11 @@
117582 ** memory.
117583 */
117584 static char *fts3QuoteId(char const *zInput){
117585 int nRet;
117586 char *zRet;
117587 nRet = 2 + (int)strlen(zInput)*2 + 1;
117588 zRet = sqlite3_malloc(nRet);
117589 if( zRet ){
117590 int i;
117591 char *z = zRet;
117592 *(z++) = '"';
@@ -117626,11 +117838,11 @@
117838 ** space required to store a copy of each column name, including the
117839 ** nul-terminator byte. */
117840 nCol = sqlite3_column_count(pStmt);
117841 for(i=0; i<nCol; i++){
117842 const char *zCol = sqlite3_column_name(pStmt, i);
117843 nStr += (int)strlen(zCol) + 1;
117844 }
117845
117846 /* Allocate and populate the array to return. */
117847 azCol = (const char **)sqlite3_malloc(sizeof(char *) * nCol + nStr);
117848 if( azCol==0 ){
@@ -117637,11 +117849,11 @@
117849 rc = SQLITE_NOMEM;
117850 }else{
117851 char *p = (char *)&azCol[nCol];
117852 for(i=0; i<nCol; i++){
117853 const char *zCol = sqlite3_column_name(pStmt, i);
117854 int n = (int)strlen(zCol)+1;
117855 memcpy(p, zCol, n);
117856 azCol[i] = p;
117857 p += n;
117858 }
117859 }
@@ -117852,11 +118064,12 @@
118064 ** column from the aCol[] array. */
118065 if( rc==SQLITE_OK && zLanguageid ){
118066 int j;
118067 for(j=0; j<nCol; j++){
118068 if( sqlite3_stricmp(zLanguageid, aCol[j])==0 ){
118069 int k;
118070 for(k=j; k<nCol; k++) aCol[k] = aCol[k+1];
118071 nCol--;
118072 break;
118073 }
118074 }
118075 }
@@ -117903,11 +118116,13 @@
118116 p->azColumn = (char **)&p[1];
118117 p->pTokenizer = pTokenizer;
118118 p->nMaxPendingData = FTS3_MAX_PENDING_DATA;
118119 p->bHasDocsize = (isFts4 && bNoDocsize==0);
118120 p->bHasStat = isFts4;
118121 p->bFts4 = isFts4;
118122 p->bDescIdx = bDescIdx;
118123 p->bAutoincrmerge = 0xff; /* 0xff means setting unknown */
118124 p->zContentTbl = zContent;
118125 p->zLanguageid = zLanguageid;
118126 zContent = 0;
118127 zLanguageid = 0;
118128 TESTONLY( p->inTransaction = -1 );
@@ -117955,10 +118170,20 @@
118170 ** database. TODO: For xConnect(), it could verify that said tables exist.
118171 */
118172 if( isCreate ){
118173 rc = fts3CreateTables(p);
118174 }
118175
118176 /* Check to see if a legacy fts3 table has been "upgraded" by the
118177 ** addition of a %_stat table so that it can use incremental merge.
118178 */
118179 if( !isFts4 && !isCreate ){
118180 int rc2 = SQLITE_OK;
118181 fts3DbExec(&rc2, db, "SELECT 1 FROM %Q.'%q_stat' WHERE id=2",
118182 p->zDb, p->zName);
118183 if( rc2==SQLITE_OK ) p->bHasStat = 1;
118184 }
118185
118186 /* Figure out the page-size for the database. This is required in order to
118187 ** estimate the cost of loading large doclists from the database. */
118188 fts3DatabasePageSize(&rc, p);
118189 p->nNodeSize = p->nPgsz-35;
@@ -118959,11 +119184,11 @@
119184 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119185 }
119186 }
119187
119188 *paOut = aOut;
119189 *pnOut = (int)(p-aOut);
119190 assert( *pnOut<=n1+n2+FTS3_VARINT_MAX-1 );
119191 return SQLITE_OK;
119192 }
119193
119194 /*
@@ -119023,11 +119248,11 @@
119248 fts3PoslistCopy(0, &p2);
119249 fts3GetDeltaVarint3(&p2, pEnd2, bDescDoclist, &i2);
119250 }
119251 }
119252
119253 *pnRight = (int)(p - aOut);
119254 }
119255
119256 /*
119257 ** Argument pList points to a position list nList bytes in size. This
119258 ** function checks to see if the position list contains any entries for
@@ -119299,11 +119524,11 @@
119524 ** Set up a cursor object for iterating through a full-text index or a
119525 ** single level therein.
119526 */
119527 SQLITE_PRIVATE int sqlite3Fts3SegReaderCursor(
119528 Fts3Table *p, /* FTS3 table handle */
119529 int iLangid, /* Language-id to search */
119530 int iIndex, /* Index to search (from 0 to p->nIndex-1) */
119531 int iLevel, /* Level of segments to scan */
119532 const char *zTerm, /* Term to query for */
119533 int nTerm, /* Size of zTerm in bytes */
119534 int isPrefix, /* True for a prefix search */
@@ -119317,16 +119542,11 @@
119542 );
119543 assert( iLevel<FTS3_SEGDIR_MAXLEVEL );
119544 assert( FTS3_SEGCURSOR_ALL<0 && FTS3_SEGCURSOR_PENDING<0 );
119545 assert( isPrefix==0 || isScan==0 );
119546
 
 
 
 
119547 memset(pCsr, 0, sizeof(Fts3MultiSegReader));
 
119548 return fts3SegReaderCursor(
119549 p, iLangid, iIndex, iLevel, zTerm, nTerm, isPrefix, isScan, pCsr
119550 );
119551 }
119552
@@ -119587,11 +119807,11 @@
119807
119808 pCsr->iLangid = 0;
119809 if( nVal==2 ) pCsr->iLangid = sqlite3_value_int(apVal[1]);
119810
119811 rc = sqlite3Fts3ExprParse(p->pTokenizer, pCsr->iLangid,
119812 p->azColumn, p->bFts4, p->nColumn, iCol, zQuery, -1, &pCsr->pExpr
119813 );
119814 if( rc!=SQLITE_OK ){
119815 if( rc==SQLITE_ERROR ){
119816 static const char *zErr = "malformed MATCH expression: [%s]";
119817 p->base.zErrMsg = sqlite3_mprintf(zErr, zQuery);
@@ -119730,26 +119950,61 @@
119950 /*
119951 ** Implementation of xSync() method. Flush the contents of the pending-terms
119952 ** hash-table to the database.
119953 */
119954 static int fts3SyncMethod(sqlite3_vtab *pVtab){
119955
119956 /* Following an incremental-merge operation, assuming that the input
119957 ** segments are not completely consumed (the usual case), they are updated
119958 ** in place to remove the entries that have already been merged. This
119959 ** involves updating the leaf block that contains the smallest unmerged
119960 ** entry and each block (if any) between the leaf and the root node. So
119961 ** if the height of the input segment b-trees is N, and input segments
119962 ** are merged eight at a time, updating the input segments at the end
119963 ** of an incremental-merge requires writing (8*(1+N)) blocks. N is usually
119964 ** small - often between 0 and 2. So the overhead of the incremental
119965 ** merge is somewhere between 8 and 24 blocks. To avoid this overhead
119966 ** dwarfing the actual productive work accomplished, the incremental merge
119967 ** is only attempted if it will write at least 64 leaf blocks. Hence
119968 ** nMinMerge.
119969 **
119970 ** Of course, updating the input segments also involves deleting a bunch
119971 ** of blocks from the segments table. But this is not considered overhead
119972 ** as it would also be required by a crisis-merge that used the same input
119973 ** segments.
119974 */
119975 const u32 nMinMerge = 64; /* Minimum amount of incr-merge work to do */
119976
119977 Fts3Table *p = (Fts3Table*)pVtab;
119978 int rc = sqlite3Fts3PendingTermsFlush(p);
119979
119980 if( rc==SQLITE_OK && p->bAutoincrmerge==1 && p->nLeafAdd>(nMinMerge/16) ){
119981 int mxLevel = 0; /* Maximum relative level value in db */
119982 int A; /* Incr-merge parameter A */
119983
119984 rc = sqlite3Fts3MaxLevel(p, &mxLevel);
119985 assert( rc==SQLITE_OK || mxLevel==0 );
119986 A = p->nLeafAdd * mxLevel;
119987 A += (A/2);
119988 if( A>(int)nMinMerge ) rc = sqlite3Fts3Incrmerge(p, A, 8);
119989 }
119990 sqlite3Fts3SegmentsClose(p);
119991 return rc;
119992 }
119993
119994 /*
119995 ** Implementation of xBegin() method. This is a no-op.
119996 */
119997 static int fts3BeginMethod(sqlite3_vtab *pVtab){
119998 Fts3Table *p = (Fts3Table*)pVtab;
119999 UNUSED_PARAMETER(pVtab);
120000 assert( p->pSegments==0 );
120001 assert( p->nPendingData==0 );
120002 assert( p->inTransaction!=1 );
120003 TESTONLY( p->inTransaction = 1 );
120004 TESTONLY( p->mxSavepoint = -1; );
120005 p->nLeafAdd = 0;
120006 return SQLITE_OK;
120007 }
120008
120009 /*
120010 ** Implementation of xCommit() method. This is a no-op. The contents of
@@ -120040,15 +120295,19 @@
120295 ** The xSavepoint() method.
120296 **
120297 ** Flush the contents of the pending-terms table to disk.
120298 */
120299 static int fts3SavepointMethod(sqlite3_vtab *pVtab, int iSavepoint){
120300 int rc = SQLITE_OK;
120301 UNUSED_PARAMETER(iSavepoint);
120302 assert( ((Fts3Table *)pVtab)->inTransaction );
120303 assert( ((Fts3Table *)pVtab)->mxSavepoint < iSavepoint );
120304 TESTONLY( ((Fts3Table *)pVtab)->mxSavepoint = iSavepoint );
120305 if( ((Fts3Table *)pVtab)->bIgnoreSavepoint==0 ){
120306 rc = fts3SyncMethod(pVtab);
120307 }
120308 return rc;
120309 }
120310
120311 /*
120312 ** The xRelease() method.
120313 **
@@ -120404,11 +120663,11 @@
120663
120664 assert( iPrev>=0 );
120665 fts3PoslistPhraseMerge(&aOut, iToken-iPrev, 0, 1, &p1, &p2);
120666 sqlite3_free(aPoslist);
120667 aPoslist = pList;
120668 nPoslist = (int)(aOut - aPoslist);
120669 if( nPoslist==0 ){
120670 sqlite3_free(aPoslist);
120671 pPhrase->doclist.pList = 0;
120672 pPhrase->doclist.nList = 0;
120673 return SQLITE_OK;
@@ -120448,11 +120707,11 @@
120707 }
120708
120709 pPhrase->doclist.pList = aOut;
120710 if( fts3PoslistPhraseMerge(&aOut, nDistance, 0, 1, &p1, &p2) ){
120711 pPhrase->doclist.bFreeList = 1;
120712 pPhrase->doclist.nList = (int)(aOut - pPhrase->doclist.pList);
120713 }else{
120714 sqlite3_free(aOut);
120715 pPhrase->doclist.pList = 0;
120716 pPhrase->doclist.nList = 0;
120717 }
@@ -120544,11 +120803,11 @@
120803 fts3PoslistCopy(0, &pDocid);
120804 while( pDocid<pEnd && *pDocid==0 ) pDocid++;
120805 iMul = (bDescIdx ? -1 : 1);
120806 }
120807
120808 *pnList = (int)(pEnd - pNext);
120809 *ppIter = pNext;
120810 *piDocid = iDocid;
120811 }else{
120812 int iMul = (bDescIdx ? -1 : 1);
120813 sqlite3_int64 iDelta;
@@ -120558,11 +120817,11 @@
120817 if( p==aDoclist ){
120818 *pbEof = 1;
120819 }else{
120820 char *pSave = p;
120821 fts3ReversePoslist(aDoclist, &p);
120822 *pnList = (int)(pSave - p);
120823 }
120824 *ppIter = p;
120825 }
120826 }
120827
@@ -120618,11 +120877,11 @@
120877 }else{
120878 pDL->iDocid -= iDelta;
120879 }
120880 pDL->pList = pIter;
120881 fts3PoslistCopy(0, &pIter);
120882 pDL->nList = (int)(pIter - pDL->pList);
120883
120884 /* pIter now points just past the 0x00 that terminates the position-
120885 ** list for document pDL->iDocid. However, if this position-list was
120886 ** edited in place by fts3EvalNearTrim(), then pIter may not actually
120887 ** point to the start of the next docid value. The following line deals
@@ -120959,11 +121218,11 @@
121218
121219 /* Allocate a MultiSegReader for each token in the expression. */
121220 fts3EvalAllocateReaders(pCsr, pCsr->pExpr, &nToken, &nOr, &rc);
121221
121222 /* Determine which, if any, tokens in the expression should be deferred. */
121223 if( rc==SQLITE_OK && nToken>1 && pTab->bFts4 ){
121224 Fts3TokenAndCost *aTC;
121225 Fts3Expr **apOr;
121226 aTC = (Fts3TokenAndCost *)sqlite3_malloc(
121227 sizeof(Fts3TokenAndCost) * nToken
121228 + sizeof(Fts3Expr *) * nOr * 2
@@ -120976,12 +121235,12 @@
121235 int ii;
121236 Fts3TokenAndCost *pTC = aTC;
121237 Fts3Expr **ppOr = apOr;
121238
121239 fts3EvalTokenCosts(pCsr, 0, pCsr->pExpr, &pTC, &ppOr, &rc);
121240 nToken = (int)(pTC-aTC);
121241 nOr = (int)(ppOr-apOr);
121242
121243 if( rc==SQLITE_OK ){
121244 rc = fts3EvalSelectDeferred(pCsr, 0, aTC, nToken);
121245 for(ii=0; rc==SQLITE_OK && ii<nOr; ii++){
121246 rc = fts3EvalSelectDeferred(pCsr, apOr[ii], aTC, nToken);
@@ -121049,11 +121308,11 @@
121308 p2 = pOut = pPhrase->doclist.pList;
121309 res = fts3PoslistNearMerge(
121310 &pOut, aTmp, nParam1, nParam2, paPoslist, &p2
121311 );
121312 if( res ){
121313 nNew = (int)(pOut - pPhrase->doclist.pList) - 1;
121314 assert( pPhrase->doclist.pList[nNew]=='\0' );
121315 assert( nNew<=pPhrase->doclist.nList && nNew>0 );
121316 memset(&pPhrase->doclist.pList[nNew], 0, pPhrase->doclist.nList - nNew);
121317 pPhrase->doclist.nList = nNew;
121318 *paPoslist = pPhrase->doclist.pList;
@@ -121774,10 +122033,11 @@
122033 fts3SegReaderCursorFree(pPhrase->aToken[i].pSegcsr);
122034 pPhrase->aToken[i].pSegcsr = 0;
122035 }
122036 }
122037 }
122038
122039
122040 /*
122041 ** Return SQLITE_CORRUPT_VTAB.
122042 */
122043 #ifdef SQLITE_DEBUG
@@ -121882,13 +122142,13 @@
122142 );
122143 return SQLITE_ERROR;
122144 }
122145
122146 zDb = argv[1];
122147 nDb = (int)strlen(zDb);
122148 zFts3 = argv[3];
122149 nFts3 = (int)strlen(zFts3);
122150
122151 rc = sqlite3_declare_vtab(db, FTS3_TERMS_SCHEMA);
122152 if( rc!=SQLITE_OK ) return rc;
122153
122154 nByte = sizeof(Fts3auxTable) + sizeof(Fts3Table) + nDb + nFts3 + 2;
@@ -125074,10 +125334,13 @@
125334
125335 /* #include <string.h> */
125336 /* #include <assert.h> */
125337 /* #include <stdlib.h> */
125338
125339
125340 #define FTS_MAX_APPENDABLE_HEIGHT 16
125341
125342 /*
125343 ** When full-text index nodes are loaded from disk, the buffer that they
125344 ** are loaded into has the following number of bytes of padding at the end
125345 ** of it. i.e. if a full-text index node is 900 bytes in size, then a buffer
125346 ** of 920 bytes is allocated for it.
@@ -125112,10 +125375,33 @@
125375 # define FTS3_NODE_CHUNK_THRESHOLD test_fts3_node_chunk_threshold
125376 #else
125377 # define FTS3_NODE_CHUNKSIZE (4*1024)
125378 # define FTS3_NODE_CHUNK_THRESHOLD (FTS3_NODE_CHUNKSIZE*4)
125379 #endif
125380
125381 /*
125382 ** The two values that may be meaningfully bound to the :1 parameter in
125383 ** statements SQL_REPLACE_STAT and SQL_SELECT_STAT.
125384 */
125385 #define FTS_STAT_DOCTOTAL 0
125386 #define FTS_STAT_INCRMERGEHINT 1
125387 #define FTS_STAT_AUTOINCRMERGE 2
125388
125389 /*
125390 ** If FTS_LOG_MERGES is defined, call sqlite3_log() to report each automatic
125391 ** and incremental merge operation that takes place. This is used for
125392 ** debugging FTS only, it should not usually be turned on in production
125393 ** systems.
125394 */
125395 #ifdef FTS3_LOG_MERGES
125396 static void fts3LogMerge(int nMerge, sqlite3_int64 iAbsLevel){
125397 sqlite3_log(SQLITE_OK, "%d-way merge from level %d", nMerge, (int)iAbsLevel);
125398 }
125399 #else
125400 #define fts3LogMerge(x, y)
125401 #endif
125402
125403
125404 typedef struct PendingList PendingList;
125405 typedef struct SegmentNode SegmentNode;
125406 typedef struct SegmentWriter SegmentWriter;
125407
@@ -125274,19 +125560,26 @@
125560 #define SQL_DELETE_SEGMENTS_RANGE 17
125561 #define SQL_CONTENT_INSERT 18
125562 #define SQL_DELETE_DOCSIZE 19
125563 #define SQL_REPLACE_DOCSIZE 20
125564 #define SQL_SELECT_DOCSIZE 21
125565 #define SQL_SELECT_STAT 22
125566 #define SQL_REPLACE_STAT 23
125567
125568 #define SQL_SELECT_ALL_PREFIX_LEVEL 24
125569 #define SQL_DELETE_ALL_TERMS_SEGDIR 25
 
125570 #define SQL_DELETE_SEGDIR_RANGE 26
 
125571 #define SQL_SELECT_ALL_LANGID 27
125572 #define SQL_FIND_MERGE_LEVEL 28
125573 #define SQL_MAX_LEAF_NODE_ESTIMATE 29
125574 #define SQL_DELETE_SEGDIR_ENTRY 30
125575 #define SQL_SHIFT_SEGDIR_ENTRY 31
125576 #define SQL_SELECT_SEGDIR 32
125577 #define SQL_CHOMP_SEGDIR 33
125578 #define SQL_SEGMENT_IS_APPENDABLE 34
125579 #define SQL_SELECT_INDEXES 35
125580 #define SQL_SELECT_MXLEVEL 36
125581
125582 /*
125583 ** This function is used to obtain an SQLite prepared statement handle
125584 ** for the statement identified by the second argument. If successful,
125585 ** *pp is set to the requested statement handle and SQLITE_OK returned.
@@ -125311,13 +125604,13 @@
125604 /* 4 */ "DELETE FROM %Q.'%q_segdir'",
125605 /* 5 */ "DELETE FROM %Q.'%q_docsize'",
125606 /* 6 */ "DELETE FROM %Q.'%q_stat'",
125607 /* 7 */ "SELECT %s WHERE rowid=?",
125608 /* 8 */ "SELECT (SELECT max(idx) FROM %Q.'%q_segdir' WHERE level = ?) + 1",
125609 /* 9 */ "REPLACE INTO %Q.'%q_segments'(blockid, block) VALUES(?, ?)",
125610 /* 10 */ "SELECT coalesce((SELECT max(blockid) FROM %Q.'%q_segments') + 1, 1)",
125611 /* 11 */ "REPLACE INTO %Q.'%q_segdir' VALUES(?,?,?,?,?,?)",
125612
125613 /* Return segments in order from oldest to newest.*/
125614 /* 12 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125615 "FROM %Q.'%q_segdir' WHERE level = ? ORDER BY idx ASC",
125616 /* 13 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
@@ -125331,18 +125624,65 @@
125624 /* 17 */ "DELETE FROM %Q.'%q_segments' WHERE blockid BETWEEN ? AND ?",
125625 /* 18 */ "INSERT INTO %Q.'%q_content' VALUES(%s)",
125626 /* 19 */ "DELETE FROM %Q.'%q_docsize' WHERE docid = ?",
125627 /* 20 */ "REPLACE INTO %Q.'%q_docsize' VALUES(?,?)",
125628 /* 21 */ "SELECT size FROM %Q.'%q_docsize' WHERE docid=?",
125629 /* 22 */ "SELECT value FROM %Q.'%q_stat' WHERE id=?",
125630 /* 23 */ "REPLACE INTO %Q.'%q_stat' VALUES(?,?)",
125631 /* 24 */ "",
125632 /* 25 */ "",
125633
125634 /* 26 */ "DELETE FROM %Q.'%q_segdir' WHERE level BETWEEN ? AND ?",
125635 /* 27 */ "SELECT DISTINCT level / (1024 * ?) FROM %Q.'%q_segdir'",
125636
125637 /* This statement is used to determine which level to read the input from
125638 ** when performing an incremental merge. It returns the absolute level number
125639 ** of the oldest level in the db that contains at least ? segments. Or,
125640 ** if no level in the FTS index contains more than ? segments, the statement
125641 ** returns zero rows. */
125642 /* 28 */ "SELECT level FROM %Q.'%q_segdir' GROUP BY level HAVING count(*)>=?"
125643 " ORDER BY (level %% 1024) ASC LIMIT 1",
125644
125645 /* Estimate the upper limit on the number of leaf nodes in a new segment
125646 ** created by merging the oldest :2 segments from absolute level :1. See
125647 ** function sqlite3Fts3Incrmerge() for details. */
125648 /* 29 */ "SELECT 2 * total(1 + leaves_end_block - start_block) "
125649 " FROM %Q.'%q_segdir' WHERE level = ? AND idx < ?",
125650
125651 /* SQL_DELETE_SEGDIR_ENTRY
125652 ** Delete the %_segdir entry on absolute level :1 with index :2. */
125653 /* 30 */ "DELETE FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125654
125655 /* SQL_SHIFT_SEGDIR_ENTRY
125656 ** Modify the idx value for the segment with idx=:3 on absolute level :2
125657 ** to :1. */
125658 /* 31 */ "UPDATE %Q.'%q_segdir' SET idx = ? WHERE level=? AND idx=?",
125659
125660 /* SQL_SELECT_SEGDIR
125661 ** Read a single entry from the %_segdir table. The entry from absolute
125662 ** level :1 with index value :2. */
125663 /* 32 */ "SELECT idx, start_block, leaves_end_block, end_block, root "
125664 "FROM %Q.'%q_segdir' WHERE level = ? AND idx = ?",
125665
125666 /* SQL_CHOMP_SEGDIR
125667 ** Update the start_block (:1) and root (:2) fields of the %_segdir
125668 ** entry located on absolute level :3 with index :4. */
125669 /* 33 */ "UPDATE %Q.'%q_segdir' SET start_block = ?, root = ?"
125670 "WHERE level = ? AND idx = ?",
125671
125672 /* SQL_SEGMENT_IS_APPENDABLE
125673 ** Return a single row if the segment with end_block=? is appendable. Or
125674 ** no rows otherwise. */
125675 /* 34 */ "SELECT 1 FROM %Q.'%q_segments' WHERE blockid=? AND block IS NULL",
125676
125677 /* SQL_SELECT_INDEXES
125678 ** Return the list of valid segment indexes for absolute level ? */
125679 /* 35 */ "SELECT idx FROM %Q.'%q_segdir' WHERE level=? ORDER BY 1 ASC",
125680
125681 /* SQL_SELECT_MXLEVEL
125682 ** Return the largest relative level in the FTS index or indexes. */
125683 /* 36 */ "SELECT max( level %% 1024 ) FROM %Q.'%q_segdir'"
125684 };
125685 int rc = SQLITE_OK;
125686 sqlite3_stmt *pStmt;
125687
125688 assert( SizeofArray(azSql)==SizeofArray(p->aStmt) );
@@ -125375,27 +125715,23 @@
125715 }
125716 }
125717 *pp = pStmt;
125718 return rc;
125719 }
125720
125721
125722 static int fts3SelectDocsize(
125723 Fts3Table *pTab, /* FTS3 table handle */
 
125724 sqlite3_int64 iDocid, /* Docid to bind for SQL_SELECT_DOCSIZE */
125725 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125726 ){
125727 sqlite3_stmt *pStmt = 0; /* Statement requested from fts3SqlStmt() */
125728 int rc; /* Return code */
125729
125730 rc = fts3SqlStmt(pTab, SQL_SELECT_DOCSIZE, &pStmt, 0);
 
 
125731 if( rc==SQLITE_OK ){
125732 sqlite3_bind_int64(pStmt, 1, iDocid);
 
 
125733 rc = sqlite3_step(pStmt);
125734 if( rc!=SQLITE_ROW || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB ){
125735 rc = sqlite3_reset(pStmt);
125736 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125737 pStmt = 0;
@@ -125410,19 +125746,33 @@
125746
125747 SQLITE_PRIVATE int sqlite3Fts3SelectDoctotal(
125748 Fts3Table *pTab, /* Fts3 table handle */
125749 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125750 ){
125751 sqlite3_stmt *pStmt = 0;
125752 int rc;
125753 rc = fts3SqlStmt(pTab, SQL_SELECT_STAT, &pStmt, 0);
125754 if( rc==SQLITE_OK ){
125755 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
125756 if( sqlite3_step(pStmt)!=SQLITE_ROW
125757 || sqlite3_column_type(pStmt, 0)!=SQLITE_BLOB
125758 ){
125759 rc = sqlite3_reset(pStmt);
125760 if( rc==SQLITE_OK ) rc = FTS_CORRUPT_VTAB;
125761 pStmt = 0;
125762 }
125763 }
125764 *ppStmt = pStmt;
125765 return rc;
125766 }
125767
125768 SQLITE_PRIVATE int sqlite3Fts3SelectDocsize(
125769 Fts3Table *pTab, /* Fts3 table handle */
125770 sqlite3_int64 iDocid, /* Docid to read size data for */
125771 sqlite3_stmt **ppStmt /* OUT: Statement handle */
125772 ){
125773 return fts3SelectDocsize(pTab, iDocid, ppStmt);
125774 }
125775
125776 /*
125777 ** Similar to fts3SqlStmt(). Except, after binding the parameters in
125778 ** array apVal[] to the SQL statement identified by eStmt, the statement
@@ -125484,22 +125834,47 @@
125834 }
125835
125836 return rc;
125837 }
125838
125839 /*
125840 ** FTS maintains a separate indexes for each language-id (a 32-bit integer).
125841 ** Within each language id, a separate index is maintained to store the
125842 ** document terms, and each configured prefix size (configured the FTS
125843 ** "prefix=" option). And each index consists of multiple levels ("relative
125844 ** levels").
125845 **
125846 ** All three of these values (the language id, the specific index and the
125847 ** level within the index) are encoded in 64-bit integer values stored
125848 ** in the %_segdir table on disk. This function is used to convert three
125849 ** separate component values into the single 64-bit integer value that
125850 ** can be used to query the %_segdir table.
125851 **
125852 ** Specifically, each language-id/index combination is allocated 1024
125853 ** 64-bit integer level values ("absolute levels"). The main terms index
125854 ** for language-id 0 is allocate values 0-1023. The first prefix index
125855 ** (if any) for language-id 0 is allocated values 1024-2047. And so on.
125856 ** Language 1 indexes are allocated immediately following language 0.
125857 **
125858 ** So, for a system with nPrefix prefix indexes configured, the block of
125859 ** absolute levels that corresponds to language-id iLangid and index
125860 ** iIndex starts at absolute level ((iLangid * (nPrefix+1) + iIndex) * 1024).
125861 */
125862 static sqlite3_int64 getAbsoluteLevel(
125863 Fts3Table *p, /* FTS3 table handle */
125864 int iLangid, /* Language id */
125865 int iIndex, /* Index in p->aIndex[] */
125866 int iLevel /* Level of segments */
125867 ){
125868 sqlite3_int64 iBase; /* First absolute level for iLangid/iIndex */
125869 assert( iLangid>=0 );
125870 assert( p->nIndex>0 );
125871 assert( iIndex>=0 && iIndex<p->nIndex );
125872
125873 iBase = ((sqlite3_int64)iLangid * p->nIndex + iIndex) * FTS3_SEGDIR_MAXLEVEL;
125874 return iBase + iLevel;
125875 }
 
125876
125877 /*
125878 ** Set *ppStmt to a statement handle that may be used to iterate through
125879 ** all rows in the %_segdir table, from oldest to newest. If successful,
125880 ** return SQLITE_OK. If an error occurs while preparing the statement,
@@ -125518,11 +125893,11 @@
125893 */
125894 SQLITE_PRIVATE int sqlite3Fts3AllSegdirs(
125895 Fts3Table *p, /* FTS3 table */
125896 int iLangid, /* Language being queried */
125897 int iIndex, /* Index for p->aIndex[] */
125898 int iLevel, /* Level to select (relative level) */
125899 sqlite3_stmt **ppStmt /* OUT: Compiled statement */
125900 ){
125901 int rc;
125902 sqlite3_stmt *pStmt = 0;
125903
@@ -125533,19 +125908,19 @@
125908 if( iLevel<0 ){
125909 /* "SELECT * FROM %_segdir WHERE level BETWEEN ? AND ? ORDER BY ..." */
125910 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL_RANGE, &pStmt, 0);
125911 if( rc==SQLITE_OK ){
125912 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
125913 sqlite3_bind_int64(pStmt, 2,
125914 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
125915 );
125916 }
125917 }else{
125918 /* "SELECT * FROM %_segdir WHERE level = ? ORDER BY ..." */
125919 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
125920 if( rc==SQLITE_OK ){
125921 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex,iLevel));
125922 }
125923 }
125924 *ppStmt = pStmt;
125925 return rc;
125926 }
@@ -126062,10 +126437,11 @@
126437 ** full, merge all segments in level iLevel into a single iLevel+1
126438 ** segment and allocate (newly freed) index 0 at level iLevel. Otherwise,
126439 ** if iNext is less than FTS3_MERGE_COUNT, allocate index iNext.
126440 */
126441 if( iNext>=FTS3_MERGE_COUNT ){
126442 fts3LogMerge(16, getAbsoluteLevel(p, iLangid, iIndex, iLevel));
126443 rc = fts3SegmentMerge(p, iLangid, iIndex, iLevel);
126444 *piIdx = 0;
126445 }else{
126446 *piIdx = iNext;
126447 }
@@ -126109,11 +126485,11 @@
126485 int *pnLoad /* OUT: Bytes actually loaded */
126486 ){
126487 int rc; /* Return code */
126488
126489 /* pnBlob must be non-NULL. paBlob may be NULL or non-NULL. */
126490 assert( pnBlob );
126491
126492 if( p->pSegments ){
126493 rc = sqlite3_blob_reopen(p->pSegments, iBlockid);
126494 }else{
126495 if( 0==p->zSegmentsTbl ){
@@ -126450,11 +126826,11 @@
126826 int nOvfl = 0;
126827 int ii;
126828 int rc = SQLITE_OK;
126829 int pgsz = p->nPgsz;
126830
126831 assert( p->bFts4 );
126832 assert( pgsz>0 );
126833
126834 for(ii=0; rc==SQLITE_OK && ii<pMsr->nSegment; ii++){
126835 Fts3SegReader *pReader = pMsr->apSegment[ii];
126836 if( !fts3SegReaderIsPending(pReader)
@@ -126807,17 +127183,38 @@
127183 sqlite3_step(pStmt);
127184 rc = sqlite3_reset(pStmt);
127185 }
127186 return rc;
127187 }
127188
127189 /*
127190 ** Find the largest relative level number in the table. If successful, set
127191 ** *pnMax to this value and return SQLITE_OK. Otherwise, if an error occurs,
127192 ** set *pnMax to zero and return an SQLite error code.
127193 */
127194 SQLITE_PRIVATE int sqlite3Fts3MaxLevel(Fts3Table *p, int *pnMax){
127195 int rc;
127196 int mxLevel = 0;
127197 sqlite3_stmt *pStmt = 0;
127198
127199 rc = fts3SqlStmt(p, SQL_SELECT_MXLEVEL, &pStmt, 0);
127200 if( rc==SQLITE_OK ){
127201 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127202 mxLevel = sqlite3_column_int(pStmt, 0);
127203 }
127204 rc = sqlite3_reset(pStmt);
127205 }
127206 *pnMax = mxLevel;
127207 return rc;
127208 }
127209
127210 /*
127211 ** Insert a record into the %_segdir table.
127212 */
127213 static int fts3WriteSegdir(
127214 Fts3Table *p, /* Virtual table handle */
127215 sqlite3_int64 iLevel, /* Value for "level" field (absolute level) */
127216 int iIdx, /* Value for "idx" field */
127217 sqlite3_int64 iStartBlock, /* Value for "start_block" field */
127218 sqlite3_int64 iLeafEndBlock, /* Value for "leaves_end_block" field */
127219 sqlite3_int64 iEndBlock, /* Value for "end_block" field */
127220 char *zRoot, /* Blob value for "root" field */
@@ -126824,11 +127221,11 @@
127221 int nRoot /* Number of bytes in buffer zRoot */
127222 ){
127223 sqlite3_stmt *pStmt;
127224 int rc = fts3SqlStmt(p, SQL_INSERT_SEGDIR, &pStmt, 0);
127225 if( rc==SQLITE_OK ){
127226 sqlite3_bind_int64(pStmt, 1, iLevel);
127227 sqlite3_bind_int(pStmt, 2, iIdx);
127228 sqlite3_bind_int64(pStmt, 3, iStartBlock);
127229 sqlite3_bind_int64(pStmt, 4, iLeafEndBlock);
127230 sqlite3_bind_int64(pStmt, 5, iEndBlock);
127231 sqlite3_bind_blob(pStmt, 6, zRoot, nRoot, SQLITE_STATIC);
@@ -127124,10 +127521,11 @@
127521 int rc;
127522
127523 /* The current leaf node is full. Write it out to the database. */
127524 rc = fts3WriteSegment(p, pWriter->iFree++, pWriter->aData, nData);
127525 if( rc!=SQLITE_OK ) return rc;
127526 p->nLeafAdd++;
127527
127528 /* Add the current term to the interior node tree. The term added to
127529 ** the interior tree must:
127530 **
127531 ** a) be greater than the largest term on the leaf node just written
@@ -127207,11 +127605,11 @@
127605 ** returned. Otherwise, an SQLite error code.
127606 */
127607 static int fts3SegWriterFlush(
127608 Fts3Table *p, /* Virtual table handle */
127609 SegmentWriter *pWriter, /* SegmentWriter to flush to the db */
127610 sqlite3_int64 iLevel, /* Value for 'level' column of %_segdir */
127611 int iIdx /* Value for 'idx' column of %_segdir */
127612 ){
127613 int rc; /* Return code */
127614 if( pWriter->pTree ){
127615 sqlite3_int64 iLast = 0; /* Largest block id written to database */
@@ -127232,10 +127630,11 @@
127630 }else{
127631 /* The entire tree fits on the root node. Write it to the segdir table. */
127632 rc = fts3WriteSegdir(
127633 p, iLevel, iIdx, 0, 0, 0, pWriter->aData, pWriter->nData);
127634 }
127635 p->nLeafAdd++;
127636 return rc;
127637 }
127638
127639 /*
127640 ** Release all memory held by the SegmentWriter object passed as the
@@ -127289,11 +127688,11 @@
127688 */
127689 static int fts3SegmentMaxLevel(
127690 Fts3Table *p,
127691 int iLangid,
127692 int iIndex,
127693 sqlite3_int64 *pnMax
127694 ){
127695 sqlite3_stmt *pStmt;
127696 int rc;
127697 assert( iIndex>=0 && iIndex<p->nIndex );
127698
@@ -127303,19 +127702,42 @@
127702 **
127703 ** (1024 is actually the value of macro FTS3_SEGDIR_PREFIXLEVEL_STR).
127704 */
127705 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR_MAX_LEVEL, &pStmt, 0);
127706 if( rc!=SQLITE_OK ) return rc;
127707 sqlite3_bind_int64(pStmt, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127708 sqlite3_bind_int64(pStmt, 2,
127709 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127710 );
127711 if( SQLITE_ROW==sqlite3_step(pStmt) ){
127712 *pnMax = sqlite3_column_int64(pStmt, 0);
127713 }
127714 return sqlite3_reset(pStmt);
127715 }
127716
127717 /*
127718 ** Delete all entries in the %_segments table associated with the segment
127719 ** opened with seg-reader pSeg. This function does not affect the contents
127720 ** of the %_segdir table.
127721 */
127722 static int fts3DeleteSegment(
127723 Fts3Table *p, /* FTS table handle */
127724 Fts3SegReader *pSeg /* Segment to delete */
127725 ){
127726 int rc = SQLITE_OK; /* Return code */
127727 if( pSeg->iStartBlock ){
127728 sqlite3_stmt *pDelete; /* SQL statement to delete rows */
127729 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDelete, 0);
127730 if( rc==SQLITE_OK ){
127731 sqlite3_bind_int64(pDelete, 1, pSeg->iStartBlock);
127732 sqlite3_bind_int64(pDelete, 2, pSeg->iEndBlock);
127733 sqlite3_step(pDelete);
127734 rc = sqlite3_reset(pDelete);
127735 }
127736 }
127737 return rc;
127738 }
127739
127740 /*
127741 ** This function is used after merging multiple segments into a single large
127742 ** segment to delete the old, now redundant, segment b-trees. Specifically,
127743 ** it:
@@ -127335,41 +127757,36 @@
127757 int iIndex, /* Index for p->aIndex */
127758 int iLevel, /* Level of %_segdir entries to delete */
127759 Fts3SegReader **apSegment, /* Array of SegReader objects */
127760 int nReader /* Size of array apSegment */
127761 ){
127762 int rc = SQLITE_OK; /* Return Code */
127763 int i; /* Iterator variable */
127764 sqlite3_stmt *pDelete = 0; /* SQL statement to delete rows */
127765
 
127766 for(i=0; rc==SQLITE_OK && i<nReader; i++){
127767 rc = fts3DeleteSegment(p, apSegment[i]);
 
 
 
 
 
 
127768 }
127769 if( rc!=SQLITE_OK ){
127770 return rc;
127771 }
127772
127773 assert( iLevel>=0 || iLevel==FTS3_SEGCURSOR_ALL );
127774 if( iLevel==FTS3_SEGCURSOR_ALL ){
127775 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_RANGE, &pDelete, 0);
127776 if( rc==SQLITE_OK ){
127777 sqlite3_bind_int64(pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, 0));
127778 sqlite3_bind_int64(pDelete, 2,
127779 getAbsoluteLevel(p, iLangid, iIndex, FTS3_SEGDIR_MAXLEVEL-1)
127780 );
127781 }
127782 }else{
127783 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_LEVEL, &pDelete, 0);
127784 if( rc==SQLITE_OK ){
127785 sqlite3_bind_int64(
127786 pDelete, 1, getAbsoluteLevel(p, iLangid, iIndex, iLevel)
127787 );
127788 }
127789 }
127790
127791 if( rc==SQLITE_OK ){
127792 sqlite3_step(pDelete);
@@ -127842,11 +128259,11 @@
128259 int iIndex, /* Index in p->aIndex[] to merge */
128260 int iLevel /* Level to merge */
128261 ){
128262 int rc; /* Return code */
128263 int iIdx = 0; /* Index of new segment */
128264 sqlite3_int64 iNewLevel = 0; /* Level/index to create new segment at */
128265 SegmentWriter *pWriter = 0; /* Used to write the new, merged, segment */
128266 Fts3SegFilter filter; /* Segment term filter condition */
128267 Fts3MultiSegReader csr; /* Cursor to iterate through level(s) */
128268 int bIgnoreEmpty = 0; /* True to ignore empty segments */
128269
@@ -127921,15 +128338,32 @@
128338 ** Flush the contents of pendingTerms to level 0 segments.
128339 */
128340 SQLITE_PRIVATE int sqlite3Fts3PendingTermsFlush(Fts3Table *p){
128341 int rc = SQLITE_OK;
128342 int i;
128343
128344 for(i=0; rc==SQLITE_OK && i<p->nIndex; i++){
128345 rc = fts3SegmentMerge(p, p->iPrevLangid, i, FTS3_SEGCURSOR_PENDING);
128346 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
128347 }
128348 sqlite3Fts3PendingTermsClear(p);
128349
128350 /* Determine the auto-incr-merge setting if unknown. If enabled,
128351 ** estimate the number of leaf blocks of content to be written
128352 */
128353 if( rc==SQLITE_OK && p->bHasStat
128354 && p->bAutoincrmerge==0xff && p->nLeafAdd>0
128355 ){
128356 sqlite3_stmt *pStmt = 0;
128357 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128358 if( rc==SQLITE_OK ){
128359 sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
128360 rc = sqlite3_step(pStmt);
128361 p->bAutoincrmerge = (rc==SQLITE_ROW && sqlite3_column_int(pStmt, 0));
128362 rc = sqlite3_reset(pStmt);
128363 }
128364 }
128365 return rc;
128366 }
128367
128368 /*
128369 ** Encode N integers as varints into a blob.
@@ -128036,16 +128470,17 @@
128470 if( a==0 ){
128471 *pRC = SQLITE_NOMEM;
128472 return;
128473 }
128474 pBlob = (char*)&a[nStat];
128475 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pStmt, 0);
128476 if( rc ){
128477 sqlite3_free(a);
128478 *pRC = rc;
128479 return;
128480 }
128481 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128482 if( sqlite3_step(pStmt)==SQLITE_ROW ){
128483 fts3DecodeIntArray(nStat, a,
128484 sqlite3_column_blob(pStmt, 0),
128485 sqlite3_column_bytes(pStmt, 0));
128486 }else{
@@ -128065,17 +128500,18 @@
128500 x = x + aSzIns[i] - aSzDel[i];
128501 }
128502 a[i+1] = x;
128503 }
128504 fts3EncodeIntArray(nStat, a, pBlob, &nBlob);
128505 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
128506 if( rc ){
128507 sqlite3_free(a);
128508 *pRC = rc;
128509 return;
128510 }
128511 sqlite3_bind_int(pStmt, 1, FTS_STAT_DOCTOTAL);
128512 sqlite3_bind_blob(pStmt, 2, pBlob, nBlob, SQLITE_STATIC);
128513 sqlite3_step(pStmt);
128514 *pRC = sqlite3_reset(pStmt);
128515 sqlite3_free(a);
128516 }
128517
@@ -128176,11 +128612,11 @@
128612 for(iCol=0; iCol<=p->nColumn; iCol++){
128613 aSzIns[iCol] += aSz[iCol];
128614 }
128615 }
128616 }
128617 if( p->bFts4 ){
128618 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nEntry);
128619 }
128620 sqlite3_free(aSz);
128621
128622 if( pStmt ){
@@ -128192,10 +128628,1692 @@
128628 }
128629
128630 return rc;
128631 }
128632
128633
128634 /*
128635 ** This function opens a cursor used to read the input data for an
128636 ** incremental merge operation. Specifically, it opens a cursor to scan
128637 ** the oldest nSeg segments (idx=0 through idx=(nSeg-1)) in absolute
128638 ** level iAbsLevel.
128639 */
128640 static int fts3IncrmergeCsr(
128641 Fts3Table *p, /* FTS3 table handle */
128642 sqlite3_int64 iAbsLevel, /* Absolute level to open */
128643 int nSeg, /* Number of segments to merge */
128644 Fts3MultiSegReader *pCsr /* Cursor object to populate */
128645 ){
128646 int rc; /* Return Code */
128647 sqlite3_stmt *pStmt = 0; /* Statement used to read %_segdir entry */
128648 int nByte; /* Bytes allocated at pCsr->apSegment[] */
128649
128650 /* Allocate space for the Fts3MultiSegReader.aCsr[] array */
128651 memset(pCsr, 0, sizeof(*pCsr));
128652 nByte = sizeof(Fts3SegReader *) * nSeg;
128653 pCsr->apSegment = (Fts3SegReader **)sqlite3_malloc(nByte);
128654
128655 if( pCsr->apSegment==0 ){
128656 rc = SQLITE_NOMEM;
128657 }else{
128658 memset(pCsr->apSegment, 0, nByte);
128659 rc = fts3SqlStmt(p, SQL_SELECT_LEVEL, &pStmt, 0);
128660 }
128661 if( rc==SQLITE_OK ){
128662 int i;
128663 int rc2;
128664 sqlite3_bind_int64(pStmt, 1, iAbsLevel);
128665 assert( pCsr->nSegment==0 );
128666 for(i=0; rc==SQLITE_OK && sqlite3_step(pStmt)==SQLITE_ROW && i<nSeg; i++){
128667 rc = sqlite3Fts3SegReaderNew(i, 0,
128668 sqlite3_column_int64(pStmt, 1), /* segdir.start_block */
128669 sqlite3_column_int64(pStmt, 2), /* segdir.leaves_end_block */
128670 sqlite3_column_int64(pStmt, 3), /* segdir.end_block */
128671 sqlite3_column_blob(pStmt, 4), /* segdir.root */
128672 sqlite3_column_bytes(pStmt, 4), /* segdir.root */
128673 &pCsr->apSegment[i]
128674 );
128675 pCsr->nSegment++;
128676 }
128677 rc2 = sqlite3_reset(pStmt);
128678 if( rc==SQLITE_OK ) rc = rc2;
128679 }
128680
128681 return rc;
128682 }
128683
128684 typedef struct IncrmergeWriter IncrmergeWriter;
128685 typedef struct NodeWriter NodeWriter;
128686 typedef struct Blob Blob;
128687 typedef struct NodeReader NodeReader;
128688
128689 /*
128690 ** An instance of the following structure is used as a dynamic buffer
128691 ** to build up nodes or other blobs of data in.
128692 **
128693 ** The function blobGrowBuffer() is used to extend the allocation.
128694 */
128695 struct Blob {
128696 char *a; /* Pointer to allocation */
128697 int n; /* Number of valid bytes of data in a[] */
128698 int nAlloc; /* Allocated size of a[] (nAlloc>=n) */
128699 };
128700
128701 /*
128702 ** This structure is used to build up buffers containing segment b-tree
128703 ** nodes (blocks).
128704 */
128705 struct NodeWriter {
128706 sqlite3_int64 iBlock; /* Current block id */
128707 Blob key; /* Last key written to the current block */
128708 Blob block; /* Current block image */
128709 };
128710
128711 /*
128712 ** An object of this type contains the state required to create or append
128713 ** to an appendable b-tree segment.
128714 */
128715 struct IncrmergeWriter {
128716 int nLeafEst; /* Space allocated for leaf blocks */
128717 int nWork; /* Number of leaf pages flushed */
128718 sqlite3_int64 iAbsLevel; /* Absolute level of input segments */
128719 int iIdx; /* Index of *output* segment in iAbsLevel+1 */
128720 sqlite3_int64 iStart; /* Block number of first allocated block */
128721 sqlite3_int64 iEnd; /* Block number of last allocated block */
128722 NodeWriter aNodeWriter[FTS_MAX_APPENDABLE_HEIGHT];
128723 };
128724
128725 /*
128726 ** An object of the following type is used to read data from a single
128727 ** FTS segment node. See the following functions:
128728 **
128729 ** nodeReaderInit()
128730 ** nodeReaderNext()
128731 ** nodeReaderRelease()
128732 */
128733 struct NodeReader {
128734 const char *aNode;
128735 int nNode;
128736 int iOff; /* Current offset within aNode[] */
128737
128738 /* Output variables. Containing the current node entry. */
128739 sqlite3_int64 iChild; /* Pointer to child node */
128740 Blob term; /* Current term */
128741 const char *aDoclist; /* Pointer to doclist */
128742 int nDoclist; /* Size of doclist in bytes */
128743 };
128744
128745 /*
128746 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
128747 ** Otherwise, if the allocation at pBlob->a is not already at least nMin
128748 ** bytes in size, extend (realloc) it to be so.
128749 **
128750 ** If an OOM error occurs, set *pRc to SQLITE_NOMEM and leave pBlob->a
128751 ** unmodified. Otherwise, if the allocation succeeds, update pBlob->nAlloc
128752 ** to reflect the new size of the pBlob->a[] buffer.
128753 */
128754 static void blobGrowBuffer(Blob *pBlob, int nMin, int *pRc){
128755 if( *pRc==SQLITE_OK && nMin>pBlob->nAlloc ){
128756 int nAlloc = nMin;
128757 char *a = (char *)sqlite3_realloc(pBlob->a, nAlloc);
128758 if( a ){
128759 pBlob->nAlloc = nAlloc;
128760 pBlob->a = a;
128761 }else{
128762 *pRc = SQLITE_NOMEM;
128763 }
128764 }
128765 }
128766
128767 /*
128768 ** Attempt to advance the node-reader object passed as the first argument to
128769 ** the next entry on the node.
128770 **
128771 ** Return an error code if an error occurs (SQLITE_NOMEM is possible).
128772 ** Otherwise return SQLITE_OK. If there is no next entry on the node
128773 ** (e.g. because the current entry is the last) set NodeReader->aNode to
128774 ** NULL to indicate EOF. Otherwise, populate the NodeReader structure output
128775 ** variables for the new entry.
128776 */
128777 static int nodeReaderNext(NodeReader *p){
128778 int bFirst = (p->term.n==0); /* True for first term on the node */
128779 int nPrefix = 0; /* Bytes to copy from previous term */
128780 int nSuffix = 0; /* Bytes to append to the prefix */
128781 int rc = SQLITE_OK; /* Return code */
128782
128783 assert( p->aNode );
128784 if( p->iChild && bFirst==0 ) p->iChild++;
128785 if( p->iOff>=p->nNode ){
128786 /* EOF */
128787 p->aNode = 0;
128788 }else{
128789 if( bFirst==0 ){
128790 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nPrefix);
128791 }
128792 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &nSuffix);
128793
128794 blobGrowBuffer(&p->term, nPrefix+nSuffix, &rc);
128795 if( rc==SQLITE_OK ){
128796 memcpy(&p->term.a[nPrefix], &p->aNode[p->iOff], nSuffix);
128797 p->term.n = nPrefix+nSuffix;
128798 p->iOff += nSuffix;
128799 if( p->iChild==0 ){
128800 p->iOff += sqlite3Fts3GetVarint32(&p->aNode[p->iOff], &p->nDoclist);
128801 p->aDoclist = &p->aNode[p->iOff];
128802 p->iOff += p->nDoclist;
128803 }
128804 }
128805 }
128806
128807 assert( p->iOff<=p->nNode );
128808
128809 return rc;
128810 }
128811
128812 /*
128813 ** Release all dynamic resources held by node-reader object *p.
128814 */
128815 static void nodeReaderRelease(NodeReader *p){
128816 sqlite3_free(p->term.a);
128817 }
128818
128819 /*
128820 ** Initialize a node-reader object to read the node in buffer aNode/nNode.
128821 **
128822 ** If successful, SQLITE_OK is returned and the NodeReader object set to
128823 ** point to the first entry on the node (if any). Otherwise, an SQLite
128824 ** error code is returned.
128825 */
128826 static int nodeReaderInit(NodeReader *p, const char *aNode, int nNode){
128827 memset(p, 0, sizeof(NodeReader));
128828 p->aNode = aNode;
128829 p->nNode = nNode;
128830
128831 /* Figure out if this is a leaf or an internal node. */
128832 if( p->aNode[0] ){
128833 /* An internal node. */
128834 p->iOff = 1 + sqlite3Fts3GetVarint(&p->aNode[1], &p->iChild);
128835 }else{
128836 p->iOff = 1;
128837 }
128838
128839 return nodeReaderNext(p);
128840 }
128841
128842 /*
128843 ** This function is called while writing an FTS segment each time a leaf o
128844 ** node is finished and written to disk. The key (zTerm/nTerm) is guaranteed
128845 ** to be greater than the largest key on the node just written, but smaller
128846 ** than or equal to the first key that will be written to the next leaf
128847 ** node.
128848 **
128849 ** The block id of the leaf node just written to disk may be found in
128850 ** (pWriter->aNodeWriter[0].iBlock) when this function is called.
128851 */
128852 static int fts3IncrmergePush(
128853 Fts3Table *p, /* Fts3 table handle */
128854 IncrmergeWriter *pWriter, /* Writer object */
128855 const char *zTerm, /* Term to write to internal node */
128856 int nTerm /* Bytes at zTerm */
128857 ){
128858 sqlite3_int64 iPtr = pWriter->aNodeWriter[0].iBlock;
128859 int iLayer;
128860
128861 assert( nTerm>0 );
128862 for(iLayer=1; ALWAYS(iLayer<FTS_MAX_APPENDABLE_HEIGHT); iLayer++){
128863 sqlite3_int64 iNextPtr = 0;
128864 NodeWriter *pNode = &pWriter->aNodeWriter[iLayer];
128865 int rc = SQLITE_OK;
128866 int nPrefix;
128867 int nSuffix;
128868 int nSpace;
128869
128870 /* Figure out how much space the key will consume if it is written to
128871 ** the current node of layer iLayer. Due to the prefix compression,
128872 ** the space required changes depending on which node the key is to
128873 ** be added to. */
128874 nPrefix = fts3PrefixCompress(pNode->key.a, pNode->key.n, zTerm, nTerm);
128875 nSuffix = nTerm - nPrefix;
128876 nSpace = sqlite3Fts3VarintLen(nPrefix);
128877 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
128878
128879 if( pNode->key.n==0 || (pNode->block.n + nSpace)<=p->nNodeSize ){
128880 /* If the current node of layer iLayer contains zero keys, or if adding
128881 ** the key to it will not cause it to grow to larger than nNodeSize
128882 ** bytes in size, write the key here. */
128883
128884 Blob *pBlk = &pNode->block;
128885 if( pBlk->n==0 ){
128886 blobGrowBuffer(pBlk, p->nNodeSize, &rc);
128887 if( rc==SQLITE_OK ){
128888 pBlk->a[0] = (char)iLayer;
128889 pBlk->n = 1 + sqlite3Fts3PutVarint(&pBlk->a[1], iPtr);
128890 }
128891 }
128892 blobGrowBuffer(pBlk, pBlk->n + nSpace, &rc);
128893 blobGrowBuffer(&pNode->key, nTerm, &rc);
128894
128895 if( rc==SQLITE_OK ){
128896 if( pNode->key.n ){
128897 pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nPrefix);
128898 }
128899 pBlk->n += sqlite3Fts3PutVarint(&pBlk->a[pBlk->n], nSuffix);
128900 memcpy(&pBlk->a[pBlk->n], &zTerm[nPrefix], nSuffix);
128901 pBlk->n += nSuffix;
128902
128903 memcpy(pNode->key.a, zTerm, nTerm);
128904 pNode->key.n = nTerm;
128905 }
128906 }else{
128907 /* Otherwise, flush the the current node of layer iLayer to disk.
128908 ** Then allocate a new, empty sibling node. The key will be written
128909 ** into the parent of this node. */
128910 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
128911
128912 assert( pNode->block.nAlloc>=p->nNodeSize );
128913 pNode->block.a[0] = (char)iLayer;
128914 pNode->block.n = 1 + sqlite3Fts3PutVarint(&pNode->block.a[1], iPtr+1);
128915
128916 iNextPtr = pNode->iBlock;
128917 pNode->iBlock++;
128918 pNode->key.n = 0;
128919 }
128920
128921 if( rc!=SQLITE_OK || iNextPtr==0 ) return rc;
128922 iPtr = iNextPtr;
128923 }
128924
128925 assert( 0 );
128926 return 0;
128927 }
128928
128929 /*
128930 ** Append a term and (optionally) doclist to the FTS segment node currently
128931 ** stored in blob *pNode. The node need not contain any terms, but the
128932 ** header must be written before this function is called.
128933 **
128934 ** A node header is a single 0x00 byte for a leaf node, or a height varint
128935 ** followed by the left-hand-child varint for an internal node.
128936 **
128937 ** The term to be appended is passed via arguments zTerm/nTerm. For a
128938 ** leaf node, the doclist is passed as aDoclist/nDoclist. For an internal
128939 ** node, both aDoclist and nDoclist must be passed 0.
128940 **
128941 ** If the size of the value in blob pPrev is zero, then this is the first
128942 ** term written to the node. Otherwise, pPrev contains a copy of the
128943 ** previous term. Before this function returns, it is updated to contain a
128944 ** copy of zTerm/nTerm.
128945 **
128946 ** It is assumed that the buffer associated with pNode is already large
128947 ** enough to accommodate the new entry. The buffer associated with pPrev
128948 ** is extended by this function if requrired.
128949 **
128950 ** If an error (i.e. OOM condition) occurs, an SQLite error code is
128951 ** returned. Otherwise, SQLITE_OK.
128952 */
128953 static int fts3AppendToNode(
128954 Blob *pNode, /* Current node image to append to */
128955 Blob *pPrev, /* Buffer containing previous term written */
128956 const char *zTerm, /* New term to write */
128957 int nTerm, /* Size of zTerm in bytes */
128958 const char *aDoclist, /* Doclist (or NULL) to write */
128959 int nDoclist /* Size of aDoclist in bytes */
128960 ){
128961 int rc = SQLITE_OK; /* Return code */
128962 int bFirst = (pPrev->n==0); /* True if this is the first term written */
128963 int nPrefix; /* Size of term prefix in bytes */
128964 int nSuffix; /* Size of term suffix in bytes */
128965
128966 /* Node must have already been started. There must be a doclist for a
128967 ** leaf node, and there must not be a doclist for an internal node. */
128968 assert( pNode->n>0 );
128969 assert( (pNode->a[0]=='\0')==(aDoclist!=0) );
128970
128971 blobGrowBuffer(pPrev, nTerm, &rc);
128972 if( rc!=SQLITE_OK ) return rc;
128973
128974 nPrefix = fts3PrefixCompress(pPrev->a, pPrev->n, zTerm, nTerm);
128975 nSuffix = nTerm - nPrefix;
128976 memcpy(pPrev->a, zTerm, nTerm);
128977 pPrev->n = nTerm;
128978
128979 if( bFirst==0 ){
128980 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nPrefix);
128981 }
128982 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nSuffix);
128983 memcpy(&pNode->a[pNode->n], &zTerm[nPrefix], nSuffix);
128984 pNode->n += nSuffix;
128985
128986 if( aDoclist ){
128987 pNode->n += sqlite3Fts3PutVarint(&pNode->a[pNode->n], nDoclist);
128988 memcpy(&pNode->a[pNode->n], aDoclist, nDoclist);
128989 pNode->n += nDoclist;
128990 }
128991
128992 assert( pNode->n<=pNode->nAlloc );
128993
128994 return SQLITE_OK;
128995 }
128996
128997 /*
128998 ** Append the current term and doclist pointed to by cursor pCsr to the
128999 ** appendable b-tree segment opened for writing by pWriter.
129000 **
129001 ** Return SQLITE_OK if successful, or an SQLite error code otherwise.
129002 */
129003 static int fts3IncrmergeAppend(
129004 Fts3Table *p, /* Fts3 table handle */
129005 IncrmergeWriter *pWriter, /* Writer object */
129006 Fts3MultiSegReader *pCsr /* Cursor containing term and doclist */
129007 ){
129008 const char *zTerm = pCsr->zTerm;
129009 int nTerm = pCsr->nTerm;
129010 const char *aDoclist = pCsr->aDoclist;
129011 int nDoclist = pCsr->nDoclist;
129012 int rc = SQLITE_OK; /* Return code */
129013 int nSpace; /* Total space in bytes required on leaf */
129014 int nPrefix; /* Size of prefix shared with previous term */
129015 int nSuffix; /* Size of suffix (nTerm - nPrefix) */
129016 NodeWriter *pLeaf; /* Object used to write leaf nodes */
129017
129018 pLeaf = &pWriter->aNodeWriter[0];
129019 nPrefix = fts3PrefixCompress(pLeaf->key.a, pLeaf->key.n, zTerm, nTerm);
129020 nSuffix = nTerm - nPrefix;
129021
129022 nSpace = sqlite3Fts3VarintLen(nPrefix);
129023 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129024 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129025
129026 /* If the current block is not empty, and if adding this term/doclist
129027 ** to the current block would make it larger than Fts3Table.nNodeSize
129028 ** bytes, write this block out to the database. */
129029 if( pLeaf->block.n>0 && (pLeaf->block.n + nSpace)>p->nNodeSize ){
129030 rc = fts3WriteSegment(p, pLeaf->iBlock, pLeaf->block.a, pLeaf->block.n);
129031 pWriter->nWork++;
129032
129033 /* Add the current term to the parent node. The term added to the
129034 ** parent must:
129035 **
129036 ** a) be greater than the largest term on the leaf node just written
129037 ** to the database (still available in pLeaf->key), and
129038 **
129039 ** b) be less than or equal to the term about to be added to the new
129040 ** leaf node (zTerm/nTerm).
129041 **
129042 ** In other words, it must be the prefix of zTerm 1 byte longer than
129043 ** the common prefix (if any) of zTerm and pWriter->zTerm.
129044 */
129045 if( rc==SQLITE_OK ){
129046 rc = fts3IncrmergePush(p, pWriter, zTerm, nPrefix+1);
129047 }
129048
129049 /* Advance to the next output block */
129050 pLeaf->iBlock++;
129051 pLeaf->key.n = 0;
129052 pLeaf->block.n = 0;
129053
129054 nPrefix = 0;
129055 nSuffix = nTerm;
129056 nSpace = 1;
129057 nSpace += sqlite3Fts3VarintLen(nSuffix) + nSuffix;
129058 nSpace += sqlite3Fts3VarintLen(nDoclist) + nDoclist;
129059 }
129060
129061 blobGrowBuffer(&pLeaf->block, pLeaf->block.n + nSpace, &rc);
129062
129063 if( rc==SQLITE_OK ){
129064 if( pLeaf->block.n==0 ){
129065 pLeaf->block.n = 1;
129066 pLeaf->block.a[0] = '\0';
129067 }
129068 rc = fts3AppendToNode(
129069 &pLeaf->block, &pLeaf->key, zTerm, nTerm, aDoclist, nDoclist
129070 );
129071 }
129072
129073 return rc;
129074 }
129075
129076 /*
129077 ** This function is called to release all dynamic resources held by the
129078 ** merge-writer object pWriter, and if no error has occurred, to flush
129079 ** all outstanding node buffers held by pWriter to disk.
129080 **
129081 ** If *pRc is not SQLITE_OK when this function is called, then no attempt
129082 ** is made to write any data to disk. Instead, this function serves only
129083 ** to release outstanding resources.
129084 **
129085 ** Otherwise, if *pRc is initially SQLITE_OK and an error occurs while
129086 ** flushing buffers to disk, *pRc is set to an SQLite error code before
129087 ** returning.
129088 */
129089 static void fts3IncrmergeRelease(
129090 Fts3Table *p, /* FTS3 table handle */
129091 IncrmergeWriter *pWriter, /* Merge-writer object */
129092 int *pRc /* IN/OUT: Error code */
129093 ){
129094 int i; /* Used to iterate through non-root layers */
129095 int iRoot; /* Index of root in pWriter->aNodeWriter */
129096 NodeWriter *pRoot; /* NodeWriter for root node */
129097 int rc = *pRc; /* Error code */
129098
129099 /* Set iRoot to the index in pWriter->aNodeWriter[] of the output segment
129100 ** root node. If the segment fits entirely on a single leaf node, iRoot
129101 ** will be set to 0. If the root node is the parent of the leaves, iRoot
129102 ** will be 1. And so on. */
129103 for(iRoot=FTS_MAX_APPENDABLE_HEIGHT-1; iRoot>=0; iRoot--){
129104 NodeWriter *pNode = &pWriter->aNodeWriter[iRoot];
129105 if( pNode->block.n>0 ) break;
129106 assert( *pRc || pNode->block.nAlloc==0 );
129107 assert( *pRc || pNode->key.nAlloc==0 );
129108 sqlite3_free(pNode->block.a);
129109 sqlite3_free(pNode->key.a);
129110 }
129111
129112 /* Empty output segment. This is a no-op. */
129113 if( iRoot<0 ) return;
129114
129115 /* The entire output segment fits on a single node. Normally, this means
129116 ** the node would be stored as a blob in the "root" column of the %_segdir
129117 ** table. However, this is not permitted in this case. The problem is that
129118 ** space has already been reserved in the %_segments table, and so the
129119 ** start_block and end_block fields of the %_segdir table must be populated.
129120 ** And, by design or by accident, released versions of FTS cannot handle
129121 ** segments that fit entirely on the root node with start_block!=0.
129122 **
129123 ** Instead, create a synthetic root node that contains nothing but a
129124 ** pointer to the single content node. So that the segment consists of a
129125 ** single leaf and a single interior (root) node.
129126 **
129127 ** Todo: Better might be to defer allocating space in the %_segments
129128 ** table until we are sure it is needed.
129129 */
129130 if( iRoot==0 ){
129131 Blob *pBlock = &pWriter->aNodeWriter[1].block;
129132 blobGrowBuffer(pBlock, 1 + FTS3_VARINT_MAX, &rc);
129133 if( rc==SQLITE_OK ){
129134 pBlock->a[0] = 0x01;
129135 pBlock->n = 1 + sqlite3Fts3PutVarint(
129136 &pBlock->a[1], pWriter->aNodeWriter[0].iBlock
129137 );
129138 }
129139 iRoot = 1;
129140 }
129141 pRoot = &pWriter->aNodeWriter[iRoot];
129142
129143 /* Flush all currently outstanding nodes to disk. */
129144 for(i=0; i<iRoot; i++){
129145 NodeWriter *pNode = &pWriter->aNodeWriter[i];
129146 if( pNode->block.n>0 && rc==SQLITE_OK ){
129147 rc = fts3WriteSegment(p, pNode->iBlock, pNode->block.a, pNode->block.n);
129148 }
129149 sqlite3_free(pNode->block.a);
129150 sqlite3_free(pNode->key.a);
129151 }
129152
129153 /* Write the %_segdir record. */
129154 if( rc==SQLITE_OK ){
129155 rc = fts3WriteSegdir(p,
129156 pWriter->iAbsLevel+1, /* level */
129157 pWriter->iIdx, /* idx */
129158 pWriter->iStart, /* start_block */
129159 pWriter->aNodeWriter[0].iBlock, /* leaves_end_block */
129160 pWriter->iEnd, /* end_block */
129161 pRoot->block.a, pRoot->block.n /* root */
129162 );
129163 }
129164 sqlite3_free(pRoot->block.a);
129165 sqlite3_free(pRoot->key.a);
129166
129167 *pRc = rc;
129168 }
129169
129170 /*
129171 ** Compare the term in buffer zLhs (size in bytes nLhs) with that in
129172 ** zRhs (size in bytes nRhs) using memcmp. If one term is a prefix of
129173 ** the other, it is considered to be smaller than the other.
129174 **
129175 ** Return -ve if zLhs is smaller than zRhs, 0 if it is equal, or +ve
129176 ** if it is greater.
129177 */
129178 static int fts3TermCmp(
129179 const char *zLhs, int nLhs, /* LHS of comparison */
129180 const char *zRhs, int nRhs /* RHS of comparison */
129181 ){
129182 int nCmp = MIN(nLhs, nRhs);
129183 int res;
129184
129185 res = memcmp(zLhs, zRhs, nCmp);
129186 if( res==0 ) res = nLhs - nRhs;
129187
129188 return res;
129189 }
129190
129191
129192 /*
129193 ** Query to see if the entry in the %_segments table with blockid iEnd is
129194 ** NULL. If no error occurs and the entry is NULL, set *pbRes 1 before
129195 ** returning. Otherwise, set *pbRes to 0.
129196 **
129197 ** Or, if an error occurs while querying the database, return an SQLite
129198 ** error code. The final value of *pbRes is undefined in this case.
129199 **
129200 ** This is used to test if a segment is an "appendable" segment. If it
129201 ** is, then a NULL entry has been inserted into the %_segments table
129202 ** with blockid %_segdir.end_block.
129203 */
129204 static int fts3IsAppendable(Fts3Table *p, sqlite3_int64 iEnd, int *pbRes){
129205 int bRes = 0; /* Result to set *pbRes to */
129206 sqlite3_stmt *pCheck = 0; /* Statement to query database with */
129207 int rc; /* Return code */
129208
129209 rc = fts3SqlStmt(p, SQL_SEGMENT_IS_APPENDABLE, &pCheck, 0);
129210 if( rc==SQLITE_OK ){
129211 sqlite3_bind_int64(pCheck, 1, iEnd);
129212 if( SQLITE_ROW==sqlite3_step(pCheck) ) bRes = 1;
129213 rc = sqlite3_reset(pCheck);
129214 }
129215
129216 *pbRes = bRes;
129217 return rc;
129218 }
129219
129220 /*
129221 ** This function is called when initializing an incremental-merge operation.
129222 ** It checks if the existing segment with index value iIdx at absolute level
129223 ** (iAbsLevel+1) can be appended to by the incremental merge. If it can, the
129224 ** merge-writer object *pWriter is initialized to write to it.
129225 **
129226 ** An existing segment can be appended to by an incremental merge if:
129227 **
129228 ** * It was initially created as an appendable segment (with all required
129229 ** space pre-allocated), and
129230 **
129231 ** * The first key read from the input (arguments zKey and nKey) is
129232 ** greater than the largest key currently stored in the potential
129233 ** output segment.
129234 */
129235 static int fts3IncrmergeLoad(
129236 Fts3Table *p, /* Fts3 table handle */
129237 sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129238 int iIdx, /* Index of candidate output segment */
129239 const char *zKey, /* First key to write */
129240 int nKey, /* Number of bytes in nKey */
129241 IncrmergeWriter *pWriter /* Populate this object */
129242 ){
129243 int rc; /* Return code */
129244 sqlite3_stmt *pSelect = 0; /* SELECT to read %_segdir entry */
129245
129246 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pSelect, 0);
129247 if( rc==SQLITE_OK ){
129248 sqlite3_int64 iStart = 0; /* Value of %_segdir.start_block */
129249 sqlite3_int64 iLeafEnd = 0; /* Value of %_segdir.leaves_end_block */
129250 sqlite3_int64 iEnd = 0; /* Value of %_segdir.end_block */
129251 const char *aRoot = 0; /* Pointer to %_segdir.root buffer */
129252 int nRoot = 0; /* Size of aRoot[] in bytes */
129253 int rc2; /* Return code from sqlite3_reset() */
129254 int bAppendable = 0; /* Set to true if segment is appendable */
129255
129256 /* Read the %_segdir entry for index iIdx absolute level (iAbsLevel+1) */
129257 sqlite3_bind_int64(pSelect, 1, iAbsLevel+1);
129258 sqlite3_bind_int(pSelect, 2, iIdx);
129259 if( sqlite3_step(pSelect)==SQLITE_ROW ){
129260 iStart = sqlite3_column_int64(pSelect, 1);
129261 iLeafEnd = sqlite3_column_int64(pSelect, 2);
129262 iEnd = sqlite3_column_int64(pSelect, 3);
129263 nRoot = sqlite3_column_bytes(pSelect, 4);
129264 aRoot = sqlite3_column_blob(pSelect, 4);
129265 }else{
129266 return sqlite3_reset(pSelect);
129267 }
129268
129269 /* Check for the zero-length marker in the %_segments table */
129270 rc = fts3IsAppendable(p, iEnd, &bAppendable);
129271
129272 /* Check that zKey/nKey is larger than the largest key the candidate */
129273 if( rc==SQLITE_OK && bAppendable ){
129274 char *aLeaf = 0;
129275 int nLeaf = 0;
129276
129277 rc = sqlite3Fts3ReadBlock(p, iLeafEnd, &aLeaf, &nLeaf, 0);
129278 if( rc==SQLITE_OK ){
129279 NodeReader reader;
129280 for(rc = nodeReaderInit(&reader, aLeaf, nLeaf);
129281 rc==SQLITE_OK && reader.aNode;
129282 rc = nodeReaderNext(&reader)
129283 ){
129284 assert( reader.aNode );
129285 }
129286 if( fts3TermCmp(zKey, nKey, reader.term.a, reader.term.n)<=0 ){
129287 bAppendable = 0;
129288 }
129289 nodeReaderRelease(&reader);
129290 }
129291 sqlite3_free(aLeaf);
129292 }
129293
129294 if( rc==SQLITE_OK && bAppendable ){
129295 /* It is possible to append to this segment. Set up the IncrmergeWriter
129296 ** object to do so. */
129297 int i;
129298 int nHeight = (int)aRoot[0];
129299 NodeWriter *pNode;
129300
129301 pWriter->nLeafEst = (int)((iEnd - iStart) + 1)/FTS_MAX_APPENDABLE_HEIGHT;
129302 pWriter->iStart = iStart;
129303 pWriter->iEnd = iEnd;
129304 pWriter->iAbsLevel = iAbsLevel;
129305 pWriter->iIdx = iIdx;
129306
129307 for(i=nHeight+1; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129308 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129309 }
129310
129311 pNode = &pWriter->aNodeWriter[nHeight];
129312 pNode->iBlock = pWriter->iStart + pWriter->nLeafEst*nHeight;
129313 blobGrowBuffer(&pNode->block, MAX(nRoot, p->nNodeSize), &rc);
129314 if( rc==SQLITE_OK ){
129315 memcpy(pNode->block.a, aRoot, nRoot);
129316 pNode->block.n = nRoot;
129317 }
129318
129319 for(i=nHeight; i>=0 && rc==SQLITE_OK; i--){
129320 NodeReader reader;
129321 pNode = &pWriter->aNodeWriter[i];
129322
129323 rc = nodeReaderInit(&reader, pNode->block.a, pNode->block.n);
129324 while( reader.aNode && rc==SQLITE_OK ) rc = nodeReaderNext(&reader);
129325 blobGrowBuffer(&pNode->key, reader.term.n, &rc);
129326 if( rc==SQLITE_OK ){
129327 memcpy(pNode->key.a, reader.term.a, reader.term.n);
129328 pNode->key.n = reader.term.n;
129329 if( i>0 ){
129330 char *aBlock = 0;
129331 int nBlock = 0;
129332 pNode = &pWriter->aNodeWriter[i-1];
129333 pNode->iBlock = reader.iChild;
129334 rc = sqlite3Fts3ReadBlock(p, reader.iChild, &aBlock, &nBlock, 0);
129335 blobGrowBuffer(&pNode->block, MAX(nBlock, p->nNodeSize), &rc);
129336 if( rc==SQLITE_OK ){
129337 memcpy(pNode->block.a, aBlock, nBlock);
129338 pNode->block.n = nBlock;
129339 }
129340 sqlite3_free(aBlock);
129341 }
129342 }
129343 nodeReaderRelease(&reader);
129344 }
129345 }
129346
129347 rc2 = sqlite3_reset(pSelect);
129348 if( rc==SQLITE_OK ) rc = rc2;
129349 }
129350
129351 return rc;
129352 }
129353
129354 /*
129355 ** Determine the largest segment index value that exists within absolute
129356 ** level iAbsLevel+1. If no error occurs, set *piIdx to this value plus
129357 ** one before returning SQLITE_OK. Or, if there are no segments at all
129358 ** within level iAbsLevel, set *piIdx to zero.
129359 **
129360 ** If an error occurs, return an SQLite error code. The final value of
129361 ** *piIdx is undefined in this case.
129362 */
129363 static int fts3IncrmergeOutputIdx(
129364 Fts3Table *p, /* FTS Table handle */
129365 sqlite3_int64 iAbsLevel, /* Absolute index of input segments */
129366 int *piIdx /* OUT: Next free index at iAbsLevel+1 */
129367 ){
129368 int rc;
129369 sqlite3_stmt *pOutputIdx = 0; /* SQL used to find output index */
129370
129371 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENT_INDEX, &pOutputIdx, 0);
129372 if( rc==SQLITE_OK ){
129373 sqlite3_bind_int64(pOutputIdx, 1, iAbsLevel+1);
129374 sqlite3_step(pOutputIdx);
129375 *piIdx = sqlite3_column_int(pOutputIdx, 0);
129376 rc = sqlite3_reset(pOutputIdx);
129377 }
129378
129379 return rc;
129380 }
129381
129382 /*
129383 ** Allocate an appendable output segment on absolute level iAbsLevel+1
129384 ** with idx value iIdx.
129385 **
129386 ** In the %_segdir table, a segment is defined by the values in three
129387 ** columns:
129388 **
129389 ** start_block
129390 ** leaves_end_block
129391 ** end_block
129392 **
129393 ** When an appendable segment is allocated, it is estimated that the
129394 ** maximum number of leaf blocks that may be required is the sum of the
129395 ** number of leaf blocks consumed by the input segments, plus the number
129396 ** of input segments, multiplied by two. This value is stored in stack
129397 ** variable nLeafEst.
129398 **
129399 ** A total of 16*nLeafEst blocks are allocated when an appendable segment
129400 ** is created ((1 + end_block - start_block)==16*nLeafEst). The contiguous
129401 ** array of leaf nodes starts at the first block allocated. The array
129402 ** of interior nodes that are parents of the leaf nodes start at block
129403 ** (start_block + (1 + end_block - start_block) / 16). And so on.
129404 **
129405 ** In the actual code below, the value "16" is replaced with the
129406 ** pre-processor macro FTS_MAX_APPENDABLE_HEIGHT.
129407 */
129408 static int fts3IncrmergeWriter(
129409 Fts3Table *p, /* Fts3 table handle */
129410 sqlite3_int64 iAbsLevel, /* Absolute level of input segments */
129411 int iIdx, /* Index of new output segment */
129412 Fts3MultiSegReader *pCsr, /* Cursor that data will be read from */
129413 IncrmergeWriter *pWriter /* Populate this object */
129414 ){
129415 int rc; /* Return Code */
129416 int i; /* Iterator variable */
129417 int nLeafEst = 0; /* Blocks allocated for leaf nodes */
129418 sqlite3_stmt *pLeafEst = 0; /* SQL used to determine nLeafEst */
129419 sqlite3_stmt *pFirstBlock = 0; /* SQL used to determine first block */
129420
129421 /* Calculate nLeafEst. */
129422 rc = fts3SqlStmt(p, SQL_MAX_LEAF_NODE_ESTIMATE, &pLeafEst, 0);
129423 if( rc==SQLITE_OK ){
129424 sqlite3_bind_int64(pLeafEst, 1, iAbsLevel);
129425 sqlite3_bind_int64(pLeafEst, 2, pCsr->nSegment);
129426 if( SQLITE_ROW==sqlite3_step(pLeafEst) ){
129427 nLeafEst = sqlite3_column_int(pLeafEst, 0);
129428 }
129429 rc = sqlite3_reset(pLeafEst);
129430 }
129431 if( rc!=SQLITE_OK ) return rc;
129432
129433 /* Calculate the first block to use in the output segment */
129434 rc = fts3SqlStmt(p, SQL_NEXT_SEGMENTS_ID, &pFirstBlock, 0);
129435 if( rc==SQLITE_OK ){
129436 if( SQLITE_ROW==sqlite3_step(pFirstBlock) ){
129437 pWriter->iStart = sqlite3_column_int64(pFirstBlock, 0);
129438 pWriter->iEnd = pWriter->iStart - 1;
129439 pWriter->iEnd += nLeafEst * FTS_MAX_APPENDABLE_HEIGHT;
129440 }
129441 rc = sqlite3_reset(pFirstBlock);
129442 }
129443 if( rc!=SQLITE_OK ) return rc;
129444
129445 /* Insert the marker in the %_segments table to make sure nobody tries
129446 ** to steal the space just allocated. This is also used to identify
129447 ** appendable segments. */
129448 rc = fts3WriteSegment(p, pWriter->iEnd, 0, 0);
129449 if( rc!=SQLITE_OK ) return rc;
129450
129451 pWriter->iAbsLevel = iAbsLevel;
129452 pWriter->nLeafEst = nLeafEst;
129453 pWriter->iIdx = iIdx;
129454
129455 /* Set up the array of NodeWriter objects */
129456 for(i=0; i<FTS_MAX_APPENDABLE_HEIGHT; i++){
129457 pWriter->aNodeWriter[i].iBlock = pWriter->iStart + i*pWriter->nLeafEst;
129458 }
129459 return SQLITE_OK;
129460 }
129461
129462 /*
129463 ** Remove an entry from the %_segdir table. This involves running the
129464 ** following two statements:
129465 **
129466 ** DELETE FROM %_segdir WHERE level = :iAbsLevel AND idx = :iIdx
129467 ** UPDATE %_segdir SET idx = idx - 1 WHERE level = :iAbsLevel AND idx > :iIdx
129468 **
129469 ** The DELETE statement removes the specific %_segdir level. The UPDATE
129470 ** statement ensures that the remaining segments have contiguously allocated
129471 ** idx values.
129472 */
129473 static int fts3RemoveSegdirEntry(
129474 Fts3Table *p, /* FTS3 table handle */
129475 sqlite3_int64 iAbsLevel, /* Absolute level to delete from */
129476 int iIdx /* Index of %_segdir entry to delete */
129477 ){
129478 int rc; /* Return code */
129479 sqlite3_stmt *pDelete = 0; /* DELETE statement */
129480
129481 rc = fts3SqlStmt(p, SQL_DELETE_SEGDIR_ENTRY, &pDelete, 0);
129482 if( rc==SQLITE_OK ){
129483 sqlite3_bind_int64(pDelete, 1, iAbsLevel);
129484 sqlite3_bind_int(pDelete, 2, iIdx);
129485 sqlite3_step(pDelete);
129486 rc = sqlite3_reset(pDelete);
129487 }
129488
129489 return rc;
129490 }
129491
129492 /*
129493 ** One or more segments have just been removed from absolute level iAbsLevel.
129494 ** Update the 'idx' values of the remaining segments in the level so that
129495 ** the idx values are a contiguous sequence starting from 0.
129496 */
129497 static int fts3RepackSegdirLevel(
129498 Fts3Table *p, /* FTS3 table handle */
129499 sqlite3_int64 iAbsLevel /* Absolute level to repack */
129500 ){
129501 int rc; /* Return code */
129502 int *aIdx = 0; /* Array of remaining idx values */
129503 int nIdx = 0; /* Valid entries in aIdx[] */
129504 int nAlloc = 0; /* Allocated size of aIdx[] */
129505 int i; /* Iterator variable */
129506 sqlite3_stmt *pSelect = 0; /* Select statement to read idx values */
129507 sqlite3_stmt *pUpdate = 0; /* Update statement to modify idx values */
129508
129509 rc = fts3SqlStmt(p, SQL_SELECT_INDEXES, &pSelect, 0);
129510 if( rc==SQLITE_OK ){
129511 int rc2;
129512 sqlite3_bind_int64(pSelect, 1, iAbsLevel);
129513 while( SQLITE_ROW==sqlite3_step(pSelect) ){
129514 if( nIdx>=nAlloc ){
129515 int *aNew;
129516 nAlloc += 16;
129517 aNew = sqlite3_realloc(aIdx, nAlloc*sizeof(int));
129518 if( !aNew ){
129519 rc = SQLITE_NOMEM;
129520 break;
129521 }
129522 aIdx = aNew;
129523 }
129524 aIdx[nIdx++] = sqlite3_column_int(pSelect, 0);
129525 }
129526 rc2 = sqlite3_reset(pSelect);
129527 if( rc==SQLITE_OK ) rc = rc2;
129528 }
129529
129530 if( rc==SQLITE_OK ){
129531 rc = fts3SqlStmt(p, SQL_SHIFT_SEGDIR_ENTRY, &pUpdate, 0);
129532 }
129533 if( rc==SQLITE_OK ){
129534 sqlite3_bind_int64(pUpdate, 2, iAbsLevel);
129535 }
129536
129537 assert( p->bIgnoreSavepoint==0 );
129538 p->bIgnoreSavepoint = 1;
129539 for(i=0; rc==SQLITE_OK && i<nIdx; i++){
129540 if( aIdx[i]!=i ){
129541 sqlite3_bind_int(pUpdate, 3, aIdx[i]);
129542 sqlite3_bind_int(pUpdate, 1, i);
129543 sqlite3_step(pUpdate);
129544 rc = sqlite3_reset(pUpdate);
129545 }
129546 }
129547 p->bIgnoreSavepoint = 0;
129548
129549 sqlite3_free(aIdx);
129550 return rc;
129551 }
129552
129553 static void fts3StartNode(Blob *pNode, int iHeight, sqlite3_int64 iChild){
129554 pNode->a[0] = (char)iHeight;
129555 if( iChild ){
129556 assert( pNode->nAlloc>=1+sqlite3Fts3VarintLen(iChild) );
129557 pNode->n = 1 + sqlite3Fts3PutVarint(&pNode->a[1], iChild);
129558 }else{
129559 assert( pNode->nAlloc>=1 );
129560 pNode->n = 1;
129561 }
129562 }
129563
129564 /*
129565 ** The first two arguments are a pointer to and the size of a segment b-tree
129566 ** node. The node may be a leaf or an internal node.
129567 **
129568 ** This function creates a new node image in blob object *pNew by copying
129569 ** all terms that are greater than or equal to zTerm/nTerm (for leaf nodes)
129570 ** or greater than zTerm/nTerm (for internal nodes) from aNode/nNode.
129571 */
129572 static int fts3TruncateNode(
129573 const char *aNode, /* Current node image */
129574 int nNode, /* Size of aNode in bytes */
129575 Blob *pNew, /* OUT: Write new node image here */
129576 const char *zTerm, /* Omit all terms smaller than this */
129577 int nTerm, /* Size of zTerm in bytes */
129578 sqlite3_int64 *piBlock /* OUT: Block number in next layer down */
129579 ){
129580 NodeReader reader; /* Reader object */
129581 Blob prev = {0, 0, 0}; /* Previous term written to new node */
129582 int rc = SQLITE_OK; /* Return code */
129583 int bLeaf = aNode[0]=='\0'; /* True for a leaf node */
129584
129585 /* Allocate required output space */
129586 blobGrowBuffer(pNew, nNode, &rc);
129587 if( rc!=SQLITE_OK ) return rc;
129588 pNew->n = 0;
129589
129590 /* Populate new node buffer */
129591 for(rc = nodeReaderInit(&reader, aNode, nNode);
129592 rc==SQLITE_OK && reader.aNode;
129593 rc = nodeReaderNext(&reader)
129594 ){
129595 if( pNew->n==0 ){
129596 int res = fts3TermCmp(reader.term.a, reader.term.n, zTerm, nTerm);
129597 if( res<0 || (bLeaf==0 && res==0) ) continue;
129598 fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129599 *piBlock = reader.iChild;
129600 }
129601 rc = fts3AppendToNode(
129602 pNew, &prev, reader.term.a, reader.term.n,
129603 reader.aDoclist, reader.nDoclist
129604 );
129605 if( rc!=SQLITE_OK ) break;
129606 }
129607 if( pNew->n==0 ){
129608 fts3StartNode(pNew, (int)aNode[0], reader.iChild);
129609 *piBlock = reader.iChild;
129610 }
129611 assert( pNew->n<=pNew->nAlloc );
129612
129613 nodeReaderRelease(&reader);
129614 sqlite3_free(prev.a);
129615 return rc;
129616 }
129617
129618 /*
129619 ** Remove all terms smaller than zTerm/nTerm from segment iIdx in absolute
129620 ** level iAbsLevel. This may involve deleting entries from the %_segments
129621 ** table, and modifying existing entries in both the %_segments and %_segdir
129622 ** tables.
129623 **
129624 ** SQLITE_OK is returned if the segment is updated successfully. Or an
129625 ** SQLite error code otherwise.
129626 */
129627 static int fts3TruncateSegment(
129628 Fts3Table *p, /* FTS3 table handle */
129629 sqlite3_int64 iAbsLevel, /* Absolute level of segment to modify */
129630 int iIdx, /* Index within level of segment to modify */
129631 const char *zTerm, /* Remove terms smaller than this */
129632 int nTerm /* Number of bytes in buffer zTerm */
129633 ){
129634 int rc = SQLITE_OK; /* Return code */
129635 Blob root = {0,0,0}; /* New root page image */
129636 Blob block = {0,0,0}; /* Buffer used for any other block */
129637 sqlite3_int64 iBlock = 0; /* Block id */
129638 sqlite3_int64 iNewStart = 0; /* New value for iStartBlock */
129639 sqlite3_int64 iOldStart = 0; /* Old value for iStartBlock */
129640 sqlite3_stmt *pFetch = 0; /* Statement used to fetch segdir */
129641
129642 rc = fts3SqlStmt(p, SQL_SELECT_SEGDIR, &pFetch, 0);
129643 if( rc==SQLITE_OK ){
129644 int rc2; /* sqlite3_reset() return code */
129645 sqlite3_bind_int64(pFetch, 1, iAbsLevel);
129646 sqlite3_bind_int(pFetch, 2, iIdx);
129647 if( SQLITE_ROW==sqlite3_step(pFetch) ){
129648 const char *aRoot = sqlite3_column_blob(pFetch, 4);
129649 int nRoot = sqlite3_column_bytes(pFetch, 4);
129650 iOldStart = sqlite3_column_int64(pFetch, 1);
129651 rc = fts3TruncateNode(aRoot, nRoot, &root, zTerm, nTerm, &iBlock);
129652 }
129653 rc2 = sqlite3_reset(pFetch);
129654 if( rc==SQLITE_OK ) rc = rc2;
129655 }
129656
129657 while( rc==SQLITE_OK && iBlock ){
129658 char *aBlock = 0;
129659 int nBlock = 0;
129660 iNewStart = iBlock;
129661
129662 rc = sqlite3Fts3ReadBlock(p, iBlock, &aBlock, &nBlock, 0);
129663 if( rc==SQLITE_OK ){
129664 rc = fts3TruncateNode(aBlock, nBlock, &block, zTerm, nTerm, &iBlock);
129665 }
129666 if( rc==SQLITE_OK ){
129667 rc = fts3WriteSegment(p, iNewStart, block.a, block.n);
129668 }
129669 sqlite3_free(aBlock);
129670 }
129671
129672 /* Variable iNewStart now contains the first valid leaf node. */
129673 if( rc==SQLITE_OK && iNewStart ){
129674 sqlite3_stmt *pDel = 0;
129675 rc = fts3SqlStmt(p, SQL_DELETE_SEGMENTS_RANGE, &pDel, 0);
129676 if( rc==SQLITE_OK ){
129677 sqlite3_bind_int64(pDel, 1, iOldStart);
129678 sqlite3_bind_int64(pDel, 2, iNewStart-1);
129679 sqlite3_step(pDel);
129680 rc = sqlite3_reset(pDel);
129681 }
129682 }
129683
129684 if( rc==SQLITE_OK ){
129685 sqlite3_stmt *pChomp = 0;
129686 rc = fts3SqlStmt(p, SQL_CHOMP_SEGDIR, &pChomp, 0);
129687 if( rc==SQLITE_OK ){
129688 sqlite3_bind_int64(pChomp, 1, iNewStart);
129689 sqlite3_bind_blob(pChomp, 2, root.a, root.n, SQLITE_STATIC);
129690 sqlite3_bind_int64(pChomp, 3, iAbsLevel);
129691 sqlite3_bind_int(pChomp, 4, iIdx);
129692 sqlite3_step(pChomp);
129693 rc = sqlite3_reset(pChomp);
129694 }
129695 }
129696
129697 sqlite3_free(root.a);
129698 sqlite3_free(block.a);
129699 return rc;
129700 }
129701
129702 /*
129703 ** This function is called after an incrmental-merge operation has run to
129704 ** merge (or partially merge) two or more segments from absolute level
129705 ** iAbsLevel.
129706 **
129707 ** Each input segment is either removed from the db completely (if all of
129708 ** its data was copied to the output segment by the incrmerge operation)
129709 ** or modified in place so that it no longer contains those entries that
129710 ** have been duplicated in the output segment.
129711 */
129712 static int fts3IncrmergeChomp(
129713 Fts3Table *p, /* FTS table handle */
129714 sqlite3_int64 iAbsLevel, /* Absolute level containing segments */
129715 Fts3MultiSegReader *pCsr, /* Chomp all segments opened by this cursor */
129716 int *pnRem /* Number of segments not deleted */
129717 ){
129718 int i;
129719 int nRem = 0;
129720 int rc = SQLITE_OK;
129721
129722 for(i=pCsr->nSegment-1; i>=0 && rc==SQLITE_OK; i--){
129723 Fts3SegReader *pSeg = 0;
129724 int j;
129725
129726 /* Find the Fts3SegReader object with Fts3SegReader.iIdx==i. It is hiding
129727 ** somewhere in the pCsr->apSegment[] array. */
129728 for(j=0; ALWAYS(j<pCsr->nSegment); j++){
129729 pSeg = pCsr->apSegment[j];
129730 if( pSeg->iIdx==i ) break;
129731 }
129732 assert( j<pCsr->nSegment && pSeg->iIdx==i );
129733
129734 if( pSeg->aNode==0 ){
129735 /* Seg-reader is at EOF. Remove the entire input segment. */
129736 rc = fts3DeleteSegment(p, pSeg);
129737 if( rc==SQLITE_OK ){
129738 rc = fts3RemoveSegdirEntry(p, iAbsLevel, pSeg->iIdx);
129739 }
129740 *pnRem = 0;
129741 }else{
129742 /* The incremental merge did not copy all the data from this
129743 ** segment to the upper level. The segment is modified in place
129744 ** so that it contains no keys smaller than zTerm/nTerm. */
129745 const char *zTerm = pSeg->zTerm;
129746 int nTerm = pSeg->nTerm;
129747 rc = fts3TruncateSegment(p, iAbsLevel, pSeg->iIdx, zTerm, nTerm);
129748 nRem++;
129749 }
129750 }
129751
129752 if( rc==SQLITE_OK && nRem!=pCsr->nSegment ){
129753 rc = fts3RepackSegdirLevel(p, iAbsLevel);
129754 }
129755
129756 *pnRem = nRem;
129757 return rc;
129758 }
129759
129760 /*
129761 ** Store an incr-merge hint in the database.
129762 */
129763 static int fts3IncrmergeHintStore(Fts3Table *p, Blob *pHint){
129764 sqlite3_stmt *pReplace = 0;
129765 int rc; /* Return code */
129766
129767 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pReplace, 0);
129768 if( rc==SQLITE_OK ){
129769 sqlite3_bind_int(pReplace, 1, FTS_STAT_INCRMERGEHINT);
129770 sqlite3_bind_blob(pReplace, 2, pHint->a, pHint->n, SQLITE_STATIC);
129771 sqlite3_step(pReplace);
129772 rc = sqlite3_reset(pReplace);
129773 }
129774
129775 return rc;
129776 }
129777
129778 /*
129779 ** Load an incr-merge hint from the database. The incr-merge hint, if one
129780 ** exists, is stored in the rowid==1 row of the %_stat table.
129781 **
129782 ** If successful, populate blob *pHint with the value read from the %_stat
129783 ** table and return SQLITE_OK. Otherwise, if an error occurs, return an
129784 ** SQLite error code.
129785 */
129786 static int fts3IncrmergeHintLoad(Fts3Table *p, Blob *pHint){
129787 sqlite3_stmt *pSelect = 0;
129788 int rc;
129789
129790 pHint->n = 0;
129791 rc = fts3SqlStmt(p, SQL_SELECT_STAT, &pSelect, 0);
129792 if( rc==SQLITE_OK ){
129793 int rc2;
129794 sqlite3_bind_int(pSelect, 1, FTS_STAT_INCRMERGEHINT);
129795 if( SQLITE_ROW==sqlite3_step(pSelect) ){
129796 const char *aHint = sqlite3_column_blob(pSelect, 0);
129797 int nHint = sqlite3_column_bytes(pSelect, 0);
129798 if( aHint ){
129799 blobGrowBuffer(pHint, nHint, &rc);
129800 if( rc==SQLITE_OK ){
129801 memcpy(pHint->a, aHint, nHint);
129802 pHint->n = nHint;
129803 }
129804 }
129805 }
129806 rc2 = sqlite3_reset(pSelect);
129807 if( rc==SQLITE_OK ) rc = rc2;
129808 }
129809
129810 return rc;
129811 }
129812
129813 /*
129814 ** If *pRc is not SQLITE_OK when this function is called, it is a no-op.
129815 ** Otherwise, append an entry to the hint stored in blob *pHint. Each entry
129816 ** consists of two varints, the absolute level number of the input segments
129817 ** and the number of input segments.
129818 **
129819 ** If successful, leave *pRc set to SQLITE_OK and return. If an error occurs,
129820 ** set *pRc to an SQLite error code before returning.
129821 */
129822 static void fts3IncrmergeHintPush(
129823 Blob *pHint, /* Hint blob to append to */
129824 i64 iAbsLevel, /* First varint to store in hint */
129825 int nInput, /* Second varint to store in hint */
129826 int *pRc /* IN/OUT: Error code */
129827 ){
129828 blobGrowBuffer(pHint, pHint->n + 2*FTS3_VARINT_MAX, pRc);
129829 if( *pRc==SQLITE_OK ){
129830 pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], iAbsLevel);
129831 pHint->n += sqlite3Fts3PutVarint(&pHint->a[pHint->n], (i64)nInput);
129832 }
129833 }
129834
129835 /*
129836 ** Read the last entry (most recently pushed) from the hint blob *pHint
129837 ** and then remove the entry. Write the two values read to *piAbsLevel and
129838 ** *pnInput before returning.
129839 **
129840 ** If no error occurs, return SQLITE_OK. If the hint blob in *pHint does
129841 ** not contain at least two valid varints, return SQLITE_CORRUPT_VTAB.
129842 */
129843 static int fts3IncrmergeHintPop(Blob *pHint, i64 *piAbsLevel, int *pnInput){
129844 const int nHint = pHint->n;
129845 int i;
129846
129847 i = pHint->n-2;
129848 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129849 while( i>0 && (pHint->a[i-1] & 0x80) ) i--;
129850
129851 pHint->n = i;
129852 i += sqlite3Fts3GetVarint(&pHint->a[i], piAbsLevel);
129853 i += sqlite3Fts3GetVarint32(&pHint->a[i], pnInput);
129854 if( i!=nHint ) return SQLITE_CORRUPT_VTAB;
129855
129856 return SQLITE_OK;
129857 }
129858
129859
129860 /*
129861 ** Attempt an incremental merge that writes nMerge leaf blocks.
129862 **
129863 ** Incremental merges happen nMin segments at a time. The two
129864 ** segments to be merged are the nMin oldest segments (the ones with
129865 ** the smallest indexes) in the highest level that contains at least
129866 ** nMin segments. Multiple merges might occur in an attempt to write the
129867 ** quota of nMerge leaf blocks.
129868 */
129869 SQLITE_PRIVATE int sqlite3Fts3Incrmerge(Fts3Table *p, int nMerge, int nMin){
129870 int rc; /* Return code */
129871 int nRem = nMerge; /* Number of leaf pages yet to be written */
129872 Fts3MultiSegReader *pCsr; /* Cursor used to read input data */
129873 Fts3SegFilter *pFilter; /* Filter used with cursor pCsr */
129874 IncrmergeWriter *pWriter; /* Writer object */
129875 int nSeg = 0; /* Number of input segments */
129876 sqlite3_int64 iAbsLevel = 0; /* Absolute level number to work on */
129877 Blob hint = {0, 0, 0}; /* Hint read from %_stat table */
129878 int bDirtyHint = 0; /* True if blob 'hint' has been modified */
129879
129880 /* Allocate space for the cursor, filter and writer objects */
129881 const int nAlloc = sizeof(*pCsr) + sizeof(*pFilter) + sizeof(*pWriter);
129882 pWriter = (IncrmergeWriter *)sqlite3_malloc(nAlloc);
129883 if( !pWriter ) return SQLITE_NOMEM;
129884 pFilter = (Fts3SegFilter *)&pWriter[1];
129885 pCsr = (Fts3MultiSegReader *)&pFilter[1];
129886
129887 rc = fts3IncrmergeHintLoad(p, &hint);
129888 while( rc==SQLITE_OK && nRem>0 ){
129889 const i64 nMod = FTS3_SEGDIR_MAXLEVEL * p->nIndex;
129890 sqlite3_stmt *pFindLevel = 0; /* SQL used to determine iAbsLevel */
129891 int bUseHint = 0; /* True if attempting to append */
129892
129893 /* Search the %_segdir table for the absolute level with the smallest
129894 ** relative level number that contains at least nMin segments, if any.
129895 ** If one is found, set iAbsLevel to the absolute level number and
129896 ** nSeg to nMin. If no level with at least nMin segments can be found,
129897 ** set nSeg to -1.
129898 */
129899 rc = fts3SqlStmt(p, SQL_FIND_MERGE_LEVEL, &pFindLevel, 0);
129900 sqlite3_bind_int(pFindLevel, 1, nMin);
129901 if( sqlite3_step(pFindLevel)==SQLITE_ROW ){
129902 iAbsLevel = sqlite3_column_int64(pFindLevel, 0);
129903 nSeg = nMin;
129904 }else{
129905 nSeg = -1;
129906 }
129907 rc = sqlite3_reset(pFindLevel);
129908
129909 /* If the hint read from the %_stat table is not empty, check if the
129910 ** last entry in it specifies a relative level smaller than or equal
129911 ** to the level identified by the block above (if any). If so, this
129912 ** iteration of the loop will work on merging at the hinted level.
129913 */
129914 if( rc==SQLITE_OK && hint.n ){
129915 int nHint = hint.n;
129916 sqlite3_int64 iHintAbsLevel = 0; /* Hint level */
129917 int nHintSeg = 0; /* Hint number of segments */
129918
129919 rc = fts3IncrmergeHintPop(&hint, &iHintAbsLevel, &nHintSeg);
129920 if( nSeg<0 || (iAbsLevel % nMod) >= (iHintAbsLevel % nMod) ){
129921 iAbsLevel = iHintAbsLevel;
129922 nSeg = nHintSeg;
129923 bUseHint = 1;
129924 bDirtyHint = 1;
129925 }else{
129926 /* This undoes the effect of the HintPop() above - so that no entry
129927 ** is removed from the hint blob. */
129928 hint.n = nHint;
129929 }
129930 }
129931
129932 /* If nSeg is less that zero, then there is no level with at least
129933 ** nMin segments and no hint in the %_stat table. No work to do.
129934 ** Exit early in this case. */
129935 if( nSeg<0 ) break;
129936
129937 /* Open a cursor to iterate through the contents of the oldest nSeg
129938 ** indexes of absolute level iAbsLevel. If this cursor is opened using
129939 ** the 'hint' parameters, it is possible that there are less than nSeg
129940 ** segments available in level iAbsLevel. In this case, no work is
129941 ** done on iAbsLevel - fall through to the next iteration of the loop
129942 ** to start work on some other level. */
129943 memset(pWriter, 0, nAlloc);
129944 pFilter->flags = FTS3_SEGMENT_REQUIRE_POS;
129945 if( rc==SQLITE_OK ){
129946 rc = fts3IncrmergeCsr(p, iAbsLevel, nSeg, pCsr);
129947 }
129948 if( SQLITE_OK==rc && pCsr->nSegment==nSeg
129949 && SQLITE_OK==(rc = sqlite3Fts3SegReaderStart(p, pCsr, pFilter))
129950 && SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, pCsr))
129951 ){
129952 int iIdx = 0; /* Largest idx in level (iAbsLevel+1) */
129953 rc = fts3IncrmergeOutputIdx(p, iAbsLevel, &iIdx);
129954 if( rc==SQLITE_OK ){
129955 if( bUseHint && iIdx>0 ){
129956 const char *zKey = pCsr->zTerm;
129957 int nKey = pCsr->nTerm;
129958 rc = fts3IncrmergeLoad(p, iAbsLevel, iIdx-1, zKey, nKey, pWriter);
129959 }else{
129960 rc = fts3IncrmergeWriter(p, iAbsLevel, iIdx, pCsr, pWriter);
129961 }
129962 }
129963
129964 if( rc==SQLITE_OK && pWriter->nLeafEst ){
129965 fts3LogMerge(nSeg, iAbsLevel);
129966 do {
129967 rc = fts3IncrmergeAppend(p, pWriter, pCsr);
129968 if( rc==SQLITE_OK ) rc = sqlite3Fts3SegReaderStep(p, pCsr);
129969 if( pWriter->nWork>=nRem && rc==SQLITE_ROW ) rc = SQLITE_OK;
129970 }while( rc==SQLITE_ROW );
129971
129972 /* Update or delete the input segments */
129973 if( rc==SQLITE_OK ){
129974 nRem -= (1 + pWriter->nWork);
129975 rc = fts3IncrmergeChomp(p, iAbsLevel, pCsr, &nSeg);
129976 if( nSeg!=0 ){
129977 bDirtyHint = 1;
129978 fts3IncrmergeHintPush(&hint, iAbsLevel, nSeg, &rc);
129979 }
129980 }
129981 }
129982
129983 fts3IncrmergeRelease(p, pWriter, &rc);
129984 }
129985
129986 sqlite3Fts3SegReaderFinish(pCsr);
129987 }
129988
129989 /* Write the hint values into the %_stat table for the next incr-merger */
129990 if( bDirtyHint && rc==SQLITE_OK ){
129991 rc = fts3IncrmergeHintStore(p, &hint);
129992 }
129993
129994 sqlite3_free(pWriter);
129995 sqlite3_free(hint.a);
129996 return rc;
129997 }
129998
129999 /*
130000 ** Convert the text beginning at *pz into an integer and return
130001 ** its value. Advance *pz to point to the first character past
130002 ** the integer.
130003 */
130004 static int fts3Getint(const char **pz){
130005 const char *z = *pz;
130006 int i = 0;
130007 while( (*z)>='0' && (*z)<='9' ) i = 10*i + *(z++) - '0';
130008 *pz = z;
130009 return i;
130010 }
130011
130012 /*
130013 ** Process statements of the form:
130014 **
130015 ** INSERT INTO table(table) VALUES('merge=A,B');
130016 **
130017 ** A and B are integers that decode to be the number of leaf pages
130018 ** written for the merge, and the minimum number of segments on a level
130019 ** before it will be selected for a merge, respectively.
130020 */
130021 static int fts3DoIncrmerge(
130022 Fts3Table *p, /* FTS3 table handle */
130023 const char *zParam /* Nul-terminated string containing "A,B" */
130024 ){
130025 int rc;
130026 int nMin = (FTS3_MERGE_COUNT / 2);
130027 int nMerge = 0;
130028 const char *z = zParam;
130029
130030 /* Read the first integer value */
130031 nMerge = fts3Getint(&z);
130032
130033 /* If the first integer value is followed by a ',', read the second
130034 ** integer value. */
130035 if( z[0]==',' && z[1]!='\0' ){
130036 z++;
130037 nMin = fts3Getint(&z);
130038 }
130039
130040 if( z[0]!='\0' || nMin<2 ){
130041 rc = SQLITE_ERROR;
130042 }else{
130043 rc = SQLITE_OK;
130044 if( !p->bHasStat ){
130045 assert( p->bFts4==0 );
130046 sqlite3Fts3CreateStatTable(&rc, p);
130047 }
130048 if( rc==SQLITE_OK ){
130049 rc = sqlite3Fts3Incrmerge(p, nMerge, nMin);
130050 }
130051 sqlite3Fts3SegmentsClose(p);
130052 }
130053 return rc;
130054 }
130055
130056 /*
130057 ** Process statements of the form:
130058 **
130059 ** INSERT INTO table(table) VALUES('automerge=X');
130060 **
130061 ** where X is an integer. X==0 means to turn automerge off. X!=0 means
130062 ** turn it on. The setting is persistent.
130063 */
130064 static int fts3DoAutoincrmerge(
130065 Fts3Table *p, /* FTS3 table handle */
130066 const char *zParam /* Nul-terminated string containing boolean */
130067 ){
130068 int rc = SQLITE_OK;
130069 sqlite3_stmt *pStmt = 0;
130070 p->bAutoincrmerge = fts3Getint(&zParam)!=0;
130071 if( !p->bHasStat ){
130072 assert( p->bFts4==0 );
130073 sqlite3Fts3CreateStatTable(&rc, p);
130074 if( rc ) return rc;
130075 }
130076 rc = fts3SqlStmt(p, SQL_REPLACE_STAT, &pStmt, 0);
130077 if( rc ) return rc;;
130078 sqlite3_bind_int(pStmt, 1, FTS_STAT_AUTOINCRMERGE);
130079 sqlite3_bind_int(pStmt, 2, p->bAutoincrmerge);
130080 sqlite3_step(pStmt);
130081 rc = sqlite3_reset(pStmt);
130082 return rc;
130083 }
130084
130085 /*
130086 ** Return a 64-bit checksum for the FTS index entry specified by the
130087 ** arguments to this function.
130088 */
130089 static u64 fts3ChecksumEntry(
130090 const char *zTerm, /* Pointer to buffer containing term */
130091 int nTerm, /* Size of zTerm in bytes */
130092 int iLangid, /* Language id for current row */
130093 int iIndex, /* Index (0..Fts3Table.nIndex-1) */
130094 i64 iDocid, /* Docid for current row. */
130095 int iCol, /* Column number */
130096 int iPos /* Position */
130097 ){
130098 int i;
130099 u64 ret = (u64)iDocid;
130100
130101 ret += (ret<<3) + iLangid;
130102 ret += (ret<<3) + iIndex;
130103 ret += (ret<<3) + iCol;
130104 ret += (ret<<3) + iPos;
130105 for(i=0; i<nTerm; i++) ret += (ret<<3) + zTerm[i];
130106
130107 return ret;
130108 }
130109
130110 /*
130111 ** Return a checksum of all entries in the FTS index that correspond to
130112 ** language id iLangid. The checksum is calculated by XORing the checksums
130113 ** of each individual entry (see fts3ChecksumEntry()) together.
130114 **
130115 ** If successful, the checksum value is returned and *pRc set to SQLITE_OK.
130116 ** Otherwise, if an error occurs, *pRc is set to an SQLite error code. The
130117 ** return value is undefined in this case.
130118 */
130119 static u64 fts3ChecksumIndex(
130120 Fts3Table *p, /* FTS3 table handle */
130121 int iLangid, /* Language id to return cksum for */
130122 int iIndex, /* Index to cksum (0..p->nIndex-1) */
130123 int *pRc /* OUT: Return code */
130124 ){
130125 Fts3SegFilter filter;
130126 Fts3MultiSegReader csr;
130127 int rc;
130128 u64 cksum = 0;
130129
130130 assert( *pRc==SQLITE_OK );
130131
130132 memset(&filter, 0, sizeof(filter));
130133 memset(&csr, 0, sizeof(csr));
130134 filter.flags = FTS3_SEGMENT_REQUIRE_POS|FTS3_SEGMENT_IGNORE_EMPTY;
130135 filter.flags |= FTS3_SEGMENT_SCAN;
130136
130137 rc = sqlite3Fts3SegReaderCursor(
130138 p, iLangid, iIndex, FTS3_SEGCURSOR_ALL, 0, 0, 0, 1,&csr
130139 );
130140 if( rc==SQLITE_OK ){
130141 rc = sqlite3Fts3SegReaderStart(p, &csr, &filter);
130142 }
130143
130144 if( rc==SQLITE_OK ){
130145 while( SQLITE_ROW==(rc = sqlite3Fts3SegReaderStep(p, &csr)) ){
130146 char *pCsr = csr.aDoclist;
130147 char *pEnd = &pCsr[csr.nDoclist];
130148
130149 i64 iDocid = 0;
130150 i64 iCol = 0;
130151 i64 iPos = 0;
130152
130153 pCsr += sqlite3Fts3GetVarint(pCsr, &iDocid);
130154 while( pCsr<pEnd ){
130155 i64 iVal = 0;
130156 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130157 if( pCsr<pEnd ){
130158 if( iVal==0 || iVal==1 ){
130159 iCol = 0;
130160 iPos = 0;
130161 if( iVal ){
130162 pCsr += sqlite3Fts3GetVarint(pCsr, &iCol);
130163 }else{
130164 pCsr += sqlite3Fts3GetVarint(pCsr, &iVal);
130165 iDocid += iVal;
130166 }
130167 }else{
130168 iPos += (iVal - 2);
130169 cksum = cksum ^ fts3ChecksumEntry(
130170 csr.zTerm, csr.nTerm, iLangid, iIndex, iDocid,
130171 (int)iCol, (int)iPos
130172 );
130173 }
130174 }
130175 }
130176 }
130177 }
130178 sqlite3Fts3SegReaderFinish(&csr);
130179
130180 *pRc = rc;
130181 return cksum;
130182 }
130183
130184 /*
130185 ** Check if the contents of the FTS index match the current contents of the
130186 ** content table. If no error occurs and the contents do match, set *pbOk
130187 ** to true and return SQLITE_OK. Or if the contents do not match, set *pbOk
130188 ** to false before returning.
130189 **
130190 ** If an error occurs (e.g. an OOM or IO error), return an SQLite error
130191 ** code. The final value of *pbOk is undefined in this case.
130192 */
130193 static int fts3IntegrityCheck(Fts3Table *p, int *pbOk){
130194 int rc = SQLITE_OK; /* Return code */
130195 u64 cksum1 = 0; /* Checksum based on FTS index contents */
130196 u64 cksum2 = 0; /* Checksum based on %_content contents */
130197 sqlite3_stmt *pAllLangid = 0; /* Statement to return all language-ids */
130198
130199 /* This block calculates the checksum according to the FTS index. */
130200 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130201 if( rc==SQLITE_OK ){
130202 int rc2;
130203 sqlite3_bind_int(pAllLangid, 1, p->nIndex);
130204 while( rc==SQLITE_OK && sqlite3_step(pAllLangid)==SQLITE_ROW ){
130205 int iLangid = sqlite3_column_int(pAllLangid, 0);
130206 int i;
130207 for(i=0; i<p->nIndex; i++){
130208 cksum1 = cksum1 ^ fts3ChecksumIndex(p, iLangid, i, &rc);
130209 }
130210 }
130211 rc2 = sqlite3_reset(pAllLangid);
130212 if( rc==SQLITE_OK ) rc = rc2;
130213 }
130214
130215 /* This block calculates the checksum according to the %_content table */
130216 rc = fts3SqlStmt(p, SQL_SELECT_ALL_LANGID, &pAllLangid, 0);
130217 if( rc==SQLITE_OK ){
130218 sqlite3_tokenizer_module const *pModule = p->pTokenizer->pModule;
130219 sqlite3_stmt *pStmt = 0;
130220 char *zSql;
130221
130222 zSql = sqlite3_mprintf("SELECT %s" , p->zReadExprlist);
130223 if( !zSql ){
130224 rc = SQLITE_NOMEM;
130225 }else{
130226 rc = sqlite3_prepare_v2(p->db, zSql, -1, &pStmt, 0);
130227 sqlite3_free(zSql);
130228 }
130229
130230 while( rc==SQLITE_OK && SQLITE_ROW==sqlite3_step(pStmt) ){
130231 i64 iDocid = sqlite3_column_int64(pStmt, 0);
130232 int iLang = langidFromSelect(p, pStmt);
130233 int iCol;
130234
130235 for(iCol=0; rc==SQLITE_OK && iCol<p->nColumn; iCol++){
130236 const char *zText = (const char *)sqlite3_column_text(pStmt, iCol+1);
130237 int nText = sqlite3_column_bytes(pStmt, iCol+1);
130238 sqlite3_tokenizer_cursor *pT = 0;
130239
130240 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130241 while( rc==SQLITE_OK ){
130242 char const *zToken; /* Buffer containing token */
130243 int nToken; /* Number of bytes in token */
130244 int iDum1, iDum2; /* Dummy variables */
130245 int iPos; /* Position of token in zText */
130246
130247 rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130248 if( rc==SQLITE_OK ){
130249 int i;
130250 cksum2 = cksum2 ^ fts3ChecksumEntry(
130251 zToken, nToken, iLang, 0, iDocid, iCol, iPos
130252 );
130253 for(i=1; i<p->nIndex; i++){
130254 if( p->aIndex[i].nPrefix<=nToken ){
130255 cksum2 = cksum2 ^ fts3ChecksumEntry(
130256 zToken, p->aIndex[i].nPrefix, iLang, i, iDocid, iCol, iPos
130257 );
130258 }
130259 }
130260 }
130261 }
130262 if( pT ) pModule->xClose(pT);
130263 if( rc==SQLITE_DONE ) rc = SQLITE_OK;
130264 }
130265 }
130266
130267 sqlite3_finalize(pStmt);
130268 }
130269
130270 *pbOk = (cksum1==cksum2);
130271 return rc;
130272 }
130273
130274 /*
130275 ** Run the integrity-check. If no error occurs and the current contents of
130276 ** the FTS index are correct, return SQLITE_OK. Or, if the contents of the
130277 ** FTS index are incorrect, return SQLITE_CORRUPT_VTAB.
130278 **
130279 ** Or, if an error (e.g. an OOM or IO error) occurs, return an SQLite
130280 ** error code.
130281 **
130282 ** The integrity-check works as follows. For each token and indexed token
130283 ** prefix in the document set, a 64-bit checksum is calculated (by code
130284 ** in fts3ChecksumEntry()) based on the following:
130285 **
130286 ** + The index number (0 for the main index, 1 for the first prefix
130287 ** index etc.),
130288 ** + The token (or token prefix) text itself,
130289 ** + The language-id of the row it appears in,
130290 ** + The docid of the row it appears in,
130291 ** + The column it appears in, and
130292 ** + The tokens position within that column.
130293 **
130294 ** The checksums for all entries in the index are XORed together to create
130295 ** a single checksum for the entire index.
130296 **
130297 ** The integrity-check code calculates the same checksum in two ways:
130298 **
130299 ** 1. By scanning the contents of the FTS index, and
130300 ** 2. By scanning and tokenizing the content table.
130301 **
130302 ** If the two checksums are identical, the integrity-check is deemed to have
130303 ** passed.
130304 */
130305 static int fts3DoIntegrityCheck(
130306 Fts3Table *p /* FTS3 table handle */
130307 ){
130308 int rc;
130309 int bOk = 0;
130310 rc = fts3IntegrityCheck(p, &bOk);
130311 if( rc==SQLITE_OK && bOk==0 ) rc = SQLITE_CORRUPT_VTAB;
130312 return rc;
130313 }
130314
130315 /*
130316 ** Handle a 'special' INSERT of the form:
130317 **
130318 ** "INSERT INTO tbl(tbl) VALUES(<expr>)"
130319 **
@@ -128211,10 +130329,16 @@
130329 return SQLITE_NOMEM;
130330 }else if( nVal==8 && 0==sqlite3_strnicmp(zVal, "optimize", 8) ){
130331 rc = fts3DoOptimize(p, 0);
130332 }else if( nVal==7 && 0==sqlite3_strnicmp(zVal, "rebuild", 7) ){
130333 rc = fts3DoRebuild(p);
130334 }else if( nVal==15 && 0==sqlite3_strnicmp(zVal, "integrity-check", 15) ){
130335 rc = fts3DoIntegrityCheck(p);
130336 }else if( nVal>6 && 0==sqlite3_strnicmp(zVal, "merge=", 6) ){
130337 rc = fts3DoIncrmerge(p, &zVal[6]);
130338 }else if( nVal>10 && 0==sqlite3_strnicmp(zVal, "automerge=", 10) ){
130339 rc = fts3DoAutoincrmerge(p, &zVal[10]);
130340 #ifdef SQLITE_TEST
130341 }else if( nVal>9 && 0==sqlite3_strnicmp(zVal, "nodesize=", 9) ){
130342 p->nNodeSize = atoi(&zVal[9]);
130343 rc = SQLITE_OK;
130344 }else if( nVal>11 && 0==sqlite3_strnicmp(zVal, "maxpending=", 9) ){
@@ -128406,11 +130530,11 @@
130530 /*
130531 ** This function does the work for the xUpdate method of FTS3 virtual
130532 ** tables. The schema of the virtual table being:
130533 **
130534 ** CREATE TABLE <table name>(
130535 ** <user columns>,
130536 ** <table name> HIDDEN,
130537 ** docid HIDDEN,
130538 ** <langid> HIDDEN
130539 ** );
130540 **
@@ -128538,11 +130662,11 @@
130662 fts3InsertDocsize(&rc, p, aSzIns);
130663 }
130664 nChng++;
130665 }
130666
130667 if( p->bFts4 ){
130668 fts3UpdateDocTotals(&rc, p, aSzIns, aSzDel, nChng);
130669 }
130670
130671 update_out:
130672 sqlite3_free(aSzIns);
@@ -129369,12 +131493,12 @@
131493 char cArg,
131494 char **pzErr
131495 ){
131496 if( (cArg==FTS3_MATCHINFO_NPHRASE)
131497 || (cArg==FTS3_MATCHINFO_NCOL)
131498 || (cArg==FTS3_MATCHINFO_NDOC && pTab->bFts4)
131499 || (cArg==FTS3_MATCHINFO_AVGLENGTH && pTab->bFts4)
131500 || (cArg==FTS3_MATCHINFO_LENGTH && pTab->bHasDocsize)
131501 || (cArg==FTS3_MATCHINFO_LCS)
131502 || (cArg==FTS3_MATCHINFO_HITS)
131503 ){
131504 return SQLITE_OK;
@@ -133134,12 +135258,12 @@
135258 }
135259
135260 sqlite3_vtab_config(db, SQLITE_VTAB_CONSTRAINT_SUPPORT, 1);
135261
135262 /* Allocate the sqlite3_vtab structure */
135263 nDb = (int)strlen(argv[1]);
135264 nName = (int)strlen(argv[2]);
135265 pRtree = (Rtree *)sqlite3_malloc(sizeof(Rtree)+nDb+nName+2);
135266 if( !pRtree ){
135267 return SQLITE_NOMEM;
135268 }
135269 memset(pRtree, 0, sizeof(Rtree)+nDb+nName+2);
@@ -133230,14 +135354,14 @@
135354 RtreeCell cell;
135355 int jj;
135356
135357 nodeGetCell(&tree, &node, ii, &cell);
135358 sqlite3_snprintf(512-nCell,&zCell[nCell],"%lld", cell.iRowid);
135359 nCell = (int)strlen(zCell);
135360 for(jj=0; jj<tree.nDim*2; jj++){
135361 sqlite3_snprintf(512-nCell,&zCell[nCell]," %f",(double)cell.aCoord[jj].f);
135362 nCell = (int)strlen(zCell);
135363 }
135364
135365 if( zText ){
135366 char *zTextNew = sqlite3_mprintf("%s {%s}", zText, zCell);
135367 sqlite3_free(zText);
@@ -133976,11 +136100,14 @@
136100 int iInput = 0;
136101 int iOut = 0;
136102
136103 *ppCursor = 0;
136104
136105 if( zInput==0 ){
136106 nInput = 0;
136107 zInput = "";
136108 }else if( nInput<0 ){
136109 nInput = strlen(zInput);
136110 }
136111 nChar = nInput+1;
136112 pCsr = (IcuCursor *)sqlite3_malloc(
136113 sizeof(IcuCursor) + /* IcuCursor */
136114
+16 -4
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105105
**
106106
** See also: [sqlite3_libversion()],
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110
-#define SQLITE_VERSION "3.7.11"
111
-#define SQLITE_VERSION_NUMBER 3007011
112
-#define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
110
+#define SQLITE_VERSION "3.7.12"
111
+#define SQLITE_VERSION_NUMBER 3007012
112
+#define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -6004,10 +6004,21 @@
60046004
** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
60056005
** <dd>This parameter returns the number of pager cache misses that have
60066006
** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
60076007
** is always 0.
60086008
** </dd>
6009
+**
6010
+** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6011
+** <dd>This parameter returns the number of dirty cache entries that have
6012
+** been written to disk. Specifically, the number of pages written to the
6013
+** wal file in wal mode databases, or the number of pages written to the
6014
+** database file in rollback mode databases. Any pages written as part of
6015
+** transaction rollback or database recovery operations are not included.
6016
+** If an IO or other error occurs while writing a page to disk, the effect
6017
+** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6018
+** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6019
+** </dd>
60096020
** </dl>
60106021
*/
60116022
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
60126023
#define SQLITE_DBSTATUS_CACHE_USED 1
60136024
#define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
60156026
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
60166027
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
60176028
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
60186029
#define SQLITE_DBSTATUS_CACHE_HIT 7
60196030
#define SQLITE_DBSTATUS_CACHE_MISS 8
6020
-#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
6031
+#define SQLITE_DBSTATUS_CACHE_WRITE 9
6032
+#define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
60216033
60226034
60236035
/*
60246036
** CAPI3REF: Prepared Statement Status
60256037
**
60266038
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.11"
111 #define SQLITE_VERSION_NUMBER 3007011
112 #define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -6004,10 +6004,21 @@
6004 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6005 ** <dd>This parameter returns the number of pager cache misses that have
6006 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6007 ** is always 0.
6008 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
6009 ** </dl>
6010 */
6011 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6012 #define SQLITE_DBSTATUS_CACHE_USED 1
6013 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
6015 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6016 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6017 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6018 #define SQLITE_DBSTATUS_CACHE_HIT 7
6019 #define SQLITE_DBSTATUS_CACHE_MISS 8
6020 #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
 
6021
6022
6023 /*
6024 ** CAPI3REF: Prepared Statement Status
6025 **
6026
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.12"
111 #define SQLITE_VERSION_NUMBER 3007012
112 #define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -6004,10 +6004,21 @@
6004 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6005 ** <dd>This parameter returns the number of pager cache misses that have
6006 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6007 ** is always 0.
6008 ** </dd>
6009 **
6010 ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6011 ** <dd>This parameter returns the number of dirty cache entries that have
6012 ** been written to disk. Specifically, the number of pages written to the
6013 ** wal file in wal mode databases, or the number of pages written to the
6014 ** database file in rollback mode databases. Any pages written as part of
6015 ** transaction rollback or database recovery operations are not included.
6016 ** If an IO or other error occurs while writing a page to disk, the effect
6017 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6018 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6019 ** </dd>
6020 ** </dl>
6021 */
6022 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6023 #define SQLITE_DBSTATUS_CACHE_USED 1
6024 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
6026 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6027 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6028 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6029 #define SQLITE_DBSTATUS_CACHE_HIT 7
6030 #define SQLITE_DBSTATUS_CACHE_MISS 8
6031 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6032 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
6033
6034
6035 /*
6036 ** CAPI3REF: Prepared Statement Status
6037 **
6038
+16 -4
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105105
**
106106
** See also: [sqlite3_libversion()],
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110
-#define SQLITE_VERSION "3.7.11"
111
-#define SQLITE_VERSION_NUMBER 3007011
112
-#define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
110
+#define SQLITE_VERSION "3.7.12"
111
+#define SQLITE_VERSION_NUMBER 3007012
112
+#define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
@@ -6004,10 +6004,21 @@
60046004
** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
60056005
** <dd>This parameter returns the number of pager cache misses that have
60066006
** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
60076007
** is always 0.
60086008
** </dd>
6009
+**
6010
+** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6011
+** <dd>This parameter returns the number of dirty cache entries that have
6012
+** been written to disk. Specifically, the number of pages written to the
6013
+** wal file in wal mode databases, or the number of pages written to the
6014
+** database file in rollback mode databases. Any pages written as part of
6015
+** transaction rollback or database recovery operations are not included.
6016
+** If an IO or other error occurs while writing a page to disk, the effect
6017
+** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6018
+** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6019
+** </dd>
60096020
** </dl>
60106021
*/
60116022
#define SQLITE_DBSTATUS_LOOKASIDE_USED 0
60126023
#define SQLITE_DBSTATUS_CACHE_USED 1
60136024
#define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
60156026
#define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
60166027
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
60176028
#define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
60186029
#define SQLITE_DBSTATUS_CACHE_HIT 7
60196030
#define SQLITE_DBSTATUS_CACHE_MISS 8
6020
-#define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
6031
+#define SQLITE_DBSTATUS_CACHE_WRITE 9
6032
+#define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
60216033
60226034
60236035
/*
60246036
** CAPI3REF: Prepared Statement Status
60256037
**
60266038
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.11"
111 #define SQLITE_VERSION_NUMBER 3007011
112 #define SQLITE_SOURCE_ID "2012-03-16 00:28:11 74eadeec34c4b19cf5f8b7f648db3b7ad601a00e"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -6004,10 +6004,21 @@
6004 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6005 ** <dd>This parameter returns the number of pager cache misses that have
6006 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6007 ** is always 0.
6008 ** </dd>
 
 
 
 
 
 
 
 
 
 
 
6009 ** </dl>
6010 */
6011 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6012 #define SQLITE_DBSTATUS_CACHE_USED 1
6013 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
6015 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6016 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6017 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6018 #define SQLITE_DBSTATUS_CACHE_HIT 7
6019 #define SQLITE_DBSTATUS_CACHE_MISS 8
6020 #define SQLITE_DBSTATUS_MAX 8 /* Largest defined DBSTATUS */
 
6021
6022
6023 /*
6024 ** CAPI3REF: Prepared Statement Status
6025 **
6026
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -105,13 +105,13 @@
105 **
106 ** See also: [sqlite3_libversion()],
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.12"
111 #define SQLITE_VERSION_NUMBER 3007012
112 #define SQLITE_SOURCE_ID "2012-03-31 19:12:23 af602d87736b52802a4e760ffeeaa28112b99d9a"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
@@ -6004,10 +6004,21 @@
6004 ** [[SQLITE_DBSTATUS_CACHE_MISS]] ^(<dt>SQLITE_DBSTATUS_CACHE_MISS</dt>
6005 ** <dd>This parameter returns the number of pager cache misses that have
6006 ** occurred.)^ ^The highwater mark associated with SQLITE_DBSTATUS_CACHE_MISS
6007 ** is always 0.
6008 ** </dd>
6009 **
6010 ** [[SQLITE_DBSTATUS_CACHE_WRITE]] ^(<dt>SQLITE_DBSTATUS_CACHE_WRITE</dt>
6011 ** <dd>This parameter returns the number of dirty cache entries that have
6012 ** been written to disk. Specifically, the number of pages written to the
6013 ** wal file in wal mode databases, or the number of pages written to the
6014 ** database file in rollback mode databases. Any pages written as part of
6015 ** transaction rollback or database recovery operations are not included.
6016 ** If an IO or other error occurs while writing a page to disk, the effect
6017 ** on subsequent SQLITE_DBSTATUS_CACHE_WRITE requests is undefined). ^The
6018 ** highwater mark associated with SQLITE_DBSTATUS_CACHE_WRITE is always 0.
6019 ** </dd>
6020 ** </dl>
6021 */
6022 #define SQLITE_DBSTATUS_LOOKASIDE_USED 0
6023 #define SQLITE_DBSTATUS_CACHE_USED 1
6024 #define SQLITE_DBSTATUS_SCHEMA_USED 2
@@ -6015,11 +6026,12 @@
6026 #define SQLITE_DBSTATUS_LOOKASIDE_HIT 4
6027 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_SIZE 5
6028 #define SQLITE_DBSTATUS_LOOKASIDE_MISS_FULL 6
6029 #define SQLITE_DBSTATUS_CACHE_HIT 7
6030 #define SQLITE_DBSTATUS_CACHE_MISS 8
6031 #define SQLITE_DBSTATUS_CACHE_WRITE 9
6032 #define SQLITE_DBSTATUS_MAX 9 /* Largest defined DBSTATUS */
6033
6034
6035 /*
6036 ** CAPI3REF: Prepared Statement Status
6037 **
6038
+20 -4
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
1919
**
2020
*/
2121
#include <string.h>
2222
#include "config.h"
2323
#include "stat.h"
24
+
25
+/*
26
+** For a sufficiently large integer, provide an alternative
27
+** representation as MB or GB or TB.
28
+*/
29
+static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
30
+ if( v<100000 ){
31
+ sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
32
+ }else if( v<1000000000 ){
33
+ sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
34
+ v, (double)v/1000000.0);
35
+ }else{
36
+ sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
37
+ v, (double)v/1000000000.0);
38
+ }
39
+}
2440
2541
/*
2642
** WEBPAGE: stat
2743
**
2844
** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
4056
brief = P("brief")!=0;
4157
style_header("Repository Statistics");
4258
@ <table class="label-value">
4359
@ <tr><th>Repository&nbsp;Size:</th><td>
4460
fsize = file_size(g.zRepositoryName);
45
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize);
46
- @ %s(zBuf) bytes
61
+ bigSizeName(sizeof(zBuf), zBuf, fsize);
62
+ @ %s(zBuf)
4763
@ </td></tr>
4864
if( !brief ){
4965
@ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
5066
n = db_int(0, "SELECT count(*) FROM blob");
5167
m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
6076
db_step(&q);
6177
t = db_column_int64(&q, 0);
6278
szAvg = db_column_int(&q, 1);
6379
szMax = db_column_int(&q, 2);
6480
db_finalize(&q);
65
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
66
- @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total
81
+ bigSizeName(sizeof(zBuf), zBuf, t);
82
+ @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
6783
@ </td></tr>
6884
@ <tr><th>Compression&nbsp;Ratio:</th><td>
6985
if( t/fsize < 5 ){
7086
b = 10;
7187
fsize /= 10;
7288
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
19 **
20 */
21 #include <string.h>
22 #include "config.h"
23 #include "stat.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
25 /*
26 ** WEBPAGE: stat
27 **
28 ** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
40 brief = P("brief")!=0;
41 style_header("Repository Statistics");
42 @ <table class="label-value">
43 @ <tr><th>Repository&nbsp;Size:</th><td>
44 fsize = file_size(g.zRepositoryName);
45 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize);
46 @ %s(zBuf) bytes
47 @ </td></tr>
48 if( !brief ){
49 @ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
50 n = db_int(0, "SELECT count(*) FROM blob");
51 m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
60 db_step(&q);
61 t = db_column_int64(&q, 0);
62 szAvg = db_column_int(&q, 1);
63 szMax = db_column_int(&q, 2);
64 db_finalize(&q);
65 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
66 @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total
67 @ </td></tr>
68 @ <tr><th>Compression&nbsp;Ratio:</th><td>
69 if( t/fsize < 5 ){
70 b = 10;
71 fsize /= 10;
72
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
19 **
20 */
21 #include <string.h>
22 #include "config.h"
23 #include "stat.h"
24
25 /*
26 ** For a sufficiently large integer, provide an alternative
27 ** representation as MB or GB or TB.
28 */
29 static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
30 if( v<100000 ){
31 sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
32 }else if( v<1000000000 ){
33 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
34 v, (double)v/1000000.0);
35 }else{
36 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
37 v, (double)v/1000000000.0);
38 }
39 }
40
41 /*
42 ** WEBPAGE: stat
43 **
44 ** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
56 brief = P("brief")!=0;
57 style_header("Repository Statistics");
58 @ <table class="label-value">
59 @ <tr><th>Repository&nbsp;Size:</th><td>
60 fsize = file_size(g.zRepositoryName);
61 bigSizeName(sizeof(zBuf), zBuf, fsize);
62 @ %s(zBuf)
63 @ </td></tr>
64 if( !brief ){
65 @ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
66 n = db_int(0, "SELECT count(*) FROM blob");
67 m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
76 db_step(&q);
77 t = db_column_int64(&q, 0);
78 szAvg = db_column_int(&q, 1);
79 szMax = db_column_int(&q, 2);
80 db_finalize(&q);
81 bigSizeName(sizeof(zBuf), zBuf, t);
82 @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
83 @ </td></tr>
84 @ <tr><th>Compression&nbsp;Ratio:</th><td>
85 if( t/fsize < 5 ){
86 b = 10;
87 fsize /= 10;
88
+20 -4
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
1919
**
2020
*/
2121
#include <string.h>
2222
#include "config.h"
2323
#include "stat.h"
24
+
25
+/*
26
+** For a sufficiently large integer, provide an alternative
27
+** representation as MB or GB or TB.
28
+*/
29
+static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
30
+ if( v<100000 ){
31
+ sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
32
+ }else if( v<1000000000 ){
33
+ sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
34
+ v, (double)v/1000000.0);
35
+ }else{
36
+ sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
37
+ v, (double)v/1000000000.0);
38
+ }
39
+}
2440
2541
/*
2642
** WEBPAGE: stat
2743
**
2844
** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
4056
brief = P("brief")!=0;
4157
style_header("Repository Statistics");
4258
@ <table class="label-value">
4359
@ <tr><th>Repository&nbsp;Size:</th><td>
4460
fsize = file_size(g.zRepositoryName);
45
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize);
46
- @ %s(zBuf) bytes
61
+ bigSizeName(sizeof(zBuf), zBuf, fsize);
62
+ @ %s(zBuf)
4763
@ </td></tr>
4864
if( !brief ){
4965
@ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
5066
n = db_int(0, "SELECT count(*) FROM blob");
5167
m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
6076
db_step(&q);
6177
t = db_column_int64(&q, 0);
6278
szAvg = db_column_int(&q, 1);
6379
szMax = db_column_int(&q, 2);
6480
db_finalize(&q);
65
- sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
66
- @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total
81
+ bigSizeName(sizeof(zBuf), zBuf, t);
82
+ @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
6783
@ </td></tr>
6884
@ <tr><th>Compression&nbsp;Ratio:</th><td>
6985
if( t/fsize < 5 ){
7086
b = 10;
7187
fsize /= 10;
7288
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
19 **
20 */
21 #include <string.h>
22 #include "config.h"
23 #include "stat.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
25 /*
26 ** WEBPAGE: stat
27 **
28 ** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
40 brief = P("brief")!=0;
41 style_header("Repository Statistics");
42 @ <table class="label-value">
43 @ <tr><th>Repository&nbsp;Size:</th><td>
44 fsize = file_size(g.zRepositoryName);
45 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", fsize);
46 @ %s(zBuf) bytes
47 @ </td></tr>
48 if( !brief ){
49 @ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
50 n = db_int(0, "SELECT count(*) FROM blob");
51 m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
60 db_step(&q);
61 t = db_column_int64(&q, 0);
62 szAvg = db_column_int(&q, 1);
63 szMax = db_column_int(&q, 2);
64 db_finalize(&q);
65 sqlite3_snprintf(sizeof(zBuf), zBuf, "%lld", t);
66 @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) bytes total
67 @ </td></tr>
68 @ <tr><th>Compression&nbsp;Ratio:</th><td>
69 if( t/fsize < 5 ){
70 b = 10;
71 fsize /= 10;
72
--- src/stat.c
+++ src/stat.c
@@ -19,10 +19,26 @@
19 **
20 */
21 #include <string.h>
22 #include "config.h"
23 #include "stat.h"
24
25 /*
26 ** For a sufficiently large integer, provide an alternative
27 ** representation as MB or GB or TB.
28 */
29 static void bigSizeName(int nOut, char *zOut, sqlite3_int64 v){
30 if( v<100000 ){
31 sqlite3_snprintf(nOut, zOut, "%lld bytes", v);
32 }else if( v<1000000000 ){
33 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fMB)",
34 v, (double)v/1000000.0);
35 }else{
36 sqlite3_snprintf(nOut, zOut, "%lld bytes (%.1fGB)",
37 v, (double)v/1000000000.0);
38 }
39 }
40
41 /*
42 ** WEBPAGE: stat
43 **
44 ** Show statistics and global information about the repository.
@@ -40,12 +56,12 @@
56 brief = P("brief")!=0;
57 style_header("Repository Statistics");
58 @ <table class="label-value">
59 @ <tr><th>Repository&nbsp;Size:</th><td>
60 fsize = file_size(g.zRepositoryName);
61 bigSizeName(sizeof(zBuf), zBuf, fsize);
62 @ %s(zBuf)
63 @ </td></tr>
64 if( !brief ){
65 @ <tr><th>Number&nbsp;Of&nbsp;Artifacts:</th><td>
66 n = db_int(0, "SELECT count(*) FROM blob");
67 m = db_int(0, "SELECT count(*) FROM delta");
@@ -60,12 +76,12 @@
76 db_step(&q);
77 t = db_column_int64(&q, 0);
78 szAvg = db_column_int(&q, 1);
79 szMax = db_column_int(&q, 2);
80 db_finalize(&q);
81 bigSizeName(sizeof(zBuf), zBuf, t);
82 @ %d(szAvg) bytes average, %d(szMax) bytes max, %s(zBuf) total
83 @ </td></tr>
84 @ <tr><th>Compression&nbsp;Ratio:</th><td>
85 if( t/fsize < 5 ){
86 b = 10;
87 fsize /= 10;
88
+20 -14
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813813
814814
/*
815815
** WEBPAGE: style.css
816816
*/
817817
void page_style_css(void){
818
- const char *zCSS = 0;
818
+ Blob css;
819819
int i;
820820
821821
cgi_set_content_type("text/css");
822
- zCSS = db_get("css",(char*)zDefaultCSS);
823
- /* append user defined css */
824
- cgi_append_content(zCSS, -1);
822
+ blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
823
+
825824
/* add special missing definitions */
826
- for (i=1;cssDefaultList[i].elementClass;i++)
827
- if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828
- cgi_append_content("/* ", -1);
829
- cgi_append_content(cssDefaultList[i].comment, -1);
830
- cgi_append_content(" */\n", -1);
831
- cgi_append_content(cssDefaultList[i].elementClass, -1);
832
- cgi_append_content(" {\n", -1);
833
- cgi_append_content(cssDefaultList[i].value, -1);
834
- cgi_append_content("}\n\n", -1);
835
- }
825
+ for(i=1; cssDefaultList[i].elementClass; i++){
826
+ if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
827
+ blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
828
+ cssDefaultList[i].comment,
829
+ cssDefaultList[i].elementClass,
830
+ cssDefaultList[i].value);
831
+ }
832
+ }
833
+
834
+ /* Process through TH1 in order to give an opportunity to substitute
835
+ ** variables such as $baseurl.
836
+ */
837
+ Th_Store("baseurl", g.zBaseURL);
838
+ Th_Store("home", g.zTop);
839
+ Th_Render(blob_str(&css));
840
+
841
+ /* Tell CGI that the content returned by this page is considered cacheable */
836842
g.isConst = 1;
837843
}
838844
839845
/*
840846
** WEBPAGE: test_env
841847
842848
ADDED www/background.jpg
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
818 const char *zCSS = 0;
819 int i;
820
821 cgi_set_content_type("text/css");
822 zCSS = db_get("css",(char*)zDefaultCSS);
823 /* append user defined css */
824 cgi_append_content(zCSS, -1);
825 /* add special missing definitions */
826 for (i=1;cssDefaultList[i].elementClass;i++)
827 if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828 cgi_append_content("/* ", -1);
829 cgi_append_content(cssDefaultList[i].comment, -1);
830 cgi_append_content(" */\n", -1);
831 cgi_append_content(cssDefaultList[i].elementClass, -1);
832 cgi_append_content(" {\n", -1);
833 cgi_append_content(cssDefaultList[i].value, -1);
834 cgi_append_content("}\n\n", -1);
835 }
 
 
 
 
 
 
 
836 g.isConst = 1;
837 }
838
839 /*
840 ** WEBPAGE: test_env
841
842 DDED www/background.jpg
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
818 Blob css;
819 int i;
820
821 cgi_set_content_type("text/css");
822 blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
823
 
824 /* add special missing definitions */
825 for(i=1; cssDefaultList[i].elementClass; i++){
826 if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
827 blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
828 cssDefaultList[i].comment,
829 cssDefaultList[i].elementClass,
830 cssDefaultList[i].value);
831 }
832 }
833
834 /* Process through TH1 in order to give an opportunity to substitute
835 ** variables such as $baseurl.
836 */
837 Th_Store("baseurl", g.zBaseURL);
838 Th_Store("home", g.zTop);
839 Th_Render(blob_str(&css));
840
841 /* Tell CGI that the content returned by this page is considered cacheable */
842 g.isConst = 1;
843 }
844
845 /*
846 ** WEBPAGE: test_env
847
848 DDED www/background.jpg
+20 -14
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813813
814814
/*
815815
** WEBPAGE: style.css
816816
*/
817817
void page_style_css(void){
818
- const char *zCSS = 0;
818
+ Blob css;
819819
int i;
820820
821821
cgi_set_content_type("text/css");
822
- zCSS = db_get("css",(char*)zDefaultCSS);
823
- /* append user defined css */
824
- cgi_append_content(zCSS, -1);
822
+ blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
823
+
825824
/* add special missing definitions */
826
- for (i=1;cssDefaultList[i].elementClass;i++)
827
- if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828
- cgi_append_content("/* ", -1);
829
- cgi_append_content(cssDefaultList[i].comment, -1);
830
- cgi_append_content(" */\n", -1);
831
- cgi_append_content(cssDefaultList[i].elementClass, -1);
832
- cgi_append_content(" {\n", -1);
833
- cgi_append_content(cssDefaultList[i].value, -1);
834
- cgi_append_content("}\n\n", -1);
835
- }
825
+ for(i=1; cssDefaultList[i].elementClass; i++){
826
+ if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
827
+ blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
828
+ cssDefaultList[i].comment,
829
+ cssDefaultList[i].elementClass,
830
+ cssDefaultList[i].value);
831
+ }
832
+ }
833
+
834
+ /* Process through TH1 in order to give an opportunity to substitute
835
+ ** variables such as $baseurl.
836
+ */
837
+ Th_Store("baseurl", g.zBaseURL);
838
+ Th_Store("home", g.zTop);
839
+ Th_Render(blob_str(&css));
840
+
841
+ /* Tell CGI that the content returned by this page is considered cacheable */
836842
g.isConst = 1;
837843
}
838844
839845
/*
840846
** WEBPAGE: test_env
841847
842848
ADDED www/background.jpg
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
818 const char *zCSS = 0;
819 int i;
820
821 cgi_set_content_type("text/css");
822 zCSS = db_get("css",(char*)zDefaultCSS);
823 /* append user defined css */
824 cgi_append_content(zCSS, -1);
825 /* add special missing definitions */
826 for (i=1;cssDefaultList[i].elementClass;i++)
827 if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
828 cgi_append_content("/* ", -1);
829 cgi_append_content(cssDefaultList[i].comment, -1);
830 cgi_append_content(" */\n", -1);
831 cgi_append_content(cssDefaultList[i].elementClass, -1);
832 cgi_append_content(" {\n", -1);
833 cgi_append_content(cssDefaultList[i].value, -1);
834 cgi_append_content("}\n\n", -1);
835 }
 
 
 
 
 
 
 
836 g.isConst = 1;
837 }
838
839 /*
840 ** WEBPAGE: test_env
841
842 DDED www/background.jpg
--- src/style.c
+++ src/style.c
@@ -813,28 +813,34 @@
813
814 /*
815 ** WEBPAGE: style.css
816 */
817 void page_style_css(void){
818 Blob css;
819 int i;
820
821 cgi_set_content_type("text/css");
822 blob_init(&css, db_get("css",(char*)zDefaultCSS), -1);
823
 
824 /* add special missing definitions */
825 for(i=1; cssDefaultList[i].elementClass; i++){
826 if( strstr(blob_str(&css), cssDefaultList[i].elementClass)==0 ){
827 blob_appendf(&css, "/* %s */\n%s {\n%s}\n",
828 cssDefaultList[i].comment,
829 cssDefaultList[i].elementClass,
830 cssDefaultList[i].value);
831 }
832 }
833
834 /* Process through TH1 in order to give an opportunity to substitute
835 ** variables such as $baseurl.
836 */
837 Th_Store("baseurl", g.zBaseURL);
838 Th_Store("home", g.zTop);
839 Th_Render(blob_str(&css));
840
841 /* Tell CGI that the content returned by this page is considered cacheable */
842 g.isConst = 1;
843 }
844
845 /*
846 ** WEBPAGE: test_env
847
848 DDED www/background.jpg

Binary file

--- www/mkdownload.tcl
+++ www/mkdownload.tcl
@@ -4,24 +4,34 @@
44
# the fossil_download_checksums.html page.
55
#
66
#
77
set out [open download.html w]
88
puts $out \
9
-{<html>
9
+{<!DOCTYPE html><html>
1010
<head>
11
-<title>Fossil: Downloads</title>
11
+<title>Fossil: Timeline</title>
1212
<link rel="stylesheet" href="/fossil/style.css" type="text/css"
1313
media="screen">
1414
</head>
1515
<body>
1616
<div class="header">
1717
<div class="logo">
18
- <img src="/fossil/doc/tip/www/fossil_logo_small.gif" alt="logo">
18
+ <img src="/fossil/logo" alt="logo">
19
+ <br /><nobr>Fossil</nobr>
1920
</div>
21
+
2022
<div class="title">Fossil Downloads</div>
2123
</div>
22
-<div class="mainmenu"><a href='/fossil/doc/tip/www/index.wiki'>Home</a><a href='/fossil/timeline'>Timeline</a><a href='/fossil/brlist'>Branches</a><a href='/fossil/taglist'>Tags</a><a href='/fossil/reportlist'>Tickets</a><a href='/fossil/wiki'>Wiki</a><a href='/fossil/login'>Login</a></div>
24
+<div class="mainmenu">
25
+<a href='/fossil/doc/trunk/www/index.wiki'>Home</a>
26
+<a href='/fossil/timeline'>Timeline</a>
27
+<a href='/fossil/dir?ci=tip'>Files</a>
28
+<a href='/fossil/brlist'>Branches</a>
29
+<a href='/fossil/taglist'>Tags</a>
30
+<a href='/fossil/reportlist'>Tickets</a>
31
+<a href='/fossil/wiki'>Wiki</a>
32
+</div>
2333
<div class="content">
2434
<p>
2535
2636
<center><font size=4>
2737
<b>To install Fossil &rarr;</b> download the stand-alone executable
2838
--- www/mkdownload.tcl
+++ www/mkdownload.tcl
@@ -4,24 +4,34 @@
4 # the fossil_download_checksums.html page.
5 #
6 #
7 set out [open download.html w]
8 puts $out \
9 {<html>
10 <head>
11 <title>Fossil: Downloads</title>
12 <link rel="stylesheet" href="/fossil/style.css" type="text/css"
13 media="screen">
14 </head>
15 <body>
16 <div class="header">
17 <div class="logo">
18 <img src="/fossil/doc/tip/www/fossil_logo_small.gif" alt="logo">
 
19 </div>
 
20 <div class="title">Fossil Downloads</div>
21 </div>
22 <div class="mainmenu"><a href='/fossil/doc/tip/www/index.wiki'>Home</a><a href='/fossil/timeline'>Timeline</a><a href='/fossil/brlist'>Branches</a><a href='/fossil/taglist'>Tags</a><a href='/fossil/reportlist'>Tickets</a><a href='/fossil/wiki'>Wiki</a><a href='/fossil/login'>Login</a></div>
 
 
 
 
 
 
 
 
23 <div class="content">
24 <p>
25
26 <center><font size=4>
27 <b>To install Fossil &rarr;</b> download the stand-alone executable
28
--- www/mkdownload.tcl
+++ www/mkdownload.tcl
@@ -4,24 +4,34 @@
4 # the fossil_download_checksums.html page.
5 #
6 #
7 set out [open download.html w]
8 puts $out \
9 {<!DOCTYPE html><html>
10 <head>
11 <title>Fossil: Timeline</title>
12 <link rel="stylesheet" href="/fossil/style.css" type="text/css"
13 media="screen">
14 </head>
15 <body>
16 <div class="header">
17 <div class="logo">
18 <img src="/fossil/logo" alt="logo">
19 <br /><nobr>Fossil</nobr>
20 </div>
21
22 <div class="title">Fossil Downloads</div>
23 </div>
24 <div class="mainmenu">
25 <a href='/fossil/doc/trunk/www/index.wiki'>Home</a>
26 <a href='/fossil/timeline'>Timeline</a>
27 <a href='/fossil/dir?ci=tip'>Files</a>
28 <a href='/fossil/brlist'>Branches</a>
29 <a href='/fossil/taglist'>Tags</a>
30 <a href='/fossil/reportlist'>Tickets</a>
31 <a href='/fossil/wiki'>Wiki</a>
32 </div>
33 <div class="content">
34 <p>
35
36 <center><font size=4>
37 <b>To install Fossil &rarr;</b> download the stand-alone executable
38

Keyboard Shortcuts

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