Fossil SCM

Add new command line option "-vfs" which overrides the FOSSIL_VFS environment variable, and which works for all future DB connections. Fix .vfsname output when win32-longpath is chosen explicitly (already in SQLite trunk).

jan.nijtmans 2013-12-10 13:23 trunk
Commit eb3899ceb2d9c25d615c68e02d8af27beb964104
+1 -12
--- src/db.c
+++ src/db.c
@@ -709,28 +709,17 @@
709709
** Open a database file. Return a pointer to the new database
710710
** connection. An error results in process abort.
711711
*/
712712
LOCAL sqlite3 *db_open(const char *zDbName){
713713
int rc;
714
- const char *zVfs;
715714
sqlite3 *db;
716715
717716
#if defined(__CYGWIN__)
718717
zDbName = fossil_utf8_to_filename(zDbName);
719718
#endif
720719
if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
721
- zVfs = fossil_getenv("FOSSIL_VFS");
722
-#if defined(_WIN32) || defined(__CYGWIN__)
723
- if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
724
- zVfs = "win32-longpath";
725
- }
726
-#endif
727
- rc = sqlite3_open_v2(
728
- zDbName, &db,
729
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
730
- zVfs
731
- );
720
+ rc = sqlite3_open(zDbName, &db);
732721
if( rc!=SQLITE_OK ){
733722
db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
734723
}
735724
sqlite3_busy_timeout(db, 5000);
736725
sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
737726
--- src/db.c
+++ src/db.c
@@ -709,28 +709,17 @@
709 ** Open a database file. Return a pointer to the new database
710 ** connection. An error results in process abort.
711 */
712 LOCAL sqlite3 *db_open(const char *zDbName){
713 int rc;
714 const char *zVfs;
715 sqlite3 *db;
716
717 #if defined(__CYGWIN__)
718 zDbName = fossil_utf8_to_filename(zDbName);
719 #endif
720 if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
721 zVfs = fossil_getenv("FOSSIL_VFS");
722 #if defined(_WIN32) || defined(__CYGWIN__)
723 if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
724 zVfs = "win32-longpath";
725 }
726 #endif
727 rc = sqlite3_open_v2(
728 zDbName, &db,
729 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
730 zVfs
731 );
732 if( rc!=SQLITE_OK ){
733 db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
734 }
735 sqlite3_busy_timeout(db, 5000);
736 sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
737
--- src/db.c
+++ src/db.c
@@ -709,28 +709,17 @@
709 ** Open a database file. Return a pointer to the new database
710 ** connection. An error results in process abort.
711 */
712 LOCAL sqlite3 *db_open(const char *zDbName){
713 int rc;
 
714 sqlite3 *db;
715
716 #if defined(__CYGWIN__)
717 zDbName = fossil_utf8_to_filename(zDbName);
718 #endif
719 if( g.fSqlTrace ) fossil_trace("-- sqlite3_open: [%s]\n", zDbName);
720 rc = sqlite3_open(zDbName, &db);
 
 
 
 
 
 
 
 
 
 
721 if( rc!=SQLITE_OK ){
722 db_err("[%s]: %s", zDbName, sqlite3_errmsg(db));
723 }
724 sqlite3_busy_timeout(db, 5000);
725 sqlite3_wal_autocheckpoint(db, 1); /* Set to checkpoint frequently */
726
+2 -20
--- src/login.c
+++ src/login.c
@@ -688,27 +688,18 @@
688688
sqlite3_stmt *pStmt; /* Query against the other repository */
689689
char *zSQL; /* SQL of the query against other repo */
690690
char *zOtherRepo; /* Filename of the other repository */
691691
int rc; /* Result code from SQLite library functions */
692692
int nXfer = 0; /* Number of credentials transferred */
693
- const char *zVfs;
694693
695694
zOtherRepo = db_text(0,
696695
"SELECT value FROM config WHERE name='peer-repo-%q'",
697696
zCode
698697
);
699698
if( zOtherRepo==0 ) return 0; /* No such peer repository */
700699
701
- zVfs = fossil_getenv("FOSSIL_VFS");
702
-#if defined(_WIN32) || defined(__CYGWIN__)
703
- if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
704
- zVfs = "win32-longpath";
705
- }
706
-#endif
707
- rc = sqlite3_open_v2(zOtherRepo, &pOther,
708
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
709
- zVfs);
700
+ rc = sqlite3_open(zOtherRepo, &pOther);
710701
if( rc==SQLITE_OK ){
711702
sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0);
712703
sqlite3_create_function(pOther, "constant_time_cmp", 2, SQLITE_UTF8, 0,
713704
constant_time_cmp_function, 0, 0);
714705
sqlite3_busy_timeout(pOther, 5000);
@@ -1437,11 +1428,10 @@
14371428
char *zSelfRepo; /* Name of our repository */
14381429
char *zSelfLabel; /* Project-name for our repository */
14391430
char *zSelfProjCode; /* Our project-code */
14401431
char *zSql; /* SQL to run on all peers */
14411432
const char *zSelf; /* The ATTACH name of our repository */
1442
- const char *zVfs;
14431433
14441434
*pzErrMsg = 0; /* Default to no errors */
14451435
zSelf = db_name("repository");
14461436
14471437
/* Get the full pathname of the other repository */
@@ -1469,19 +1459,11 @@
14691459
/* Make sure the other repository is a valid Fossil database */
14701460
if( file_size(zRepo)<0 ){
14711461
*pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo);
14721462
return;
14731463
}
1474
- zVfs = fossil_getenv("FOSSIL_VFS");
1475
-#if defined(_WIN32) || defined(__CYGWIN__)
1476
- if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
1477
- zVfs = "win32-longpath";
1478
- }
1479
-#endif
1480
- rc = sqlite3_open_v2(zRepo, &pOther,
1481
- SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
1482
- zVfs);
1464
+ rc = sqlite3_open(zRepo, &pOther);
14831465
if( rc!=SQLITE_OK ){
14841466
*pzErrMsg = mprintf(sqlite3_errmsg(pOther));
14851467
}else{
14861468
rc = sqlite3_exec(pOther, "SELECT count(*) FROM user", 0, 0, pzErrMsg);
14871469
}
14881470
--- src/login.c
+++ src/login.c
@@ -688,27 +688,18 @@
688 sqlite3_stmt *pStmt; /* Query against the other repository */
689 char *zSQL; /* SQL of the query against other repo */
690 char *zOtherRepo; /* Filename of the other repository */
691 int rc; /* Result code from SQLite library functions */
692 int nXfer = 0; /* Number of credentials transferred */
693 const char *zVfs;
694
695 zOtherRepo = db_text(0,
696 "SELECT value FROM config WHERE name='peer-repo-%q'",
697 zCode
698 );
699 if( zOtherRepo==0 ) return 0; /* No such peer repository */
700
701 zVfs = fossil_getenv("FOSSIL_VFS");
702 #if defined(_WIN32) || defined(__CYGWIN__)
703 if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
704 zVfs = "win32-longpath";
705 }
706 #endif
707 rc = sqlite3_open_v2(zOtherRepo, &pOther,
708 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
709 zVfs);
710 if( rc==SQLITE_OK ){
711 sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0);
712 sqlite3_create_function(pOther, "constant_time_cmp", 2, SQLITE_UTF8, 0,
713 constant_time_cmp_function, 0, 0);
714 sqlite3_busy_timeout(pOther, 5000);
@@ -1437,11 +1428,10 @@
1437 char *zSelfRepo; /* Name of our repository */
1438 char *zSelfLabel; /* Project-name for our repository */
1439 char *zSelfProjCode; /* Our project-code */
1440 char *zSql; /* SQL to run on all peers */
1441 const char *zSelf; /* The ATTACH name of our repository */
1442 const char *zVfs;
1443
1444 *pzErrMsg = 0; /* Default to no errors */
1445 zSelf = db_name("repository");
1446
1447 /* Get the full pathname of the other repository */
@@ -1469,19 +1459,11 @@
1469 /* Make sure the other repository is a valid Fossil database */
1470 if( file_size(zRepo)<0 ){
1471 *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo);
1472 return;
1473 }
1474 zVfs = fossil_getenv("FOSSIL_VFS");
1475 #if defined(_WIN32) || defined(__CYGWIN__)
1476 if( zVfs==0 && sqlite3_libversion_number()>=3008001 ){
1477 zVfs = "win32-longpath";
1478 }
1479 #endif
1480 rc = sqlite3_open_v2(zRepo, &pOther,
1481 SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE,
1482 zVfs);
1483 if( rc!=SQLITE_OK ){
1484 *pzErrMsg = mprintf(sqlite3_errmsg(pOther));
1485 }else{
1486 rc = sqlite3_exec(pOther, "SELECT count(*) FROM user", 0, 0, pzErrMsg);
1487 }
1488
--- src/login.c
+++ src/login.c
@@ -688,27 +688,18 @@
688 sqlite3_stmt *pStmt; /* Query against the other repository */
689 char *zSQL; /* SQL of the query against other repo */
690 char *zOtherRepo; /* Filename of the other repository */
691 int rc; /* Result code from SQLite library functions */
692 int nXfer = 0; /* Number of credentials transferred */
 
693
694 zOtherRepo = db_text(0,
695 "SELECT value FROM config WHERE name='peer-repo-%q'",
696 zCode
697 );
698 if( zOtherRepo==0 ) return 0; /* No such peer repository */
699
700 rc = sqlite3_open(zOtherRepo, &pOther);
 
 
 
 
 
 
 
 
701 if( rc==SQLITE_OK ){
702 sqlite3_create_function(pOther,"now",0,SQLITE_ANY,0,db_now_function,0,0);
703 sqlite3_create_function(pOther, "constant_time_cmp", 2, SQLITE_UTF8, 0,
704 constant_time_cmp_function, 0, 0);
705 sqlite3_busy_timeout(pOther, 5000);
@@ -1437,11 +1428,10 @@
1428 char *zSelfRepo; /* Name of our repository */
1429 char *zSelfLabel; /* Project-name for our repository */
1430 char *zSelfProjCode; /* Our project-code */
1431 char *zSql; /* SQL to run on all peers */
1432 const char *zSelf; /* The ATTACH name of our repository */
 
1433
1434 *pzErrMsg = 0; /* Default to no errors */
1435 zSelf = db_name("repository");
1436
1437 /* Get the full pathname of the other repository */
@@ -1469,19 +1459,11 @@
1459 /* Make sure the other repository is a valid Fossil database */
1460 if( file_size(zRepo)<0 ){
1461 *pzErrMsg = mprintf("repository file \"%s\" does not exist", zRepo);
1462 return;
1463 }
1464 rc = sqlite3_open(zRepo, &pOther);
 
 
 
 
 
 
 
 
1465 if( rc!=SQLITE_OK ){
1466 *pzErrMsg = mprintf(sqlite3_errmsg(pOther));
1467 }else{
1468 rc = sqlite3_exec(pOther, "SELECT count(*) FROM user", 0, 0, pzErrMsg);
1469 }
1470
+18
--- src/main.c
+++ src/main.c
@@ -549,10 +549,11 @@
549549
#endif
550550
int main(int argc, char **argv)
551551
#endif
552552
{
553553
const char *zCmdName = "unknown";
554
+ const char *zVfsName;
554555
int idx;
555556
int rc;
556557
sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
557558
sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
558559
memset(&g, 0, sizeof(g));
@@ -576,10 +577,27 @@
576577
memset(&g.tcl, 0, sizeof(TclContext));
577578
g.tcl.argc = g.argc;
578579
g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
579580
#endif
580581
g.mainTimerId = fossil_timer_start();
582
+ zVfsName = find_option("vfs",0,1);
583
+ if( zVfsName==0 ){
584
+ zVfsName = fossil_getenv("FOSSIL_VFS");
585
+ }
586
+#if defined(_WIN32) || defined(__CYGWIN__)
587
+ if( zVfsName==0 && sqlite3_libversion_number()>=3008001 ){
588
+ zVfsName = "win32-longpath";
589
+ }
590
+#endif
591
+ if( zVfsName ){
592
+ sqlite3_vfs *pVfs = sqlite3_vfs_find(zVfsName);
593
+ if( pVfs ){
594
+ sqlite3_vfs_register(pVfs, 1);
595
+ }else{
596
+ fossil_fatal("no such VFS: \"%s\"", zVfsName);
597
+ }
598
+ }
581599
if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
582600
zCmdName = "cgi";
583601
g.isHTTP = 1;
584602
}else if( g.argc<2 ){
585603
fossil_print(
586604
--- src/main.c
+++ src/main.c
@@ -549,10 +549,11 @@
549 #endif
550 int main(int argc, char **argv)
551 #endif
552 {
553 const char *zCmdName = "unknown";
 
554 int idx;
555 int rc;
556 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
557 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
558 memset(&g, 0, sizeof(g));
@@ -576,10 +577,27 @@
576 memset(&g.tcl, 0, sizeof(TclContext));
577 g.tcl.argc = g.argc;
578 g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
579 #endif
580 g.mainTimerId = fossil_timer_start();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
581 if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
582 zCmdName = "cgi";
583 g.isHTTP = 1;
584 }else if( g.argc<2 ){
585 fossil_print(
586
--- src/main.c
+++ src/main.c
@@ -549,10 +549,11 @@
549 #endif
550 int main(int argc, char **argv)
551 #endif
552 {
553 const char *zCmdName = "unknown";
554 const char *zVfsName;
555 int idx;
556 int rc;
557 sqlite3_config(SQLITE_CONFIG_SINGLETHREAD);
558 sqlite3_config(SQLITE_CONFIG_LOG, fossil_sqlite_log, 0);
559 memset(&g, 0, sizeof(g));
@@ -576,10 +577,27 @@
577 memset(&g.tcl, 0, sizeof(TclContext));
578 g.tcl.argc = g.argc;
579 g.tcl.argv = copy_args(g.argc, g.argv); /* save full arguments */
580 #endif
581 g.mainTimerId = fossil_timer_start();
582 zVfsName = find_option("vfs",0,1);
583 if( zVfsName==0 ){
584 zVfsName = fossil_getenv("FOSSIL_VFS");
585 }
586 #if defined(_WIN32) || defined(__CYGWIN__)
587 if( zVfsName==0 && sqlite3_libversion_number()>=3008001 ){
588 zVfsName = "win32-longpath";
589 }
590 #endif
591 if( zVfsName ){
592 sqlite3_vfs *pVfs = sqlite3_vfs_find(zVfsName);
593 if( pVfs ){
594 sqlite3_vfs_register(pVfs, 1);
595 }else{
596 fossil_fatal("no such VFS: \"%s\"", zVfsName);
597 }
598 }
599 if( fossil_getenv("GATEWAY_INTERFACE")!=0 && !find_option("nocgi", 0, 0)){
600 zCmdName = "cgi";
601 g.isHTTP = 1;
602 }else if( g.argc<2 ){
603 fossil_print(
604
+1 -1
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -34073,11 +34073,11 @@
3407334073
winModeBit(pFile, WINFILE_PSOW, (int*)pArg);
3407434074
OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
3407534075
return SQLITE_OK;
3407634076
}
3407734077
case SQLITE_FCNTL_VFSNAME: {
34078
- *(char**)pArg = sqlite3_mprintf("win32");
34078
+ *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
3407934079
OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
3408034080
return SQLITE_OK;
3408134081
}
3408234082
case SQLITE_FCNTL_WIN32_AV_RETRY: {
3408334083
int *a = (int*)pArg;
3408434084
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -34073,11 +34073,11 @@
34073 winModeBit(pFile, WINFILE_PSOW, (int*)pArg);
34074 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
34075 return SQLITE_OK;
34076 }
34077 case SQLITE_FCNTL_VFSNAME: {
34078 *(char**)pArg = sqlite3_mprintf("win32");
34079 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
34080 return SQLITE_OK;
34081 }
34082 case SQLITE_FCNTL_WIN32_AV_RETRY: {
34083 int *a = (int*)pArg;
34084
--- src/sqlite3.c
+++ src/sqlite3.c
@@ -34073,11 +34073,11 @@
34073 winModeBit(pFile, WINFILE_PSOW, (int*)pArg);
34074 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
34075 return SQLITE_OK;
34076 }
34077 case SQLITE_FCNTL_VFSNAME: {
34078 *(char**)pArg = sqlite3_mprintf("%s", pFile->pVfs->zName);
34079 OSTRACE(("FCNTL file=%p, rc=SQLITE_OK\n", pFile->h));
34080 return SQLITE_OK;
34081 }
34082 case SQLITE_FCNTL_WIN32_AV_RETRY: {
34083 int *a = (int*)pArg;
34084

Keyboard Shortcuts

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