Closed majcl closed 6 years ago
It's because MYSQL_BIND
structure is initialized by zeros and buffer_type
with value 0 corresponds to type MYSQL_TYPE_DECIMAL
.
I'd made some tests and some observations on MySQL library source code, so:
Solution: I can fix the exception message only and let the responsibility on the developer or I can check whether all binds are set. I would prefer check bind params, but on other side it adds extra overhead.
Any thoughts?
So, this is actually not initialized "variable" issue. IMHO undefined behaviour for not initialized "variable" is perfectly valid. I think that more detailed error with not-initialized parameter suggestion will be enough.
Example: 1) We have two
unsigned int
columns in dynamic prepared statement result. 2) We incorrectly bind only first column, but twice, to different places. 3) Strange error occurs on updateResultBinding thatdecimal
cannot be binded tounsigned Long
(the second type is ok -unsigned int(10)
is actuallyunsigned Long
, but thisdecimal
is wrong, and also the error message misleading.