Bug #6096 field.max_length is always zero for numeric columns (stmt_resultset_metadata)
| Submitted: | 14 Oct 2004 12:44 | Modified: | 28 Oct 2004 13:10 |
|---|---|---|---|
| Reporter: | Georg Richter | Email Updates: | |
| Status: | Closed | Impact on me: | |
| Category: | MySQL Server | Severity: | S1 (Critical) |
| Version: | 4.1 | OS: | Linux (Linux) |
| Assigned to: | Konstantin Osipov | CPU Architecture: | Any |
[28 Oct 2004 13:10]
Konstantin Osipov
Fixed in 4.1.8 Subject: bk commit - 4.1 tree (konstantin:1.2056) BUG#6096 ChangeSet 1.2056 04/10/27 22:53:50 konstantin@mysql.com +3 -0 A fix and test case for Bug#6096 "field.max_length is always zero for numeric columns (stmt_resultset_metadata)" libmysql/libmysql.c 1.275 04/10/27 22:53:46 konstantin@mysql.com +19 -2 A fix for Bug#6096 "field.max_length is always zero for numeric columns (stmt_resultset_metadata)": set field->max_lenght for numeric columns when we set up skip_result functions. A minor drawback for this approach is that field->max_length can be not zero even if STMT_ATTR_UPDATE_MAX_LENGTH is not set.
Portions of this website are copyright © 2001, 2002 The PHP Group
Page generated in 0.051 sec. using MySQL 8.4.7-u6-cloud
Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the
respective copyright holders.
It is not reviewed in advance
by Oracle and does not necessarily represent the opinion of
Oracle or any other party.
Description: When retrieving resultset metadata from a prepared statement field->max_length is always zero for numerical values. Output: Max. Lenghts (PS) Field 1: Len:20 max. Len: 8 Field 2: Len:11 max. Len: 0 Lenghts (Query) Field 1: Len:20 max. Len: 8 Field 2: Len:11 max. Len: 4 How to repeat: #include <mysql.h> #include <stdio.h> main() { MYSQL *mysql; MYSQL_STMT *stmt; MYSQL_RES *result; char query[512]; int i; int val = 1; mysql = mysql_init(NULL); if (!mysql_real_connect(mysql, "localhost", "root", "", "test", 0, NULL, 0)) { printf("Error: %s\n", mysql_error(mysql)); mysql_close(mysql); exit(-1); } /* create a temporary table */ mysql_query(mysql, "CREATE TEMPORARY TABLE t1 (a varchar(20), c2 int)"); /* insert some values */ mysql_query(mysql, "INSERT INTO t1 VALUES ('foo',2),('bar(kov)',4000)"); stmt = mysql_stmt_init(mysql); strcpy(query, "SELECT * FROM t1"); mysql_stmt_prepare(stmt, query, strlen(query)); mysql_stmt_execute(stmt); mysql_stmt_attr_set(stmt, STMT_ATTR_UPDATE_MAX_LENGTH, (void *)&val); mysql_stmt_store_result(stmt); result = mysql_stmt_result_metadata(stmt); printf("Max. Lenghts (PS)\n"); for (i=0; i < 2; i++) { printf("Field %d: Len:%d max. Len: %d\n", i+1, result->fields[i].length, result->fields[i].max_length); } mysql_stmt_free_result(stmt); mysql_stmt_close(stmt); mysql_query(mysql, query); result = mysql_store_result(mysql); printf("Lenghts (Query)\n"); for (i=0; i < 2; i++) { printf("Field %d: Len:%d max. Len: %d\n", i+1, result->fields[i].length, result->fields[i].max_length); } mysql_free_result(result); mysql_close(mysql); }