SOURCES: php-pdo_mysql-charsetphpini.patch (NEW), php-mysqli-charsetphpini....

glen glen at pld-linux.org
Wed Oct 8 00:45:21 CEST 2008


Author: glen                         Date: Tue Oct  7 22:45:21 2008 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- mysql default charset support from gentoo (distfiles/php-patchset-5.2.6-r8.tar.bz2)

---- Files affected:
SOURCES:
   php-pdo_mysql-charsetphpini.patch (NONE -> 1.1)  (NEW), php-mysqli-charsetphpini.patch (NONE -> 1.1)  (NEW), php-mysql-charsetphpini.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/php-pdo_mysql-charsetphpini.patch
diff -u /dev/null SOURCES/php-pdo_mysql-charsetphpini.patch:1.1
--- /dev/null	Wed Oct  8 00:45:22 2008
+++ SOURCES/php-pdo_mysql-charsetphpini.patch	Wed Oct  8 00:45:15 2008
@@ -0,0 +1,111 @@
+--- ext/pdo_mysql/mysql_driver.c	2006-12-02 17:26:53.000000000 +0100
++++ ext/pdo_mysql/mysql_driver.c	2006-12-02 17:27:12.000000000 +0100
+@@ -436,6 +436,7 @@
+ 	pdo_mysql_db_handle *H;
+ 	int i, ret = 0;
+ 	char *host = NULL, *unix_socket = NULL;
++	char *connect_charset = NULL;
+ 	unsigned int port = 3306;
+ 	char *dbname;
+ 	struct pdo_data_src_parser vars[] = {
+@@ -546,6 +547,13 @@
+ 	if (vars[2].optval && !strcmp("localhost", vars[2].optval)) {
+ 		unix_socket = vars[4].optval;  
+ 	}
++
++	connect_charset = PDOMYSQLG(connect_charset);
++
++	if (connect_charset != NULL) {
++		mysql_options(H->server, MYSQL_SET_CHARSET_NAME, connect_charset);
++	}
++
+ 	if (mysql_real_connect(H->server, host, dbh->username, dbh->password, dbname, port, unix_socket, connect_opts) == NULL) {
+ 		pdo_mysql_error(dbh);
+ 		goto cleanup;
+--- ext/pdo_mysql/pdo_mysql.c	2006-12-02 17:26:53.000000000 +0100
++++ ext/pdo_mysql/pdo_mysql.c	2006-12-02 17:27:12.000000000 +0100
+@@ -30,6 +30,9 @@
+ #include "php_pdo_mysql.h"
+ #include "php_pdo_mysql_int.h"
+ 
++ZEND_DECLARE_MODULE_GLOBALS(pdo_mysql)
++static PHP_GINIT_FUNCTION(pdo_mysql);
++
+ /* {{{ pdo_mysql_functions[] */
+ zend_function_entry pdo_mysql_functions[] = {
+ 	{NULL, NULL, NULL}
+@@ -61,7 +64,11 @@
+ 	NULL,
+ 	PHP_MINFO(pdo_mysql),
+ 	"1.0.2",
+-	STANDARD_MODULE_PROPERTIES
++	PHP_MODULE_GLOBALS(pdo_mysql),
++	PHP_GINIT(pdo_mysql),
++	NULL,
++	NULL,
++	STANDARD_MODULE_PROPERTIES_EX
+ };
+ /* }}} */
+ 
+@@ -69,12 +76,23 @@
+ ZEND_GET_MODULE(pdo_mysql)
+ #endif
+ 
++PHP_INI_BEGIN()
++	STD_PHP_INI_ENTRY("pdo_mysql.connect_charset",	NULL,	PHP_INI_ALL,	OnUpdateString,	connect_charset,	zend_pdo_mysql_globals,	pdo_mysql_globals)
++PHP_INI_END()
++
++static PHP_GINIT_FUNCTION(pdo_mysql)
++{
++	pdo_mysql_globals->connect_charset = NULL;
++}
++
+ /* true global environment */
+ 
+ /* {{{ PHP_MINIT_FUNCTION
+  */
+ PHP_MINIT_FUNCTION(pdo_mysql)
+ {
++	REGISTER_INI_ENTRIES();
++
+ 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_USE_BUFFERED_QUERY", (long)PDO_MYSQL_ATTR_USE_BUFFERED_QUERY);
+ 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_LOCAL_INFILE", (long)PDO_MYSQL_ATTR_LOCAL_INFILE);
+ 	REGISTER_PDO_CLASS_CONST_LONG("MYSQL_ATTR_INIT_COMMAND", (long)PDO_MYSQL_ATTR_INIT_COMMAND);
+@@ -91,6 +109,7 @@
+  */
+ PHP_MSHUTDOWN_FUNCTION(pdo_mysql)
+ {
++	UNREGISTER_INI_ENTRIES();
+ 	php_pdo_unregister_driver(&pdo_mysql_driver);
+ 	return SUCCESS;
+ }
+@@ -103,6 +122,8 @@
+ 	php_info_print_table_start();
+ 	php_info_print_table_header(2, "PDO Driver for MySQL, client library version", mysql_get_client_info());
+ 	php_info_print_table_end();
++
++	DISPLAY_INI_ENTRIES();
+ }
+ /* }}} */
+ 
+--- ext/pdo_mysql/php_pdo_mysql.h	2006-12-02 17:26:53.000000000 +0100
++++ ext/pdo_mysql/php_pdo_mysql.h	2006-12-02 17:28:49.000000000 +0100
+@@ -40,6 +40,18 @@
+ PHP_RSHUTDOWN_FUNCTION(pdo_mysql);
+ PHP_MINFO_FUNCTION(pdo_mysql);
+ 
++ZEND_BEGIN_MODULE_GLOBALS(pdo_mysql)
++	char	*connect_charset;
++ZEND_END_MODULE_GLOBALS(pdo_mysql)
++
++#ifdef ZTS
++# define PDOMYSQLG(v) TSRMG(pdo_mysql_globals_id, zend_pdo_mysql_globals *, v)
++#else
++# define PDOMYSQLG(v) (pdo_mysql_globals.v)
++#endif
++
++ZEND_EXTERN_MODULE_GLOBALS(pdo_mysql)
++
+ #endif	/* PHP_PDO_MYSQL_H */
+ 
+ 

================================================================
Index: SOURCES/php-mysqli-charsetphpini.patch
diff -u /dev/null SOURCES/php-mysqli-charsetphpini.patch:1.1
--- /dev/null	Wed Oct  8 00:45:22 2008
+++ SOURCES/php-mysqli-charsetphpini.patch	Wed Oct  8 00:45:16 2008
@@ -0,0 +1,76 @@
+--- ext/mysqli/mysqli_api.c	2006-12-01 16:30:36.000000000 +0100
++++ ext/mysqli/mysqli_api.c	2006-12-01 16:39:32.000000000 +0100
+@@ -1395,7 +1395,7 @@
+ PHP_FUNCTION(mysqli_real_connect)
+ {
+ 	MY_MYSQL 		*mysql;
+-	char 			*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
++	char 			*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL, *connect_charset=NULL;
+ 	unsigned int 	hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
+ 	unsigned long 	port=0, flags=0;
+ 	zval			*mysql_link;
+@@ -1436,6 +1436,12 @@
+ 		socket = MyG(default_socket);
+ 	}
+ 
++	connect_charset = MyG(connect_charset);
++
++	if (connect_charset != NULL) {
++		mysql_options(mysql->mysql, MYSQL_SET_CHARSET_NAME, connect_charset);
++	}
++
+ 	if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,flags) == NULL) {
+ 		php_mysqli_set_error(mysql_errno(mysql->mysql), (char *) mysql_error(mysql->mysql) TSRMLS_CC);
+ 		php_mysqli_throw_sql_exception( mysql->mysql->net.sqlstate, mysql->mysql->net.last_errno TSRMLS_CC,
+--- ext/mysqli/mysqli.c	2006-12-01 16:30:36.000000000 +0100
++++ ext/mysqli/mysqli.c	2006-12-01 16:38:01.000000000 +0100
+@@ -459,6 +459,7 @@
+ 	STD_PHP_INI_ENTRY("mysqli.default_pw",				NULL,	PHP_INI_ALL,		OnUpdateString,		default_pw,			zend_mysqli_globals,		mysqli_globals)
+ 	STD_PHP_INI_ENTRY("mysqli.default_port",			"3306",	PHP_INI_ALL,		OnUpdateLong,		default_port,		zend_mysqli_globals,		mysqli_globals)
+ 	STD_PHP_INI_ENTRY("mysqli.default_socket",			NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysqli_globals,		mysqli_globals)
++	STD_PHP_INI_ENTRY("mysqli.connect_charset",			NULL,	PHP_INI_ALL,		OnUpdateString,		connect_charset,	zend_mysqli_globals,		mysqli_globals)
+ 	STD_PHP_INI_BOOLEAN("mysqli.reconnect",				"0",	PHP_INI_SYSTEM,		OnUpdateLong,		reconnect,			zend_mysqli_globals,		mysqli_globals)
+ PHP_INI_END()
+ 
+@@ -475,6 +476,7 @@
+ 	mysqli_globals->default_user = NULL;
+ 	mysqli_globals->default_pw = NULL;
+ 	mysqli_globals->default_socket = NULL;
++	mysqli_globals->connect_charset = NULL;
+ 	mysqli_globals->reconnect = 0;
+ 	mysqli_globals->report_mode = 0;
+ 	mysqli_globals->report_ht = 0;
+--- ext/mysqli/mysqli_nonapi.c	2006-12-01 16:30:36.000000000 +0100
++++ ext/mysqli/mysqli_nonapi.c	2006-12-01 16:40:29.000000000 +0100
+@@ -36,7 +36,7 @@
+ 	MY_MYSQL 			*mysql;
+ 	MYSQLI_RESOURCE 	*mysqli_resource;
+ 	zval  				*object = getThis();
+-	char 				*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL;
++	char 				*hostname = NULL, *username=NULL, *passwd=NULL, *dbname=NULL, *socket=NULL, *connect_charset=NULL;
+ 	unsigned int 		hostname_len = 0, username_len = 0, passwd_len = 0, dbname_len = 0, socket_len = 0;
+ 	long				port=0;
+ 
+@@ -88,6 +88,12 @@
+ 		socket = MyG(default_socket);
+ 	}
+ 
++	connect_charset = MyG(connect_charset);
++
++	if (connect_charset != NULL) {
++		mysql_options(mysql->mysql, MYSQL_SET_CHARSET_NAME, connect_charset);
++	}
++
+ 	if (mysql_real_connect(mysql->mysql,hostname,username,passwd,dbname,port,socket,CLIENT_MULTI_RESULTS) == NULL) {
+ 		/* Save error messages */
+ 
+--- ext/mysqli/php_mysqli.h	2006-12-01 16:30:36.000000000 +0100
++++ ext/mysqli/php_mysqli.h	2006-12-01 16:36:23.000000000 +0100
+@@ -433,6 +433,7 @@
+ 	char			*default_user;
+ 	char			*default_socket;
+ 	char            *default_pw;
++	char			*connect_charset;
+ 	int				reconnect;
+ 	int				strict;
+ 	long			error_no;

================================================================
Index: SOURCES/php-mysql-charsetphpini.patch
diff -u /dev/null SOURCES/php-mysql-charsetphpini.patch:1.1
--- /dev/null	Wed Oct  8 00:45:23 2008
+++ SOURCES/php-mysql-charsetphpini.patch	Wed Oct  8 00:45:16 2008
@@ -0,0 +1,76 @@
+diff -aur php-5.2.5_p20080206.orig/ext/mysql/php_mysql.c php-5.2.5_p20080206/ext/mysql/php_mysql.c
+--- php-5.2.5_p20080206.orig/ext/mysql/php_mysql.c	2008-02-06 14:22:57.652600900 +0100
++++ php-5.2.5_p20080206/ext/mysql/php_mysql.c	2008-02-06 14:24:40.216655403 +0100
+@@ -360,6 +360,7 @@
+ 	PHP_INI_ENTRY("mysql.default_port",				NULL,	PHP_INI_ALL,		OnMySQLPort)
+ 	STD_PHP_INI_ENTRY("mysql.default_socket",		NULL,	PHP_INI_ALL,		OnUpdateStringUnempty,	default_socket,	zend_mysql_globals,		mysql_globals)
+ 	STD_PHP_INI_ENTRY("mysql.connect_timeout",		"60",	PHP_INI_ALL,		OnUpdateLong,		connect_timeout, 	zend_mysql_globals,		mysql_globals)
++	STD_PHP_INI_ENTRY("mysql.connect_charset",		NULL,	PHP_INI_ALL,		OnUpdateString,		connect_charset,	zend_mysql_globals,		mysql_globals)
+ 	STD_PHP_INI_BOOLEAN("mysql.trace_mode",			"0",	PHP_INI_ALL,		OnUpdateLong,		trace_mode, 		zend_mysql_globals,		mysql_globals)
+ PHP_INI_END()
+ /* }}} */
+@@ -376,6 +377,7 @@
+ 	mysql_globals->connect_errno = 0;
+ 	mysql_globals->connect_error = NULL;
+ 	mysql_globals->connect_timeout = 0;
++	mysql_globals->connect_charset = NULL;
+ 	mysql_globals->trace_mode = 0;
+ 	mysql_globals->result_allocated = 0;
+ }
+@@ -515,6 +517,7 @@
+ {
+ 	char *user=NULL, *passwd=NULL, *host_and_port=NULL, *socket=NULL, *tmp=NULL, *host=NULL;
+ 	int  user_len, passwd_len, host_len;
++	char *connect_charset=NULL;
+ 	char *hashed_details=NULL;
+ 	int hashed_details_length, port = MYSQL_PORT;
+ 	int client_flags = 0;
+@@ -527,6 +530,7 @@
+ 
+ 
+ 	connect_timeout = MySG(connect_timeout);
++	connect_charset = MySG(connect_charset);
+ 
+ 	socket = MySG(default_socket);
+ 
+@@ -640,6 +644,9 @@
+ 				mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+ 			}
+ 
++			if (connect_charset != NULL)
++				mysql_options(&mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
++
+ 			if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
+ #else
+ 			if (mysql_connect(&mysql->conn, host, user, passwd)==NULL) {
+@@ -684,6 +691,9 @@
+ 				signal(SIGPIPE, handler);
+ #endif /* end mysql_ping */
+ #if MYSQL_VERSION_ID > 32199 /* this lets us set the port number */
++				if (connect_charset != NULL)
++					mysql_options(le->ptr, MYSQL_SET_CHARSET_NAME, connect_charset);
++
+ 				if (mysql_real_connect(le->ptr, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
+ #else
+ 				if (mysql_connect(le->ptr, host, user, passwd)==NULL) {
+@@ -747,6 +757,9 @@
+ 			mysql_options(&mysql->conn, MYSQL_OPT_CONNECT_TIMEOUT, (const char *)&connect_timeout);
+ 		}
+ 
++		if (connect_charset != NULL)
++			mysql_options(&mysql->conn, MYSQL_SET_CHARSET_NAME, connect_charset);
++
+ 		if (mysql_real_connect(&mysql->conn, host, user, passwd, NULL, port, socket, client_flags)==NULL) {
+ #else
+ 		if (mysql_connect(&mysql->conn, host, user, passwd)==NULL) {
+diff -aur php-5.2.5_p20080206.orig/ext/mysql/php_mysql_structs.h php-5.2.5_p20080206/ext/mysql/php_mysql_structs.h
+--- php-5.2.5_p20080206.orig/ext/mysql/php_mysql_structs.h	2008-02-06 14:22:57.510605687 +0100
++++ php-5.2.5_p20080206/ext/mysql/php_mysql_structs.h	2008-02-06 14:23:27.764590355 +0100
+@@ -103,6 +103,7 @@
+ 	long default_port;
+ 	char *default_host, *default_user, *default_password;
+ 	char *default_socket;
++	char *connect_charset;
+ 	char *connect_error;
+ 	long connect_errno;
+ 	long connect_timeout;
================================================================


More information about the pld-cvs-commit mailing list