Bug #10645 | mysql_fetch_fields not returning array | ||
---|---|---|---|
Submitted: | 15 May 2005 19:04 | Modified: | 18 May 2005 19:33 |
Reporter: | Jonathan martens | Email Updates: | |
Status: | Not a Bug | Impact on me: | |
Category: | MySQL Server | Severity: | S1 (Critical) |
Version: | 4.1.11.nt | OS: | Windows (Windows XP SP2) |
Assigned to: | CPU Architecture: | Any |
[15 May 2005 19:04]
Jonathan martens
[15 May 2005 19:15]
Jonathan martens
Changed the category to libmysql in stead of libmysqld, I selected the wrong item by accident.
[16 May 2005 1:31]
MySQL Verification Team
I was unable to repeat the output showed below is from the the application at the bottom: C:\temp>bug10645 Connected with the Server: 4.1.12-nt Field 0 is cl1 Field 1 is cl2 Field 2 is cl3 Field 3 is cl4 Field 4 is cl5 Field 5 is cl6 #ifdef WIN32 typedef unsigned __int64 ulonglong; typedef __int64 longlong; typedef unsigned long ulong; #endif #include <stdio.h> #include <string.h> #include <my_global.h> #include <m_ctype.h> #include <m_string.h> #include <mysql.h> #define query1 "Create Table A (cl1 int,cl2 int,cl3 int,cl4 int,cl5 int,cl6 int)" #define query2 "Insert into A values (1,2,3,4,5,6)" #define query3 "Select * from A" void main() { MYSQL *MySQL; MYSQL_RES * result ; unsigned int num_fields; unsigned int i; MYSQL_FIELD *fields; if ( (MySQL = mysql_init((MYSQL*) 0)) && mysql_real_connect( MySQL,"localhost","root", "", "test", 0, NULL, 0 )) { printf("Connected with the Server: %s\n", mysql_get_server_info(MySQL)); } else { printf("Failed to connect with the server\n"); mysql_close( MySQL ); return; } if (mysql_real_query(MySQL,query1,sizeof(query1)) < 0) { printf("Create Table A failed (%s)\n",mysql_error(MySQL)); mysql_close( MySQL ); return; } if (mysql_real_query(MySQL,query2,sizeof(query2)) < 0) { printf("Insert query failed (%s)\n",mysql_error(MySQL)); mysql_close( MySQL ); return; } if (mysql_real_query(MySQL,query3,sizeof(query3)) < 0) { printf("Select query failed (%s)\n",mysql_error(MySQL)); mysql_close( MySQL ); return; } result = mysql_store_result( MySQL ); num_fields = mysql_num_fields(result); fields = mysql_fetch_fields(result); for (i = 0; i < num_fields; i++) { printf("Field %u is %s\n", i, fields[i].name); } mysql_close( MySQL ); }
[16 May 2005 10:30]
Jonathan martens
Unfortunately with the example provided I still get the same error. Access violation in the printf routine when trying to print the field name of the second column (i=1). I also noticed that when I connect with a user with a password I get the following error: Failed to connect with the server (Client does not support authentication protocol requested by the server; consider upgrading MySQL client) If I connect with a user without a password I am able to login to the mysql server and run the queries. However the sample code still crashes on displaying the second field name. I was thinking of some version incomaptibility as a result of the files I specified not being linked but some file from a different location with an other version. Therefore I explicitly linked to the libmysql.lib file in the lib\opt directory of the server. In my opinion I don't think I should have this error, as I am linking to the file that came with the server installation. The filestamp of this file is 4-4-2005 16:57. Unfortunately no version information is available under the properties tab in the explorer. I also removed all the include directories in the tools > options > directory tab to see if some other version of the header file was included from some other location perhaps but then it fails to compile, on the my_globals.h file. It says it cannot find it. As soon as I add the include path again it succesfully compiles. Again I use Microsoft Visual C++ 6 SP 6 on Windows XP SP2 and Mysql 4.1.11-nt.
[16 May 2005 18:41]
MySQL Verification Team
Please verify if you have a libmysql.dll in the Windows environment path (Windows..system32). I use the static library mysqlclient.lib. So you are linking with 4.1.1 libmysql.lib and the application loading another older one.
[18 May 2005 19:33]
MySQL Verification Team
Thank you for the feedback.
[19 Dec 2006 11:16]
Yipeng Huang
I am facing the exact same problem with MYSQL 5.0, I believe I may have accidently changed the version of libmysql.dll/lib. Where can I download a compatible version?