From 7db2c2e1d1bbb39cddcec8419e58683dc71f64a8 Mon Sep 17 00:00:00 2001 From: DS_Starter Date: Tue, 18 Jan 2022 15:35:51 +0000 Subject: [PATCH] 93_DbRep: contrib 8.47.1 git-svn-id: https://svn.fhem.de/fhem/trunk@25496 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/contrib/DS_Starter/93_DbRep.pm | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/fhem/contrib/DS_Starter/93_DbRep.pm b/fhem/contrib/DS_Starter/93_DbRep.pm index 7b4959b9c..4d4d268a2 100644 --- a/fhem/contrib/DS_Starter/93_DbRep.pm +++ b/fhem/contrib/DS_Starter/93_DbRep.pm @@ -538,6 +538,7 @@ sub DbRep_Set { if (AttrVal($name, "sqlCmdHistoryLength", 0)) { $hl .= "___purge_sqlhistory___"; $hl .= ",___list_sqlhistory___"; + $hl .= ",___save_sqlhistory___"; $hl .= ",___restore_sqlhistory___"; } @@ -1040,6 +1041,12 @@ sub DbRep_Set { return $cache; } + if($sqlcmd eq "___save_sqlhistory___") { + my $err = DbRep_writeSQLcmdCache ($hash); # SQL Cache File schreiben + $err //= "SQL history entries of $name successfully saved"; + return $err; + } + if($sqlcmd eq "___restore_sqlhistory___") { my $count = DbRep_initSQLcmdCache ($name); return $count ? "SQL history entries of $name restored: $count" : undef; @@ -1800,6 +1807,7 @@ sub DbRep_Shutdown { DbRep_delread ($hash,1); RemoveInternalTimer ($hash); + DbRep_writeSQLcmdCache ($hash); # SQL Cache File schreiben return; } @@ -11416,8 +11424,10 @@ sub DbRep_setCmdFile { } push @new, "$key:$value" if(!$fnd && defined($value)); + + my $err = FileWrite($param, @new); -return FileWrite($param, @new); +return $err; } #################################################################################################### @@ -11539,7 +11549,6 @@ sub DbRep_addSQLcmdCache { if($doIns) { _DbRep_insertSQLtoCache ($name, $tmpsql); - DbRep_writeSQLcmdCache ($hash); # SQL Cache File schreiben } return; @@ -11615,9 +11624,9 @@ sub DbRep_writeSQLcmdCache { my $name = $hash->{NAME}; my (undef, $cstr) = DbRep_listSQLcmdCache ($name, 1); - DbRep_setCmdFile($name."_sqlCmdList", $cstr, $hash); + my $err = DbRep_setCmdFile($name."_sqlCmdList", $cstr, $hash); -return; +return $err; } #################################################################################################### @@ -14485,6 +14494,7 @@ return;
  • sqlCmdHistory - If activated with the attribute sqlCmdHistoryLength, a stored SQL statement can be selected from a list and executed. + The SQL cache is automatically saved when FHEM is closed and restored when the system is started. The following entries execute special functions:

    @@ -14493,7 +14503,8 @@ return; ___purge_sqlhistory___ : deletes the history cache ___list_sqlhistory___ : shows the SQL statements currently in the cache, including their cache key (ckey) - ___restore_sqlhistory___ : Undoes a previously executed "___purge_sqlhistory___" + ___save_sqlhistory___ : backs up the history cache manually + ___restore_sqlhistory___ : restores the last backup of the history cache
    @@ -17293,6 +17304,7 @@ return;
  • sqlCmdHistory - Wenn mit dem Attribut sqlCmdHistoryLength aktiviert, kann ein gespeichertes SQL-Statement aus einer Liste ausgewählt und ausgeführt werden. + Der SQL Cache wird beim Beenden von FHEM automatisch gesichert und beim Start des Systems wiederhergestellt. Mit den nachfolgenden Einträgen werden spezielle Funktionen ausgeführt:

    @@ -17301,7 +17313,8 @@ return; ___purge_sqlhistory___ : löscht den History Cache ___list_sqlhistory___ : zeigt die aktuell im Cache vorhandenen SQL-Statements incl. ihrem Cache Key (ckey) - ___restore_sqlhistory___ : macht ein zuvor ausgeführtes "___purge_sqlhistory___" rückgängig + ___save_sqlhistory___ : sichert den History Cache manuell + ___restore_sqlhistory___ : stellt die letzte Sicherung des History Cache wieder her