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 "Tomohito Nakayama (JIRA)" <de...@db.apache.org> on 2005/11/21 12:24:42 UTC

[jira] Created: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
---------------------------------------------------------------------------------------------------

         Key: DERBY-721
         URL: http://issues.apache.org/jira/browse/DERBY-721
     Project: Derby
        Type: Bug
  Components: Unknown  
 Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
naka@rufelza:~/derby/dev/trunk$ java -version
java version "1.4.2_10"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)

    Reporter: Tomohito Nakayama


State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .

Test code ...
	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");

	byte[] data = new byte[1024 * 1024];
	for(int i = 0;
	    i < 1024 * 1024;
	    i  ++){
	    data[i] = (byte)(i % 256);
	}

	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
	pst.executeUpdate();
	pst.close();
	
	
	st = conn.createStatement();
	ResultSet rs = st.executeQuery("select b from a");
	rs.next();
	
	InputStream is = rs.getBinaryStream(1);
	System.out.println("Here goes first stream");
	System.out.println(is.read());
	System.out.println(is.read());
	System.out.println(is.read());
	
	is = rs.getBinaryStream(1);
	System.out.println("Here goes 2nd stream");
	System.out.println(is.read());
	System.out.println(is.read());
	System.out.println(is.read());

Result ....
naka@rufelza:~/derby/test/20051121$ java testLob
Here goes first stream
0
1
2
Here goes 2nd stream
7
8
9

It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Resolved: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama resolved DERBY-721:
-------------------------------------

    Resolution: Fixed

Committed.

Adding         java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/Stream.out
Transmitting file data .
Committed revision 357966.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: JDBC, Network Client
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_5.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Kathey Marsden updated DERBY-721:
---------------------------------

    Fix Version: 10.2.0.0

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug

>   Components: JDBC, Network Client
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>      Fix For: 10.2.0.0
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_5.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721_2.patch

Patch for the phenomena found in getCharacterStream

Description:
   Modified to reset the source InputStream instead of closing it , when org.apache.derby.impl.jdbc.UTF8Reader was closed.

Test:
   Executed derbyall and does not found new error other than found in http://www.multinet.no/~solberg/public/Apache/Derby/Limited/index.html already.


> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: testLob.java
                testResult.txt

These are test program for reproduction of the phenomena  what I found , and result of the program .

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>  Attachments: testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Reopened: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama reopened DERBY-721:
-------------------------------------


Dan wrote: 

The error handling is incorrect here, and I think in at least one other
place in the patch.

1) Derby should not be printing stack traces to System.err, it should
just throw an exception. It's up to the calling application to print the
stack trace, if it wants.

2) There are utility methods, e.g. noStateChangeLOB, to create new
SQLExceptions, creating an exception like this will not include a
SQLState and will not link the original IOException to the SQLException.

Thanks,
Dan.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


Re: [jira] Resolved: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by TomohitoNakayama <to...@basil.ocn.ne.jp>.
Hello.


I found next error of jdbcapi/Stream.java in regression test using DB2 
universal driver .
http://www.multinet.no/~solberg/public/Apache/TinderBox_Derby/testlog/SunOS-5.10_i86pc-i386/357435-derbynetmats_diff.txt

I could not found this problem , because test for DB2 universal driver 
was not executed at my environment in derbyall suite ....


The error tells that modification done in DERBY-721 made different behavior
between using  DB2 universal driver and using Network client JDBC driver .

Because this difference is a natural consequence from decision in 
DERBY-721 ,
I will add master .out file of jdbcapi/Stream.java for DB2 universal 
driver to be passed .


Best regards.


Tomohito Nakayama (JIRA) wrote:

>     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
>     
>Tomohito Nakayama resolved DERBY-721:
>-------------------------------------
>
>    Resolution: Fixed
>
>Committed .
>
>Sending        java/client/org/apache/derby/client/am/ResultSet.java
>Sending        java/engine/org/apache/derby/iapi/reference/SQLState.java
>Sending        java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
>Sending        java/engine/org/apache/derby/loc/messages_en.properties
>Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/LOBTest.out
>Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/LOBTest.out
>Adding         java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/Stream.out
>Sending        java/testing/org/apache/derbyTesting/functionTests/master/LOBTest.out
>Adding         java/testing/org/apache/derbyTesting/functionTests/master/Stream.out
>Sending        java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out
>Sending        java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
>Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LOBTest.java
>Adding         java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Stream.java
>Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/connectionJdbc20.java
>Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetStream.java
>Transmitting file data ...............
>Committed revision 357435.
>
>  
>
>>State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
>>---------------------------------------------------------------------------------------------------
>>
>>         Key: DERBY-721
>>         URL: http://issues.apache.org/jira/browse/DERBY-721
>>     Project: Derby
>>        Type: Bug
>>  Components: Unknown
>> Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
>>Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
>>naka@rufelza:~/derby/dev/trunk$ java -version
>>java version "1.4.2_10"
>>Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
>>Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>>    Reporter: Tomohito Nakayama
>>    Assignee: Tomohito Nakayama
>> Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>>
>>State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
>>Test code ...
>>	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
>>	byte[] data = new byte[1024 * 1024];
>>	for(int i = 0;
>>	    i < 1024 * 1024;
>>	    i  ++){
>>	    data[i] = (byte)(i % 256);
>>	}
>>	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
>>	pst.executeUpdate();
>>	pst.close();
>>	
>>	
>>	st = conn.createStatement();
>>	ResultSet rs = st.executeQuery("select b from a");
>>	rs.next();
>>	
>>	InputStream is = rs.getBinaryStream(1);
>>	System.out.println("Here goes first stream");
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	
>>	is = rs.getBinaryStream(1);
>>	System.out.println("Here goes 2nd stream");
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>Result ....
>>naka@rufelza:~/derby/test/20051121$ java testLob
>>Here goes first stream
>>0
>>1
>>2
>>Here goes 2nd stream
>>7
>>8
>>9
>>It is expected that result printed from first stream is as same as result printed from 2nd.
>>    
>>
>
>  
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


