Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
ISC Open Source Projects
Kea
Commits
62fd2020
Commit
62fd2020
authored
Dec 03, 2019
by
Francis Dupont
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[
#1008
] Addressed comments
parent
c131e65e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
40 deletions
+53
-40
src/lib/mysql/mysql_connection.cc
src/lib/mysql/mysql_connection.cc
+53
-40
No files found.
src/lib/mysql/mysql_connection.cc
View file @
62fd2020
...
...
@@ -229,18 +229,22 @@ MySqlConnection::getVersion(const ParameterMap& parameters) {
"statement structure, reason: "
<<
mysql_error
(
conn
.
mysql_
));
}
try
{
// Prepare the statement from SQL text.
const
char
*
version_sql
=
"SELECT version, minor FROM schema_version"
;
int
status
=
mysql_stmt_prepare
(
stmt
,
version_sql
,
strlen
(
version_sql
));
if
(
status
!=
0
)
{
isc_throw
(
DbOperationError
,
"unable to prepare MySQL statement <"
<<
version_sql
<<
">, reason: "
<<
mysql_error
(
conn
.
mysql_
));
<<
version_sql
<<
">, reason: "
<<
mysql_error
(
conn
.
mysql_
));
}
// Execute the prepared statement.
if
(
mysql_stmt_execute
(
stmt
)
!=
0
)
{
isc_throw
(
DbOperationError
,
"cannot execute schema version query <"
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
}
// Bind the output of the statement to the appropriate variables.
...
...
@@ -261,20 +265,29 @@ MySqlConnection::getVersion(const ParameterMap& parameters) {
if
(
mysql_stmt_bind_result
(
stmt
,
bind
))
{
isc_throw
(
DbOperationError
,
"unable to bind result set for <"
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
}
// Fetch the data.
if
(
mysql_stmt_fetch
(
stmt
))
{
mysql_stmt_close
(
stmt
);
isc_throw
(
DbOperationError
,
"unable to bind result set for <"
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
<<
version_sql
<<
">, reason: "
<<
mysql_errno
(
conn
.
mysql_
));
}
// Discard the statement and its resources
mysql_stmt_close
(
stmt
);
return
(
std
::
make_pair
(
major
,
minor
));
}
catch
(
const
std
::
exception
&
)
{
// Avoid a memory leak on error.
mysql_stmt_close
(
stmt
);
// Send the exception to the caller.
throw
;
}
}
// Prepared statement setup. The textual form of an SQL statement is stored
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment