seznam / SuperiorMySqlpp

SuperiorMySQL++
GNU Lesser General Public License v3.0
31 stars 20 forks source link

Strange error while incorrect dynamic prepared statement result binding. #14

Closed majcl closed 6 years ago

majcl commented 8 years ago

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 that decimal cannot be binded to unsigned Long (the second type is ok - unsigned int(10) is actually unsigned Long, but this decimal is wrong, and also the error message misleading.

smradCZ commented 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?

majcl commented 6 years ago

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.