[Pdns-users] Altering the SQL query for gmysql backend

Steven Looman steven at krx.nl
Fri Oct 8 08:26:38 UTC 2004


Ok, this is normal since they are using the same backend. I didn't take a look at the sources yet... Now I also know you meant something else when you asked about any ideas how to handle this. :)

I guess the simplest fix would be to have a function/method that replaces certain strings. The string class in the C++ STL does provide a basic_string::replace method, which can do the trick when using %name and %type (or %n and %t as suggested by James Cloos) in combination with basic_string::find. See http://www.sgi.com/tech/stl/basic_string.html for some information.

Another option would be to use a regexp library, but imo this is bloated since the first suggestion would work just fine and does not add (extra) dependencies to PowerDNS. The regexp lib is probably also slower than using basic_string::replace (but don't stick me to it ;)).

I'm willing to do mess around a bit with this in my free time and send you any of my results/patches. However, as I stated before I really don't like the idea of custom patches. But maybe this can be used in a future release of PowerDNS? (tho it will break old configs which use %s)

Steven Looman

PS.
Sorry for replying so much and to myself.

On Fri, Oct 08, 2004 at 09:49:28AM +0200, Steven Looman wrote:
> Same thing hapen when having more than two (in basic-query) '%s' when using the gmysql-backend.
> 
> 
> On Fri, Oct 08, 2004 at 08:52:15AM +0200, Steven Looman wrote:
> > Maybe it would be an idea to replace the %s with %type for type and %name for name. This way you don't need to worry about the order and makes things a bit clearer. Imo a good thing (TM).
> > 
> > Untill now I was using the generic PostgreSQL backend. But as I suggested, I want to start using the generic MySQL backend. Yesterday I was getting tired (was staying a bit longer at work) and didn't realize i actually should be checking out the generic MySQL backend... I will do so now and post my findings.
> > 
> > Greets,
> > 
> > steven Looman
> > 
> > On Thu, Oct 07, 2004 at 09:56:16PM +0200, bert hubert wrote:
> > > On Thu, Oct 07, 2004 at 06:39:59PM +0200, Steven Looman wrote:
> > > 
> > > > However, it does seem that powerdns cannot handle more than two (in this
> > > > case) %s values, it crashes (signal 11).
> > > 
> > > Indeed, I never realised people might want to add more %s's.
> > > 
> > > > If I do something like this (just to try things, of course added \'s to the end of each (but the last) line):
> > > >         select content, ttl, prio, type, domain_id, name
> > > >         from records
> > > >         where type='%s' and name='%s' and type='%s' and name='%s'
> > > > it also crashes (signal 11).
> > > 
> > > You'll need to edit pdns/backends/gsql/gsqlbackend.cc a lot to get this to
> > > work. Do you have any ideas on how PowerDNS should handle this, it needs a
> > > specific order of %s to make this work.
> > > 
> > > -- 
> > > http://www.PowerDNS.com      Open source, database driven DNS Software 
> > > http://lartc.org           Linux Advanced Routing & Traffic Control HOWTO
> > > 
> > _______________________________________________
> > Pdns-users mailing list
> > Pdns-users at mailman.powerdns.com
> > http://mailman.powerdns.com/mailman/listinfo/pdns-users
> > 
> _______________________________________________
> Pdns-users mailing list
> Pdns-users at mailman.powerdns.com
> http://mailman.powerdns.com/mailman/listinfo/pdns-users
> 


More information about the Pdns-users mailing list