[jira] Resolved: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama resolved DERBY-721:
-------------------------------------

    Resolution: Fixed

Committed .

Sending        java/client/org/apache/derby/client/am/ResultSet.java
Sending        java/engine/org/apache/derby/iapi/reference/SQLState.java
Sending        java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
Sending        java/engine/org/apache/derby/loc/messages_en.properties
Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNet/LOBTest.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/LOBTest.out
Adding         java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/Stream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/LOBTest.out
Adding         java/testing/org/apache/derbyTesting/functionTests/master/Stream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/connectionJdbc20.out
Sending        java/testing/org/apache/derbyTesting/functionTests/suites/jdbcapi.runall
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/LOBTest.java
Adding         java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/Stream.java
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/connectionJdbc20.java
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetStream.java
Transmitting file data ...............
Committed revision 357435.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Resolved: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama resolved DERBY-721:
-------------------------------------

    Resolution: Fixed

patch commited.


Sending        java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
Sending        java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java
Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetStream.java
Transmitting file data .....
Committed revision 349718.


> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12360504 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

I add one more description for the patch:
  What is done: 
    3: Modify several test code to confirm 1.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Reopened: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama reopened DERBY-721:
-------------------------------------


I found same problem in getCharacterStream ...

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Kathey Marsden (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Kathey Marsden updated DERBY-721:
---------------------------------

    Derby Info: [Existing Application Impact, Release Note Needed]

I think this change may affect existing applicaitons. Because of the fact that the  InputStream retrieved from resultset is not clean , we now throw an exception if the user gest the stream for a value in result set twice. 

Typically this would mean they were getting wrong results before if they retrieved the stream more than once. Now they will get an exception which is correct but may be surprising to users that  are now seeing this new symptom.  A formal release note still needs to be added.


> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>                 Key: DERBY-721
>                 URL: http://issues.apache.org/jira/browse/DERBY-721
>             Project: Derby
>          Issue Type: Bug
>          Components: JDBC, Network Client
>         Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>            Reporter: Tomohito Nakayama
>         Assigned To: Tomohito Nakayama
>             Fix For: 10.2.0.0
>
>         Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_5.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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

        

[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12359870 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

I  commited DERBY-721_rollback_1+2.patch .

Sending        java/engine/org/apache/derby/impl/jdbc/BinaryToRawStream.java
Sending        java/engine/org/apache/derby/impl/jdbc/EmbedClob.java
Sending        java/engine/org/apache/derby/impl/jdbc/UTF8Reader.java
Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetStream.java
Transmitting file data ......
Committed revision 355437.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: testLob2.java
                testResult2.txt

These are test to reproduce phenomena found at  getCharacterStream

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721_rollback_1+2.patch

Description of this patch :
  This patch rollback  DERBY-721.patch and  DERBY-721_2.patch .

Test :
  Executed derbyall and found no error .


> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721_4.patch

Description of patch :
 What is done:
  1: Throw newly defined exception when stream for same column in result was retrieved from a resultset , both in embed and network client.
  2: Add new test code for 1.

 What is *not* done:
  I think these should be considered in other patch/issue.
  1:Exception was *not* thrown when stream for same column in result was retrieved from Blob/Clob .
  2:Exception was *not* thrown when value , other than stream , was retrieved from result set ,after stream for the same column was retrieved.


Test:
 Executed derbyall and found no error except found in regression test .

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Resolved: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama resolved DERBY-721:
-------------------------------------

    Resolution: Fixed

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721.patch

Description of the patch:
  Modified close method of org.apache.derby.impl.jdbc.BinaryToRawStream to reset source InputStream which implements Resetable interface,
  because the source InputStream is shared with following InputStream.

Test:
 execute derbyall and found no error.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12358338 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

I found that BinaryToRawStream is subclass of java.io.FilteredInputStream and 
would just close source InputStream when close method was called.

However, source InputStream was shared between bunch of destination InputStream.
Then, just closing source InputStream may be not correct.

I found when this phenomena was found , substantial class of source InputStream object implements Resetable .

I will call method to reset source InputStream object ,if it was Resetable object , in BinaryToRawSteream.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I agree with you conclusion, if in the future someone wants to fix
the network server case then it should not be difficult to make the
embedded case match.  Going forward I think our best shot at having
reasonable stream implementations is that we should assume they
can only be read once both on the way into the server and on the
way out (at least the normal optimized codepath should do so).

1 meg will cause the large blob/clob code path.  As a rule of thumb
stream based tests probably should have 3 instances:
1) blob/clob less than 1k
2) blob/clob more than 250k
3) blob/clob more than the allowed heap size in jvm you are testing,
    these tests can follow the exising ones in the large test area.

