Fossil SCM

Merge the optimizations into trunk.

drh 2012-10-26 20:33 trunk merge
Commit 09681e17bb7cb60fa16976f891592752acaf5b03
+50 -53
--- src/shell.c
+++ src/shell.c
@@ -2822,25 +2822,28 @@
28222822
*/
28232823
static const char zOptions[] =
28242824
" -bail stop after hitting an error\n"
28252825
" -batch force batch I/O\n"
28262826
" -column set output mode to 'column'\n"
2827
- " -cmd command run \"command\" before reading stdin\n"
2827
+ " -cmd COMMAND run \"COMMAND\" before reading stdin\n"
28282828
" -csv set output mode to 'csv'\n"
28292829
" -echo print commands before execution\n"
2830
- " -init filename read/process named file\n"
2830
+ " -init FILENAME read/process named file\n"
28312831
" -[no]header turn headers on or off\n"
2832
+#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
2833
+ " -heap SIZE Size of heap for memsys3 or memsys5\n"
2834
+#endif
28322835
" -help show this message\n"
28332836
" -html set output mode to HTML\n"
28342837
" -interactive force interactive I/O\n"
28352838
" -line set output mode to 'line'\n"
28362839
" -list set output mode to 'list'\n"
28372840
#ifdef SQLITE_ENABLE_MULTIPLEX
28382841
" -multiplex enable the multiplexor VFS\n"
28392842
#endif
2840
- " -nullvalue 'text' set text string for NULL values\n"
2841
- " -separator 'x' set output field separator (|)\n"
2843
+ " -nullvalue TEXT set text string for NULL values. Default ''\n"
2844
+ " -separator SEP set output field separator. Default: '|'\n"
28422845
" -stats print memory stats before each finalize\n"
28432846
" -version show SQLite version\n"
28442847
" -vfs NAME use NAME as the default VFS\n"
28452848
#ifdef SQLITE_ENABLE_VFSTRACE
28462849
" -vfstrace enable tracing of all VFS calls\n"
@@ -2871,10 +2874,23 @@
28712874
sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
28722875
sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
28732876
sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
28742877
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
28752878
}
2879
+
2880
+/*
2881
+** Get the argument to an --option. Throw an error and die if no argument
2882
+** is available.
2883
+*/
2884
+static char *cmdline_option_value(int argc, char **argv, int i){
2885
+ if( i==argc ){
2886
+ fprintf(stderr, "%s: Error: missing argument to %s\n",
2887
+ argv[0], argv[argc-1]);
2888
+ exit(1);
2889
+ }
2890
+ return argv[i];
2891
+}
28762892
28772893
int main(int argc, char **argv){
28782894
char *zErrMsg = 0;
28792895
struct callback_data data;
28802896
const char *zInitFile = 0;
@@ -2901,36 +2917,47 @@
29012917
/* Do an initial pass through the command-line argument to locate
29022918
** the name of the database file, the name of the initialization file,
29032919
** the size of the alternative malloc heap,
29042920
** and the first command to execute.
29052921
*/
2906
- for(i=1; i<argc-1; i++){
2922
+ for(i=1; i<argc; i++){
29072923
char *z;
2908
- if( argv[i][0]!='-' ) break;
29092924
z = argv[i];
2925
+ if( z[0]!='-' ){
2926
+ if( data.zDbFilename==0 ){
2927
+ data.zDbFilename = z;
2928
+ continue;
2929
+ }
2930
+ if( zFirstCmd==0 ){
2931
+ zFirstCmd = z;
2932
+ continue;
2933
+ }
2934
+ fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
2935
+ fprintf(stderr,"Use -help for a list of options.\n");
2936
+ return 1;
2937
+ }
29102938
if( z[1]=='-' ) z++;
29112939
if( strcmp(z,"-separator")==0
29122940
|| strcmp(z,"-nullvalue")==0
29132941
|| strcmp(z,"-cmd")==0
29142942
){
2915
- i++;
2943
+ (void)cmdline_option_value(argc, argv, ++i);
29162944
}else if( strcmp(z,"-init")==0 ){
2917
- i++;
2918
- zInitFile = argv[i];
2919
- /* Need to check for batch mode here to so we can avoid printing
2920
- ** informational messages (like from process_sqliterc) before
2921
- ** we do the actual processing of arguments later in a second pass.
2922
- */
2945
+ zInitFile = cmdline_option_value(argc, argv, ++i);
29232946
}else if( strcmp(z,"-batch")==0 ){
2947
+ /* Need to check for batch mode here to so we can avoid printing
2948
+ ** informational messages (like from process_sqliterc) before
2949
+ ** we do the actual processing of arguments later in a second pass.
2950
+ */
29242951
stdin_is_interactive = 0;
29252952
}else if( strcmp(z,"-heap")==0 ){
29262953
#if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
29272954
int j, c;
29282955
const char *zSize;
29292956
sqlite3_int64 szHeap;
29302957
2931
- zSize = argv[++i];
2958
+ zSize = cmdline_option_value(argc, argv, ++i);
29322959
szHeap = atoi(zSize);
29332960
for(j=0; (c = zSize[j])!=0; j++){
29342961
if( c=='M' ){ szHeap *= 1000000; break; }
29352962
if( c=='K' ){ szHeap *= 1000; break; }
29362963
if( c=='G' ){ szHeap *= 1000000000; break; }
@@ -2953,51 +2980,35 @@
29532980
}else if( strcmp(z,"-multiplex")==0 ){
29542981
extern int sqlite3_multiple_initialize(const char*,int);
29552982
sqlite3_multiplex_initialize(0, 1);
29562983
#endif
29572984
}else if( strcmp(z,"-vfs")==0 ){
2958
- sqlite3_vfs *pVfs = sqlite3_vfs_find(argv[++i]);
2985
+ sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
29592986
if( pVfs ){
29602987
sqlite3_vfs_register(pVfs, 1);
29612988
}else{
29622989
fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]);
29632990
exit(1);
29642991
}
29652992
}
29662993
}
2967
- if( i<argc ){
2968
- data.zDbFilename = argv[i++];
2969
- }else{
2994
+ if( data.zDbFilename==0 ){
29702995
#ifndef SQLITE_OMIT_MEMORYDB
29712996
data.zDbFilename = ":memory:";
29722997
#else
2973
- data.zDbFilename = 0;
2998
+ fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
2999
+ return 1;
29743000
#endif
29753001
/***** Begin Fossil Patch *****/
29763002
{
29773003
extern void fossil_open(const char **);
29783004
fossil_open(&data.zDbFilename);
29793005
}
29803006
/***** End Fossil Patch *****/
29813007
}
2982
- if( i<argc ){
2983
- zFirstCmd = argv[i++];
2984
- }
2985
- if( i<argc ){
2986
- fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
2987
- fprintf(stderr,"Use -help for a list of options.\n");
2988
- return 1;
2989
- }
29903008
data.out = stdout;
29913009
2992
-#ifdef SQLITE_OMIT_MEMORYDB
2993
- if( data.zDbFilename==0 ){
2994
- fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
2995
- return 1;
2996
- }
2997
-#endif
2998
-
29993010
/* Go ahead and open the database file if it already exists. If the
30003011
** file does not exist, delay opening it. This prevents empty database
30013012
** files from being created if a user mistypes the database name argument
30023013
** to the sqlite command-line tool.
30033014
*/
@@ -3017,12 +3028,13 @@
30173028
/* Make a second pass through the command-line argument and set
30183029
** options. This second pass is delayed until after the initialization
30193030
** file is processed so that the command-line arguments will override
30203031
** settings in the initialization file.
30213032
*/
3022
- for(i=1; i<argc && argv[i][0]=='-'; i++){
3033
+ for(i=1; i<argc; i++){
30233034
char *z = argv[i];
3035
+ if( z[0]!='-' ) continue;
30243036
if( z[1]=='-' ){ z++; }
30253037
if( strcmp(z,"-init")==0 ){
30263038
i++;
30273039
}else if( strcmp(z,"-html")==0 ){
30283040
data.mode = MODE_Html;
@@ -3034,29 +3046,15 @@
30343046
data.mode = MODE_Column;
30353047
}else if( strcmp(z,"-csv")==0 ){
30363048
data.mode = MODE_Csv;
30373049
memcpy(data.separator,",",2);
30383050
}else if( strcmp(z,"-separator")==0 ){
3039
- i++;
3040
- if(i>=argc){
3041
- fprintf(stderr,"%s: Error: missing argument for option: %s\n",
3042
- Argv0, z);
3043
- fprintf(stderr,"Use -help for a list of options.\n");
3044
- return 1;
3045
- }
30463051
sqlite3_snprintf(sizeof(data.separator), data.separator,
3047
- "%.*s",(int)sizeof(data.separator)-1,argv[i]);
3052
+ "%s",cmdline_option_value(argc,argv,++i));
30483053
}else if( strcmp(z,"-nullvalue")==0 ){
3049
- i++;
3050
- if(i>=argc){
3051
- fprintf(stderr,"%s: Error: missing argument for option: %s\n",
3052
- Argv0, z);
3053
- fprintf(stderr,"Use -help for a list of options.\n");
3054
- return 1;
3055
- }
30563054
sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
3057
- "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
3055
+ "%s",cmdline_option_value(argc,argv,++i));
30583056
}else if( strcmp(z,"-header")==0 ){
30593057
data.showHeader = 1;
30603058
}else if( strcmp(z,"-noheader")==0 ){
30613059
data.showHeader = 0;
30623060
}else if( strcmp(z,"-echo")==0 ){
@@ -3086,12 +3084,11 @@
30863084
#endif
30873085
}else if( strcmp(z,"-help")==0 ){
30883086
usage(1);
30893087
}else if( strcmp(z,"-cmd")==0 ){
30903088
if( i==argc-1 ) break;
3091
- i++;
3092
- z = argv[i];
3089
+ z = cmdline_option_value(argc,argv,++i);
30933090
if( z[0]=='.' ){
30943091
rc = do_meta_command(z, &data);
30953092
if( rc && bail_on_error ) return rc;
30963093
}else{
30973094
open_db(&data);
30983095
--- src/shell.c
+++ src/shell.c
@@ -2822,25 +2822,28 @@
2822 */
2823 static const char zOptions[] =
2824 " -bail stop after hitting an error\n"
2825 " -batch force batch I/O\n"
2826 " -column set output mode to 'column'\n"
2827 " -cmd command run \"command\" before reading stdin\n"
2828 " -csv set output mode to 'csv'\n"
2829 " -echo print commands before execution\n"
2830 " -init filename read/process named file\n"
2831 " -[no]header turn headers on or off\n"
 
 
 
2832 " -help show this message\n"
2833 " -html set output mode to HTML\n"
2834 " -interactive force interactive I/O\n"
2835 " -line set output mode to 'line'\n"
2836 " -list set output mode to 'list'\n"
2837 #ifdef SQLITE_ENABLE_MULTIPLEX
2838 " -multiplex enable the multiplexor VFS\n"
2839 #endif
2840 " -nullvalue 'text' set text string for NULL values\n"
2841 " -separator 'x' set output field separator (|)\n"
2842 " -stats print memory stats before each finalize\n"
2843 " -version show SQLite version\n"
2844 " -vfs NAME use NAME as the default VFS\n"
2845 #ifdef SQLITE_ENABLE_VFSTRACE
2846 " -vfstrace enable tracing of all VFS calls\n"
@@ -2871,10 +2874,23 @@
2871 sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
2872 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
2873 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
2874 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
2875 }
 
 
 
 
 
 
 
 
 
 
 
 
 
2876
2877 int main(int argc, char **argv){
2878 char *zErrMsg = 0;
2879 struct callback_data data;
2880 const char *zInitFile = 0;
@@ -2901,36 +2917,47 @@
2901 /* Do an initial pass through the command-line argument to locate
2902 ** the name of the database file, the name of the initialization file,
2903 ** the size of the alternative malloc heap,
2904 ** and the first command to execute.
2905 */
2906 for(i=1; i<argc-1; i++){
2907 char *z;
2908 if( argv[i][0]!='-' ) break;
2909 z = argv[i];
 
 
 
 
 
 
 
 
 
 
 
 
 
2910 if( z[1]=='-' ) z++;
2911 if( strcmp(z,"-separator")==0
2912 || strcmp(z,"-nullvalue")==0
2913 || strcmp(z,"-cmd")==0
2914 ){
2915 i++;
2916 }else if( strcmp(z,"-init")==0 ){
2917 i++;
2918 zInitFile = argv[i];
2919 /* Need to check for batch mode here to so we can avoid printing
2920 ** informational messages (like from process_sqliterc) before
2921 ** we do the actual processing of arguments later in a second pass.
2922 */
2923 }else if( strcmp(z,"-batch")==0 ){
 
 
 
 
2924 stdin_is_interactive = 0;
2925 }else if( strcmp(z,"-heap")==0 ){
2926 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
2927 int j, c;
2928 const char *zSize;
2929 sqlite3_int64 szHeap;
2930
2931 zSize = argv[++i];
2932 szHeap = atoi(zSize);
2933 for(j=0; (c = zSize[j])!=0; j++){
2934 if( c=='M' ){ szHeap *= 1000000; break; }
2935 if( c=='K' ){ szHeap *= 1000; break; }
2936 if( c=='G' ){ szHeap *= 1000000000; break; }
@@ -2953,51 +2980,35 @@
2953 }else if( strcmp(z,"-multiplex")==0 ){
2954 extern int sqlite3_multiple_initialize(const char*,int);
2955 sqlite3_multiplex_initialize(0, 1);
2956 #endif
2957 }else if( strcmp(z,"-vfs")==0 ){
2958 sqlite3_vfs *pVfs = sqlite3_vfs_find(argv[++i]);
2959 if( pVfs ){
2960 sqlite3_vfs_register(pVfs, 1);
2961 }else{
2962 fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]);
2963 exit(1);
2964 }
2965 }
2966 }
2967 if( i<argc ){
2968 data.zDbFilename = argv[i++];
2969 }else{
2970 #ifndef SQLITE_OMIT_MEMORYDB
2971 data.zDbFilename = ":memory:";
2972 #else
2973 data.zDbFilename = 0;
 
2974 #endif
2975 /***** Begin Fossil Patch *****/
2976 {
2977 extern void fossil_open(const char **);
2978 fossil_open(&data.zDbFilename);
2979 }
2980 /***** End Fossil Patch *****/
2981 }
2982 if( i<argc ){
2983 zFirstCmd = argv[i++];
2984 }
2985 if( i<argc ){
2986 fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
2987 fprintf(stderr,"Use -help for a list of options.\n");
2988 return 1;
2989 }
2990 data.out = stdout;
2991
2992 #ifdef SQLITE_OMIT_MEMORYDB
2993 if( data.zDbFilename==0 ){
2994 fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
2995 return 1;
2996 }
2997 #endif
2998
2999 /* Go ahead and open the database file if it already exists. If the
3000 ** file does not exist, delay opening it. This prevents empty database
3001 ** files from being created if a user mistypes the database name argument
3002 ** to the sqlite command-line tool.
3003 */
@@ -3017,12 +3028,13 @@
3017 /* Make a second pass through the command-line argument and set
3018 ** options. This second pass is delayed until after the initialization
3019 ** file is processed so that the command-line arguments will override
3020 ** settings in the initialization file.
3021 */
3022 for(i=1; i<argc && argv[i][0]=='-'; i++){
3023 char *z = argv[i];
 
3024 if( z[1]=='-' ){ z++; }
3025 if( strcmp(z,"-init")==0 ){
3026 i++;
3027 }else if( strcmp(z,"-html")==0 ){
3028 data.mode = MODE_Html;
@@ -3034,29 +3046,15 @@
3034 data.mode = MODE_Column;
3035 }else if( strcmp(z,"-csv")==0 ){
3036 data.mode = MODE_Csv;
3037 memcpy(data.separator,",",2);
3038 }else if( strcmp(z,"-separator")==0 ){
3039 i++;
3040 if(i>=argc){
3041 fprintf(stderr,"%s: Error: missing argument for option: %s\n",
3042 Argv0, z);
3043 fprintf(stderr,"Use -help for a list of options.\n");
3044 return 1;
3045 }
3046 sqlite3_snprintf(sizeof(data.separator), data.separator,
3047 "%.*s",(int)sizeof(data.separator)-1,argv[i]);
3048 }else if( strcmp(z,"-nullvalue")==0 ){
3049 i++;
3050 if(i>=argc){
3051 fprintf(stderr,"%s: Error: missing argument for option: %s\n",
3052 Argv0, z);
3053 fprintf(stderr,"Use -help for a list of options.\n");
3054 return 1;
3055 }
3056 sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
3057 "%.*s",(int)sizeof(data.nullvalue)-1,argv[i]);
3058 }else if( strcmp(z,"-header")==0 ){
3059 data.showHeader = 1;
3060 }else if( strcmp(z,"-noheader")==0 ){
3061 data.showHeader = 0;
3062 }else if( strcmp(z,"-echo")==0 ){
@@ -3086,12 +3084,11 @@
3086 #endif
3087 }else if( strcmp(z,"-help")==0 ){
3088 usage(1);
3089 }else if( strcmp(z,"-cmd")==0 ){
3090 if( i==argc-1 ) break;
3091 i++;
3092 z = argv[i];
3093 if( z[0]=='.' ){
3094 rc = do_meta_command(z, &data);
3095 if( rc && bail_on_error ) return rc;
3096 }else{
3097 open_db(&data);
3098
--- src/shell.c
+++ src/shell.c
@@ -2822,25 +2822,28 @@
2822 */
2823 static const char zOptions[] =
2824 " -bail stop after hitting an error\n"
2825 " -batch force batch I/O\n"
2826 " -column set output mode to 'column'\n"
2827 " -cmd COMMAND run \"COMMAND\" before reading stdin\n"
2828 " -csv set output mode to 'csv'\n"
2829 " -echo print commands before execution\n"
2830 " -init FILENAME read/process named file\n"
2831 " -[no]header turn headers on or off\n"
2832 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
2833 " -heap SIZE Size of heap for memsys3 or memsys5\n"
2834 #endif
2835 " -help show this message\n"
2836 " -html set output mode to HTML\n"
2837 " -interactive force interactive I/O\n"
2838 " -line set output mode to 'line'\n"
2839 " -list set output mode to 'list'\n"
2840 #ifdef SQLITE_ENABLE_MULTIPLEX
2841 " -multiplex enable the multiplexor VFS\n"
2842 #endif
2843 " -nullvalue TEXT set text string for NULL values. Default ''\n"
2844 " -separator SEP set output field separator. Default: '|'\n"
2845 " -stats print memory stats before each finalize\n"
2846 " -version show SQLite version\n"
2847 " -vfs NAME use NAME as the default VFS\n"
2848 #ifdef SQLITE_ENABLE_VFSTRACE
2849 " -vfstrace enable tracing of all VFS calls\n"
@@ -2871,10 +2874,23 @@
2874 sqlite3_config(SQLITE_CONFIG_LOG, shellLog, data);
2875 sqlite3_snprintf(sizeof(mainPrompt), mainPrompt,"sqlite> ");
2876 sqlite3_snprintf(sizeof(continuePrompt), continuePrompt," ...> ");
2877 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
2878 }
2879
2880 /*
2881 ** Get the argument to an --option. Throw an error and die if no argument
2882 ** is available.
2883 */
2884 static char *cmdline_option_value(int argc, char **argv, int i){
2885 if( i==argc ){
2886 fprintf(stderr, "%s: Error: missing argument to %s\n",
2887 argv[0], argv[argc-1]);
2888 exit(1);
2889 }
2890 return argv[i];
2891 }
2892
2893 int main(int argc, char **argv){
2894 char *zErrMsg = 0;
2895 struct callback_data data;
2896 const char *zInitFile = 0;
@@ -2901,36 +2917,47 @@
2917 /* Do an initial pass through the command-line argument to locate
2918 ** the name of the database file, the name of the initialization file,
2919 ** the size of the alternative malloc heap,
2920 ** and the first command to execute.
2921 */
2922 for(i=1; i<argc; i++){
2923 char *z;
 
2924 z = argv[i];
2925 if( z[0]!='-' ){
2926 if( data.zDbFilename==0 ){
2927 data.zDbFilename = z;
2928 continue;
2929 }
2930 if( zFirstCmd==0 ){
2931 zFirstCmd = z;
2932 continue;
2933 }
2934 fprintf(stderr,"%s: Error: too many options: \"%s\"\n", Argv0, argv[i]);
2935 fprintf(stderr,"Use -help for a list of options.\n");
2936 return 1;
2937 }
2938 if( z[1]=='-' ) z++;
2939 if( strcmp(z,"-separator")==0
2940 || strcmp(z,"-nullvalue")==0
2941 || strcmp(z,"-cmd")==0
2942 ){
2943 (void)cmdline_option_value(argc, argv, ++i);
2944 }else if( strcmp(z,"-init")==0 ){
2945 zInitFile = cmdline_option_value(argc, argv, ++i);
 
 
 
 
 
2946 }else if( strcmp(z,"-batch")==0 ){
2947 /* Need to check for batch mode here to so we can avoid printing
2948 ** informational messages (like from process_sqliterc) before
2949 ** we do the actual processing of arguments later in a second pass.
2950 */
2951 stdin_is_interactive = 0;
2952 }else if( strcmp(z,"-heap")==0 ){
2953 #if defined(SQLITE_ENABLE_MEMSYS3) || defined(SQLITE_ENABLE_MEMSYS5)
2954 int j, c;
2955 const char *zSize;
2956 sqlite3_int64 szHeap;
2957
2958 zSize = cmdline_option_value(argc, argv, ++i);
2959 szHeap = atoi(zSize);
2960 for(j=0; (c = zSize[j])!=0; j++){
2961 if( c=='M' ){ szHeap *= 1000000; break; }
2962 if( c=='K' ){ szHeap *= 1000; break; }
2963 if( c=='G' ){ szHeap *= 1000000000; break; }
@@ -2953,51 +2980,35 @@
2980 }else if( strcmp(z,"-multiplex")==0 ){
2981 extern int sqlite3_multiple_initialize(const char*,int);
2982 sqlite3_multiplex_initialize(0, 1);
2983 #endif
2984 }else if( strcmp(z,"-vfs")==0 ){
2985 sqlite3_vfs *pVfs = sqlite3_vfs_find(cmdline_option_value(argc,argv,++i));
2986 if( pVfs ){
2987 sqlite3_vfs_register(pVfs, 1);
2988 }else{
2989 fprintf(stderr, "no such VFS: \"%s\"\n", argv[i]);
2990 exit(1);
2991 }
2992 }
2993 }
2994 if( data.zDbFilename==0 ){
 
 
2995 #ifndef SQLITE_OMIT_MEMORYDB
2996 data.zDbFilename = ":memory:";
2997 #else
2998 fprintf(stderr,"%s: Error: no database filename specified\n", Argv0);
2999 return 1;
3000 #endif
3001 /***** Begin Fossil Patch *****/
3002 {
3003 extern void fossil_open(const char **);
3004 fossil_open(&data.zDbFilename);
3005 }
3006 /***** End Fossil Patch *****/
3007 }
 
 
 
 
 
 
 
 
3008 data.out = stdout;
3009
 
 
 
 
 
 
 
3010 /* Go ahead and open the database file if it already exists. If the
3011 ** file does not exist, delay opening it. This prevents empty database
3012 ** files from being created if a user mistypes the database name argument
3013 ** to the sqlite command-line tool.
3014 */
@@ -3017,12 +3028,13 @@
3028 /* Make a second pass through the command-line argument and set
3029 ** options. This second pass is delayed until after the initialization
3030 ** file is processed so that the command-line arguments will override
3031 ** settings in the initialization file.
3032 */
3033 for(i=1; i<argc; i++){
3034 char *z = argv[i];
3035 if( z[0]!='-' ) continue;
3036 if( z[1]=='-' ){ z++; }
3037 if( strcmp(z,"-init")==0 ){
3038 i++;
3039 }else if( strcmp(z,"-html")==0 ){
3040 data.mode = MODE_Html;
@@ -3034,29 +3046,15 @@
3046 data.mode = MODE_Column;
3047 }else if( strcmp(z,"-csv")==0 ){
3048 data.mode = MODE_Csv;
3049 memcpy(data.separator,",",2);
3050 }else if( strcmp(z,"-separator")==0 ){
 
 
 
 
 
 
 
3051 sqlite3_snprintf(sizeof(data.separator), data.separator,
3052 "%s",cmdline_option_value(argc,argv,++i));
3053 }else if( strcmp(z,"-nullvalue")==0 ){
 
 
 
 
 
 
 
3054 sqlite3_snprintf(sizeof(data.nullvalue), data.nullvalue,
3055 "%s",cmdline_option_value(argc,argv,++i));
3056 }else if( strcmp(z,"-header")==0 ){
3057 data.showHeader = 1;
3058 }else if( strcmp(z,"-noheader")==0 ){
3059 data.showHeader = 0;
3060 }else if( strcmp(z,"-echo")==0 ){
@@ -3086,12 +3084,11 @@
3084 #endif
3085 }else if( strcmp(z,"-help")==0 ){
3086 usage(1);
3087 }else if( strcmp(z,"-cmd")==0 ){
3088 if( i==argc-1 ) break;
3089 z = cmdline_option_value(argc,argv,++i);
 
3090 if( z[0]=='.' ){
3091 rc = do_meta_command(z, &data);
3092 if( rc && bail_on_error ) return rc;
3093 }else{
3094 open_db(&data);
3095
+265 -121
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673673
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674674
** [sqlite_version()] and [sqlite_source_id()].
675675
*/
676676
#define SQLITE_VERSION "3.7.15"
677677
#define SQLITE_VERSION_NUMBER 3007015
678
-#define SQLITE_SOURCE_ID "2012-10-09 01:39:25 01dc032b5bbd9c9ebb1965f176ca5d732cda85ea"
678
+#define SQLITE_SOURCE_ID "2012-10-26 19:22:45 e24ba5bee4424e99d0859ef652164ae1397a2378"
679679
680680
/*
681681
** CAPI3REF: Run-Time Library Version Numbers
682682
** KEYWORDS: sqlite3_version, sqlite3_sourceid
683683
**
@@ -8439,10 +8439,12 @@
84398439
SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);
84408440
84418441
SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
84428442
SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
84438443
8444
+SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);
8445
+
84448446
/*
84458447
** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
84468448
** should be one of the following values. The integer values are assigned
84478449
** to constants so that the offset of the corresponding field in an
84488450
** SQLite database header may be found using the following formula:
@@ -8953,11 +8955,11 @@
89538955
SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
89548956
SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
89558957
SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);
89568958
SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
89578959
SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
8958
-SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*);
8960
+SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
89598961
SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
89608962
SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
89618963
SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
89628964
SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
89638965
#ifdef SQLITE_DEBUG
@@ -9143,15 +9145,18 @@
91439145
SQLITE_PRIVATE int sqlite3PagerRollback(Pager*);
91449146
SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
91459147
SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
91469148
SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
91479149
9148
-SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
9149
-SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
9150
-SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
9151
-SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
9152
-SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
9150
+#ifndef SQLITE_OMIT_WAL
9151
+SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
9152
+SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
9153
+SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
9154
+SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
9155
+SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
9156
+#endif
9157
+
91539158
#ifdef SQLITE_ENABLE_ZIPVFS
91549159
SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
91559160
#endif
91569161
91579162
/* Functions used to query pager state and configuration. */
@@ -12220,12 +12225,14 @@
1222012225
SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
1222112226
SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
1222212227
SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
1222312228
SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
1222412229
SQLITE_PRIVATE const char *sqlite3JournalModename(int);
12225
-SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
12226
-SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
12230
+#ifndef SQLITE_OMIT_WAL
12231
+SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
12232
+SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
12233
+#endif
1222712234
1222812235
/* Declarations for functions in fkey.c. All of these are replaced by
1222912236
** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
1223012237
** key functionality is available. If OMIT_TRIGGER is defined but
1223112238
** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
@@ -13704,11 +13711,11 @@
1370413711
struct Vdbe *pVdbe; /* Used to iterate through VMs */
1370513712
int nByte = 0; /* Used to accumulate return value */
1370613713
1370713714
db->pnBytesFreed = &nByte;
1370813715
for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){
13709
- sqlite3VdbeDeleteObject(db, pVdbe);
13716
+ sqlite3VdbeClearObject(db, pVdbe);
1371013717
}
1371113718
db->pnBytesFreed = 0;
1371213719
1371313720
*pHighwater = 0;
1371413721
*pCurrent = nByte;
@@ -22374,11 +22381,11 @@
2237422381
pEntry->count--;
2237522382
assert( pEntry->count>=0 );
2237622383
}
2237722384
sqlite3_free( elem );
2237822385
pH->count--;
22379
- if( pH->count<=0 ){
22386
+ if( pH->count==0 ){
2238022387
assert( pH->first==0 );
2238122388
assert( pH->count==0 );
2238222389
sqlite3HashClear(pH);
2238322390
}
2238422391
}
@@ -22844,10 +22851,14 @@
2284422851
void *lockingContext; /* Locking style specific state */
2284522852
UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
2284622853
const char *zPath; /* Name of the file */
2284722854
unixShm *pShm; /* Shared memory segment information */
2284822855
int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
22856
+#ifdef __QNXNTO__
22857
+ int sectorSize; /* Device sector size */
22858
+ int deviceCharacteristics; /* Precomputed device characteristics */
22859
+#endif
2284922860
#if SQLITE_ENABLE_LOCKING_STYLE
2285022861
int openFlags; /* The flags specified at open() */
2285122862
#endif
2285222863
#if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
2285322864
unsigned fsFlags; /* cached details from statfs() */
@@ -24920,17 +24931,17 @@
2492024931
2492124932
/*
2492224933
** Close a file. Make sure the lock has been released before closing.
2492324934
*/
2492424935
static int dotlockClose(sqlite3_file *id) {
24925
- int rc;
24936
+ int rc = SQLITE_OK;
2492624937
if( id ){
2492724938
unixFile *pFile = (unixFile*)id;
2492824939
dotlockUnlock(id, NO_LOCK);
2492924940
sqlite3_free(pFile->lockingContext);
24941
+ rc = closeUnixFile(id);
2493024942
}
24931
- rc = closeUnixFile(id);
2493224943
return rc;
2493324944
}
2493424945
/****************** End of the dot-file lock implementation *******************
2493524946
******************************************************************************/
2493624947
@@ -25130,14 +25141,16 @@
2513025141
2513125142
/*
2513225143
** Close a file.
2513325144
*/
2513425145
static int flockClose(sqlite3_file *id) {
25146
+ int rc = SQLITE_OK;
2513525147
if( id ){
2513625148
flockUnlock(id, NO_LOCK);
25149
+ rc = closeUnixFile(id);
2513725150
}
25138
- return closeUnixFile(id);
25151
+ return rc;
2513925152
}
2514025153
2514125154
#endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */
2514225155
2514325156
/******************* End of the flock lock implementation *********************
@@ -26470,14 +26483,96 @@
2647026483
** SQLite code assumes this function cannot fail. It also assumes that
2647126484
** if two files are created in the same file-system directory (i.e.
2647226485
** a database and its journal file) that the sector size will be the
2647326486
** same for both.
2647426487
*/
26475
-static int unixSectorSize(sqlite3_file *pFile){
26476
- (void)pFile;
26488
+#ifndef __QNXNTO__
26489
+static int unixSectorSize(sqlite3_file *NotUsed){
26490
+ UNUSED_PARAMETER(NotUsed);
2647726491
return SQLITE_DEFAULT_SECTOR_SIZE;
2647826492
}
26493
+#endif
26494
+
26495
+/*
26496
+** The following version of unixSectorSize() is optimized for QNX.
26497
+*/
26498
+#ifdef __QNXNTO__
26499
+#include <sys/dcmd_blk.h>
26500
+#include <sys/statvfs.h>
26501
+static int unixSectorSize(sqlite3_file *id){
26502
+ unixFile *pFile = (unixFile*)id;
26503
+ if( pFile->sectorSize == 0 ){
26504
+ struct statvfs fsInfo;
26505
+
26506
+ /* Set defaults for non-supported filesystems */
26507
+ pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
26508
+ pFile->deviceCharacteristics = 0;
26509
+ if( fstatvfs(pFile->h, &fsInfo) == -1 ) {
26510
+ return pFile->sectorSize;
26511
+ }
26512
+
26513
+ if( !strcmp(fsInfo.f_basetype, "tmp") ) {
26514
+ pFile->sectorSize = fsInfo.f_bsize;
26515
+ pFile->deviceCharacteristics =
26516
+ SQLITE_IOCAP_ATOMIC4K | /* All ram filesystem writes are atomic */
26517
+ SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26518
+ ** the write succeeds */
26519
+ SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26520
+ ** so it is ordered */
26521
+ 0;
26522
+ }else if( strstr(fsInfo.f_basetype, "etfs") ){
26523
+ pFile->sectorSize = fsInfo.f_bsize;
26524
+ pFile->deviceCharacteristics =
26525
+ /* etfs cluster size writes are atomic */
26526
+ (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |
26527
+ SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26528
+ ** the write succeeds */
26529
+ SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26530
+ ** so it is ordered */
26531
+ 0;
26532
+ }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){
26533
+ pFile->sectorSize = fsInfo.f_bsize;
26534
+ pFile->deviceCharacteristics =
26535
+ SQLITE_IOCAP_ATOMIC | /* All filesystem writes are atomic */
26536
+ SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26537
+ ** the write succeeds */
26538
+ SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26539
+ ** so it is ordered */
26540
+ 0;
26541
+ }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){
26542
+ pFile->sectorSize = fsInfo.f_bsize;
26543
+ pFile->deviceCharacteristics =
26544
+ /* full bitset of atomics from max sector size and smaller */
26545
+ ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
26546
+ SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26547
+ ** so it is ordered */
26548
+ 0;
26549
+ }else if( strstr(fsInfo.f_basetype, "dos") ){
26550
+ pFile->sectorSize = fsInfo.f_bsize;
26551
+ pFile->deviceCharacteristics =
26552
+ /* full bitset of atomics from max sector size and smaller */
26553
+ ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
26554
+ SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26555
+ ** so it is ordered */
26556
+ 0;
26557
+ }else{
26558
+ pFile->deviceCharacteristics =
26559
+ SQLITE_IOCAP_ATOMIC512 | /* blocks are atomic */
26560
+ SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26561
+ ** the write succeeds */
26562
+ 0;
26563
+ }
26564
+ }
26565
+ /* Last chance verification. If the sector size isn't a multiple of 512
26566
+ ** then it isn't valid.*/
26567
+ if( pFile->sectorSize % 512 != 0 ){
26568
+ pFile->deviceCharacteristics = 0;
26569
+ pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
26570
+ }
26571
+ return pFile->sectorSize;
26572
+}
26573
+#endif /* __QNXNTO__ */
2647926574
2648026575
/*
2648126576
** Return the device characteristics for the file.
2648226577
**
2648326578
** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.
@@ -26490,15 +26585,19 @@
2649026585
** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control
2649126586
** available to turn it off and URI query parameter available to turn it off.
2649226587
*/
2649326588
static int unixDeviceCharacteristics(sqlite3_file *id){
2649426589
unixFile *p = (unixFile*)id;
26590
+ int rc = 0;
26591
+#ifdef __QNXNTO__
26592
+ if( p->sectorSize==0 ) unixSectorSize(id);
26593
+ rc = p->deviceCharacteristics;
26594
+#endif
2649526595
if( p->ctrlFlags & UNIXFILE_PSOW ){
26496
- return SQLITE_IOCAP_POWERSAFE_OVERWRITE;
26497
- }else{
26498
- return 0;
26596
+ rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
2649926597
}
26598
+ return rc;
2650026599
}
2650126600
2650226601
#ifndef SQLITE_OMIT_WAL
2650326602
2650426603
@@ -26932,11 +27031,11 @@
2693227031
while(pShmNode->nRegion<=iRegion){
2693327032
void *pMem;
2693427033
if( pShmNode->h>=0 ){
2693527034
pMem = mmap(0, szRegion,
2693627035
pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
26937
- MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion
27036
+ MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion
2693827037
);
2693927038
if( pMem==MAP_FAILED ){
2694027039
rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
2694127040
goto shmpage_out;
2694227041
}
@@ -32130,11 +32229,12 @@
3213032229
if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
3213132230
#endif
3213232231
if( retryIoerr(&nRetry, &lastErrno) ) continue;
3213332232
break;
3213432233
}
32135
- if( nWrite<=0 ){
32234
+ assert( nWrite==0 || nWrite<=(DWORD)nRem );
32235
+ if( nWrite==0 || nWrite>(DWORD)nRem ){
3213632236
lastErrno = osGetLastError();
3213732237
break;
3213832238
}
3213932239
#if !SQLITE_OS_WINCE
3214032240
offset += nWrite;
@@ -42790,11 +42890,11 @@
4279042890
UNUSED_PARAMETER(isDirectMode);
4279142891
#else
4279242892
# define DIRECT_MODE isDirectMode
4279342893
#endif
4279442894
42795
- if( !pPager->changeCountDone && pPager->dbSize>0 ){
42895
+ if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){
4279642896
PgHdr *pPgHdr; /* Reference to page 1 */
4279742897
4279842898
assert( !pPager->tempFile && isOpen(pPager->fd) );
4279942899
4280042900
/* Open page 1 of the file for writing. */
@@ -43010,19 +43110,18 @@
4301043110
#endif
4301143111
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
4301243112
4301343113
/* If this transaction has made the database smaller, then all pages
4301443114
** being discarded by the truncation must be written to the journal
43015
- ** file. This can only happen in auto-vacuum mode.
43115
+ ** file.
4301643116
**
4301743117
** Before reading the pages with page numbers larger than the
4301843118
** current value of Pager.dbSize, set dbSize back to the value
4301943119
** that it took at the start of the transaction. Otherwise, the
4302043120
** calls to sqlite3PagerGet() return zeroed pages instead of
4302143121
** reading data from the database file.
4302243122
*/
43023
- #ifndef SQLITE_OMIT_AUTOVACUUM
4302443123
if( pPager->dbSize<pPager->dbOrigSize
4302543124
&& pPager->journalMode!=PAGER_JOURNALMODE_OFF
4302643125
){
4302743126
Pgno i; /* Iterator variable */
4302843127
const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */
@@ -43038,11 +43137,10 @@
4303843137
if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
4303943138
}
4304043139
}
4304143140
pPager->dbSize = dbSize;
4304243141
}
43043
- #endif
4304443142
4304543143
/* Write the master journal name into the journal file. If a master
4304643144
** journal file name has already been written to the journal file,
4304743145
** or if zMaster is NULL (no master journal), then this call is a no-op.
4304843146
*/
@@ -44041,10 +44139,12 @@
4404144139
}
4404244140
}
4404344141
return rc;
4404444142
}
4404544143
44144
+#endif /* !SQLITE_OMIT_WAL */
44145
+
4404644146
#ifdef SQLITE_ENABLE_ZIPVFS
4404744147
/*
4404844148
** A read-lock must be held on the pager when this function is called. If
4404944149
** the pager is in WAL mode and the WAL file currently contains one or more
4405044150
** frames, return the size in bytes of the page images stored within the
@@ -44070,12 +44170,10 @@
4407044170
CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);
4407144171
return aData;
4407244172
}
4407344173
#endif /* SQLITE_HAS_CODEC */
4407444174
44075
-#endif /* !SQLITE_OMIT_WAL */
44076
-
4407744175
#endif /* SQLITE_OMIT_DISKIO */
4407844176
4407944177
/************** End of pager.c ***********************************************/
4408044178
/************** Begin file wal.c *********************************************/
4408144179
/*
@@ -46595,11 +46693,11 @@
4659546693
** committed. As a result, the call to xUndo may not fail.
4659646694
*/
4659746695
assert( walFramePgno(pWal, iFrame)!=1 );
4659846696
rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
4659946697
}
46600
- walCleanupHash(pWal);
46698
+ if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
4660146699
}
4660246700
assert( rc==SQLITE_OK );
4660346701
return rc;
4660446702
}
4660546703
@@ -50648,10 +50746,24 @@
5064850746
#endif
5064950747
pBt->nPage = 1;
5065050748
data[31] = 1;
5065150749
return SQLITE_OK;
5065250750
}
50751
+
50752
+/*
50753
+** Initialize the first page of the database file (creating a database
50754
+** consisting of a single page and no schema objects). Return SQLITE_OK
50755
+** if successful, or an SQLite error code otherwise.
50756
+*/
50757
+SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){
50758
+ int rc;
50759
+ sqlite3BtreeEnter(p);
50760
+ p->pBt->nPage = 0;
50761
+ rc = newDatabase(p->pBt);
50762
+ sqlite3BtreeLeave(p);
50763
+ return rc;
50764
+}
5065350765
5065450766
/*
5065550767
** Attempt to start a new transaction. A write-transaction
5065650768
** is started if the second argument is nonzero, otherwise a read-
5065750769
** transaction. If the second argument is 2 or more and exclusive
@@ -53848,11 +53960,11 @@
5384853960
assert( sqlite3_mutex_held(pPage->pBt->mutex) );
5384953961
assert( sqlite3PagerIswriteable(pParent->pDbPage) );
5385053962
assert( pPage->nOverflow==1 );
5385153963
5385253964
/* This error condition is now caught prior to reaching this function */
53853
- if( pPage->nCell<=0 ) return SQLITE_CORRUPT_BKPT;
53965
+ if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;
5385453966
5385553967
/* Allocate a new page. This page will become the right-sibling of
5385653968
** pPage. Make the parent page writable, so that the new divider cell
5385753969
** may be inserted. If both these operations are successful, proceed.
5385853970
*/
@@ -56866,11 +56978,17 @@
5686656978
** is to make sure that the schema-version really does change in
5686756979
** the case where the source and destination databases have the
5686856980
** same schema version.
5686956981
*/
5687056982
if( rc==SQLITE_DONE ){
56871
- rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);
56983
+ if( nSrcPage==0 ){
56984
+ rc = sqlite3BtreeNewDb(p->pDest);
56985
+ nSrcPage = 1;
56986
+ }
56987
+ if( rc==SQLITE_OK || rc==SQLITE_DONE ){
56988
+ rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);
56989
+ }
5687256990
if( rc==SQLITE_OK ){
5687356991
if( p->pDestDb ){
5687456992
sqlite3ResetAllSchemasOfConnection(p->pDestDb);
5687556993
}
5687656994
if( destMode==PAGER_JOURNALMODE_WAL ){
@@ -56900,10 +57018,11 @@
5690057018
nDestTruncate--;
5690157019
}
5690257020
}else{
5690357021
nDestTruncate = nSrcPage * (pgszSrc/pgszDest);
5690457022
}
57023
+ assert( nDestTruncate>0 );
5690557024
sqlite3PagerTruncateImage(pDestPager, nDestTruncate);
5690657025
5690757026
if( pgszSrc<pgszDest ){
5690857027
/* If the source page-size is smaller than the destination page-size,
5690957028
** two extra things may need to happen:
@@ -56918,11 +57037,12 @@
5691857037
sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
5691957038
i64 iOff;
5692057039
i64 iEnd;
5692157040
5692257041
assert( pFile );
56923
- assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || (
57042
+ assert( nDestTruncate==0
57043
+ || (i64)nDestTruncate*(i64)pgszDest >= iSize || (
5692457044
nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
5692557045
&& iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
5692657046
));
5692757047
5692857048
/* This call ensures that all data required to recreate the original
@@ -60769,16 +60889,18 @@
6076960889
}
6077060890
}
6077160891
}
6077260892
6077360893
/*
60774
-** Free all memory associated with the Vdbe passed as the second argument.
60894
+** Free all memory associated with the Vdbe passed as the second argument,
60895
+** except for object itself, which is preserved.
60896
+**
6077560897
** The difference between this function and sqlite3VdbeDelete() is that
6077660898
** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with
60777
-** the database connection.
60899
+** the database connection and frees the object itself.
6077860900
*/
60779
-SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3 *db, Vdbe *p){
60901
+SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
6078060902
SubProgram *pSub, *pNext;
6078160903
int i;
6078260904
assert( p->db==0 || p->db==db );
6078360905
releaseMemArray(p->aVar, p->nVar);
6078460906
releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
@@ -60795,11 +60917,10 @@
6079560917
sqlite3DbFree(db, p->pFree);
6079660918
#if defined(SQLITE_ENABLE_TREE_EXPLAIN)
6079760919
sqlite3DbFree(db, p->zExplain);
6079860920
sqlite3DbFree(db, p->pExplain);
6079960921
#endif
60800
- sqlite3DbFree(db, p);
6080160922
}
6080260923
6080360924
/*
6080460925
** Delete an entire VDBE.
6080560926
*/
@@ -60807,10 +60928,11 @@
6080760928
sqlite3 *db;
6080860929
6080960930
if( NEVER(p==0) ) return;
6081060931
db = p->db;
6081160932
assert( sqlite3_mutex_held(db->mutex) );
60933
+ sqlite3VdbeClearObject(db, p);
6081260934
if( p->pPrev ){
6081360935
p->pPrev->pNext = p->pNext;
6081460936
}else{
6081560937
assert( db->pVdbe==p );
6081660938
db->pVdbe = p->pNext;
@@ -60818,11 +60940,11 @@
6081860940
if( p->pNext ){
6081960941
p->pNext->pPrev = p->pPrev;
6082060942
}
6082160943
p->magic = VDBE_MAGIC_DEAD;
6082260944
p->db = 0;
60823
- sqlite3VdbeDeleteObject(db, p);
60945
+ sqlite3DbFree(db, p);
6082460946
}
6082560947
6082660948
/*
6082760949
** Make sure the cursor p is ready to read or write the row to which it
6082860950
** was last positioned. Return an error code if an OOM fault or I/O error
@@ -70730,12 +70852,15 @@
7073070852
if( iBuf==0 ){
7073170853
int nRead; /* Bytes to read from disk */
7073270854
int rc; /* sqlite3OsRead() return code */
7073370855
7073470856
/* Determine how many bytes of data to read. */
70735
- nRead = (int)(p->iEof - p->iReadOff);
70736
- if( nRead>p->nBuffer ) nRead = p->nBuffer;
70857
+ if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){
70858
+ nRead = p->nBuffer;
70859
+ }else{
70860
+ nRead = (int)(p->iEof - p->iReadOff);
70861
+ }
7073770862
assert( nRead>0 );
7073870863
7073970864
/* Read data from the file. Return early if an error occurs. */
7074070865
rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff);
7074170866
assert( rc!=SQLITE_IOERR_SHORT_READ );
@@ -72415,11 +72540,11 @@
7241572540
Schema *pSchema = 0; /* Schema of the expression */
7241672541
int isTrigger = 0;
7241772542
7241872543
assert( pNC ); /* the name context cannot be NULL. */
7241972544
assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
72420
- assert( ~ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
72545
+ assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
7242172546
7242272547
/* Initialize the node to no-match */
7242372548
pExpr->iTable = -1;
7242472549
pExpr->pTab = 0;
7242572550
ExprSetIrreducible(pExpr);
@@ -82417,10 +82542,11 @@
8241782542
}
8241882543
if( iLargest==0 ){
8241982544
return;
8242082545
}else{
8242182546
int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
82547
+ assert( iDb>=0 && iDb<pParse->db->nDb );
8242282548
destroyRootPage(pParse, iLargest, iDb);
8242382549
iDestroyed = iLargest;
8242482550
}
8242582551
}
8242682552
#endif
@@ -92962,17 +93088,16 @@
9296293088
pParse->nMem = 2;
9296393089
sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
9296493090
sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC);
9296593091
for(i=0; i<db->nDb; i++){
9296693092
Btree *pBt;
92967
- Pager *pPager;
9296893093
const char *zState = "unknown";
9296993094
int j;
9297093095
if( db->aDb[i].zName==0 ) continue;
9297193096
sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC);
9297293097
pBt = db->aDb[i].pBt;
92973
- if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){
93098
+ if( pBt==0 || sqlite3BtreePager(pBt)==0 ){
9297493099
zState = "closed";
9297593100
}else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0,
9297693101
SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
9297793102
zState = azLockName[j];
9297893103
}
@@ -97007,14 +97132,13 @@
9700797132
** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".
9700897133
*/
9700997134
pList = pParent->pEList;
9701097135
for(i=0; i<pList->nExpr; i++){
9701197136
if( pList->a[i].zName==0 ){
97012
- const char *zSpan = pList->a[i].zSpan;
97013
- if( ALWAYS(zSpan) ){
97014
- pList->a[i].zName = sqlite3DbStrDup(db, zSpan);
97015
- }
97137
+ char *zName = sqlite3DbStrDup(db, pList->a[i].zSpan);
97138
+ sqlite3Dequote(zName);
97139
+ pList->a[i].zName = zName;
9701697140
}
9701797141
}
9701897142
substExprList(db, pParent->pEList, iParent, pSub->pEList);
9701997143
if( isAgg ){
9702097144
substExprList(db, pParent->pGroupBy, iParent, pSub->pEList);
@@ -100655,10 +100779,11 @@
100655100779
*/
100656100780
SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse){
100657100781
Vdbe *v = sqlite3GetVdbe(pParse);
100658100782
if( v ){
100659100783
sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);
100784
+ sqlite3VdbeUsesBtree(v, 0);
100660100785
}
100661100786
return;
100662100787
}
100663100788
100664100789
/*
@@ -101182,13 +101307,12 @@
101182101307
*/
101183101308
SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
101184101309
if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
101185101310
if( p->azModuleArg ){
101186101311
int i;
101187
- assert( p->nModuleArg<2 || p->azModuleArg[1]==0 );
101188101312
for(i=0; i<p->nModuleArg; i++){
101189
- sqlite3DbFree(db, p->azModuleArg[i]);
101313
+ if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);
101190101314
}
101191101315
sqlite3DbFree(db, p->azModuleArg);
101192101316
}
101193101317
}
101194101318
@@ -101415,11 +101539,10 @@
101415101539
return SQLITE_NOMEM;
101416101540
}
101417101541
pVTable->db = db;
101418101542
pVTable->pMod = pMod;
101419101543
101420
- assert( pTab->azModuleArg[1]==0 );
101421101544
iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
101422101545
pTab->azModuleArg[1] = db->aDb[iDb].zName;
101423101546
101424101547
/* Invoke the virtual table constructor */
101425101548
assert( &db->pVtabCtx );
@@ -101429,11 +101552,10 @@
101429101552
pPriorCtx = db->pVtabCtx;
101430101553
db->pVtabCtx = &sCtx;
101431101554
rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
101432101555
db->pVtabCtx = pPriorCtx;
101433101556
if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
101434
- pTab->azModuleArg[1] = 0;
101435101557
101436101558
if( SQLITE_OK!=rc ){
101437101559
if( zErr==0 ){
101438101560
*pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
101439101561
}else {
@@ -103838,11 +103960,13 @@
103838103960
}
103839103961
if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){
103840103962
/* Automatic indices are disabled at run-time */
103841103963
return;
103842103964
}
103843
- if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0 ){
103965
+ if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0
103966
+ && (p->cost.plan.wsFlags & WHERE_COVER_SCAN)==0
103967
+ ){
103844103968
/* We already have some kind of index in use for this query. */
103845103969
return;
103846103970
}
103847103971
if( pSrc->notIndexed ){
103848103972
/* The NOT INDEXED clause appears in the SQL. */
@@ -104794,18 +104918,10 @@
104794104918
** by the index pIdx and other indices in outer loops.
104795104919
**
104796104920
** The table being queried has a cursor number of "base". pIdx is the
104797104921
** index that is postulated for use to access the table.
104798104922
**
104799
-** nEqCol is the number of columns of pIdx that are used as equality
104800
-** constraints and where the other side of the == is an ordered column
104801
-** or constant. An "order column" in the previous sentence means a column
104802
-** in table from an outer loop whose values will always appear in the
104803
-** correct order due to othre index, or because the outer loop generates
104804
-** a unique result. Any of the first nEqCol columns of pIdx may be missing
104805
-** from the ORDER BY clause and the match can still be a success.
104806
-**
104807104923
** The *pbRev value is set to 0 order 1 depending on whether or not
104808104924
** pIdx should be run in the forward order or in reverse order.
104809104925
*/
104810104926
static int isSortingIndex(
104811104927
WhereBestIdx *p, /* Best index search context */
@@ -104917,41 +105033,50 @@
104917105033
}
104918105034
104919105035
/* termSortOrder is 0 or 1 for whether or not the access loop should
104920105036
** run forward or backwards (respectively) in order to satisfy this
104921105037
** term of the ORDER BY clause. */
105038
+ assert( pOBItem->sortOrder==0 || pOBItem->sortOrder==1 );
105039
+ assert( iSortOrder==0 || iSortOrder==1 );
104922105040
termSortOrder = iSortOrder ^ pOBItem->sortOrder;
104923105041
104924105042
/* If X is the column in the index and ORDER BY clause, check to see
104925105043
** if there are any X= or X IS NULL constraints in the WHERE clause. */
104926105044
pConstraint = findTerm(p->pWC, base, iColumn, p->notReady,
104927105045
WO_EQ|WO_ISNULL|WO_IN, pIdx);
104928105046
if( pConstraint==0 ){
104929105047
isEq = 0;
104930105048
}else if( pConstraint->eOperator==WO_IN ){
105049
+ /* Constraints of the form: "X IN ..." cannot be used with an ORDER BY
105050
+ ** because we do not know in what order the values on the RHS of the IN
105051
+ ** operator will occur. */
104931105052
break;
104932105053
}else if( pConstraint->eOperator==WO_ISNULL ){
104933105054
uniqueNotNull = 0;
104934
- isEq = 1;
105055
+ isEq = 1; /* "X IS NULL" means X has only a single value */
104935105056
}else if( pConstraint->prereqRight==0 ){
104936
- isEq = 1;
105057
+ isEq = 1; /* Constraint "X=constant" means X has only a single value */
104937105058
}else{
104938105059
Expr *pRight = pConstraint->pExpr->pRight;
104939105060
if( pRight->op==TK_COLUMN ){
104940105061
WHERETRACE((" .. isOrderedColumn(tab=%d,col=%d)",
104941105062
pRight->iTable, pRight->iColumn));
104942105063
isEq = isOrderedColumn(p, pRight->iTable, pRight->iColumn);
104943105064
WHERETRACE((" -> isEq=%d\n", isEq));
105065
+
105066
+ /* If the constraint is of the form X=Y where Y is an ordered value
105067
+ ** in an outer loop, then make sure the sort order of Y matches the
105068
+ ** sort order required for X. */
104944105069
if( isMatch && isEq>=2 && isEq!=pOBItem->sortOrder+2 ){
105070
+ testcase( isEq==2 );
105071
+ testcase( isEq==3 );
104945105072
break;
104946105073
}
104947105074
}else{
104948
- isEq = 0;
105075
+ isEq = 0; /* "X=expr" places no ordering constraints on X */
104949105076
}
104950105077
}
104951
- assert( pOBItem->sortOrder==0 || pOBItem->sortOrder==1 );
104952
- assert( iSortOrder==0 || iSortOrder==1 );
104953105078
if( !isMatch ){
104954105079
if( isEq==0 ){
104955105080
break;
104956105081
}else{
104957105082
continue;
@@ -104966,11 +105091,14 @@
104966105091
j++;
104967105092
pOBItem++;
104968105093
if( iColumn<0 ){
104969105094
seenRowid = 1;
104970105095
break;
104971
- }else if( pTab->aCol[iColumn].notNull==0 && isEq==0 ){
105096
+ }else if( pTab->aCol[iColumn].notNull==0 && isEq!=1 ){
105097
+ testcase( isEq==0 );
105098
+ testcase( isEq==2 );
105099
+ testcase( isEq==3 );
104972105100
uniqueNotNull = 0;
104973105101
}
104974105102
}
104975105103
104976105104
/* If we have not found at least one ORDER BY term that matches the
@@ -106624,11 +106752,11 @@
106624106752
sqlite3WhereEnd(pSubWInfo);
106625106753
}
106626106754
}
106627106755
}
106628106756
pLevel->u.pCovidx = pCov;
106629
- pLevel->iIdxCur = iCovCur;
106757
+ if( pCov ) pLevel->iIdxCur = iCovCur;
106630106758
if( pAndExpr ){
106631106759
pAndExpr->pLeft = 0;
106632106760
sqlite3ExprDelete(pParse->db, pAndExpr);
106633106761
}
106634106762
sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
@@ -110720,10 +110848,11 @@
110720110848
/* (324) anylist ::= */ yytestcase(yyruleno==324);
110721110849
/* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110722110850
/* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
110723110851
break;
110724110852
};
110853
+ assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
110725110854
yygoto = yyRuleInfo[yyruleno].lhs;
110726110855
yysize = yyRuleInfo[yyruleno].nrhs;
110727110856
yypParser->yyidx -= yysize;
110728110857
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
110729110858
if( yyact < YYNSTATE ){
@@ -121244,39 +121373,43 @@
121244121373
/* Allocate temporary working space. */
121245121374
for(p=pExpr; p->pLeft; p=p->pLeft){
121246121375
nTmp += p->pRight->pPhrase->doclist.nList;
121247121376
}
121248121377
nTmp += p->pPhrase->doclist.nList;
121249
- aTmp = sqlite3_malloc(nTmp*2);
121250
- if( !aTmp ){
121251
- *pRc = SQLITE_NOMEM;
121378
+ if( nTmp==0 ){
121252121379
res = 0;
121253121380
}else{
121254
- char *aPoslist = p->pPhrase->doclist.pList;
121255
- int nToken = p->pPhrase->nToken;
121256
-
121257
- for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){
121258
- Fts3Phrase *pPhrase = p->pRight->pPhrase;
121259
- int nNear = p->nNear;
121260
- res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121261
- }
121262
-
121263
- aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121264
- nToken = pExpr->pRight->pPhrase->nToken;
121265
- for(p=pExpr->pLeft; p && res; p=p->pLeft){
121266
- int nNear;
121267
- Fts3Phrase *pPhrase;
121268
- assert( p->pParent && p->pParent->pLeft==p );
121269
- nNear = p->pParent->nNear;
121270
- pPhrase = (
121271
- p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase
121272
- );
121273
- res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121274
- }
121275
- }
121276
-
121277
- sqlite3_free(aTmp);
121381
+ aTmp = sqlite3_malloc(nTmp*2);
121382
+ if( !aTmp ){
121383
+ *pRc = SQLITE_NOMEM;
121384
+ res = 0;
121385
+ }else{
121386
+ char *aPoslist = p->pPhrase->doclist.pList;
121387
+ int nToken = p->pPhrase->nToken;
121388
+
121389
+ for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){
121390
+ Fts3Phrase *pPhrase = p->pRight->pPhrase;
121391
+ int nNear = p->nNear;
121392
+ res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121393
+ }
121394
+
121395
+ aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121396
+ nToken = pExpr->pRight->pPhrase->nToken;
121397
+ for(p=pExpr->pLeft; p && res; p=p->pLeft){
121398
+ int nNear;
121399
+ Fts3Phrase *pPhrase;
121400
+ assert( p->pParent && p->pParent->pLeft==p );
121401
+ nNear = p->pParent->nNear;
121402
+ pPhrase = (
121403
+ p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase
121404
+ );
121405
+ res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121406
+ }
121407
+ }
121408
+
121409
+ sqlite3_free(aTmp);
121410
+ }
121278121411
}
121279121412
121280121413
return res;
121281121414
}
121282121415
@@ -122510,11 +122643,11 @@
122510122643
int nConsumed = 0;
122511122644
122512122645
rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, n, &pCursor);
122513122646
if( rc==SQLITE_OK ){
122514122647
const char *zToken;
122515
- int nToken, iStart, iEnd, iPosition;
122648
+ int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;
122516122649
int nByte; /* total space to allocate */
122517122650
122518122651
rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
122519122652
if( rc==SQLITE_OK ){
122520122653
nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;
@@ -122625,11 +122758,11 @@
122625122758
pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);
122626122759
if( rc==SQLITE_OK ){
122627122760
int ii;
122628122761
for(ii=0; rc==SQLITE_OK; ii++){
122629122762
const char *zByte;
122630
- int nByte, iBegin, iEnd, iPos;
122763
+ int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;
122631122764
rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);
122632122765
if( rc==SQLITE_OK ){
122633122766
Fts3PhraseToken *pToken;
122634122767
122635122768
p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
@@ -124622,14 +124755,14 @@
124622124755
int nInput;
124623124756
124624124757
const char *azArg[64];
124625124758
124626124759
const char *zToken;
124627
- int nToken;
124628
- int iStart;
124629
- int iEnd;
124630
- int iPos;
124760
+ int nToken = 0;
124761
+ int iStart = 0;
124762
+ int iEnd = 0;
124763
+ int iPos = 0;
124631124764
int i;
124632124765
124633124766
Tcl_Obj *pRet;
124634124767
124635124768
if( argc<2 ){
@@ -125875,17 +126008,17 @@
125875126008
const char *zText, /* Text of document to be inserted */
125876126009
int iCol, /* Column into which text is being inserted */
125877126010
u32 *pnWord /* OUT: Number of tokens inserted */
125878126011
){
125879126012
int rc;
125880
- int iStart;
125881
- int iEnd;
125882
- int iPos;
126013
+ int iStart = 0;
126014
+ int iEnd = 0;
126015
+ int iPos = 0;
125883126016
int nWord = 0;
125884126017
125885126018
char const *zToken;
125886
- int nToken;
126019
+ int nToken = 0;
125887126020
125888126021
sqlite3_tokenizer *pTokenizer = p->pTokenizer;
125889126022
sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
125890126023
sqlite3_tokenizer_cursor *pCsr;
125891126024
int (*xNext)(sqlite3_tokenizer_cursor *pCursor,
@@ -130030,13 +130163,13 @@
130030130163
sqlite3_tokenizer_cursor *pT = 0;
130031130164
130032130165
rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130033130166
while( rc==SQLITE_OK ){
130034130167
char const *zToken; /* Buffer containing token */
130035
- int nToken; /* Number of bytes in token */
130036
- int iDum1, iDum2; /* Dummy variables */
130037
- int iPos; /* Position of token in zText */
130168
+ int nToken = 0; /* Number of bytes in token */
130169
+ int iDum1 = 0, iDum2 = 0; /* Dummy variables */
130170
+ int iPos = 0; /* Position of token in zText */
130038130171
130039130172
rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130040130173
if( rc==SQLITE_OK ){
130041130174
int i;
130042130175
cksum2 = cksum2 ^ fts3ChecksumEntry(
@@ -130199,13 +130332,13 @@
130199130332
sqlite3_tokenizer_cursor *pTC = 0;
130200130333
130201130334
rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
130202130335
while( rc==SQLITE_OK ){
130203130336
char const *zToken; /* Buffer containing token */
130204
- int nToken; /* Number of bytes in token */
130205
- int iDum1, iDum2; /* Dummy variables */
130206
- int iPos; /* Position of token in zText */
130337
+ int nToken = 0; /* Number of bytes in token */
130338
+ int iDum1 = 0, iDum2 = 0; /* Dummy variables */
130339
+ int iPos = 0; /* Position of token in zText */
130207130340
130208130341
rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130209130342
for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
130210130343
Fts3PhraseToken *pPT = pDef->pToken;
130211130344
if( (pDef->iCol>=p->nColumn || pDef->iCol==i)
@@ -131069,11 +131202,11 @@
131069131202
rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);
131070131203
if( rc!=SQLITE_OK ){
131071131204
return rc;
131072131205
}
131073131206
while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){
131074
- const char *ZDUMMY; int DUMMY1, DUMMY2, DUMMY3;
131207
+ const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;
131075131208
rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
131076131209
}
131077131210
pMod->xClose(pC);
131078131211
if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }
131079131212
@@ -131113,12 +131246,10 @@
131113131246
int iPos = pFragment->iPos; /* First token of snippet */
131114131247
u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */
131115131248
int iCol = pFragment->iCol+1; /* Query column to extract text from */
131116131249
sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
131117131250
sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */
131118
- const char *ZDUMMY; /* Dummy argument used with tokenizer */
131119
- int DUMMY1; /* Dummy argument used with tokenizer */
131120131251
131121131252
zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);
131122131253
if( zDoc==0 ){
131123131254
if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){
131124131255
return SQLITE_NOMEM;
@@ -131133,14 +131264,27 @@
131133131264
if( rc!=SQLITE_OK ){
131134131265
return rc;
131135131266
}
131136131267
131137131268
while( rc==SQLITE_OK ){
131138
- int iBegin; /* Offset in zDoc of start of token */
131139
- int iFin; /* Offset in zDoc of end of token */
131140
- int isHighlight; /* True for highlighted terms */
131269
+ const char *ZDUMMY; /* Dummy argument used with tokenizer */
131270
+ int DUMMY1 = -1; /* Dummy argument used with tokenizer */
131271
+ int iBegin = 0; /* Offset in zDoc of start of token */
131272
+ int iFin = 0; /* Offset in zDoc of end of token */
131273
+ int isHighlight = 0; /* True for highlighted terms */
131141131274
131275
+ /* Variable DUMMY1 is initialized to a negative value above. Elsewhere
131276
+ ** in the FTS code the variable that the third argument to xNext points to
131277
+ ** is initialized to zero before the first (*but not necessarily
131278
+ ** subsequent*) call to xNext(). This is done for a particular application
131279
+ ** that needs to know whether or not the tokenizer is being used for
131280
+ ** snippet generation or for some other purpose.
131281
+ **
131282
+ ** Extreme care is required when writing code to depend on this
131283
+ ** initialization. It is not a documented part of the tokenizer interface.
131284
+ ** If a tokenizer is used directly by any code outside of FTS, this
131285
+ ** convention might not be respected. */
131142131286
rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
131143131287
if( rc!=SQLITE_OK ){
131144131288
if( rc==SQLITE_DONE ){
131145131289
/* Special case - the last token of the snippet is also the last token
131146131290
** of the column. Append any punctuation that occurred between the end
@@ -131826,12 +131970,10 @@
131826131970
sqlite3_context *pCtx, /* SQLite function call context */
131827131971
Fts3Cursor *pCsr /* Cursor object */
131828131972
){
131829131973
Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
131830131974
sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;
131831
- const char *ZDUMMY; /* Dummy argument used with xNext() */
131832
- int NDUMMY; /* Dummy argument used with xNext() */
131833131975
int rc; /* Return Code */
131834131976
int nToken; /* Number of tokens in query */
131835131977
int iCol; /* Column currently being processed */
131836131978
StrBuffer res = {0, 0, 0}; /* Result string */
131837131979
TermOffsetCtx sCtx; /* Context for fts3ExprTermOffsetInit() */
@@ -131860,13 +132002,15 @@
131860132002
/* Loop through the table columns, appending offset information to
131861132003
** string-buffer res for each column.
131862132004
*/
131863132005
for(iCol=0; iCol<pTab->nColumn; iCol++){
131864132006
sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */
131865
- int iStart;
131866
- int iEnd;
131867
- int iCurrent;
132007
+ const char *ZDUMMY; /* Dummy argument used with xNext() */
132008
+ int NDUMMY = 0; /* Dummy argument used with xNext() */
132009
+ int iStart = 0;
132010
+ int iEnd = 0;
132011
+ int iCurrent = 0;
131868132012
const char *zDoc;
131869132013
int nDoc;
131870132014
131871132015
/* Initialize the contents of sCtx.aTerm[] for column iCol. There is
131872132016
** no way that this operation can fail, so the return code from
@@ -136745,19 +136889,19 @@
136745136889
nInput = strlen(zInput);
136746136890
}
136747136891
nChar = nInput+1;
136748136892
pCsr = (IcuCursor *)sqlite3_malloc(
136749136893
sizeof(IcuCursor) + /* IcuCursor */
136750
- nChar * sizeof(UChar) + /* IcuCursor.aChar[] */
136894
+ ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */
136751136895
(nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */
136752136896
);
136753136897
if( !pCsr ){
136754136898
return SQLITE_NOMEM;
136755136899
}
136756136900
memset(pCsr, 0, sizeof(IcuCursor));
136757136901
pCsr->aChar = (UChar *)&pCsr[1];
136758
- pCsr->aOffset = (int *)&pCsr->aChar[nChar];
136902
+ pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];
136759136903
136760136904
pCsr->aOffset[iOut] = iInput;
136761136905
U8_NEXT(zInput, iInput, nInput, c);
136762136906
while( c>0 ){
136763136907
int isError = 0;
136764136908
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674 ** [sqlite_version()] and [sqlite_source_id()].
675 */
676 #define SQLITE_VERSION "3.7.15"
677 #define SQLITE_VERSION_NUMBER 3007015
678 #define SQLITE_SOURCE_ID "2012-10-09 01:39:25 01dc032b5bbd9c9ebb1965f176ca5d732cda85ea"
679
680 /*
681 ** CAPI3REF: Run-Time Library Version Numbers
682 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
683 **
@@ -8439,10 +8439,12 @@
8439 SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);
8440
8441 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
8442 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
8443
 
 
8444 /*
8445 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
8446 ** should be one of the following values. The integer values are assigned
8447 ** to constants so that the offset of the corresponding field in an
8448 ** SQLite database header may be found using the following formula:
@@ -8953,11 +8955,11 @@
8953 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
8954 SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
8955 SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);
8956 SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
8957 SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
8958 SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3*,Vdbe*);
8959 SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
8960 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
8961 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
8962 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
8963 #ifdef SQLITE_DEBUG
@@ -9143,15 +9145,18 @@
9143 SQLITE_PRIVATE int sqlite3PagerRollback(Pager*);
9144 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
9145 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
9146 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
9147
9148 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
9149 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
9150 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
9151 SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
9152 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
 
 
 
9153 #ifdef SQLITE_ENABLE_ZIPVFS
9154 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
9155 #endif
9156
9157 /* Functions used to query pager state and configuration. */
@@ -12220,12 +12225,14 @@
12220 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
12221 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
12222 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
12223 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
12224 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
12225 SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
12226 SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
 
 
12227
12228 /* Declarations for functions in fkey.c. All of these are replaced by
12229 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
12230 ** key functionality is available. If OMIT_TRIGGER is defined but
12231 ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
@@ -13704,11 +13711,11 @@
13704 struct Vdbe *pVdbe; /* Used to iterate through VMs */
13705 int nByte = 0; /* Used to accumulate return value */
13706
13707 db->pnBytesFreed = &nByte;
13708 for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){
13709 sqlite3VdbeDeleteObject(db, pVdbe);
13710 }
13711 db->pnBytesFreed = 0;
13712
13713 *pHighwater = 0;
13714 *pCurrent = nByte;
@@ -22374,11 +22381,11 @@
22374 pEntry->count--;
22375 assert( pEntry->count>=0 );
22376 }
22377 sqlite3_free( elem );
22378 pH->count--;
22379 if( pH->count<=0 ){
22380 assert( pH->first==0 );
22381 assert( pH->count==0 );
22382 sqlite3HashClear(pH);
22383 }
22384 }
@@ -22844,10 +22851,14 @@
22844 void *lockingContext; /* Locking style specific state */
22845 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
22846 const char *zPath; /* Name of the file */
22847 unixShm *pShm; /* Shared memory segment information */
22848 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
 
 
 
 
22849 #if SQLITE_ENABLE_LOCKING_STYLE
22850 int openFlags; /* The flags specified at open() */
22851 #endif
22852 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
22853 unsigned fsFlags; /* cached details from statfs() */
@@ -24920,17 +24931,17 @@
24920
24921 /*
24922 ** Close a file. Make sure the lock has been released before closing.
24923 */
24924 static int dotlockClose(sqlite3_file *id) {
24925 int rc;
24926 if( id ){
24927 unixFile *pFile = (unixFile*)id;
24928 dotlockUnlock(id, NO_LOCK);
24929 sqlite3_free(pFile->lockingContext);
 
24930 }
24931 rc = closeUnixFile(id);
24932 return rc;
24933 }
24934 /****************** End of the dot-file lock implementation *******************
24935 ******************************************************************************/
24936
@@ -25130,14 +25141,16 @@
25130
25131 /*
25132 ** Close a file.
25133 */
25134 static int flockClose(sqlite3_file *id) {
 
25135 if( id ){
25136 flockUnlock(id, NO_LOCK);
 
25137 }
25138 return closeUnixFile(id);
25139 }
25140
25141 #endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */
25142
25143 /******************* End of the flock lock implementation *********************
@@ -26470,14 +26483,96 @@
26470 ** SQLite code assumes this function cannot fail. It also assumes that
26471 ** if two files are created in the same file-system directory (i.e.
26472 ** a database and its journal file) that the sector size will be the
26473 ** same for both.
26474 */
26475 static int unixSectorSize(sqlite3_file *pFile){
26476 (void)pFile;
 
26477 return SQLITE_DEFAULT_SECTOR_SIZE;
26478 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26479
26480 /*
26481 ** Return the device characteristics for the file.
26482 **
26483 ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.
@@ -26490,15 +26585,19 @@
26490 ** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control
26491 ** available to turn it off and URI query parameter available to turn it off.
26492 */
26493 static int unixDeviceCharacteristics(sqlite3_file *id){
26494 unixFile *p = (unixFile*)id;
 
 
 
 
 
26495 if( p->ctrlFlags & UNIXFILE_PSOW ){
26496 return SQLITE_IOCAP_POWERSAFE_OVERWRITE;
26497 }else{
26498 return 0;
26499 }
 
26500 }
26501
26502 #ifndef SQLITE_OMIT_WAL
26503
26504
@@ -26932,11 +27031,11 @@
26932 while(pShmNode->nRegion<=iRegion){
26933 void *pMem;
26934 if( pShmNode->h>=0 ){
26935 pMem = mmap(0, szRegion,
26936 pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
26937 MAP_SHARED, pShmNode->h, pShmNode->nRegion*szRegion
26938 );
26939 if( pMem==MAP_FAILED ){
26940 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
26941 goto shmpage_out;
26942 }
@@ -32130,11 +32229,12 @@
32130 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
32131 #endif
32132 if( retryIoerr(&nRetry, &lastErrno) ) continue;
32133 break;
32134 }
32135 if( nWrite<=0 ){
 
32136 lastErrno = osGetLastError();
32137 break;
32138 }
32139 #if !SQLITE_OS_WINCE
32140 offset += nWrite;
@@ -42790,11 +42890,11 @@
42790 UNUSED_PARAMETER(isDirectMode);
42791 #else
42792 # define DIRECT_MODE isDirectMode
42793 #endif
42794
42795 if( !pPager->changeCountDone && pPager->dbSize>0 ){
42796 PgHdr *pPgHdr; /* Reference to page 1 */
42797
42798 assert( !pPager->tempFile && isOpen(pPager->fd) );
42799
42800 /* Open page 1 of the file for writing. */
@@ -43010,19 +43110,18 @@
43010 #endif
43011 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
43012
43013 /* If this transaction has made the database smaller, then all pages
43014 ** being discarded by the truncation must be written to the journal
43015 ** file. This can only happen in auto-vacuum mode.
43016 **
43017 ** Before reading the pages with page numbers larger than the
43018 ** current value of Pager.dbSize, set dbSize back to the value
43019 ** that it took at the start of the transaction. Otherwise, the
43020 ** calls to sqlite3PagerGet() return zeroed pages instead of
43021 ** reading data from the database file.
43022 */
43023 #ifndef SQLITE_OMIT_AUTOVACUUM
43024 if( pPager->dbSize<pPager->dbOrigSize
43025 && pPager->journalMode!=PAGER_JOURNALMODE_OFF
43026 ){
43027 Pgno i; /* Iterator variable */
43028 const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */
@@ -43038,11 +43137,10 @@
43038 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
43039 }
43040 }
43041 pPager->dbSize = dbSize;
43042 }
43043 #endif
43044
43045 /* Write the master journal name into the journal file. If a master
43046 ** journal file name has already been written to the journal file,
43047 ** or if zMaster is NULL (no master journal), then this call is a no-op.
43048 */
@@ -44041,10 +44139,12 @@
44041 }
44042 }
44043 return rc;
44044 }
44045
 
 
44046 #ifdef SQLITE_ENABLE_ZIPVFS
44047 /*
44048 ** A read-lock must be held on the pager when this function is called. If
44049 ** the pager is in WAL mode and the WAL file currently contains one or more
44050 ** frames, return the size in bytes of the page images stored within the
@@ -44070,12 +44170,10 @@
44070 CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);
44071 return aData;
44072 }
44073 #endif /* SQLITE_HAS_CODEC */
44074
44075 #endif /* !SQLITE_OMIT_WAL */
44076
44077 #endif /* SQLITE_OMIT_DISKIO */
44078
44079 /************** End of pager.c ***********************************************/
44080 /************** Begin file wal.c *********************************************/
44081 /*
@@ -46595,11 +46693,11 @@
46595 ** committed. As a result, the call to xUndo may not fail.
46596 */
46597 assert( walFramePgno(pWal, iFrame)!=1 );
46598 rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
46599 }
46600 walCleanupHash(pWal);
46601 }
46602 assert( rc==SQLITE_OK );
46603 return rc;
46604 }
46605
@@ -50648,10 +50746,24 @@
50648 #endif
50649 pBt->nPage = 1;
50650 data[31] = 1;
50651 return SQLITE_OK;
50652 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
50653
50654 /*
50655 ** Attempt to start a new transaction. A write-transaction
50656 ** is started if the second argument is nonzero, otherwise a read-
50657 ** transaction. If the second argument is 2 or more and exclusive
@@ -53848,11 +53960,11 @@
53848 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
53849 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
53850 assert( pPage->nOverflow==1 );
53851
53852 /* This error condition is now caught prior to reaching this function */
53853 if( pPage->nCell<=0 ) return SQLITE_CORRUPT_BKPT;
53854
53855 /* Allocate a new page. This page will become the right-sibling of
53856 ** pPage. Make the parent page writable, so that the new divider cell
53857 ** may be inserted. If both these operations are successful, proceed.
53858 */
@@ -56866,11 +56978,17 @@
56866 ** is to make sure that the schema-version really does change in
56867 ** the case where the source and destination databases have the
56868 ** same schema version.
56869 */
56870 if( rc==SQLITE_DONE ){
56871 rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);
 
 
 
 
 
 
56872 if( rc==SQLITE_OK ){
56873 if( p->pDestDb ){
56874 sqlite3ResetAllSchemasOfConnection(p->pDestDb);
56875 }
56876 if( destMode==PAGER_JOURNALMODE_WAL ){
@@ -56900,10 +57018,11 @@
56900 nDestTruncate--;
56901 }
56902 }else{
56903 nDestTruncate = nSrcPage * (pgszSrc/pgszDest);
56904 }
 
56905 sqlite3PagerTruncateImage(pDestPager, nDestTruncate);
56906
56907 if( pgszSrc<pgszDest ){
56908 /* If the source page-size is smaller than the destination page-size,
56909 ** two extra things may need to happen:
@@ -56918,11 +57037,12 @@
56918 sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
56919 i64 iOff;
56920 i64 iEnd;
56921
56922 assert( pFile );
56923 assert( (i64)nDestTruncate*(i64)pgszDest >= iSize || (
 
56924 nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
56925 && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
56926 ));
56927
56928 /* This call ensures that all data required to recreate the original
@@ -60769,16 +60889,18 @@
60769 }
60770 }
60771 }
60772
60773 /*
60774 ** Free all memory associated with the Vdbe passed as the second argument.
 
 
60775 ** The difference between this function and sqlite3VdbeDelete() is that
60776 ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with
60777 ** the database connection.
60778 */
60779 SQLITE_PRIVATE void sqlite3VdbeDeleteObject(sqlite3 *db, Vdbe *p){
60780 SubProgram *pSub, *pNext;
60781 int i;
60782 assert( p->db==0 || p->db==db );
60783 releaseMemArray(p->aVar, p->nVar);
60784 releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
@@ -60795,11 +60917,10 @@
60795 sqlite3DbFree(db, p->pFree);
60796 #if defined(SQLITE_ENABLE_TREE_EXPLAIN)
60797 sqlite3DbFree(db, p->zExplain);
60798 sqlite3DbFree(db, p->pExplain);
60799 #endif
60800 sqlite3DbFree(db, p);
60801 }
60802
60803 /*
60804 ** Delete an entire VDBE.
60805 */
@@ -60807,10 +60928,11 @@
60807 sqlite3 *db;
60808
60809 if( NEVER(p==0) ) return;
60810 db = p->db;
60811 assert( sqlite3_mutex_held(db->mutex) );
 
60812 if( p->pPrev ){
60813 p->pPrev->pNext = p->pNext;
60814 }else{
60815 assert( db->pVdbe==p );
60816 db->pVdbe = p->pNext;
@@ -60818,11 +60940,11 @@
60818 if( p->pNext ){
60819 p->pNext->pPrev = p->pPrev;
60820 }
60821 p->magic = VDBE_MAGIC_DEAD;
60822 p->db = 0;
60823 sqlite3VdbeDeleteObject(db, p);
60824 }
60825
60826 /*
60827 ** Make sure the cursor p is ready to read or write the row to which it
60828 ** was last positioned. Return an error code if an OOM fault or I/O error
@@ -70730,12 +70852,15 @@
70730 if( iBuf==0 ){
70731 int nRead; /* Bytes to read from disk */
70732 int rc; /* sqlite3OsRead() return code */
70733
70734 /* Determine how many bytes of data to read. */
70735 nRead = (int)(p->iEof - p->iReadOff);
70736 if( nRead>p->nBuffer ) nRead = p->nBuffer;
 
 
 
70737 assert( nRead>0 );
70738
70739 /* Read data from the file. Return early if an error occurs. */
70740 rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff);
70741 assert( rc!=SQLITE_IOERR_SHORT_READ );
@@ -72415,11 +72540,11 @@
72415 Schema *pSchema = 0; /* Schema of the expression */
72416 int isTrigger = 0;
72417
72418 assert( pNC ); /* the name context cannot be NULL. */
72419 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
72420 assert( ~ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
72421
72422 /* Initialize the node to no-match */
72423 pExpr->iTable = -1;
72424 pExpr->pTab = 0;
72425 ExprSetIrreducible(pExpr);
@@ -82417,10 +82542,11 @@
82417 }
82418 if( iLargest==0 ){
82419 return;
82420 }else{
82421 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
 
82422 destroyRootPage(pParse, iLargest, iDb);
82423 iDestroyed = iLargest;
82424 }
82425 }
82426 #endif
@@ -92962,17 +93088,16 @@
92962 pParse->nMem = 2;
92963 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
92964 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC);
92965 for(i=0; i<db->nDb; i++){
92966 Btree *pBt;
92967 Pager *pPager;
92968 const char *zState = "unknown";
92969 int j;
92970 if( db->aDb[i].zName==0 ) continue;
92971 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC);
92972 pBt = db->aDb[i].pBt;
92973 if( pBt==0 || (pPager = sqlite3BtreePager(pBt))==0 ){
92974 zState = "closed";
92975 }else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0,
92976 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
92977 zState = azLockName[j];
92978 }
@@ -97007,14 +97132,13 @@
97007 ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".
97008 */
97009 pList = pParent->pEList;
97010 for(i=0; i<pList->nExpr; i++){
97011 if( pList->a[i].zName==0 ){
97012 const char *zSpan = pList->a[i].zSpan;
97013 if( ALWAYS(zSpan) ){
97014 pList->a[i].zName = sqlite3DbStrDup(db, zSpan);
97015 }
97016 }
97017 }
97018 substExprList(db, pParent->pEList, iParent, pSub->pEList);
97019 if( isAgg ){
97020 substExprList(db, pParent->pGroupBy, iParent, pSub->pEList);
@@ -100655,10 +100779,11 @@
100655 */
100656 SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse){
100657 Vdbe *v = sqlite3GetVdbe(pParse);
100658 if( v ){
100659 sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);
 
100660 }
100661 return;
100662 }
100663
100664 /*
@@ -101182,13 +101307,12 @@
101182 */
101183 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
101184 if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
101185 if( p->azModuleArg ){
101186 int i;
101187 assert( p->nModuleArg<2 || p->azModuleArg[1]==0 );
101188 for(i=0; i<p->nModuleArg; i++){
101189 sqlite3DbFree(db, p->azModuleArg[i]);
101190 }
101191 sqlite3DbFree(db, p->azModuleArg);
101192 }
101193 }
101194
@@ -101415,11 +101539,10 @@
101415 return SQLITE_NOMEM;
101416 }
101417 pVTable->db = db;
101418 pVTable->pMod = pMod;
101419
101420 assert( pTab->azModuleArg[1]==0 );
101421 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
101422 pTab->azModuleArg[1] = db->aDb[iDb].zName;
101423
101424 /* Invoke the virtual table constructor */
101425 assert( &db->pVtabCtx );
@@ -101429,11 +101552,10 @@
101429 pPriorCtx = db->pVtabCtx;
101430 db->pVtabCtx = &sCtx;
101431 rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
101432 db->pVtabCtx = pPriorCtx;
101433 if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
101434 pTab->azModuleArg[1] = 0;
101435
101436 if( SQLITE_OK!=rc ){
101437 if( zErr==0 ){
101438 *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
101439 }else {
@@ -103838,11 +103960,13 @@
103838 }
103839 if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){
103840 /* Automatic indices are disabled at run-time */
103841 return;
103842 }
103843 if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0 ){
 
 
103844 /* We already have some kind of index in use for this query. */
103845 return;
103846 }
103847 if( pSrc->notIndexed ){
103848 /* The NOT INDEXED clause appears in the SQL. */
@@ -104794,18 +104918,10 @@
104794 ** by the index pIdx and other indices in outer loops.
104795 **
104796 ** The table being queried has a cursor number of "base". pIdx is the
104797 ** index that is postulated for use to access the table.
104798 **
104799 ** nEqCol is the number of columns of pIdx that are used as equality
104800 ** constraints and where the other side of the == is an ordered column
104801 ** or constant. An "order column" in the previous sentence means a column
104802 ** in table from an outer loop whose values will always appear in the
104803 ** correct order due to othre index, or because the outer loop generates
104804 ** a unique result. Any of the first nEqCol columns of pIdx may be missing
104805 ** from the ORDER BY clause and the match can still be a success.
104806 **
104807 ** The *pbRev value is set to 0 order 1 depending on whether or not
104808 ** pIdx should be run in the forward order or in reverse order.
104809 */
104810 static int isSortingIndex(
104811 WhereBestIdx *p, /* Best index search context */
@@ -104917,41 +105033,50 @@
104917 }
104918
104919 /* termSortOrder is 0 or 1 for whether or not the access loop should
104920 ** run forward or backwards (respectively) in order to satisfy this
104921 ** term of the ORDER BY clause. */
 
 
104922 termSortOrder = iSortOrder ^ pOBItem->sortOrder;
104923
104924 /* If X is the column in the index and ORDER BY clause, check to see
104925 ** if there are any X= or X IS NULL constraints in the WHERE clause. */
104926 pConstraint = findTerm(p->pWC, base, iColumn, p->notReady,
104927 WO_EQ|WO_ISNULL|WO_IN, pIdx);
104928 if( pConstraint==0 ){
104929 isEq = 0;
104930 }else if( pConstraint->eOperator==WO_IN ){
 
 
 
104931 break;
104932 }else if( pConstraint->eOperator==WO_ISNULL ){
104933 uniqueNotNull = 0;
104934 isEq = 1;
104935 }else if( pConstraint->prereqRight==0 ){
104936 isEq = 1;
104937 }else{
104938 Expr *pRight = pConstraint->pExpr->pRight;
104939 if( pRight->op==TK_COLUMN ){
104940 WHERETRACE((" .. isOrderedColumn(tab=%d,col=%d)",
104941 pRight->iTable, pRight->iColumn));
104942 isEq = isOrderedColumn(p, pRight->iTable, pRight->iColumn);
104943 WHERETRACE((" -> isEq=%d\n", isEq));
 
 
 
 
104944 if( isMatch && isEq>=2 && isEq!=pOBItem->sortOrder+2 ){
 
 
104945 break;
104946 }
104947 }else{
104948 isEq = 0;
104949 }
104950 }
104951 assert( pOBItem->sortOrder==0 || pOBItem->sortOrder==1 );
104952 assert( iSortOrder==0 || iSortOrder==1 );
104953 if( !isMatch ){
104954 if( isEq==0 ){
104955 break;
104956 }else{
104957 continue;
@@ -104966,11 +105091,14 @@
104966 j++;
104967 pOBItem++;
104968 if( iColumn<0 ){
104969 seenRowid = 1;
104970 break;
104971 }else if( pTab->aCol[iColumn].notNull==0 && isEq==0 ){
 
 
 
104972 uniqueNotNull = 0;
104973 }
104974 }
104975
104976 /* If we have not found at least one ORDER BY term that matches the
@@ -106624,11 +106752,11 @@
106624 sqlite3WhereEnd(pSubWInfo);
106625 }
106626 }
106627 }
106628 pLevel->u.pCovidx = pCov;
106629 pLevel->iIdxCur = iCovCur;
106630 if( pAndExpr ){
106631 pAndExpr->pLeft = 0;
106632 sqlite3ExprDelete(pParse->db, pAndExpr);
106633 }
106634 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
@@ -110720,10 +110848,11 @@
110720 /* (324) anylist ::= */ yytestcase(yyruleno==324);
110721 /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110722 /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
110723 break;
110724 };
 
110725 yygoto = yyRuleInfo[yyruleno].lhs;
110726 yysize = yyRuleInfo[yyruleno].nrhs;
110727 yypParser->yyidx -= yysize;
110728 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
110729 if( yyact < YYNSTATE ){
@@ -121244,39 +121373,43 @@
121244 /* Allocate temporary working space. */
121245 for(p=pExpr; p->pLeft; p=p->pLeft){
121246 nTmp += p->pRight->pPhrase->doclist.nList;
121247 }
121248 nTmp += p->pPhrase->doclist.nList;
121249 aTmp = sqlite3_malloc(nTmp*2);
121250 if( !aTmp ){
121251 *pRc = SQLITE_NOMEM;
121252 res = 0;
121253 }else{
121254 char *aPoslist = p->pPhrase->doclist.pList;
121255 int nToken = p->pPhrase->nToken;
121256
121257 for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){
121258 Fts3Phrase *pPhrase = p->pRight->pPhrase;
121259 int nNear = p->nNear;
121260 res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121261 }
121262
121263 aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121264 nToken = pExpr->pRight->pPhrase->nToken;
121265 for(p=pExpr->pLeft; p && res; p=p->pLeft){
121266 int nNear;
121267 Fts3Phrase *pPhrase;
121268 assert( p->pParent && p->pParent->pLeft==p );
121269 nNear = p->pParent->nNear;
121270 pPhrase = (
121271 p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase
121272 );
121273 res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121274 }
121275 }
121276
121277 sqlite3_free(aTmp);
 
 
 
 
 
 
121278 }
121279
121280 return res;
121281 }
121282
@@ -122510,11 +122643,11 @@
122510 int nConsumed = 0;
122511
122512 rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, n, &pCursor);
122513 if( rc==SQLITE_OK ){
122514 const char *zToken;
122515 int nToken, iStart, iEnd, iPosition;
122516 int nByte; /* total space to allocate */
122517
122518 rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
122519 if( rc==SQLITE_OK ){
122520 nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;
@@ -122625,11 +122758,11 @@
122625 pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);
122626 if( rc==SQLITE_OK ){
122627 int ii;
122628 for(ii=0; rc==SQLITE_OK; ii++){
122629 const char *zByte;
122630 int nByte, iBegin, iEnd, iPos;
122631 rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);
122632 if( rc==SQLITE_OK ){
122633 Fts3PhraseToken *pToken;
122634
122635 p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
@@ -124622,14 +124755,14 @@
124622 int nInput;
124623
124624 const char *azArg[64];
124625
124626 const char *zToken;
124627 int nToken;
124628 int iStart;
124629 int iEnd;
124630 int iPos;
124631 int i;
124632
124633 Tcl_Obj *pRet;
124634
124635 if( argc<2 ){
@@ -125875,17 +126008,17 @@
125875 const char *zText, /* Text of document to be inserted */
125876 int iCol, /* Column into which text is being inserted */
125877 u32 *pnWord /* OUT: Number of tokens inserted */
125878 ){
125879 int rc;
125880 int iStart;
125881 int iEnd;
125882 int iPos;
125883 int nWord = 0;
125884
125885 char const *zToken;
125886 int nToken;
125887
125888 sqlite3_tokenizer *pTokenizer = p->pTokenizer;
125889 sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
125890 sqlite3_tokenizer_cursor *pCsr;
125891 int (*xNext)(sqlite3_tokenizer_cursor *pCursor,
@@ -130030,13 +130163,13 @@
130030 sqlite3_tokenizer_cursor *pT = 0;
130031
130032 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130033 while( rc==SQLITE_OK ){
130034 char const *zToken; /* Buffer containing token */
130035 int nToken; /* Number of bytes in token */
130036 int iDum1, iDum2; /* Dummy variables */
130037 int iPos; /* Position of token in zText */
130038
130039 rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130040 if( rc==SQLITE_OK ){
130041 int i;
130042 cksum2 = cksum2 ^ fts3ChecksumEntry(
@@ -130199,13 +130332,13 @@
130199 sqlite3_tokenizer_cursor *pTC = 0;
130200
130201 rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
130202 while( rc==SQLITE_OK ){
130203 char const *zToken; /* Buffer containing token */
130204 int nToken; /* Number of bytes in token */
130205 int iDum1, iDum2; /* Dummy variables */
130206 int iPos; /* Position of token in zText */
130207
130208 rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130209 for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
130210 Fts3PhraseToken *pPT = pDef->pToken;
130211 if( (pDef->iCol>=p->nColumn || pDef->iCol==i)
@@ -131069,11 +131202,11 @@
131069 rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);
131070 if( rc!=SQLITE_OK ){
131071 return rc;
131072 }
131073 while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){
131074 const char *ZDUMMY; int DUMMY1, DUMMY2, DUMMY3;
131075 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
131076 }
131077 pMod->xClose(pC);
131078 if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }
131079
@@ -131113,12 +131246,10 @@
131113 int iPos = pFragment->iPos; /* First token of snippet */
131114 u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */
131115 int iCol = pFragment->iCol+1; /* Query column to extract text from */
131116 sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
131117 sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */
131118 const char *ZDUMMY; /* Dummy argument used with tokenizer */
131119 int DUMMY1; /* Dummy argument used with tokenizer */
131120
131121 zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);
131122 if( zDoc==0 ){
131123 if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){
131124 return SQLITE_NOMEM;
@@ -131133,14 +131264,27 @@
131133 if( rc!=SQLITE_OK ){
131134 return rc;
131135 }
131136
131137 while( rc==SQLITE_OK ){
131138 int iBegin; /* Offset in zDoc of start of token */
131139 int iFin; /* Offset in zDoc of end of token */
131140 int isHighlight; /* True for highlighted terms */
 
 
131141
 
 
 
 
 
 
 
 
 
 
 
131142 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
131143 if( rc!=SQLITE_OK ){
131144 if( rc==SQLITE_DONE ){
131145 /* Special case - the last token of the snippet is also the last token
131146 ** of the column. Append any punctuation that occurred between the end
@@ -131826,12 +131970,10 @@
131826 sqlite3_context *pCtx, /* SQLite function call context */
131827 Fts3Cursor *pCsr /* Cursor object */
131828 ){
131829 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
131830 sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;
131831 const char *ZDUMMY; /* Dummy argument used with xNext() */
131832 int NDUMMY; /* Dummy argument used with xNext() */
131833 int rc; /* Return Code */
131834 int nToken; /* Number of tokens in query */
131835 int iCol; /* Column currently being processed */
131836 StrBuffer res = {0, 0, 0}; /* Result string */
131837 TermOffsetCtx sCtx; /* Context for fts3ExprTermOffsetInit() */
@@ -131860,13 +132002,15 @@
131860 /* Loop through the table columns, appending offset information to
131861 ** string-buffer res for each column.
131862 */
131863 for(iCol=0; iCol<pTab->nColumn; iCol++){
131864 sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */
131865 int iStart;
131866 int iEnd;
131867 int iCurrent;
 
 
131868 const char *zDoc;
131869 int nDoc;
131870
131871 /* Initialize the contents of sCtx.aTerm[] for column iCol. There is
131872 ** no way that this operation can fail, so the return code from
@@ -136745,19 +136889,19 @@
136745 nInput = strlen(zInput);
136746 }
136747 nChar = nInput+1;
136748 pCsr = (IcuCursor *)sqlite3_malloc(
136749 sizeof(IcuCursor) + /* IcuCursor */
136750 nChar * sizeof(UChar) + /* IcuCursor.aChar[] */
136751 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */
136752 );
136753 if( !pCsr ){
136754 return SQLITE_NOMEM;
136755 }
136756 memset(pCsr, 0, sizeof(IcuCursor));
136757 pCsr->aChar = (UChar *)&pCsr[1];
136758 pCsr->aOffset = (int *)&pCsr->aChar[nChar];
136759
136760 pCsr->aOffset[iOut] = iInput;
136761 U8_NEXT(zInput, iInput, nInput, c);
136762 while( c>0 ){
136763 int isError = 0;
136764
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -673,11 +673,11 @@
673 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
674 ** [sqlite_version()] and [sqlite_source_id()].
675 */
676 #define SQLITE_VERSION "3.7.15"
677 #define SQLITE_VERSION_NUMBER 3007015
678 #define SQLITE_SOURCE_ID "2012-10-26 19:22:45 e24ba5bee4424e99d0859ef652164ae1397a2378"
679
680 /*
681 ** CAPI3REF: Run-Time Library Version Numbers
682 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
683 **
@@ -8439,10 +8439,12 @@
8439 SQLITE_PRIVATE void sqlite3BtreeTripAllCursors(Btree*, int);
8440
8441 SQLITE_PRIVATE void sqlite3BtreeGetMeta(Btree *pBtree, int idx, u32 *pValue);
8442 SQLITE_PRIVATE int sqlite3BtreeUpdateMeta(Btree*, int idx, u32 value);
8443
8444 SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p);
8445
8446 /*
8447 ** The second parameter to sqlite3BtreeGetMeta or sqlite3BtreeUpdateMeta
8448 ** should be one of the following values. The integer values are assigned
8449 ** to constants so that the offset of the corresponding field in an
8450 ** SQLite database header may be found using the following formula:
@@ -8953,11 +8955,11 @@
8955 SQLITE_PRIVATE void sqlite3VdbeUsesBtree(Vdbe*, int);
8956 SQLITE_PRIVATE VdbeOp *sqlite3VdbeGetOp(Vdbe*, int);
8957 SQLITE_PRIVATE int sqlite3VdbeMakeLabel(Vdbe*);
8958 SQLITE_PRIVATE void sqlite3VdbeRunOnlyOnce(Vdbe*);
8959 SQLITE_PRIVATE void sqlite3VdbeDelete(Vdbe*);
8960 SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3*,Vdbe*);
8961 SQLITE_PRIVATE void sqlite3VdbeMakeReady(Vdbe*,Parse*);
8962 SQLITE_PRIVATE int sqlite3VdbeFinalize(Vdbe*);
8963 SQLITE_PRIVATE void sqlite3VdbeResolveLabel(Vdbe*, int);
8964 SQLITE_PRIVATE int sqlite3VdbeCurrentAddr(Vdbe*);
8965 #ifdef SQLITE_DEBUG
@@ -9143,15 +9145,18 @@
9145 SQLITE_PRIVATE int sqlite3PagerRollback(Pager*);
9146 SQLITE_PRIVATE int sqlite3PagerOpenSavepoint(Pager *pPager, int n);
9147 SQLITE_PRIVATE int sqlite3PagerSavepoint(Pager *pPager, int op, int iSavepoint);
9148 SQLITE_PRIVATE int sqlite3PagerSharedLock(Pager *pPager);
9149
9150 #ifndef SQLITE_OMIT_WAL
9151 SQLITE_PRIVATE int sqlite3PagerCheckpoint(Pager *pPager, int, int*, int*);
9152 SQLITE_PRIVATE int sqlite3PagerWalSupported(Pager *pPager);
9153 SQLITE_PRIVATE int sqlite3PagerWalCallback(Pager *pPager);
9154 SQLITE_PRIVATE int sqlite3PagerOpenWal(Pager *pPager, int *pisOpen);
9155 SQLITE_PRIVATE int sqlite3PagerCloseWal(Pager *pPager);
9156 #endif
9157
9158 #ifdef SQLITE_ENABLE_ZIPVFS
9159 SQLITE_PRIVATE int sqlite3PagerWalFramesize(Pager *pPager);
9160 #endif
9161
9162 /* Functions used to query pager state and configuration. */
@@ -12220,12 +12225,14 @@
12225 SQLITE_PRIVATE int sqlite3Reprepare(Vdbe*);
12226 SQLITE_PRIVATE void sqlite3ExprListCheckLength(Parse*, ExprList*, const char*);
12227 SQLITE_PRIVATE CollSeq *sqlite3BinaryCompareCollSeq(Parse *, Expr *, Expr *);
12228 SQLITE_PRIVATE int sqlite3TempInMemory(const sqlite3*);
12229 SQLITE_PRIVATE const char *sqlite3JournalModename(int);
12230 #ifndef SQLITE_OMIT_WAL
12231 SQLITE_PRIVATE int sqlite3Checkpoint(sqlite3*, int, int, int*, int*);
12232 SQLITE_PRIVATE int sqlite3WalDefaultHook(void*,sqlite3*,const char*,int);
12233 #endif
12234
12235 /* Declarations for functions in fkey.c. All of these are replaced by
12236 ** no-op macros if OMIT_FOREIGN_KEY is defined. In this case no foreign
12237 ** key functionality is available. If OMIT_TRIGGER is defined but
12238 ** OMIT_FOREIGN_KEY is not, only some of the functions are no-oped. In
@@ -13704,11 +13711,11 @@
13711 struct Vdbe *pVdbe; /* Used to iterate through VMs */
13712 int nByte = 0; /* Used to accumulate return value */
13713
13714 db->pnBytesFreed = &nByte;
13715 for(pVdbe=db->pVdbe; pVdbe; pVdbe=pVdbe->pNext){
13716 sqlite3VdbeClearObject(db, pVdbe);
13717 }
13718 db->pnBytesFreed = 0;
13719
13720 *pHighwater = 0;
13721 *pCurrent = nByte;
@@ -22374,11 +22381,11 @@
22381 pEntry->count--;
22382 assert( pEntry->count>=0 );
22383 }
22384 sqlite3_free( elem );
22385 pH->count--;
22386 if( pH->count==0 ){
22387 assert( pH->first==0 );
22388 assert( pH->count==0 );
22389 sqlite3HashClear(pH);
22390 }
22391 }
@@ -22844,10 +22851,14 @@
22851 void *lockingContext; /* Locking style specific state */
22852 UnixUnusedFd *pUnused; /* Pre-allocated UnixUnusedFd */
22853 const char *zPath; /* Name of the file */
22854 unixShm *pShm; /* Shared memory segment information */
22855 int szChunk; /* Configured by FCNTL_CHUNK_SIZE */
22856 #ifdef __QNXNTO__
22857 int sectorSize; /* Device sector size */
22858 int deviceCharacteristics; /* Precomputed device characteristics */
22859 #endif
22860 #if SQLITE_ENABLE_LOCKING_STYLE
22861 int openFlags; /* The flags specified at open() */
22862 #endif
22863 #if SQLITE_ENABLE_LOCKING_STYLE || defined(__APPLE__)
22864 unsigned fsFlags; /* cached details from statfs() */
@@ -24920,17 +24931,17 @@
24931
24932 /*
24933 ** Close a file. Make sure the lock has been released before closing.
24934 */
24935 static int dotlockClose(sqlite3_file *id) {
24936 int rc = SQLITE_OK;
24937 if( id ){
24938 unixFile *pFile = (unixFile*)id;
24939 dotlockUnlock(id, NO_LOCK);
24940 sqlite3_free(pFile->lockingContext);
24941 rc = closeUnixFile(id);
24942 }
 
24943 return rc;
24944 }
24945 /****************** End of the dot-file lock implementation *******************
24946 ******************************************************************************/
24947
@@ -25130,14 +25141,16 @@
25141
25142 /*
25143 ** Close a file.
25144 */
25145 static int flockClose(sqlite3_file *id) {
25146 int rc = SQLITE_OK;
25147 if( id ){
25148 flockUnlock(id, NO_LOCK);
25149 rc = closeUnixFile(id);
25150 }
25151 return rc;
25152 }
25153
25154 #endif /* SQLITE_ENABLE_LOCKING_STYLE && !OS_VXWORK */
25155
25156 /******************* End of the flock lock implementation *********************
@@ -26470,14 +26483,96 @@
26483 ** SQLite code assumes this function cannot fail. It also assumes that
26484 ** if two files are created in the same file-system directory (i.e.
26485 ** a database and its journal file) that the sector size will be the
26486 ** same for both.
26487 */
26488 #ifndef __QNXNTO__
26489 static int unixSectorSize(sqlite3_file *NotUsed){
26490 UNUSED_PARAMETER(NotUsed);
26491 return SQLITE_DEFAULT_SECTOR_SIZE;
26492 }
26493 #endif
26494
26495 /*
26496 ** The following version of unixSectorSize() is optimized for QNX.
26497 */
26498 #ifdef __QNXNTO__
26499 #include <sys/dcmd_blk.h>
26500 #include <sys/statvfs.h>
26501 static int unixSectorSize(sqlite3_file *id){
26502 unixFile *pFile = (unixFile*)id;
26503 if( pFile->sectorSize == 0 ){
26504 struct statvfs fsInfo;
26505
26506 /* Set defaults for non-supported filesystems */
26507 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
26508 pFile->deviceCharacteristics = 0;
26509 if( fstatvfs(pFile->h, &fsInfo) == -1 ) {
26510 return pFile->sectorSize;
26511 }
26512
26513 if( !strcmp(fsInfo.f_basetype, "tmp") ) {
26514 pFile->sectorSize = fsInfo.f_bsize;
26515 pFile->deviceCharacteristics =
26516 SQLITE_IOCAP_ATOMIC4K | /* All ram filesystem writes are atomic */
26517 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26518 ** the write succeeds */
26519 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26520 ** so it is ordered */
26521 0;
26522 }else if( strstr(fsInfo.f_basetype, "etfs") ){
26523 pFile->sectorSize = fsInfo.f_bsize;
26524 pFile->deviceCharacteristics =
26525 /* etfs cluster size writes are atomic */
26526 (pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) |
26527 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26528 ** the write succeeds */
26529 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26530 ** so it is ordered */
26531 0;
26532 }else if( !strcmp(fsInfo.f_basetype, "qnx6") ){
26533 pFile->sectorSize = fsInfo.f_bsize;
26534 pFile->deviceCharacteristics =
26535 SQLITE_IOCAP_ATOMIC | /* All filesystem writes are atomic */
26536 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26537 ** the write succeeds */
26538 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26539 ** so it is ordered */
26540 0;
26541 }else if( !strcmp(fsInfo.f_basetype, "qnx4") ){
26542 pFile->sectorSize = fsInfo.f_bsize;
26543 pFile->deviceCharacteristics =
26544 /* full bitset of atomics from max sector size and smaller */
26545 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
26546 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26547 ** so it is ordered */
26548 0;
26549 }else if( strstr(fsInfo.f_basetype, "dos") ){
26550 pFile->sectorSize = fsInfo.f_bsize;
26551 pFile->deviceCharacteristics =
26552 /* full bitset of atomics from max sector size and smaller */
26553 ((pFile->sectorSize / 512 * SQLITE_IOCAP_ATOMIC512) << 1) - 2 |
26554 SQLITE_IOCAP_SEQUENTIAL | /* The ram filesystem has no write behind
26555 ** so it is ordered */
26556 0;
26557 }else{
26558 pFile->deviceCharacteristics =
26559 SQLITE_IOCAP_ATOMIC512 | /* blocks are atomic */
26560 SQLITE_IOCAP_SAFE_APPEND | /* growing the file does not occur until
26561 ** the write succeeds */
26562 0;
26563 }
26564 }
26565 /* Last chance verification. If the sector size isn't a multiple of 512
26566 ** then it isn't valid.*/
26567 if( pFile->sectorSize % 512 != 0 ){
26568 pFile->deviceCharacteristics = 0;
26569 pFile->sectorSize = SQLITE_DEFAULT_SECTOR_SIZE;
26570 }
26571 return pFile->sectorSize;
26572 }
26573 #endif /* __QNXNTO__ */
26574
26575 /*
26576 ** Return the device characteristics for the file.
26577 **
26578 ** This VFS is set up to return SQLITE_IOCAP_POWERSAFE_OVERWRITE by default.
@@ -26490,15 +26585,19 @@
26585 ** Hence, while POWERSAFE_OVERWRITE is on by default, there is a file-control
26586 ** available to turn it off and URI query parameter available to turn it off.
26587 */
26588 static int unixDeviceCharacteristics(sqlite3_file *id){
26589 unixFile *p = (unixFile*)id;
26590 int rc = 0;
26591 #ifdef __QNXNTO__
26592 if( p->sectorSize==0 ) unixSectorSize(id);
26593 rc = p->deviceCharacteristics;
26594 #endif
26595 if( p->ctrlFlags & UNIXFILE_PSOW ){
26596 rc |= SQLITE_IOCAP_POWERSAFE_OVERWRITE;
 
 
26597 }
26598 return rc;
26599 }
26600
26601 #ifndef SQLITE_OMIT_WAL
26602
26603
@@ -26932,11 +27031,11 @@
27031 while(pShmNode->nRegion<=iRegion){
27032 void *pMem;
27033 if( pShmNode->h>=0 ){
27034 pMem = mmap(0, szRegion,
27035 pShmNode->isReadonly ? PROT_READ : PROT_READ|PROT_WRITE,
27036 MAP_SHARED, pShmNode->h, szRegion*(i64)pShmNode->nRegion
27037 );
27038 if( pMem==MAP_FAILED ){
27039 rc = unixLogError(SQLITE_IOERR_SHMMAP, "mmap", pShmNode->zFilename);
27040 goto shmpage_out;
27041 }
@@ -32130,11 +32229,12 @@
32229 if( !osWriteFile(pFile->h, aRem, nRem, &nWrite, &overlapped) ){
32230 #endif
32231 if( retryIoerr(&nRetry, &lastErrno) ) continue;
32232 break;
32233 }
32234 assert( nWrite==0 || nWrite<=(DWORD)nRem );
32235 if( nWrite==0 || nWrite>(DWORD)nRem ){
32236 lastErrno = osGetLastError();
32237 break;
32238 }
32239 #if !SQLITE_OS_WINCE
32240 offset += nWrite;
@@ -42790,11 +42890,11 @@
42890 UNUSED_PARAMETER(isDirectMode);
42891 #else
42892 # define DIRECT_MODE isDirectMode
42893 #endif
42894
42895 if( !pPager->changeCountDone && ALWAYS(pPager->dbSize>0) ){
42896 PgHdr *pPgHdr; /* Reference to page 1 */
42897
42898 assert( !pPager->tempFile && isOpen(pPager->fd) );
42899
42900 /* Open page 1 of the file for writing. */
@@ -43010,19 +43110,18 @@
43110 #endif
43111 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
43112
43113 /* If this transaction has made the database smaller, then all pages
43114 ** being discarded by the truncation must be written to the journal
43115 ** file.
43116 **
43117 ** Before reading the pages with page numbers larger than the
43118 ** current value of Pager.dbSize, set dbSize back to the value
43119 ** that it took at the start of the transaction. Otherwise, the
43120 ** calls to sqlite3PagerGet() return zeroed pages instead of
43121 ** reading data from the database file.
43122 */
 
43123 if( pPager->dbSize<pPager->dbOrigSize
43124 && pPager->journalMode!=PAGER_JOURNALMODE_OFF
43125 ){
43126 Pgno i; /* Iterator variable */
43127 const Pgno iSkip = PAGER_MJ_PGNO(pPager); /* Pending lock page */
@@ -43038,11 +43137,10 @@
43137 if( rc!=SQLITE_OK ) goto commit_phase_one_exit;
43138 }
43139 }
43140 pPager->dbSize = dbSize;
43141 }
 
43142
43143 /* Write the master journal name into the journal file. If a master
43144 ** journal file name has already been written to the journal file,
43145 ** or if zMaster is NULL (no master journal), then this call is a no-op.
43146 */
@@ -44041,10 +44139,12 @@
44139 }
44140 }
44141 return rc;
44142 }
44143
44144 #endif /* !SQLITE_OMIT_WAL */
44145
44146 #ifdef SQLITE_ENABLE_ZIPVFS
44147 /*
44148 ** A read-lock must be held on the pager when this function is called. If
44149 ** the pager is in WAL mode and the WAL file currently contains one or more
44150 ** frames, return the size in bytes of the page images stored within the
@@ -44070,12 +44170,10 @@
44170 CODEC2(pPg->pPager, pPg->pData, pPg->pgno, 6, return 0, aData);
44171 return aData;
44172 }
44173 #endif /* SQLITE_HAS_CODEC */
44174
 
 
44175 #endif /* SQLITE_OMIT_DISKIO */
44176
44177 /************** End of pager.c ***********************************************/
44178 /************** Begin file wal.c *********************************************/
44179 /*
@@ -46595,11 +46693,11 @@
46693 ** committed. As a result, the call to xUndo may not fail.
46694 */
46695 assert( walFramePgno(pWal, iFrame)!=1 );
46696 rc = xUndo(pUndoCtx, walFramePgno(pWal, iFrame));
46697 }
46698 if( iMax!=pWal->hdr.mxFrame ) walCleanupHash(pWal);
46699 }
46700 assert( rc==SQLITE_OK );
46701 return rc;
46702 }
46703
@@ -50648,10 +50746,24 @@
50746 #endif
50747 pBt->nPage = 1;
50748 data[31] = 1;
50749 return SQLITE_OK;
50750 }
50751
50752 /*
50753 ** Initialize the first page of the database file (creating a database
50754 ** consisting of a single page and no schema objects). Return SQLITE_OK
50755 ** if successful, or an SQLite error code otherwise.
50756 */
50757 SQLITE_PRIVATE int sqlite3BtreeNewDb(Btree *p){
50758 int rc;
50759 sqlite3BtreeEnter(p);
50760 p->pBt->nPage = 0;
50761 rc = newDatabase(p->pBt);
50762 sqlite3BtreeLeave(p);
50763 return rc;
50764 }
50765
50766 /*
50767 ** Attempt to start a new transaction. A write-transaction
50768 ** is started if the second argument is nonzero, otherwise a read-
50769 ** transaction. If the second argument is 2 or more and exclusive
@@ -53848,11 +53960,11 @@
53960 assert( sqlite3_mutex_held(pPage->pBt->mutex) );
53961 assert( sqlite3PagerIswriteable(pParent->pDbPage) );
53962 assert( pPage->nOverflow==1 );
53963
53964 /* This error condition is now caught prior to reaching this function */
53965 if( pPage->nCell==0 ) return SQLITE_CORRUPT_BKPT;
53966
53967 /* Allocate a new page. This page will become the right-sibling of
53968 ** pPage. Make the parent page writable, so that the new divider cell
53969 ** may be inserted. If both these operations are successful, proceed.
53970 */
@@ -56866,11 +56978,17 @@
56978 ** is to make sure that the schema-version really does change in
56979 ** the case where the source and destination databases have the
56980 ** same schema version.
56981 */
56982 if( rc==SQLITE_DONE ){
56983 if( nSrcPage==0 ){
56984 rc = sqlite3BtreeNewDb(p->pDest);
56985 nSrcPage = 1;
56986 }
56987 if( rc==SQLITE_OK || rc==SQLITE_DONE ){
56988 rc = sqlite3BtreeUpdateMeta(p->pDest,1,p->iDestSchema+1);
56989 }
56990 if( rc==SQLITE_OK ){
56991 if( p->pDestDb ){
56992 sqlite3ResetAllSchemasOfConnection(p->pDestDb);
56993 }
56994 if( destMode==PAGER_JOURNALMODE_WAL ){
@@ -56900,10 +57018,11 @@
57018 nDestTruncate--;
57019 }
57020 }else{
57021 nDestTruncate = nSrcPage * (pgszSrc/pgszDest);
57022 }
57023 assert( nDestTruncate>0 );
57024 sqlite3PagerTruncateImage(pDestPager, nDestTruncate);
57025
57026 if( pgszSrc<pgszDest ){
57027 /* If the source page-size is smaller than the destination page-size,
57028 ** two extra things may need to happen:
@@ -56918,11 +57037,12 @@
57037 sqlite3_file * const pFile = sqlite3PagerFile(pDestPager);
57038 i64 iOff;
57039 i64 iEnd;
57040
57041 assert( pFile );
57042 assert( nDestTruncate==0
57043 || (i64)nDestTruncate*(i64)pgszDest >= iSize || (
57044 nDestTruncate==(int)(PENDING_BYTE_PAGE(p->pDest->pBt)-1)
57045 && iSize>=PENDING_BYTE && iSize<=PENDING_BYTE+pgszDest
57046 ));
57047
57048 /* This call ensures that all data required to recreate the original
@@ -60769,16 +60889,18 @@
60889 }
60890 }
60891 }
60892
60893 /*
60894 ** Free all memory associated with the Vdbe passed as the second argument,
60895 ** except for object itself, which is preserved.
60896 **
60897 ** The difference between this function and sqlite3VdbeDelete() is that
60898 ** VdbeDelete() also unlinks the Vdbe from the list of VMs associated with
60899 ** the database connection and frees the object itself.
60900 */
60901 SQLITE_PRIVATE void sqlite3VdbeClearObject(sqlite3 *db, Vdbe *p){
60902 SubProgram *pSub, *pNext;
60903 int i;
60904 assert( p->db==0 || p->db==db );
60905 releaseMemArray(p->aVar, p->nVar);
60906 releaseMemArray(p->aColName, p->nResColumn*COLNAME_N);
@@ -60795,11 +60917,10 @@
60917 sqlite3DbFree(db, p->pFree);
60918 #if defined(SQLITE_ENABLE_TREE_EXPLAIN)
60919 sqlite3DbFree(db, p->zExplain);
60920 sqlite3DbFree(db, p->pExplain);
60921 #endif
 
60922 }
60923
60924 /*
60925 ** Delete an entire VDBE.
60926 */
@@ -60807,10 +60928,11 @@
60928 sqlite3 *db;
60929
60930 if( NEVER(p==0) ) return;
60931 db = p->db;
60932 assert( sqlite3_mutex_held(db->mutex) );
60933 sqlite3VdbeClearObject(db, p);
60934 if( p->pPrev ){
60935 p->pPrev->pNext = p->pNext;
60936 }else{
60937 assert( db->pVdbe==p );
60938 db->pVdbe = p->pNext;
@@ -60818,11 +60940,11 @@
60940 if( p->pNext ){
60941 p->pNext->pPrev = p->pPrev;
60942 }
60943 p->magic = VDBE_MAGIC_DEAD;
60944 p->db = 0;
60945 sqlite3DbFree(db, p);
60946 }
60947
60948 /*
60949 ** Make sure the cursor p is ready to read or write the row to which it
60950 ** was last positioned. Return an error code if an OOM fault or I/O error
@@ -70730,12 +70852,15 @@
70852 if( iBuf==0 ){
70853 int nRead; /* Bytes to read from disk */
70854 int rc; /* sqlite3OsRead() return code */
70855
70856 /* Determine how many bytes of data to read. */
70857 if( (p->iEof - p->iReadOff) > (i64)p->nBuffer ){
70858 nRead = p->nBuffer;
70859 }else{
70860 nRead = (int)(p->iEof - p->iReadOff);
70861 }
70862 assert( nRead>0 );
70863
70864 /* Read data from the file. Return early if an error occurs. */
70865 rc = sqlite3OsRead(p->pFile, p->aBuffer, nRead, p->iReadOff);
70866 assert( rc!=SQLITE_IOERR_SHORT_READ );
@@ -72415,11 +72540,11 @@
72540 Schema *pSchema = 0; /* Schema of the expression */
72541 int isTrigger = 0;
72542
72543 assert( pNC ); /* the name context cannot be NULL. */
72544 assert( zCol ); /* The Z in X.Y.Z cannot be NULL */
72545 assert( !ExprHasAnyProperty(pExpr, EP_TokenOnly|EP_Reduced) );
72546
72547 /* Initialize the node to no-match */
72548 pExpr->iTable = -1;
72549 pExpr->pTab = 0;
72550 ExprSetIrreducible(pExpr);
@@ -82417,10 +82542,11 @@
82542 }
82543 if( iLargest==0 ){
82544 return;
82545 }else{
82546 int iDb = sqlite3SchemaToIndex(pParse->db, pTab->pSchema);
82547 assert( iDb>=0 && iDb<pParse->db->nDb );
82548 destroyRootPage(pParse, iLargest, iDb);
82549 iDestroyed = iLargest;
82550 }
82551 }
82552 #endif
@@ -92962,17 +93088,16 @@
93088 pParse->nMem = 2;
93089 sqlite3VdbeSetColName(v, 0, COLNAME_NAME, "database", SQLITE_STATIC);
93090 sqlite3VdbeSetColName(v, 1, COLNAME_NAME, "status", SQLITE_STATIC);
93091 for(i=0; i<db->nDb; i++){
93092 Btree *pBt;
 
93093 const char *zState = "unknown";
93094 int j;
93095 if( db->aDb[i].zName==0 ) continue;
93096 sqlite3VdbeAddOp4(v, OP_String8, 0, 1, 0, db->aDb[i].zName, P4_STATIC);
93097 pBt = db->aDb[i].pBt;
93098 if( pBt==0 || sqlite3BtreePager(pBt)==0 ){
93099 zState = "closed";
93100 }else if( sqlite3_file_control(db, i ? db->aDb[i].zName : 0,
93101 SQLITE_FCNTL_LOCKSTATE, &j)==SQLITE_OK ){
93102 zState = azLockName[j];
93103 }
@@ -97007,14 +97132,13 @@
97132 ** "a" we substitute "x*3" and every place we see "b" we substitute "y+10".
97133 */
97134 pList = pParent->pEList;
97135 for(i=0; i<pList->nExpr; i++){
97136 if( pList->a[i].zName==0 ){
97137 char *zName = sqlite3DbStrDup(db, pList->a[i].zSpan);
97138 sqlite3Dequote(zName);
97139 pList->a[i].zName = zName;
 
97140 }
97141 }
97142 substExprList(db, pParent->pEList, iParent, pSub->pEList);
97143 if( isAgg ){
97144 substExprList(db, pParent->pGroupBy, iParent, pSub->pEList);
@@ -100655,10 +100779,11 @@
100779 */
100780 SQLITE_PRIVATE void sqlite3Vacuum(Parse *pParse){
100781 Vdbe *v = sqlite3GetVdbe(pParse);
100782 if( v ){
100783 sqlite3VdbeAddOp2(v, OP_Vacuum, 0, 0);
100784 sqlite3VdbeUsesBtree(v, 0);
100785 }
100786 return;
100787 }
100788
100789 /*
@@ -101182,13 +101307,12 @@
101307 */
101308 SQLITE_PRIVATE void sqlite3VtabClear(sqlite3 *db, Table *p){
101309 if( !db || db->pnBytesFreed==0 ) vtabDisconnectAll(0, p);
101310 if( p->azModuleArg ){
101311 int i;
 
101312 for(i=0; i<p->nModuleArg; i++){
101313 if( i!=1 ) sqlite3DbFree(db, p->azModuleArg[i]);
101314 }
101315 sqlite3DbFree(db, p->azModuleArg);
101316 }
101317 }
101318
@@ -101415,11 +101539,10 @@
101539 return SQLITE_NOMEM;
101540 }
101541 pVTable->db = db;
101542 pVTable->pMod = pMod;
101543
 
101544 iDb = sqlite3SchemaToIndex(db, pTab->pSchema);
101545 pTab->azModuleArg[1] = db->aDb[iDb].zName;
101546
101547 /* Invoke the virtual table constructor */
101548 assert( &db->pVtabCtx );
@@ -101429,11 +101552,10 @@
101552 pPriorCtx = db->pVtabCtx;
101553 db->pVtabCtx = &sCtx;
101554 rc = xConstruct(db, pMod->pAux, nArg, azArg, &pVTable->pVtab, &zErr);
101555 db->pVtabCtx = pPriorCtx;
101556 if( rc==SQLITE_NOMEM ) db->mallocFailed = 1;
 
101557
101558 if( SQLITE_OK!=rc ){
101559 if( zErr==0 ){
101560 *pzErr = sqlite3MPrintf(db, "vtable constructor failed: %s", zModuleName);
101561 }else {
@@ -103838,11 +103960,13 @@
103960 }
103961 if( (pParse->db->flags & SQLITE_AutoIndex)==0 ){
103962 /* Automatic indices are disabled at run-time */
103963 return;
103964 }
103965 if( (p->cost.plan.wsFlags & WHERE_NOT_FULLSCAN)!=0
103966 && (p->cost.plan.wsFlags & WHERE_COVER_SCAN)==0
103967 ){
103968 /* We already have some kind of index in use for this query. */
103969 return;
103970 }
103971 if( pSrc->notIndexed ){
103972 /* The NOT INDEXED clause appears in the SQL. */
@@ -104794,18 +104918,10 @@
104918 ** by the index pIdx and other indices in outer loops.
104919 **
104920 ** The table being queried has a cursor number of "base". pIdx is the
104921 ** index that is postulated for use to access the table.
104922 **
 
 
 
 
 
 
 
 
104923 ** The *pbRev value is set to 0 order 1 depending on whether or not
104924 ** pIdx should be run in the forward order or in reverse order.
104925 */
104926 static int isSortingIndex(
104927 WhereBestIdx *p, /* Best index search context */
@@ -104917,41 +105033,50 @@
105033 }
105034
105035 /* termSortOrder is 0 or 1 for whether or not the access loop should
105036 ** run forward or backwards (respectively) in order to satisfy this
105037 ** term of the ORDER BY clause. */
105038 assert( pOBItem->sortOrder==0 || pOBItem->sortOrder==1 );
105039 assert( iSortOrder==0 || iSortOrder==1 );
105040 termSortOrder = iSortOrder ^ pOBItem->sortOrder;
105041
105042 /* If X is the column in the index and ORDER BY clause, check to see
105043 ** if there are any X= or X IS NULL constraints in the WHERE clause. */
105044 pConstraint = findTerm(p->pWC, base, iColumn, p->notReady,
105045 WO_EQ|WO_ISNULL|WO_IN, pIdx);
105046 if( pConstraint==0 ){
105047 isEq = 0;
105048 }else if( pConstraint->eOperator==WO_IN ){
105049 /* Constraints of the form: "X IN ..." cannot be used with an ORDER BY
105050 ** because we do not know in what order the values on the RHS of the IN
105051 ** operator will occur. */
105052 break;
105053 }else if( pConstraint->eOperator==WO_ISNULL ){
105054 uniqueNotNull = 0;
105055 isEq = 1; /* "X IS NULL" means X has only a single value */
105056 }else if( pConstraint->prereqRight==0 ){
105057 isEq = 1; /* Constraint "X=constant" means X has only a single value */
105058 }else{
105059 Expr *pRight = pConstraint->pExpr->pRight;
105060 if( pRight->op==TK_COLUMN ){
105061 WHERETRACE((" .. isOrderedColumn(tab=%d,col=%d)",
105062 pRight->iTable, pRight->iColumn));
105063 isEq = isOrderedColumn(p, pRight->iTable, pRight->iColumn);
105064 WHERETRACE((" -> isEq=%d\n", isEq));
105065
105066 /* If the constraint is of the form X=Y where Y is an ordered value
105067 ** in an outer loop, then make sure the sort order of Y matches the
105068 ** sort order required for X. */
105069 if( isMatch && isEq>=2 && isEq!=pOBItem->sortOrder+2 ){
105070 testcase( isEq==2 );
105071 testcase( isEq==3 );
105072 break;
105073 }
105074 }else{
105075 isEq = 0; /* "X=expr" places no ordering constraints on X */
105076 }
105077 }
 
 
105078 if( !isMatch ){
105079 if( isEq==0 ){
105080 break;
105081 }else{
105082 continue;
@@ -104966,11 +105091,14 @@
105091 j++;
105092 pOBItem++;
105093 if( iColumn<0 ){
105094 seenRowid = 1;
105095 break;
105096 }else if( pTab->aCol[iColumn].notNull==0 && isEq!=1 ){
105097 testcase( isEq==0 );
105098 testcase( isEq==2 );
105099 testcase( isEq==3 );
105100 uniqueNotNull = 0;
105101 }
105102 }
105103
105104 /* If we have not found at least one ORDER BY term that matches the
@@ -106624,11 +106752,11 @@
106752 sqlite3WhereEnd(pSubWInfo);
106753 }
106754 }
106755 }
106756 pLevel->u.pCovidx = pCov;
106757 if( pCov ) pLevel->iIdxCur = iCovCur;
106758 if( pAndExpr ){
106759 pAndExpr->pLeft = 0;
106760 sqlite3ExprDelete(pParse->db, pAndExpr);
106761 }
106762 sqlite3VdbeChangeP1(v, iRetInit, sqlite3VdbeCurrentAddr(v));
@@ -110720,10 +110848,11 @@
110848 /* (324) anylist ::= */ yytestcase(yyruleno==324);
110849 /* (325) anylist ::= anylist LP anylist RP */ yytestcase(yyruleno==325);
110850 /* (326) anylist ::= anylist ANY */ yytestcase(yyruleno==326);
110851 break;
110852 };
110853 assert( yyruleno>=0 && yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
110854 yygoto = yyRuleInfo[yyruleno].lhs;
110855 yysize = yyRuleInfo[yyruleno].nrhs;
110856 yypParser->yyidx -= yysize;
110857 yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
110858 if( yyact < YYNSTATE ){
@@ -121244,39 +121373,43 @@
121373 /* Allocate temporary working space. */
121374 for(p=pExpr; p->pLeft; p=p->pLeft){
121375 nTmp += p->pRight->pPhrase->doclist.nList;
121376 }
121377 nTmp += p->pPhrase->doclist.nList;
121378 if( nTmp==0 ){
 
 
121379 res = 0;
121380 }else{
121381 aTmp = sqlite3_malloc(nTmp*2);
121382 if( !aTmp ){
121383 *pRc = SQLITE_NOMEM;
121384 res = 0;
121385 }else{
121386 char *aPoslist = p->pPhrase->doclist.pList;
121387 int nToken = p->pPhrase->nToken;
121388
121389 for(p=p->pParent;res && p && p->eType==FTSQUERY_NEAR; p=p->pParent){
121390 Fts3Phrase *pPhrase = p->pRight->pPhrase;
121391 int nNear = p->nNear;
121392 res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121393 }
121394
121395 aPoslist = pExpr->pRight->pPhrase->doclist.pList;
121396 nToken = pExpr->pRight->pPhrase->nToken;
121397 for(p=pExpr->pLeft; p && res; p=p->pLeft){
121398 int nNear;
121399 Fts3Phrase *pPhrase;
121400 assert( p->pParent && p->pParent->pLeft==p );
121401 nNear = p->pParent->nNear;
121402 pPhrase = (
121403 p->eType==FTSQUERY_NEAR ? p->pRight->pPhrase : p->pPhrase
121404 );
121405 res = fts3EvalNearTrim(nNear, aTmp, &aPoslist, &nToken, pPhrase);
121406 }
121407 }
121408
121409 sqlite3_free(aTmp);
121410 }
121411 }
121412
121413 return res;
121414 }
121415
@@ -122510,11 +122643,11 @@
122643 int nConsumed = 0;
122644
122645 rc = sqlite3Fts3OpenTokenizer(pTokenizer, pParse->iLangid, z, n, &pCursor);
122646 if( rc==SQLITE_OK ){
122647 const char *zToken;
122648 int nToken = 0, iStart = 0, iEnd = 0, iPosition = 0;
122649 int nByte; /* total space to allocate */
122650
122651 rc = pModule->xNext(pCursor, &zToken, &nToken, &iStart, &iEnd, &iPosition);
122652 if( rc==SQLITE_OK ){
122653 nByte = sizeof(Fts3Expr) + sizeof(Fts3Phrase) + nToken;
@@ -122625,11 +122758,11 @@
122758 pTokenizer, pParse->iLangid, zInput, nInput, &pCursor);
122759 if( rc==SQLITE_OK ){
122760 int ii;
122761 for(ii=0; rc==SQLITE_OK; ii++){
122762 const char *zByte;
122763 int nByte = 0, iBegin = 0, iEnd = 0, iPos = 0;
122764 rc = pModule->xNext(pCursor, &zByte, &nByte, &iBegin, &iEnd, &iPos);
122765 if( rc==SQLITE_OK ){
122766 Fts3PhraseToken *pToken;
122767
122768 p = fts3ReallocOrFree(p, nSpace + ii*sizeof(Fts3PhraseToken));
@@ -124622,14 +124755,14 @@
124755 int nInput;
124756
124757 const char *azArg[64];
124758
124759 const char *zToken;
124760 int nToken = 0;
124761 int iStart = 0;
124762 int iEnd = 0;
124763 int iPos = 0;
124764 int i;
124765
124766 Tcl_Obj *pRet;
124767
124768 if( argc<2 ){
@@ -125875,17 +126008,17 @@
126008 const char *zText, /* Text of document to be inserted */
126009 int iCol, /* Column into which text is being inserted */
126010 u32 *pnWord /* OUT: Number of tokens inserted */
126011 ){
126012 int rc;
126013 int iStart = 0;
126014 int iEnd = 0;
126015 int iPos = 0;
126016 int nWord = 0;
126017
126018 char const *zToken;
126019 int nToken = 0;
126020
126021 sqlite3_tokenizer *pTokenizer = p->pTokenizer;
126022 sqlite3_tokenizer_module const *pModule = pTokenizer->pModule;
126023 sqlite3_tokenizer_cursor *pCsr;
126024 int (*xNext)(sqlite3_tokenizer_cursor *pCursor,
@@ -130030,13 +130163,13 @@
130163 sqlite3_tokenizer_cursor *pT = 0;
130164
130165 rc = sqlite3Fts3OpenTokenizer(p->pTokenizer, iLang, zText, nText, &pT);
130166 while( rc==SQLITE_OK ){
130167 char const *zToken; /* Buffer containing token */
130168 int nToken = 0; /* Number of bytes in token */
130169 int iDum1 = 0, iDum2 = 0; /* Dummy variables */
130170 int iPos = 0; /* Position of token in zText */
130171
130172 rc = pModule->xNext(pT, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130173 if( rc==SQLITE_OK ){
130174 int i;
130175 cksum2 = cksum2 ^ fts3ChecksumEntry(
@@ -130199,13 +130332,13 @@
130332 sqlite3_tokenizer_cursor *pTC = 0;
130333
130334 rc = sqlite3Fts3OpenTokenizer(pT, pCsr->iLangid, zText, -1, &pTC);
130335 while( rc==SQLITE_OK ){
130336 char const *zToken; /* Buffer containing token */
130337 int nToken = 0; /* Number of bytes in token */
130338 int iDum1 = 0, iDum2 = 0; /* Dummy variables */
130339 int iPos = 0; /* Position of token in zText */
130340
130341 rc = pModule->xNext(pTC, &zToken, &nToken, &iDum1, &iDum2, &iPos);
130342 for(pDef=pCsr->pDeferred; pDef && rc==SQLITE_OK; pDef=pDef->pNext){
130343 Fts3PhraseToken *pPT = pDef->pToken;
130344 if( (pDef->iCol>=p->nColumn || pDef->iCol==i)
@@ -131069,11 +131202,11 @@
131202 rc = sqlite3Fts3OpenTokenizer(pTab->pTokenizer, iLangid, zDoc, nDoc, &pC);
131203 if( rc!=SQLITE_OK ){
131204 return rc;
131205 }
131206 while( rc==SQLITE_OK && iCurrent<(nSnippet+nDesired) ){
131207 const char *ZDUMMY; int DUMMY1 = 0, DUMMY2 = 0, DUMMY3 = 0;
131208 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &DUMMY2, &DUMMY3, &iCurrent);
131209 }
131210 pMod->xClose(pC);
131211 if( rc!=SQLITE_OK && rc!=SQLITE_DONE ){ return rc; }
131212
@@ -131113,12 +131246,10 @@
131246 int iPos = pFragment->iPos; /* First token of snippet */
131247 u64 hlmask = pFragment->hlmask; /* Highlight-mask for snippet */
131248 int iCol = pFragment->iCol+1; /* Query column to extract text from */
131249 sqlite3_tokenizer_module *pMod; /* Tokenizer module methods object */
131250 sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor open on zDoc/nDoc */
 
 
131251
131252 zDoc = (const char *)sqlite3_column_text(pCsr->pStmt, iCol);
131253 if( zDoc==0 ){
131254 if( sqlite3_column_type(pCsr->pStmt, iCol)!=SQLITE_NULL ){
131255 return SQLITE_NOMEM;
@@ -131133,14 +131264,27 @@
131264 if( rc!=SQLITE_OK ){
131265 return rc;
131266 }
131267
131268 while( rc==SQLITE_OK ){
131269 const char *ZDUMMY; /* Dummy argument used with tokenizer */
131270 int DUMMY1 = -1; /* Dummy argument used with tokenizer */
131271 int iBegin = 0; /* Offset in zDoc of start of token */
131272 int iFin = 0; /* Offset in zDoc of end of token */
131273 int isHighlight = 0; /* True for highlighted terms */
131274
131275 /* Variable DUMMY1 is initialized to a negative value above. Elsewhere
131276 ** in the FTS code the variable that the third argument to xNext points to
131277 ** is initialized to zero before the first (*but not necessarily
131278 ** subsequent*) call to xNext(). This is done for a particular application
131279 ** that needs to know whether or not the tokenizer is being used for
131280 ** snippet generation or for some other purpose.
131281 **
131282 ** Extreme care is required when writing code to depend on this
131283 ** initialization. It is not a documented part of the tokenizer interface.
131284 ** If a tokenizer is used directly by any code outside of FTS, this
131285 ** convention might not be respected. */
131286 rc = pMod->xNext(pC, &ZDUMMY, &DUMMY1, &iBegin, &iFin, &iCurrent);
131287 if( rc!=SQLITE_OK ){
131288 if( rc==SQLITE_DONE ){
131289 /* Special case - the last token of the snippet is also the last token
131290 ** of the column. Append any punctuation that occurred between the end
@@ -131826,12 +131970,10 @@
131970 sqlite3_context *pCtx, /* SQLite function call context */
131971 Fts3Cursor *pCsr /* Cursor object */
131972 ){
131973 Fts3Table *pTab = (Fts3Table *)pCsr->base.pVtab;
131974 sqlite3_tokenizer_module const *pMod = pTab->pTokenizer->pModule;
 
 
131975 int rc; /* Return Code */
131976 int nToken; /* Number of tokens in query */
131977 int iCol; /* Column currently being processed */
131978 StrBuffer res = {0, 0, 0}; /* Result string */
131979 TermOffsetCtx sCtx; /* Context for fts3ExprTermOffsetInit() */
@@ -131860,13 +132002,15 @@
132002 /* Loop through the table columns, appending offset information to
132003 ** string-buffer res for each column.
132004 */
132005 for(iCol=0; iCol<pTab->nColumn; iCol++){
132006 sqlite3_tokenizer_cursor *pC; /* Tokenizer cursor */
132007 const char *ZDUMMY; /* Dummy argument used with xNext() */
132008 int NDUMMY = 0; /* Dummy argument used with xNext() */
132009 int iStart = 0;
132010 int iEnd = 0;
132011 int iCurrent = 0;
132012 const char *zDoc;
132013 int nDoc;
132014
132015 /* Initialize the contents of sCtx.aTerm[] for column iCol. There is
132016 ** no way that this operation can fail, so the return code from
@@ -136745,19 +136889,19 @@
136889 nInput = strlen(zInput);
136890 }
136891 nChar = nInput+1;
136892 pCsr = (IcuCursor *)sqlite3_malloc(
136893 sizeof(IcuCursor) + /* IcuCursor */
136894 ((nChar+3)&~3) * sizeof(UChar) + /* IcuCursor.aChar[] */
136895 (nChar+1) * sizeof(int) /* IcuCursor.aOffset[] */
136896 );
136897 if( !pCsr ){
136898 return SQLITE_NOMEM;
136899 }
136900 memset(pCsr, 0, sizeof(IcuCursor));
136901 pCsr->aChar = (UChar *)&pCsr[1];
136902 pCsr->aOffset = (int *)&pCsr->aChar[(nChar+3)&~3];
136903
136904 pCsr->aOffset[iOut] = iInput;
136905 U8_NEXT(zInput, iInput, nInput, c);
136906 while( c>0 ){
136907 int isError = 0;
136908
+1 -1
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107107
** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108108
** [sqlite_version()] and [sqlite_source_id()].
109109
*/
110110
#define SQLITE_VERSION "3.7.15"
111111
#define SQLITE_VERSION_NUMBER 3007015
112
-#define SQLITE_SOURCE_ID "2012-10-09 01:39:25 01dc032b5bbd9c9ebb1965f176ca5d732cda85ea"
112
+#define SQLITE_SOURCE_ID "2012-10-26 19:22:45 e24ba5bee4424e99d0859ef652164ae1397a2378"
113113
114114
/*
115115
** CAPI3REF: Run-Time Library Version Numbers
116116
** KEYWORDS: sqlite3_version, sqlite3_sourceid
117117
**
118118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.15"
111 #define SQLITE_VERSION_NUMBER 3007015
112 #define SQLITE_SOURCE_ID "2012-10-09 01:39:25 01dc032b5bbd9c9ebb1965f176ca5d732cda85ea"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/sqlite3.h
+++ src/sqlite3.h
@@ -107,11 +107,11 @@
107 ** [sqlite3_libversion_number()], [sqlite3_sourceid()],
108 ** [sqlite_version()] and [sqlite_source_id()].
109 */
110 #define SQLITE_VERSION "3.7.15"
111 #define SQLITE_VERSION_NUMBER 3007015
112 #define SQLITE_SOURCE_ID "2012-10-26 19:22:45 e24ba5bee4424e99d0859ef652164ae1397a2378"
113
114 /*
115 ** CAPI3REF: Run-Time Library Version Numbers
116 ** KEYWORDS: sqlite3_version, sqlite3_sourceid
117 **
118
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1017,14 +1017,22 @@
10171017
** repository.
10181018
*/
10191019
static int in_this_repo(const char *zUuid){
10201020
static Stmt q;
10211021
int rc;
1022
+ int n;
1023
+ char zU2[UUID_SIZE+1];
10221024
db_static_prepare(&q,
1023
- "SELECT 1 FROM blob WHERE uuid>=:u AND +uuid GLOB (:u || '*')"
1025
+ "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
10241026
);
10251027
db_bind_text(&q, ":u", zUuid);
1028
+ n = (int)strlen(zUuid);
1029
+ if( n>=sizeof(zU2) ) n = sizeof(zU2)-1;
1030
+ memcpy(zU2, zUuid, n);
1031
+ zU2[n-1]++;
1032
+ zU2[n] = 0;
1033
+ db_bind_text(&q, ":u2", zU2);
10261034
rc = db_step(&q);
10271035
db_reset(&q);
10281036
return rc==SQLITE_ROW;
10291037
}
10301038
10311039
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1017,14 +1017,22 @@
1017 ** repository.
1018 */
1019 static int in_this_repo(const char *zUuid){
1020 static Stmt q;
1021 int rc;
 
 
1022 db_static_prepare(&q,
1023 "SELECT 1 FROM blob WHERE uuid>=:u AND +uuid GLOB (:u || '*')"
1024 );
1025 db_bind_text(&q, ":u", zUuid);
 
 
 
 
 
 
1026 rc = db_step(&q);
1027 db_reset(&q);
1028 return rc==SQLITE_ROW;
1029 }
1030
1031
--- src/wikiformat.c
+++ src/wikiformat.c
@@ -1017,14 +1017,22 @@
1017 ** repository.
1018 */
1019 static int in_this_repo(const char *zUuid){
1020 static Stmt q;
1021 int rc;
1022 int n;
1023 char zU2[UUID_SIZE+1];
1024 db_static_prepare(&q,
1025 "SELECT 1 FROM blob WHERE uuid>=:u AND uuid<:u2"
1026 );
1027 db_bind_text(&q, ":u", zUuid);
1028 n = (int)strlen(zUuid);
1029 if( n>=sizeof(zU2) ) n = sizeof(zU2)-1;
1030 memcpy(zU2, zUuid, n);
1031 zU2[n-1]++;
1032 zU2[n] = 0;
1033 db_bind_text(&q, ":u2", zU2);
1034 rc = db_step(&q);
1035 db_reset(&q);
1036 return rc==SQLITE_ROW;
1037 }
1038
1039

Keyboard Shortcuts

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