Skip to content

Commit a769b04

Browse files
author
Ambrish Bhargava
committed
fixing bug in db2_statistics
1 parent 4b1dc89 commit a769b04

File tree

4 files changed

+35
-46
lines changed

4 files changed

+35
-46
lines changed

CREDITS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
IBM_DB2
2-
Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, Dan Scott, Helmut Tessarek, Edin Kadribasic, Kellen Bombardier, Tony Cairns
2+
Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, Dan Scott, Helmut Tessarek, Edin Kadribasic, Kellen Bombardier, Tony Cairns, Ambrish Bhargava

ibm_db2.c

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
$Id$
2323
*/
2424

25-
2625
#ifdef HAVE_CONFIG_H
2726
#include "config.h"
2827
#endif
@@ -98,7 +97,6 @@ typedef struct _conn_handle_struct {
9897
SQLHANDLE henv;
9998
SQLHANDLE hdbc;
10099
long auto_commit;
101-
long is_auto_commit;
102100
long c_bin_mode;
103101
long c_case_mode;
104102
long c_cursor_type;
@@ -168,6 +166,7 @@ typedef struct _stmt_handle_struct {
168166
db2_row_type *row_data;
169167
} stmt_handle;
170168

169+
171170
/* equivalent functions on different platforms */
172171
#ifdef PHP_WIN32
173172
#define STRCASECMP stricmp
@@ -1136,7 +1135,6 @@ static void _php_db2_assign_options( void *handle, int type, char *opt_key, zval
11361135
}
11371136
} else if (!STRCASECMP(opt_key, "autocommit")) {
11381137
if (type == SQL_HANDLE_DBC ) {
1139-
((conn_handle*)handle)->is_auto_commit = 1;
11401138
switch (option_num) {
11411139
case DB2_AUTOCOMMIT_ON:
11421140
/* Setting AUTOCOMMIT again here. The user could modify
@@ -2078,6 +2076,19 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
20782076
}
20792077
}
20802078

2079+
conn_res->auto_commit = SQL_AUTOCOMMIT_ON;
2080+
#ifndef PASE
2081+
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)(conn_res->auto_commit), SQL_NTS);
2082+
#else /* PASE */
2083+
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)(&conn_res->auto_commit), SQL_NTS);
2084+
conn_res->c_i5_allow_commit = IBM_DB2_G(i5_allow_commit);
2085+
conn_res->c_i5_dbcs_alloc = IBM_DB2_G(i5_dbcs_alloc);
2086+
if (IBM_DB2_G(i5_job_sort)) {
2087+
attr = 2; /* 2 = special value John Broich PTF */
2088+
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, 10046, (SQLPOINTER)&attr, 0);
2089+
}
2090+
#endif /* PASE */
2091+
20812092
conn_res->c_bin_mode = IBM_DB2_G(bin_mode);
20822093
conn_res->c_case_mode = DB2_CASE_NATURAL;
20832094
conn_res->c_cursor_type = DB2_FORWARD_ONLY;
@@ -2088,13 +2099,8 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
20882099
/* handle not active as of yet */
20892100
conn_res->handle_active = 0;
20902101
conn_res->flag_transaction = 0;
2091-
2092-
#ifdef PASE /* i5/OS php.ini unique settings */
2093-
conn_res->c_i5_pending_cmd = NULL;
2094-
conn_res->c_i5_dbcs_alloc = IBM_DB2_G(i5_dbcs_alloc);
2095-
/* i5/OS OFF default and tests fail (LUW is ON default) */
2096-
conn_res->auto_commit = SQL_AUTOCOMMIT_ON;
2097-
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)(&conn_res->auto_commit), SQL_NTS);
2102+
#ifdef PASE
2103+
conn_res->c_i5_pending_cmd=NULL;
20982104
#endif /* PASE */
20992105
/* Set Options */
21002106
if ( options != NULL ) {
@@ -2103,6 +2109,15 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
21032109
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Options Array must have string indexes");
21042110
}
21052111
}
2112+
#ifdef PASE
2113+
if (!conn_res->c_i5_allow_commit) {
2114+
if (!rc) {
2115+
SQLINTEGER nocommitpase = SQL_TXN_NO_COMMIT;
2116+
SQLSetConnectOption((SQLHDBC)conn_res->hdbc, SQL_ATTR_COMMIT, (SQLPOINTER)&nocommitpase);
2117+
}
2118+
}
2119+
#endif /* PASE */
2120+
21062121
if (! reused) {
21072122
/* Connect */
21082123
/* If the string contains a =, use SQLDriverConnect */
@@ -2164,28 +2179,6 @@ static int _php_db2_connect_helper( INTERNAL_FUNCTION_PARAMETERS, conn_handle **
21642179
#endif /* PASE */
21652180
}
21662181

2167-
/* Set this after the connection handle has been allocated to avoid
2168-
unnecessary network flows. Initialize the structure to default values */
2169-
if(conn_res->is_auto_commit) {
2170-
#ifndef PASE /* i5/OS needs ptr to value */
2171-
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)(conn_res->auto_commit), SQL_NTS);
2172-
#else /* PASE */
2173-
rc = SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, SQL_ATTR_AUTOCOMMIT, (SQLPOINTER)(&conn_res->auto_commit), SQL_NTS);
2174-
#endif /* PASE */
2175-
}
2176-
#ifdef PASE /* i5/OS php.ini unique override settings */
2177-
/* i5/OS 2 = special value John Broich PTF */
2178-
if (IBM_DB2_G(i5_job_sort)) {
2179-
attr = 2;
2180-
SQLSetConnectAttr((SQLHDBC)conn_res->hdbc, 10046, (SQLPOINTER)&attr, 0);
2181-
}
2182-
/* i5/OS CRTLIB style schemas do not allow commit */
2183-
if (!IBM_DB2_G(i5_allow_commit)) {
2184-
SQLINTEGER nocommitpase = SQL_TXN_NO_COMMIT;
2185-
SQLSetConnectOption((SQLHDBC)conn_res->hdbc, SQL_ATTR_COMMIT, (SQLPOINTER)&nocommitpase);
2186-
}
2187-
#endif /* PASE */
2188-
21892182
conn_res->handle_active = 1;
21902183
} while (0);
21912184