The difference between
1 meg a 1 gig is that it is hard to tell if the underlying code is
materializing the entire stream into memory with 1 meg.  There is some
number between the 2 (with appropriate setting of max jvm heap) that will.

TomohitoNakayama wrote:
> Hello.
> 
> Mike Matrigali wrote:
> 
>> For embedded I was worried about your description of changes, that made
>> it sound like you somehow were going to buffer the blob in memory.  I
>> see from your changes you basically added reset calls if the underlying
>> stream was resetable.  What I don't know is what happens in the 2 gig
>> blob/clob cases, either you will have to investigate or maybe someone
>> on the list knows?
>>
> As you saw, the patch does not make new cache, just resets the stream.
> I tested just case of 1 mega lob and confirmed lob was streamed from the 
> beginning from 2nd InputStream.
> I don't think there exists qualitative difference in behavior between 1M 
> and  1G, though I'm not completely confirmed it.
> 
> 
> However, I understand your opinion that this patch will implicitly 
> restrict implementation of network client ,
> that entire information streamed from server have to be stored , because 
> streaming between server and client are performed only once.
> 
> Now I think it is preferable to throw Exception
> when 2nd Reader/InputStream for same value in result was retrieved or
> when Reader/InputStream was retrieved in different order as in sql.
> // I hope other's opinion around restriction not to allow user to 
> retrieve Reader/InputStream for result columns in different order as in 
> sql .
> 
> Once, I think the restriction may be too hard for user ,
> however I conclude the restriction is reasonable because ResultSet is 
> not cache for set of result and
> have characteristic of  Stream (especially when lob was used ).
> If user needs cache , the cache should be developed as separated from 
> ResultSet .
> 
> Thank you for your suggestion.
> I didn't realize this Stream like characteristics of ResultSet .
> 
> Best regards.
> 
> 
> Mike Matrigali wrote:
> 
>> I don't have enough information to completely answer, but will
>> try to state my opinion on the issue.
>>
>> I think the goals should be:
>> 1) provide same behavior in embedded and network server mode.
>> 2) provide same behavior whether the blob is "small" or "large".
>> 3) optimize the standard case of getting the column once in jdbc,
>>   as the spec allows.
>> 4) If at all possible when selecting a blob/clob as a stream it should
>>   not be necessary to materialize the entire stream in memory.
>>
>> For embedded I was worried about your description of changes, that made
>> it sound like you somehow were going to buffer the blob in memory.  I
>> see from your changes you basically added reset calls if the underlying
>> stream was resetable.  What I don't know is what happens in the 2 gig
>> blob/clob cases, either you will have to investigate or maybe someone
>> on the list knows?
>>
>> For embedded it is theoretically possible for the reset of the stream
>> to go all the way back to store and read it again from the beginning.
>> For network client this seems even more complicated to do in an
>> optimized way (I believe you are looking at improving the streaming
>> behavior of large objects to network client so I defer to you in
>> how hard this may be).
>>
>> My opinion would be to make the second reference throw an error, to
>> make that behavior consistent in network server, embedded, long and
>> short blob/clob streams.  And to document that behavior.
>>
>> Having said that, I am not against the code working as you are moving
>> toward as long as it does not cause a memory/runtime performance issue
>> for the normal single get stream case.
>>
>> TomohitoNakayama wrote:
>>
>>  
>>
>>> Hello Daniel and Mike .
>>>
>>> Do you think it is preferable not to allow user to call getXXXXStream
>>> twice from one row ,
>>> in order to make a room for releasing memory for cache in ResultSet as
>>> soon as possible ?
>>>
>>> Best regards.
>>>
>>>
>>> Daniel John Debrunner wrote:
>>>
>>>   
>>>
>>>> Mike Matrigali wrote:
>>>>
>>>>
>>>>
>>>>     
>>>>
>>>>> Is there anything in the standard that says what the second call to
>>>>> the get the stream has to do?  Imagine the case where the first
>>>>> stream reads 1 gig of a 2 gig blob, does the second call to
>>>>> getBinaryStream() have to return the 1st gig again?
>>>>>  
>>>>>       
>>>>
>>>> Yes & no.
>>>>
>>>> Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet 
>>>> has
>>>> always had:
>>>>
>>>> " For maximum portability, result set columns within each row should be
>>>> read in left-to-right order, and each column should be read only once."
>>>>
>>>> Thus, Derby could thrown an exception if there was a second 
>>>> getXXXStream
>>>> call on the same column.
>>>>
>>>>
>>>>
>>>>     
>>>>
>>>>> Any change that tries to cache the bytes returned by the first
>>>>> getBinaryStream either in local client or network client code is
>>>>> going to be a performance/memory drain.
>>>>>  
>>>>>       
>>>>
>>>> Agreed, we need to be careful here, we need to optmise the frequent
>>>> case, getting the column's value once as-per JDBC.
>>>>
>>>> Dan.
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>
>>>>     
>>
>>
>>
>>  
>>
> 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by TomohitoNakayama <to...@basil.ocn.ne.jp>.
Hello.

