db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From be...@apache.org
Subject svn commit: r332491 [1/4] - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/conn/ engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/jdbc/ engine/org/apache/derby/impl/sql/ engine/org/apache/derby/impl/sql/compile/...
Date Fri, 11 Nov 2005 08:42:33 GMT
Author: bernt
Date: Fri Nov 11 00:41:31 2005
New Revision: 332491

URL: http://svn.apache.org/viewcvs?rev=332491&view=rev
Log:
DERBY-231 FOR UPDATE required for updatable result set to work. Submitted by  Andreas Korneliussen
<Andreas.Korneliussen@Sun.COM>

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/updatableResultSet.out
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatableResultSet.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionContext.java
Fri Nov 11 00:41:31 2005
@@ -593,7 +593,7 @@
 	 * @return StatementContext	The statement context.
 	 *
 	 */
-	StatementContext pushStatementContext(boolean isAtomic, String stmtText,
+	StatementContext pushStatementContext(boolean isAtomic, boolean isForReadOnly, String stmtText,
 		ParameterValueSet pvs, boolean rollbackParentContext, long timeoutMillis);
 
 	/**
@@ -863,12 +863,34 @@
 	/** Get the AccessFactory cached in this LanguageConnectionContext */
 	AccessFactory getAccessFactory();
 
-	/**
-		Return a compiled Statement object. The schema and unicode
-		setting fo the returned statement are that of this connection.
-	*/
-	public PreparedStatement prepareInternalStatement(String sqlText) throws StandardException;
-	public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema, String
sqlText) throws StandardException;
+        /**
+	 * Return a PreparedStatement object for the query.
+	 * This method first tries to locate the PreparedStatement object from a statement
+	 * cache.  If the statement is not found in the cache, the query will be compiled and
+	 * put into the cache.
+	 * @param compilationSchema schema
+	 * @param sqlText sql query string
+	 * @param isForReadOnly read only status for resultset. Set to true if the concurrency mode
for the resultset 
+	 *                      is CONCUR_READ_ONLY
+	 */
+         public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema,
String sqlText, boolean isForReadOnly) 
+	    throws StandardException;
+
+        /**
+	 * Return a PreparedStatement object for the query.
+	 * This method first tries to locate the PreparedStatement object from a statement
+	 * cache.  If the statement is not found in the cache, the query will be compiled and 
+	 * put into the cache.
+	 * The schema used when compiling the statement is the same schema as returned by
+	 * getDefaultSchema().  For internal statements, the read only status is set to
+	 * true.
+	 * Calling this method is equivalent to calling 
+	 * prepareExternalStatement(lcc.getDefaultSchema(), sqlText, true);
+	 * 
+	 * @param sqlText sql query string
+	 */
+        public PreparedStatement prepareInternalStatement(String sqlText) 
+	    throws StandardException;
 
 	/**
 	 * Control whether or not optimizer trace is on.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/LanguageConnectionFactory.java
Fri Nov 11 00:41:31 2005
@@ -80,13 +80,15 @@
 	 */
 	String MODULE = "org.apache.derby.iapi.sql.conn.LanguageConnectionFactory";
 
+
 	/**
-		Get a Statement.
-		
+		Get a Statement
+		@param compilationSchema schema
 		@param statementText the text for the statement
+		@param forReadOnly true if concurrency mode is CONCUR_READ_ONLY
 		@return	The Statement
 	 */
-	Statement getStatement(SchemaDescriptor compilationSchema, String statementText);
+	Statement getStatement(SchemaDescriptor compilationSchema, String statementText, boolean
forReadOnly);
 
 	/**
 		Get a new LanguageConnectionContext. this holds things

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/conn/StatementContext.java Fri
Nov 11 00:41:31 2005
@@ -47,6 +47,8 @@
 	 *	@param inTrigger true if the parent started in the context of a trigger
 	 *	@param	isAtomic true if the statement must be executed
 	 *		atomically
+	 *      @param isForReadOnly true if the statement is for producing non-updatable
+	 *                           resultset
 	 *  @param stmtText the text of the statement.  Needed for any language
 	 * 	statement (currently, for any statement that can cause a trigger
 	 * 	to fire).  Please set this unless you are some funky jdbc setXXX
@@ -55,8 +57,8 @@
      *  @param timeoutMillis timeout value for the statement, in milliseconds.
      *   Zero means no timeout.
 	 */
