From: Yasuo Ohgaki Date: Thu, 25 Apr 2002 01:42:23 +0000 (+0000) Subject: pg_client_encoding/pg_set_client_encoding should be compiled always. X-Git-Tag: php-4.3.0dev-ZendEngine2-Preview1~440 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c65a20df4a1cb391feab90dbd05586ffd246edfc;p=php pg_client_encoding/pg_set_client_encoding should be compiled always. Recent libpq has PQclientEncoding/PQsetClientEncoding regarless of multibyte support enabled or not. Reported by c@cornelia-boenigk.de # This should be merged, but need a little more testing. --- diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c index 94b404cca1..1ba7e2d727 100644 --- a/ext/pgsql/pgsql.c +++ b/ext/pgsql/pgsql.c @@ -137,10 +137,8 @@ function_entry pgsql_functions[] = { PHP_FE(pg_escape_string,NULL) PHP_FE(pg_escape_bytea, NULL) #endif -#if HAVE_PQCLIENTENCODING PHP_FE(pg_client_encoding, NULL) PHP_FE(pg_set_client_encoding, NULL) -#endif /* misc function */ PHP_FE(pg_metadata, NULL) PHP_FE(pg_convert, NULL) @@ -172,10 +170,8 @@ function_entry pgsql_functions[] = { PHP_FALIAS(pg_lowrite, pg_lo_write, NULL) PHP_FALIAS(pg_loimport, pg_lo_import, NULL) PHP_FALIAS(pg_loexport, pg_lo_export, NULL) -#if HAVE_PQCLIENTENCODING PHP_FALIAS(pg_clientencoding, pg_client_encoding, NULL) PHP_FALIAS(pg_setclientencoding, pg_set_client_encoding, NULL) -#endif {NULL, NULL, NULL} }; /* }}} */ @@ -2133,7 +2129,6 @@ PHP_FUNCTION(pg_lo_tell) } /* }}} */ -#ifdef HAVE_PQCLIENTENCODING /* {{{ proto int pg_set_client_encoding([resource connection,] string encoding) Set client encoding */ PHP_FUNCTION(pg_set_client_encoding) @@ -2159,13 +2154,18 @@ PHP_FUNCTION(pg_set_client_encoding) WRONG_PARAM_COUNT; break; } - + +#ifdef HAVE_PQCLIENTENCODING ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); convert_to_string_ex(encoding); Z_LVAL_P(return_value) = PQsetClientEncoding(pgsql, Z_STRVAL_PP(encoding)); Z_TYPE_P(return_value) = IS_LONG; - +#else + php_error(E_NOTICE, "%s() PHP is compiled with libpq without multibyte PQsetClientEncoding" + get_active_function_name(TSRMLS_C)); + RETURN_LONG(-1); +#endif } /* }}} */ @@ -2192,6 +2192,7 @@ PHP_FUNCTION(pg_client_encoding) break; } +#ifdef HAVE_PQCLIENTENCODING ZEND_FETCH_RESOURCE2(pgsql, PGconn *, pgsql_link, id, "PostgreSQL link", le_link, le_plink); /* Just do the same as found in PostgreSQL sources... */ @@ -2205,9 +2206,13 @@ PHP_FUNCTION(pg_client_encoding) Z_STRLEN_P(return_value) = strlen(Z_STRVAL_P(return_value)); Z_STRVAL_P(return_value) = (char *) estrdup(Z_STRVAL_P(return_value)); Z_TYPE_P(return_value) = IS_STRING; +#else + php_error(E_NOTICE, "%s() PHP is compiled with libpq without PQclientEncoding" + get_active_function_name(TSRMLS_C)); + RETURN_STRING("SQL_ASCII",1); +#endif } /* }}} */ -#endif #define COPYBUFSIZ 8192 diff --git a/ext/pgsql/php_pgsql.h b/ext/pgsql/php_pgsql.h index a1d547e6e8..d58fe09ad2 100644 --- a/ext/pgsql/php_pgsql.h +++ b/ext/pgsql/php_pgsql.h @@ -114,10 +114,8 @@ PHP_FUNCTION(pg_trace); PHP_FUNCTION(pg_untrace); /* utility functions */ -#if HAVE_PQCLIENTENCODING PHP_FUNCTION(pg_client_encoding); PHP_FUNCTION(pg_set_client_encoding); -#endif #if HAVE_PQESCAPE PHP_FUNCTION(pg_escape_string); PHP_FUNCTION(pg_escape_bytea);