Issue Details (XML | Word | Printable)

Key: DERBY-1585
Type: Bug Bug
Status: Closed Closed
Resolution: Fixed
Priority: Major Major
Assignee: Daniel John Debrunner
Reporter: Henri van de Scheur
Votes: 2
Watchers: 1
Operations

If you were logged in you would be able to see more operations.
Derby

derbylang/procedureInTrigger: not able to create trigger due to an open ResultSet

Created: 25/Jul/06 08:54 AM   Updated: 25/Jan/08 02:39 PM
Return to search
Component/s: SQL
Affects Version/s: 10.2.1.6
Fix Version/s: 10.3.3.0, 10.4.1.3

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works close.diff 2007-04-19 10:54 PM Knut Anders Hatlen 2 kB
Text File Licensed for inclusion in ASF works derby1585_diff.txt 2007-12-05 10:38 PM Daniel John Debrunner 9 kB
Text File Licensed for inclusion in ASF works derby1585_diff_v2.txt 2007-12-06 06:08 PM Daniel John Debrunner 14 kB
File Licensed for inclusion in ASF works derby1585_v1.diff 2006-09-08 10:52 PM Deepa Remesh 41 kB
File Licensed for inclusion in ASF works derby1585_v1.status 2006-09-08 10:52 PM Deepa Remesh 0.4 kB
Java Source File Licensed for inclusion in ASF works Main.java 2008-01-08 03:59 PM Dag H. Wanvik 3 kB
Environment:
------------------ Java Information ------------------
Java Version: 1.6.0-rc
Java Vendor: Sun Microsystems Inc.
Java home: /usr/local/java/jdk1.6.0_b91/jre
Java classpath:
test/junit.jar:test/dbprocedures.jar:test/jmxremote.jar:test/javadbtests.jar: test/Dots.jar:test/mail.jar:test/activation.jar:test/Perfmon.jar: test/jakarta-oro-2.0.8.jar:test/commons-logging.jar:test/jagops.jar: test/jdmkrt.jar:test/db2jcc_license_c.jar:test/jet.jar:test/jetbatch.jar: test/db2jcc.jar:test/jag.jar:test/jagclient.jar:test/jagutils.jar:test/GenCfg.jar: test/jmxremote_optional.jar:test/jmx.jar:test/hadbjdbc4.jar:derbyTesting.jar: derby.jar:derbyLocale_zh_TW.jar:derbytools.jar:derbyLocale_ko_KR.jar: derbyLocale_zh_CN.jar:derbyLocale_es.jar:derbyLocale_de_DE.jar:derbyLocale_ja_JP.jar: derbynet.jar:derbyLocale_pt_BR.jar:derbyclient.jar:derbyLocale_fr.jar:derbyrun.jar: derbyLocale_it.jar:

OS name: Linux
OS architecture: i386
OS version: 2.6.9-34.ELsmp
java.specification.name: Java Platform API Specification
java.specification.version: 1.6
--------- Derby Information --------
JRE - JDBC: Java SE 6 - JDBC 4.0
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derby.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbytools.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbynet.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyclient.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc_license_c.jar] 2.4 - (17)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc.jar] 2.4 - (17)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale : [English/United States [en_US]]
Found support for locale: [de_DE]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [es]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [fr]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [it]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ja_JP]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ko_KR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [pt_BR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_CN]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_TW]
version: 10.2.0.4 alpha - (423199)
------------------------------------------------------
Issue Links:
Reference
 

Urgency: Normal
Resolution Date: 11/Jan/08 08:01 PM


 Description  « Hide
********* Diff file derbyall/derbylang/procedureInTrigger.diff
*** Start: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:20 ***
714a715,730
> ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
> ij> --- delete a row. check that trigger is fired - procedure should be called once
> delete from t1 where i=10;
> 1 row inserted/updated/deleted
> ij> --- check delete is successful
> select * from t1;
> I |B
> ---------------------------
> 5 |two
> 6 |four
> 8 |eight
> ij> drop trigger select_from_trig_table;
> ERROR 42X94: TRIGGER 'SELECT_FROM_TRIG_TABLE' does not exist.
> ij> --- use procedures which alter/drop trigger table and some other table
> create trigger alter_table_trig AFTER delete on t1
> for each STATEMENT mode db2sql call alter_table_proc();
716,732d731
< ij> --- delete a row. check that trigger is fired - procedure should be called once
< delete from t1 where i=10;
< selectRows - 1 arg - 1 rs
< 1 row inserted/updated/deleted
< ij> --- check delete is successful
< select * from t1;
< I |B
< ---------------------------
< 5 |two
< 6 |four
< 8 |eight
< ij> drop trigger select_from_trig_table;
< 0 rows inserted/updated/deleted
< ij> --- use procedures which alter/drop trigger table and some other table
< create trigger alter_table_trig AFTER delete on t1
< for each STATEMENT mode db2sql call alter_table_proc();
< 0 rows inserted/updated/deleted
Test Failed.
*** End: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:34 ***

 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Kathey Marsden added a comment - 27/Jul/06 04:49 AM
