Bug #1130 Clob truncate fails

Submitted: 25 Aug 2003 3:00 Modified: 25 Aug 2003 7:42
Reporter: Roland Littwin Email Updates:
Status: Closed Impact on me:
None 
Category:Connector / J Severity:S2 (Serious)
Version:3.0.8 OS:Any (All)
Assigned to: Mark Matthews CPU Architecture:Any

[25 Aug 2003 3:00] Roland Littwin
Description:
JDBC Documentation said
public void truncate(long len)
              throws SQLExceptionTruncates the CLOB value that this Clob designates to have a length of len characters.

but your implementation in file com/mysql/jdbc/Clob.java sets the Clob to
the tailing string after the length-Position. So truncating a clob to 0 bytes
requires
clob.truncate(clob.length()) and not clob.truncate(0). If im wrong, i'm sorry
but I think I'm right.

How to repeat:
Call
clob.truncate(0) to a nonemty field and store result. It will be unchanged.

Suggested fix:
Your version:
   public void truncate(long length) throws SQLException {
        this.charData = this.charData.substring((int) length);
    }

Corrected version:
    public void truncate(long length) throws SQLException {
        this.charData = this.charData.substring(0,(int) length);
    }
[25 Aug 2003 7:42] Mark Matthews
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html

Portions of this website are copyright © 2001, 2002 The PHP Group

Page generated in 0.050 sec. using MySQL 8.4.7-u6-cloud

Timestamp references displayed by the system are UTC.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.