sixd            Tue Mar  4 21:46:24 2008 UTC

  Added files:                 (Branch: PHP_5_3)
    /php-src/ext/oci8/tests     bind_char_1.phpt bind_char_2.phpt 
                                bind_char_3.phpt bind_char_4.phpt 
                                bug41069.phpt 

  Modified files:              
    /php-src/ext/oci8   oci8_statement.c 
  Log:
  MFH Fix bug #41069 (db link crash).  Also allow SQLT_AFC (aka CHAR datatype) 
in oci_bind_by_name
  
http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/oci8_statement.c?r1=1.7.2.14.2.28.2.4&r2=1.7.2.14.2.28.2.5&diff_format=u
Index: php-src/ext/oci8/oci8_statement.c
diff -u php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.28.2.4 
php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.28.2.5
--- php-src/ext/oci8/oci8_statement.c:1.7.2.14.2.28.2.4 Mon Feb 25 23:50:51 2008
+++ php-src/ext/oci8/oci8_statement.c   Tue Mar  4 21:46:24 2008
@@ -25,7 +25,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: oci8_statement.c,v 1.7.2.14.2.28.2.4 2008/02/25 23:50:51 sixd Exp $ */
+/* $Id: oci8_statement.c,v 1.7.2.14.2.28.2.5 2008/03/04 21:46:24 sixd Exp $ */
 
 
 #ifdef HAVE_CONFIG_H
@@ -125,22 +125,13 @@
  Set prefetch buffer size for the statement (we're assuming that one row is 
~1K sized) */
 int php_oci_statement_set_prefetch(php_oci_statement *statement, long size 
TSRMLS_DC)
 { 
-       ub4 prefetch = size * 1024;
+       ub4 prefetch = size;
 
        if (size < 1) {
                php_error_docref(NULL TSRMLS_CC, E_WARNING, "Number of rows has 
to be greater than or equal to 1");
                return 1;
        }
        
-       PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, 
OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_MEMORY, statement->err));
-
-       if (statement->errcode != OCI_SUCCESS) {
-               php_oci_error(statement->err, statement->errcode TSRMLS_CC);
-               PHP_OCI_HANDLE_ERROR(statement->connection, statement->errcode);
-               return 1;
-       }
-
-       prefetch = size;
        PHP_OCI_CALL_RETURN(statement->errcode, OCIAttrSet, (statement->stmt, 
OCI_HTYPE_STMT, &prefetch, 0, OCI_ATTR_PREFETCH_ROWS, statement->err));
        
        if (statement->errcode != OCI_SUCCESS) {
@@ -975,8 +966,8 @@
                case SQLT_LBI:
                case SQLT_BIN:
                case SQLT_LNG:
-               case SQLT_CHR:
-                       /* this is the default case when type was not specified 
*/
+               case SQLT_AFC:
+               case SQLT_CHR: /* SQLT_CHR is the default value when type was 
not specified */
                        if (Z_TYPE_P(var) != IS_NULL) {
                                convert_to_string(var);
                        }

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bind_char_1.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bind_char_1.phpt
+++ php-src/ext/oci8/tests/bind_char_1.phpt
--TEST--
SELECT oci_bind_by_name with SQLT_AFC aka CHAR
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
        "drop table bind_char_tab",
        "create table bind_char_tab (id number, c1 char(10), c2 varchar2(10))",
        "insert into bind_char_tab values (1, 'abc', NULL)",
        "insert into bind_char_tab values (2, NULL, 'abc')",
        "insert into bind_char_tab values (3, NULL, 'abc       ')"
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}

// Run Test

echo "*** Non-null Data Tests against CHAR***\n";

$bv1 = 'abc';

echo "Test 1.1: Type: default.  Length: default\n";
$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv");
$r = oci_bind_by_name($s, ":bv", $bv1);
if ($r)
        do_e_q($s);

