Fossil SCM
Fix uninitialized variable in command-line shell [http://www.sqlite.org/src/info/dc2ac024d31a898b|dc2ac024d3] and other shell improvements, cherry-picked from SQLite trunk.
Commit
63256980eef3cff6b1022ddefdc4a7c6a3a59383
Parent
1a6892aeb7c2484…
1 file changed
+5
-5
+5
-5
| --- src/shell.c | ||
| +++ src/shell.c | ||
| @@ -163,11 +163,11 @@ | ||
| 163 | 163 | /* Return the current wall-clock time */ |
| 164 | 164 | static sqlite3_int64 timeOfDay(void){ |
| 165 | 165 | static sqlite3_vfs *clockVfs = 0; |
| 166 | 166 | sqlite3_int64 t; |
| 167 | 167 | if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); |
| 168 | - if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){ | |
| 168 | + if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ | |
| 169 | 169 | clockVfs->xCurrentTimeInt64(clockVfs, &t); |
| 170 | 170 | }else{ |
| 171 | 171 | double r; |
| 172 | 172 | clockVfs->xCurrentTime(clockVfs, &r); |
| 173 | 173 | t = (sqlite3_int64)(r*86400000.0); |
| @@ -2558,11 +2558,11 @@ | ||
| 2558 | 2558 | { "number of views:", |
| 2559 | 2559 | "SELECT count(*) FROM %s WHERE type='view'" }, |
| 2560 | 2560 | { "schema size:", |
| 2561 | 2561 | "SELECT total(length(sql)) FROM %s" }, |
| 2562 | 2562 | }; |
| 2563 | - sqlite3_file *pFile; | |
| 2563 | + sqlite3_file *pFile = 0; | |
| 2564 | 2564 | int i; |
| 2565 | 2565 | char *zSchemaTab; |
| 2566 | 2566 | char *zDb = nArg>=2 ? azArg[1] : "main"; |
| 2567 | 2567 | unsigned char aHdr[100]; |
| 2568 | 2568 | open_db(p, 0); |
| @@ -4599,14 +4599,14 @@ | ||
| 4599 | 4599 | data.shellFlgs |= SHFLG_Scratch; |
| 4600 | 4600 | }else if( strcmp(z,"-pagecache")==0 ){ |
| 4601 | 4601 | int n, sz; |
| 4602 | 4602 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4603 | 4603 | if( sz>70000 ) sz = 70000; |
| 4604 | - if( sz<800 ) sz = 800; | |
| 4604 | + if( sz<0 ) sz = 0; | |
| 4605 | 4605 | n = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4606 | - if( n<10 ) n = 10; | |
| 4607 | - sqlite3_config(SQLITE_CONFIG_PAGECACHE, malloc(n*sz+1), sz, n); | |
| 4606 | + sqlite3_config(SQLITE_CONFIG_PAGECACHE, | |
| 4607 | + (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n); | |
| 4608 | 4608 | data.shellFlgs |= SHFLG_Pagecache; |
| 4609 | 4609 | }else if( strcmp(z,"-lookaside")==0 ){ |
| 4610 | 4610 | int n, sz; |
| 4611 | 4611 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4612 | 4612 | if( sz<0 ) sz = 0; |
| 4613 | 4613 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -163,11 +163,11 @@ | |
| 163 | /* Return the current wall-clock time */ |
| 164 | static sqlite3_int64 timeOfDay(void){ |
| 165 | static sqlite3_vfs *clockVfs = 0; |
| 166 | sqlite3_int64 t; |
| 167 | if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); |
| 168 | if( clockVfs->iVersion>=1 && clockVfs->xCurrentTimeInt64!=0 ){ |
| 169 | clockVfs->xCurrentTimeInt64(clockVfs, &t); |
| 170 | }else{ |
| 171 | double r; |
| 172 | clockVfs->xCurrentTime(clockVfs, &r); |
| 173 | t = (sqlite3_int64)(r*86400000.0); |
| @@ -2558,11 +2558,11 @@ | |
| 2558 | { "number of views:", |
| 2559 | "SELECT count(*) FROM %s WHERE type='view'" }, |
| 2560 | { "schema size:", |
| 2561 | "SELECT total(length(sql)) FROM %s" }, |
| 2562 | }; |
| 2563 | sqlite3_file *pFile; |
| 2564 | int i; |
| 2565 | char *zSchemaTab; |
| 2566 | char *zDb = nArg>=2 ? azArg[1] : "main"; |
| 2567 | unsigned char aHdr[100]; |
| 2568 | open_db(p, 0); |
| @@ -4599,14 +4599,14 @@ | |
| 4599 | data.shellFlgs |= SHFLG_Scratch; |
| 4600 | }else if( strcmp(z,"-pagecache")==0 ){ |
| 4601 | int n, sz; |
| 4602 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4603 | if( sz>70000 ) sz = 70000; |
| 4604 | if( sz<800 ) sz = 800; |
| 4605 | n = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4606 | if( n<10 ) n = 10; |
| 4607 | sqlite3_config(SQLITE_CONFIG_PAGECACHE, malloc(n*sz+1), sz, n); |
| 4608 | data.shellFlgs |= SHFLG_Pagecache; |
| 4609 | }else if( strcmp(z,"-lookaside")==0 ){ |
| 4610 | int n, sz; |
| 4611 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4612 | if( sz<0 ) sz = 0; |
| 4613 |
| --- src/shell.c | |
| +++ src/shell.c | |
| @@ -163,11 +163,11 @@ | |
| 163 | /* Return the current wall-clock time */ |
| 164 | static sqlite3_int64 timeOfDay(void){ |
| 165 | static sqlite3_vfs *clockVfs = 0; |
| 166 | sqlite3_int64 t; |
| 167 | if( clockVfs==0 ) clockVfs = sqlite3_vfs_find(0); |
| 168 | if( clockVfs->iVersion>=2 && clockVfs->xCurrentTimeInt64!=0 ){ |
| 169 | clockVfs->xCurrentTimeInt64(clockVfs, &t); |
| 170 | }else{ |
| 171 | double r; |
| 172 | clockVfs->xCurrentTime(clockVfs, &r); |
| 173 | t = (sqlite3_int64)(r*86400000.0); |
| @@ -2558,11 +2558,11 @@ | |
| 2558 | { "number of views:", |
| 2559 | "SELECT count(*) FROM %s WHERE type='view'" }, |
| 2560 | { "schema size:", |
| 2561 | "SELECT total(length(sql)) FROM %s" }, |
| 2562 | }; |
| 2563 | sqlite3_file *pFile = 0; |
| 2564 | int i; |
| 2565 | char *zSchemaTab; |
| 2566 | char *zDb = nArg>=2 ? azArg[1] : "main"; |
| 2567 | unsigned char aHdr[100]; |
| 2568 | open_db(p, 0); |
| @@ -4599,14 +4599,14 @@ | |
| 4599 | data.shellFlgs |= SHFLG_Scratch; |
| 4600 | }else if( strcmp(z,"-pagecache")==0 ){ |
| 4601 | int n, sz; |
| 4602 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4603 | if( sz>70000 ) sz = 70000; |
| 4604 | if( sz<0 ) sz = 0; |
| 4605 | n = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4606 | sqlite3_config(SQLITE_CONFIG_PAGECACHE, |
| 4607 | (n>0 && sz>0) ? malloc(n*sz) : 0, sz, n); |
| 4608 | data.shellFlgs |= SHFLG_Pagecache; |
| 4609 | }else if( strcmp(z,"-lookaside")==0 ){ |
| 4610 | int n, sz; |
| 4611 | sz = (int)integerValue(cmdline_option_value(argc,argv,++i)); |
| 4612 | if( sz<0 ) sz = 0; |
| 4613 |