Jump to content

Archived

This topic is now archived and is closed to further replies.

icyfire624

Help!! Error when php->so->myodbc->mysql.

Recommended Posts

I used PHP->"C++ shared object(*.so)"->unixODBC->myodbc->mysql architecture.
I executed "php test.php" at command line. Then I got "segment fault" on tty.
I apply ODBC trace log. I found SQLConnect succeeded but SQLExecDirect was failed at the first "SELECT" statement.
I traced into unixODBC and found no return from myodbc's SQLEXECDIRECT. It seems dead in myodbc.
I had not traced into myodbc since no source code of myodbc. I installed myodbc with binary code.

Furthermore, I used "C binary: main()"->"C++ shared object(*.so)"->unixODBC->myodbc->mysql architecture to test.
Everything is OK. SQLExecDirect succeeded at every "SELECT" statement.
The "SELECT" statement is the same as php execution mode. I saw they are coincident in ODBC trace log.

The environment is:
Login linux with "root".
Connect ODBC with "DSN=testdb;UID=root;PWD=;". There is no password for "root" of mysql.

Some versions:
myodbc-connector 3.51.12
unixODBC 2.2.11
mysql Ver 11.18 Distrib 3.23.54, for redhat-linux-gnu (i386)

PHP 4.4.2 (cli) (built: Mar 19 2006 15:50:38)
Copyright © 1997-2006 The PHP Group
Zend Engine v1.3.0, Copyright © 1998-2004 Zend Technologies

gcc (GCC) 3.2.2 20030222 (Red Hat Linux 3.2.2-5)
Copyright © 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU Make version 3.79.1, by Richard Stallman and Roland McGrath.
Built for i386-redhat-linux-gnu
Copyright © 1988, 89, 90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 2000
Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

Report bugs to <bug-make@gnu.org>.

Share this post


Link to post
Share on other sites
I traced into myodbc and found it was caused by charset setting.

When I use exec-file built from C source code to test, the charset is "latin1".
And when I use "php test.php" to test, the charset struct parameter is null pointer. SQLDriverConnect passed but SQLExecDirect failed.
When SQLDriverConnect, "mysql_real_connect" said:
| | | >get_charsets_dir
| | | | info: charsets dir='NONEXISTENT/charsets/'

I configed the php.ini and add "default-charset=latin1". But the failure is the same.

Who can tell me how to set the charset for php->odbc->mysql?

Share this post


Link to post
Share on other sites
I have not resolved the problem yet.

After tracing, I found two different test way caused different call of "mysql_init" and other mysql client api:

When I use "a.out" built from C source code (a.out->my.so->iodbc->myodbc->mysql) to test, it used "mysql-init" within the libmysqlclient.so.

When I use "php test.php" (php->my.so->iodbc->myodbc->mysql) to test, it used "mysql_init" within "php". "php" client contained a "mysql_init" from its "ext/mysql".

So strange. And I have not found how to deal with it.

Please help me.

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.