echo "Test 1.2: Type: AFC.  Length: default\n";
$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.3: Type: AFC:  Length: 0\n";
$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.4: Type: AFC:  Length: strlen\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.5: Type: AFC.  Length: strlen-1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.6: Type: AFC.  Length: strlen+1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "\n\n*** NULL data tests against CHAR ***\n";

$bv1 = null;

echo "Test 2.1: Type: default.  Length: default\n";
$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv");
$r = oci_bind_by_name($s, ":bv", $bv1);
if ($r)
        do_e_q($s);

echo "Test 2.2: Type: AFC.  Length: default\n";
$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 2.3: Type: AFC:  Length: 0\n";
$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 2.4: Type: AFC:  Length: strlen\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 2.5: Type: AFC.  Length: strlen-1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 2.6: Type: AFC.  Length: strlen+1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e_q($s);


echo "\n\n*** Non-null Data Tests against VARCHAR2***\n";

$bv1 = 'abc';

echo "Test 3.1: Type: default.  Length: default\n";
$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv");
$r = oci_bind_by_name($s, ":bv", $bv1);
if ($r)
        do_e_q($s);

echo "Test 3.2: Type: AFC.  Length: default\n";
$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 3.3: Type: AFC:  Length: 0\n";
$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 3.4: Type: AFC:  Length: strlen\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 3.5: Type: AFC.  Length: strlen-1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 3.6: Type: AFC.  Length: strlen+1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e_q($s);


echo "\n\n*** NULL data tests against VARCHAR2 ***\n";

$bv1 = null;

echo "Test 4.1: Type: default.  Length: default\n";
$s = oci_parse($c, "select * from bind_char_tab where c2 = :bv");
$r = oci_bind_by_name($s, ":bv", $bv1);
if ($r)
        do_e_q($s);

echo "Test 4.2: Type: AFC.  Length: default\n";
$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 4.3: Type: AFC:  Length: 0\n";
$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 4.4: Type: AFC:  Length: strlen\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 4.5: Type: AFC.  Length: strlen-1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 4.6: Type: AFC.  Length: strlen+1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e_q($s);



function do_e_q($s)
{
        echo "  Querying:\n";

        $r = @oci_execute($s);
        if (!$r) {
                $m = oci_error($s);
                echo "    Oci_execute error ORA-".$m['code']." Exiting Query\n";
                return;
        }
        while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) {
                foreach ($row as $item) {
                        echo "    :" . $item . ":\n";
                }
        }
}

