if (Z_TYPE_P(var) != IS_NULL) {
convert_to_string(var);
}
- if (maxlength == -1) {
- /*
- value_sz = (Z_TYPE_P(var) == IS_STRING) ? Z_STRLEN_P(var) : PHP_OCI_PIECE_SIZE;
- */
- /* We should use max length as dynamic bind is used */
- value_sz = PHP_OCI_PIECE_SIZE;
- } else {
- if (maxlength == 0) {
- value_sz = PHP_OCI_PIECE_SIZE;
+ if ((maxlength == -1) || (maxlength == 0)) {
+ if (type == SQLT_LNG) {
+ value_sz = SB4MAXVAL;
+ } else if (Z_TYPE_P(var) == IS_STRING) {
+ value_sz = (sb4) Z_STRLEN_P(var);
} else {
- value_sz = (sb4) maxlength;
+ value_sz = PHP_OCI_PIECE_SIZE;
}
+ } else {
+ value_sz = (sb4) maxlength;
}
break;
break;
}
- if (value_sz == 0) {
- value_sz = 1;
- }
-
if (!statement->binds) {
ALLOC_HASHTABLE(statement->binds);
zend_hash_init(statement->binds, 13, NULL, php_oci_bind_hash_dtor, 0);
bindp->parent_statement = statement;
bindp->zval = var;
bindp->type = type;
-
+ /* Storing max length set in OCIBindByName() to check it later in
+ * php_oci_bind_in_callback() function to avoid ORA-1406 error while
+ * executing OCIStmtExecute()
+ */
+ bindp->dummy_len = value_sz;
+
PHP_OCI_CALL_RETURN(errstatus,
OCIBindByName,
(
*bufpp = Z_STRVAL_P(val);
*alenp = (ub4) Z_STRLEN_P(val);
+ /*
+ * bind_char_1: If max length set in OCIBindByName is less than the
+ * actual length of input string, then we have to overwrite alenp with
+ * max value set in OCIBindByName (dummy_len). Or else it will cause
+ * ORA-1406 error in OCIStmtExecute
+ */
+ if ((phpbind->dummy_len > 0) && (phpbind->dummy_len < *alenp))
+ *alenp = phpbind->dummy_len;
*indpp = (dvoid *)&phpbind->indicator;
} else if (phpbind->statement != 0) {
/* RSET */
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
::
Test 1.5: Type: AFC. Length: strlen-1
Querying:
- :1:
- :abc :
- ::
Test 1.6: Type: AFC. Length: strlen+1
Querying:
:1:
:abc:
Test 3.5: Type: AFC. Length: strlen-1
Querying:
- :2:
- ::
- :abc:
Test 3.6: Type: AFC. Length: strlen+1
Querying:
:2:
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
::
Test 1.3: Type: AFC: Length: 0
Querying:
- Oci_execute error ORA-1460 Exiting Query
+ :1:
+ :abc :
+ ::
Test 1.4: Type: AFC: Length: strlen
Querying:
:1:
::
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:
Test 3.3: Type: AFC: Length: 0
Querying:
- Oci_execute error ORA-1460 Exiting Query
+ :2:
+ ::
+ :abc:
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:
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
:2008-04-20:
Test 1.3: Type: AFC: Length: 0
Querying:
- Oci_execute error ORA-1460 Exiting Query
+ :1:
+ :2008-04-20:
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:
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
:2008-04-20:
Test 1.3: Type: AFC: Length: 0
Querying:
- Oci_execute error ORA-1460 Exiting Query
+ :1:
+ :2008-04-20:
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:
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
Executing:
string(3) "abc"
-string(30) "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(9) "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"
-string(6) "abc "
Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC
Executing:
string(3) "abc"
-string(12) "abc "
+string(4) "abc "
Tests with ''
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
--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
+string(3) "abc"
Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default
Executing:
string(3) "abc"
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
Test 1.4 In Length: -1. In Type: AFC. Out Length: 10. Out Type: AFC
Executing:
string(3) "abc"
-string(30) "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(9) "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"
-string(6) "abc "
Test 1.7 In Length: strlen. In Type: AFC. Out Length: strlen(input)+1. Out Type: AFC
Executing:
string(3) "abc"
-string(12) "abc "
+string(4) "abc "
Tests with ''
}
?>
--ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
--FILE--
<?php
--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
+string(3) "abc"
Test 1.2 In Length: default. In Type: default. Out Length: 10. Out Type: default
Executing:
string(3) "abc"
$stmt = oci_parse ($c, "insert into phptestlng (id, filetxt) values (:id, :filetxt)");
$i=1;
-$filetxt = file_get_contents( dirname(__FILE__)."/test.txt");
-
+$filetxt1 = file_get_contents( dirname(__FILE__)."/test.txt");
+$filetxt = str_replace("\r", "", $filetxt1);
oci_bind_by_name( $stmt, ":id", $i, -1);
oci_bind_by_name( $stmt, ":filetxt", $filetxt, -1, SQLT_LNG);
Test 1
array(5) {
[0]=>
- string(4) "five"
+ string(3) "one"
[1]=>
- string(4) "four"
+ string(3) "two"
[2]=>
string(5) "three"
[3]=>
- string(3) "two"
+ string(4) "four"
[4]=>
- string(3) "one"
+ string(4) "five"
}
array(5) {
[0]=>
var_dump($row = oci_fetch_array($s));
while (!$row[0]->eof()) {
- var_dump($row[0]->read(1024));
+ var_dump(str_replace("\r", "", $row[0]->read(1024)));
}
require dirname(__FILE__).'/drop_table.inc';
var_dump($row = oci_fetch_array($s));
while (!$row[0]->eof()) {
- var_dump($row[0]->read(1024));
+ var_dump(str_replace("\r", "", $row[0]->read(1024)));
}
require dirname(__FILE__).'/drop_table.inc';