You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-dev@db.apache.org by "Anurag Shekhar (JIRA)" <ji...@apache.org> on 2007/05/28 11:36:16 UTC

[jira] Created: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

If large clob is updated after Reader. the reader continues to point to old data
--------------------------------------------------------------------------------

                 Key: DERBY-2712
                 URL: https://issues.apache.org/jira/browse/DERBY-2712
             Project: Derby
          Issue Type: Bug
            Reporter: Anurag Shekhar
             Fix For: 10.3.0.0


If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan updated DERBY-2712:
-----------------------------------

    Fix Version/s: 10.3.0.0

This fix will go into 10.3.

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Closed: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Anurag Shekhar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anurag Shekhar closed DERBY-2712.
---------------------------------


> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff, derby-2712v2.diff, derby-2712v3.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Anurag Shekhar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anurag Shekhar updated DERBY-2712:
----------------------------------

    Attachment: derby-2712.diff

I have modified EmbedClob.getCharacterStream to return ClobUpdateableReader. ClobUpdateableReader is modifed to detect if the Clob has moved from Readonly InternalClob to a writable InternalClob. If the EmbedClob moves from readonly mode to writable mode it fetches the input stream again from the EmbedClob and skips to the current position.
Code to invalidate the internal Reader in case the underlying stream is modified was already part of this Reader.

Updated files
java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
Added two methods
	isWritable
		ClobUpdateableReader uses this methods to determine if the Clob has swtched from a readonly InternalClob to a writable InternalClob.
	getInternalStream
		ClobUpdateableReader uses this method if it detects Clob is modified since creating ClobUpdateableReader.
	
Modified getCharacterStream() to return ClobUpdateableReader.

java/engine/org/apache/derby/impl/jdbc/ClobUpdateableReader.java

added a new constructor. This constructor will be used by EmbedClob. It accepts Clob as a parameter Clob object is used to check if the InternalClob its using is writable or not. In case it was read only in the begning ClobUpdateableReader uses getInternalStream to refresh the stream after it switches to writable InternalClob.

Added a new private method updateIfRequired which is called in every method to check if the underlying stream has changed.

java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/ClobUpdateableReaderTest.java

Added a new test for switching from StoreStream to ClobStreamControl.



> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>         Attachments: derby-2712.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Anurag Shekhar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anurag Shekhar updated DERBY-2712:
----------------------------------

    Attachment: derby-2712v3.diff

changes in this patch
1.Checking for SanityManager.DEBUG before calling SanityManager.assert
2.Moved InternalClob.getByteLength in separate call in ClobStreamControl.copyClobContent(InternalClob clob) to avoid 2806


> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff, derby-2712v2.diff, derby-2712v3.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan updated DERBY-2712:
-----------------------------------

    Component/s: JDBC

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan updated DERBY-2712:
-----------------------------------

    Assignee: Anurag Shekhar

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Anurag Shekhar (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Anurag Shekhar updated DERBY-2712:
----------------------------------

    Attachment: derby-2712v2.diff

thanks Kristian for the review

1) Since the method EmbedClob.getInternalStream() has been added, why not rewrite the new ClobUpdateableReader constructor to only take the EmbedClob-object and fetch the stream by calling getInternalStream()?

I have modified the constroctor to take only clob.

 2) The code below can loop infinitely.
+ while (remainToSkip > 0) {
+ long skipBy = streamReader.skip(remainToSkip);
+ remainToSkip -= skipBy;
    A check to see if skipBy == 0 should be added, which if true means the EOF has been reached.
    One must consider under which scenarios this can happen (only programming error?). Would be better to fail "gracefully" instead of looping for ever.

Fixed this problem. Now I am calling read if skip returns zero. If it returns -1 it will throw EOF exception and its able to read a char it will add 1 to skipped and continue.

 3) The instance variable 'clob' in ClobUpdateableReader should be final.

fixed

 4) There are some typos in the JavaDoc. Might want to do another pass on it.
 5) Quite a few occurrences of trailing spaces.

fixed trailing spaces and typos

 6) A bit unsure about this one in ClobUpdateableReader:
+ if (clob == null) {
+ throw new IOException ("Internal error while " +
+ "updating stream");
+ }

    This can only happen if there is a programming error. Is IOException the right mechanism to communicate this?
    What about replacing it with a SanityManager.DEBUG/ASSERT?

added sanity manager.assert.


For issue 7. It will be good to remove dependency on length but as you rightly said it should be handled in a new jira.

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff, derby-2712v2.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12503441 ] 

Kristian Waagan commented on DERBY-2712:
----------------------------------------

Hello Anurag,

I reviewed your patch and have the following comments/questions:
 1) Since the method EmbedClob.getInternalStream() has been added, why not rewrite the new ClobUpdateableReader constructor to only take the EmbedClob-object and fetch the stream by calling getInternalStream()?

 2)  The code below can loop infinitely.
+        while (remainToSkip > 0) {
+            long skipBy = streamReader.skip(remainToSkip);            
+            remainToSkip -= skipBy;
    A check to see if skipBy == 0 should be added, which if true means the EOF has been reached.
    One must consider under which scenarios this can happen (only programming error?). Would be better to fail "gracefully" instead of looping for ever.

 3) The instance variable 'clob' in ClobUpdateableReader should be final.

 4) There are some typos in the JavaDoc. Might want to do another pass on it.

 5) Quite a few occurrences of trailing spaces.

 6) A bit unsure about this one in ClobUpdateableReader:
+            if (clob == null) {
+                throw new IOException ("Internal error while " +
+                        "updating stream");
+            }

    This can only happen if there is a programming error. Is IOException the right mechanism to communicate this?
    What about replacing it with a SanityManager.DEBUG/ASSERT?

 7) A somewhat different issue, but why does the UTF8Reader need the length of the stream?
    I see how it is used in UTF8Reader, but is it really necessary? (btw, this is not something to be handled under this Jira)

I ran suites.All (1.5) with the patch without failures. I'm running derbyall as we speak.

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>         Attachments: derby-2712.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Resolved: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Kristian Waagan (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Kristian Waagan resolved DERBY-2712.
------------------------------------

    Resolution: Fixed

Ran suites.All without failures.

Committed 'derby-2712v3.diff' to trunk with revision 546831.

Thanks Anurag!

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>            Assignee: Anurag Shekhar
>             Fix For: 10.3.0.0
>
>         Attachments: derby-2712.diff, derby-2712v2.diff, derby-2712v3.diff
>
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Updated: (DERBY-2712) If large clob is updated after Reader. the reader continues to point to old data

Posted by "Myrna van Lunteren (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/DERBY-2712?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Myrna van Lunteren updated DERBY-2712:
--------------------------------------

    Affects Version/s: 10.3.0.0
        Fix Version/s:     (was: 10.3.0.0)

changing fix in 10.3 to affects 10.3, I assume that's what was meant; unassigned issues should not have a fix in at this point (unless they're a blocker for 10.3 release)

> If large clob is updated after Reader. the reader continues to point to old data
> --------------------------------------------------------------------------------
>
>                 Key: DERBY-2712
>                 URL: https://issues.apache.org/jira/browse/DERBY-2712
>             Project: Derby
>          Issue Type: Bug
>    Affects Versions: 10.3.0.0
>            Reporter: Anurag Shekhar
>
> If a Reader is fetched from a large clob (obtained from ResultSet) a reader linked to the dvd stream is returned once a set method is called on it the clob data is materialized in control class but the Reader returned previously continues to point to old data.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.