I will put this in component test for now. I am not sure ultimately if it should be test or sql

Kathey Marsden made changes - 27/Jul/06 04:49 AM
Field Original Value New Value
Description
********* Diff file derbyall/derbylang/procedureInTrigger.diff
*** Start: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:20 ***
714a715,730
> ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
> ij> --- delete a row. check that trigger is fired - procedure should be called once
> delete from t1 where i=10;
> 1 row inserted/updated/deleted
> ij> --- check delete is successful
> select * from t1;
> I |B
> ---------------------------
> 5 |two
> 6 |four
> 8 |eight
> ij> drop trigger select_from_trig_table;
> ERROR 42X94: TRIGGER 'SELECT_FROM_TRIG_TABLE' does not exist.
> ij> --- use procedures which alter/drop trigger table and some other table
> create trigger alter_table_trig AFTER delete on t1
> for each STATEMENT mode db2sql call alter_table_proc();
716,732d731
< ij> --- delete a row. check that trigger is fired - procedure should be called once
< delete from t1 where i=10;
< selectRows - 1 arg - 1 rs
< 1 row inserted/updated/deleted
< ij> --- check delete is successful
< select * from t1;
< I |B
< ---------------------------
< 5 |two
< 6 |four
< 8 |eight
< ij> drop trigger select_from_trig_table;
< 0 rows inserted/updated/deleted
< ij> --- use procedures which alter/drop trigger table and some other table
< create trigger alter_table_trig AFTER delete on t1
< for each STATEMENT mode db2sql call alter_table_proc();
< 0 rows inserted/updated/deleted
Test Failed.
*** End: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:34 ***
********* Diff file derbyall/derbylang/procedureInTrigger.diff
*** Start: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:20 ***
714a715,730
> ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
> ij> --- delete a row. check that trigger is fired - procedure should be called once
> delete from t1 where i=10;
> 1 row inserted/updated/deleted
> ij> --- check delete is successful
> select * from t1;
> I |B
> ---------------------------
> 5 |two
> 6 |four
> 8 |eight
> ij> drop trigger select_from_trig_table;
> ERROR 42X94: TRIGGER 'SELECT_FROM_TRIG_TABLE' does not exist.
> ij> --- use procedures which alter/drop trigger table and some other table
> create trigger alter_table_trig AFTER delete on t1
> for each STATEMENT mode db2sql call alter_table_proc();
716,732d731
< ij> --- delete a row. check that trigger is fired - procedure should be called once
< delete from t1 where i=10;
< selectRows - 1 arg - 1 rs
< 1 row inserted/updated/deleted
< ij> --- check delete is successful
< select * from t1;
< I |B
< ---------------------------
< 5 |two
< 6 |four
< 8 |eight
< ij> drop trigger select_from_trig_table;
< 0 rows inserted/updated/deleted
< ij> --- use procedures which alter/drop trigger table and some other table
< create trigger alter_table_trig AFTER delete on t1
< for each STATEMENT mode db2sql call alter_table_proc();
< 0 rows inserted/updated/deleted
Test Failed.
*** End: procedureInTrigger jdk1.6.0-rc derbyall:derbylang 2006-07-19 13:52:34 ***
Component/s Test [ 11413 ]
Myrna van Lunteren added a comment - 28/Jul/06 06:48 PM
I see a similar diff with wctme5.7/j9 2.2:
*** Start: procedureInTrigger jdk1.3.1 subset - 2.2 2006-07-28 11:45:34 ***
700a701,716
> ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
> ij> --- delete a row. check that trigger is fired - procedure should be called once
> delete from t1 where i=10;
> 1 row inserted/updated/deleted
> ij> --- check delete is successful
> select * from t1;
> I |B
> ---------------------------
> 5 |two
> 6 |four
> 8 |eight
> ij> drop trigger select_from_trig_table;
> ERROR 42X94: TRIGGER 'SELECT_FROM_TRIG_TABLE' does not exist.
> ij> --- use procedures which alter/drop trigger table and some other table
> create trigger alter_table_trig AFTER delete on t1
> for each STATEMENT mode db2sql call alter_table_proc();
702,718d717
< ij> --- delete a row. check that trigger is fired - procedure should be called once
< delete from t1 where i=10;
< selectRows - 1 arg - 1 rs
< 1 row inserted/updated/deleted
< ij> --- check delete is successful
< select * from t1;
< I |B
< ---------------------------
< 5 |two
< 6 |four
< 8 |eight
< ij> drop trigger select_from_trig_table;
< 0 rows inserted/updated/deleted
< ij> --- use procedures which alter/drop trigger table and some other table
< create trigger alter_table_trig AFTER delete on t1
< for each STATEMENT mode db2sql call alter_table_proc();
< 0 rows inserted/updated/deleted
Test Failed.
*** End: procedureInTrigger jdk1.3.1 subset - 2.2 2006-07-28 11:46:08 ***

