* BLOB temporary handling
authorJure Kajzer <freakolowsky@users.mediawiki.org>
Tue, 9 Nov 2010 08:56:15 +0000 (08:56 +0000)
committerJure Kajzer <freakolowsky@users.mediawiki.org>
Tue, 9 Nov 2010 08:56:15 +0000 (08:56 +0000)
* en/decodeBlob

includes/db/DatabaseOracle.php

index 971bfa3..5fa9c8e 100644 (file)
@@ -534,7 +534,7 @@ class DatabaseOracle extends DatabaseBase {
                                // do nothing ... null was inserted in statement creation
                        } elseif ( $col_type != 'BLOB' && $col_type != 'CLOB' ) {
                                if ( is_object( $val ) ) {
-                                       $val = $val->getData();
+                                       $val = $val->fetch();
                                }
 
                                if ( preg_match( '/^timestamp.*/i', $col_type ) == 1 && strtolower( $val ) == 'infinity' ) {
@@ -553,11 +553,15 @@ class DatabaseOracle extends DatabaseBase {
                                        throw new DBUnexpectedError( $this, "Cannot create LOB descriptor: " . $e['message'] );
                                }
 
+                               if ( is_object( $val ) ) {
+                                       $val = $val->fetch();
+                               }
+
                                if ( $col_type == 'BLOB' ) {
-                                       $lob[$col]->writeTemporary( $val );
-                                       oci_bind_by_name( $stmt, ":$col", $lob[$col], - 1, SQLT_BLOB );
+                                       $lob[$col]->writeTemporary( $val, OCI_TEMP_BLOB );
+                                       oci_bind_by_name( $stmt, ":$col", $lob[$col], - 1, OCI_B_BLOB );
                                } else {
-                                       $lob[$col]->writeTemporary( $val );
+                                       $lob[$col]->writeTemporary( $val, OCI_TEMP_CLOB );
                                        oci_bind_by_name( $stmt, ":$col", $lob[$col], - 1, OCI_B_CLOB );
                                }
                        }
@@ -812,6 +816,17 @@ class DatabaseOracle extends DatabaseBase {
                return "SELECT * FROM ($sql) WHERE rownum >= (1 + $offset) AND rownum < (1 + $limit + $offset)";
        }
 
+       function encodeBlob( $b ) {
+               return new Blob( $b );
+       }
+
+       function decodeBlob( $b ) {
+               if ( $b instanceof Blob ) {
+                       $b = $b->fetch();
+               }
+               return $b;
+       }
+
        function unionQueries( $sqls, $all ) {
                $glue = ' UNION ALL ';
                return 'SELECT * ' . ( $all ? '':'/* UNION_UNIQUE */ ' ) . 'FROM (' . implode( $glue, $sqls ) . ')' ;