mirror of
https://github.com/fhem/fhem-mirror.git
synced 2025-04-22 20:24:36 +00:00
93_DbRep: SQL code for SQLite, Forum:#122791
git-svn-id: https://svn.fhem.de/fhem/trunk@24929 2b470e98-0d58-463d-a4d8-8e2adae1ed80
This commit is contained in:
parent
a2b737f0dd
commit
8578e476c2
@ -1,5 +1,6 @@
|
||||
# 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.
|
||||
- change: 93_DbRep: SQL code for SQLite, Forum:#122791
|
||||
- bugfix: 70_ZoneMinder: Trigger-Port state fixed
|
||||
- feature: 49_IPCAM: introduced attribute 'blocking'
|
||||
- bugfix: 47_OBIS: Support Holley-smartmeters with negative metering
|
||||
|
@ -57,6 +57,7 @@ no if $] >= 5.017011, warnings => 'experimental::smartmatch';
|
||||
|
||||
# Version History intern
|
||||
my %DbRep_vNotesIntern = (
|
||||
"8.42.9" => "05.09.2021 minor fixes, change SQL for SQLite in deldoublets_DoParse ",
|
||||
"8.42.8" => "17.07.2021 more log data verbose 5, delete whitespaces in sub getInitData ",
|
||||
"8.42.7" => "27.02.2021 fix attribute sqlCmdVars is not working in sqlCmdBlocking Forum: /topic,53584.msg1135528.html#msg1135528",
|
||||
"8.42.6" => "25.02.2021 fix commandref ",
|
||||
@ -5564,7 +5565,7 @@ sub deldoublets_DoParse {
|
||||
|
||||
no warnings 'uninitialized';
|
||||
|
||||
foreach my $row (@ts) {
|
||||
for my $row (@ts) {
|
||||
my @a = split("#", $row);
|
||||
my $runtime_string = $a[0];
|
||||
my $runtime_string_first = $a[1];
|
||||
@ -5593,13 +5594,15 @@ sub deldoublets_DoParse {
|
||||
# Array @warp -> die zu löschenden Datensätze
|
||||
my (@warp);
|
||||
my $i = 0;
|
||||
foreach my $nr (map { $_->[1]."_ESC_".$_->[2]."_ESC_".($_->[0] =~ s/ /_ESC_/r)."_ESC_".$_->[3]."_|_".($_->[4]-1) } @{$sth->fetchall_arrayref()}) {
|
||||
for my $nr (map { $_->[1]."_ESC_".$_->[2]."_ESC_".($_->[0] =~ s/ /_ESC_/r)."_ESC_".$_->[3]."_|_".($_->[4]-1) } @{$sth->fetchall_arrayref()}) {
|
||||
# Reihenfolge geändert in: DEVICE,READING,DATE,TIME,VALUE,count(*)
|
||||
if($opt =~ /adviceDelete/) {
|
||||
push(@warp,$i."_".$nr) if($#todel+1 < $limit); # die zu löschenden Datensätze (nur zur Anzeige)
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
push(@warp,$i."_".$nr); # Array der zu löschenden Datensätze
|
||||
}
|
||||
|
||||
my $c = (split("|",$nr))[-1];
|
||||
Log3 ($name, 4, "DbRep $name - WARP: $nr, ntodel: $ntodel, c: $c");
|
||||
$ntodel = $ntodel + $c;
|
||||
@ -5613,11 +5616,19 @@ sub deldoublets_DoParse {
|
||||
$val =~ s/'/''/g; # escape ' with ''
|
||||
$val =~ s/\\/\\\\/g if($model eq "MYSQL"); # escape \ with \\ für MySQL
|
||||
$st = [gettimeofday];
|
||||
if($model =~ /MYSQL|SQLITE/) {
|
||||
|
||||
if($model =~ /MYSQL/) {
|
||||
$dsql = "delete FROM $table WHERE TIMESTAMP = '$dt' AND DEVICE = '$dev' AND READING = '$read' AND VALUE = '$val' limit $limit;";
|
||||
} elsif ($model eq "POSTGRESQL") {
|
||||
}
|
||||
elsif ($model eq "SQLITE") { # Forum: https://forum.fhem.de/index.php/topic,122791.0.html
|
||||
$dsql = "delete FROM $table where rowid in (select rowid from $table WHERE TIMESTAMP = '$dt' AND DEVICE = '$dev' AND READING = '$read' AND VALUE = '$val' LIMIT $limit);";
|
||||
}
|
||||
elsif ($model eq "POSTGRESQL") {
|
||||
$dsql = "DELETE FROM $table WHERE ctid = any (array(SELECT ctid FROM $table WHERE TIMESTAMP = '$dt' AND DEVICE = '$dev' AND READING = '$read' AND VALUE = '$val' ORDER BY timestamp LIMIT $limit));";
|
||||
}
|
||||
|
||||
Log3 ($name, 4, "DbRep $name - SQL execute: $dsql");
|
||||
|
||||
my $sthd = $dbh->prepare($dsql);
|
||||
|
||||
eval {$sthd->execute();};
|
||||
@ -9395,12 +9406,11 @@ sub DbRep_ParseAborted {
|
||||
my $dbh = $hash->{DBH};
|
||||
my $erread = "";
|
||||
|
||||
Log3 ($name, 5, qq{DbRep $name - BlockingCall finished PID "$hash->{HELPER}{RUNNING_PID}{pid}"});
|
||||
Log3 ($name, 5, qq{DbRep $name - BlockingCall finished PID "$hash->{HELPER}{RUNNING_PID}{pid}"});
|
||||
Log3 ($name, 1, "DbRep $name -> BlockingCall $hash->{HELPER}{RUNNING_PID}{fn} pid:$hash->{HELPER}{RUNNING_PID}{pid} $cause");
|
||||
|
||||
delete($hash->{HELPER}{RUNNING_PID});
|
||||
|
||||
Log3 ($name, 1, "DbRep $name -> BlockingCall $hash->{HELPER}{RUNNING_PID}{fn} pid:$hash->{HELPER}{RUNNING_PID}{pid} $cause");
|
||||
|
||||
# Befehl nach Procedure ausführen
|
||||
no warnings 'uninitialized';
|
||||
$erread = DbRep_afterproc($hash, "command");
|
||||
|
Loading…
x
Reference in New Issue
Block a user