Bug #21635 | MYSQL_FIELD struct's member strings seem to misbehave for expression cols | ||
---|---|---|---|
Submitted: | 14 Aug 2006 20:35 | Modified: | 4 Dec 2006 14:09 |
Reporter: | Bryan Maloney | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: C API (client library) | Severity: | S3 (Non-critical) |
Version: | 4.1, 5.0.26-BK, 5.0.24 | OS: | Linux (Linux, Redhat 3.2.2-5) |
Assigned to: | Tomash Brechko | CPU Architecture: | Any |
Tags: | expression, MYSQL_FIELD, org_name |
[14 Aug 2006 20:35]
Bryan Maloney
[14 Aug 2006 20:37]
Bryan Maloney
After proofing the bug report I notice I missed a line in the code fragment. Add the following before the loop: unsigned long field_count = mysql_field_count(conn); sorry!
[26 Aug 2006 10:47]
Valeriy Kravchuk
Thank you for a problem report. Please, try to repeat with a newer version, 5.0.24, and inform about the results.
[30 Aug 2006 20:57]
Bryan Maloney
I am still seeing the problem with both server and client libraries upgraded to v 5.0.24: MySQL Client: 5.0.24 MySql Server: 5.0.24-standard-log field 0 name: tID org_name: ID table: f org_table: Test field 1 name: max1 org_name: max1 table: org_table: field 2 name: count(f.ID) org_name: count(f.ID) table: org_table: field 3 name: juan org_name: table: org_table: field 4 name: 2 org_name: table: org_table: field 5 name: Test Name org_name: name table: f org_table: Test field 6 name: Test Short Name org_name: abbr table: f org_table: Test field 7 name: ID org_name: ID table: Y org_table: tv field 8 name: value org_name: value table: Y org_table: tv field 9 name: valid org_name: valid table: Y org_table: tv
[27 Sep 2006 20:24]
Valeriy Kravchuk
Verified with 5.0.26-BK on linux, with a similar test case: openxs@suse:~/dbs/5.0> cat 21635.c #include <stdio.h> #include "mysql.h" int main() { MYSQL *conn; char SELECT1[1000]= "SELECT f.ID AS 'tID', max(f.ID) AS 'max1', 1 AS 'juan', count(f.ID), 2, f.name AS 'Test Name', f.abbr AS 'Test Short Name', Y.*, f.ID AS '__[test][Test][ID]', Y.ID AS '__[ test][tv][ID]' FROM (Test AS f, tv AS Y) GROUP BY f.id LIMIT 10" ; conn= mysql_init(NULL); conn= mysql_real_connect(conn, "127.0.0.1", "root", "", "test", 3306, 0, 0); if (!conn) { fprintf(stderr, "Cannot connect\n"); exit(1); } printf("Client info: %s\n", mysql_get_client_info()); printf("Server info: %s\n", mysql_get_server_info(conn)); mysql_real_query(conn, SELECT1, strlen(SELECT1)); MYSQL_RES *resp = mysql_store_result(conn); if (resp == NULL) { mysql_free_result(resp); } MYSQL_FIELD *field; int x; unsigned long field_count = mysql_num_fields(resp); for(x = 0; x < field_count; x++) { field = mysql_fetch_field_direct(resp, x); printf("field %d\n\tname: %s\n\torg_name: %s\n\ttable: %s\n\torg_table: %s\n", x, field->name, field->org_name, field->table, field->org_table); } mysql_close(conn); return 0; } openxs@suse:~/dbs/5.0> gcc -o 21635 `$CFG --cflags` 21635.c `$CFG --libs` openxs@suse:~/dbs/5.0> ./21635 Client info: 5.0.22 Server info: 5.0.26-debug field 0 name: tID org_name: ID table: f org_table: Test field 1 name: max1 org_name: max1 table: f org_table: Test field 2 name: juan org_name: table: org_table: field 3 name: count(f.ID) org_name: count(f.ID) table: org_table: field 4 name: 2 org_name: table: org_table: field 5 name: Test Name org_name: name table: f org_table: Test field 6 name: Test Short Name org_name: abbr table: f org_table: Test field 7 name: ID org_name: ID table: Y org_table: tv field 8 name: value org_name: value table: Y org_table: tv field 9 name: valid org_name: valid table: Y org_table: tv field 10 name: __[test][Test][ID] org_name: ID table: f org_table: Test field 11 name: __[test][tv][ID] org_name: ID table: Y org_table: tv
[17 Nov 2006 15:07]
Tomash Brechko
Adding 4.1, as the bug is there too.
[17 Nov 2006 16:17]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/15511 ChangeSet@1.2540, 2006-11-17 19:14:09+03:00, kroki@moonlight.intranet +2 -0 BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for expression cols. The problem was that MYSQL_FIELD::org_name was set for MIN() and MAX() functions (COUNT() was already fixed). The solution is to reset this field for all functions.
[21 Nov 2006 16:34]
Konstantin Osipov
Sent a reivew by email.
[22 Nov 2006 11:01]
Bugs System
A patch for this bug has been committed. After review, it may be pushed to the relevant source trees for release in the next version. You can access the patch from: http://lists.mysql.com/commits/15693 ChangeSet@1.2540, 2006-11-22 13:58:00+03:00, kroki@moonlight.intranet +2 -0 BUG#21635: MYSQL_FIELD struct's member strings seem to misbehave for expression cols. The problem was that MYSQL_FIELD::org_name was set for MIN() and MAX() functions (COUNT() is also mentioned in the bug report but was already fixed). After this patch for expressions MYSQL_FIELD::name is set to either expression itself or its alias, and other data origin fields of MYSQL_FILED (db, org_table, table, org_name) are empty strings.
[22 Nov 2006 13:59]
Tomash Brechko
Queued to 4.1-runtime, 5.0-runtime, 5.1-runtime.
[30 Nov 2006 1:34]
Konstantin Osipov
Pushed into 4.1.23, 5.0.32 and 5.1.13
[4 Dec 2006 14:09]
MC Brown
A note has been added to the 4.1.23, 5.0.30 and 5.1.14 changelogs.
[20 Jan 2007 17:12]
TOM DONOVAN
The mysql_client_test for this bug continues to fail on 5.0.33. Executed on Windows 2000 sp4, built from 5.0.33 Windows community source. Appears not to be fixed. ##################################### 201 of (1/1): test_bug21635 ##################################### MIN(i) -> MIN(i) ... .\mysql_client_test.c:15447: check failed: 'field->db[0] == 0 && field->org_table[0] == 0 && field->table[0] == 0 && field->org_name[0] == 0' This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.
[15 Apr 2007 17:03]
TOM DONOVAN
Remains unfixed in 5.0.38 - Built with VC8 on Win2ks-p4: ##################################### 202 of (1/1): test_bug21635 ##################################### MIN(i) -> MIN(i) ... .\mysql_client_test.c:15521: check failed: 'field->db[0] == 0 && field->org_table[0] == 0 && field->table[0] == 0 && field->org_name[0] == 0' This application has requested the Runtime to terminate it in an unusual way. Please contact the application's support team for more information.