Mike Matrigali wrote:

>For embedded I was worried about your description of changes, that made
>it sound like you somehow were going to buffer the blob in memory.  I
>see from your changes you basically added reset calls if the underlying
>stream was resetable.  What I don't know is what happens in the 2 gig
>blob/clob cases, either you will have to investigate or maybe someone
>on the list knows?
>
As you saw, the patch does not make new cache, just resets the stream.
I tested just case of 1 mega lob and confirmed lob was streamed from the 
beginning from 2nd InputStream.
I don't think there exists qualitative difference in behavior between 1M 
and  1G, though I'm not completely confirmed it.


However, I understand your opinion that this patch will implicitly 
restrict implementation of network client ,
that entire information streamed from server have to be stored , because 
streaming between server and client are performed only once.

Now I think it is preferable to throw Exception
when 2nd Reader/InputStream for same value in result was retrieved or
when Reader/InputStream was retrieved in different order as in sql.
// I hope other's opinion around restriction not to allow user to 
retrieve Reader/InputStream for result columns in different order as in 
sql .

Once, I think the restriction may be too hard for user ,
however I conclude the restriction is reasonable because ResultSet is 
not cache for set of result and
have characteristic of  Stream (especially when lob was used ).
If user needs cache , the cache should be developed as separated from 
ResultSet .

Thank you for your suggestion.
I didn't realize this Stream like characteristics of ResultSet .

Best regards.


Mike Matrigali wrote:

>I don't have enough information to completely answer, but will
>try to state my opinion on the issue.
>
>I think the goals should be:
>1) provide same behavior in embedded and network server mode.
>2) provide same behavior whether the blob is "small" or "large".
>3) optimize the standard case of getting the column once in jdbc,
>   as the spec allows.
>4) If at all possible when selecting a blob/clob as a stream it should
>   not be necessary to materialize the entire stream in memory.
>
>For embedded I was worried about your description of changes, that made
>it sound like you somehow were going to buffer the blob in memory.  I
>see from your changes you basically added reset calls if the underlying
>stream was resetable.  What I don't know is what happens in the 2 gig
>blob/clob cases, either you will have to investigate or maybe someone
>on the list knows?
>
>For embedded it is theoretically possible for the reset of the stream
>to go all the way back to store and read it again from the beginning.
>For network client this seems even more complicated to do in an
>optimized way (I believe you are looking at improving the streaming
>behavior of large objects to network client so I defer to you in
>how hard this may be).
>
>My opinion would be to make the second reference throw an error, to
>make that behavior consistent in network server, embedded, long and
>short blob/clob streams.  And to document that behavior.
>
>Having said that, I am not against the code working as you are moving
>toward as long as it does not cause a memory/runtime performance issue
>for the normal single get stream case.
>
>TomohitoNakayama wrote:
>
>  
>
>>Hello Daniel and Mike .
>>
>>Do you think it is preferable not to allow user to call getXXXXStream
>>twice from one row ,
>>in order to make a room for releasing memory for cache in ResultSet as
>>soon as possible ?
>>
>>Best regards.
>>
>>
>>Daniel John Debrunner wrote:
>>
>>    
>>
>>>Mike Matrigali wrote:
>>>
>>> 
>>>
>>>      
>>>
>>>>Is there anything in the standard that says what the second call to
>>>>the get the stream has to do?  Imagine the case where the first
>>>>stream reads 1 gig of a 2 gig blob, does the second call to
>>>>getBinaryStream() have to return the 1st gig again?
>>>>  
>>>>        
>>>>
>>>Yes & no.
>>>
>>>Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet has
>>>always had:
>>>
>>>" For maximum portability, result set columns within each row should be
>>>read in left-to-right order, and each column should be read only once."
>>>
>>>Thus, Derby could thrown an exception if there was a second getXXXStream
>>>call on the same column.
>>>
>>> 
>>>
>>>      
>>>
>>>>Any change that tries to cache the bytes returned by the first
>>>>getBinaryStream either in local client or network client code is
>>>>going to be a performance/memory drain.
>>>>  
>>>>        
>>>>
>>>Agreed, we need to be careful here, we need to optmise the frequent
>>>case, getting the column's value once as-per JDBC.
>>>
>>>Dan.
>>>
>>>
>>>
>>>
>>> 
>>>
>>>      
>>>
>
>
>  
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I don't have enough information to completely answer, but will
try to state my opinion on the issue.

