| Bug #2248 | mysql_fetch without prior mysql_execute hangs | ||
|---|---|---|---|
| Submitted: | 1 Jan 2004 10:10 | Modified: | 11 Feb 2004 6:19 | 
| Reporter: | Georg Richter | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S3 (Non-critical) | 
| Version: | 4.1.2 | OS: | |
| Assigned to: | Dmitry Lenev | CPU Architecture: | Any | 
   [11 Feb 2004 6:19]
   Dmitry Lenev        
  Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.
If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html
Additional info:
ChangeSet 1.1664.33.1 2004/02/10 16:58:20 dlenev@dlenev.mshome
  Fixed bug #2248 "mysql_fetch without prior mysql_execute hangs"
  Done clean-up in prep stmt API functions...
 
Description: calling mysql_fetch without prior mysql_execute hangs instead to give an error. Not sure if I reported this bug already, but I wasn't able to find it in bug system :( How to repeat: #include <mysql.h> #include <stdio.h> main() { MYSQL *mysql; MYSQL_STMT *stmt; mysql = mysql_init(NULL); mysql_real_connect(mysql, "localhost", "root", "", "test", 0, NULL, 0); stmt = mysql_prepare(mysql, "SELECT DATABASE()", 100); mysql_fetch(stmt); // <------- hangs mysql_stmt_close(stmt); mysql_close(mysql); } Suggested fix: add an error check in mysql_fetch: if (stmt->state == MY_ST_PREPARE) { // throw error }