g_log<<Logger::Warning<<"Result field at row " << d_residx << " column " << i << " has been truncated, we allocated " << d_res_bind[i].buffer_length << " bytes but at least " << *d_res_bind[i].length << " was needed" << endl;
}
if (*d_res_bind[i].is_null) {
- row.push_back("");
+ row.emplace_back("");
continue;
} else {
- row.push_back(string((char*)d_res_bind[i].buffer, std::min(d_res_bind[i].buffer_length, *d_res_bind[i].length)));
+ row.emplace_back((char*)d_res_bind[i].buffer, std::min(d_res_bind[i].buffer_length, *d_res_bind[i].length));
}
}
while(hasNextRow()) {
nextRow(row);
- result.push_back(row);
+ result.push_back(std::move(row));
}
return this;
row.reserve(PQnfields(d_res));
for(i=0;i<PQnfields(d_res);i++) {
if (PQgetisnull(d_res, d_residx, i)) {
- row.push_back("");
+ row.emplace_back("");
} else if (PQftype(d_res, i) == 16) { // BOOLEAN
char *val = PQgetvalue(d_res, d_residx, i);
- row.push_back(val[0] == 't' ? "1" : "0");
+ row.emplace_back(val[0] == 't' ? "1" : "0");
} else {
- row.push_back(string(PQgetvalue(d_res, d_residx, i)));
+ row.emplace_back(PQgetvalue(d_res, d_residx, i));
}
}
d_residx++;
if (d_res == NULL) return this;
result.reserve(d_resnum);
row_t row;
- while(hasNextRow()) { nextRow(row); result.push_back(row); }
+ while(hasNextRow()) { nextRow(row); result.push_back(std::move(row)); }
return this;
}
return false;
}
-void GSQLBackend::extractRecord(const SSqlStatement::row_t& row, DNSResourceRecord& r)
+void GSQLBackend::extractRecord(SSqlStatement::row_t& row, DNSResourceRecord& r)
{
+ static const int defaultTTL = ::arg().asNum( "default-ttl" );
+
if (row[1].empty())
- r.ttl = ::arg().asNum( "default-ttl" );
+ r.ttl = defaultTTL;
else
r.ttl=pdns_stou(row[1]);
+
if(!d_qname.empty())
r.qname=d_qname;
else
r.qtype=row[3];
- if (r.qtype==QType::MX || r.qtype==QType::SRV)
+ if (r.qtype==QType::MX || r.qtype==QType::SRV) {
+ r.content.reserve(row[2].size() + row[0].size() + 1);
r.content=row[2]+" "+row[0];
- else
- r.content=row[0];
+ }
+ else {
+ r.content=std::move(row[0]);
+ }
r.last_modified=0;
r.domain_id=pdns_stou(row[4]);
}
-void GSQLBackend::extractComment(const SSqlStatement::row_t& row, Comment& comment)
+void GSQLBackend::extractComment(SSqlStatement::row_t& row, Comment& comment)
{
comment.domain_id = pdns_stou(row[0]);
comment.qname = DNSName(row[1]);
comment.qtype = row[2];
comment.modified_at = pdns_stou(row[3]);
- comment.account = row[4];
- comment.content = row[5];
+ comment.account = std::move(row[4]);
+ comment.content = std::move(row[5]);
}
SSqlStatement::~SSqlStatement() {
protected:
bool createDomain(const DNSName &domain, const string &type, const string &masters, const string &account);
string pattern2SQLPattern(const string& pattern);
- void extractRecord(const SSqlStatement::row_t& row, DNSResourceRecord& rr);
- void extractComment(const SSqlStatement::row_t& row, Comment& c);
+ void extractRecord(SSqlStatement::row_t& row, DNSResourceRecord& rr);
+ void extractComment(SSqlStatement::row_t& row, Comment& c);
bool isConnectionUsable() {
if (d_db) {
return d_db->isConnectionUsable();
for ( int i=0; i<numCols; i++)
{
if (sqlite3_column_type(d_stmt,i) == SQLITE_NULL) {
- row.push_back("");
+ row.emplace_back("");
} else {
const char *pData = (const char*) sqlite3_column_text(d_stmt, i);
- row.push_back(string(pData, sqlite3_column_bytes(d_stmt, i)));
+ row.emplace_back(pData, sqlite3_column_bytes(d_stmt, i));
}
}
d_rc = sqlite3_step(d_stmt);
while(hasNextRow()) {
row_t row;
nextRow(row);
- result.push_back(row);
+ result.push_back(std::move(row));
}
return this;
}