// Cleanup
$stmtarray = array(
        "drop table bind_char_tab"
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

echo "Done\n";

?>
--EXPECT--
*** Non-null Data Tests against CHAR***
Test 1.1: Type: default.  Length: default
  Querying:
Test 1.2: Type: AFC.  Length: default
  Querying:
    :1:
    :abc       :
    ::
Test 1.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.4: Type: AFC:  Length: strlen
  Querying:
    :1:
    :abc       :
    ::
Test 1.5: Type: AFC.  Length: strlen-1
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.6: Type: AFC.  Length: strlen+1
  Querying:
    :1:
    :abc       :
    ::


*** NULL data tests against CHAR ***
Test 2.1: Type: default.  Length: default
  Querying:
Test 2.2: Type: AFC.  Length: default
  Querying:
Test 2.3: Type: AFC:  Length: 0
  Querying:
Test 2.4: Type: AFC:  Length: strlen
  Querying:
Test 2.5: Type: AFC.  Length: strlen-1
  Querying:
Test 2.6: Type: AFC.  Length: strlen+1
  Querying:


*** Non-null Data Tests against VARCHAR2***
Test 3.1: Type: default.  Length: default
  Querying:
    :2:
    ::
    :abc:
Test 3.2: Type: AFC.  Length: default
  Querying:
    :2:
    ::
    :abc:
Test 3.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 3.4: Type: AFC:  Length: strlen
  Querying:
    :2:
    ::
    :abc:
Test 3.5: Type: AFC.  Length: strlen-1
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 3.6: Type: AFC.  Length: strlen+1
  Querying:
    :2:
    ::
    :abc:


*** NULL data tests against VARCHAR2 ***
Test 4.1: Type: default.  Length: default
  Querying:
Test 4.2: Type: AFC.  Length: default
  Querying:
Test 4.3: Type: AFC:  Length: 0
  Querying:
Test 4.4: Type: AFC:  Length: strlen
  Querying:
Test 4.5: Type: AFC.  Length: strlen-1
  Querying:
Test 4.6: Type: AFC.  Length: strlen+1
  Querying:
Done
--UEXPECT--
*** Non-null Data Tests against CHAR***
Test 1.1: Type: default.  Length: default
  Querying:
Test 1.2: Type: AFC.  Length: default
  Querying:
    :1:
    :abc       :
    ::
Test 1.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.4: Type: AFC:  Length: strlen
  Querying:
    :1:
    :abc       :
    ::
Test 1.5: Type: AFC.  Length: strlen-1
  Querying:
    :1:
    :abc       :
    ::
Test 1.6: Type: AFC.  Length: strlen+1
  Querying:
    :1:
    :abc       :
    ::


*** NULL data tests against CHAR ***
Test 2.1: Type: default.  Length: default
  Querying:
Test 2.2: Type: AFC.  Length: default
  Querying:
Test 2.3: Type: AFC:  Length: 0
  Querying:
Test 2.4: Type: AFC:  Length: strlen
  Querying:
Test 2.5: Type: AFC.  Length: strlen-1
  Querying:
Test 2.6: Type: AFC.  Length: strlen+1
  Querying:


*** Non-null Data Tests against VARCHAR2***
Test 3.1: Type: default.  Length: default
  Querying:
    :2:
    ::
    :abc:
Test 3.2: Type: AFC.  Length: default
  Querying:
    :2:
    ::
    :abc:
Test 3.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 3.4: Type: AFC:  Length: strlen
  Querying:
    :2:
    ::
    :abc:
Test 3.5: Type: AFC.  Length: strlen-1
  Querying:
    :2:
    ::
    :abc:
Test 3.6: Type: AFC.  Length: strlen+1
  Querying:
    :2:
    ::
    :abc:


*** NULL data tests against VARCHAR2 ***
Test 4.1: Type: default.  Length: default
  Querying:
Test 4.2: Type: AFC.  Length: default
  Querying:
Test 4.3: Type: AFC:  Length: 0
  Querying:
Test 4.4: Type: AFC:  Length: strlen
  Querying:
Test 4.5: Type: AFC.  Length: strlen-1
  Querying:
Test 4.6: Type: AFC.  Length: strlen+1
  Querying:
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bind_char_2.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bind_char_2.phpt
+++ php-src/ext/oci8/tests/bind_char_2.phpt
--TEST--
SELECT oci_bind_by_name with SQLT_AFC aka CHAR and dates
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
        "alter session set nls_date_format='YYYY-MM-DD'",
        "drop table bind_char_tab",
        "create table bind_char_tab (id number, c1 date)",
        "insert into bind_char_tab values (1, '2008-04-20')",
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}

// Run Test

$bv1 = '2008-04-20';

echo "Test 1.1: Type: default.  Length: default\n";
$s = oci_parse($c, "select * from bind_char_tab where c1 = :bv");
$r = oci_bind_by_name($s, ":bv", $bv1);
if ($r)
   do_e_q($s);