In other words, wctme5.7 barks earlier than jdk16.

Deepa Remesh made changes - 28/Jul/06 07:31 PM
Assignee Deepa Remesh [ deepa ]
Kathey Marsden made changes - 29/Jul/06 12:02 AM
Component/s Regression Test Failure [ 12310664 ]
Fix Version/s 10.2.0.0 [ 11187 ]
Urgency Normal
Deepa Remesh added a comment - 08/Sep/06 10:52 PM
Attaching a patch 'derby1585_v1.diff' to resolve the intermittent failure seen in the test lang/procedureInTrigger.sql.

The intermittent failure was happening when a result set returned by a procedure called from a trigger remains open. Then when we create another trigger on the same table, we get following exception:
ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.

The purpose of the test is only to test after/before triggers that call a procedure which executes a select statement. As we are calling the procedure from a trigger, there is no need to use a procedure that returns a result set. The result set cannot be accessed from the trigger. So I changed this test to call a new procedure which executes a select, uses the result set and closes it. I believe this will solve the intermittent failure.

This patch modifies only tests. I ran the changed test multiple times on jdk142, jdk15, and j9_22 vm successfully. I modified the master file for jdk16 but have some trouble with jdk16 environment on my machine. So I haven't run the test on jdk16.

Please take a look at this patch and commit if okay.

Deepa Remesh made changes - 08/Sep/06 10:52 PM
Attachment derby1585_v1.diff [ 12340485 ]
Attachment derby1585_v1.status [ 12340486 ]
Daniel John Debrunner added a comment - 08/Sep/06 11:05 PM
Does this mean that there is a bug?
Either:

When a procedure is called from a trigger any ResultSet's returned are not explictly closed by the trigger calling mechanism?

or

procedures that return result sers should not be allowed in triggers.

Might need to look at the standard to see what is expected here. For the first case the question would be should the
returned dynamic result sets simply be closed, or should each row be fetched and then closed. The fetching of rows
could have functions that produce side effects the application is expecting to occur.

Deepa Remesh added a comment - 14/Sep/06 12:04 AM
Pasting the link to my previous comment to derby-dev for reference.
http://www.nabble.com/Re%3A--jira--Commented%3A-%28DERBY-1585%29-derbylang-procedureInTrigger%3A-not-able-to-create-trigger-due-to-an-open-ResultSet-p6235128.html

In the code, the result set returned from executing the trigger action statement is closed. GenericTriggerExecutor.executeSPS fetches all rows and closes the result set. So the problem seems to be elsewhere.

Rick Hillegas added a comment - 19/Sep/06 02:42 PM
Moving to 10.2.2.0.

Rick Hillegas made changes - 19/Sep/06 02:42 PM
Fix Version/s 10.2.2.0 [ 12312027 ]
Fix Version/s 10.2.1.0 [ 11187 ]
Deepa Remesh added a comment - 25/Sep/06 07:33 PM
I had earlier said:
"In the code, the result set returned from executing the trigger action statement is closed. GenericTriggerExecutor.executeSPS fetches all rows and closes the result set. So the problem seems to be elsewhere."

What I had previously stated is not fully correct. Result set returned by executing the trigger action statement (in this case the call statement) is closed. But the result set which is closed is the internal CallStatementResultSet.
The result set returned by the procedure is not closed. It may get closed if it is garbage collected. However, if the result set remains open, a subsequent trigger creation will fail with following error:
ERROR X0X95: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.



Øystein Grøvlen added a comment - 01/Dec/06 09:33 AM
What is the status on this bug fix? It would be nice to get this
fixed since I think it is one of the more common intermittent in the
nightly tests. This week it has also happened twice in the tinderbox
test.

Henri van de Scheur added a comment - 01/Dec/06 10:12 AM
I agree it would be nice to get this one fixed, but I do not have the
resources to follow up bug fixes....
After Deepa assigned this bug, I don't think there has been so much
activity......
I can send a copy of this mail to Rick, maybe it starts itching...... ;-)

Henri


--

With regards,



Henri van de Scheur, Database Technology Group,
Sun Microsystems, Trondheim, Norway


Deepa Remesh added a comment - 01/Dec/06 03:47 PM
After the initial analysis, I hadn't spent much time on this bug. Thanks for bringing this up. I'm unassigning now if anyone else wants to pick this up.