-    public void setInUse(boolean inTrigger, boolean isAtomic, String stmtText,
-                         ParameterValueSet pvs, long timeoutMillis);
+    public void setInUse(boolean inTrigger, boolean isAtomic, boolean isForReadOnly,
+			 String stmtText, ParameterValueSet pvs, long timeoutMillis);
 
 	/**
 	 * Mark this context as not in use.  This is important because we
@@ -173,6 +175,14 @@
 	 * @return true if in use
 	 */
 	public boolean inUse();
+
+    /**
+     * Is this statement for a read only, non-updatable ResultSet
+     * @return true if the statement is for creating a 
+     *         read only, non-updatable ResultSet
+     */
+    public boolean isForReadOnly();
+    
 	
     /**
      * Checks if the statement which has allocated this statement context

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/SPSDescriptor.java
Fri Nov 11 00:41:31 2005
@@ -346,7 +346,7 @@
 		}
 
 		// stored statements always stored as unicode.
-		Statement 			stmt = lcf.getStatement(dd.getSchemaDescriptor(compSchemaId, null), text);
+		Statement 			stmt = lcf.getStatement(dd.getSchemaDescriptor(compSchemaId, null), text,
true);
 
 		try
 		{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedPreparedStatement.java
Fri Nov 11 00:41:31 2005
@@ -115,8 +115,10 @@
 			SQLText = sql;
 
 			try {
-			    preparedStatement = lcc.prepareInternalStatement(sql);
-				getWarnings(preparedStatement.getCompileTimeWarnings());
+			    preparedStatement = lcc.prepareInternalStatement
+				(lcc.getDefaultSchema(), sql, resultSetConcurrency==JDBC20Translation.CONCUR_READ_ONLY);
+			    
+			    getWarnings(preparedStatement.getCompileTimeWarnings());
 
 			    activation = preparedStatement.getActivation(lcc, resultSetType == JDBC20Translation.TYPE_SCROLL_INSENSITIVE);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java Fri Nov
11 00:41:31 2005
@@ -336,8 +336,10 @@
 				 * (Cache the LanguageConnectionContext)
 				 */
                 StatementContext statementContext =