I think the goals should be:
1) provide same behavior in embedded and network server mode.
2) provide same behavior whether the blob is "small" or "large".
3) optimize the standard case of getting the column once in jdbc,
   as the spec allows.
4) If at all possible when selecting a blob/clob as a stream it should
   not be necessary to materialize the entire stream in memory.

For embedded I was worried about your description of changes, that made
it sound like you somehow were going to buffer the blob in memory.  I
see from your changes you basically added reset calls if the underlying
stream was resetable.  What I don't know is what happens in the 2 gig
blob/clob cases, either you will have to investigate or maybe someone
on the list knows?

For embedded it is theoretically possible for the reset of the stream
to go all the way back to store and read it again from the beginning.
For network client this seems even more complicated to do in an
optimized way (I believe you are looking at improving the streaming
behavior of large objects to network client so I defer to you in
how hard this may be).

My opinion would be to make the second reference throw an error, to
make that behavior consistent in network server, embedded, long and
short blob/clob streams.  And to document that behavior.

Having said that, I am not against the code working as you are moving
toward as long as it does not cause a memory/runtime performance issue
for the normal single get stream case.

TomohitoNakayama wrote:

> Hello Daniel and Mike .
> 
> Do you think it is preferable not to allow user to call getXXXXStream
> twice from one row ,
> in order to make a room for releasing memory for cache in ResultSet as
> soon as possible ?
> 
> Best regards.
> 
> 
> Daniel John Debrunner wrote:
> 
>> Mike Matrigali wrote:
>>
>>  
>>
>>> Is there anything in the standard that says what the second call to
>>> the get the stream has to do?  Imagine the case where the first
>>> stream reads 1 gig of a 2 gig blob, does the second call to
>>> getBinaryStream() have to return the 1st gig again?
>>>   
>>
>>
>> Yes & no.
>>
>> Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet has
>> always had:
>>
>> " For maximum portability, result set columns within each row should be
>> read in left-to-right order, and each column should be read only once."
>>
>> Thus, Derby could thrown an exception if there was a second getXXXStream
>> call on the same column.
>>
>>  
>>
>>> Any change that tries to cache the bytes returned by the first
>>> getBinaryStream either in local client or network client code is
>>> going to be a performance/memory drain.
>>>   
>>
>>
>> Agreed, we need to be careful here, we need to optmise the frequent
>> case, getting the column's value once as-per JDBC.
>>
>> Dan.
>>
>>
>>
>>
>>  
>>
> 

Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by TomohitoNakayama <to...@basil.ocn.ne.jp>.
<monologue>
Restriction of "each row should be read in left-to-right order, and each
column should be read only once" in java.sql.ResultSet would have
some impact on Streaming between client and server , because DRDA seems
to stream LOB between client and server only once and in left-to right
order as in sql ....
</monologue>

TomohitoNakayama wrote:

> Hello Daniel and Mike .
>
> Do you think it is preferable not to allow user to call getXXXXStream
> twice from one row ,
> in order to make a room for releasing memory for cache in ResultSet as
> soon as possible ?
>
> Best regards.
>
>
> Daniel John Debrunner wrote:
>
>> Mike Matrigali wrote:
>>
>>
>>
>>> Is there anything in the standard that says what the second call to
>>> the get the stream has to do? Imagine the case where the first
>>> stream reads 1 gig of a 2 gig blob, does the second call to
>>> getBinaryStream() have to return the 1st gig again?
>>>
>>
>> Yes & no.
>>
>> Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet has
>> always had:
>>
>> " For maximum portability, result set columns within each row should be
>> read in left-to-right order, and each column should be read only once."
>>
>> Thus, Derby could thrown an exception if there was a second getXXXStream
>> call on the same column.
>>
>>
>>
>>> Any change that tries to cache the bytes returned by the first
>>> getBinaryStream either in local client or network client code is
>>> going to be a performance/memory drain.
>>>
>>
>> Agreed, we need to be careful here, we need to optmise the frequent
>> case, getting the column's value once as-per JDBC.
>>
>> Dan.
>>
>>
>>
>>
>>
>>
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by TomohitoNakayama <to...@basil.ocn.ne.jp>.
Hello Daniel and Mike .

Do you think it is preferable not to allow user to call getXXXXStream 
twice from one row ,
in order to make a room for releasing memory for cache in ResultSet as 
soon as possible ?

Best regards.


Daniel John Debrunner wrote:

