]> granicus.if.org Git - php/commitdiff
Squash some more PHP 7 diffs and improve test portability (Senthil)
authorChristopher Jones <christopher.jones@oracle.com>
Wed, 26 Aug 2015 11:22:58 +0000 (21:22 +1000)
committerChristopher Jones <christopher.jones@oracle.com>
Wed, 26 Aug 2015 11:22:58 +0000 (21:22 +1000)
13 files changed:
ext/oci8/oci8_statement.c
ext/oci8/tests/bind_char_1.phpt
ext/oci8/tests/bind_char_1_11gR1.phpt
ext/oci8/tests/bind_char_2.phpt
ext/oci8/tests/bind_char_2_11gR1.phpt
ext/oci8/tests/bind_char_3.phpt
ext/oci8/tests/bind_char_3_11gR1.phpt
ext/oci8/tests/bind_char_4.phpt
ext/oci8/tests/bind_char_4_11gR1.phpt
ext/oci8/tests/bind_long.phpt
ext/oci8/tests/bug51253.phpt
ext/oci8/tests/lob_009.phpt
ext/oci8/tests/lob_023.phpt

index 3ab249949e7d5f767178d195dc178b20f44ef0b0..a23ed2bbb139ae00941a7e542146f2e93f67f1d0 100644 (file)
@@ -1166,18 +1166,16 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l
                        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;
 
@@ -1225,10 +1223,6 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l
                        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);
@@ -1249,7 +1243,12 @@ int php_oci_bind_by_name(php_oci_statement *statement, char *name, size_t name_l
        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,
                (
@@ -1353,6 +1352,14 @@ sb4 php_oci_bind_in_callback(
 
                *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 */
index dc162ff9431822bd9c5dfe4b26d45dcce82f3787..bb368fc7da98590c9af45c77de8af3c8190caf2e 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] >= 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -223,9 +223,6 @@ Test 1.4: Type: AFC:  Length: strlen
     ::
 Test 1.5: Type: AFC.  Length: strlen-1
   Querying:
-    :1:
-    :abc       :
-    ::
 Test 1.6: Type: AFC.  Length: strlen+1
   Querying:
     :1:
@@ -271,9 +268,6 @@ Test 3.4: Type: AFC:  Length: strlen
     :abc:
 Test 3.5: Type: AFC.  Length: strlen-1
   Querying:
-    :2:
-    ::
-    :abc:
 Test 3.6: Type: AFC.  Length: strlen+1
   Querying:
     :2:
index bdc29f766dab35c0a08a36fde7e153a9bca8e36e..5b22cdc8c4e1d90706a477dbd00bf34a831bce88 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] < 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -215,7 +215,9 @@ Test 1.2: Type: AFC.  Length: default
     ::
 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:
@@ -223,7 +225,6 @@ Test 1.4: Type: AFC:  Length: strlen
     ::
 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:
@@ -259,7 +260,9 @@ Test 3.2: Type: AFC.  Length: default
     :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:
@@ -267,7 +270,6 @@ Test 3.4: Type: AFC:  Length: strlen
     :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:
index 9c61a858c8e7130297c636d2b282dc15e84ab647..57b0c610f1d181645ed6275edbc224fcf8bb0579 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] >= 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -102,15 +102,14 @@ Test 1.2: Type: AFC.  Length: default
     :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:
index 06c37afc93e20d9b535a0aeee22b8fdea158d2c5..438885e12a68ce62d72c47293efed8f2af79b620 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] < 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -102,14 +102,14 @@ Test 1.2: Type: AFC.  Length: default
     :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:
index 177676e25ca3b19d3177dc0369e02ba56ce39aad..67aafae3cc177586c15bfd9f2a03a6ed839108c1 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] >= 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -259,19 +259,20 @@ string(3) "abc"
 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 ''
index c3ec999d0f10d08dd4086dbc5e29680674d47abc..5c8b286249d1258bb76d9b67f69aab4ede45666a 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] < 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -246,9 +246,8 @@ 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
+string(3) "abc"
 Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               Out Type: default
   Executing:
 string(3) "abc"
index b4d3e089b136f34584a9f6a5c98e190a8414107a..9ca369a1727383283518905d22e9661f1f0684c7 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] >= 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -261,19 +261,20 @@ string(3) "abc"
 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 ''
index ccad2cb7894c160dd4a8127f20bc3c7eb5021e3b..56a666e4a55696f3c69be464178d31ccc42f5aa2 100644 (file)
@@ -11,7 +11,7 @@ if (!(isset($matches[0]) && $matches[1] < 12)) {
 }
 ?>
 --ENV--
-NLS_LANG=
+NLS_LANG=.AL32UTF8
 --FILE--
 <?php
 
@@ -248,9 +248,8 @@ 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
+string(3) "abc"
 Test 1.2 In Length: default.  In Type: default.  Out Length: 10.               Out Type: default
   Executing:
 string(3) "abc"
index 40c579992d690b071ded7b6398285eb4fcb0f3b9..cbd83128cb7576c83afdfbdb25ad54db3e5a0312 100644 (file)
@@ -20,8 +20,8 @@ echo "Test 1\n";
 
 $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);
index 111da929bb7ce828014eb82ad32bc313142c93af..b38bc7606b710bb872ff80f804a22f485c9a5bf6 100644 (file)
@@ -93,15 +93,15 @@ echo "Done\n";
 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]=>
index 4702e61acad9c46c7bc9c09aa260aaf59312eef4..dc7c1b462863346d9335234a81fac7d796a6a0ce 100644 (file)
@@ -35,7 +35,7 @@ oci_execute($s, OCI_DEFAULT);
 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';
index 6416fb45a6b55f409f258ccea3992150369eb408..1a1ee80ead905748532b31165340fb844053b94a 100644 (file)
@@ -40,7 +40,7 @@ oci_execute($s, OCI_DEFAULT);
 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';