PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.phpt ('PDO_OCI: Attribute: beginTransaction and native transactions')

Script

1: <?php
2:
3:
require(dirname(__FILE__) . '/../../pdo/tests/pdo_test.inc');
4:
$dbh PDOTest::factory();
5:
6:
$dbh->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_SILENT);
7:
$dbh->exec("drop table pdo_ac_tab");
8:
$dbh->setAttribute(PDO::ATTR_ERRMODEPDO::ERRMODE_EXCEPTION);
9:
10:
$dbh->exec("create table pdo_ac_tab (col1 varchar2(25))");
11:
12: echo 
"Test 1 Check beginTransaction insertion\n";
13:
14:
$dbh->beginTransaction();
15: try {
16:     
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 1')");
17:     
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 2')");
18:     
$dbh->commit();
19: }
20: catch (
PDOException $e) {
21:     echo 
"Caught unexpected exception at line " __LINE__ "\n";
22:     echo 
$e->getMessage() . "\n";
23:     
$dbh->rollback();
24: }
25:
26: echo 
"Test 2 Cause an exception and test beginTransaction rollback\n";
27:
28:
$dbh->beginTransaction();
29: try {
30:     
$dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #1')");
31:     
$dbh->exec("insert into pdo_ac_tab (col1) values ('data that is too long to fit and will barf')");
32:     
$dbh->commit();
33: }
34: catch (
PDOException $e) {
35:     echo 
"Caught expected exception at line " __LINE__ "\n";
36:     echo 
$e->getMessage() . "\n";
37:     
$dbh->rollback();
38: }
39:
40: echo 
"Test 3 Setting ATTR_AUTOCOMMIT to true will commit and end the transaction\n";
41:
42:
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 3')");
43:
$dbh->setAttribute(PDO::ATTR_AUTOCOMMITtrue);
44: print 
"PDO::ATTR_AUTOCOMMIT: ";
45:
var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
46: try {
47:     
$dbh->rollback();
48: }
49: catch (
PDOException $e) {
50:     echo 
"Caught expected exception at line " __LINE__ "\n";
51:     echo 
$e->getMessage() . "\n";
52: }
53:
54: echo 
"Test 4 Setting ATTR_AUTOCOMMIT to false will commit and end the transaction\n";
55:
56:
$dbh->beginTransaction();
57:
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 4')");
58:
$dbh->setAttribute(PDO::ATTR_AUTOCOMMITfalse);
59: print 
"PDO::ATTR_AUTOCOMMIT: ";
60:
var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
61: try {
62:     
$dbh->rollback();
63: }
64: catch (
PDOException $e) {
65:     echo 
"Caught expected exception at line " __LINE__ "\n";
66:     echo 
$e->getMessage() . "\n";
67: }
68:
69: echo 
"Test 5 Handle transactions ourselves\n";
70:
71: print 
"PDO::ATTR_AUTOCOMMIT: ";
72:
var_dump($dbh->getAttribute(PDO::ATTR_AUTOCOMMIT));
73:
74:
$dbh->exec("insert into pdo_ac_tab (col1) values ('not committed #2')");
75:
$dbh->exec("rollback");
76:
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 5')");
77:
$dbh->exec("insert into pdo_ac_tab (col1) values ('data 6')");
78:
79:
$dbh->exec("commit");
80:
81:
// Open new connection to really verify what was inserted
82:
83:
$dbh2 PDOTest::factory();
84:
85: echo 
"Query Results are:\n";
86:
$s $dbh2->prepare("select col1 from pdo_ac_tab");
87:
$s->execute();
88: while (
$r $s->fetch()) {
89:     echo 
$r[0] . "\n";
90: }
91:
92: echo 
"Done\n";
93:
94:
?>
95:

Expected