echo "Test 1.2: Type: AFC.  Length: default\n";
$r = oci_bind_by_name($s, ":bv", $bv1, -1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.3: Type: AFC:  Length: 0\n";
$r = oci_bind_by_name($s, ":bv", $bv1, 0, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.4: Type: AFC:  Length: strlen\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1), SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.5: Type: AFC.  Length: strlen-1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e_q($s);

echo "Test 1.6: Type: AFC.  Length: strlen+1\n";
$r = oci_bind_by_name($s, ":bv", $bv1, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e_q($s);


function do_e_q($s)
{
        echo "  Querying:\n";

        $r = @oci_execute($s);
        if (!$r) {
                $m = oci_error($s);
                echo "    Oci_execute error ORA-".$m['code']." Exiting Query\n";
                return;
        }
        while ($row = oci_fetch_array($s, OCI_ASSOC+OCI_RETURN_NULLS)) {
                foreach ($row as $item) {
                        echo "    :" . $item . ":\n";
                }
        }
}

// Cleanup
$stmtarray = array(
        "drop table bind_char_tab"
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

echo "Done\n";

?>
--EXPECT--
Test 1.1: Type: default.  Length: default
  Querying:
    :1:
    :2008-04-20:
Test 1.2: Type: AFC.  Length: default
  Querying:
    :1:
    :2008-04-20:
Test 1.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.4: Type: AFC:  Length: strlen
  Querying:
    :1:
    :2008-04-20:
Test 1.5: Type: AFC.  Length: strlen-1
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.6: Type: AFC.  Length: strlen+1
  Querying:
    :1:
    :2008-04-20:
Done
--UEXPECT--
Test 1.1: Type: default.  Length: default
  Querying:
    :1:
    :2008-04-20:
Test 1.2: Type: AFC.  Length: default
  Querying:
    :1:
    :2008-04-20:
Test 1.3: Type: AFC:  Length: 0
  Querying:
    Oci_execute error ORA-1460 Exiting Query
Test 1.4: Type: AFC:  Length: strlen
  Querying:
    :1:
    :2008-04-20:
Test 1.5: Type: AFC.  Length: strlen-1
  Querying:
    :1:
    :2008-04-20:
Test 1.6: Type: AFC.  Length: strlen+1
  Querying:
    :1:
    :2008-04-20:
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bind_char_3.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bind_char_3.phpt
+++ php-src/ext/oci8/tests/bind_char_3.phpt
--TEST--
PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to CHAR parameter
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
        "create or replace function bind_char_3_fn(p1 char) return char as 
begin return p1; end;",
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}

// Run Test

echo "Test 1.1 In Length: default.  In Type: default.  Out Length: default.     
     Out Type: default\n";

$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;");
$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);

echo "Test 1.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input).    Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input)-1.  Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input)+1.  Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "\n\nTests with ''\n\n";

echo "Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 2.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "\n\nTests with NULL\n";

echo "Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 3.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.           
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


function do_e($s)
{
        echo "  Executing:\n";

        $r = @oci_execute($s);
        if (!$r) {
                $m = oci_error($s);
                echo "    Oci_execute error ORA-".$m['code']."\n";
                return;
        }
}

// Cleanup

//require(dirname(__FILE__).'/drop_table.inc');

$stmtarray = array(
        "drop function bind_char_3_fn"
);

foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

echo "Done\n";

?>
--EXPECTF--
Test 1.1 In Length: default.  In Type: default.  Out Length: default.          
Out Type: default
  Executing:
    Oci_execute error ORA-6502
string(3) "abc"
NULL
Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(3) "abc"
string(10) "abc       "
Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: strlen(input).    
Out Type: AFC
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)-1.  
Out Type: AFC
  Executing:
    Oci_execute error ORA-6502
string(3) "abc"
string(3) "abc"
Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)+1.  
Out Type: AFC
  Executing:
string(3) "abc"
string(4) "abc "


Tests with ''

Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
string(0) ""
NULL
Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
string(0) ""
NULL
Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
string(0) ""
NULL


Tests with NULL
Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
NULL
NULL
Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
NULL
NULL
Done
--UEXPECT--
Test 1.1 In Length: default.  In Type: default.  Out Length: default.          
Out Type: default
  Executing:
    Oci_execute error ORA-6502
unicode(3) "abc"
NULL
Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
unicode(3) "abc"
unicode(3) "abc"
Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
unicode(3) "abc"
unicode(3) "abc"
Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(20) "abc                 "
Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: strlen(input).    
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(6) "abc   "
Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)-1.  
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(4) "abc "
Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)+1.  
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(8) "abc     "


Tests with ''

Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
unicode(0) ""
NULL
Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
unicode(0) ""
NULL
Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL


Tests with NULL
Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
NULL
NULL
Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
NULL
NULL
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bind_char_4.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bind_char_4.phpt
+++ php-src/ext/oci8/tests/bind_char_4.phpt
--TEST--
PL/SQL oci_bind_by_name with SQLT_AFC aka CHAR to VARCHAR2 parameter
--SKIPIF--
<?php if (!extension_loaded('oci8')) die ("skip no oci8 extension"); ?>
--FILE--
<?php

// Same test as bind_char_3 but the PL/SQL function uses VARCHAR2 instead of 
CHAR

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
        "create or replace function bind_char_3_fn(p1 varchar2) return varchar2 
as begin return p1; end;",
);
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}

// Run Test

echo "Test 1.1 In Length: default.  In Type: default.  Out Length: default.     
     Out Type: default\n";

$s = oci_parse($c, "begin :bv2 := bind_char_3_fn(:bv1); end;");
$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);

echo "Test 1.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input).    Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1), SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input)-1.  Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)-1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: 
strlen(input)+1.  Out Type: AFC\n";

$bv1 = 'abc';
$r = oci_bind_by_name($s, ':bv1', $bv1, strlen($bv1), SQLT_AFC) && 
oci_bind_by_name($s, ':bv2', $bv2, strlen($bv1)+1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "\n\nTests with ''\n\n";

echo "Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 2.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, 0, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.           
     Out Type: AFC\n";

$bv1 = '';
$r = oci_bind_by_name($s, ':bv1', $bv1, 1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "\n\nTests with NULL\n";

echo "Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 3.2 In Length: default.  In Type: default.  Out Length: 10.          
     Out Type: default\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1) && oci_bind_by_name($s, ':bv2', $bv2, 
10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: default\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.          
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 10, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


echo "Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.           
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 0, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);



echo "Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.           
     Out Type: AFC\n";

$bv1 = null;
$r = oci_bind_by_name($s, ':bv1', $bv1, -1, SQLT_AFC) && oci_bind_by_name($s, 
':bv2', $bv2, 1, SQLT_AFC);
if ($r)
        do_e($s);
var_dump($bv1, $bv2);


function do_e($s)
{
        echo "  Executing:\n";

        $r = @oci_execute($s);
        if (!$r) {
                $m = oci_error($s);
                echo "    Oci_execute error ORA-".$m['code']."\n";
                return;
        }
}

// Cleanup

//require(dirname(__FILE__).'/drop_table.inc');

$stmtarray = array(
        "drop function bind_char_3_fn"
);

foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

echo "Done\n";

?>
--EXPECTF--
Test 1.1 In Length: default.  In Type: default.  Out Length: default.          
Out Type: default
  Executing:
    Oci_execute error ORA-6502
string(3) "abc"
NULL
Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(3) "abc"
string(10) "abc       "
Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: strlen(input).    
Out Type: AFC
  Executing:
string(3) "abc"
string(3) "abc"
Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)-1.  
Out Type: AFC
  Executing:
    Oci_execute error ORA-6502
string(3) "abc"
string(3) "abc"
Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)+1.  
Out Type: AFC
  Executing:
string(3) "abc"
string(4) "abc "


Tests with ''

Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
string(0) ""
NULL
Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
string(0) ""
NULL
Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
string(0) ""
NULL
Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
string(0) ""
NULL


Tests with NULL
Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
NULL
NULL
Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
NULL
NULL
Done
--UEXPECT--
Test 1.1 In Length: default.  In Type: default.  Out Length: default.          
Out Type: default
  Executing:
    Oci_execute error ORA-6502
unicode(3) "abc"
NULL
Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
unicode(3) "abc"
unicode(3) "abc"
Test 1.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
unicode(3) "abc"
unicode(3) "abc"
Test 1.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(20) "abc                 "
Test 1.5 In Length: strlen.   In Type: AFC.      Out Length: strlen(input).    
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(6) "abc   "
Test 1.6 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)-1.  
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(4) "abc "
Test 1.7 In Length: strlen.   In Type: AFC.      Out Length: strlen(input)+1.  
Out Type: AFC
  Executing:
unicode(3) "abc"
unicode(8) "abc     "


Tests with ''

Test 2.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
unicode(0) ""
NULL
Test 2.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
unicode(0) ""
NULL
Test 2.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.6 In Length: 0.        In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL
Test 2.7 In Length: 1.        In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
unicode(0) ""
NULL


Tests with NULL
Test 3.1 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.2 In Length: default.  In Type: default.  Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.3 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: default
  Executing:
NULL
NULL
Test 3.4 In Length: -1.       In Type: AFC.      Out Length: 10.               
Out Type: AFC
  Executing:
NULL
NULL
Test 3.5 In Length: -1.       In Type: AFC.      Out Length: 0.                
Out Type: AFC
  Executing:
NULL
NULL
Test 3.6 In Length: -1.       In Type: AFC.      Out Length: 1.                
Out Type: AFC
  Executing:
NULL
NULL
Done

http://cvs.php.net/viewvc.cgi/php-src/ext/oci8/tests/bug41069.phpt?view=markup&rev=1.1
Index: php-src/ext/oci8/tests/bug41069.phpt
+++ php-src/ext/oci8/tests/bug41069.phpt
--TEST--
Bug #41069 (Oracle crash with certain data over a DB-link when prefetch memory 
limit used - Oracle bug 6039623)
--SKIPIF--
<?php 
if (!extension_loaded('oci8')) die ("skip no oci8 extension"); 
require(dirname(__FILE__).'/details.inc');
if (empty($dbase)) die ("skip requires network connection alias for DB link 
loopback");
if ($test_drcp) die("skip DRCP does not support shared database links");
?>
--INI--
oci8.default_prefetch=5
--FILE--
<?php

require(dirname(__FILE__).'/connect.inc');

// Initialization

$stmtarray = array(
        "alter session set nls_date_format = 'MM/DD/YYYY'",

        "drop database link bug41069_dblink",

        "drop table bug41069_tab",

        "create shared database link bug41069_dblink authenticated by $user 
identified by $password using '$dbase'",

        "create table bug41069_tab
        (
                c1  number(20),
                c2  varchar2(60 byte),
                c3  varchar2(1000 byte),
                c4  varchar2(255 byte),
                c5  varchar2(2 byte),
                c6  varchar2(1 byte),
                c7  varchar2(255 byte),
                c8  varchar2(50 byte),
                c9  date,
                c10 date,
                c12 number(20),
                c13 varchar2(20 byte),
                c15 varchar2(50 byte)
         )",

        "insert into bug41069_tab (c1, c2, c5, c6, c9, c10, c12, c15)   values
        (111, 'aaaaaaa', 'b', 'c', '01/17/2008', '01/07/2017', 2222, 
'zzzzzzzzzz')",

        "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, 
c13, c15) values
        (112, 'aaaaaaa', 'bbbbbbbb', 'ccccccc', 'd', 'e', 'rrrrrrr', 
'04/16/2007', '04/16/2007', 2223, 'xxxxxxxx', 'zzzzzzzz')",

        "insert into bug41069_tab (c1, c2, c3, c4, c5, c6, c7, c9, c10, c12, 
c15)       values
        (113, 'aaaaaaa', 'bbbbbbbbbb', 'cccccc', 'e', 'f', 'dddd', 
'12/04/2006', '12/04/2006', 2224, 'zzzzzzz')"
                                   );
                                                 
foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        @oci_execute($s);
}


// Run Tests

echo "Test 1: non-DB link case that always worked\n";
$stid = oci_parse($c, 'select * from bug41069_tab order by c1');
oci_execute($stid, OCI_DEFAULT);
oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW);
var_dump($results);

echo "Test 2: Should not crash\n";
$stid = oci_parse($c, 'select * from [EMAIL PROTECTED] order by c1');
oci_execute($stid, OCI_DEFAULT);
oci_fetch_all($stid, $results, 0, -1, OCI_ASSOC+OCI_FETCHSTATEMENT_BY_ROW);
var_dump($results);

