List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:December 23 1999 2:23pm
Subject:Re: System dependent weirdness.
View as plain text  
At 5:41 PM -0400 1999-12-23, Super-User wrote:
>Hi guys!
>The peice of code in attachement works fine under Solaris and core dumps
>under Linux.
>GDB shows that it crashes on mysql_num_fields(res) function.


You don't perform any error checking at all, so you don't even know
whether or not the connection attempt succeeded, whether the query
suceeded, etc.  For example, you don't know that res is non-NULL.
You should put some error checking code into your program to find
out which MySQL call is really failing, and why.  Use mysql_error()
to find out.

>
>System info:
>Sparcstation 5
>Solaris 2.6
>MySQL 3.22.6 (binary from TCX)
>GCC 2.8.1
>
>Result: Works fine
>l
>System info:
>Sparcstation 5
>Solaris 2.6
>MySQL 3.23.7 (binary from TCX)
>GCC 2.8.1
>
>Result: works fine
>
>System:
>P133
>Linux REDHAT 6.0, 6.1
>MySQL 3.23.5 (binary from TCX)
>EGCS 2.91
>
>Result: Core Dump
>
>The source is just draft test, so there's no checks on exception.
>Crash appears on every kind of tables(i.e. number and type of fields
>doesn't matter).
>
>Thanks in advance.
>			Ruben Muradyan (AKA Pascal)
>
>Content-Type: TEXT/PLAIN; charset=US-ASCII; name="prog.c"
>Content-ID: <Pine.GSO.3.96.991223174139.355B@stripped>
>Content-Description:
>
>/*mysql executable */
>
>#include <stdlib.h>
>#include <stdarg.h>
>#include <mysql/mysql.h>
>
>const char*	host = "127.0.0.1";
>const char*	user = "root";
>const char*	pass = "rumata=";
>const char*	db = "paper";
>const char*	query = "select * from NEWS";
>unsigned int num_fields;
>unsigned int i;
>
>MYSQL	s, *p;
>MYSQL_RES *res;
>MYSQL_ROW row;
>
>
>int main ()
>{
>mysql_init (&s);
>p = mysql_real_connect(&s, host, user, pass, db, 0, NULL, CLIENT_COMPRESS);
>mysql_ping (&s);
>
>/***********************************/
>mysql_query (&s, query);
>res = mysql_store_result (&s);
>               
>num_fields = mysql_num_fields(res);
>while ((row = mysql_fetch_row(res))) 
>{             
>    unsigned long *lengths;
>    lengths = mysql_fetch_lengths(res);     
>    for(i = 0; i < num_fields; i++)
>    {          
>        printf("%.*s ", (int) lengths[i], row[i] ? row[i] : "NULL");
>    }          
>    printf("\n");
>}             
>
>mysql_free_result (res);
>
>}
>---------------------------------------------------------------------
>Please check "http://www.mysql.com/Manual_chapter/manual_toc.html" before
>posting. To request this thread, e-mail mysql-thread22017@stripped
>
>To unsubscribe, send a message to the address shown in the
>List-Unsubscribe header of this message. If you cannot see it,
>e-mail mysql-unsubscribe@stripped instead.


-- 
Paul DuBois, paul@stripped
Thread
System dependent weirdness.Super-User23 Dec
  • Re: System dependent weirdness.Paul DuBois23 Dec
  • Re: System dependent weirdness.sinisa23 Dec
  • Re: System dependent weirdness.Sasha Pachev23 Dec