@@ -2791,9 +2784,7 @@ PHP_FUNCTION(db2_columns)
27912784
zval *connection = NULL;
27922785
conn_handle *conn_res;
27932786
stmt_handle *stmt_res;
2794-
stmt_handle *stmt_res_identity;
27952787
int rc;
2796-
int i;
27972788

27982789
if (zend_parse_parameters(argc TSRMLS_CC, "r|ssss", &connection, &qualifier,
27992790
&qualifier_len, &owner, &owner_len, &table_name, &table_name_len,
@@ -3178,7 +3169,8 @@ PHP_FUNCTION(db2_statistics)
31783169
}
31793170

31803171
if (connection) {
3181-
ZEND_FETCH_RESOURCE(conn_res, conn_handle*, &connection, connection_id, "Connection Resource", le_conn_struct);
3172+
ZEND_FETCH_RESOURCE2(conn_res, conn_handle*, &connection, connection_id,
3173+
"Connection Resource", le_conn_struct, le_pconn_struct);
31823174

31833175
stmt_res = _db2_new_stmt_struct(conn_res);
31843176
sql_unique = unique;
@@ -3387,7 +3379,6 @@ PHP_FUNCTION(db2_commit)
33873379
static int _php_db2_do_prepare(SQLHANDLE hdbc, char* stmt_string, stmt_handle *stmt_res, int stmt_string_len, zval *options TSRMLS_DC)
33883380
{
33893381
int rc;
3390-
SQLINTEGER vParam;
33913382

33923383
/* alloc handle and return only if it errors */
33933384
rc = SQLAllocHandle(SQL_HANDLE_STMT, hdbc, &(stmt_res->hstmt));
@@ -3440,7 +3431,6 @@ PHP_FUNCTION(db2_exec)
34403431
stmt_handle *stmt_res;
34413432
conn_handle *conn_res;
34423433
int rc;
3443-
SQLINTEGER vParam;
34443434

34453435
/* This function basically is a wrap of the _php_db2_do_prepare and _php_db2_execute_stmt */
34463436
/* After completing statement execution, it returns the statement resource */
@@ -3534,6 +3524,7 @@ PHP_FUNCTION(db2_prepare)
35343524
&stmt_string_len, &options) == FAILURE) {
35353525
return;
35363526
}
3527+
35373528
if (connection) {
35383529
ZEND_FETCH_RESOURCE2(conn_res, conn_handle*, &connection, connection_id,
35393530
"Connection Resource", le_conn_struct, le_pconn_struct);
@@ -3886,6 +3877,7 @@ static int _php_db2_bind_data( stmt_handle *stmt_res, param_node *curr, zval **b
38863877
curr->bind_indicator = (curr->value)->value.str.len;
38873878
paramValuePtr = (SQLPOINTER)((curr->value)->value.str.val);
38883879
}
3880+
38893881
rc = SQLBindParameter(stmt_res->hstmt, curr->param_num,
38903882
curr->param_type, valueType, curr->data_type, curr->param_size,
38913883
curr->scale, paramValuePtr, Z_STRLEN_P(curr->value)+1, &(curr->bind_indicator));

package.xml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,19 @@ Cloudscape, and Apache Derby databases.
2222
<email>[email protected]</email>
2323
<active>yes</active>
2424
</lead>
25-
<date>2010-09-07</date>
25+
<date>2010-11-09</date>
2626
<time>15:17:22</time>
2727
<version>
28-
<release>1.9.0</release>
29-
<api>1.9.0</api>
28+
<release>1.9.1</release>
29+
<api>1.9.1</api>
3030
</version>
3131
<stability>
3232
<release>stable</release>
3333
<api>stable</api>
3434
</stability>
3535
<license>Apache License 2.0</license>
3636
<notes>
37-
Fix for BIGINT fix for i5.
38-
Fix for autocommit issue (CLI setting is now handled).
39-
Fix for db2_pconnect connection reset issue.
40-
Fix for connection rollback in db2_pconnect at the end of request.
37+
Fix for db2_statistics (Failing with pconnect).
4138
</notes>
4239
<contents>
4340
<dir name="/">

php_ibm_db2.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
$Id$
2323
*/
2424

25-
#define PHP_IBM_DB2_VERSION "1.9.0"
25+
#define PHP_IBM_DB2_VERSION "1.9.1"
2626

2727
#ifndef PHP_IBM_DB2_H
2828
#define PHP_IBM_DB2_H

0 commit comments

Comments
 (0)