From 1c6cd4c1b94aff729a78bf756816456de493f4f8 Mon Sep 17 00:00:00 2001 From: deespe Date: Tue, 14 Feb 2023 20:00:33 +0000 Subject: [PATCH] 98_serviced: repeat failed commit - sorry Heiko git-svn-id: https://svn.fhem.de/fhem/trunk@27227 2b470e98-0d58-463d-a4d8-8e2adae1ed80 --- fhem/FHEM/98_serviced.pm | 3 +- fhem/contrib/DS_Starter/93_DbLog.pm | 51 ++++++++++++++++------------- 2 files changed, 30 insertions(+), 24 deletions(-) diff --git a/fhem/FHEM/98_serviced.pm b/fhem/FHEM/98_serviced.pm index 7e78c7d00..d06a1a86f 100644 --- a/fhem/FHEM/98_serviced.pm +++ b/fhem/FHEM/98_serviced.pm @@ -16,7 +16,7 @@ use Blocking; use Time::HiRes; use vars qw{%defs}; -my $servicedVersion = "1.2.8"; +my $servicedVersion = "1.2.9"; sub serviced_shutdownwait($); @@ -402,6 +402,7 @@ sub serviced_Shutdown($) { my ($hash) = @_; my $name = $hash->{NAME}; + return if (IsDisabled($name)); my $autostop = AttrNum($name,"serviceAutostop",0); $autostop = $autostop > 300 ? 300 : $autostop; if ($autostop) diff --git a/fhem/contrib/DS_Starter/93_DbLog.pm b/fhem/contrib/DS_Starter/93_DbLog.pm index 3c40aa8ad..e71f9bfd1 100644 --- a/fhem/contrib/DS_Starter/93_DbLog.pm +++ b/fhem/contrib/DS_Starter/93_DbLog.pm @@ -38,8 +38,8 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch'; # Version History intern by DS_Starter: my %DbLog_vNotesIntern = ( - "5.8.1" => "13.02.2023 change field type of DbLogInclude, DbLogExclude to textField-long, ". - "_DbLog_SBP_connectDB evaluate DB Character set and use it for connection collation ", + "5.8.1" => "13.02.2023 change field type of DbLogInclude, DbLogExclude to textField-long, configCheck evaluate collation ". + "_DbLog_SBP_connectDB evaluate DB Character/collation set and use it for connection collation ", "5.8.0" => "30.01.2023 new Get menu for a selection of getters, fix creation of new subprocess during shutdown sequence ", "5.7.0" => "25.01.2023 send Log3() data back ro parent process, improve _DbLog_dbReadings function ", "5.6.2" => "22.01.2023 check Syntax of DbLogValueFn attribute with Log output, Forum:#131777 ", @@ -2602,25 +2602,7 @@ sub _DbLog_SBP_connectDB { if($utf8) { if($model eq "MYSQL") { - $dbh->{mysql_enable_utf8} = 1; - - ($err, my @se) = _DbLog_prepExecQueryOnly ($name, $dbh, "SHOW VARIABLES LIKE 'character_set_database';"); - return ($err, q{}) if($err); - - my $dbcharset = @se ? uc($se[1]) : "no result"; - - _DbLog_SBP_Log3Parent ( { name => $name, - level => 4, - msg => qq(Database Character set is >$dbcharset<), - oper => 'log3parent', - subprocess => $subprocess - } - ); - - $dbcharset = 'UTF8' if($dbcharset !~ /UTF8MB4/xs); - - ($err, undef) = _DbLog_SBP_dbhDo ($name, $dbh, qq(set names "$dbcharset"), $subprocess); - return ($err, q{}) if($err); + $dbh->{mysql_enable_utf8} = 1; } if($model eq "SQLITE") { @@ -2628,6 +2610,29 @@ sub _DbLog_SBP_connectDB { return ($err, q{}) if($err); } } + + if ($model eq "MYSQL") { + ($err, my @se) = _DbLog_prepExecQueryOnly ($name, $dbh, "SHOW VARIABLES LIKE 'collation_database'"); + return ($err, q{}) if($err); + + my $dbcharset = @se ? $se[1] : 'noresult'; + + _DbLog_SBP_Log3Parent ( { name => $name, + level => 4, + msg => qq(Database Character set is >$dbcharset<), + oper => 'log3parent', + subprocess => $subprocess + } + ); + + if ($dbcharset !~ /noresult|ucs2|utf16|utf32/ixs) { # Impermissible Client Character Sets -> https://dev.mysql.com/doc/refman/8.0/en/charset-connection.html + my $collation = $dbcharset; + $dbcharset = (split '_', $collation, 2)[0]; + + ($err, undef) = _DbLog_SBP_dbhDo ($name, $dbh, qq(set names "$dbcharset" collate "$collation"), $subprocess); # set names utf8 collate utf8_general_ci + return ($err, q{}) if($err); + } + } if ($model eq 'SQLITE') { my @dos = ("PRAGMA temp_store=MEMORY", @@ -7107,10 +7112,10 @@ sub DbLog_configcheck { my ($chutf8mod,$chutf8dat); if ($dbmodel =~ /MYSQL/) { - ($err, @ce) = _DbLog_prepExecQueryOnly ($name, $dbh, "SHOW VARIABLES LIKE 'character_set_connection'"); + ($err, @ce) = _DbLog_prepExecQueryOnly ($name, $dbh, qq(SHOW VARIABLES LIKE 'collation_connection')); # character_set_connection $chutf8mod = @ce ? uc($ce[1]) : "no result"; - ($err, @se) = _DbLog_prepExecQueryOnly ($name, $dbh, "SHOW VARIABLES LIKE 'character_set_database'"); + ($err, @se) = _DbLog_prepExecQueryOnly ($name, $dbh, qq(SHOW VARIABLES LIKE 'collation_database')); # character_set_database $chutf8dat = @se ? uc($se[1]) : "no result"; if($chutf8mod eq $chutf8dat) {