Re: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h

From: Date: Thu, 25 Apr 2002 06:45:06 +0000
Subject: Re: cvs: php4 /ext/pgsql pgsql.c php_pgsql.h
References: 1 2 3  Groups: php.cvs 
Request: Send a blank email to php-cvs+get-11419@lists.php.net to get a copy of this message
In such cases the manual has to be changed, not the code. - Markus On Thu, Apr 25, 2002 at 03:28:41PM +0900, Yasuo Ohgaki wrote : > Markus Fischer wrote: > > Hi, > > > > I think it reached a common consesus that functions, which > > are not supported in a build, should NOT be in the function > > table. We're having a similar mess with GD and other > > extension. The proper way is to use function_exists() to > > check whether it's support or not. What makes those client > > encoding functions so special? Even the documentation clearly > > states that this function is available since 4.0.3 and > > requires PostgresSQL 7.0 or higher. > > This is the problem. > > PQclientEncoding/PQsetClientEncoding introduced from 7.0, > but I've got report that PHP will complain encoding functions are > not defined unless --enable-multibyte is used to build PostgreSQL. > > Therefore, I have to change manual or code. > > Since PQclientEncoding/PQsetClientEncording returns static > values w/o multibyte support, I've made pg_client_encoding/ > pg_set_client_encoding always available for better script > portability. > > With this change, documents became correct and we have > better portability. I thought the issue previously discussed > is whether we should raise error for not supported functions > or not. > > Any comments? > I don't mind at all if I'm better to change the manual instead > of code. > > -- > Yasuo Ohgaki > > > > > - Markus > > > >On Thu, Apr 25, 2002 at 01:42:23AM -0000, Yasuo Ohgaki wrote : > > > >>yohgaki Wed Apr 24 21:42:23 2002 EDT > >> > >> Modified files: > >> /php4/ext/pgsql pgsql.c php_pgsql.h > >> Log: > >> 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. > >> > >> > >>Index: php4/ext/pgsql/pgsql.c > >>diff -u php4/ext/pgsql/pgsql.c:1.196 php4/ext/pgsql/pgsql.c:1.197 > >>--- php4/ext/pgsql/pgsql.c:1.196 Wed Apr 24 19:03:48 2002 > >>+++ php4/ext/pgsql/pgsql.c Wed Apr 24 21:42:21 2002 > >>@@ -19,7 +19,7 @@ > >> +----------------------------------------------------------------------+ > >> */ > >> > >>-/* $Id: pgsql.c,v 1.196 2002/04/24 23:03:48 yohgaki Exp $ */ > >>+/* $Id: pgsql.c,v 1.197 2002/04/25 01:42:21 yohgaki Exp $ */ > >> > >>#include <stdlib.h> > >> > >>@@ -137,10 +137,8 @@ > >> 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 @@ > >> 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 @@ > >>} > >>/* }}} */ > >> > >>-#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 @@ > >> 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 @@ > >> 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 @@ > >> 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 > >>Index: php4/ext/pgsql/php_pgsql.h > >>diff -u php4/ext/pgsql/php_pgsql.h:1.44 php4/ext/pgsql/php_pgsql.h:1.45 > >>--- php4/ext/pgsql/php_pgsql.h:1.44 Mon Apr 22 23:42:26 2002 > >>+++ php4/ext/pgsql/php_pgsql.h Wed Apr 24 21:42:23 2002 > >>@@ -17,7 +17,7 @@ > >> +----------------------------------------------------------------------+ > >> */ > >> > >>-/* $Id: php_pgsql.h,v 1.44 2002/04/23 03:42:26 yohgaki Exp $ */ > >>+/* $Id: php_pgsql.h,v 1.45 2002/04/25 01:42:23 yohgaki Exp $ */ > >> > >>#ifndef PHP_PGSQL_H > >>#define PHP_PGSQL_H > >>@@ -114,10 +114,8 @@ > >>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); > >> > >> > >> > >>-- > >>PHP CVS Mailing List (http://www.php.net/) > >>To unsubscribe, visit: http://www.php.net/unsub.php > > > > > > -- Please always Cc to me when replying to me on the lists. GnuPG Key: http://guru.josefine.at/~mfischer/C2272BD0.asc "Mind if I MFH ?" "What QA did you do on it?" "the usual?" "ah... none :)"

« previous php.cvs (#11419) next »