Changeset 103
- Timestamp:
- 09/24/25 13:00:12 (38 hours ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/dnsbl/DNSBL.pm
r95 r103 188 188 # JIC someone wants to close the db but not finish the script 189 189 sub dbclose { 190 $dbh->rollback;191 190 $dbh->disconnect; 192 191 } … … 196 195 sub connect { 197 196 my $self = shift; 198 # # want to NOT autocommit everything, it's unlikely we'll step on our own toes but...197 # after jumping a HUUUGE number of PG versions, AutoCommit => 0 produced some bizarre bugs 199 198 $dbh = DBI->connect("DBI:Pg:host=$self->{dbhost};dbname=$self->{dbname}", $self->{dbuser}, $self->{dbpass}, { 200 AutoCommit => 0,201 PrintError => 1199 AutoCommit => 1, 200 PrintError => 0 202 201 }) 203 202 or die "database inaccessible: ".$DBI::errstr; … … 250 249 my $sth; 251 250 my $rows = 0; 251 252 local $dbh->{AutoCommit} = 0; 253 local $dbh->{RaiseError} = 1; 254 252 255 if ($rep =~ /^[\d.]+$/) { 253 256 # weesa gonna ASS-U-ME IP addresses are sanely formatted. … … 363 366 return "$blockin not a single CIDR range" if !$block; 364 367 365 # local $dbh->{AutoCommit} = 1; # force autocommit 368 local $dbh->{AutoCommit} = 0; 369 local $dbh->{RaiseError} = 1; 366 370 367 371 my $sth; … … 373 377 ($parent) = $sth->fetchrow_array; 374 378 } 375 $sth = $dbh->prepare("INSERT INTO blocks (block,orgid,level,parent,exclude,comments,ipcount) VALUES (?,?,?,?,?,?,". 376 "(SELECT count(*) FROM iplist i JOIN blocks b ON b.block=i.parent WHERE i.ip << ? AND i.exclude='n' AND b.exclude='n'))"); 377 $sth->execute("$block",$orgid,$level,$parent,$exclude,$comment,"$block"); 378 $sth = $dbh->prepare("UPDATE iplist SET parent=? WHERE parent=? AND ip << ?"); 379 $sth->execute("$block",$parent,"$block"); 379 $dbh->do("INSERT INTO blocks (block,orgid,level,parent,exclude,comments,ipcount) VALUES (?,?,?,?,?,?,". 380 "(SELECT count(*) FROM iplist i JOIN blocks b ON b.block=i.parent WHERE i.ip << ? AND i.exclude='n' AND b.exclude='n'))", 381 undef, "$block",$orgid,$level,$parent,$exclude,$comment,"$block"); 382 $dbh->do("UPDATE iplist SET parent=? WHERE parent=? AND ip << ?", undef, "$block", $parent, "$block"); 380 383 $dbh->commit; 381 384 };
Note:
See TracChangeset
for help on using the changeset viewer.