Deepa Remesh made changes - 01/Dec/06 03:47 PM
Assignee Deepa Remesh [ deepa ]
Rick Hillegas added a comment - 06/Dec/06 02:37 PM
Move to 10.2.3.0.

Rick Hillegas made changes - 06/Dec/06 02:37 PM
Fix Version/s 10.2.3.0 [ 12312215 ]
Fix Version/s 10.2.2.0 [ 12312027 ]
Andrew McIntyre added a comment - 25/Jan/07 08:36 PM
Unsetting Fix Version for unassigned issues.

Andrew McIntyre made changes - 25/Jan/07 08:36 PM
Fix Version/s 10.2.3.0 [ 12312215 ]
Knut Anders Hatlen added a comment - 19/Apr/07 10:54 PM
I have a machine where this test (actually, it's the new ProcedureInTriggerTest) fails more or less consistently (running on OpenSolaris and Sun JDK 6). The attached patch makes the test pass, but it's more of a hack than a fix.

The patch makes GenericTriggerExecutor call close() on any dynamic result sets returned by the trigger action, and on their statements. However, the calls to close() are no-ops because setting up the context stack fails and the error is silently ignored. Therefore, I also had to make EmbedPreparedStatement.close() call markUnused() on its activation if setupContextStack() failed. The same thing should probably have been done with singleUseActivation in EmbedResultSet.close() in case the ResultSet didn't come from a PreparedStatement, but that wasn't necessary for this particular issue.

Ugly, I know, but at least it's a starting point... No other tests were run.

Knut Anders Hatlen made changes - 19/Apr/07 10:54 PM
Attachment close.diff [ 12355869 ]
Daniel John Debrunner added a comment - 20/Apr/07 01:26 AM
I see the intent in closing the result sets but this (in edge cases) can lead to exceptions being thrown in a trigger but calling the procedure directly would not throw those exceptions.
That would be when the close() fails on a ResultSet that would be ignored by EmbedStatement.processDynamicResults.
Also if multiple result sets are returned and an exception is thrown on close, then the remaining result sets would not be closed, thus leaving the potential for
the bug to resurface.

It's also strange that the close calls are failing, is it because the result sets are in a limbo between the old closed nested connection and the user connection?
I.e. if this was a plain CALL statement then the ResultSets would be linked into the valid open user connection, which obviously does not (and should not) happen here.

Not sure I have good ideas here on the best approach, but I don't understand why the close() is failing or how the change in EmbedPreparedStatement.close() achieves.
Also the comment about singleUseActivation in EmbedResultSet.close() is not clear to me.


Kristian Waagan added a comment - 20/Apr/07 08:29 AM
There were problems with the line-breaking in the environment field. I removed the prefix '/export/home/tmp/jagtmp/autoderbyN_regression/install/lib' from the Java classpath and broke the lines manually.

Kristian Waagan made changes - 20/Apr/07 08:29 AM
Environment ------------------ Java Information ------------------
Java Version: 1.6.0-rc
Java Vendor: Sun Microsystems Inc.
Java home: /usr/local/java/jdk1.6.0_b91/jre
Java classpath: /export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/junit.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/dbprocedures.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jmxremote.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/javadbtests.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/Dots.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/mail.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/activation.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/Perfmon.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jakarta-oro-2.0.8.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/commons-logging.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jagops.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jdmkrt.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc_license_c.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jet.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jetbatch.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jag.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jagclient.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jagutils.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/GenCfg.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jmxremote_optional.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/jmx.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/hadbjdbc4.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyTesting.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derby.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_zh_TW.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbytools.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_ko_KR.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_zh_CN.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_es.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_de_DE.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_ja_JP.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbynet.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_pt_BR.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyclient.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_fr.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyrun.jar:/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyLocale_it.jar:
OS name: Linux
OS architecture: i386
OS version: 2.6.9-34.ELsmp
java.specification.name: Java Platform API Specification
java.specification.version: 1.6
--------- Derby Information --------
JRE - JDBC: Java SE 6 - JDBC 4.0
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derby.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbytools.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbynet.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyclient.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc_license_c.jar] 2.4 - (17)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc.jar] 2.4 - (17)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale : [English/United States [en_US]]
Found support for locale: [de_DE]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [es]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [fr]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [it]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ja_JP]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ko_KR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [pt_BR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_CN]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_TW]
version: 10.2.0.4 alpha - (423199)
------------------------------------------------------
------------------ Java Information ------------------
Java Version: 1.6.0-rc
Java Vendor: Sun Microsystems Inc.
Java home: /usr/local/java/jdk1.6.0_b91/jre
Java classpath:
test/junit.jar:test/dbprocedures.jar:test/jmxremote.jar:test/javadbtests.jar: test/Dots.jar:test/mail.jar:test/activation.jar:test/Perfmon.jar: test/jakarta-oro-2.0.8.jar:test/commons-logging.jar:test/jagops.jar: test/jdmkrt.jar:test/db2jcc_license_c.jar:test/jet.jar:test/jetbatch.jar: test/db2jcc.jar:test/jag.jar:test/jagclient.jar:test/jagutils.jar:test/GenCfg.jar: test/jmxremote_optional.jar:test/jmx.jar:test/hadbjdbc4.jar:derbyTesting.jar: derby.jar:derbyLocale_zh_TW.jar:derbytools.jar:derbyLocale_ko_KR.jar: derbyLocale_zh_CN.jar:derbyLocale_es.jar:derbyLocale_de_DE.jar:derbyLocale_ja_JP.jar: derbynet.jar:derbyLocale_pt_BR.jar:derbyclient.jar:derbyLocale_fr.jar:derbyrun.jar: derbyLocale_it.jar:

OS name: Linux
OS architecture: i386
OS version: 2.6.9-34.ELsmp
java.specification.name: Java Platform API Specification
java.specification.version: 1.6
--------- Derby Information --------
JRE - JDBC: Java SE 6 - JDBC 4.0
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derby.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbytools.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbynet.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/derbyclient.jar] 10.2.0.4 alpha - (423199)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc_license_c.jar] 2.4 - (17)
[/export/home/tmp/jagtmp/autoderbyN_regression/install/lib/test/db2jcc.jar] 2.4 - (17)
------------------------------------------------------
----------------- Locale Information -----------------
Current Locale : [English/United States [en_US]]
Found support for locale: [de_DE]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [es]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [fr]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [it]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ja_JP]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [ko_KR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [pt_BR]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_CN]
version: 10.2.0.4 alpha - (423199)
Found support for locale: [zh_TW]
version: 10.2.0.4 alpha - (423199)
------------------------------------------------------
Knut Anders Hatlen added a comment - 20/Apr/07 08:48 AM
close() doesn't actually fail, but EmbedResultSet.close() and EmbedPreparedStatement.closeActions() have this piece of code:

try {
setupContextStack(); // make sure there's context
} catch (SQLException se) {
// we may get an exception here if this is part of an XA transaction
// and the transaction has been committed
// just give up and return
return;
}

The exception that is swallowed is a no-current-connection error, so your limbo theory could very well be correct.

With my comment about singleUseActivation I meant to say that the attached patch only fixes the problem if the stored procedure used a PreparedStatement (since ResultSet.close() was a no-op here and I only fixed/hacked EmbedPreparedStatement.closeActions()). If the stored procedure had used a Statement, we would have to find another way to mark the activation as unused.

I guess the main problem is that we only have access to the dynamic results through their JDBC interface, and since we're in the SQL execution layer, we cannot simply call some package private methods to do the required magic.

Anyway, the patch is not meant for commit. Only food for thought.

Mike Matrigali added a comment - 24/Apr/07 05:35 PM
I believe the following junit test failure is the same bug, if not let me know and I will file it as a separate case. it also seems intermittent. It followed on this date in the nightly poster runs in only one enviroment and passed in the others. It failed in
http://dbtg.thresher.com/derby/test/Daily/jvm1.6/testing/testlog/sles/531517-suitesAll_diff.txt

