Fossil SCM

If there is a need to do lazy updates of the full text index during a request that is not from the same origin, then allow database writes for the duration of that update. Also, allow changes to USER and CONFIG tables when explicitly authorized by db_unprotect() even if the request that prompted the change is not from the same origin.

drh 2022-12-30 11:53 trunk
Commit 8e85d6ca2281b8dd2472ceab37449ef831b97c9eac67fc4337f26cbceb252288
2 files changed +1 -1 +2
+1 -1
--- src/db.c
+++ src/db.c
@@ -459,11 +459,11 @@
459459
void db_unprotect(unsigned flags){
460460
if( db.nProtect>=count(db.aProtect)-2 ){
461461
fossil_panic("too many db_unprotect() calls");
462462
}
463463
db.aProtect[db.nProtect++] = db.protectMask;
464
- db.protectMask &= ~flags;
464
+ db.protectMask &= ~(flags|PROTECT_READONLY);
465465
}
466466
void db_protect_pop(void){
467467
if( db.nProtect<1 ){
468468
fossil_panic("too many db_protect_pop() calls");
469469
}
470470
--- src/db.c
+++ src/db.c
@@ -459,11 +459,11 @@
459 void db_unprotect(unsigned flags){
460 if( db.nProtect>=count(db.aProtect)-2 ){
461 fossil_panic("too many db_unprotect() calls");
462 }
463 db.aProtect[db.nProtect++] = db.protectMask;
464 db.protectMask &= ~flags;
465 }
466 void db_protect_pop(void){
467 if( db.nProtect<1 ){
468 fossil_panic("too many db_protect_pop() calls");
469 }
470
--- src/db.c
+++ src/db.c
@@ -459,11 +459,11 @@
459 void db_unprotect(unsigned flags){
460 if( db.nProtect>=count(db.aProtect)-2 ){
461 fossil_panic("too many db_unprotect() calls");
462 }
463 db.aProtect[db.nProtect++] = db.protectMask;
464 db.protectMask &= ~(flags|PROTECT_READONLY);
465 }
466 void db_protect_pop(void){
467 if( db.nProtect<1 ){
468 fossil_panic("too many db_protect_pop() calls");
469 }
470
--- src/search.c
+++ src/search.c
@@ -1814,10 +1814,11 @@
18141814
*/
18151815
void search_update_index(unsigned int srchFlags){
18161816
if( !search_index_exists() ) return;
18171817
if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return;
18181818
search_sql_setup(g.db);
1819
+ db_unprotect(PROTECT_READONLY);
18191820
if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){
18201821
search_update_doc_index();
18211822
search_update_checkin_index();
18221823
}
18231824
if( srchFlags & SRCH_TKT ){
@@ -1830,10 +1831,11 @@
18301831
search_update_technote_index();
18311832
}
18321833
if( srchFlags & SRCH_FORUM ){
18331834
search_update_forum_index();
18341835
}
1836
+ db_protect_pop();
18351837
}
18361838
18371839
/*
18381840
** Construct, prepopulate, and then update the full-text index.
18391841
*/
18401842
--- src/search.c
+++ src/search.c
@@ -1814,10 +1814,11 @@
1814 */
1815 void search_update_index(unsigned int srchFlags){
1816 if( !search_index_exists() ) return;
1817 if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return;
1818 search_sql_setup(g.db);
 
1819 if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){
1820 search_update_doc_index();
1821 search_update_checkin_index();
1822 }
1823 if( srchFlags & SRCH_TKT ){
@@ -1830,10 +1831,11 @@
1830 search_update_technote_index();
1831 }
1832 if( srchFlags & SRCH_FORUM ){
1833 search_update_forum_index();
1834 }
 
1835 }
1836
1837 /*
1838 ** Construct, prepopulate, and then update the full-text index.
1839 */
1840
--- src/search.c
+++ src/search.c
@@ -1814,10 +1814,11 @@
1814 */
1815 void search_update_index(unsigned int srchFlags){
1816 if( !search_index_exists() ) return;
1817 if( !db_exists("SELECT 1 FROM ftsdocs WHERE NOT idxed") ) return;
1818 search_sql_setup(g.db);
1819 db_unprotect(PROTECT_READONLY);
1820 if( srchFlags & (SRCH_CKIN|SRCH_DOC) ){
1821 search_update_doc_index();
1822 search_update_checkin_index();
1823 }
1824 if( srchFlags & SRCH_TKT ){
@@ -1830,10 +1831,11 @@
1831 search_update_technote_index();
1832 }
1833 if( srchFlags & SRCH_FORUM ){
1834 search_update_forum_index();
1835 }
1836 db_protect_pop();
1837 }
1838
1839 /*
1840 ** Construct, prepopulate, and then update the full-text index.
1841 */
1842

Keyboard Shortcuts

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