Ignore:
Timestamp:
12/30/25 16:51:56 (6 hours ago)
Author:
Kris Deugau
Message:

/branches/cname-collision

Extend _cname_collision() lookups to skip the record passed in for update,
so as to not fail the checks by finding that record itself.
See #72.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/cname-collision/DNSDB.pm

    r942 r959  
    637637  if (${$args{rectype}} == 5) {
    638638    # First, check for non-CNAME collisions.
    639     my @t = $dbh->selectrow_array("SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}).
    640         " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type <> 5 AND $hfield = ?",
    641         undef, $args{id}, $hcheck);
     639    my $sql = "SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}).
     640        " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type <> 5 AND $hfield = ?";
     641    my @lookupargs = ($args{id}, $hcheck);
     642    if ($args{update}) {
     643      $sql .= " AND record_id <> ?";
     644      push @lookupargs, $args{update};
     645    }
     646    my @t = $dbh->selectrow_array($sql, undef, @lookupargs);
    642647    if ($t[0] > 0) {
    643648      $errstr = "One or more non-CNAME records already exist for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).
     
    648653
    649654  # Second, check for multiple CNAMEs
    650   my @t = $dbh->selectrow_array("SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}).
    651         " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type = 5 AND $hfield = ?",
    652         undef, $args{id}, $hcheck);
     655  my $sql = "SELECT count(*) FROM "._rectable($args{defrec}, $args{revrec}).
     656        " WHERE "._recparent($args{defrec}, $args{revrec})." = ? AND type = 5 AND $hfield = ?";
     657  my @lookupargs = ($args{id}, $hcheck);
     658  if ($args{update}) {
     659    $sql .= " AND record_id <> ?";
     660    push @lookupargs, $args{update};
     661  }
     662  my @t = $dbh->selectrow_array($sql, undef, @lookupargs);
    653663  if ($t[0] > 0) {
    654664    $errstr = "There is already a CNAME present for ".($args{revrec} eq 'y' ? $arpaname : $hcheck).
Note: See TracChangeset for help on using the changeset viewer.