2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-05-01 12:38:37 +00:00

93_DbLog: contrib 5.8.1

git-svn-id: https://svn.fhem.de/fhem/trunk@27224 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2023-02-14 16:35:13 +00:00
parent b2fdf2c67b
commit 8291937c25

View File

@ -38,8 +38,8 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
# Version History intern by DS_Starter: # Version History intern by DS_Starter:
my %DbLog_vNotesIntern = ( my %DbLog_vNotesIntern = (
"5.8.1" => "13.02.2023 change field type of DbLogInclude, DbLogExclude to textField-long, ". "5.8.1" => "13.02.2023 change field type of DbLogInclude, DbLogExclude to textField-long, configCheck evaluate collation ".
"_DbLog_SBP_connectDB evaluate DB Character set and use it for connection 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.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.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 ", "5.6.2" => "22.01.2023 check Syntax of DbLogValueFn attribute with Log output, Forum:#131777 ",
@ -2603,24 +2603,6 @@ sub _DbLog_SBP_connectDB {
if($utf8) { if($utf8) {
if($model eq "MYSQL") { if($model eq "MYSQL") {
$dbh->{mysql_enable_utf8} = 1; $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);
} }
if($model eq "SQLITE") { if($model eq "SQLITE") {
@ -2629,6 +2611,29 @@ sub _DbLog_SBP_connectDB {
} }
} }
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') { if ($model eq 'SQLITE') {
my @dos = ("PRAGMA temp_store=MEMORY", my @dos = ("PRAGMA temp_store=MEMORY",
"PRAGMA synchronous=FULL", "PRAGMA synchronous=FULL",
@ -7107,10 +7112,10 @@ sub DbLog_configcheck {
my ($chutf8mod,$chutf8dat); my ($chutf8mod,$chutf8dat);
if ($dbmodel =~ /MYSQL/) { 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"; $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"; $chutf8dat = @se ? uc($se[1]) : "no result";
if($chutf8mod eq $chutf8dat) { if($chutf8mod eq $chutf8dat) {