Bug #42488 | metadata field 'length' is 0 after preparing statement: "select ?" | ||
---|---|---|---|
Submitted: | 30 Jan 2009 18:35 | Modified: | 24 Feb 2009 8:24 |
Reporter: | Shane Bester (Platinum Quality Contributor) | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server: Prepared statements | Severity: | S3 (Non-critical) |
Version: | 5.1.30 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | mysql_stmt_result_metadata |
[30 Jan 2009 18:35]
Shane Bester
[30 Jan 2009 18:41]
MySQL Verification Team
testcase
Attachment: bug42488.c (text/plain), 4.53 KiB.
[2 Feb 2009 7:27]
Sveta Smirnova
Server returns correct length for statements like "select 'foo'" or "select f1 from t1", so it mostly looks like not a bug for me. Regarding to generic application wouldn't it be not safe to return random values?
[2 Feb 2009 8:51]
MySQL Verification Team
If you call mysql_stmt_result_metadata() after each mysql_stmt_execute(), the correct metadata is returned. However, this workaround is too inefficient to use always, because too many calls would have to be made (1 per execute instead of 1 per prepare), which may involve the client malloc/free buffers all over again. Sveta: I agree with you - the only reliable "length" that can be guessed is to make it equal to max_allowed_packet, which is too large. So, I think this is a case that might well be best handled by the client... If client finds unacceptable metadata when calling mysql_stmt_result_metadata() before mysql_stmt_execute(), then it will call it after each mysql_stmt_execute(). Otherwise, only call mysql_stmt_result_metadata() once after mysql_stmt_prepare().