~ubuntu-branches/ubuntu/maverick/php5/maverick-proposed

« back to all changes in this revision

Viewing changes to ext/oci8/tests/commit_002.phpt

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2010-08-01 11:58:54 UTC
  • mfrom: (1.1.19 upstream) (0.4.6 experimental)
  • Revision ID: james.westby@ubuntu.com-20100801115854-30yqnnj2vx87v6no
Tags: 5.3.3-1ubuntu1
Merge from Debian experimental: 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
--TEST--
 
2
Test oci_commit failure
 
3
--SKIPIF--
 
4
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
 
5
--FILE--
 
6
<?php
 
7
 
 
8
require(dirname(__FILE__).'/connect.inc');
 
9
 
 
10
// Initialization
 
11
 
 
12
$stmtarray = array(
 
13
        "drop table commit_002_tab",
 
14
        "create table commit_002_tab
 
15
     ( x int constraint commit_002_tab_check_x check ( x > 0 ) deferrable initially immediate,
 
16
       y int constraint commit_002_tab_check_y check ( y > 0 ) deferrable initially deferred)"
 
17
);
 
18
 
 
19
foreach ($stmtarray as $stmt) {
 
20
        $s = oci_parse($c, $stmt);
 
21
        $r = @oci_execute($s);
 
22
        if (!$r) {
 
23
                $m = oci_error($s);
 
24
                if (!in_array($m['code'], array(   // ignore expected errors
 
25
                            942 // table or view does not exist
 
26
                        ,  2289 // sequence does not exist
 
27
                        ,  4080 // trigger does not exist
 
28
                        , 38802 // edition does not exist
 
29
                ))) {
 
30
                        echo $stmt . PHP_EOL . $m['message'] . PHP_EOL;
 
31
                }
 
32
        }
 
33
}
 
34
 
 
35
// Run Test
 
36
 
 
37
echo "First Insert\n";
 
38
$s = oci_parse($c, "insert into commit_002_tab values (-1, 1)");
 
39
$r = @oci_execute($s, OCI_DEFAULT);
 
40
if (!$r) {
 
41
    $m = oci_error($s);
 
42
    echo 'Could not execute: '. $m['message'] . "\n";
 
43
}
 
44
$r = oci_commit($c);
 
45
if (!$r) {
 
46
    $m = oci_error($c);
 
47
    echo 'Could not commit: '. $m['message'] . "\n";
 
48
}
 
49
 
 
50
 
 
51
echo "Second Insert\n";
 
52
$s = oci_parse($c, "insert into commit_002_tab values (1, -1)");
 
53
$r = @oci_execute($s, OCI_NO_AUTO_COMMIT);
 
54
if (!$r) {
 
55
    $m = oci_error($s);
 
56
    echo 'Could not execute: '. $m['message'] . "\n";
 
57
}
 
58
$r = oci_commit($c);
 
59
if (!$r) {
 
60
    $m = oci_error($c);
 
61
    echo 'Could not commit: '. $m['message'] . "\n";
 
62
}
 
63
 
 
64
 
 
65
// Clean up
 
66
 
 
67
$stmtarray = array(
 
68
        "drop table commit_002_tab"
 
69
);
 
70
 
 
71
foreach ($stmtarray as $stmt) {
 
72
        $s = oci_parse($c, $stmt);
 
73
        oci_execute($s);
 
74
}
 
75
 
 
76
oci_close($c);
 
77
 
 
78
?>
 
79
===DONE===
 
80
<?php exit(0); ?>
 
81
--EXPECTF--
 
82
First Insert
 
83
Could not execute: ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_X) %s
 
84
Second Insert
 
85
 
 
86
Warning: oci_commit(): ORA-02091: %s
 
87
ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s in %scommit_002.php on line %d
 
88
Could not commit: ORA-02091: %s
 
89
ORA-02290: %s (%s.COMMIT_002_TAB_CHECK_Y) %s
 
90
===DONE===