There was 1 error:
1) testTriggerNegative(org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest)java.sql.SQLException: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
at org.apache.derby.impl.jdbc.SQLExceptionFactory40.getSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.Util.generateCsSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.wrapInSQLException(Unknown Source)
at org.apache.derby.impl.jdbc.TransactionResourceImpl.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedConnection.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.ConnectionChild.handleException(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.executeStatement(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derby.impl.jdbc.EmbedStatement.execute(Unknown Source)
at org.apache.derbyTesting.functionTests.tests.lang.ProcedureInTriggerTest.testTriggerNegative(ProcedureInTriggerTest.java:396)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at org.apache.derbyTesting.junit.BaseTestCase.runBare(BaseTestCase.java:88)
at junit.extensions.TestDecorator.basicRun(TestDecorator.java:24)
at junit.extensions.TestSetup$1.protect(TestSetup.java:21)
at junit.extensions.TestSetup.run(TestSetup.java:25)
Caused by: java.sql.SQLException: Operation 'CREATE TRIGGER' cannot be performed on object 'T1' because there is an open ResultSet dependent on that object.
at org.apache.derby.iapi.error.StandardException.newException(Unknown Source)
at org.apache.derby.impl.sql.conn.GenericLanguageConnectionContext.verifyNoOpenResultSets(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.prepareToInvalidate(Unknown Source)
at org.apache.derby.impl.sql.depend.BasicDependencyManager.coreInvalidateFor(Unknown Source)
at org.apache.derby.impl.sql.depend.BasicDependencyManager.invalidateFor(Unknown Source)
at org.apache.derby.impl.sql.execute.CreateTriggerConstantAction.executeConstantAction(Unknown Source)
at org.apache.derby.impl.sql.execute.MiscResultSet.open(Unknown Source)
at org.apache.derby.impl.sql.GenericPreparedStatement.execute(Unknown Source)
... 32 more

Dag H. Wanvik added a comment - 25/Apr/07 12:12 AM
See also my experience/run-in with this test in DERBY-1947. Relying
on explicitly running System.gc and System.runFinalization
is not a sure way to make this work (cf
GenericLanguageConnectionContext#verifyNoOpenResultSets),
so intermittent occurences would be expected.

Dag H. Wanvik made changes - 25/Apr/07 12:13 AM
Link This issue is related to DERBY-1947 [ DERBY-1947 ]
Daniel John Debrunner made changes - 03/Dec/07 10:52 PM
Component/s Regression Test Failure [ 12310664 ]
Component/s Test [ 11413 ]
Component/s SQL [ 11408 ]
Daniel John Debrunner made changes - 04/Dec/07 06:06 PM
Assignee Daniel John Debrunner [ djd ]
Daniel John Debrunner added a comment - 04/Dec/07 06:06 PM
Section 4.27.5 of the TECHNICAL CORRIGENDUM 1 to the SQL 2003 Standard details what happens to dynamic result sets in detail, the SQL 2003 foundation document is missing these details.

If the dynamic result sets are unreachable, which they will be for a CALL statement as a trigger's single action statement, then they must be destroyed, which is ResultSet.close() in JDBC terms.

Thus I think the general idea of the close.diff is correct, but I think a cleaner implementation would be to encapsulate the logic in the close of the activation for the CALL statement. (also need to ensure that all result sets are closed, regardless of any exceptions).

Daniel John Debrunner added a comment - 05/Dec/07 10:38 PM
Patch that closes dynamic result sets in the CallStatementResultSet.close(), thus encapsulating the logic rather than putting CALL specific code in the general trigger path. Code will also work for any other situations where a CALL statement will be executed and the dynamic results inaccessible (ie. potential future changes).

CallStatementResultSet.close() ensures all dynamic ResultSets for the current connection are closed and thus mimics the logic when dynamic results sets are processed in EmbedStatement (through code sharing).

Patch does close result sets in ProcedureInTrigger test that were not closed before, so I assume it will fix the bug, but I haven't be able to make the test fail without the change.

Will run tests on the patch before any commit

Daniel John Debrunner made changes - 05/Dec/07 10:38 PM
Attachment derby1585_diff.txt [ 12371076 ]
Daniel John Debrunner made changes - 05/Dec/07 10:39 PM
Derby Info [Patch Available]
Knut Anders Hatlen added a comment - 05/Dec/07 11:13 PM
I have a machine on which I'm able to reproduce this failure when I use an insane build. I'm afraid it still fails after applying the patch.

Daniel John Debrunner added a comment - 06/Dec/07 02:11 AM
Thanks Knut Anders, I neglected the information you found earlier that the close of the result set did nothing. I'll submit a new patch, again I can't seem to make this test fail.

Daniel John Debrunner added a comment - 06/Dec/07 06:08 PM
Patch that ensures the close on the dynamic results does in fact close the language ResultSet and activation.

Daniel John Debrunner made changes - 06/Dec/07 06:08 PM
Attachment derby1585_diff_v2.txt [ 12371154 ]
Knut Anders Hatlen added a comment - 10/Dec/07 05:31 PM
Hi Dan,

I'm not able to reproduce the failure with the v2 patch, so +1 to commit from me. I found the javadoc comment for EmbedConnectionContext.processInaccessibleDynamicResult() a bit unclear, so you may consider rewriting it. (It talks about converting a ResultSet, but I can't see that any conversion is performed. The interface's javadoc comment says "Process the resultSet as a dynamic result for closure" which sounds clearer to me.)

Repository Revision Date User Message
ASF #602991 Mon Dec 10 18:45:05 UTC 2007 djd DERBY-1585 For a CALL statement that generates dynamic result sets add code so that the result sets are closed if they are inaccessible following the SQL Standard.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedConnectionContext.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/iapi/jdbc/ConnectionContext.java

Daniel John Debrunner added a comment - 10/Dec/07 06:47 PM
Revisions 602991 (trunk) closes inaccessible dynamic result sets from a CALL statement, which was causing the procedureInTriggerTest to fail.

Thanks to Knut Anders for confirming the test no longer failed with the patch.

Daniel John Debrunner made changes - 10/Dec/07 06:47 PM
Resolution Fixed [ 1 ]
Fix Version/s 10.4.0.0 [ 12312540 ]
Derby Info [Patch Available]
Status Open [ 1 ] Resolved [ 5 ]
Knut Anders Hatlen added a comment - 10/Dec/07 07:44 PM
Thanks for fixing this, Dan.

By the way, I noticed this incomplete comment in EmbedStatement:

+ * <P>
+ * if b

Perhaps you could elaborate a bit more on what happens if b... ;)

Repository Revision Date User Message
ASF #603030 Mon Dec 10 20:12:42 UTC 2007 djd DERBY-1585 Remove meaningless comment 'if b'.
Files Changed
MODIFY /db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java

Ole Solberg added a comment - 28/Dec/07 10:27 AM
We still see this on 10.3: http://dbtg.thresher.com/derby/test/stats.html .
Could the 602991(trunk) fix be merged to 10.3?

Dag H. Wanvik added a comment - 08/Jan/08 03:59 PM
I attach a a repro (Main.java) that shows changed behavior after svn 602991
(the patch committed for this issue). It seems a regression:

An explicit commit inside a stored procedure makes a dynamic result sets passed out unavailable, even if the commit is executed *prior* to the result set; as in the repro.
Is this the expected behavior or not? Reopening.


Dag H. Wanvik made changes - 08/Jan/08 03:59 PM
Attachment Main.java [ 12372720 ]
Dag H. Wanvik made changes - 08/Jan/08 04:00 PM
Status Resolved [ 5 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Daniel John Debrunner added a comment - 08/Jan/08 04:24 PM
issue shown by Main.java attachment is a new issue, since it does not involve triggers in any way. Clearer to have a separate issue.

Daniel John Debrunner made changes - 08/Jan/08 04:24 PM
Resolution Fixed [ 1 ]
Status Reopened [ 4 ] Closed [ 6 ]
Repository Revision Date User Message
ASF #611274 Fri Jan 11 19:45:13 UTC 2008 djd DERBY-1585 For a CALL statement that generates dynamic result sets add code so t hat the result sets are closed if they are inaccessible following the SQL Standard.
Merge of 602991 and 603030 from trunk.
Slight hand-merge for EmbedStatement with 602991 due to a moved call to ResultSet.finish() being changed to a ResultSet.close().
Files Changed
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedConnectionContext.java
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/iapi/jdbc/ConnectionContext.java

Daniel John Debrunner added a comment - 11/Jan/08 07:58 PM
To record back-port to 10.3 branch

Daniel John Debrunner made changes - 11/Jan/08 07:58 PM
Status Closed [ 6 ] Reopened [ 4 ]
Resolution Fixed [ 1 ]
Daniel John Debrunner added a comment - 11/Jan/08 08:01 PM
Revision: 611274 merges trunk revisions 602991 and 603030 to the 10.3 branch.

Daniel John Debrunner made changes - 11/Jan/08 08:01 PM
Status Reopened [ 4 ] Resolved [ 5 ]
Fix Version/s 10.3.2.2 [ 12312885 ]
Resolution Fixed [ 1 ]
Henri van de Scheur added a comment - 25/Jan/08 02:39 PM
Not seen anymore after week 2 when this was fixed

Henri van de Scheur made changes - 25/Jan/08 02:39 PM
Status Resolved [ 5 ] Closed [ 6 ]
Repository Revision Date User Message
ASF #615407 Sat Jan 26 00:02:13 UTC 2008 myrnavl backport revision 608039 to fix the javadoc warning introduced with the backport
of the fix for DERBY-1585 (611274, backport of 602991).
Files Changed
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/execute/CallStatementResultSet.java

Repository Revision Date User Message
ASF #628130 Fri Feb 15 17:36:50 UTC 2008 mamta DERBY-3304
DERBY-3037
DERBY-1585

I am adding a test case to check for the resultset from the java procedure call when the
java procedure has done a rollback inside it. This test shows that in trunk, after checkin
602991 for DERBY-1585, a procedure does not return a resultset if there was a rollbck
inside the procedure with resultset creation before rollback. This behavior is different
than what happens in 10.2 codeline. In 10.2, a procedure will return a *closed* resultset
if there was a rollback inside the procedure. But a procedure should not return closed
result sets, so it appears that trunk is behaving correctly and 10.2's behavior was
incorrect.
Files Changed
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/junit/JDBC.java
MODIFY /db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java

Repository Revision Date User Message
ASF #633778 Wed Mar 05 06:03:22 UTC 2008 mamta I am backporting quite a few checkins from trunk into 10.3 codeline for DERBY-3304 and
DERBY-3404.

The main functionality that is getting ported is when a user initiates a rollback through
JDBC Connection object, the rollback should not close the resultsets that do not return
rows.

This functionality was checked in into trunk through multiple checkins for DERBY-3304 and
those checkins are 628130, 629926, 631481. In addition, there was a supporting checkin into
trunk by Knut for DERBY-3404 (revision 629712) on which the 3 checkins listed earlier rely.
I am backporting all of these 4 checkins from trunk into 10.3 codeline.

The tests have run fine with no new regression.

I am including checkin comments for all these revisions for easy reference here.
**********checkin comments for 628130)**************
DERBY-3304
DERBY-3037
DERBY-1585

I am adding a test case to check for the resultset from the java procedure call when the
java procedure has done a rollback inside it. This test shows that in trunk, after checkin
602991 for DERBY-1585, a procedure does not return a resultset if there was a rollbck
inside the procedure with resultset creation before rollback. This behavior is different
than what happens in 10.2 codeline. In 10.2, a procedure will return a *closed* resultset
if there was a rollback inside the procedure. But a procedure should not return closed
result sets, so it appears that trunk is behaving correctly and 10.2's behavior was
incorrect.
**********end of checkin comments for 628130)*******


**********checkin comments for 629712)**************
DERBY-3404: EmbedResultSet.getString() returns wrong value after auto-commit with
CLOSE_CURSORS_AT_COMMIT
**********end of checkin comments for 629712)*******


