You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by my...@apache.org on 2014/05/28 02:32:26 UTC

svn commit: r1597910 - in /db/derby/code/trunk/java: testing/org/apache/derbyTesting/functionTests/master/ testing/org/apache/derbyTesting/functionTests/tests/tools/ tools/org/apache/derby/impl/tools/ij/ tools/org/apache/derby/loc/

Author: myrnavl
Date: Wed May 28 00:32:26 2014
New Revision: 1597910

URL: http://svn.apache.org/r1597910
Log:
DERBY-6585; add HoldForConnection ij command to match NoHoldForConnection
   adding the new command, including updating the help output. Also adding a test.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql   (with props)
Modified:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ToolScripts.java
    db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
    db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out?rev=1597910&r1=1597909&r2=1597910&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/ij.out Wed May 28 00:32:26 2014
@@ -103,6 +103,8 @@ help;
                                -- each column to integerValue
   ASYNC name 'SQL-J text';     -- run the command in another thread
   WAIT FOR name;               -- wait for result of ASYNC'd command
+  HOLDFORCONNECTION;           -- sets holdability for a connection to HOLD
+                               -- (i.e. ResultSet.HOLD_CURSORS_OVER_COMMIT)
   NOHOLDFORCONNECTION;         -- sets holdability for a connection to NO HOLD
                                -- (i.e. ResultSet.CLOSE_CURSORS_AT_COMMIT)
   GET [SCROLL INSENSITIVE] [WITH  { HOLD | NOHOLD }] CURSOR name AS 'SQL-J query';

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out?rev=1597910&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out Wed May 28 00:32:26 2014
@@ -0,0 +1,131 @@
+ij> --
+--   Licensed to the Apache Software Foundation (ASF) under one or more
+--   contributor license agreements.  See the NOTICE file distributed with
+--   this work for additional information regarding copyright ownership.
+--   The ASF licenses this file to You under the Apache License, Version 2.0
+--   (the "License"); you may not use this file except in compliance with
+--   the License.  You may obtain a copy of the License at
+--
+--      http://www.apache.org/licenses/LICENSE-2.0
+--
+--   Unless required by applicable law or agreed to in writing, software
+--   distributed under the License is distributed on an "AS IS" BASIS,
+--   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+--   See the License for the specific language governing permissions and
+--   limitations under the License.
+--
+-- create a table
+create table sethold(c1 int, c2 int);
+0 rows inserted/updated/deleted
+ij> -- insert data into tables
+insert into sethold values(1,1);
+1 row inserted/updated/deleted
+ij> insert into sethold values(2,2);
+1 row inserted/updated/deleted
+ij> -- set autocommit off
+autocommit off;
+ij> -- first test - make sure that cursors created with default holdability
+-- have open resultsets after commit
+get cursor jdk1 as 'SELECT * FROM sethold';
+ij> get scroll insensitive cursor jdk2 as 'SELECT * FROM sethold';
+ij> -- do fetches from these cursors
+next jdk1;
+C1         |C2         
+-----------------------
+1          |1          
+ij> next jdk2;
+C1         |C2         
+-----------------------
+1          |1          
+ij> --commit and see if the cursors are still open
+commit;
+ij> next jdk1;
+C1         |C2         
+-----------------------
+2          |2          
+ij> next jdk2;
+C1         |C2         
+-----------------------
+2          |2          
+ij> -- second test - make sure that cursors created with holdability false
+-- do not have open resultsets after commit
+
+-- set NoHold, then declare 2 different kind of cursors and fetch from them
+NoHoldForConnection;
+ij> get cursor jdk3 as 'SELECT * FROM sethold';
+ij> get scroll insensitive cursor jdk4 as 'SELECT * FROM sethold';
+ij> -- do fetches from these cursors
+next jdk3;
+C1         |C2         
+-----------------------
+1          |1          
+ij> next jdk4;
+C1         |C2         
+-----------------------
+1          |1          
+ij> --commit and see if the cursors are still open
+commit;
+ij> next jdk3;
+ERROR XCL16: ResultSet not open. Operation 'next' not permitted. Verify that autocommit is off.
+ij> next jdk4;
+ERROR XCL16: ResultSet not open. Operation 'next' not permitted. Verify that autocommit is off.
+ij> -- third test - make sure that cursors created with holdability true
+-- have open resultsets after commit
+-- set Hold, then declare 2 different kind of cursors and fetch from them
+HoldForConnection;
+ij> get cursor jdk5 as 'SELECT * FROM sethold';
+ij> get scroll insensitive cursor jdk6 as 'SELECT * FROM sethold';
+ij> -- do fetches from these cursors
+next jdk5;
+C1         |C2         
+-----------------------
+1          |1          
+ij> next jdk6;
+C1         |C2         
+-----------------------
+1          |1          
+ij> --commit
+commit;
+ij> next jdk5;
+C1         |C2         
+-----------------------
+2          |2          
+ij> next jdk6;
+C1         |C2         
+-----------------------
+2          |2          
+ij> -- fourth test - make sure that we get the same behavior as before after
+-- setting the holdability to No Hold again.
+
+-- set NoHold, then declare 2 different kind of cursors and fetch from them
+NoHoldForConnection;
+ij> get cursor jdk7 as 'SELECT * FROM sethold';
+ij> get scroll insensitive cursor jdk8 as 'SELECT * FROM sethold';
+ij> -- do fetches from these cursors
+next jdk7;
+C1         |C2         
+-----------------------
+1          |1          
+ij> next jdk8;
+C1         |C2         
+-----------------------
+1          |1          
+ij> --commit and see if the cursors are still open
+commit;
+ij> next jdk7;
+ERROR XCL16: ResultSet not open. Operation 'next' not permitted. Verify that autocommit is off.
+ij> next jdk8;
+ERROR XCL16: ResultSet not open. Operation 'next' not permitted. Verify that autocommit is off.
+ij> -- clean up.
+close jdk1;
+ij> close jdk2;
+ij> close jdk3;
+ij> close jdk4;
+ij> close jdk5;
+ij> close jdk6;
+ij> close jdk7;
+ij> close jdk8;
+ij> drop table sethold;
+0 rows inserted/updated/deleted
+ij> commit;
+ij> 
\ No newline at end of file

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/setholdij.out
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ToolScripts.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ToolScripts.java?rev=1597910&r1=1597909&r2=1597910&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ToolScripts.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/ToolScripts.java Wed May 28 00:32:26 2014
@@ -53,7 +53,7 @@ public final class ToolScripts extends S
      *
      */
     private static final String[] CLIENT_AND_EMBEDDED_TESTS = {
-        "ij4", "ij6", "ij7",
+        "ij4", "ij6", "ij7", "setholdij",
     };
 
     /**

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql?rev=1597910&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql Wed May 28 00:32:26 2014
@@ -0,0 +1,105 @@
+--
+--   Licensed to the Apache Software Foundation (ASF) under one or more
+--   contributor license agreements.  See the NOTICE file distributed with
+--   this work for additional information regarding copyright ownership.
+--   The ASF licenses this file to You under the Apache License, Version 2.0
+--   (the "License"); you may not use this file except in compliance with
+--   the License.  You may obtain a copy of the License at
+--
+--      http://www.apache.org/licenses/LICENSE-2.0
+--
+--   Unless required by applicable law or agreed to in writing, software
+--   distributed under the License is distributed on an "AS IS" BASIS,
+--   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+--   See the License for the specific language governing permissions and
+--   limitations under the License.
+--
+-- create a table
+create table sethold(c1 int, c2 int);
+
+-- insert data into tables
+insert into sethold values(1,1);
+insert into sethold values(2,2);
+-- set autocommit off
+autocommit off;
+
+-- first test - make sure that cursors created with default holdability
+-- have open resultsets after commit
+get cursor jdk1 as 'SELECT * FROM sethold';
+get scroll insensitive cursor jdk2 as 'SELECT * FROM sethold';
+
+-- do fetches from these cursors
+next jdk1;
+next jdk2;
+
+--commit and see if the cursors are still open
+commit;
+
+next jdk1;
+next jdk2;
+
+-- second test - make sure that cursors created with holdability false
+-- do not have open resultsets after commit
+
+-- set NoHold, then declare 2 different kind of cursors and fetch from them
+NoHoldForConnection;
+get cursor jdk3 as 'SELECT * FROM sethold';
+get scroll insensitive cursor jdk4 as 'SELECT * FROM sethold';
+
+-- do fetches from these cursors
+next jdk3;
+next jdk4;
+
+--commit and see if the cursors are still open
+commit;
+
+next jdk3;
+next jdk4;
+
+-- third test - make sure that cursors created with holdability true
+-- have open resultsets after commit
+-- set Hold, then declare 2 different kind of cursors and fetch from them
+HoldForConnection;
+get cursor jdk5 as 'SELECT * FROM sethold';
+get scroll insensitive cursor jdk6 as 'SELECT * FROM sethold';
+
+-- do fetches from these cursors
+next jdk5;
+next jdk6;
+
+--commit
+commit;
+
+next jdk5;
+next jdk6;
+
+-- fourth test - make sure that we get the same behavior as before after
+-- setting the holdability to No Hold again.
+
+-- set NoHold, then declare 2 different kind of cursors and fetch from them
+NoHoldForConnection;
+get cursor jdk7 as 'SELECT * FROM sethold';
+get scroll insensitive cursor jdk8 as 'SELECT * FROM sethold';
+
+-- do fetches from these cursors
+next jdk7;
+next jdk8;
+
+--commit and see if the cursors are still open
+commit;
+
+next jdk7;
+next jdk8;
+
+
+-- clean up.
+close jdk1;
+close jdk2;
+close jdk3;
+close jdk4;
+close jdk5;
+close jdk6;
+close jdk7;
+close jdk8;
+drop table sethold;
+commit;

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/tools/setholdij.sql
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj?rev=1597910&r1=1597909&r2=1597910&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/impl/tools/ij/ij.jj Wed May 28 00:32:26 2014
@@ -1196,6 +1196,7 @@ TOKEN [IGNORE_CASE] :
 |	<GET: "get">
 |	<GETCURRENTROWNUMBER: "getcurrentrownumber">
 |	<HOLD: "hold">
+|   <HOLDFORCONNECTION: "holdforconnection">
 |	<HELP: "help">
 |	<IN: "in">
 |	<INDEXES: "indexes">
@@ -1584,6 +1585,7 @@ throws SQLException
 |	r=GetCursorStatement()	
 |	r=GetCurrentRowNumber()	
 |	r=HelpStatement()	
+|   r=HoldForConnectionStatement()    
 |	r=LastStatement()	
 |	r=LocalizedDisplay()
 |	r=MaximumDisplayWidthStatement()	
@@ -2815,6 +2817,27 @@ throws SQLException
 }
 
 /**
+ * By default, holdability is set to true for Connection objects. This syntax HOLDFORCONNECTION lets you set it to the default.
+ * Syntax:
+ *   HOLDFORCONNECTION ;
+ */
+ijResult
+HoldForConnectionStatement()
+throws SQLException
+:
+{
+    Token on=null;
+}
+{
+    <HOLDFORCONNECTION> 
+    {
+        haveConnection();
+        theConnection.setHoldability(ResultSet.HOLD_CURSORS_OVER_COMMIT);
+        return null;
+    }
+}
+
+/**
  * Localizeddisplay controls locale sensitive data representayion
  * <p>
  * Syntax:

Modified: db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties?rev=1597910&r1=1597909&r2=1597910&view=diff
==============================================================================
--- db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties (original)
+++ db/derby/code/trunk/java/tools/org/apache/derby/loc/toolsmessages.properties Wed May 28 00:32:26 2014
@@ -126,6 +126,8 @@ IJ_HelpText=\
 \  ASYNC name ''SQL-J text'';     -- run the command in another thread\n\
 \  WAIT FOR name;               -- wait for result of ASYNC''d command\n\
 \ \n\
+\  HOLDFORCONNECTION;           -- sets holdability for a connection to HOLD\n\
+\                               -- (i.e. ResultSet.HOLD_CURSORS_OVER_COMMIT)\n\
 \  NOHOLDFORCONNECTION;         -- sets holdability for a connection to NO HOLD\n\
 \                               -- (i.e. ResultSet.CLOSE_CURSORS_AT_COMMIT)\n\
 \  GET [SCROLL INSENSITIVE] [WITH  '{' HOLD | NOHOLD '}'] CURSOR name AS ''SQL-J query'';\n\