From: Ilia Alshanetsky Date: Wed, 19 May 2004 15:12:05 +0000 (+0000) Subject: Simplify config via the use of mysql_config. X-Git-Tag: RELEASE_0_1~107 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b5f8bd8e9e7da941dcb9e8c7a7ae9a9bbea13487;p=php Simplify config via the use of mysql_config. Fixed errno naming conflict. --- diff --git a/ext/pdo_mysql/config.m4 b/ext/pdo_mysql/config.m4 index 1d697d0927..205a9091b8 100755 --- a/ext/pdo_mysql/config.m4 +++ b/ext/pdo_mysql/config.m4 @@ -18,25 +18,18 @@ PHP_ARG_WITH(pdo_mysql, for MySQL support, if test "$PHP_PDO_MYSQL" != "no"; then AC_DEFINE(HAVE_MYSQL, 1, [Whether you have MySQL]) - AC_MSG_CHECKING([for MySQL UNIX socket location]) - if test "$PHP_MYSQL_SOCK" != "no" && test "$PHP_MYSQL_SOCK" != "yes"; then - MYSQL_SOCK=$PHP_MYSQL_SOCK - AC_DEFINE_UNQUOTED(MYSQL_UNIX_ADDR, "$MYSQL_SOCK", [ ]) - AC_MSG_RESULT([$MYSQL_SOCK]) - elif test "$PHP_MYSQL" = "yes" || test "$PHP_MYSQL_SOCK" = "yes"; then - PHP_MYSQL_SOCKET_SEARCH - else - AC_MSG_RESULT([no]) - fi - for i in $PHP_PDO_MYSQL /usr/local /usr; do - if test -r $i/include/mysql/mysql.h; then + if test -x $i/bin/mysql_config; then MYSQL_DIR=$i + PDO_MYSQL_CONFIG=$MYSQL_DIR/bin/mysql_config MYSQL_INC_DIR=$i/include/mysql + MYSQL_LIBS=$i/lib break - elif test -r $i/include/mysql.h; then + elif test -x $i/bin/mysql_config; then MYSQL_DIR=$i + PDO_MYSQL_CONFIG=$MYSQL_DIR/bin/mysql_config MYSQL_INC_DIR=$i/include + MYSQL_LIBS=$i/lib break fi done @@ -46,50 +39,24 @@ if test "$PHP_PDO_MYSQL" != "no"; then Note that the MySQL client library is not bundled anymore.]) fi - for i in lib lib/mysql; do - MYSQL_LIB_CHK($i) - done - - if test -z "$MYSQL_LIB_DIR"; then - AC_MSG_ERROR([Cannot find libmysqlclient under $MYSQL_DIR. -Note that the MySQL client library is not bundled anymore.]) - fi + PDO_MYSQL_LIBS=`$PDO_MYSQL_CONFIG --libs` + PDO_MYSQL_SOCKET=`$PDO_MYSQL_CONFIG --socket` - PHP_CHECK_LIBRARY(mysqlclient, mysql_close, [ ], - [ - if test "$PHP_ZLIB_DIR" != "no"; then - PHP_ADD_LIBRARY_WITH_PATH(z, $PHP_ZLIB_DIR, PDO_MYSQL_SHARED_LIBADD) - PHP_CHECK_LIBRARY(mysqlclient, mysql_error, [], [ - AC_MSG_ERROR([mysql configure failed. Please check config.log for more information.]) - ], [ - -L$PHP_ZLIB_DIR/lib -L$MYSQL_LIB_DIR - ]) - MYSQL_LIBS="-L$PHP_ZLIB_DIR/lib -lz" - else - PHP_ADD_LIBRARY(z,, PDO_MYSQL_SHARED_LIBADD) - PHP_CHECK_LIBRARY(mysqlclient, mysql_errno, [], [ - AC_MSG_ERROR([Try adding --with-zlib-dir=. Please check config.log for more information.]) - ], [ - -L$MYSQL_LIB_DIR - ]) - MYSQL_LIBS="-lz" - fi - ], [ - -L$MYSQL_LIB_DIR - ]) + AC_DEFINE_UNQUOTED(PDO_MYSQL_UNIX_ADDR, "$PDO_MYSQL_SOCKET", [ ]) - PHP_ADD_LIBRARY_WITH_PATH(mysqlclient, $MYSQL_LIB_DIR, PDO_MYSQL_SHARED_LIBADD) + PHP_ADD_LIBRARY_WITH_PATH(mysqlclient, $MYSQL_LIBS, PDO_MYSQL_SHARED_LIBADD) PHP_ADD_INCLUDE($MYSQL_INC_DIR) - + if test -f $prefix/include/php/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$prefix/include/php/ext - else + elif test -f $abs_srcdir/include/php/ext/pdo/php_pdo_driver.h; then pdo_inc_path=$abs_srcdir/ext + else + AC_MSG_ERROR([Cannot find php_pdo_driver.h.]) fi PHP_NEW_EXTENSION(pdo_mysql, pdo_mysql.c mysql_driver.c mysql_statement.c, $ext_shared,,-I$pdo_inc_path) PDO_MYSQL_MODULE_TYPE=external - PDO_MYSQL_LIBS="-L$MYSQL_LIB_DIR -lmysqlclient $MYSQL_LIBS" PDO_MYSQL_INCLUDE=-I$MYSQL_INC_DIR PHP_SUBST(PDO_MYSQL_SHARED_LIBADD) diff --git a/ext/pdo_mysql/mysql_driver.c b/ext/pdo_mysql/mysql_driver.c index 948ee5e7d7..0f545021ed 100755 --- a/ext/pdo_mysql/mysql_driver.c +++ b/ext/pdo_mysql/mysql_driver.c @@ -30,11 +30,11 @@ #include "php_pdo_mysql.h" #include "php_pdo_mysql_int.h" -int _pdo_mysql_error(char *what, int errno, const char *file, int line TSRMLS_DC) /* {{{ */ +int _pdo_mysql_error(char *what, int mysql_errno, const char *file, int line TSRMLS_DC) /* {{{ */ { switch (errno) { default: - php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s:%d) %s: %d", file, line, what, errno); + php_error_docref(NULL TSRMLS_CC, E_WARNING, "(%s:%d) %s: %d", file, line, what, mysql_errno); break; } return errno; @@ -83,8 +83,7 @@ static int mysql_handle_quoter(pdo_dbh_t *dbh, const char *unquoted, int unquote pdo_mysql_db_handle *H = (pdo_mysql_db_handle *)dbh->driver_data; *quoted = emalloc(2*unquotedlen + 3); (*quoted)[0] = '"'; - *quotedlen = mysql_real_escape_string(H->server, *quoted + 1, - unquoted, unquotedlen); + *quotedlen = mysql_real_escape_string(H->server, *quoted + 1, unquoted, unquotedlen); (*quoted)[*quotedlen + 1] = '"'; (*quoted)[*quotedlen + 2] = '\0'; *quotedlen += 2; @@ -111,7 +110,7 @@ static int pdo_mysql_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ { "dbname", "", 0 }, { "host", "localhost", 0 }, { "port", "3306", 0 }, - { "unix_socket", "/var/tmp/mysql.sock", 0 }, + { "unix_socket", PDO_MYSQL_UNIX_ADDR, 0 }, }; php_pdo_parse_data_source(dbh->data_source, dbh->data_source_len, vars, 4); diff --git a/ext/pdo_mysql/php_pdo_mysql_int.h b/ext/pdo_mysql/php_pdo_mysql_int.h index f66eb3cdf0..3a3e4bfa62 100755 --- a/ext/pdo_mysql/php_pdo_mysql_int.h +++ b/ext/pdo_mysql/php_pdo_mysql_int.h @@ -53,7 +53,7 @@ typedef struct { extern pdo_driver_t pdo_mysql_driver; -extern int _pdo_mysql_error(char *what, int errno, const char *file, int line TSRMLS_DC); +extern int _pdo_mysql_error(char *what, int mysql_errno, const char *file, int line TSRMLS_DC); #define pdo_mysql_error(w,s) _pdo_mysql_error(w, s, __FILE__, __LINE__ TSRMLS_CC) extern int mysql_handle_error(pdo_dbh_t *dbh, pdo_mysql_db_handle *H, int errcode);