// Cleanup

$c = oci_new_connect($user, $password, $dbase);

$stmtarray = array(
        "drop database link bug41069_dblink",
        "drop table bug41069_tab"
                                   );

foreach ($stmtarray as $stmt) {
        $s = oci_parse($c, $stmt);
        oci_execute($s);
}

oci_close($c);

echo "Done\n";

?>
--EXPECT--
Test 1: non-DB link case that always worked
array(3) {
  [0]=>
  array(13) {
    ["C1"]=>
    string(3) "111"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    NULL
    ["C4"]=>
    NULL
    ["C5"]=>
    string(1) "b"
    ["C6"]=>
    string(1) "c"
    ["C7"]=>
    NULL
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "01/17/2008"
    ["C10"]=>
    string(10) "01/07/2017"
    ["C12"]=>
    string(4) "2222"
    ["C13"]=>
    NULL
    ["C15"]=>
    string(10) "zzzzzzzzzz"
  }
  [1]=>
  array(13) {
    ["C1"]=>
    string(3) "112"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    string(8) "bbbbbbbb"
    ["C4"]=>
    string(7) "ccccccc"
    ["C5"]=>
    string(1) "d"
    ["C6"]=>
    string(1) "e"
    ["C7"]=>
    string(7) "rrrrrrr"
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "04/16/2007"
    ["C10"]=>
    string(10) "04/16/2007"
    ["C12"]=>
    string(4) "2223"
    ["C13"]=>
    string(8) "xxxxxxxx"
    ["C15"]=>
    string(8) "zzzzzzzz"
  }
  [2]=>
  array(13) {
    ["C1"]=>
    string(3) "113"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    string(10) "bbbbbbbbbb"
    ["C4"]=>
    string(6) "cccccc"
    ["C5"]=>
    string(1) "e"
    ["C6"]=>
    string(1) "f"
    ["C7"]=>
    string(4) "dddd"
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "12/04/2006"
    ["C10"]=>
    string(10) "12/04/2006"
    ["C12"]=>
    string(4) "2224"
    ["C13"]=>
    NULL
    ["C15"]=>
    string(7) "zzzzzzz"
  }
}
Test 2: Should not crash
array(3) {
  [0]=>
  array(13) {
    ["C1"]=>
    string(3) "111"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    NULL
    ["C4"]=>
    NULL
    ["C5"]=>
    string(1) "b"
    ["C6"]=>
    string(1) "c"
    ["C7"]=>
    NULL
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "01/17/2008"
    ["C10"]=>
    string(10) "01/07/2017"
    ["C12"]=>
    string(4) "2222"
    ["C13"]=>
    NULL
    ["C15"]=>
    string(10) "zzzzzzzzzz"
  }
  [1]=>
  array(13) {
    ["C1"]=>
    string(3) "112"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    string(8) "bbbbbbbb"
    ["C4"]=>
    string(7) "ccccccc"
    ["C5"]=>
    string(1) "d"
    ["C6"]=>
    string(1) "e"
    ["C7"]=>
    string(7) "rrrrrrr"
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "04/16/2007"
    ["C10"]=>
    string(10) "04/16/2007"
    ["C12"]=>
    string(4) "2223"
    ["C13"]=>
    string(8) "xxxxxxxx"
    ["C15"]=>
    string(8) "zzzzzzzz"
  }
  [2]=>
  array(13) {
    ["C1"]=>
    string(3) "113"
    ["C2"]=>
    string(7) "aaaaaaa"
    ["C3"]=>
    string(10) "bbbbbbbbbb"
    ["C4"]=>
    string(6) "cccccc"
    ["C5"]=>
    string(1) "e"
    ["C6"]=>
    string(1) "f"
    ["C7"]=>
    string(4) "dddd"
    ["C8"]=>
    NULL
    ["C9"]=>
    string(10) "12/04/2006"
    ["C10"]=>
    string(10) "12/04/2006"
    ["C12"]=>
    string(4) "2224"
    ["C13"]=>
    NULL
    ["C15"]=>
    string(7) "zzzzzzz"
  }
}
Done
--UEXPECT--
Test 1: non-DB link case that always worked
array(3) {
  [0]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "111"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    NULL
    [u"C4"]=>
    NULL
    [u"C5"]=>
    unicode(1) "b"
    [u"C6"]=>
    unicode(1) "c"
    [u"C7"]=>
    NULL
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "01/17/2008"
    [u"C10"]=>
    unicode(10) "01/07/2017"
    [u"C12"]=>
    unicode(4) "2222"
    [u"C13"]=>
    NULL
    [u"C15"]=>
    unicode(10) "zzzzzzzzzz"
  }
  [1]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "112"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    unicode(8) "bbbbbbbb"
    [u"C4"]=>
    unicode(7) "ccccccc"
    [u"C5"]=>
    unicode(1) "d"
    [u"C6"]=>
    unicode(1) "e"
    [u"C7"]=>
    unicode(7) "rrrrrrr"
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "04/16/2007"
    [u"C10"]=>
    unicode(10) "04/16/2007"
    [u"C12"]=>
    unicode(4) "2223"
    [u"C13"]=>
    unicode(8) "xxxxxxxx"
    [u"C15"]=>
    unicode(8) "zzzzzzzz"
  }
  [2]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "113"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    unicode(10) "bbbbbbbbbb"
    [u"C4"]=>
    unicode(6) "cccccc"
    [u"C5"]=>
    unicode(1) "e"
    [u"C6"]=>
    unicode(1) "f"
    [u"C7"]=>
    unicode(4) "dddd"
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "12/04/2006"
    [u"C10"]=>
    unicode(10) "12/04/2006"
    [u"C12"]=>
    unicode(4) "2224"
    [u"C13"]=>
    NULL
    [u"C15"]=>
    unicode(7) "zzzzzzz"
  }
}
Test 2: Should not crash
array(3) {
  [0]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "111"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    NULL
    [u"C4"]=>
    NULL
    [u"C5"]=>
    unicode(1) "b"
    [u"C6"]=>
    unicode(1) "c"
    [u"C7"]=>
    NULL
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "01/17/2008"
    [u"C10"]=>
    unicode(10) "01/07/2017"
    [u"C12"]=>
    unicode(4) "2222"
    [u"C13"]=>
    NULL
    [u"C15"]=>
    unicode(10) "zzzzzzzzzz"
  }
  [1]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "112"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    unicode(8) "bbbbbbbb"
    [u"C4"]=>
    unicode(7) "ccccccc"
    [u"C5"]=>
    unicode(1) "d"
    [u"C6"]=>
    unicode(1) "e"
    [u"C7"]=>
    unicode(7) "rrrrrrr"
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "04/16/2007"
    [u"C10"]=>
    unicode(10) "04/16/2007"
    [u"C12"]=>
    unicode(4) "2223"
    [u"C13"]=>
    unicode(8) "xxxxxxxx"
    [u"C15"]=>
    unicode(8) "zzzzzzzz"
  }
  [2]=>
  array(13) {
    [u"C1"]=>
    unicode(3) "113"
    [u"C2"]=>
    unicode(7) "aaaaaaa"
    [u"C3"]=>
    unicode(10) "bbbbbbbbbb"
    [u"C4"]=>
    unicode(6) "cccccc"
    [u"C5"]=>
    unicode(1) "e"
    [u"C6"]=>
    unicode(1) "f"
    [u"C7"]=>
    unicode(4) "dddd"
    [u"C8"]=>
    NULL
    [u"C9"]=>
    unicode(10) "12/04/2006"
    [u"C10"]=>
    unicode(10) "12/04/2006"
    [u"C12"]=>
    unicode(4) "2224"
    [u"C13"]=>
    NULL
    [u"C15"]=>
    unicode(7) "zzzzzzz"
  }
}
Done

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to