db-derby-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Mamta A. Satoor (Commented) (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (DERBY-3823) NullPointerException in stress.multi test
Date Mon, 10 Oct 2011 19:52:30 GMT

    [ https://issues.apache.org/jira/browse/DERBY-3823?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13124427#comment-13124427

Mamta A. Satoor commented on DERBY-3823:

Dag, I wrote a program to see what happens to the resultset's metadata description when it
gets changed underneath while a resultset is still open. (I ran this program with the current
trunk codeline, ie without Dag;s suggested changes)

As you suspected, embedded version throws an error because the resultset is still open but
netwrok server goes ahead and allows the metadata change but this change does not get reflected
in the resultset's metadata descriptor even after a fresh fetch of resultset's metadata descriptor
after the metadata change. 

To run in the embedded mode, run the program with no parameters or with '1'. To run it in
network server mode, have the network server running and then run the program with any value
other than '1' for the parameter. eg
embedded mode
java DERBY3824StressTestNPE 1
java DERBY3824StressTestNPE
For Network server mode
java DERBY3824StressTestNPE 0

The test results for embedded mode looks as follows
Done loading data
char column length is 5
should get error for inserting too large of a data
Error is A truncation error was encountered trying to shrink VARCHAR '12345678'to length 5.
Exception in thread "main" java.sql.SQLException: Operation 'ALTER TABLE' cannot be performed
on object 'T1' because there is an open ResultSet dependent on tha
t object.

The test results for network server mode looks as follows
Done loading data
char column length is 5
should get error for inserting too large of a data
Error is A truncation error was encountered trying to shrink VARCHAR '12345678'to length 5.
char column length after alter table is 5
was able to insert large data

Following is the program. 
import java.sql.*;

public class DERBY3824StressTestNPE extends Thread {
    public static void main(String[] args) throws Exception {
		Connection conn = null;
		if (args.length == 1) {
			int embedded = Integer.parseInt(args[0]);
			if (embedded == 1) {
		        conn =  DriverManager.getConnection(
			} else {
		        String url = "jdbc:derby://localhost:1527/DERBY4437DB;create=true";
		        conn = DriverManager.getConnection(url);
	    } else {
	        conn =  DriverManager.getConnection(
        Statement st  = conn.createStatement();
        st.executeUpdate("create table t1(c11 int, "+
        		"c12 varchar(5))");
        PreparedStatement ps = 
	        conn.prepareStatement("insert into t1 values(?,'aaaaa')");
		for (int i = 0; i < 1000; i++) {
			ps.setInt(1, i);
        System.out.println("Done loading data");

        ResultSet rs = st.executeQuery("select * from t1");
		for (int i = 0; i < 100; i++) {
		ResultSetMetaData rsmd = rs.getMetaData();
		int charLength = rsmd.getColumnDisplaySize(2);
		System.out.println("char column length is " + charLength);
        Statement st2  = conn.createStatement();
        try {
		st2.executeUpdate("insert into t1 values(99,'12345678')");
        } catch(Exception ex) {
        	System.out.println("should get error for inserting too large of a data");
        	System.out.println("Error is " + ex.getMessage());

		st2.execute("alter table t1 alter column c12 set data type varchar(8)");
		rsmd = rs.getMetaData();
		charLength = rsmd.getColumnDisplaySize(2);
		System.out.println("char column length after alter table is " + charLength);
		st2.executeUpdate("insert into t1 values(99,'12345678')");
		System.out.println("was able to insert large data");
> NullPointerException in stress.multi test
> -----------------------------------------
>                 Key: DERBY-3823
>                 URL: https://issues.apache.org/jira/browse/DERBY-3823
>             Project: Derby
>          Issue Type: Bug
>          Components: Network Server
>    Affects Versions:,,
>            Reporter: Kathey Marsden
>              Labels: derby_triage10_5_2
>         Attachments: d3823-1.diff, derby.log
> I saw the following NPE in stress.multi running on 10.3 with derbyclient.
> java.lang.NullPointerException
>         at org.apache.derby.impl.jdbc.EmbedPreparedStatement.getMetaData(Unknown
>  Source)
>         at org.apache.derby.impl.drda.DRDAConnThread.writeSQLDARD(Unknown Source
> )
>         at org.apache.derby.impl.drda.DRDAConnThread.processCommands(Unknown Sou
> rce)
>         at org.apache.derby.impl.drda.DRDAConnThread.run(Unknown Source)
> Cleanup action completed

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira


View raw message