>Mike Matrigali wrote:
>
>  
>
>>Is there anything in the standard that says what the second call to
>>the get the stream has to do?  Imagine the case where the first
>>stream reads 1 gig of a 2 gig blob, does the second call to
>>getBinaryStream() have to return the 1st gig again?
>>    
>>
>
>Yes & no.
>
>Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet has
>always had:
>
>" For maximum portability, result set columns within each row should be
>read in left-to-right order, and each column should be read only once."
>
>Thus, Derby could thrown an exception if there was a second getXXXStream
>call on the same column.
>
>  
>
>>Any change that tries to cache the bytes returned by the first
>>getBinaryStream either in local client or network client code is
>>going to be a performance/memory drain.
>>    
>>
>
>Agreed, we need to be careful here, we need to optmise the frequent
>case, getting the column's value once as-per JDBC.
>
>Dan.
>
>
>
>
>  
>

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Mike Matrigali wrote:

> 
> Is there anything in the standard that says what the second call to
> the get the stream has to do?  Imagine the case where the first
> stream reads 1 gig of a 2 gig blob, does the second call to
> getBinaryStream() have to return the 1st gig again?

Yes & no.

Nothing in the JDBC spec doc, but the javadoc for java.sql.ResultSet has
always had:

" For maximum portability, result set columns within each row should be
read in left-to-right order, and each column should be read only once."

Thus, Derby could thrown an exception if there was a second getXXXStream
call on the same column.

> Any change that tries to cache the bytes returned by the first
> getBinaryStream either in local client or network client code is
> going to be a performance/memory drain.

Agreed, we need to be careful here, we need to optmise the frequent
case, getting the column's value once as-per JDBC.

Dan.



Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Mike Matrigali <mi...@sbcglobal.net>.
Is there anything in the standard that says what the second call to
the get the stream has to do?  Imagine the case where the first
stream reads 1 gig of a 2 gig blob, does the second call to 
getBinaryStream() have to return the 1st gig again?

Any change that tries to cache the bytes returned by the first
getBinaryStream either in local client or network client code is
going to be a performance/memory drain.

/mikem

Daniel John Debrunner wrote:
> Mike Matrigali wrote:
> 
>>I am new to this issue and have not reviewed the patch yet.  I am just
>>trying to understand what the correct behavior is.  If this has
>>already been discussed feel free to point that out.I know Sunitha
>>submitted some fixes in this area, but she will not be able to look
>>at these for awhile.
>>
>>In your test it is obvious that the first instance of the stream can
>>not be used anymore since you use the same variable.  What if the
>>test instead did:
>>
>>InputStream is1 = rs.getBinaryStream(1);
>>System.out.println("Here goes first stream");
>>System.out.println(is1.read());
>>System.out.println(is1.read());
>>System.out.println(is1.read());
>>    
>>InputStream is2 = rs.getBinaryStream(1);
>>System.out.println("Here goes 2nd stream");
>>System.out.println(is2.read());
>>System.out.println(is2.read());
>>System.out.println(is2.read());
>>
>>System.out.println("Here goes first stream continuing");
>>System.out.println(is1.read());
>>System.out.println(is1.read());
>>System.out.println(is1.read());
> 
> 
> The second call to getBinaryStream is required to close the first stream.
> 
> Dan.
> 
> 
> 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Daniel John Debrunner <dj...@debrunners.com>.
Mike Matrigali wrote:
> I am new to this issue and have not reviewed the patch yet.  I am just
> trying to understand what the correct behavior is.  If this has
> already been discussed feel free to point that out.I know Sunitha
> submitted some fixes in this area, but she will not be able to look
> at these for awhile.
> 
> In your test it is obvious that the first instance of the stream can
> not be used anymore since you use the same variable.  What if the
> test instead did:
> 
> InputStream is1 = rs.getBinaryStream(1);
> System.out.println("Here goes first stream");
> System.out.println(is1.read());
> System.out.println(is1.read());
> System.out.println(is1.read());
>     
> InputStream is2 = rs.getBinaryStream(1);
> System.out.println("Here goes 2nd stream");
> System.out.println(is2.read());
> System.out.println(is2.read());
> System.out.println(is2.read());
> 
> System.out.println("Here goes first stream continuing");
> System.out.println(is1.read());
> System.out.println(is1.read());
> System.out.println(is1.read());

The second call to getBinaryStream is required to close the first stream.

Dan.


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by TomohitoNakayama <to...@basil.ocn.ne.jp>.
Hello.

Mike Matrigali wrote:

> I am new to this issue and have not reviewed the patch yet.  I am just 
> trying to understand what the correct behavior is.  If this has
> already been discussed feel free to point that out.I know Sunitha 
> submitted some fixes in this area, but she will not be able to look
> at these for awhile.
>
> In your test it is obvious that the first instance of the stream can
> not be used anymore since you use the same variable.  What if the
> test instead did:
>
> InputStream is1 = rs.getBinaryStream(1);
> System.out.println("Here goes first stream");
> System.out.println(is1.read());
> System.out.println(is1.read());
> System.out.println(is1.read());
>     
> InputStream is2 = rs.getBinaryStream(1);
> System.out.println("Here goes 2nd stream");
> System.out.println(is2.read());
> System.out.println(is2.read());
> System.out.println(is2.read());
>
> System.out.println("Here goes first stream continuing");
> System.out.println(is1.read());
> System.out.println(is1.read());
> System.out.println(is1.read());
>

