Skip to content

Commit d68f658

Browse files
author
Ambrish Bhargava
committed
Adding execute_many() API for Batching support
1 parent 388d434 commit d68f658

8 files changed

+761
-32
lines changed

ibm_db2.c

Lines changed: 318 additions & 25 deletions
Large diffs are not rendered by default.

package.xml

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,24 +22,27 @@ Cloudscape, and Apache Derby databases.
2222
<email>[email protected]</email>
2323
<active>yes</active>
2424
</lead>
25-
<date>2010-11-08</date>
26-
<time>15:17:22</time>
25+
<date>2011-08-23</date>
26+
<time>15:00:00</time>
2727
<version>
28-
<release>1.9.1</release>
29-
<api>1.9.1</api>
28+
<release>1.9.2</release>
29+
<api>1.9.2</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 db2_statistics (Failing with pconnect).
37+
Added execute_many() API to execute batch.
38+
Fixed: Connection hanging issue.
39+
Fixed: Defect #20281 (Improve error reporting)
3840
</notes>
3941
<contents>
4042
<dir name="/">
4143
<dir name="tests">
4244
<file baseinstalldir="ibm_db2" name="connection.inc" role="test" />
45+
<file baseinstalldir="ibm_db2" name="rollbackhandler.inc" role="test" />
4346
<file baseinstalldir="ibm_db2" name="escape.dat" role="test" />
4447
<file baseinstalldir="ibm_db2" name="pic1.jpg" role="test" />
4548
<file baseinstalldir="ibm_db2" name="resume_000130.txt" role="test" />
@@ -265,6 +268,10 @@ Fix for db2_statistics (Failing with pconnect).
265268
<file baseinstalldir="ibm_db2" name="test_trusted_context_pconnect.phpt" role="test" />
266269
<file baseinstalldir="ibm_db2" name="test_000_PrepareDb.phpt" role="test" />
267270
<file baseinstalldir="ibm_db2" name="trusted_connection.inc" role="test" />
271+
<file baseinstalldir="ibm_db2" name="test_graphic_data_type.phpt" role="test" />
272+
<file baseinstalldir="ibm_db2" name="test_check_rollback.phpt" role="test" />
273+
<file baseinstalldir="ibm_db2" name="test_connect_deallocator.phpt" role="test" />
274+
<file baseinstalldir="ibm_db2" name="test_execute_many.phpt" role="test" />
268275
</dir> <!-- //tests -->
269276
<file baseinstalldir="ibm_db2" name="config.m4" role="src" />
270277
<file baseinstalldir="ibm_db2" name="config.w32" role="src" />

php_ibm_db2.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,14 @@
1616
| permissions and limitations under the License. |
1717
+----------------------------------------------------------------------+
1818
| Authors: Sushant Koduru, Lynh Nguyen, Kanchana Padmanabhan, |
19-
| Dan Scott, Helmut Tessarek, Ambrish Bhargava |
19+
| Dan Scott, Helmut Tessarek, Ambrish Bhargava, |
20+
| Rahul Priyadarshi |
2021
+----------------------------------------------------------------------+
2122
2223
$Id$
2324
*/
2425

25-
#define PHP_IBM_DB2_VERSION "1.9.1"
26+
#define PHP_IBM_DB2_VERSION "1.9.2"
2627

2728
#ifndef PHP_IBM_DB2_H
2829
#define PHP_IBM_DB2_H
@@ -224,6 +225,7 @@ PHP_FUNCTION(db2_commit);
224225
PHP_FUNCTION(db2_exec);
225226
PHP_FUNCTION(db2_prepare);
226227
PHP_FUNCTION(db2_execute);
228+
PHP_FUNCTION(db2_execute_many);
227229
PHP_FUNCTION(db2_conn_errormsg);
228230
PHP_FUNCTION(db2_stmt_errormsg);
229231
PHP_FUNCTION(db2_conn_error);

tests/rollbackhandler.inc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
require_once('connection.inc');
3+
if($url == "no url") {
4+
die('skip');
5+
}
6+
?>

tests/test_066_TableObjects.phpt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ Name: ANIMALS
2828
Type: TABLE
2929
Remarks:
3030

31+
Schema: %s
32+
Name: ANIMAL_PICS
33+
Type: TABLE
34+
Remarks:
35+
3136
Schema: %s
3237
Name: ANIME_CAT
3338
Type: VIEW

tests/test_check_rollback.phpt

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
--TEST--
2+
IBM-DB2: pConnect Rollback Handler Test.
3+
--SKIPIF--
4+
<?php require_once('rollbackhandler.inc'); ?>
5+
--FILE--
6+
<?php
7+
require_once('connection.inc');
8+
9+
$conn = db2_connect($database, $user, $password);
10+
11+
db2_autocommit($conn,DB2_AUTOCOMMIT_ON);
12+
13+
function prepare() {
14+
global $conn;
15+
16+
$stmtCreate = db2_exec($conn,"create table rollbacktest(id integer primary key not null, charval varchar(20))");
17+
18+
if($stmtCreate) {
19+
return 1;
20+
} else {
21+
echo "creation of table failed\n";
22+
$err = db2_stmt_errormsg();
23+
print "done $err";
24+
return 0;
25+
}
26+
}
27+
28+
function cleanup() {
29+
global $conn;
30+
31+
$stmtdrop = db2_exec($conn,"drop table rollbacktest");
32+
33+
if($stmtdrop) {
34+
return 1;
35+
} else {
36+
echo "drop table failed\n";
37+
return 0;
38+
}
39+
}
40+
41+
function callURL() {
42+
global $url,$database,$user,$password,$hostname,$port;
43+
$myurl = "$url?database=$database&user=$user&password=$password&host=$hostname&port=$port";
44+
$ch = curl_init($myurl);
45+
if( $ch ) {
46+
curl_exec($ch);
47+
} else {
48+
echo "URL specified is not valid";
49+
}
50+
}
51+
52+
function checkTest() {
53+
global $conn;
54+
$stmt = db2_exec($conn,"insert into rollbacktest (id,charval) values (1,'rolled back')");
55+
if ( $stmt) {
56+
echo "Test successful\n";
57+
} else {
58+
echo "Test failed\n";
59+
$err = db2_stmt_errormsg();
60+
print "$err";
61+
}
62+
}
63+
64+
function main() {
65+
$retVal = prepare();
66+
if( $retVal ){
67+
callURL();
68+
checkTest();
69+
cleanup();
70+
} else {
71+
echo "DB preapre failed \n";
72+
}
73+
}
74+
75+
if ($conn) {
76+
echo "Connection succeeded.\n" ;
77+
main();
78+
} else {
79+
echo "Connection failed. \n";
80+
print db2_conn_errormsg($conn);
81+
}
82+
?>
83+
--EXPECT--
84+
Connection succeeded.
85+
Connection succeeded.
86+
row insert went through successfully
87+
Test successful

0 commit comments

Comments
 (0)