You forgot to include your C code. :) Adam Hooper [EMAIL PROTECTED]
On Thu, 30 May 2002 15:59:31 -0700 Bill Rausch <[EMAIL PROTECTED]> wrote: > I have a program prototyped in PHP that works fine, but when I > convert it to C using libmysqlclient the program fails inside the > mysqlclient library with a segmentation fault on a particular query. > It fails on two different platforms (Linux and Mac OS X). > > The database I'm using is very simple: > mysql> describe documents; > +-------------+------------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +-------------+------------------+------+-----+---------+----------------+ > | document_id | int(10) unsigned | | PRI | NULL | auto_increment | > | document | varchar(255) | | UNI | | | > +-------------+------------------+------+-----+---------+----------------+ > mysql> describe words; > +---------+------------------+------+-----+---------+----------------+ > | Field | Type | Null | Key | Default | Extra | > +---------+------------------+------+-----+---------+----------------+ > | word_id | int(10) unsigned | | PRI | NULL | auto_increment | > | word | varchar(255) | | UNI | | | > +---------+------------------+------+-----+---------+----------------+ > mysql> describe main_index; > +-------------+------------------+------+-----+---------+-------+ > | Field | Type | Null | Key | Default | Extra | > +-------------+------------------+------+-----+---------+-------+ > | document_id | int(10) unsigned | | PRI | 0 | | > | sequence | int(10) unsigned | | PRI | 0 | | > | word_id | int(10) unsigned | | MUL | 0 | | > +-------------+------------------+------+-----+---------+-------+ > > mysql> select distinct document from documents, main_index, words > where words.word="hello" and > documents.document_id=main_index.document_id and > main_index.word_id=words.word_id; > +----------+ > | document | > +----------+ > | market1 | > | market2 | > | market3 | > | market4 | > +----------+ > > If I build and run this same query in PHP it also works correctly but > when I do it using the C library it core dumps. Other simpler > queries do work correctly. > > Using gdb, I get: > > (gdb) r > Starting program: /home/bill/indexer/t.server > > Program received signal SIGSEGV, Segmentation fault. > 0x4002d26b in simple_command () > from /usr/local/mysql/lib/mysql/libmysqlclient.so.10 > (gdb) where > #0 0x4002d26b in simple_command () > from /usr/local/mysql/lib/mysql/libmysqlclient.so.10 > #1 0x4003021f in mysql_real_query () > from /usr/local/mysql/lib/mysql/libmysqlclient.so.10 > #2 0x400301be in mysql_query () > from /usr/local/mysql/lib/mysql/libmysqlclient.so.10 > #3 0x0804e846 in mydb_query ( > query=0xbffff130 "select distinct document from documents, > main_index, words where words.word=\"hello\" and > documents.document_id=main_index.document_id and > main_index.word_id=words.word_id") at query.c:30 > #4 0x0804e566 in search_start (word=0x807da87 "hello") at search.c:18 > #5 0x0804e6fa in do_search (argc=3, argv=0x8051900) at search.c:72 > #6 0x0804a9ca in interact () at server.c:745 > #7 0x0804af84 in main (argc=1, argv=0xbffffacc) at server.c:903 > #8 0x40060177 in __libc_start_main (main=0x804aa14 <main>, argc=1, > > I tried calling mysql_real_query directly but that didn't fix anything. > > Bill > > -- > Bill Rausch, Software Development, UNIX, Mac, Windows > Numerical Applications, Richland, WA 509-943-0861 > > --------------------------------------------------------------------- > Before posting, please check: > http://www.mysql.com/manual.php (the manual) > http://lists.mysql.com/ (the list archive) > > To request this thread, e-mail <[EMAIL PROTECTED]> > To unsubscribe, e-mail <[EMAIL PROTECTED]> > Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php > --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php