BIND 10 trac2040, updated. 8c3cf6602f8977639b544fefbc6eb869b01eab07 [2040] compiled statements in MySQL benchmarks added for UPDATE and DELETE
BIND 10 source code commits
bind10-changes at lists.isc.org
Mon Aug 20 17:51:13 UTC 2012
The branch, trac2040 has been updated
via 8c3cf6602f8977639b544fefbc6eb869b01eab07 (commit)
from 6a212576107d4b72f31249850b634eb6f7fec5ce (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 8c3cf6602f8977639b544fefbc6eb869b01eab07
Author: Tomek Mrugalski <tomasz at isc.org>
Date: Mon Aug 20 19:50:59 2012 +0200
[2040] compiled statements in MySQL benchmarks added for UPDATE and DELETE
-----------------------------------------------------------------------
Summary of changes:
tests/tools/dhcp-ubench/mysql_ubench.cc | 125 +++++++++++++++++++++++++++++--
1 file changed, 117 insertions(+), 8 deletions(-)
-----------------------------------------------------------------------
diff --git a/tests/tools/dhcp-ubench/mysql_ubench.cc b/tests/tools/dhcp-ubench/mysql_ubench.cc
index 1a70bd7..f317c5a 100644
--- a/tests/tools/dhcp-ubench/mysql_ubench.cc
+++ b/tests/tools/dhcp-ubench/mysql_ubench.cc
@@ -467,6 +467,12 @@ void MySQL_uBenchmark::searchLease4Test() {
}
}
+ if (compiled_stmt_) {
+ if (mysql_stmt_close(stmt)) {
+ failure("Failed to close compiled statement, mysql_stmt_close returned non-zero");
+ }
+ }
+
printf("\n");
}
@@ -477,19 +483,74 @@ void MySQL_uBenchmark::updateLease4Test() {
printf("UPDATE: ");
+ uint32_t valid_lft = 1002; // just some dummy value
+ char cltt[] = "now()";
+ size_t cltt_len = strlen(cltt);
+ uint32_t addr = 0;
+
+ MYSQL_STMT * stmt = NULL;
+ MYSQL_BIND bind[3];
+ if (compiled_stmt_) {
+ stmt = mysql_stmt_init(Conn_);
+ if (!stmt) {
+ failure("Unable to create compiled statement");
+ }
+ const char * statement = "UPDATE lease4 SET valid_lft=?, cltt=? WHERE addr=?";
+ if (mysql_stmt_prepare(stmt, statement, strlen(statement))) {
+ failure("Failed to prepare statement, mysql_stmt_prepare() returned non-zero");
+ }
+ int param_cnt = mysql_stmt_param_count(stmt);
+ if (param_cnt != 3) {
+ failure("Parameter count sanity check failed.");
+ }
+
+ memset(bind, 0, sizeof(bind));
+
+ // 1st parameter: valid lifetime
+ bind[0].buffer_type = MYSQL_TYPE_LONG;
+ bind[0].buffer = &valid_lft;
+
+ // 2nd parameter: cltt
+ bind[1].buffer_type = MYSQL_TYPE_STRING;
+ bind[1].buffer = &cltt;
+ bind[1].buffer_length = cltt_len;
+
+ bind[2].buffer_type = MYSQL_TYPE_LONG;
+ bind[2].buffer = &addr;
+ }
+
+
for (uint32_t i = 0; i < num_; i++) {
- uint32_t x = BASE_ADDR4 + random() % num_;
+ addr = BASE_ADDR4 + random() % num_;
+
+ if (!compiled_stmt_) {
+ char query[128];
+ sprintf(query, "UPDATE lease4 SET valid_lft=1002, cltt=now() WHERE addr=%d", addr);
+ mysql_real_query(Conn_, query, strlen(query));
+
+ } else {
+ // compiled statement
+ if (mysql_stmt_bind_param(stmt, bind)) {
+ failure("Failed to bind parameters: mysql_stmt_bind_param() returned non-zero");
+ }
- char query[2000];
- sprintf(query, "UPDATE lease4 SET valid_lft=1002, cltt=now() WHERE addr=%d", x);
- mysql_real_query(Conn_, query, strlen(query));
+ if (mysql_stmt_execute(stmt)) {
+ failure("Failed to execute statement: mysql_stmt_execute() returned non-zero");
+ }
+ }
if (verbose_) {
printf(".");
}
}
+ if (compiled_stmt_) {
+ if (mysql_stmt_close(stmt)) {
+ failure("Failed to close compiled statement, mysql_stmt_close returned non-zero");
+ }
+ }
+
printf("\n");
}
@@ -500,19 +561,67 @@ void MySQL_uBenchmark::deleteLease4Test() {
printf("DELETE: ");
+ uint32_t addr = 0;
+
+ MYSQL_STMT * stmt = NULL;
+ MYSQL_BIND bind[1]; // just a single element
+ if (compiled_stmt_) {
+
+ stmt = mysql_stmt_init(Conn_);
+ if (!stmt) {
+ failure("Unable to create compiled statement, mysql_stmt_init() failed");
+ }
+
+ const char * statement = "DELETE FROM lease4 WHERE addr=?";
+
+ if (mysql_stmt_prepare(stmt, statement, strlen(statement) )) {
+ failure("Failed to prepare statement, mysql_stmt_prepare() returned non-zero");
+ }
+ int param_cnt = mysql_stmt_param_count(stmt);
+ if (param_cnt != 1) {
+ failure("Parameter count sanity check failed.");
+ }
+
+ memset(bind, 0, sizeof(bind));
+
+ // 1st parameter: IPv4 address
+ bind[0].buffer_type = MYSQL_TYPE_LONG;
+ bind[0].buffer = (&addr);
+ bind[0].is_null = 0;
+ bind[0].length = 0;
+ }
+
+
for (uint32_t i = 0; i < num_; i++) {
- uint32_t x = BASE_ADDR4 + i;
+ addr = BASE_ADDR4 + i;
+
+ if (!compiled_stmt_) {
+ char query[128];
+ sprintf(query, "DELETE FROM lease4 WHERE addr=%d", addr);
+ mysql_real_query(Conn_, query, strlen(query));
+ } else {
+ // compiled statement
+ if (mysql_stmt_bind_param(stmt, bind)) {
+ failure("Failed to bind parameters: mysql_stmt_bind_param() returned non-zero");
+ }
- char query[2000];
- sprintf(query, "DELETE FROM lease4 WHERE addr=%d", x);
- mysql_real_query(Conn_, query, strlen(query));
+ if (mysql_stmt_execute(stmt)) {
+ failure("Failed to execute statement: mysql_stmt_execute() returned non-zero");
+ }
+ }
if (verbose_) {
printf(".");
}
}
+ if (compiled_stmt_) {
+ if (mysql_stmt_close(stmt)) {
+ failure("Failed to close compiled statement, mysql_stmt_close returned non-zero");
+ }
+ }
+
printf("\n");
}
More information about the bind10-changes
mailing list