diff --git a/contrib/DS_Starter/93_DbLog.pm b/contrib/DS_Starter/93_DbLog.pm index f875b0c8e..7c2f8c47c 100644 --- a/contrib/DS_Starter/93_DbLog.pm +++ b/contrib/DS_Starter/93_DbLog.pm @@ -456,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 :-( } } @@ -564,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) = @_; @@ -3242,12 +3270,16 @@ sub DbLog_ConnectPush { 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"; } - $dbhp->do("PRAGMA cache_size=". AttrVal($name, "SQLiteCacheSize", "4000")); + my $cs = AttrVal($name, "SQLiteCacheSize", "4000"); + $dbhp->do("PRAGMA cache_size=$cs"); + $hash->{SQLITECACHESIZE} = $cs; } return 1; @@ -7678,8 +7710,7 @@ attr SMA_Energymeter DbLogValueFn Since WAL about doubles the spaces requirements on disk it might not be the best fit for embedded devices using a RAM backed disk. off will turn the journaling off. In case of corruption, the database probably won't be possible to repair and has to be recreated!
- (default: WAL)

- Note: FHEM must be restarted to take this attribute affected ! + (default: WAL) @@ -9144,8 +9175,7 @@ attr SMA_Energymeter DbLogValueFn Standardmäßig werden ca. 4MB RAM für Caching verwendet (page_size=1024bytes, cache_size=4000).
Bei Embedded Devices mit wenig RAM genügen auch 1000 Pages - zu Lasten der Performance.
- (default: 4000)

- Note: FHEM muß nach der Attributänderung restarted werden ! + (default: 4000) @@ -9165,8 +9195,7 @@ attr SMA_Energymeter DbLogValueFn Festplattenplatz (z.B. eine RAM Disk in Embedded Devices) kann das Journal deaktiviert werden (off). Im Falle eines Datenfehlers kann die Datenbank aber wahrscheinlich nicht repariert werden, und muss neu erstellt werden!
- (default: WAL)

- Note: FHEM muß nach der Attributänderung restarted werden ! + (default: WAL)