php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #68050
Patch multibytePatch revision 2014-09-26 11:45 UTC by rahulpriyadarshi@php.net
Patch ibm_statement_MultiByteCharsPatch revision 2014-09-19 09:26 UTC by thomas dot baumgartl at stahlgruber dot de

Patch multibytePatch for PDO_IBM Bug #68050

Patch version 2014-09-26 11:45 UTC

Return to Bug #68050 | Download this patch
Patch Revisions:

Developer: rahulpriyadarshi@php.net

Index: ibm_driver.c
===================================================================
--- ibm_driver.c	(revision 334368)
+++ ibm_driver.c	(working copy)
@@ -814,6 +814,8 @@
 	int dsn_length = 0;
 	char *new_dsn = NULL;
 	SQLSMALLINT d_length = 0, u_length = 0, p_length = 0;
+	struct sqlca    sqlca;
+	struct sqlca    *pSQLCA = &sqlca;
 #ifdef PASE /* i5/OS incompatible v6 change */
 	char buffer11[11];
 	long attr = SQL_TRUE;
@@ -990,8 +992,11 @@
 		else PDO_IBM_G(is_i5os_classic) = 0;
 #endif /* PASE */
 	}
-
-
+	
+	rc = SQLGetSQLCA((SQLHENV) conn_res->henv, (SQLHDBC) conn_res->hdbc, SQL_NULL_HSTMT, pSQLCA);
+        check_dbh_error(rc, "SQLGetSQLCA");
+	conn_res->expansion_factor = pSQLCA->sqlerrd[1];	
+	
 	/* set the desired case to be upper */
 	dbh->desired_case = PDO_CASE_UPPER;
 
Index: ibm_statement.c
===================================================================
--- ibm_statement.c	(revision 334368)
+++ ibm_statement.c	(working copy)
@@ -902,6 +902,17 @@
 		case SQL_NUMERIC:
 		default:
 			in_length = col_res->data_size + in_length;
+			if( col_res->data_type  == SQL_GRAPHIC || col_res->data_type  == SQL_VARGRAPHIC ){
+				/* Graphic string is 2 byte character string. Hence size multiply by 2 is required */
+				in_length = in_length * 2;
+			}
+			if( col_res->data_type == SQL_CHAR || col_res->data_type ){
+				/* Multiply the size by expansion factor to handle cases where client and server code pages are different.*/
+				conn_handle *conn_res = (conn_handle *)stmt->dbh->driver_data;
+				if( conn_res->expansion_factor > 1 ){
+					in_length = in_length * conn_res->expansion_factor;
+				}
+			}
 			col_res->data.str_val = (char *) emalloc(in_length+1);
 			check_stmt_allocation(col_res->data.str_val,
 					"stmt_bind_column",
Index: php_pdo_ibm.h
===================================================================
--- php_pdo_ibm.h	(revision 334368)
+++ php_pdo_ibm.h	(working copy)
@@ -22,7 +22,7 @@
 #ifndef PHP_PDO_IBM_H
 #define PHP_PDO_IBM_H
 
-#define PDO_IBM_VERSION "1.3.3"
+#define PDO_IBM_VERSION "1.3.3.1"
 
 extern zend_module_entry pdo_ibm_module_entry;
 #define phpext_pdo_ibm_ptr &pdo_ibm_module_entry
Index: php_pdo_ibm_int.h
===================================================================
--- php_pdo_ibm_int.h	(revision 334368)
+++ php_pdo_ibm_int.h	(working copy)
@@ -174,6 +174,7 @@
 	SQLHANDLE hdbc;				/* the connection handle */
 	conn_error_data error_data;	/* error handling information */
 	int last_insert_id;			/* the last serial id inserted */
+	int expansion_factor;			/* maximum expected expansion factor for the length of mixed character data when converted to the application code page from the database code page*/
 } conn_handle;
 
 /* values used for binding fetched data */
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 14:01:29 2024 UTC