As Daniel told already, is1 is closed when 2nd call of getBinaryStream.

> Also if you have not done so, please always test a short blob (ie. 
> something shorter than 4k and a long blob (something longer than
> 32k or whatever is the page size of the table being used).  There
> are 2 very different paths through the code, depending on size of
> the datatypes.  In the short case they are passed around in memory
> as a single object and in the long case there is an underlying
> stream that should only be read once.  I believe the new test covers
> a lot of these cases.
>

I see .
I will add the test pattern for different size lob.

Best regards.

-- 
/*

        Tomohito Nakayama
        tomonaka@basil.ocn.ne.jp
        tomohito@rose.zero.ad.jp
        tmnk@apache.org

        Naka
        http://www5.ocn.ne.jp/~tomohito/TopPage.html

*/ 


Re: [jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by Mike Matrigali <mi...@sbcglobal.net>.
I am new to this issue and have not reviewed the patch yet.  I am just 
trying to understand what the correct behavior is.  If this has
already been discussed feel free to point that out.I know Sunitha 
submitted some fixes in this area, but she will not be able to look
at these for awhile.

In your test it is obvious that the first instance of the stream can
not be used anymore since you use the same variable.  What if the
test instead did:

InputStream is1 = rs.getBinaryStream(1);
System.out.println("Here goes first stream");
System.out.println(is1.read());
System.out.println(is1.read());
System.out.println(is1.read());
	
InputStream is2 = rs.getBinaryStream(1);
System.out.println("Here goes 2nd stream");
System.out.println(is2.read());
System.out.println(is2.read());
System.out.println(is2.read());

System.out.println("Here goes first stream continuing");
System.out.println(is1.read());
System.out.println(is1.read());
System.out.println(is1.read());

Also if you have not done so, please always test a short blob (ie. 
something shorter than 4k and a long blob (something longer than
32k or whatever is the page size of the table being used).  There
are 2 very different paths through the code, depending on size of
the datatypes.  In the short case they are passed around in memory
as a single object and in the long case there is an underlying
stream that should only be read once.  I believe the new test covers
a lot of these cases.

My main concern with stream issues is that it should always be
possible to write a program that reads and/or writes as a stream
and Derby should never need to instantiate the complete blob/clob
in memory.  Historically this has been broken many times, I believe

I believe sunitha added a range of tests to the "large" suite so
you should run that suite with your change also.
	


Tomohito Nakayama (JIRA) wrote:
>      [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
> 
> Tomohito Nakayama updated DERBY-721:
> ------------------------------------
> 
>     Attachment: DERBY-721_3.patch
> 
> Description of patch :
>    I judged that SQLException should not be thrown in InputStream#close/Reader#close.
>    I remove calling resetStream method from close method and 
>      implemented Resetable interface in UTF8Reader and BinaryToRawStream and 
>      reset them from EmbedResultSet.
> 
> Test of patch:
>    I executed derbyall and does not found new error.
> 
> 
>>State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
>>---------------------------------------------------------------------------------------------------
>>
>>         Key: DERBY-721
>>         URL: http://issues.apache.org/jira/browse/DERBY-721
>>     Project: Derby
>>        Type: Bug
>>  Components: Unknown
>> Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
>>Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
>>naka@rufelza:~/derby/dev/trunk$ java -version
>>java version "1.4.2_10"
>>Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
>>Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>>    Reporter: Tomohito Nakayama
>>    Assignee: Tomohito Nakayama
>> Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>>
>>State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
>>Test code ...
>>	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
>>	byte[] data = new byte[1024 * 1024];
>>	for(int i = 0;
>>	    i < 1024 * 1024;
>>	    i  ++){
>>	    data[i] = (byte)(i % 256);
>>	}
>>	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
>>	pst.executeUpdate();
>>	pst.close();
>>	
>>	
>>	st = conn.createStatement();
>>	ResultSet rs = st.executeQuery("select b from a");
>>	rs.next();
>>	
>>	InputStream is = rs.getBinaryStream(1);
>>	System.out.println("Here goes first stream");
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	
>>	is = rs.getBinaryStream(1);
>>	System.out.println("Here goes 2nd stream");
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>	System.out.println(is.read());
>>Result ....
>>naka@rufelza:~/derby/test/20051121$ java testLob
>>Here goes first stream
>>0
>>1
>>2
>>Here goes 2nd stream
>>7
>>8
>>9
>>It is expected that result printed from first stream is as same as result printed from 2nd.
> 
> 


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721_3.patch

Description of patch :
   I judged that SQLException should not be thrown in InputStream#close/Reader#close.
   I remove calling resetStream method from close method and 
     implemented Resetable interface in UTF8Reader and BinaryToRawStream and 
     reset them from EmbedResultSet.

Test of patch:
   I executed derbyall and does not found new error.

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Component: JDBC
               Network Client
                   (was: Unknown)

I updated Component/s ...

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: JDBC, Network Client
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_5.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12358545 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

Committed

Sending        java/engine/org/apache/derby/impl/jdbc/BinaryToRawStream.java
Sending        java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/master/resultsetStream.out
Sending        java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/resultsetStream.java
Transmitting file data ....
Committed revision 349079.


> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12358335 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

I found that this phenomena does not happen if data length was small, such as 32.

Class of inputstream was different between when phenomena happen and when does not.

When phenomena happens:
main[1] eval is
 is = "org.apache.derby.impl.jdbc.BinaryToRawStream@29d294"

When phenomena does not happen.
main[1] eval is
 is = "org.apache.derby.iapi.services.io.NewByteArrayInputStream@19abd2b"

I suspect closing process of BinaryToRawStream ...

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>  Attachments: testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Assigned: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama reassigned DERBY-721:
---------------------------------------

    Assign To: Tomohito Nakayama

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: testLob.java, testResult.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Reopened: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]
     
Tomohito Nakayama reopened DERBY-721:
-------------------------------------


There found error when using DB2 universal driver .
see http://mail-archives.apache.org/mod_mbox/db-derby-dev/200512.mbox/<43A6A2BB.8040902%40basil.ocn.ne.jp>

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Updated: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
     [ http://issues.apache.org/jira/browse/DERBY-721?page=all ]

Tomohito Nakayama updated DERBY-721:
------------------------------------

    Attachment: DERBY-721_5.patch

Description of patch :
   Add master .out file for using DB2 universal driver .

Test :
   Execute derbyall with classpath contains db2jcc.jar and db2jcc_license_c.jar , and found no error .

> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, DERBY-721_4.patch, DERBY-721_5.patch, DERBY-721_rollback_1+2.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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


[jira] Commented: (DERBY-721) State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .

Posted by "Tomohito Nakayama (JIRA)" <de...@db.apache.org>.
    [ http://issues.apache.org/jira/browse/DERBY-721?page=comments#action_12359728 ] 

Tomohito Nakayama commented on DERBY-721:
-----------------------------------------

http://mail-archives.apache.org/mod_mbox/db-derby-dev/200512.mbox/%3c43971A11.3070909@sbcglobal.net%3e

As discussed in series of mail refered by URL above ,
it should be restricted to get InputStream for same value in result row twice from a ResultSet .



> State of InputStream retrieved from resultset is not clean , if there exists previous InputStream .
> ---------------------------------------------------------------------------------------------------
>
>          Key: DERBY-721
>          URL: http://issues.apache.org/jira/browse/DERBY-721
>      Project: Derby
>         Type: Bug
>   Components: Unknown
>  Environment: naka@rufelza:~/derby/dev/trunk$ cat /proc/version 
> Linux version 2.6.12-1-386 (horms@tabatha.lab.ultramonkey.org) (gcc version 4.0.2 20050917 (prerelease) (Debian 4.0.1-8)) #1 Tue Sep 27 12:41:08 JST 2005
> naka@rufelza:~/derby/dev/trunk$ java -version
> java version "1.4.2_10"
> Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_10-b03)
> Java HotSpot(TM) Client VM (build 1.4.2_10-b03, mixed mode)
>     Reporter: Tomohito Nakayama
>     Assignee: Tomohito Nakayama
>  Attachments: DERBY-721.patch, DERBY-721_2.patch, DERBY-721_3.patch, testLob.java, testLob2.java, testResult.txt, testResult2.txt
>
> State of InputStream retrieved from ResultSet was not clean , if there exists previous InputStream retrieved from ResultSet .
> Test code ...
> 	PreparedStatement pst = conn.prepareStatement("insert into a(b) values(?)");
> 	byte[] data = new byte[1024 * 1024];
> 	for(int i = 0;
> 	    i < 1024 * 1024;
> 	    i  ++){
> 	    data[i] = (byte)(i % 256);
> 	}
> 	pst.setBinaryStream(1,new ByteArrayInputStream(data),data.length);
> 	pst.executeUpdate();
> 	pst.close();
> 	
> 	
> 	st = conn.createStatement();
> 	ResultSet rs = st.executeQuery("select b from a");
> 	rs.next();
> 	
> 	InputStream is = rs.getBinaryStream(1);
> 	System.out.println("Here goes first stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	
> 	is = rs.getBinaryStream(1);
> 	System.out.println("Here goes 2nd stream");
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> 	System.out.println(is.read());
> Result ....
> naka@rufelza:~/derby/test/20051121$ java testLob
> Here goes first stream
> 0
> 1
> 2
> Here goes 2nd stream
> 7
> 8
> 9
> It is expected that result printed from first stream is as same as result printed from 2nd.

-- 
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