**********checkin comments for 629926)**************
DERBY-3304

The main purpose of this patch is to fix the rollback handling for resultsets that do not
return rows. An example case for this is a java procedure which has a Connection.rollback
inside it. When the user calls the java procedure, and Connection.rollback is made inside
of it, Derby should not be closing the resultset assoicated with the java procedure call
(that resultset is a CallStatementResultSet). In other words, a user initiated rollback
through JDBC Connection object should leave the resultsets that do not return rows open. In
order to implement this, I had to make changes to ignore resultsets that do not return rows
in
GenericLanguageConnectionContext.endTransactionActivationHandling. As a result of this
change, for the eg case given above, the activation assoicated with the java procedure
will not be reset (which also means that, CallStatementResultSet.close will not be called)
inside GenericLanguageConnectionContext.endTransactionActivationHandling.

But the code inside CallStatementResultset.close() took care of the closed dynamic resultset
and it took out the closed dynamic resultset from the list of resultsets that would be
available to user through the Statement.getResultSet api. With my changes through this
patch, we are going to skip the CallStatementResultset.close during
GenericLanguageConnectionContext.endTransactionActivationHandling which means that we have
to deal with those closed dynamic resultsets on our own. I did that part of logic
changes in EmbedStatement.processDynamicResults

EmbedStatement.processDynamicResults used to check if the JDBC Resultset is closed by
directly checking the field isClosed in the EmbedResultSet. But it is not sufficient to
check only JDBC Resultset. We need to check the underlying language Resultset too to
determine if the dynamic resultset is closed. There is no direct api on EmbedResultset
which will return a boolean after checking the JDBC Resultset and language Resulset. Instead,
there is a method called EmbedResultSet.checkIfClosed. This method will throw an exception
if it finds the JDBC ResultSet or language ResultSet closed. So, my changes in
EmbedStatement.processDynamicResults make a call to EmbedResultSet.checkIfClosed and if
there is an exception thrown, then we know that the resultset is closed and hence we should
move to the next resultset.

