| Bug #12172 | segmentation fault in c code using mysql API | ||
|---|---|---|---|
| Submitted: | 26 Jul 2005 9:18 | Modified: | 2 Aug 2005 11:10 |
| Reporter: | Emad Damra | Email Updates: | |
| Status: | Can't repeat | Impact on me: | |
| Category: | MySQL Server | Severity: | S2 (Serious) |
| Version: | mysql-5.0.3 beta statndard verion | OS: | Linux (Linux Redhat 9) |
| Assigned to: | CPU Architecture: | Any | |
[26 Jul 2005 9:24]
Jan Lindström
Could you please provide output from show create table user_info and contents of that table if there are not very many rows (e.g. doing select * from user_info in mysql client). Regards, JanL
[26 Jul 2005 9:26]
Emad Damra
hi
here is the output of your request:
+-----------+-----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
------------------------------+
| Table | Create Table
|
+-----------+-----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
------------------------------+
| user_info | CREATE TABLE `user_info` (
`username` varchar(20) NOT NULL default '',
`password` varchar(20) NOT NULL default '',
`PrivilegeId` int(2) NOT NULL default '0',
`GroupName` varchar(30) default NULL,
UNIQUE KEY `username` (`username`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 |
+-----------+-----------------------------------------------------------------------------------------------------------------------
------------------------------------------------------------------------------------------------------------------------------------
------------------------------+
1 row in set (0.00 sec)
Thanks alot..:)
[2 Aug 2005 11:10]
Andrey Hristov
Can't reproduce with 4.1.12 and 5.0.11-beta. As a side note C API does not check for consistency of the pointers passed to the library functions and every result from the API has be inspected in "user land".

Description: i have my code in c using the MySql API library, but it give me a segmentation fault and it cause my other functions to exit on failed, so i use the following code, just to check if it in the mysql API functions or not , and give me in the end the same result "segmentation fault" here is simply the code: <test.c> #include <stdio.h> #include "mysql.h" MYSQL mysql; MYSQL_RES *res; MYSQL_ROW row; int main() { char q[512]; bzero(q,sizeof(q)); sprintf(q,"%s","select * from user_info;"); mysql_init(&mysql); mysql_real_connect(&mysql,"localhost",NULL,NULL,NULL,0,NULL,0); mysql_select_db(&mysql,"MyDB"); mysql_query(&mysql,q); res=mysql_store_result(&mysql); while ((row = mysql_fetch_row(res))) { printf("row=%s\n",row[0]); } mysql_free_result(res); mysql_close(&mysql); return 0; } and i compile the code by the following links: gcc -o mytest mytest.c -I/usr/include/mysql -L/usr/lib/mysql -I. -lmysqlclient -lz -lm the output was like:{ row=admin row=omdeh row=emad row=hmsom Segmentation fault } it's amzing that the output return successfully from the database but i still have Segmentation fault, which cause another functions to failled!!!!!!!!!!!!!! How to repeat: i don't understatnd this field, relly, how to repeat the bug, but my mail is e_mad81@hotmail.com