Changeset 561

Show
Ignore:
Timestamp:
01/18/06 23:01:16 (7 years ago)
Author:
ahu
Message:

opendbx updates by Norbert

Location:
trunk/pdns/modules/opendbxbackend
Files:
3 modified

Legend:

Unmodified
Added
Removed
  • trunk/pdns/modules/opendbxbackend/odbxbackend.cc

    r559 r561  
    6666{ 
    6767        const char* tmp; 
    68         string stmt, type; 
     68        string stmt; 
    6969 
    7070 
     
    8484                        di.master = ""; 
    8585                        di.last_check = 0; 
     86                        di.notified_serial = 0; 
     87                        di.kind = DomainInfo::Native; 
    8688                        di.backend = this; 
    87                         type = ""; 
     89                        di.serial = 0; 
    8890 
    8991                        if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) 
     
    99101                        if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) 
    100102                        { 
     103                                if( !strncmp( tmp, "SLAVE", 5 ) ) 
     104                                { 
     105                                        di.kind = DomainInfo::Slave; 
     106                                } 
     107                                else if( !strncmp( tmp, "MASTER", 6 ) ) 
     108                                { 
     109                                        di.kind = DomainInfo::Master; 
     110                                } 
     111                        } 
     112 
     113                        if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
     114                        { 
    101115                                di.master = string( tmp ); 
    102116                        } 
    103117 
    104                         if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
     118                        if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) 
    105119                        { 
    106120                                di.last_check = strtol( tmp, NULL, 10 ); 
    107121                        } 
    108122 
    109                         if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) 
    110                         { 
    111                                 type = string( tmp ); 
    112                         } 
    113  
    114                         di.kind = DomainInfo::Native; 
    115  
    116                         if( type == "SLAVE" ) 
     123                        if( ( tmp = odbx_field_value( m_result, 6 ) ) != NULL ) 
    117124                        { 
    118125                                SOAData sd; 
    119126 
    120127                                sd.serial = 0; 
    121  
    122                                 if( ( tmp = odbx_field_value( m_result, 6 ) ) != NULL ) 
    123                                 { 
    124128                                        DNSPacket::fillSOAData( string( tmp ), sd ); 
    125                                 } 
    126                                 else 
    127                                 { 
    128                                         L.log( m_myname + " getDomainInfo: No serial for '" + domain + "' found", Logger::Notice ); 
    129                                 } 
    130  
    131129                                di.serial = sd.serial; 
    132                                 di.kind = DomainInfo::Slave; 
    133                         } 
    134                         else if( type == "MASTER" ) 
    135                         { 
    136                                 di.kind = DomainInfo::Master; 
    137130                        } 
    138131                } 
     
    260253                        if( ( tmp = odbx_field_value( m_result, 0 ) ) != NULL ) 
    261254                        { 
     255                                rr.domain_id = strtol( tmp, NULL, 10 ); 
     256                        } 
     257 
     258                        if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) 
     259                        { 
     260                                rr.qname = string( tmp ); 
     261                        } 
     262 
     263                        if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) 
     264                        { 
     265                                rr.qtype = QType( tmp ); 
     266                        } 
     267 
     268                        if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
     269                        { 
     270                                rr.ttl = strtoul( tmp, NULL, 10 ); 
     271                        } 
     272 
     273                        if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) 
     274                        { 
     275                                rr.priority = (u_int16_t) strtoul( tmp, NULL, 10 ); 
     276                        } 
     277 
     278                        if( ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) 
     279                        { 
    262280                                rr.content = string( tmp ); 
    263                         } 
    264  
    265                         if( ( tmp = odbx_field_value( m_result, 1 ) ) != NULL ) 
    266                         { 
    267                                 rr.ttl = strtoul( tmp, NULL, 10 ); 
    268                         } 
    269  
    270                         if( ( tmp = odbx_field_value( m_result, 2 ) ) != NULL ) 
    271                         { 
    272                                 rr.priority = (u_int16_t) strtoul( tmp, NULL, 10 ); 
    273                         } 
    274  
    275                         if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
    276                         { 
    277                                 rr.qtype = QType( tmp ); 
    278                         } 
    279  
    280                         if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) 
    281                         { 
    282                                 rr.domain_id = strtol( tmp, NULL, 10 ); 
    283                         } 
    284  
    285                         if( m_qname.empty() && ( tmp = odbx_field_value( m_result, 5 ) ) != NULL ) 
    286                         { 
    287                                 rr.qname = string( tmp ); 
    288281                        } 
    289282 
  • trunk/pdns/modules/opendbxbackend/odbxbackend.hh

    r559 r561  
    114114                declare( suffix, "password","Password for connecting to the DBMS",""); 
    115115 
    116                 declare( suffix, "sql-list", "AXFR query", "SELECT content, ttl, prio, type, domain_id, name FROM records WHERE domain_id=':id'" ); 
     116                declare( suffix, "sql-list", "AXFR query", "SELECT domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id'" ); 
    117117 
    118                 declare( suffix, "sql-lookup", "Lookup query","SELECT content, ttl, prio, type, domain_id, name FROM records WHERE name=':name'" ); 
    119                 declare( suffix, "sql-lookupid", "Lookup query with id","SELECT content, ttl, prio, type, domain_id, name FROM records WHERE name=':name' AND domain_id=':id'" ); 
    120                 declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT content, ttl, prio, type, domain_id, name FROM records WHERE type=':type' AND name=':name'" ); 
    121                 declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT content, ttl, prio, type, domain_id, name FROM records WHERE type=':type' AND name=':name' AND domain_id=':id'" ); 
     118                declare( suffix, "sql-lookup", "Lookup query","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE name=':name'" ); 
     119                declare( suffix, "sql-lookupid", "Lookup query with id","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id' AND name=':name'" ); 
     120                declare( suffix, "sql-lookuptype", "Lookup query with type","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE name=':name' AND type=':type'" ); 
     121                declare( suffix, "sql-lookuptypeid", "Lookup query with type and id","SELECT domain_id, name, type, ttl, prio, content FROM records WHERE domain_id=':id' AND name=':name' AND type=':type'" ); 
    122122 
    123123                declare( suffix, "sql-zonedelete","Delete all records for this zone","DELETE FROM records WHERE domain_id=':id'" ); 
    124                 declare( suffix, "sql-zoneinfo","Get domain info","SELECT d.id, d.name, d.master, d.last_check, d.notified_serial, d.type, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.name=':name' AND r.type='SOA' ) OR ( d.name=':name' AND r.domain_id IS NULL )" ); 
     124                declare( suffix, "sql-zoneinfo","Get domain info","SELECT d.id, d.name, d.type, d.master, d.last_check, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.name=':name' AND r.type='SOA' ) OR ( d.name=':name' AND r.domain_id IS NULL )" ); 
    125125 
    126126                declare( suffix, "sql-transactbegin", "Start transaction", "BEGIN" ); 
     
    128128                declare( suffix, "sql-transactabort", "Abort transaction", "ROLLBACK" ); 
    129129 
    130                 declare( suffix, "sql-insert-slave","Add slave domain", "INSERT INTO domains ( type, name, master, account ) VALUES ( 'SLAVE', '%s', '%s', '%s' )" ); 
     130                declare( suffix, "sql-insert-slave","Add slave domain", "INSERT INTO domains ( name, type, master, account ) VALUES ( '%s', 'SLAVE', '%s', '%s' )" ); 
    131131                declare( suffix, "sql-insert-record","Feed record into table", "INSERT INTO records ( domain_id, name, type, ttl, prio, content ) VALUES ( '%d', '%s', '%s', '%d', '%d', '%s' )" ); 
    132132 
     
    134134                declare( suffix, "sql-update-lastcheck", "Set time of last check", "UPDATE domains SET last_check='%d' WHERE id='%d'" ); 
    135135 
    136                 declare( suffix, "sql-master", "Get master record for zone", "SELECT master FROM domains WHERE type='SLAVE' AND name=':name'" ); 
     136                declare( suffix, "sql-master", "Get master record for zone", "SELECT master FROM domains WHERE name=':name' AND type='SLAVE'" ); 
    137137                declare( suffix, "sql-supermaster","Get supermaster info", "SELECT account FROM supermasters WHERE ip=':ip' AND nameserver=':ns'" ); 
    138138 
    139                 declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.id, d.name, d.master, d.last_check, d.notified_serial, r.change_date, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.type='SLAVE' AND r.type='SOA' ) OR ( d.type='SLAVE' AND r.domain_id IS NULL )" ); 
    140                 declare( suffix, "sql-infomasters", "Get all updated masters", "SELECT d.id, d.name, d.master, d.last_check, d.notified_serial, r.change_date, r.content FROM domains AS d, records AS r WHERE d.type='MASTER' AND d.id=r.domain_id AND r.type='SOA'" ); 
     139                declare( suffix, "sql-infoslaves", "Get all unfresh slaves", "SELECT d.id, d.name, d.master, d.notified_serial, d.last_check, r.change_date, r.content FROM domains AS d LEFT JOIN records AS r ON d.id=r.domain_id WHERE ( d.type='SLAVE' AND r.type='SOA' ) OR ( d.type='SLAVE' AND r.domain_id IS NULL )" ); 
     140                declare( suffix, "sql-infomasters", "Get all updated masters", "SELECT d.id, d.name, d.master, d.notified_serial, d.last_check, r.change_date, r.content FROM domains AS d, records AS r WHERE d.type='MASTER' AND d.id=r.domain_id AND r.type='SOA'" ); 
    141141        } 
    142142 
  • trunk/pdns/modules/opendbxbackend/odbxprivate.cc

    r559 r561  
    139139                if( ( tmp = odbx_field_value( m_result, 4 ) ) != NULL ) 
    140140                { 
     141                        nlast = strtol( tmp, NULL, 10 ); 
     142                } 
     143 
     144                if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
     145                { 
    141146                        nserial = strtol( tmp, NULL, 10 ); 
    142                 } 
    143  
    144                 if( ( tmp = odbx_field_value( m_result, 3 ) ) != NULL ) 
    145                 { 
    146                         nlast = strtol( tmp, NULL, 10 ); 
    147147                } 
    148148