In addition to these code changes, I have added a new test to LangProcedureTest. The new
java procedure is defined to return 2 dynamic resultsets. One of these resultsets is
created before Connection.rollback inside the java procedure. The other dynamic resultset
is created after Connection.rollback. As as result of Connection.rollback, the first
dynamic resultset will be closed but the second one will remain open. The test makes sure
that only one dynamic resultset is returned by the java procedure.

Also, made one minor change in LangProcedureTest for an existing test. The test at line 804
was getting a resultset from the Statement object without asserting that there are no more
resultsets. The resultset object would have been null anyways in this test because there
are no open resulsets from the Java procedure. Because of this, I took out the redundant
code of getting null resultset object from Statement using getResultset,
**********end of checkin comments for 629926)*******


**********checkin comments for 631481)**************
Checking in code cleanup for DERBY-3304. This code cleanup is based on Knut's review of my
earlier commit 629926. No functionality has changed, but code will be now much easier to
read.
**********end of checkin comments for 631481)*******
Files Changed
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/jdk16/closed.out
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/closed.out
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbc4/ResultSetTest.java
MODIFY /db/derby/code/branches/10.3/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/jdbcapi/DataSourceTest.java
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/master/nestedCommit.out
MODIFY /db/derby/code/branches/10.3/java/testing/org/apache/derbyTesting/functionTests/tests/lang/LangProcedureTest.java