Test 1 Check beginTransaction insertion
Test 2 Cause an exception and test beginTransaction rollback
Caught expected exception at line 35
SQLSTATE[HY000]: General error: 12899 OCIStmtExecute: ORA-12899: %s
%s
Test 3 Setting ATTR_AUTOCOMMIT to true will commit and end the transaction
PDO::ATTR_AUTOCOMMIT: bool(true)
Caught expected exception at line %d
There is no active transaction
Test 4 Setting ATTR_AUTOCOMMIT to false will commit and end the transaction
PDO::ATTR_AUTOCOMMIT: bool(false)
Caught expected exception at line %d
There is no active transaction
Test 5 Handle transactions ourselves
PDO::ATTR_AUTOCOMMIT: bool(false)
Query Results are:
data 1
data 2
data 3
data 4
data 5
data 6
Done

Output

***********************************************************************
Fatal NI connect error 12541, connecting to:
 (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))

  VERSION INFORMATION:
	TNS for Linux: Version 11.2.0.2.0 - Beta
	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
  Time: 17-JUN-2018 09:51:22
  Tracing not turned on.
  Tns error struct:
    ns main err code: 12541
    TNS-12541: TNS:no listener
    ns secondary err code: 12560
    nt main err code: 511
    TNS-00511: No listener

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
 (/var/php_gcov/PHP_HEAD/ext/pdo_oci/oci_driver.c:634) in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc:35
Stack trace:
#0 /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc(35): PDO->__construct('oci:dbname=//lo...', 'system', 'oracle', NULL)
#1 /var/php_gcov/PHP_HEAD/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.php(4): PDOTest::factory()
#2 {main}
  thrown in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc on line 35
    nt secondary err code: 111
    nt OS err code: 0

Diff

001+ ***********************************************************************
002+ Fatal NI connect error 12541, connecting to:
003+  (DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=XE)(CID=(PROGRAM=php)(HOST=nex2.php.net)(USER=nlopess)))(ADDRESS=(PROTOCOL=TCP)(HOST=127.0.0.1)(PORT=1521)))
004+ 
005+   VERSION INFORMATION:
006+ 	TNS for Linux: Version 11.2.0.2.0 - Beta
007+ 	TCP/IP NT Protocol Adapter for Linux: Version 11.2.0.2.0 - Beta
008+   Time: 17-JUN-2018 09:51:22
009+   Tracing not turned on.
010+   Tns error struct:
011+     ns main err code: 12541
012+     TNS-12541: TNS:no listener
013+     ns secondary err code: 12560
014+     nt main err code: 511
015+     TNS-00511: No listener
016+ 
017+ Fatal error: Uncaught PDOException: SQLSTATE[HY000]: pdo_oci_handle_factory: ORA-12541: TNS:no listener
018+  (/var/php_gcov/PHP_HEAD/ext/pdo_oci/oci_driver.c:634) in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc:35
019+ Stack trace:
020+ #0 /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc(35): PDO->__construct('oci:dbname=//lo...', 'system', 'oracle', NULL)
021+ #1 /var/php_gcov/PHP_HEAD/ext/pdo_oci/tests/pdo_oci_attr_autocommit_2.php(4): PDOTest::factory()
022+ #2 {main}
023+   thrown in /var/php_gcov/PHP_HEAD/ext/pdo/tests/pdo_test.inc on line 35
024+     nt secondary err code: 111
001- Test 1 Check beginTransaction insertion
002- Test 2 Cause an exception and test beginTransaction rollback
003- Caught expected exception at line 35
004- SQLSTATE[HY000]: General error: 12899 OCIStmtExecute: ORA-12899: %s
006- Test 3 Setting ATTR_AUTOCOMMIT to true will commit and end the transaction
007- PDO::ATTR_AUTOCOMMIT: bool(true)
008- Caught expected exception at line %d
009- There is no active transaction
010- Test 4 Setting ATTR_AUTOCOMMIT to false will commit and end the transaction
011- PDO::ATTR_AUTOCOMMIT: bool(false)
012- Caught expected exception at line %d
013- There is no active transaction
014- Test 5 Handle transactions ourselves
015- PDO::ATTR_AUTOCOMMIT: bool(false)
016- Query Results are:
017- data 1
018- data 2
019- data 3
020- data 4
021- data 5
022- data 6
023- Done

 

Generated at Mon, 18 Jun 2018 17:33:50 +0000 (20 hours ago)

Copyright © 2005-2018 The PHP Group
All rights reserved.