-                    lcc.pushStatementContext(isAtomic, getSQLText(),
-                                             getParameterValueSet(),
+                    lcc.pushStatementContext(isAtomic, 
+					     concurrencyOfThisResultSet==JDBC20Translation.CONCUR_READ_ONLY, 
+					     getSQLText(),
+					     getParameterValueSet(),
                                              false, timeoutMillis);
 
 				switch (position)
@@ -3234,7 +3236,7 @@
             lcc = getEmbedConnection().getLanguageConnection();
 
             // Context used for preparing, don't set any timeout (use 0)
-            statementContext = lcc.pushStatementContext(isAtomic, updateWhereCurrentOfSQL.toString(),
null, false, 0L);
+            statementContext = lcc.pushStatementContext(isAtomic, false, updateWhereCurrentOfSQL.toString(),
null, false, 0L);
             org.apache.derby.iapi.sql.PreparedStatement ps = lcc.prepareInternalStatement(updateWhereCurrentOfSQL.toString());
             Activation act = ps.getActivation(lcc, false);
 
@@ -3286,7 +3288,7 @@
                 LanguageConnectionContext lcc = getEmbedConnection().getLanguageConnection();
 
                 // Context used for preparing, don't set any timeout (use 0)
-                StatementContext statementContext = lcc.pushStatementContext(isAtomic, deleteWhereCurrentOfSQL.toString(),
null, false, 0L);
+                StatementContext statementContext = lcc.pushStatementContext(isAtomic, false,
deleteWhereCurrentOfSQL.toString(), null, false, 0L);
                 org.apache.derby.iapi.sql.PreparedStatement ps = lcc.prepareInternalStatement(deleteWhereCurrentOfSQL.toString());
                 // Don't set any timeout when deleting rows (use 0)
                 org.apache.derby.iapi.sql.ResultSet rs = ps.execute(lcc, true, 0L); //execute
delete where current of sql
@@ -3918,7 +3920,9 @@
 							.getLanguageConnection();
                     // No timeout for this operation (use 0)
 					StatementContext statementContext =
-                        lcc.pushStatementContext(isAtomic, getSQLText(),
+                        lcc.pushStatementContext(isAtomic, 
+						 concurrencyOfThisResultSet==JDBC20Translation.CONCUR_READ_ONLY,
+						 getSQLText(),
                                                  getParameterValueSet(),
                                                  false, 0L);
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/jdbc/EmbedStatement.java Fri Nov
11 00:41:31 2005
@@ -530,7 +530,8 @@
 		try {
 			Activation activation;
 			try {
-				PreparedStatement preparedStatement = lcc.prepareInternalStatement(sql);
+				PreparedStatement preparedStatement = lcc.prepareInternalStatement
+				    (lcc.getDefaultSchema(), sql, resultSetConcurrency==JDBC20Translation.CONCUR_READ_ONLY);
 				activation =
 					preparedStatement.getActivation(lcc, resultSetType == JDBC20Translation.TYPE_SCROLL_INSENSITIVE);
 				checkRequiresCallableStatement(activation);

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericPreparedStatement.java
Fri Nov 11 00:41:31 2005
@@ -61,6 +61,7 @@
 import org.apache.derby.iapi.sql.conn.StatementContext;
 
 import org.apache.derby.impl.sql.compile.QueryTreeNode;
+import org.apache.derby.impl.sql.compile.CursorNode;
 
 import org.apache.derby.iapi.error.StandardException;
 
@@ -343,7 +344,7 @@
 			}
 
 			StatementContext statementContext = lccToUse.pushStatementContext(
-				isAtomic, getSource(), pvs, rollbackParentContext, timeoutMillis);
+				isAtomic, updateMode==CursorNode.READ_ONLY, getSource(), pvs, rollbackParentContext,
timeoutMillis);
 
 			if (needsSavepoint())
 			{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/GenericStatement.java Fri Nov
11 00:41:31 2005
@@ -77,19 +77,22 @@
 	// these fields define the identity of the statement
 	private final SchemaDescriptor compilationSchema;
 	private final String			statementText;
+        private final boolean isForReadOnly;
 	private int                      prepareIsolationLevel;
 	private GenericPreparedStatement preparedStmt;
 
 	/**
 	 * Constructor for a Statement given the text of the statement in a String
-	 *
+	 * @param compliationSchema schema
 	 * @param statementText	The text of the statement
+	 * @param isForReadOnly if the statement is opened with level CONCUR_READ_ONLY
 	 */
 
-	public GenericStatement(SchemaDescriptor compilationSchema, String statementText)
+	public GenericStatement(SchemaDescriptor compilationSchema, String statementText, boolean
isForReadOnly)
 	{
 		this.compilationSchema = compilationSchema;
 		this.statementText = statementText;
+		this.isForReadOnly = isForReadOnly;
 	}
 
 	/*
@@ -237,7 +240,7 @@
 			{
 				// since this is for compilation only, set atomic
 				// param to true and timeout param to 0
-				statementContext = lcc.pushStatementContext(true, getSource(),
+				statementContext = lcc.pushStatementContext(true, isForReadOnly, getSource(),
                                                             null, false, 0L);
 			}
 
@@ -621,7 +624,7 @@
 
 			GenericStatement os = (GenericStatement) other;
 
-			return statementText.equals(os.statementText)
+			return statementText.equals(os.statementText) && isForReadOnly==os.isForReadOnly
 				&& compilationSchema.equals(os.compilationSchema) &&
 				(prepareIsolationLevel == os.prepareIsolationLevel);
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CursorNode.java Fri
Nov 11 00:41:31 2005
@@ -272,28 +272,34 @@
 		// if it doesn't know if it is updatable, determine it
 		if (updateMode == UNSPECIFIED)
 		{
-			/*
-			** NOTE: THIS IS NOT COMPATIBLE WITH THE ISO/ANSI STANDARD!!!
-			**
-			** According to ANSI, cursors are updatable by default, unless
-			** they can't be (e.g. they contain joins).  But this would mean
-			** that we couldn't use an index on any single-table select,
-			** unless it was declared FOR READ ONLY.  This would be pretty
-			** terrible, so we are breaking the ANSI rules and making all
-			** cursors (i.e. select statements) read-only by default.
-			** Users will have to say FOR UPDATE if they want a cursor to
-			** be updatable.  Later, we may have an ANSI compatibility
-			** mode so we can pass the NIST tests.
-			*/
-			updateMode = READ_ONLY;
+		    // If the statement is opened with CONCUR_READ_ONLY, the upgrade mode is 
+		    // set to read only.
+		    
+		    // NOTE: THIS IS NOT COMPATIBLE WITH THE ISO/ANSI SQL STANDARD.
 
-			/* updateMode = determineUpdateMode(); */
+		    // According to the SQL-standard:
+		    // If updatability is not specified, a SELECT * FROM T will be implicitely
+		    // read only in the context of a cursor which is insensitive, scrollable or
+		    // have an order by clause. Otherwise it is implicitely updatable.
+		    
+		    // In Derby, we make a SELECT * FROM T updatable if the concurrency mode is
+		    // ResultSet.CONCUR_UPDATE. If we do make all SELECT * FROM T  updatable
+		    // by default, we cannot use an index on any single-table select, unless it
+		    // was declared FOR READ ONLY. This would be pretty terrible, so we are
+		    // breaking the ANSI rules.
 
+		    if (getLanguageConnectionContext().getStatementContext().isForReadOnly()) {
+			updateMode = READ_ONLY;
+		    } else {
+			updateMode = determineUpdateMode(dataDictionary);
+		    }
+		    		    
 			//if (SanityManager.DEBUG)
 			//SanityManager.DEBUG("DumpUpdateCheck","update mode is UNSPECIFIED ("+UNSPECIFIED+")
checked mode is "+updateMode);
-
-			if (updateMode == READ_ONLY)
-				updatableColumns = null; // don't need them any more
+		}
+		
+		if (updateMode == READ_ONLY) {
+		    updatableColumns = null; // don't need them any more
 		}
 
 		// bind the update columns

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionContext.java
Fri Nov 11 00:41:31 2005
@@ -695,18 +695,24 @@
     tempTableInfo.setModifiedInSavepointLevel(currentSavepointLevel);
 	}
 
-	/**
-		Return a Statement object to compile a Statement. The schema 
-		setting fo the returned statement are that of this connection.
-	*/
-
-	public PreparedStatement prepareInternalStatement(String sqlText) throws StandardException
{
-		return connFactory.getStatement(sd, sqlText).prepare(this);
-	}
-
-	public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema, String
sqlText) throws StandardException {
-		return connFactory.getStatement(compilationSchema, sqlText).prepare(this);
+        /**
+	 * @see LanguageConnectionContext#prepareInternalStatement
+	 */
+        public PreparedStatement prepareInternalStatement(SchemaDescriptor compilationSchema,
String sqlText, boolean isForReadOnly) 
+	    throws StandardException 
+        {
+	    return connFactory.getStatement(compilationSchema, sqlText, isForReadOnly).prepare(this);
+	}
+        
+        /**
+	 * @see LanguageConnectionContext#prepareInternalStatement
+	 */
+        public PreparedStatement prepareInternalStatement(String sqlText) 
+	    throws StandardException 
+        {
+	    return connFactory.getStatement(sd, sqlText, true).prepare(this);
 	}
+        
 
 	/**
 	 * Remove the activation to those known about by this connection.
@@ -1881,6 +1887,7 @@
 	 * Push a StatementContext on the context stack.
 	 *
 	 * @param isAtomic whether this statement is atomic or not
+	 * @param isForReadonly whether this statement is for a read only resultset
 	 * @param stmtText the text of the statement.  Needed for any language
 	 * 	statement (currently, for any statement that can cause a trigger
 	 * 	to fire).  Please set this unless you are some funky jdbc setXXX
@@ -1895,8 +1902,10 @@
 	 * @return StatementContext  The statement context.
 	 *
 	 */
-	public StatementContext pushStatementContext(boolean isAtomic, String stmtText,
-		ParameterValueSet pvs, boolean rollbackParentContext, long timeoutMillis)
+	public StatementContext pushStatementContext (boolean isAtomic, boolean isForReadOnly, 
+						      String stmtText, ParameterValueSet pvs, 
+						      boolean rollbackParentContext, 
+						      long timeoutMillis)
 	{
 		int					parentStatementDepth = statementDepth;
 		boolean				inTrigger = false;
@@ -1946,7 +1955,7 @@
 
 		incrementStatementDepth();
 
-		statementContext.setInUse(inTrigger, isAtomic || parentIsAtomic, stmtText, pvs, timeoutMillis);
+		statementContext.setInUse(inTrigger, isAtomic || parentIsAtomic, isForReadOnly, stmtText,
pvs, timeoutMillis);
 		if (rollbackParentContext)
 			statementContext.setParentRollback();
 		return statementContext;

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericLanguageConnectionFactory.java
Fri Nov 11 00:41:31 2005
@@ -137,14 +137,16 @@
 
 	/**
 		Get a Statement for the connection
-		
+		@param compilationSchema schema
 		@param statementText the text for the statement
+		@param forReadOnly if concurrency is CONCUR_READ_ONLY
 		@return	The Statement
 	 */
-	public Statement getStatement(SchemaDescriptor compilationSchema, String statementText)
-	{
-		return new GenericStatement(compilationSchema, statementText);
+        public Statement getStatement(SchemaDescriptor compilationSchema, String statementText,
boolean forReadOnly)
+        {
+	    return new GenericStatement(compilationSchema, statementText, forReadOnly);
 	}
+
 
 	/**
 		Get a LanguageConnectionContext. this holds things

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/conn/GenericStatementContext.java
Fri Nov 11 00:41:31 2005
@@ -86,6 +86,7 @@
     private CancelQueryTask cancelTask = null;
         
     private	boolean		parentInTrigger;	// whetherparent started with a trigger on stack
+    private	boolean		isForReadOnly = false;	
     private	boolean		isAtomic;	
 	private boolean		isSystemCode;
 	private boolean		rollbackParentContext;
@@ -189,6 +190,7 @@
 	( 
 		boolean parentInTrigger,
 		boolean isAtomic, 
+                boolean isForReadOnly,
 		String stmtText,
 		ParameterValueSet pvs,
         long timeoutMillis
@@ -197,6 +199,7 @@
 		inUse = true;
 
 		this.parentInTrigger = parentInTrigger;
+		this.isForReadOnly = isForReadOnly;
 		this.isAtomic = isAtomic;
 		this.stmtText = stmtText;
 		this.pvs = pvs;
@@ -218,6 +221,7 @@
 
 		parentInTrigger = false;
 		isAtomic = false;
+		isForReadOnly = false;
 		this.stmtText = null;
 		sqlAllowed = -1;
 		isSystemCode = false;
@@ -643,6 +647,10 @@
 	{
 		return inUse;
 	}
+    public boolean isForReadOnly()
+    {
+	return isForReadOnly;
+    }
         
     /**
      * Tests whether the statement which has allocated this StatementContext

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/ConstraintConstantAction.java
Fri Nov 11 00:41:31 2005
@@ -308,7 +308,7 @@
 		ResultSet rs = null;
 		try
 		{
-			PreparedStatement ps = lcc.prepareInternalStatement(td.getSchemaDescriptor(), checkStmt.toString());
+			PreparedStatement ps = lcc.prepareInternalStatement(checkStmt.toString());
 
             // This is a substatement; for now, we do not set any timeout
             // for it. We might change this behaviour later, by linking

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out?rev=332491&r1=332490&r2=332491&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/DerbyNetClient/jdk14/updatableResultSet.out
Fri Nov 11 00:41:31 2005
@@ -40,14 +40,12 @@
 Now attempting to send a updateRow on a read only resultset with FOR UPDATE clause in the
SELECT sql.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row
or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
-Negative Test5 - request updatable resultset for sql with no FOR UPDATE clause
+Negative Test5 - request resultset with no FOR UPDATE clause and CONCUR_READ_ONLY
 Make sure that we got CONCUR_READ_ONLY? true
-Jira issue Derby-159 : Warnings raised by Derby are not getting passed to the Client in Network
Server Mode
-Will see the warnings in embedded mode only
-Now attempting to send a delete on a sql with no FOR UPDATE clause.
+Now attempting to send a delete on a sql with no FOR UPDATE clause and CONCUR_READ_ONLY.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row
or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
-Now attempting to send a updateRow on a sql with no FOR UPDATE clause.
+Now attempting to send a updateRow on a sql with no FOR UPDATE clause and CONCUR_READ_ONLY.
 SQL State : null
 Got expected exception This method cannot be invoked while the cursor is on the insert row
or if the concurrency of this ResultSet object is CONCUR_READ_ONLY.
 Negative Test6 - request updatable resultset for sql with FOR READ ONLY clause
@@ -146,6 +144,31 @@
 Got expected exception Invalid operation to update at current cursor position
 Position the ResultSet with next()
 Should be able to updateRow() on the current row now
+Positive Test1c - use updatable resultset to do postitioned delete
+requested TYPE_FORWARD_ONLY, CONCUR_UPDATABLE
+got TYPE_FORWARD_ONLY? true
+got CONCUR_UPDATABLE? true
+column 1 on this row before positioned delete 234
+column 2 on this row before positioned delete aa                  
+column 1 on this deleted row is 234
+column 2 on this deleted row is aa                  
+doing positioned delete again w/o first positioning the ResultSet on the next row will fail
+SQL State : XCL08
+Got expected exception Cursor '<xxx-cursor-name-xxx>' is not on a row.
+Position the ResultSet with next()
+Should be able to do positioned delete on the current row now
+Positive Test1d - updatable resultset to do positioned update
+column 1 on this row before positioned update is 1
+now dow positioned update on the row
+column 1 on the updated  row is 1
+column 1 on the updated  row is aa                  
+Refreshing the row
+SQL State : null
+Got expected exception This method should only be called on ResultSet objects that are scrollable(type
TYPE_SCROLL_SENSITIVE or TYPE_SCROLL_INSENSITIVE)
+doing positioned update again w/o positioning the RS will succeed
+because the cursor is still positioned
+Position the ResultSet with next()
+Should still be able to do positioned update
 Positive Test2 - even if no columns from table specified in the column list, we should be
able to get updatable resultset
 Will work in embedded mode because target table is not derived from the columns in the select
list
 Will not work in network server mode because it derives the target table from the columns
in the select list



Mime
View raw message