Patch bug_64999.patch for PDO_IBM Bug #64999
Patch version 2013-07-24 17:24 UTC
Return to Bug #64999 |
Download this patch
Patch Revisions:
Developer: rahulpriyadarshi@php.net
diff -cB PDO_IBM-1.3.3/ibm_statement.c PDO_IBM-1.3.3_PHP54_INOUT/ibm_statement.c
*** PDO_IBM-1.3.3/ibm_statement.c 2012-03-12 18:41:56.000000000 +0530
--- PDO_IBM-1.3.3_PHP54_INOUT/ibm_statement.c 2013-07-24 22:26:37.000000000 +0530
***************
*** 62,69 ****
int colno;
};
! #ifdef PASE
! static int get_lob_length(pdo_stmt_t *stmt, column_data *col_res)
{
SQLRETURN rc = 0;
SQLHANDLE new_hstmt;
--- 62,68 ----
int colno;
};
! static int get_lob_length(pdo_stmt_t *stmt, column_data *col_res TSRMLS_DC)
{
SQLRETURN rc = 0;
SQLHANDLE new_hstmt;
***************
*** 73,148 ****
if (rc != SQL_SUCCESS) {
return rc;
}
!
rc = SQLGetLength((SQLHSTMT)new_hstmt,
col_res->loc_type,
col_res->lob_loc,
! &col_res->lob_data_length,
! &col_res->loc_ind);
check_stmt_error(rc, "SQLGetLength");
- if (rc != SQL_SUCCESS) {
- col_res->lob_data_length=0;
- }
-
SQLFreeHandle(SQL_HANDLE_STMT, new_hstmt);
return rc;
}
static int get_lob_substring(pdo_stmt_t *stmt, column_data *col_res,
! SQLSMALLINT ctype, SQLINTEGER *out_length)
{
SQLRETURN rc = 0;
SQLHANDLE new_hstmt;
conn_handle *conn_res = (conn_handle *)stmt->dbh->driver_data;
*out_length=0;
- col_res->lob_data_offset = 0;
- col_res->lob_data[col_res->lob_data_length]='\0';
rc = SQLAllocHandle(SQL_HANDLE_STMT, conn_res->hdbc, &new_hstmt);
if (rc != SQL_SUCCESS) {
return rc;
}
rc = SQLGetSubString(
(SQLHSTMT)new_hstmt,
col_res->loc_type,
col_res->lob_loc,
! 1,
! col_res->lob_data_length,
ctype,
! col_res->lob_data,
! col_res->lob_data_length+1,
out_length,
&col_res->loc_ind);
check_stmt_error(rc, "SQLGetSubString");
!
! col_res->lob_data[col_res->lob_data_length]='\0';
SQLFreeHandle(SQL_HANDLE_STMT, new_hstmt);
return rc;
}
- #endif
size_t lob_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
SQLINTEGER readBytes = 0;
struct lob_stream_data *data = stream->abstract;
- column_data *col_res = &data->stmt_res->columns[data->colno];
- stmt_handle *stmt_res = data->stmt_res;
pdo_stmt_t *stmt = data->stmt;
int ctype = 0;
SQLRETURN rc = 0;
- long sLength;
switch (col_res->data_type) {
default:
! #ifndef PASE
! case SQL_LONGVARCHAR:
! #else /* i5os string type required for the ascii->ebcdic conversion */
case SQL_CLOB:
case SQL_DBCLOB:
#endif
--- 72,146 ----
if (rc != SQL_SUCCESS) {
return rc;
}
! col_res->loc_ind = 0;
rc = SQLGetLength((SQLHSTMT)new_hstmt,
col_res->loc_type,
col_res->lob_loc,
! &(col_res->lob_data_length),
! &(col_res->loc_ind));
check_stmt_error(rc, "SQLGetLength");
SQLFreeHandle(SQL_HANDLE_STMT, new_hstmt);
return rc;
}
static int get_lob_substring(pdo_stmt_t *stmt, column_data *col_res,
! SQLSMALLINT ctype, char *buf, size_t count, SQLINTEGER *out_length TSRMLS_DC)
{
SQLRETURN rc = 0;
SQLHANDLE new_hstmt;
+ SQLUINTEGER readByte = 0;
conn_handle *conn_res = (conn_handle *)stmt->dbh->driver_data;
*out_length=0;
rc = SQLAllocHandle(SQL_HANDLE_STMT, conn_res->hdbc, &new_hstmt);
if (rc != SQL_SUCCESS) {
return rc;
}
+ col_res->loc_ind = 0;
+ if ((col_res->lob_data_length - col_res->lob_data_offset) > count){
+ readByte = count;
+ } else if ((col_res->lob_data_length - col_res->lob_data_offset) > 0) {
+ readByte = col_res->lob_data_length - col_res->lob_data_offset;
+ } else {
+ *out_length = 0;
+ return 0;
+ }
+
rc = SQLGetSubString(
(SQLHSTMT)new_hstmt,
col_res->loc_type,
col_res->lob_loc,
! col_res->lob_data_offset + 1,
! readByte,
ctype,
! buf,
! count + 1,
out_length,
&col_res->loc_ind);
check_stmt_error(rc, "SQLGetSubString");
! col_res->lob_data_offset = col_res->lob_data_offset + *out_length;
SQLFreeHandle(SQL_HANDLE_STMT, new_hstmt);
return rc;
}
size_t lob_stream_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
{
SQLINTEGER readBytes = 0;
struct lob_stream_data *data = stream->abstract;
pdo_stmt_t *stmt = data->stmt;
+ column_data *col_res = &data->stmt_res->columns[data->colno];
int ctype = 0;
SQLRETURN rc = 0;
switch (col_res->data_type) {
default:
! #ifdef PASE /* i5os string type required for the ascii->ebcdic conversion */
case SQL_CLOB:
case SQL_DBCLOB:
#endif
***************
*** 160,167 ****
case SQL_BLOB:
#ifndef PASE
case SQL_CLOB:
#endif
- case SQL_XML:
#ifdef PASE /* i5/OS V6R1 incompatible change */
if (PDO_IBM_G(is_i5os_classic)){
ctype = SQL_C_BINARY;
--- 158,165 ----
case SQL_BLOB:
#ifndef PASE
case SQL_CLOB:
+ case SQL_DBCLOB:
#endif
#ifdef PASE /* i5/OS V6R1 incompatible change */
if (PDO_IBM_G(is_i5os_classic)){
ctype = SQL_C_BINARY;
***************
*** 174,216 ****
break;
}
! #ifdef PASE
! if (buf == NULL) {
! rc = get_lob_length(stmt, col_res);
! if (rc != SQL_ERROR && col_res->lob_data_length > 0) {
! col_res->lob_data = emalloc(col_res->lob_data_length+1);
! rc = get_lob_substring(stmt, col_res, ctype, &readBytes);
! }
! } else {
! readBytes = MIN(count, col_res->lob_data_length - col_res->lob_data_offset);
! if (readBytes > 0) {
! memcpy( buf, col_res->lob_data + col_res->lob_data_offset, readBytes);
! col_res->lob_data_offset +=readBytes;
! }
! }
!
! if (readBytes <= 0) {
! readBytes = -1;
! if (buf != NULL) {
! /* EOF reached */
! stream->eof = 1;
! }
! }
! #else
! rc = SQLGetData(stmt_res->hstmt, data->colno + 1, ctype, buf, count, &readBytes);
! check_stmt_error(rc, "SQLGetData");
!
! if (readBytes == -1) { /*For NULL CLOB/BLOB values */
! return (size_t) readBytes;
! }
! if (readBytes > count) {
! if (col_res->data_type == SQL_LONGVARCHAR) { /*Dont return the NULL at end of CLOB buffer */
! readBytes = count - 1;
! } else {
! readBytes = count;
! }
! }
! #endif
return (size_t) readBytes;
}
--- 172,178 ----
break;
}
! get_lob_substring(stmt, col_res, ctype, buf, count, &readBytes TSRMLS_CC);
return (size_t) readBytes;
}
***************
*** 248,266 ****
struct lob_stream_data *data;
column_data *col_res;
php_stream *retval;
data = emalloc(sizeof(struct lob_stream_data));
data->stmt_res = stmt_res;
data->stmt = stmt;
data->colno = colno;
col_res = &data->stmt_res->columns[data->colno];
- retval = (php_stream *) php_stream_alloc(&lob_stream_ops, data, NULL, "r");
/* Find out if the column contains NULL data */
! if (lob_stream_read(retval, NULL, 0 TSRMLS_CC) == SQL_NULL_DATA) {
! php_stream_close(retval);
return NULL;
! } else
return retval;
}
/*
--- 210,234 ----
struct lob_stream_data *data;
column_data *col_res;
php_stream *retval;
+ SQLRETURN rc;
data = emalloc(sizeof(struct lob_stream_data));
data->stmt_res = stmt_res;
data->stmt = stmt;
data->colno = colno;
col_res = &data->stmt_res->columns[data->colno];
/* Find out if the column contains NULL data */
! if (col_res->loc_ind == SQL_NULL_DATA) {
return NULL;
! }
! col_res->lob_data_length = 0;
! col_res->lob_data_offset = 0;
! retval = (php_stream *) php_stream_alloc(&lob_stream_ops, data, NULL, "r");
! /* Find out the length of data */
! get_lob_length(stmt, col_res TSRMLS_CC);
return retval;
+
+
}
/*
***************
*** 280,286 ****
* buffer that also needs releasing.
*/
if (stmt_res->columns[i].returned_type == PDO_PARAM_STR) {
! efree(stmt_res->columns[i].data.str_val);
}
if (stmt_res->columns[i].returned_type == PDO_PARAM_LOB && (stmt_res->columns[i].lob_data != NULL)) {
--- 248,256 ----
* buffer that also needs releasing.
*/
if (stmt_res->columns[i].returned_type == PDO_PARAM_STR) {
! if (!IS_INTERNED(stmt_res->columns[i].data.str_val)){
! efree(stmt_res->columns[i].data.str_val);
! }
}
if (stmt_res->columns[i].returned_type == PDO_PARAM_LOB && (stmt_res->columns[i].lob_data != NULL)) {
***************
*** 604,609 ****
--- 574,583 ----
param_res->param_size = Z_STRLEN_P(curr->parameter);
+ if (IS_INTERNED((curr->parameter)->value.str.val)){
+ Z_STRVAL_P(curr->parameter) = estrndup(Z_STRVAL_P(curr->parameter), param_res->param_size);
+ }
+
/*
* Now we need to make sure the string buffer
* is large enough to receive a new value if
***************
*** 842,873 ****
#endif
case SQL_BLOB:
case SQL_CLOB:
- #ifdef PASE /* i5 DBCLOB locator */
case SQL_DBCLOB:
- #else
- case SQL_XML:
- #endif /* PASE */
{
! /* we're going to need to do getdata calls to retrieve these */
col_res->out_length = 0;
/* and this is returned as a stream */
col_res->returned_type = PDO_PARAM_LOB;
col->param_type = PDO_PARAM_LOB;
col_res->lob_loc = 0;
! if(col_res->data_type == SQL_CLOB) {
col_res->loc_type = SQL_CLOB_LOCATOR;
- #ifdef PASE /* i5 DBCLOB locator */
} else if(col_res->data_type == SQL_DBCLOB) {
col_res->loc_type = SQL_DBCLOB_LOCATOR;
- #endif /* PASE */
} else {
! col_res->loc_type = SQL_C_CHAR;
}
col_res->loc_ind = 0;
col_res->lob_data_length = 0;
col_res->lob_data_offset = 0;
- col_res->lob_data = NULL;
rc = SQLBindCol( (SQLHSTMT) stmt_res->hstmt,
(SQLUSMALLINT) (colno + 1),
col_res->loc_type,
--- 816,840 ----
#endif
case SQL_BLOB:
case SQL_CLOB:
case SQL_DBCLOB:
{
! /* we're going to need to do getSubString calls to retrieve these */
col_res->out_length = 0;
/* and this is returned as a stream */
col_res->returned_type = PDO_PARAM_LOB;
col->param_type = PDO_PARAM_LOB;
col_res->lob_loc = 0;
! if((col_res->data_type == SQL_CLOB) || col_res->data_type == SQL_XML) {
col_res->loc_type = SQL_CLOB_LOCATOR;
} else if(col_res->data_type == SQL_DBCLOB) {
col_res->loc_type = SQL_DBCLOB_LOCATOR;
} else {
! col_res->loc_type = SQL_BLOB_LOCATOR;
}
col_res->loc_ind = 0;
col_res->lob_data_length = 0;
col_res->lob_data_offset = 0;
rc = SQLBindCol( (SQLHSTMT) stmt_res->hstmt,
(SQLUSMALLINT) (colno + 1),
col_res->loc_type,
***************
*** 884,890 ****
case SQL_VARBINARY:
case SQL_BINARY:
case SQL_XML:
! #endif
#ifdef PASE /* i5/OS incompatible v6r1 change */
case SQL_VARBINARY_V6:
case SQL_BINARY_V6:
--- 851,857 ----
case SQL_VARBINARY:
case SQL_BINARY:
case SQL_XML:
! #endif /* PASE */
#ifdef PASE /* i5/OS incompatible v6r1 change */
case SQL_VARBINARY_V6:
case SQL_BINARY_V6:
diff -cB PDO_IBM-1.3.3/php_pdo_ibm.h PDO_IBM-1.3.3_PHP54_INOUT/php_pdo_ibm.h
*** PDO_IBM-1.3.3/php_pdo_ibm.h 2012-03-12 18:41:56.000000000 +0530
--- PDO_IBM-1.3.3_PHP54_INOUT/php_pdo_ibm.h 2013-07-24 22:29:51.000000000 +0530
***************
*** 15,28 ****
| permissions and limitations under the License. |
+----------------------------------------------------------------------+
| Authors: Rick McGuire, Dan Scott, Krishna Raman, Kellen Bombardier, |
! | Ambrish Bhargava |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PDO_IBM_H
#define PHP_PDO_IBM_H
! #define PDO_IBM_VERSION "1.3.3"
extern zend_module_entry pdo_ibm_module_entry;
#define phpext_pdo_ibm_ptr &pdo_ibm_module_entry
--- 15,28 ----
| permissions and limitations under the License. |
+----------------------------------------------------------------------+
| Authors: Rick McGuire, Dan Scott, Krishna Raman, Kellen Bombardier, |
! | Ambrish Bhargava, Rahul Priyadarshi |
+----------------------------------------------------------------------+
*/
#ifndef PHP_PDO_IBM_H
#define PHP_PDO_IBM_H
! #define PDO_IBM_VERSION "1.3.3.240713"
extern zend_module_entry pdo_ibm_module_entry;
#define phpext_pdo_ibm_ptr &pdo_ibm_module_entry
diff -cB PDO_IBM-1.3.3/php_pdo_ibm_int.h PDO_IBM-1.3.3_PHP54_INOUT/php_pdo_ibm_int.h
*** PDO_IBM-1.3.3/php_pdo_ibm_int.h 2012-03-12 18:41:56.000000000 +0530
--- PDO_IBM-1.3.3_PHP54_INOUT/php_pdo_ibm_int.h 2013-07-24 22:20:33.000000000 +0530
***************
*** 25,30 ****
--- 25,35 ----
#include "sqlcli1.h"
+ /* Needed for backward compatibility (IS_INTERNED not defined prior to PHP-5.4) */
+ #ifndef IS_INTERNED
+ #define IS_INTERNED(s) (0)
+ #endif
+
#define MAX_OPTION_LEN 10
#define MAX_ERR_MSG_LEN (SQL_MAX_MESSAGE_LENGTH + SQL_SQLSTATE_SIZE + 1)
#define CDTIMETYPE 112
Common subdirectories: PDO_IBM-1.3.3/tests and PDO_IBM-1.3.3_PHP54_INOUT/tests
|