Mantis - Quercus
Viewing Issue Advanced Details
5187 minor always 08-24-12 00:53 08-30-12 03:23
nam  
 
normal  
new  
open  
none    
none  
0005187: oci_fetch_array() with OCI_RETURN_LOBS not implemented
(rep by Kiarash)

At the moment, We are having some technical difficulties regarding implemented methods (for Oracle Database) in Quercus. We are unable to retrieve CLOB values from database (all others work fine).following is the exception we get:
 
com.caucho.quercus.UnimplementedException: `oci_fetch_array with OCI_RETURN_LOBS'

Notes
(0006026)
kiarash   
08-30-12 03:23   
Quercus implementation of oci_fetch_array eventually tries to retrieve all values in a string format (refer to JdbcResultResource class). in getColumnString() function, for performance purposes, data is being retrieved using getByte() method and converted to string. this will not work for CLOB values. therefore for CLOB data, getString() method should be used instead of getByte().
in addition, the code to return UnimplementedException for OCI_RETURN_LOB can be removed since the overall implementation should always follow this mode.

following fix can be applied to com.caucho.quercus.lib.db.JdbcResultResource

...
protected Value getColumnString(Env env,
                                  ResultSet rs,
                                  ResultSetMetaData md,
                                  int column)
    throws SQLException
  {
    // php/1464, php/144f, php/144g
    // php/144b

    // calling getString() will decode using the database encoding, so
    // get bytes directly. Also, getBytes is faster for MySQL since
    // getString converts from bytes to string.
    byte []bytes = rs.getBytes(column);

    if (bytes == null)
      return NullValue.NULL;

    StringValue bb = env.createUnicodeBuilder();

    //enhanced for retrieving CLOB Type: CLOB values should be retrieved
    //using getString() method for data to be decoded correctly --kk
    if (md.getColumnType(column) == Types.CLOB)
        bb.append(rs.getString(column));
    else
        bb.append(bytes);
    
    return bb;
  }