diff --git a/fhem/CHANGED b/fhem/CHANGED
index 9331cc669..d104d6fbd 100644
--- a/fhem/CHANGED
+++ b/fhem/CHANGED
@@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide.
# Do not insert empty lines here, update check depends on it.
+ - feature: 93_DbLog: new attributes SQLiteCacheSize, SQLiteJournalMode
- bugfix: 98_Text2Speech.pm: some Improvements by Mirko
- change: 73_GardenaSmartBridge: Change part of code for new API
- bugfix: 47_OBIS: fixed bug with 64 bit integer numbers
diff --git a/fhem/FHEM/93_DbLog.pm b/fhem/FHEM/93_DbLog.pm
index 143daf573..511e6817f 100644
--- a/fhem/FHEM/93_DbLog.pm
+++ b/fhem/FHEM/93_DbLog.pm
@@ -30,6 +30,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Version History intern by DS_Starter:
my %DbLog_vNotesIntern = (
+ "4.12.0" => "29.03.2021 new attributes SQLiteCacheSize, SQLiteJournalMode ",
"4.11.0" => "20.02.2021 new attr cacheOverflowThreshold, reading CacheOverflowLastNum/CacheOverflowLastState, ".
"remove prototypes, new subs DbLog_writeFileIfCacheOverflow, DbLog_setReadingstate ",
"4.10.2" => "23.06.2020 configCheck changed for SQLite again ",
@@ -274,6 +275,8 @@ sub DbLog_Initialize {
"colValue ".
"DbLogSelectionMode:Exclude,Include,Exclude/Include ".
"DbLogType:Current,History,Current/History,SampleFill/History ".
+ "SQLiteJournalMode:WAL,off ".
+ "SQLiteCacheSize ".
"dbSchema ".
"defaultMinInterval:textField-long ".
"disable:1,0 ".
@@ -421,7 +424,11 @@ sub DbLog_Attr {
my $do = 0;
if($cmd eq "set") {
- if ($aName eq "syncInterval" || $aName eq "cacheLimit" || $aName eq "cacheOverflowThreshold" || $aName eq "timeout") {
+ if ($aName eq "syncInterval" ||
+ $aName eq "cacheLimit" ||
+ $aName eq "cacheOverflowThreshold" ||
+ $aName eq "SQLiteCacheSize" ||
+ $aName eq "timeout") {
if ($aVal !~ /^[0-9]+$/) { return "The Value of $aName is not valid. Use only figures 0-9 !";}
}
@@ -449,6 +456,11 @@ sub DbLog_Attr {
if ($aName eq "shutdownWait") {
return "DbLog $name - The attribute $aName is deprecated and has been removed !";
+ }
+
+ if ($aName eq "SQLiteCacheSize" || $aName eq "SQLiteJournalMode") {
+ InternalTimer(gettimeofday()+1.0, "DbLog_attrForSQLite", $hash, 0);
+ InternalTimer(gettimeofday()+1.5, "DbLog_attrForSQLite", $hash, 0); # muß zweimal ausgeführt werden - Grund unbekannt :-(
}
}
@@ -557,6 +569,29 @@ sub DbLog_Attr {
return;
}
+################################################################
+# reopen DB beim Setzen bestimmter Attribute
+################################################################
+sub DbLog_attrForSQLite {
+ my $hash = shift;
+
+ return if($hash->{MODEL} ne "SQLITE");
+
+ my $name = $hash->{NAME};
+
+ my $dbh = $hash->{DBHP};
+ if ($dbh) {
+ my $history = $hash->{HELPER}{TH};
+ if(!$dbh->{AutoCommit}) {
+ eval {$dbh->commit()} or Log3($name, 2, "DbLog $name -> Error commit $history - $@");
+ }
+ $dbh->disconnect();
+ }
+ DbLog_ConnectPush ($hash,1);
+
+return;
+}
+
################################################################
sub DbLog_Set {
my ($hash, @a) = @_;
@@ -3225,18 +3260,29 @@ sub DbLog_ConnectPush {
DbLog_setReadingstate ($hash, $state);
}
- $hash->{DBHP}= $dbhp;
+ $hash->{DBHP} = $dbhp;
if ($hash->{MODEL} eq "SQLITE") {
$dbhp->do("PRAGMA temp_store=MEMORY");
$dbhp->do("PRAGMA synchronous=FULL"); # For maximum reliability and for robustness against database corruption,
# SQLite should always be run with its default synchronous setting of FULL.
# https://sqlite.org/howtocorrupt.html
- $dbhp->do("PRAGMA journal_mode=WAL");
- $dbhp->do("PRAGMA cache_size=4000");
+
+ if (AttrVal($name, "SQLiteJournalMode", "WAL") eq "off") {
+ $dbhp->do("PRAGMA journal_mode=off");
+ $hash->{SQLITEWALMODE} = "off";
+ }
+ else {
+ $dbhp->do("PRAGMA journal_mode=WAL");
+ $hash->{SQLITEWALMODE} = "on";
+ }
+
+ my $cs = AttrVal($name, "SQLiteCacheSize", "4000");
+ $dbhp->do("PRAGMA cache_size=$cs");
+ $hash->{SQLITECACHESIZE} = $cs;
}
- return 1;
+return 1;
}
sub DbLog_ConnectNewDBH {
@@ -7634,6 +7680,42 @@ attr SMA_Energymeter DbLogValueFn
+
+ attr <device> SQLiteCacheSize <number of memory pages used for caching>
+
+ attr <device> SQLiteJournalMode [WAL|off]
+
+ attr <device> SQLiteCacheSize <Anzahl Memory Pages für Cache>
+
+ attr <device> SQLiteJournalMode [WAL|off]
+