- Timestamp:
- 06/11/12 18:05:15 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/DNSDB.pm
r343 r344 4193 4193 my $revsth = $dbh->prepare("SELECT rdns_id,revnet,status FROM revzones WHERE status=1 ". 4194 4194 "ORDER BY masklen(revnet) DESC"); 4195 # For reasons unknown, we can't sanely UNION these statements. Feh. 4196 # Supposedly it should work though (note last 3 lines): 4197 ## PG manual 4198 #UNION Clause 4199 # 4200 #The UNION clause has this general form: 4201 # 4202 # select_statement UNION [ ALL ] select_statement 4203 # 4204 #select_statement is any SELECT statement without an ORDER BY, LIMIT, FOR UPDATE, or FOR SHARE clause. (ORDER BY 4205 #and LIMIT can be attached to a subexpression if it is enclosed in parentheses. Without parentheses, these 4206 #clauses will be taken to apply to the result of the UNION, not to its right-hand input expression.) 4207 4208 my $soasth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id ". 4209 "FROM records WHERE rdns_id=? AND type=6"); 4195 4210 $recsth = $dbh->prepare("SELECT host,type,val,distance,weight,port,ttl,record_id ". 4196 "FROM records WHERE rdns_id=? AND type=6 UNION ".4197 "(SELECT host,type,val,distance,weight,port,ttl,record_id ".4198 4211 "FROM records WHERE rdns_id=? AND not type=6 ". 4199 "ORDER BY masklen(CAST(val AS inet)) DESC, CAST(val AS inet) )");4212 "ORDER BY masklen(CAST(val AS inet)) DESC, CAST(val AS inet)"); 4200 4213 $revsth->execute(); 4201 4214 while (my ($revid,$revzone,$revstat) = $revsth->fetchrow_array) { 4202 $recsth->execute($revid, $revid); 4215 $soasth->execute($revid); 4216 my (@zsoa) = $soasth->fetchrow_array(); 4217 _printrec_tiny($datafile,'y',\%recflags,$revzone, 4218 $zsoa[0],$zsoa[1],$zsoa[2],$zsoa[3],$zsoa[4],$zsoa[5],$zsoa[6],'',''); 4219 4220 $recsth->execute($revid); 4203 4221 while (my ($host,$type,$val,$dist,$weight,$port,$ttl,$recid) = $recsth->fetchrow_array) { 4204 4222 next if $recflags{$recid};
Note:
See TracChangeset
for help on using the changeset viewer.