@@ -239,6 +239,7 @@ typedef struct _conn_handle_struct {
239
239
#ifdef PASE /* IBM i overrides php.ini */
240
240
long c_i5_dbcs_alloc ; /* orig - IBM i 6x space for CCSID<>UTF-8 convert (DBCS customer issue) */
241
241
long c_i5_max_pconnect ; /* 1.9.7 - IBM i count max usage connection recycle (customer issue months live connection) */
242
+ long c_i5_executing ; /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
242
243
#endif /* PASE */
243
244
/* 1.9.7 - IBM i + LUW 10.5 system naming on (*libl)/file.mbr */
244
245
long c_i5_sys_naming ; /* 1.9.7 - IBM i + LUW DB2 Connect 10.5 system naming (customer *LIBL issues) */
@@ -284,8 +285,8 @@ typedef struct _stmt_handle_struct {
284
285
long cursor_type ;
285
286
long s_case_mode ;
286
287
long s_rowcount ;
287
- #ifdef PASE /* IBM i override php.ini */
288
- long s_i5_dbcs_alloc ;
288
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
289
+ conn_handle * s_i5_conn_parent ;
289
290
#endif /* PASE */
290
291
SQLSMALLINT error_recno_tracker ;
291
292
SQLSMALLINT errormsg_recno_tracker ;
@@ -829,8 +830,8 @@ static stmt_handle *_db2_new_stmt_struct(conn_handle* conn_res)
829
830
stmt_res -> cursor_type = conn_res -> c_cursor_type ;
830
831
stmt_res -> s_case_mode = conn_res -> c_case_mode ;
831
832
832
- #ifdef PASE /* IBM i allow 6x DBCS convert php.ini */
833
- stmt_res -> s_i5_dbcs_alloc = conn_res -> c_i5_dbcs_alloc ;
833
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
834
+ stmt_res -> s_i5_conn_parent = conn_res ;
834
835
#endif /* PASE */
835
836
836
837
stmt_res -> expansion_factor = conn_res -> expansion_factor ;
@@ -2172,7 +2173,7 @@ static int _php_db2_get_result_set_info(stmt_handle *stmt_res TSRMLS_DC)
2172
2173
break ;
2173
2174
}
2174
2175
#ifdef PASE /* i5/OS DBCS may have up to 6 times growth in column alloc size on convert */
2175
- if (stmt_res -> s_i5_dbcs_alloc > 0 ) {
2176
+ if (stmt_res -> s_i5_conn_parent -> c_i5_dbcs_alloc > 0 ) {
2176
2177
switch (stmt_res -> column_info [i ].type ) {
2177
2178
case SQL_CHAR :
2178
2179
case SQL_VARCHAR :
@@ -2579,6 +2580,11 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2579
2580
reused = 1 ;
2580
2581
} /* else will re-connect since connection is dead */
2581
2582
#else
2583
+ /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
2584
+ if (conn_res -> c_i5_executing ) {
2585
+ conn_res -> flag_pconnect = 9 ;
2586
+ conn_res -> c_i5_executing = 0 ;
2587
+ } else {
2582
2588
/* 1.9.7 - IBM i remote persistent connection or long lived local (customer issue dead connection) */
2583
2589
/* 1.9.7 - IBM i i5/OS DB2 Maid Service (monitor QSQSRVR jobs) */
2584
2590
/* 1.9.7 - IBM i level 4: try conn new statement (check statement) */
@@ -2638,6 +2644,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2638
2644
/* close sets conn_res->flag_pconnect=9 */
2639
2645
_php_db2_close_now (conn_res , 1 TSRMLS_CC );
2640
2646
}
2647
+ } /* 1.9.9 executing */
2641
2648
reused = 1 ;
2642
2649
#endif /* PASE */
2643
2650
}
@@ -2708,6 +2715,7 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
2708
2715
}
2709
2716
#ifdef PASE /* 1.9.7 - IBM i count max usage connection recycle (customer issue months live connection) */
2710
2717
conn_res -> c_i5_max_pconnect = IBM_DB2_G (i5_max_pconnect );
2718
+ conn_res -> c_i5_executing = 0 ; /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
2711
2719
#endif /* PASE */
2712
2720
}
2713
2721
@@ -4254,7 +4262,13 @@ static int _php_db2_execute_stmt(stmt_handle *stmt_res TSRMLS_DC)
4254
4262
{
4255
4263
int rc ;
4256
4264
4265
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
4266
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 1 ;
4267
+ #endif /* PASE */
4257
4268
rc = SQLExecute ((SQLHSTMT )stmt_res -> hstmt );
4269
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
4270
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 0 ;
4271
+ #endif /* PASE */
4258
4272
if ( rc == SQL_ERROR ) {
4259
4273
_php_db2_check_sql_errors (stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
4260
4274
}
@@ -4312,7 +4326,13 @@ PHP_FUNCTION(db2_exec)
4312
4326
}
4313
4327
}
4314
4328
4329
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
4330
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 1 ;
4331
+ #endif /* PASE */
4315
4332
rc = SQLExecDirect ((SQLHSTMT )stmt_res -> hstmt , stmt_string , stmt_string_len );
4333
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
4334
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 0 ;
4335
+ #endif /* PASE */
4316
4336
if ( rc == SQL_ERROR ) {
4317
4337
_php_db2_check_sql_errors (stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
4318
4338
}
@@ -4548,7 +4568,10 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
4548
4568
*/
4549
4569
if (IS_INTERNED (ZEND_STR (* data ))) {
4550
4570
#if PHP_MAJOR_VERSION >= 7
4551
- Z_STR_P (* data ) = zend_string_init (ZEND_Z_STRVAL_PP (data ), ZEND_Z_STRLEN_PP (data ), 0 );
4571
+ /* Need use macro assignment to avoid leak in php 7. (Thanks Dimitry)
4572
+ * Z_STR_P(*data) = zend_string_init(ZEND_Z_STRVAL_PP(data), ZEND_Z_STRLEN_PP(data), 0);
4573
+ */
4574
+ ZVAL_STR (* data , zend_string_init (ZEND_Z_STRVAL_PP (data ), ZEND_Z_STRLEN_PP (data ), 0 ));
4552
4575
#else
4553
4576
ZEND_Z_STRVAL_PP (data ) = estrndup (ZEND_Z_STRVAL_PP (data ), ZEND_Z_STRLEN_PP (data ));
4554
4577
#endif
@@ -4557,7 +4580,10 @@ static int _php_db2_bind_pad(param_node *curr, int nullterm, int isvarying, int
4557
4580
/* make enough space for full write */
4558
4581
if (* poriglen < curr -> param_size ) {
4559
4582
#if PHP_MAJOR_VERSION >= 7
4560
- Z_STR_P (* data ) = zend_string_extend (Z_STR_P (* data ), curr -> param_size + nullterm , 0 );
4583
+ /* Need use macro assignment in php 7 (follow pattern zend_string_init)
4584
+ * Z_STR_P(*data) = zend_string_extend(Z_STR_P(*data), curr->param_size + nullterm, 0);
4585
+ */
4586
+ ZVAL_STR (* data , zend_string_extend (Z_STR_P (* data ), curr -> param_size + nullterm , 0 ));
4561
4587
#else
4562
4588
ZEND_Z_STRVAL_PP (data ) = erealloc (ZEND_Z_STRVAL_PP (data ), curr -> param_size + nullterm );
4563
4589
#endif
@@ -5077,7 +5103,7 @@ PHP_FUNCTION(db2_execute)
5077
5103
}
5078
5104
5079
5105
#if PHP_MAJOR_VERSION >= 7
5080
- if (parameters_array && Z_TYPE_P (parameters_array ) == IS_ARRAY && (Z_TYPE_FLAGS_P (parameters_array ) & IS_TYPE_IMMUTABLE )) {
5106
+ if (parameters_array && Z_TYPE_P (parameters_array ) == IS_ARRAY && (Z_TYPE_FLAGS_P (parameters_array ) & ( IS_TYPE_COPYABLE & ! IS_TYPE_REFCOUNTED ) )) {
5081
5107
SEPARATE_ARRAY (parameters_array );
5082
5108
}
5083
5109
#endif
@@ -5180,7 +5206,13 @@ PHP_FUNCTION(db2_execute)
5180
5206
} else {
5181
5207
/* No Parameters */
5182
5208
/* We just execute the statement. No additional work needed. */
5209
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
5210
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 1 ;
5211
+ #endif /* PASE */
5183
5212
rc = SQLExecute ((SQLHSTMT )stmt_res -> hstmt );
5213
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
5214
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 0 ;
5215
+ #endif /* PASE */
5184
5216
if ( rc == SQL_ERROR ) {
5185
5217
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Statement Execute Failed ");
5186
5218
_php_db2_check_sql_errors (stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
@@ -5189,7 +5221,13 @@ PHP_FUNCTION(db2_execute)
5189
5221
RETURN_TRUE ;
5190
5222
}
5191
5223
/* Execute Stmt -- All parameters bound */
5224
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
5225
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 1 ;
5226
+ #endif /* PASE */
5192
5227
rc = SQLExecute ((SQLHSTMT )stmt_res -> hstmt );
5228
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
5229
+ stmt_res -> s_i5_conn_parent -> c_i5_executing = 0 ;
5230
+ #endif /* PASE */
5193
5231
if ( rc == SQL_ERROR ) {
5194
5232
php_error_docref (NULL TSRMLS_CC , E_WARNING , "Statement Execute Failed ");
5195
5233
_php_db2_check_sql_errors (stmt_res -> hstmt , SQL_HANDLE_STMT , rc , 1 , NULL , -1 , 1 TSRMLS_CC );
@@ -5438,8 +5476,8 @@ PHP_FUNCTION(db2_next_result)
5438
5476
new_stmt_res -> s_bin_mode = stmt_res -> s_bin_mode ;
5439
5477
new_stmt_res -> cursor_type = stmt_res -> cursor_type ;
5440
5478
new_stmt_res -> s_case_mode = stmt_res -> s_case_mode ;
5441
- #ifdef PASE /* i5 override php.ini */
5442
- new_stmt_res -> s_i5_dbcs_alloc = stmt_res -> s_i5_dbcs_alloc ;
5479
+ #ifdef PASE /* 1.9.9 - IBM i customer request abandon connection stored proc in MSQW (human response needed) */
5480
+ new_stmt_res -> s_i5_conn_parent = stmt_res -> s_i5_conn_parent ;
5443
5481
#endif /* PASE */
5444
5482
new_stmt_res -> head_cache_list = NULL ;
5445
5483
new_stmt_res -> current_node = NULL ;
@@ -5953,7 +5991,7 @@ static RETCODE _php_db2_get_length(stmt_handle* stmt_res, SQLUSMALLINT col_num,
5953
5991
}
5954
5992
#ifdef PASE /* i5/OS special DBCS */
5955
5993
if (* sLength != SQL_NULL_DATA ){
5956
- if (stmt_res -> s_i5_dbcs_alloc > 0 ) {
5994
+ if (stmt_res -> s_i5_conn_parent -> c_i5_dbcs_alloc > 0 ) {
5957
5995
switch (stmt_res -> column_info [col_num - 1 ].type ) {
5958
5996
case SQL_CHAR :
5959
5997
case SQL_VARCHAR :
@@ -7779,7 +7817,7 @@ PHP_FUNCTION( db2_execute_many )
7779
7817
}
7780
7818
7781
7819
#if PHP_MAJOR_VERSION >= 7
7782
- if (params && Z_TYPE_P (params ) == IS_ARRAY && (Z_TYPE_FLAGS_P (params ) & IS_TYPE_IMMUTABLE )) {
7820
+ if (params && Z_TYPE_P (params ) == IS_ARRAY && (Z_TYPE_FLAGS_P (params ) & ( IS_TYPE_COPYABLE & ! IS_TYPE_REFCOUNTED ) )) {
7783
7821
SEPARATE_ARRAY (params );
7784
7822
}
7785
7823
#endif
0 commit comments