2
0
mirror of https://github.com/fhem/fhem-mirror.git synced 2025-02-28 02:44:53 +00:00

93_DbRep: V7.14.1, bugfix for PostgreSQL

git-svn-id: https://svn.fhem.de/fhem/trunk@16318 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
nasseeder1 2018-03-03 18:43:12 +00:00
parent 4636e25bbd
commit 4b80303344
2 changed files with 19 additions and 18 deletions

View File

@ -1,5 +1,6 @@
# Add changes at the top of the list. Keep it in ASCII, and 80-char wide. # 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. # Do not insert empty lines here, update check depends on it.
- bugfix: 93_DbRep: V7.14.1, bugfix for PostgreSQL
- added: 88_xs1Dev: added new module for control xs1 - added: 88_xs1Dev: added new module for control xs1
- changed: 88_xs1Bridge: changed for another module - changed: 88_xs1Bridge: changed for another module
- bugfix: 88_HMCCU: Fixed bug in attribute peer - bugfix: 88_HMCCU: Fixed bug in attribute peer

View File

@ -37,7 +37,8 @@
########################################################################################################################### ###########################################################################################################################
# Versions History: # Versions History:
# #
# 7.14.0 28.02.2018 syncStandby # 7.14.1 01.03.2018 currentfillup_Push bugfix for PostgreSQL
# 7.14.0 26.02.2018 syncStandby
# 7.13.3 25.02.2018 commandref revised (forum:#84953) # 7.13.3 25.02.2018 commandref revised (forum:#84953)
# 7.13.2 24.02.2018 DbRep_firstconnect changed, bug fix in DbRep_collaggstr for aggregation = month # 7.13.2 24.02.2018 DbRep_firstconnect changed, bug fix in DbRep_collaggstr for aggregation = month
# 7.13.1 20.02.2018 commandref revised # 7.13.1 20.02.2018 commandref revised
@ -321,7 +322,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
sub DbRep_Main($$;$); sub DbRep_Main($$;$);
sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden sub DbLog_cutCol($$$$$$$); # DbLog-Funktion nutzen um Daten auf maximale Länge beschneiden
my $DbRepVersion = "7.14.0"; my $DbRepVersion = "7.14.1";
my %dbrep_col = ("DEVICE" => 64, my %dbrep_col = ("DEVICE" => 64,
"TYPE" => 64, "TYPE" => 64,
@ -3834,19 +3835,19 @@ sub currentfillup_Push($) {
$sql .= "group by timestamp,device,reading ;"; $sql .= "group by timestamp,device,reading ;";
} elsif ($usepkc && $dbloghash->{MODEL} eq 'POSTGRESQL') { } elsif ($usepkc && $dbloghash->{MODEL} eq 'POSTGRESQL') {
$sql = "INSERT INTO current (TIMESTAMP,DEVICE,READING) SELECT '$runtime_string_next',device,reading FROM history where "; $sql = "INSERT INTO current (DEVICE,TIMESTAMP,READING) SELECT device, (array_agg(timestamp ORDER BY reading ASC))[1], reading FROM history where ";
$sql .= "DEVICE LIKE '$devs' AND " if($danz <= 1 && $devs !~ m(^%$) && $devs =~ m(\%)); $sql .= "DEVICE LIKE '$devs' AND " if($danz <= 1 && $devs !~ m(^%$) && $devs =~ m(\%));
$sql .= "DEVICE = '$devs' AND " if($danz <= 1 && $devs !~ m(\%)); $sql .= "DEVICE = '$devs' AND " if($danz <= 1 && $devs !~ m(\%));
$sql .= "DEVICE IN ($devs) AND " if($danz > 1); $sql .= "DEVICE IN ($devs) AND " if($danz > 1);
$sql .= "READING LIKE '$reading' AND " if($ranz <= 1 && $reading !~ m(^%$) && $reading =~ m(\%)); $sql .= "READING LIKE '$reading' AND " if($ranz <= 1 && $reading !~ m(^%$) && $reading =~ m(\%));
$sql .= "READING = '$reading' AND " if($ranz <= 1 && $reading !~ m(\%)); $sql .= "READING = '$reading' AND " if($ranz <= 1 && $reading !~ m(\%));
$sql .= "READING IN ($reading) AND " if($ranz > 1); $sql .= "READING IN ($reading) AND " if($ranz > 1);
if ($IsTimeSet) { if ($IsTimeSet) {
$sql .= "TIMESTAMP >= '$runtime_string_first' AND TIMESTAMP < '$runtime_string_next' "; $sql .= "TIMESTAMP >= '$runtime_string_first' AND TIMESTAMP < '$runtime_string_next' ";
} else { } else {
$sql .= "true "; $sql .= "true ";
} }
$sql .= "group by device,reading ORDER BY 2 ASC, 3 ASC ON CONFLICT DO NOTHING; "; $sql .= "group by device,reading ON CONFLICT ($pkc) DO NOTHING; ";
} else { } else {
if($dbloghash->{MODEL} ne 'POSTGRESQL') { if($dbloghash->{MODEL} ne 'POSTGRESQL') {
@ -3866,7 +3867,7 @@ sub currentfillup_Push($) {
$sql .= "group by device,reading ;"; $sql .= "group by device,reading ;";
} else { } else {
# PostgreSQL # PostgreSQL
$sql = "INSERT INTO current (TIMESTAMP,DEVICE,READING) SELECT '$runtime_string_next',device,reading FROM history where "; $sql = "INSERT INTO current (DEVICE,TIMESTAMP,READING) SELECT device, (array_agg(timestamp ORDER BY reading ASC))[1], reading FROM history where ";
$sql .= "DEVICE LIKE '$devs' AND " if($danz <= 1 && $devs !~ m(^%$) && $devs =~ m(\%)); $sql .= "DEVICE LIKE '$devs' AND " if($danz <= 1 && $devs !~ m(^%$) && $devs =~ m(\%));
$sql .= "DEVICE = '$devs' AND " if($danz <= 1 && $devs !~ m(\%)); $sql .= "DEVICE = '$devs' AND " if($danz <= 1 && $devs !~ m(\%));
$sql .= "DEVICE IN ($devs) AND " if($danz > 1); $sql .= "DEVICE IN ($devs) AND " if($danz > 1);
@ -3878,8 +3879,7 @@ sub currentfillup_Push($) {
} else { } else {
$sql .= "true "; $sql .= "true ";
} }
$sql .= "group by device,reading ORDER BY 2 ASC, 3 ASC;"; $sql .= "group by device,reading;";
} }
} }