From 0853684091a90800705c053e092ff15e0bbf6741 Mon Sep 17 00:00:00 2001 From: Pieter Lexis Date: Wed, 10 Feb 2016 12:20:56 +0100 Subject: [PATCH] Deprecate the insert-record-order-query --- .../authoritative/backend-generic-sql.md | 1 - modules/gmysqlbackend/gmysqlbackend.cc | 3 +- modules/godbcbackend/godbcbackend.cc | 3 +- modules/goraclebackend/goraclebackend.cc | 3 +- modules/gpgsqlbackend/gpgsqlbackend.cc | 3 +- modules/gsqlite3backend/gsqlite3backend.cc | 3 +- pdns/backends/gsql/gsqlbackend.cc | 56 +++++++------------ pdns/backends/gsql/gsqlbackend.hh | 6 +- pdns/ssqlite3.cc | 2 +- 9 files changed, 28 insertions(+), 52 deletions(-) diff --git a/docs/markdown/authoritative/backend-generic-sql.md b/docs/markdown/authoritative/backend-generic-sql.md index 63d988497d..704b083319 100644 --- a/docs/markdown/authoritative/backend-generic-sql.md +++ b/docs/markdown/authoritative/backend-generic-sql.md @@ -206,7 +206,6 @@ if you wish to calculate ordername and auth without using pdns-rectify. - `info-zone-query`: Called to retrieve (nearly) all information for a domain. - `insert-record-query`: Called during incoming AXFR. -- `insert-record-order-query`: Add a new record for a domain, including the ordername. - `update-account-query`: Set the account for a domain. - `delete-names-query`: Called to delete all records of a certain name. - `delete-rrset-query`: Called to delete an RRset based on domain\_id, name and type. diff --git a/modules/gmysqlbackend/gmysqlbackend.cc b/modules/gmysqlbackend/gmysqlbackend.cc index e14e99e8de..6b0e7c033e 100644 --- a/modules/gmysqlbackend/gmysqlbackend.cc +++ b/modules/gmysqlbackend/gmysqlbackend.cc @@ -77,8 +77,7 @@ public: declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)"); - declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (?,?,?,?,?,?,?,?)"); - declare(suffix, "insert-record-order-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,?,?)"); + declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,?,?)"); declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,?,0,?,?,?)"); declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername from records where domain_id=? and disabled=0 and ordername is not null order by 1 asc limit 1"); diff --git a/modules/godbcbackend/godbcbackend.cc b/modules/godbcbackend/godbcbackend.cc index 6c73fce114..9be9e7c64c 100644 --- a/modules/godbcbackend/godbcbackend.cc +++ b/modules/godbcbackend/godbcbackend.cc @@ -75,8 +75,7 @@ public: declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',?)"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',?,?,?)"); - declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (?,?,?,?,?,?,?,?)"); - declare(suffix, "insert-record-order-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,convert(varbinary(255),?),?)"); + declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (?,?,?,?,?,?,?,convert(varbinary(255),?),?)"); declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,?,0,?,convert(varbinary(255),?),?)"); declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select top 1 convert(varchar(255), ordername) from records where domain_id=? and disabled=0 and ordername is not null order by 1 asc"); diff --git a/modules/goraclebackend/goraclebackend.cc b/modules/goraclebackend/goraclebackend.cc index d7d495c2b2..a52908940b 100644 --- a/modules/goraclebackend/goraclebackend.cc +++ b/modules/goraclebackend/goraclebackend.cc @@ -90,8 +90,7 @@ public: declare(suffix, "supermaster-name-to-ips", "", "select ip,account from supermasters where nameserver=:nameserver and account=:account"); declare(suffix, "insert-zone-query", "", "insert into domains (id,type,name) values(domains_id_sequence.nextval,'NATIVE',:domain)"); declare(suffix, "insert-slave-query", "", "insert into domains (id,type,name,master,account) values(domains_id_sequence.nextval,'SLAVE',:domain,:masters,:account)"); - declare(suffix, "insert-record-query", "", "insert into records (id,content,ttl,prio,type,domain_id,disabled,name,auth) values (records_id_sequence.nextval,:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:auth)"); - declare(suffix, "insert-record-order-query", "", "insert into records (id,content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval,:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername || ' ',:auth)"); + declare(suffix, "insert-record-query", "", "insert into records (id,content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval,:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername || ' ',:auth)"); declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (id,type,domain_id,disabled,name,ordername,auth) values (records_id_sequence.nextval,null,:domain_id,0,:qname,:ordername,:auth)"); declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select * FROM (select trim(ordername) from records where disabled=0 and domain_id=:domain_id and ordername is not null order by ordername asc) where rownum=1"); diff --git a/modules/gpgsqlbackend/gpgsqlbackend.cc b/modules/gpgsqlbackend/gpgsqlbackend.cc index 9822bbd908..f5b97391e4 100644 --- a/modules/gpgsqlbackend/gpgsqlbackend.cc +++ b/modules/gpgsqlbackend/gpgsqlbackend.cc @@ -72,8 +72,7 @@ public: declare(suffix,"insert-zone-query","", "insert into domains (type,name) values('NATIVE',$1)"); declare(suffix,"insert-slave-query","", "insert into domains (type,name,master,account) values('SLAVE',$1,$2,$3)"); - declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values ($1,$2,$3,$4,$5,$6,$7,$8)"); - declare(suffix, "insert-record-order-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ($1,$2,$3,$4,$5,$6,$7,$8,$9)"); + declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values ($1,$2,$3,$4,$5,$6,$7,$8,$9)"); declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,$1,false,$2,$3,$4)"); declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, last", "select ordername from records where disabled=false and domain_id=$1 and ordername is not null order by 1 using ~<~ limit 1"); diff --git a/modules/gsqlite3backend/gsqlite3backend.cc b/modules/gsqlite3backend/gsqlite3backend.cc index 5f36707b2a..9952acfaea 100644 --- a/modules/gsqlite3backend/gsqlite3backend.cc +++ b/modules/gsqlite3backend/gsqlite3backend.cc @@ -88,8 +88,7 @@ public: declare(suffix, "insert-zone-query", "", "insert into domains (type,name) values('NATIVE',:domain)"); declare(suffix, "insert-slave-query", "", "insert into domains (type,name,master,account) values('SLAVE',:domain,:masters,:account)"); - declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:auth)"); - declare(suffix, "insert-record-order-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername,:auth)"); + declare(suffix, "insert-record-query", "", "insert into records (content,ttl,prio,type,domain_id,disabled,name,ordername,auth) values (:content,:ttl,:priority,:qtype,:domain_id,:disabled,:qname,:ordername,:auth)"); declare(suffix, "insert-empty-non-terminal-order-query", "insert empty non-terminal in zone", "insert into records (type,domain_id,disabled,name,ordername,auth) values (null,:domain_id,0,:qname,:ordername,:auth)"); declare(suffix, "get-order-first-query", "DNSSEC Ordering Query, first", "select ordername from records where disabled=0 and domain_id=:domain_id and ordername is not null order by 1 asc limit 1"); diff --git a/pdns/backends/gsql/gsqlbackend.cc b/pdns/backends/gsql/gsqlbackend.cc index 7d97153a23..70f5e3eee6 100644 --- a/pdns/backends/gsql/gsqlbackend.cc +++ b/pdns/backends/gsql/gsqlbackend.cc @@ -93,8 +93,6 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_DeleteCommentRRsetQuery = getArg("delete-comment-rrset-query"); d_DeleteCommentsQuery = getArg("delete-comments-query"); - d_InsertRecordOrderQuery=getArg("insert-record-order-query"); - d_firstOrderQuery = getArg("get-order-first-query"); d_beforeOrderQuery = getArg("get-order-before-query"); d_afterOrderQuery = getArg("get-order-after-query"); @@ -144,7 +142,6 @@ GSQLBackend::GSQLBackend(const string &mode, const string &suffix) d_InsertZoneQuery_stmt = NULL; d_InsertSlaveZoneQuery_stmt = NULL; d_InsertRecordQuery_stmt = NULL; - d_InsertRecordOrderQuery_stmt = NULL; d_InsertEmptyNonTerminalOrderQuery_stmt = NULL; d_UpdateMasterOfZoneQuery_stmt = NULL; d_UpdateKindOfZoneQuery_stmt = NULL; @@ -1305,39 +1302,28 @@ bool GSQLBackend::feedRecord(const DNSResourceRecord &r, string *ordername) } try { - if(d_dnssecQueries && ordername) - { - d_InsertRecordOrderQuery_stmt-> - bind("content",content)-> - bind("ttl",r.ttl)-> - bind("priority",prio)-> - bind("qtype",r.qtype.getName())-> - bind("domain_id",r.domain_id)-> - bind("disabled",r.disabled)-> - bind("qname",r.qname); // FIXME400 lowercase? - if (ordername == NULL) - d_InsertRecordOrderQuery_stmt->bindNull("ordername"); - else - d_InsertRecordOrderQuery_stmt->bind("ordername",*ordername); - d_InsertRecordOrderQuery_stmt-> - bind("auth",r.auth)-> - execute()-> - reset(); - } + d_InsertRecordQuery_stmt-> + bind("content",content)-> + bind("ttl",r.ttl)-> + bind("priority",prio)-> + bind("qtype",r.qtype.getName())-> + bind("domain_id",r.domain_id)-> + bind("disabled",r.disabled)-> + bind("qname",stripDot(r.qname.toString())); // FIXME400 lowercase? + + if (ordername == NULL) + d_InsertRecordQuery_stmt->bindNull("ordername"); else - { - d_InsertRecordQuery_stmt-> - bind("content",content)-> - bind("ttl",r.ttl)-> - bind("priority",prio)-> - bind("qtype",r.qtype.getName())-> - bind("domain_id",r.domain_id)-> - bind("disabled",r.disabled)-> - bind("qname",r.qname)-> - bind("auth", (r.auth || !d_dnssecQueries))-> - execute()-> - reset(); - } + d_InsertRecordQuery_stmt->bind("ordername",*ordername); + + if (d_dnssecQueries) + d_InsertRecordQuery_stmt->bind("auth", r.auth); + else + d_InsertRecordQuery_stmt->bind("auth", true); + + d_InsertRecordQuery_stmt-> + execute()-> + reset(); } catch (SSqlException &e) { throw DBException("GSQLBackend unable to feed record: "+e.txtReason()); diff --git a/pdns/backends/gsql/gsqlbackend.hh b/pdns/backends/gsql/gsqlbackend.hh index fb55e0556e..ae713201a0 100644 --- a/pdns/backends/gsql/gsqlbackend.hh +++ b/pdns/backends/gsql/gsqlbackend.hh @@ -44,8 +44,7 @@ public: d_GetSuperMasterIPs_stmt = d_db->prepare(d_GetSuperMasterIPs, 2); d_InsertZoneQuery_stmt = d_db->prepare(d_InsertZoneQuery, 1); d_InsertSlaveZoneQuery_stmt = d_db->prepare(d_InsertSlaveZoneQuery, 3); - d_InsertRecordQuery_stmt = d_db->prepare(d_InsertRecordQuery, 8); - d_InsertRecordOrderQuery_stmt = d_db->prepare(d_InsertRecordOrderQuery, 9); + d_InsertRecordQuery_stmt = d_db->prepare(d_InsertRecordQuery, 9); d_InsertEmptyNonTerminalOrderQuery_stmt = d_db->prepare(d_InsertEmptyNonTerminalOrderQuery, 4); d_UpdateMasterOfZoneQuery_stmt = d_db->prepare(d_UpdateMasterOfZoneQuery, 2); d_UpdateKindOfZoneQuery_stmt = d_db->prepare(d_UpdateKindOfZoneQuery, 2); @@ -114,7 +113,6 @@ public: release(&d_InsertZoneQuery_stmt); release(&d_InsertSlaveZoneQuery_stmt); release(&d_InsertRecordQuery_stmt); - release(&d_InsertRecordOrderQuery_stmt); release(&d_InsertEmptyNonTerminalOrderQuery_stmt); release(&d_UpdateMasterOfZoneQuery_stmt); release(&d_UpdateKindOfZoneQuery_stmt); @@ -252,7 +250,6 @@ private: string d_InsertZoneQuery; string d_InsertSlaveZoneQuery; string d_InsertRecordQuery; - string d_InsertRecordOrderQuery; string d_InsertEmptyNonTerminalOrderQuery; string d_UpdateMasterOfZoneQuery; string d_UpdateKindOfZoneQuery; @@ -325,7 +322,6 @@ private: SSqlStatement* d_InsertZoneQuery_stmt; SSqlStatement* d_InsertSlaveZoneQuery_stmt; SSqlStatement* d_InsertRecordQuery_stmt; - SSqlStatement* d_InsertRecordOrderQuery_stmt; SSqlStatement* d_InsertEmptyNonTerminalOrderQuery_stmt; SSqlStatement* d_UpdateMasterOfZoneQuery_stmt; SSqlStatement* d_UpdateKindOfZoneQuery_stmt; diff --git a/pdns/ssqlite3.cc b/pdns/ssqlite3.cc index 536442b422..3b57698b4e 100644 --- a/pdns/ssqlite3.cc +++ b/pdns/ssqlite3.cc @@ -46,7 +46,7 @@ public: #else if (sqlite3_prepare(d_db->db(), query.c_str(), -1, &d_stmt, &pTail ) != SQLITE_OK) #endif - throw SSqlException(string("Unable to compile SQLite statement : ")+sqlite3_errmsg(d_db->db())); + throw SSqlException(string("Unable to compile SQLite statement : '")+query+"': "+sqlite3_errmsg(d_db->db())); if (pTail && strlen(pTail)>0) L<