[Pdns-users] automatic gmysql soa serial patch

Anthony Walker pdns at awalker.co.za
Sun Jun 10 09:22:44 UTC 2007


Hi

When I downloaded the latest release I was under the impression that SOA 
serials were automatically calculated using the last_change time field 
in the database.
I was surprised to find that that is only supported in the depreciated 
mysql backed and not in gmysql.

So I put this patch together to rectify that and am contributing it here 
in the hope it may be of use to others with the same wish and/or that 
perhaps someone may fix it up for the release version.
It seems to work ok, but its quite possible I don't know what I am doing.

The r.last_modified=atoi(row[6].c_str()) probably needs a check to make 
sure the value is valid before it assigns it, for the case of other sql 
backends that do not supply it or for the event of odd data in the database.

Regards
Anthony

--- ../orig/pdns-2.9.21/modules/gmysqlbackend/gmysqlbackend.cc  
2007-04-21 15:56:36.000000000 +0200
+++ modules/gmysqlbackend/gmysqlbackend.cc      2007-06-10 
10:52:30.000000000 +0200
@@ -51,17 +51,17 @@
     declare(suffix,"socket","Pdns backend socket to connect to","");
     declare(suffix,"password","Pdns backend password to connect with","");

-    declare(suffix,"basic-query","Basic query","select 
content,ttl,prio,type,domain_id,name from records where type='%s' and 
name='%s'");
-    declare(suffix,"id-query","Basic with ID query","select 
content,ttl,prio,type,domain_id,name from records where type='%s' and 
name='%s' and domain_id=%d");
-    declare(suffix,"wildcard-query","Wildcard query","select 
content,ttl,prio,type,domain_id,name from records where type='%s' and 
name like '%s'");
-    declare(suffix,"wildcard-id-query","Wildcard with ID query","select 
content,ttl,prio,type,domain_id,name from records where type='%s' and 
name like '%s' and domain_id='%d'");
-
-    declare(suffix,"any-query","Any query","select 
content,ttl,prio,type,domain_id,name from records where name='%s'");
-    declare(suffix,"any-id-query","Any with ID query","select 
content,ttl,prio,type,domain_id,name from records where name='%s' and 
domain_id=%d");
-    declare(suffix,"wildcard-any-query","Wildcard ANY query","select 
content,ttl,prio,type,domain_id,name from records where name like '%s'");
-    declare(suffix,"wildcard-any-id-query","Wildcard ANY with ID 
query","select content,ttl,prio,type,domain_id,name from records where 
name like '%s' and domain_id='%d'");
+    declare(suffix,"basic-query","Basic query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
type='%s' and name='%s'");
+    declare(suffix,"id-query","Basic with ID query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
type='%s' and name='%s' and domain_id=%d");
+    declare(suffix,"wildcard-query","Wildcard query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
type='%s' and name like '%s'");
+    declare(suffix,"wildcard-id-query","Wildcard with ID query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
type='%s' and name like '%s' and domain_id='%d'");
+
+    declare(suffix,"any-query","Any query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
name='%s'");
+    declare(suffix,"any-id-query","Any with ID query","select 
content,ttl,prio,type,domain_id,name,change_date from records where 
name='%s' and domain_id=%d");
+    declare(suffix,"wildcard-any-query","Wildcard ANY query","select 
content,ttl,prio,type,domain_id,name,change_date from records where name 
like '%s'");
+    declare(suffix,"wildcard-any-id-query","Wildcard ANY with ID 
query","select content,ttl,prio,type,domain_id,name,change_date from 
records where name like '%s' and domain_id='%d'");

-    declare(suffix,"list-query","AXFR query", "select 
content,ttl,prio,type,domain_id,name from records where domain_id='%d'");
+    declare(suffix,"list-query","AXFR query", "select 
content,ttl,prio,type,domain_id,name,change_date from records where 
domain_id='%d'");
     declare(suffix,"master-zone-query","Data", "select master from 
domains where name='%s' and type='SLAVE'");

     declare(suffix,"info-zone-query","","select 
id,name,master,last_check,notified_serial,type from domains where 
name='%s'");


--- ../orig/pdns-2.9.21/pdns/backends/gsql/gsqlbackend.cc       
2007-04-21 15:56:35.000000000 +0200
+++ pdns/backends/gsql/gsqlbackend.cc   2007-06-10 10:57:10.000000000 +0200
@@ -372,7 +372,7 @@
     else
       r.qname=row[5];
     r.qtype=row[3];
-    r.last_modified=0;
+    r.last_modified=atoi(row[6].c_str());

     r.domain_id=atoi(row[4].c_str());
     return true;




More information about the Pdns-users mailing list