[ 
http://issues.apache.org/jira/browse/DERBY-1917?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12461669
 ] 

V.Narayanan commented on DERBY-1917:
------------------------------------

Thanks for taking a look at this issue and commenting on it.

1) I will change the identation to use tabs instead of spaces and repost my 
patch

2) Would'nt changing the new lines to use 4 spaces make those lines stand out 
from sorrounding code?

3) The position method was earlier being tested for search strings of length 
only within 256  as a workaround in BlobClob4BlobTest (That is the only 
     place in my knowledge that carries a test for the position method). Now it 
has been changed to test for arbitary length strings. 

4) But as a specific test for this bug I can add the repro attached with this 
issue as a test case. Since the chunk size is 256 I could probably add test 
    cases to test for a range of chunk sizes like 0-256, 256-512.... But IMHO 
the existing test case and the repro(if required) should be good enough.

5) From my knowledge of tracing this algorithm it would work irrespective of 
the number 256

6) I however do not know if 256 is something like a most efficient chunk size. 
I mean the algorithm works most efficiently if your chunk size is 256. I 
    have not tested this.

thanx once again for the comments and guidance,
Narayanan

> Clob.position fails with Embedded driver and large Clobs
> --------------------------------------------------------
>
>                 Key: DERBY-1917
>                 URL: http://issues.apache.org/jira/browse/DERBY-1917
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>            Reporter: Fernanda Pizzorno
>         Assigned To: V.Narayanan
>            Priority: Minor
>         Attachments: Position_patch_explanation.txt, position_patch_v1.diff, 
> position_patch_v1.stat
>
>
> The method Clob.position(String searchstr, long start) fails when used on 
> large lobs if the searchstr is bigger than 256 characters. I have seen two 
> different errors, if the search string it bigger than 256 character it is not 
> found and if the search string is bigger than 512 characters an exception is 
> thrown.
> /* Repro */
>             // Connect
>             Class.forName("org.apache.derby.jdbc.EmbeddedDriver");
>             Connection conn = 
> DriverManager.getConnection("jdbc:derby:ReproClob;create=true", "app", "app");
>             
>             // Create table and populate
>             Statement stmt = conn.createStatement();
>             try {
>                 stmt.executeUpdate("DROP TABLE tmpClob");
>             } catch (SQLException se) {}
>             stmt.executeUpdate("CREATE TABLE tmpClob (a int, b clob(40K))");
>             
>             PreparedStatement ps = conn.prepareStatement("INSERT INTO tmpClob 
> VALUES (?, ?)");
>             String tmp = "abcdefghijklmnopqrstuvxyz";
>             StringBuilder sb = new StringBuilder();
>             for (int i=0; i<1500; i++) {
>                 sb.append(tmp);
>             }
>             ps.setInt(1, 1);
>             ps.setString(2, sb.toString());
>             ps.executeUpdate();
>             ps.close();
>             ResultSet rs = stmt.executeQuery("SELECT * FROM tmpClob");
>             if (rs.next()) {
>                 Clob c = rs.getClob(2);
>                 // Bug #1
>                 String subString1 = c.getSubString(100, 513);
>                 try {
>                     long i1 = c.position(subString1, 90);
>                     System.out.println("Found searched string at: " + i1);
>                 } catch (SQLException se) {
>                     System.out.println("FAILURE REPRODUCED: 
> Clob.position(string, int) throws an exception when the length of the search 
> string is bigger than 512");
>                     se.printStackTrace();
>                     while (se != null) {
>                         System.out.println("FAIL: " + se.getMessage());
>                         se = se.getNextException();
>                     }
>                 }
>                 // Bug #2
>                 String subString2 = c.getSubString(100, 257);
>                 long i2 = c.position(subString2, 90);
>                 if (i2 == -1) {
>                     System.out.println("FAILURE REPRODUCED: 
> Clob.position(string, int) does not find the search string if its length is 
> bigger than 256");
>                 } else {
>                     System.out.println("Found searched string at: " + i2);
>                 }
>             }
>             rs.close();
>             stmt.close();
>             conn.rollback();
>             conn.close();

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to