Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
dCache
cta
Commits
bf0a5465
Commit
bf0a5465
authored
Sep 25, 2019
by
Steven Murray
Browse files
Fixed bug in MysqlStmt::bindOptionalUint64() where a uint64 was treated as a double
parent
4c236672
Changes
2
Hide whitespace changes
Inline
Side-by-side
rdbms/StmtTest.cpp
View file @
bf0a5465
...
...
@@ -231,6 +231,44 @@ TEST_P(cta_rdbms_StmtTest, insert_with_bindUint64_2_pow_64_minus_1) {
}
}
TEST_P
(
cta_rdbms_StmtTest
,
insert_with_bindUint64_2_pow_64_minus_2
)
{
using
namespace
cta
::
rdbms
;
const
uint64_t
insertValue
=
18446744073709551614U
;
// Insert a row into the test table
{
const
char
*
const
sql
=
"INSERT INTO STMT_TEST("
"UINT64_COL) "
"VALUES("
":UINT64_COL)"
;
auto
stmt
=
m_conn
.
createStmt
(
sql
);
stmt
.
bindUint64
(
":UINT64_COL"
,
insertValue
);
stmt
.
executeNonQuery
();
}
// Select the row back from the table
{
const
char
*
const
sql
=
"SELECT "
"UINT64_COL AS UINT64_COL "
"FROM "
"STMT_TEST"
;
auto
stmt
=
m_conn
.
createStmt
(
sql
);
auto
rset
=
stmt
.
executeQuery
();
ASSERT_TRUE
(
rset
.
next
());
const
auto
selectValue
=
rset
.
columnOptionalUint64
(
"UINT64_COL"
);
ASSERT_TRUE
((
bool
)
selectValue
);
ASSERT_EQ
(
insertValue
,
selectValue
.
value
());
ASSERT_FALSE
(
rset
.
next
());
}
}
TEST_P
(
cta_rdbms_StmtTest
,
insert_with_bindString
)
{
using
namespace
cta
::
rdbms
;
...
...
rdbms/wrapper/MysqlStmt.cpp
View file @
bf0a5465
...
...
@@ -189,14 +189,14 @@ void MysqlStmt::bindOptionalUint64(const std::string ¶mName, const optional<
const
unsigned
int
paramIdx
=
getParamIdx
(
paramName
);
// starts from 1.
const
unsigned
int
idx
=
paramIdx
-
1
;
Mysql
::
Placeholder_
Double
*
holder
=
dynamic_cast
<
Mysql
::
Placeholder_
Double
*>
(
m_placeholder
[
idx
]);
Mysql
::
Placeholder_
Uint64
*
holder
=
dynamic_cast
<
Mysql
::
Placeholder_
Uint64
*>
(
m_placeholder
[
idx
]);
// if already exists, try to reuse
if
(
!
holder
and
m_placeholder
[
idx
])
{
throw
exception
::
Exception
(
std
::
string
(
__FUNCTION__
)
+
" can't cast from Placeholder to Placeholder_Uint64. "
);
}
if
(
!
holder
)
{
holder
=
new
Mysql
::
Placeholder_
Double
();
holder
=
new
Mysql
::
Placeholder_
Uint64
();
holder
->
idx
=
idx
;
holder
->
length
=
sizeof
(
uint64_t
);
}
...
...
Write
Preview
Supports
Markdown
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