Fossil SCM

Use the new SQLITE_FCNTL_DATA_VERSION interface in SQLite to limit running the backoffice processing to case when the repository file changes.

drh 2018-07-18 19:22 trunk
Commit 752ea432d1cf20faeed74be61adefc7e20d700b54c5691e58efeac80ccc6aba5
3 files changed +2 -1 +17 +1
+2 -1
--- src/cgi.c
+++ src/cgi.c
@@ -343,11 +343,12 @@
343343
CGIDEBUG(("DONE\n"));
344344
345345
/* After the webpage has been sent, do any useful background
346346
** processing.
347347
*/
348
- if( g.db!=0 && sqlite3_total_changes(g.db)>0 ){
348
+ if( g.db!=0 && db_repository_has_changed() ){
349
+ if( g.fAnyTrace ) fprintf(stderr, "-- repository changes have occurred\n");
349350
backoffice_run();
350351
}
351352
}
352353
353354
/*
354355
--- src/cgi.c
+++ src/cgi.c
@@ -343,11 +343,12 @@
343 CGIDEBUG(("DONE\n"));
344
345 /* After the webpage has been sent, do any useful background
346 ** processing.
347 */
348 if( g.db!=0 && sqlite3_total_changes(g.db)>0 ){
 
349 backoffice_run();
350 }
351 }
352
353 /*
354
--- src/cgi.c
+++ src/cgi.c
@@ -343,11 +343,12 @@
343 CGIDEBUG(("DONE\n"));
344
345 /* After the webpage has been sent, do any useful background
346 ** processing.
347 */
348 if( g.db!=0 && db_repository_has_changed() ){
349 if( g.fAnyTrace ) fprintf(stderr, "-- repository changes have occurred\n");
350 backoffice_run();
351 }
352 }
353
354 /*
355
+17
--- src/db.c
+++ src/db.c
@@ -1646,10 +1646,12 @@
16461646
}
16471647
}
16481648
g.zRepositoryName = mprintf("%s", zDbName);
16491649
db_open_or_attach(g.zRepositoryName, "repository");
16501650
g.repositoryOpen = 1;
1651
+ sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION,
1652
+ &g.iRepoDataVers);
16511653
/* Cache "allow-symlinks" option, because we'll need it on every stat call */
16521654
g.allowSymlinks = db_get_boolean("allow-symlinks",
16531655
db_allow_symlinks_by_default());
16541656
g.zAuxSchema = db_get("aux-schema","");
16551657
g.eHashPolicy = db_get_int("hash-policy",-1);
@@ -1661,10 +1663,25 @@
16611663
/* Make a change to the CHECK constraint on the BLOB table for
16621664
** version 2.0 and later.
16631665
*/
16641666
rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
16651667
}
1668
+
1669
+/*
1670
+** Return true if there have been any changes to the repository
1671
+** database since it was opened.
1672
+**
1673
+** Changes to "config" and "localdb" and "temp" do not count.
1674
+** This routine only returns true if there have been changes
1675
+** to "repository".
1676
+*/
1677
+int db_repository_has_changed(void){
1678
+ unsigned int v;
1679
+ if( !g.repositoryOpen ) return 0;
1680
+ sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION, &v);
1681
+ return g.iRepoDataVers != v;
1682
+}
16661683
16671684
/*
16681685
** Flags for the db_find_and_open_repository() function.
16691686
*/
16701687
#if INTERFACE
16711688
--- src/db.c
+++ src/db.c
@@ -1646,10 +1646,12 @@
1646 }
1647 }
1648 g.zRepositoryName = mprintf("%s", zDbName);
1649 db_open_or_attach(g.zRepositoryName, "repository");
1650 g.repositoryOpen = 1;
 
 
1651 /* Cache "allow-symlinks" option, because we'll need it on every stat call */
1652 g.allowSymlinks = db_get_boolean("allow-symlinks",
1653 db_allow_symlinks_by_default());
1654 g.zAuxSchema = db_get("aux-schema","");
1655 g.eHashPolicy = db_get_int("hash-policy",-1);
@@ -1661,10 +1663,25 @@
1661 /* Make a change to the CHECK constraint on the BLOB table for
1662 ** version 2.0 and later.
1663 */
1664 rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
1665 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1666
1667 /*
1668 ** Flags for the db_find_and_open_repository() function.
1669 */
1670 #if INTERFACE
1671
--- src/db.c
+++ src/db.c
@@ -1646,10 +1646,12 @@
1646 }
1647 }
1648 g.zRepositoryName = mprintf("%s", zDbName);
1649 db_open_or_attach(g.zRepositoryName, "repository");
1650 g.repositoryOpen = 1;
1651 sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION,
1652 &g.iRepoDataVers);
1653 /* Cache "allow-symlinks" option, because we'll need it on every stat call */
1654 g.allowSymlinks = db_get_boolean("allow-symlinks",
1655 db_allow_symlinks_by_default());
1656 g.zAuxSchema = db_get("aux-schema","");
1657 g.eHashPolicy = db_get_int("hash-policy",-1);
@@ -1661,10 +1663,25 @@
1663 /* Make a change to the CHECK constraint on the BLOB table for
1664 ** version 2.0 and later.
1665 */
1666 rebuild_schema_update_2_0(); /* Do the Fossil-2.0 schema updates */
1667 }
1668
1669 /*
1670 ** Return true if there have been any changes to the repository
1671 ** database since it was opened.
1672 **
1673 ** Changes to "config" and "localdb" and "temp" do not count.
1674 ** This routine only returns true if there have been changes
1675 ** to "repository".
1676 */
1677 int db_repository_has_changed(void){
1678 unsigned int v;
1679 if( !g.repositoryOpen ) return 0;
1680 sqlite3_file_control(g.db, "repository", SQLITE_FCNTL_DATA_VERSION, &v);
1681 return g.iRepoDataVers != v;
1682 }
1683
1684 /*
1685 ** Flags for the db_find_and_open_repository() function.
1686 */
1687 #if INTERFACE
1688
+1
--- src/main.c
+++ src/main.c
@@ -130,10 +130,11 @@
130130
char *zAuxSchema; /* Main repository aux-schema */
131131
int dbIgnoreErrors; /* Ignore database errors if true */
132132
const char *zConfigDbName;/* Path of the config database. NULL if not open */
133133
sqlite3_int64 now; /* Seconds since 1970 */
134134
int repositoryOpen; /* True if the main repository database is open */
135
+ unsigned iRepoDataVers; /* Initial data version for repository database */
135136
char *zRepositoryOption; /* Most recent cached repository option value */
136137
char *zRepositoryName; /* Name of the repository database file */
137138
char *zLocalDbName; /* Name of the local database file */
138139
char *zOpenRevision; /* Check-in version to use during database open */
139140
int localOpen; /* True if the local database is open */
140141
--- src/main.c
+++ src/main.c
@@ -130,10 +130,11 @@
130 char *zAuxSchema; /* Main repository aux-schema */
131 int dbIgnoreErrors; /* Ignore database errors if true */
132 const char *zConfigDbName;/* Path of the config database. NULL if not open */
133 sqlite3_int64 now; /* Seconds since 1970 */
134 int repositoryOpen; /* True if the main repository database is open */
 
135 char *zRepositoryOption; /* Most recent cached repository option value */
136 char *zRepositoryName; /* Name of the repository database file */
137 char *zLocalDbName; /* Name of the local database file */
138 char *zOpenRevision; /* Check-in version to use during database open */
139 int localOpen; /* True if the local database is open */
140
--- src/main.c
+++ src/main.c
@@ -130,10 +130,11 @@
130 char *zAuxSchema; /* Main repository aux-schema */
131 int dbIgnoreErrors; /* Ignore database errors if true */
132 const char *zConfigDbName;/* Path of the config database. NULL if not open */
133 sqlite3_int64 now; /* Seconds since 1970 */
134 int repositoryOpen; /* True if the main repository database is open */
135 unsigned iRepoDataVers; /* Initial data version for repository database */
136 char *zRepositoryOption; /* Most recent cached repository option value */
137 char *zRepositoryName; /* Name of the repository database file */
138 char *zLocalDbName; /* Name of the local database file */
139 char *zOpenRevision; /* Check-in version to use during database open */
140 int localOpen; /* True if the local database is open */
141

Keyboard Shortcuts

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