Bug #63835 | Cann't get ResultSet after using CURSOR in procedure | ||
---|---|---|---|
Submitted: | 22 Dec 2011 8:31 | Modified: | 17 Nov 2022 19:29 |
Reporter: | Tank W | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / C++ | Severity: | S3 (Non-critical) |
Version: | 1.0.5 | OS: | Windows (windows server 2008) |
Assigned to: | CPU Architecture: | Any | |
Tags: | cursor, ResultSet, sql::PreparedStatement |
[22 Dec 2011 8:31]
Tank W
[22 Dec 2011 8:40]
Tank W
step 4 changes "SET rstRoleID = '';" to "SET rstRoleID = '1';"
[23 Dec 2011 4:12]
Tank W
It's ok when I changed mysql server 5.5 to 5.1. It means the problem is about mysql server 5.5.
[26 Dec 2011 17:58]
Sveta Smirnova
Thank you for the report. Please send us full C++ code you use.
[27 Dec 2011 1:25]
Tank W
EnmDBResult UserDAL::GetUserByKey(UserDef *o_ent, const char * userName) { if(!o_ent) { return EnmDBResult_FAIL; } sql::PreparedStatement *pstmt = NULL; sql::ResultSet *res = NULL; EnmDBResult rst = EnmDBResult_FAIL; try { pstmt = ((sql::Connection*)_conn)->prepareStatement("CALL SP_User_SELECT_BY_ID(?)"); pstmt->setString(1, userName); pstmt->executeQuery(); res = pstmt->getResultSet(); if (res->next()) { rst = SetStringValue(&o_ent->UserName, F_User_UserName, _pool, res); if (rst == EnmDBResult_OK) { rst = SetStringValue(&o_ent->Password, F_User_Password, _pool, res); } if (rst == EnmDBResult_OK) { rst = SetStringValue(&o_ent->Name, F_User_Name, _pool, res); } if (rst == EnmDBResult_OK) { rst = SetStringValue(&o_ent->Email, F_User_Email, _pool, res); } if (rst == EnmDBResult_OK) { /// Get role list int len = 0; std::string strGet = res->getString(F_User_RoleID); len = strGet.length(); if (len > 0) { o_ent->RoleIDArray = apr_array_make(_pool, 1, sizeof(apr_int32_t)); char *strList = (char *)apr_palloc(_pool, len + 1); memcpy(strList, strGet.c_str(), len); strList[len] = 0; char *last; char *cur = apr_strtok(strList, kDBSplit, &last); while(cur != NULL) { int *temp = (int *)apr_array_push(o_ent->RoleIDArray); *temp = apr_atoi64(cur); cur = apr_strtok(NULL, kDBSplit, &last); } } else { o_ent->RoleIDArray = NULL; } } } else { rst = EnmDBResult_NotExist; } } catch (sql::SQLException &e) { WriteSQLException(&e, "UserDAL::GetUserByKey"); rst = EnmDBResult_SQLException; } EnmDBResult cret = CloseExecute(pstmt, res, ((sql::Connection*)_conn)); if(cret != EnmDBResult_OK) { rst = cret; } return rst; }
[29 Dec 2011 19:48]
Sveta Smirnova
Thank you for the feedback. Verified as described. Version 1.1.0 does not allow me to execute executeQuery on procedure which returns result set at all. 5.5 vs 5.1 issue, I think, happens, because 5.5 handles warnings in handlers differently.
[29 Dec 2011 19:51]
Sveta Smirnova
short test case and how-to
Attachment: bug63835.howto.txt (text/plain), 2.30 KiB.
[30 Dec 2011 1:38]
Tank W
Thank you for your answer
[17 Nov 2022 19:29]
Luis Silva
Posted by developer: Problem no longer reproducible on current connector with 5.7 or 8.0 server.