@@ -21,18 +21,19 @@ $dbh->setAttribute(PDO::ATTR_CASE, PDO::CASE_NATURAL);
2121$ dbh ->setAttribute (PDO ::ATTR_STRINGIFY_FETCHES , false );
2222
2323@$ dbh ->exec ('DROP TABLE pdo_oci_bug60994 ' );
24- $ dbh ->exec ('CREATE TABLE pdo_oci_bug60994 (id NUMBER, data CLOB) ' );
24+ $ dbh ->exec ('CREATE TABLE pdo_oci_bug60994 (id NUMBER, data CLOB, data2 NCLOB ) ' );
2525
2626$ id = null ;
27- $ insert = $ dbh ->prepare ('INSERT INTO pdo_oci_bug60994 (id, data) VALUES (:id, :data) ' );
27+ $ insert = $ dbh ->prepare ('INSERT INTO pdo_oci_bug60994 (id, data, data2 ) VALUES (:id, :data, :data2 ) ' );
2828$ insert ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
29- $ select = $ dbh ->prepare ("SELECT data FROM pdo_oci_bug60994 WHERE id = :id " );
29+ $ select = $ dbh ->prepare ("SELECT data, data2 FROM pdo_oci_bug60994 WHERE id = :id " );
3030
3131
3232echo PHP_EOL , 'Test 1: j ' , PHP_EOL ;
3333$ string1 = 'abc ' . str_repeat ('j ' , 8187 ) . 'xyz ' ; // 8193 chars total works fine here (even 1 million works fine, subject to memory_limit)
3434$ id = 1 ;
3535$ insert ->bindParam (':data ' , $ string1 , \PDO ::PARAM_STR , strlen ($ string1 )); // length in bytes
36+ $ insert ->bindParam (':data2 ' , $ string1 , \PDO ::PARAM_STR , strlen ($ string1 ));
3637$ insert ->execute ();
3738$ select ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
3839$ select ->execute ();
@@ -44,12 +45,15 @@ echo 'size of string1 is ', strlen($string1), ' bytes, ', mb_strlen($string1), '
4445echo 'size of stream1 is ' , strlen ($ stream1 ), ' bytes, ' , mb_strlen ($ stream1 ), ' chars. ' , PHP_EOL ;
4546echo 'beg of stream1 is ' , $ start1 , PHP_EOL ;
4647echo 'end of stream1 is ' , $ ending1 , PHP_EOL ;
47-
48+ if ($ string1 != $ stream1 || $ stream1 != stream_get_contents ($ row ['DATA2 ' ])) {
49+ echo 'Expected nclob value to match clob value for stream1 ' , PHP_EOL ;
50+ }
4851
4952echo PHP_EOL , 'Test 2: £ ' , PHP_EOL ;
5053$ string2 = 'abc ' . str_repeat ('£ ' , 8187 ) . 'xyz ' ; // 8193 chars total is when it breaks
5154$ id = 2 ;
5255$ insert ->bindParam (':data ' , $ string2 , \PDO ::PARAM_STR , strlen ($ string2 )); // length in bytes
56+ $ insert ->bindParam (':data2 ' , $ string2 , \PDO ::PARAM_STR , strlen ($ string2 ));
5357$ insert ->execute ();
5458$ select ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
5559$ select ->execute ();
@@ -61,12 +65,15 @@ echo 'size of string2 is ', strlen($string2), ' bytes, ', mb_strlen($string2), '
6165echo 'size of stream2 is ' , strlen ($ stream2 ), ' bytes, ' , mb_strlen ($ stream2 ), ' chars. ' , PHP_EOL ;
6266echo 'beg of stream2 is ' , $ start2 , PHP_EOL ;
6367echo 'end of stream2 is ' , $ ending2 , PHP_EOL ;
64-
68+ if ($ string2 != $ stream2 || $ stream2 != stream_get_contents ($ row ['DATA2 ' ])) {
69+ echo 'Expected nclob value to match clob value for stream2 ' , PHP_EOL ;
70+ }
6571
6672echo PHP_EOL , 'Test 3: Җ ' , PHP_EOL ;
6773$ string3 = 'abc ' . str_repeat ('Җ ' , 8187 ) . 'xyz ' ; // 8193 chars total is when it breaks
6874$ id = 3 ;
6975$ insert ->bindParam (':data ' , $ string3 , \PDO ::PARAM_STR , strlen ($ string3 )); // length in bytes
76+ $ insert ->bindParam (':data2 ' , $ string3 , \PDO ::PARAM_STR , strlen ($ string3 ));
7077$ insert ->execute ();
7178$ select ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
7279$ select ->execute ();
@@ -78,12 +85,15 @@ echo 'size of string3 is ', strlen($string3), ' bytes, ', mb_strlen($string3), '
7885echo 'size of stream3 is ' , strlen ($ stream3 ), ' bytes, ' , mb_strlen ($ stream3 ), ' chars. ' , PHP_EOL ;
7986echo 'beg of stream3 is ' , $ start3 , PHP_EOL ;
8087echo 'end of stream3 is ' , $ ending3 , PHP_EOL ;
81-
88+ if ($ string3 != $ stream3 || $ stream3 != stream_get_contents ($ row ['DATA2 ' ])) {
89+ echo 'Expected nclob value to match clob value for stream3 ' , PHP_EOL ;
90+ }
8291
8392echo PHP_EOL , 'Test 4: の ' , PHP_EOL ;
8493$ string4 = 'abc ' . str_repeat ('の ' , 8187 ) . 'xyz ' ; // 8193 chars total is when it breaks
8594$ id = 4 ;
8695$ insert ->bindParam (':data ' , $ string4 , \PDO ::PARAM_STR , strlen ($ string4 )); // length in bytes
96+ $ insert ->bindParam (':data2 ' , $ string4 , \PDO ::PARAM_STR , strlen ($ string4 ));
8797$ insert ->execute ();
8898$ select ->bindParam (':id ' , $ id , \PDO ::PARAM_STR );
8999$ select ->execute ();
@@ -95,13 +105,14 @@ echo 'size of string4 is ', strlen($string4), ' bytes, ', mb_strlen($string4), '
95105echo 'size of stream4 is ' , strlen ($ stream4 ), ' bytes, ' , mb_strlen ($ stream4 ), ' chars. ' , PHP_EOL ;
96106echo 'beg of stream4 is ' , $ start4 , PHP_EOL ;
97107echo 'end of stream4 is ' , $ ending4 , PHP_EOL ;
108+ if ($ string4 != $ stream4 || $ stream4 != stream_get_contents ($ row ['DATA2 ' ])) {
109+ echo 'Expected nclob value to match clob value for stream4 ' , PHP_EOL ;
110+ }
98111?>
99- --XFAIL--
100- Fails due to Bug 60994
101112--EXPECT--
102113Test 1: j
103- size of string1 is 1000006 bytes, 1000006 chars.
104- size of stream1 is 1000006 bytes, 1000006 chars.
114+ size of string1 is 8193 bytes, 8193 chars.
115+ size of stream1 is 8193 bytes, 8193 chars.
105116beg of stream1 is abcjjjjjjj
106117end of stream1 is jjjjjjjxyz
107118
0 commit comments