Return-Path: Delivered-To: apmail-db-derby-dev-archive@www.apache.org Received: (qmail 77160 invoked from network); 31 Mar 2005 04:28:31 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 31 Mar 2005 04:28:31 -0000 Received: (qmail 53965 invoked by uid 500); 31 Mar 2005 04:28:30 -0000 Delivered-To: apmail-db-derby-dev-archive@db.apache.org Received: (qmail 53931 invoked by uid 500); 31 Mar 2005 04:28:30 -0000 Mailing-List: contact derby-dev-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: List-Id: Reply-To: "Derby Development" Delivered-To: mailing list derby-dev@db.apache.org Received: (qmail 53918 invoked by uid 99); 31 Mar 2005 04:28:30 -0000 X-ASF-Spam-Status: No, hits=0.4 required=10.0 tests=DNS_FROM_RFC_ABUSE,RCVD_BY_IP,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: domain of msatoor@gmail.com designates 64.233.184.198 as permitted sender) Received: from wproxy.gmail.com (HELO wproxy.gmail.com) (64.233.184.198) by apache.org (qpsmtpd/0.28) with ESMTP; Wed, 30 Mar 2005 20:28:28 -0800 Received: by wproxy.gmail.com with SMTP id 58so418087wri for ; Wed, 30 Mar 2005 20:28:26 -0800 (PST) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:references; b=jwbOdXg3/tBcGwmf/NULy313gUl7v0h0AivU7ZWP2ErPDSaj5rENjPT03XW2ZhdVNEEMziA6fTqUpbco1acEOAe0RKW2FAe+kYzVAilB2aEhegHSBTv8QKzaiXOkMNSSQ6JViiwZA6OccawulGGjxbtXjgLRsa2wEMw+s8zuROQ= Received: by 10.54.8.48 with SMTP id 48mr525393wrh; Wed, 30 Mar 2005 20:28:26 -0800 (PST) Received: by 10.54.49.63 with HTTP; Wed, 30 Mar 2005 20:28:26 -0800 (PST) Message-ID: Date: Wed, 30 Mar 2005 20:28:26 -0800 From: Mamta Satoor Reply-To: Mamta Satoor To: Derby Development Subject: Re: [VOTE][PATCH]updates on forward only resultset using JDBC 2.0 UpdatableResultset APIs In-Reply-To: <422F33AB.50001@debrunners.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="----=_Part_985_20260064.1112243306194" References: <422F33AB.50001@debrunners.com> X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_985_20260064.1112243306194 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Wed, 09 Mar 2005 09:34:35 -0800, Daniel John Debrunner wrote: > > +0.8 > > I think the functionality is correct, but there are some issues in the > method checksBeforeUpdateOrDelete(). They could be addressed in a > subsequent patch. > > - The code at the end of checksBeforeUpdateOrDelete to get the table > descriptor and perform column correlation name checks is expensive, and > seems like it could be done once, rather than on every updateXXX. A > final solution would ideally address these concerns at compile time and > not runtime, e.g. part of compilation could be identifying if a > statement is suitable for updateable result sets. > > - Making method behaviour depend on the name of the calling method is > not a common programming practise in Derby, and again is expensive. Now > every updateXXX() call has to perform three String comparisions that are > not needed. Ie. this code. > > //the remaining checks only apply to updateXXX methods > + if (methodName.equals("updateRow") || > methodName.equals("deleteRow") || methodName.equals("cancelRowUpdates")) > + return; > > The typical way to address this would be to have the code before this in > a separate method, have deleteRow, updateRow and cancelRowUpdate methods > call that new method, and have checksBeforeUpdateOrDelete call that > method (rather than duplicate code). > > - The lack of synchronization for the updateXXX() methods is also an > area of concern. As coded two threads performing concurrent updateXXX() > calls on the same result set will mess each other up, leading to missed > update values or possibly NullPointerException later if cancelRowUpdates > is called. But synchronization is a performance hit, and multiple > threads executing concurrent operations on a JDBC object is not > recommended. So maybe we can survive without it? > [Putting the synchronization in getDVDforColumnUpdates() would be the > logical place, not each updateXXX method.] > > Dan. > > I have a patch which takes care of first 2 points raised by Dan. Derby does not support correlation name for updatable columns. This check was earlier made at runtime everytime an updateXXX was issued. I have moved the check for correlation name to compile time in CursorNode.java. If the cursor sql has a correlation name for an updatable column, compile time code will throw an exception. The new exception code and message has been added to SQLState.java and messages_en.properties respectively. The changes in EmbedResultSet.java is to remove the runtime check for correlation name and to make the various other checks prior to updateXXX, updateRow and cancelRowUpdates and deleteRow more efficient. In addition, I have changed the existing tests to have couple more checks for compile time catch of correlation name. Can a commiter please commit this patch for me? svn stat M java\engine\org\apache\derby\impl\sql\compile\CursorNode.java M java\engine\org\apache\derby\impl\jdbc\EmbedResultSet.java M java\engine\org\apache\derby\iapi\reference\SQLState.java M java\engine\org\apache\derby\loc\messages_en.properties M java\testing\org\apache\derbyTesting\functionTests\tests\lang\updatableResultSet.java M java\testing\org\apache\derbyTesting\functionTests\master\updatableResultSet.out M java\testing\org\apache\derbyTesting\functionTests\master\jdk14\updatableResultSet.out thanks, Mamta ------=_Part_985_20260064.1112243306194 Content-Type: text/plain; name="diff033005.txt" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="diff033005.txt" Index: java/engine/org/apache/derby/impl/sql/compile/CursorNode.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/engine/org/apache/derby/impl/sql/compile/CursorNode.java=09(revisi= on 159525) +++ java/engine/org/apache/derby/impl/sql/compile/CursorNode.java=09(workin= g copy) @@ -716,6 +716,7 @@ =09=09int size =3D updatableColumns.size(); =09=09TableDescriptor tableDescriptor; =09=09String columnName; +=09=09ResultColumnList rcls =3D resultSet.getResultColumns(); =20 =09=09for (int index =3D 0; index < size; index++) =09=09{ @@ -723,9 +724,22 @@ =09=09 tableDescriptor =3D targetTable.getTableDescriptor(); =09=09 if ( tableDescriptor.getColumnDescriptor(columnName) =3D=3D null= ) =09=09 { -=09=09=09throw StandardException.newException(SQLState.LANG_COLUMN_NOT_FOU= ND, columnName); +=09=09=09=09=09throw StandardException.newException(SQLState.LANG_COLUMN_N= OT_FOUND, columnName); =09=09 } =20 +=09=09 ResultColumn rc; +=09=09 //make sure that we are not using correlation names for updatabl= e columns.=20 +=09=09 //eg select c11 as col1, 2, c13 as col3 from t1 for update of c1= 1, c12 +=09=09 //In the eg above, correlation name for c11 will cause exception= because Derby does not support correlation name for updatable columns +=09=09 //But correlation name for c13 is ok because it is a read only c= olumn +=09=09 for (int rclsIndex =3D 0; rclsIndex < rcls.size(); rclsIndex++) = {//look through each column in the resultset for cursor +=09=09=09=09=09rc =3D ((ResultColumn) rcls.elementAt(rclsIndex)); +=09=09=09=09=09if (rc.getSourceTableName() =3D=3D null) //continue to look= at the next column because this is derived column in the select list +=09=09=09=09=09continue; +=09=09=09=09=09if (rc.getExpression() !=3D null && rc.getExpression().getC= olumnName().equals(columnName) && !rc.getName().equals(columnName)) { +=09=09=09=09=09throw StandardException.newException(SQLState.LANG_CORRELAT= ION_NAME_FOR_UPDATABLE_COLUMN_DISALLOWED_IN_CURSOR, columnName); +=09=09=09=09=09} +=09=09 } =09=09} =09} =20 Index: java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java=09(revision = 159525) +++ java/engine/org/apache/derby/impl/jdbc/EmbedResultSet.java=09(working c= opy) @@ -155,8 +155,6 @@ =20 private int fetchDirection; private int fetchSize; - //td will be used to ensure the column selected for updateXXX is part = of the table. - private TableDescriptor td =3D null; =20 =09/** =09 * This class provides the glue between the Cloudscape @@ -2038,15 +2036,25 @@ =09=09return false; =09} =20 +=09//do following few checks before accepting updateXXX resultset api +=09protected void checksBeforeUpdateXXX(String methodName, int columnIndex= ) throws SQLException { + checksBeforeUpdateOrDelete(methodName, columnIndex); + + //1)Make sure for updateXXX methods, the column position is not out = of range + ResultDescription rd =3D theResults.getResultDescription(); + if (columnIndex < 1 || columnIndex > rd.getColumnCount()) + throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POS= ITION, new Integer(columnIndex), String.valueOf(rd.getColumnCount())); + + //2)Make sure the column corresponds to a column in the base table a= nd it is not a derived column + if (rd.getColumnDescriptor(columnIndex).getSourceTableName() =3D=3D = null) + throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TA= BLE, methodName); +=09} + =09//do following few checks before accepting updatable resultset api =09//1)Make sure this is an updatable ResultSet =09//2)Make sure JDBC ResultSet is not closed =09//3)Make sure JDBC ResultSet is positioned on a row =09//4)Make sure underneath language resultset is not closed -=09//5)Make sure for updateXXX methods, the column position is not out of = range -=09//6)Make sure the column corresponds to a column in the base table and = it is not a derived column -=09//7)Make sure correlation names are not used for base table column name= s in updateXXXX. This is because the mapping -=09// of correlation name to base table column position is not available = at runtime. =09protected void checksBeforeUpdateOrDelete(String methodName, int column= Index) throws SQLException { =20 //1)Make sure this is an updatable ResultSet @@ -2065,57 +2073,11 @@ //4)Make sure underneath language resultset is not closed if (theResults.isClosed()) throw Util.generateCsSQLException(SQLState.LANG_RESULT_SET_NOT_OPE= N, methodName); - - //the remaining checks only apply to updateXXX methods - if (methodName.equals("updateRow") || methodName.equals("deleteRow")= || methodName.equals("cancelRowUpdates")) - return; - - //5)Make sure for updateXXX methods, the column position is not out = of range - ResultDescription rd =3D theResults.getResultDescription(); - if (columnIndex < 1 || columnIndex > rd.getColumnCount()) - throw Util.generateCsSQLException(SQLState.LANG_INVALID_COLUMN_POS= ITION, new Integer(columnIndex), String.valueOf(rd.getColumnCount())); - - //6)Make sure the column corresponds to a column in the base table a= nd it is not a derived column - if (rd.getColumnDescriptor(columnIndex).getSourceTableName() =3D=3D = null) - throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TA= BLE, methodName); - - //7)Make sure correlation names are not used for base table column n= ames in updateXXX. This is because the mapping - // of correlation name to base table column position is not availab= le at runtime. - //If can't find the column in the base table, then throw exception. = This will happen if correlation name is used for column names - if (td =3D=3D null) getTargetTableDescriptor(); - if (td.getColumnDescriptor(rd.getColumnDescriptor(columnIndex).getNa= me()) =3D=3D null) - throw Util.generateCsSQLException(SQLState.COLUMN_NOT_FROM_BASE_TA= BLE, methodName); =09} =20 -=09//Get the table descriptor for the target table for updateXXX. td will = be used to ensure the column selected for updateXXX -=09//is part of the table. -=09private void getTargetTableDescriptor() throws SQLException { - setupContextStack(); - try { - LanguageConnectionContext lcc =3D getEmbedConnection().getLanguage= Connection(); - CursorActivation activation =3D lcc.lookupCursorActivation(getCurs= orName()); - ExecCursorTableReference targetTable =3D activation.getPreparedSta= tement().getTargetTable(); - SchemaDescriptor sd =3D null; - if (targetTable.getSchemaName() !=3D null) - sd =3D lcc.getDataDictionary().getSchemaDescriptor(targetTable= .getSchemaName(),null, false); - else - sd =3D lcc.getDataDictionary().getSchemaDescriptor(lcc.getCurr= entSchemaName(),null, false); - - if ((sd !=3D null) && sd.getSchemaName().equals(SchemaDescriptor.S= TD_DECLARED_GLOBAL_TEMPORARY_TABLES_SCHEMA_NAME)) - td =3D lcc.getTableDescriptorForDeclaredGlobalTempTable(target= Table.getBaseName()); //check if this is a temp table before checking data = dictionary - - if (td =3D=3D null) //td null here means it is not a temporary tab= le. Look for table in physical SESSION schema - td =3D lcc.getDataDictionary().getTableDescriptor(targetTable.= getBaseName(), sd); - } catch (StandardException t) { - throw noStateChangeException(t); - } finally { - restoreContextStack(); - } -=09} - =09//mark the column as updated and return DataValueDescriptor for it. It = will be used by updateXXX methods to put new values =09protected DataValueDescriptor getDVDforColumnToBeUpdated(int columnInde= x, String updateMethodName) throws StandardException, SQLException { - checksBeforeUpdateOrDelete(updateMethodName, columnIndex); + checksBeforeUpdateXXX(updateMethodName, columnIndex); if (columnGotUpdated[columnIndex-1] =3D=3D false) {//this is the fir= st updateXXX call on this column //this is the first updateXXX method call on this column. Save the= original content of the column into copyOfDatabaseRow //The saved copy of the column will be needed if cancelRowUpdates = is issued @@ -2473,7 +2435,7 @@ =09 */ =09public void updateAsciiStream(int columnIndex, java.io.InputStream x, =09=09=09int length) throws SQLException { -=09=09checksBeforeUpdateOrDelete("updateAsciiStream", columnIndex); +=09=09checksBeforeUpdateXXX("updateAsciiStream", columnIndex); =20 =09=09int colType =3D getColumnType(columnIndex); =09=09switch (colType) { @@ -2519,7 +2481,7 @@ =09 */ =09public void updateBinaryStream(int columnIndex, java.io.InputStream x, =09=09=09int length) throws SQLException { -=09=09checksBeforeUpdateOrDelete("updateBinaryStream", columnIndex); +=09=09checksBeforeUpdateXXX("updateBinaryStream", columnIndex); =09=09int colType =3D getColumnType(columnIndex); =09=09switch (colType) { =09=09=09case Types.BINARY: @@ -2576,8 +2538,8 @@ =09=09=09int length) throws SQLException { =09=09//If the column type is the right datatype, this method will eventua= lly call getDVDforColumnToBeUpdated which will check for =09=09//the read only resultset. But for other datatypes, we want to catch= if this updateCharacterStream is being issued -=09=09//against a read only resultset. And that is the reason for call to = checksBeforeUpdateOrDelete here. -=09=09checksBeforeUpdateOrDelete("updateCharacterStream", columnIndex); +=09=09//against a read only resultset. And that is the reason for call to = checksBeforeUpdateXXX here. +=09=09checksBeforeUpdateXXX("updateCharacterStream", columnIndex); =09=09int colType =3D getColumnType(columnIndex); =09=09switch (colType) { =09=09=09case Types.CHAR: @@ -2680,7 +2642,7 @@ =09 * if a database-access error occurs =09 */ =09public void updateObject(int columnIndex, Object x) throws SQLException= { -=09=09checksBeforeUpdateOrDelete("updateObject", columnIndex); +=09=09checksBeforeUpdateXXX("updateObject", columnIndex); =09=09int colType =3D getColumnType(columnIndex); =09=09if (colType =3D=3D org.apache.derby.iapi.reference.JDBC20Translation= .SQL_TYPES_JAVA_OBJECT) { =09=09=09try { @@ -3522,7 +3484,7 @@ =09 * Feature not implemented for now. =09 */ =09public void updateBlob(int columnIndex, Blob x) throws SQLException { - checksBeforeUpdateOrDelete("updateBlob", columnIndex); + checksBeforeUpdateXXX("updateBlob", columnIndex); int colType =3D getColumnType(columnIndex); if (colType !=3D Types.BLOB) throw dataTypeConversion(columnIndex, "java.sql.Blob"); @@ -3568,7 +3530,7 @@ =09 * Feature not implemented for now. =09 */ =09public void updateClob(int columnIndex, Clob x) throws SQLException { - checksBeforeUpdateOrDelete("updateClob", columnIndex); + checksBeforeUpdateXXX("updateClob", columnIndex); int colType =3D getColumnType(columnIndex); if (colType !=3D Types.CLOB) throw dataTypeConversion(columnIndex, "java.sql.Clob"); Index: java/engine/org/apache/derby/iapi/reference/SQLState.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/engine/org/apache/derby/iapi/reference/SQLState.java=09(revision 1= 59525) +++ java/engine/org/apache/derby/iapi/reference/SQLState.java=09(working co= py) @@ -737,6 +737,7 @@ =09String LANG_CURSOR_UPDATE_MISMATCH =3D = "42X29"; =09String LANG_CURSOR_NOT_FOUND =3D = "42X30"; =09String LANG_COLUMN_NOT_UPDATABLE_IN_CURSOR =3D = "42X31"; +=09String LANG_CORRELATION_NAME_FOR_UPDATABLE_COLUMN_DISALLOWED_IN_CURSOR = =3D "42X42"; =09String LANG_DERIVED_COLUMN_LIST_MISMATCH =3D = "42X32"; =09String LANG_DUPLICATE_COLUMN_NAME_DERIVED =3D = "42X33"; =09String LANG_PARAM_IN_SELECT_LIST =3D = "42X34"; Index: java/engine/org/apache/derby/loc/messages_en.properties =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/engine/org/apache/derby/loc/messages_en.properties=09(revision 159= 525) +++ java/engine/org/apache/derby/loc/messages_en.properties=09(working copy= ) @@ -443,6 +443,7 @@ 42X29=3DUpdate table ''{0}'' is not target of cursor ''{1}''. 42X30=3DCursor ''{0}'' not found. Verify that autocommit is OFF. 42X31=3DColumn ''{0}'' is not in FOR UPDATE list of cursor ''{1}''. +42X42=3DCorrelation name not allowed for column ''{0}'' because it is part= of the FOR UPDATE list. 42X32=3DThe number of columns in the derived column list must match the nu= mber of columns in table ''{0}''. 42X33=3DThe derived column list contains a duplicate column name ''{0}''. 42X34=3DThere is a ? parameter in the select list. This is not allowed. Index: java/testing/org/apache/derbyTesting/functionTests/tests/lang/updata= bleResultSet.java =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatable= ResultSet.java=09(revision 159525) +++ java/testing/org/apache/derbyTesting/functionTests/tests/lang/updatable= ResultSet.java=09(working copy) @@ -946,18 +946,39 @@ =09=09=09rs.deleteRow(); =09=09=09rs.close(); =20 -=09=09=09System.out.println("Positive Test9b - using correlation name for = column names is not allowed with updateXXX"); +=09=09=09System.out.println("Positive Test9b - using correlation name for = updatable column name is not allowed"); =09=09=09reloadData(); =09=09=09stmt =3D conn.createStatement(ResultSet.TYPE_FORWARD_ONLY, Result= Set.CONCUR_UPDATABLE); =09=09=09System.out.println("Table t1 has following rows"); =09=09=09dumpRS(stmt.executeQuery("select * from t1")); -=09=09=09rs =3D stmt.executeQuery("SELECT c1 as col1, c2 as col2 FROM t1 a= bcde FOR UPDATE of c1"); +=09=09=09try { +=09=09=09=09System.out.println("attempt to get an updatable resultset usin= g correlation name for an updatable column"); +=09=09=09=09System.out.println("The sql is SELECT c1 as col1, c2 as col2 F= ROM t1 abcde FOR UPDATE of c1"); +=09=09=09=09rs =3D stmt.executeQuery("SELECT c1 as col1, c2 as col2 FROM t= 1 abcde FOR UPDATE of c1"); +=09=09=09=09System.out.println("FAIL!!! executeQuery should have failed"); +=09=09=09} +=09=09=09catch (SQLException e) { +=09=09=09=09System.out.println("SQL State : " + e.getSQLState()); +=09=09=09=09System.out.println("Got expected exception " + e.getMessage())= ; +=09=09=09} +=09=09=09System.out.println("attempt to get an updatable resultset using c= orrelation name for an readonly column. It should work"); +=09=09=09System.out.println("The sql is SELECT c1, c2 as col2 FROM t1 abcd= e FOR UPDATE of c1"); +=09=09=09rs =3D stmt.executeQuery("SELECT c1, c2 as col2 FROM t1 abcde FOR= UPDATE of c1"); =09=09=09rs.next(); -=09=09=09System.out.println("column 1 on this row is " + rs.getInt(1)); +=09=09=09rs.updateInt(1,11); +=09=09=09rs.updateRow(); +=09=09=09rs.close(); +=09=09=09System.out.println("Table t1 after updateRow has following rows")= ; +=09=09=09dumpRS(stmt.executeQuery("select * from t1")); + +=09=09=09System.out.println("Positive Test9c - try to updateXXX on a reado= nly column. Should get error"); +=09=09=09reloadData(); +=09=09=09rs =3D stmt.executeQuery("SELECT c1, c2 FROM t1 abcde FOR UPDATE = of c1"); +=09=09=09rs.next(); +=09=09=09rs.updateString(2,"bbbb"); =09=09=09try { -=09=09=09=09System.out.println("attempt to send updateXXX on correlation n= ame column will fail"); -=09=09=09=09rs.updateShort(1, (new Integer(123)).shortValue()); -=09=09=09=09System.out.println("FAIL!!! updateXXX should have failed"); +=09=09=09=09rs.updateRow(); +=09=09=09=09System.out.println("FAIL!!! updateRow should have failed"); =09=09=09} =09=09=09catch (SQLException e) { =09=09=09=09System.out.println("SQL State : " + e.getSQLState()); Index: java/testing/org/apache/derbyTesting/functionTests/master/updatableR= esultSet.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/testing/org/apache/derbyTesting/functionTests/master/updatableResu= ltSet.out=09(revision 159525) +++ java/testing/org/apache/derbyTesting/functionTests/master/updatableResu= ltSet.out=09(working copy) @@ -247,20 +247,31 @@ Positive Test9a - using correlation name for the table in the select sql i= s not a problem column 1 on this row is 1 now try to deleteRow -Positive Test9b - using correlation name for column names is not allowed w= ith updateXXX +Positive Test9b - using correlation name for updatable column name is not = allowed Table t1 has following rows =09 C1,C2 =09 -- -- =09{1,aa } =09{2,bb } =09{3,cc } -column 1 on this row is 1 -attempt to send updateXXX on correlation name column will fail -SQL State : XJ084 -Got expected exception Column does not correspond to a column in the base = table. Cant issue {0} on this column. +attempt to get an updatable resultset using correlation name for an updata= ble column +The sql is SELECT c1 as col1, c2 as col2 FROM t1 abcde FOR UPDATE of c1 +SQL State : 42X42 +Got expected exception Correlation name not allowed for column 'C1' becaus= e it is part of the FOR UPDATE list. +attempt to get an updatable resultset using correlation name for an readon= ly column. It should work +The sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1 Table t1 after updateRow has following rows =09 C1,C2 =09 -- -- +=09{11,aa } +=09{2,bb } +=09{3,cc } +Positive Test9c - try to updateXXX on a readonly column. Should get error +SQL State : 42X31 +Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR15'. +Table t1 after updateRow has following rows +=09 C1,C2 +=09 -- -- =09{1,aa } =09{2,bb } =09{3,cc } @@ -268,7 +279,7 @@ delete using first resultset attempt to send deleteRow on the same row through a different resultset sh= ould throw an exception SQL State : XCL08 -Got expected exception Cursor 'SQLCUR16' is not on a row. +Got expected exception Cursor 'SQLCUR17' is not on a row. Move to next row in the 2nd resultset and then delete using the second res= ultset Positive Test11 - setting the fetch size to > 1 will be ignored by updatab= le resultset. Same as updatable cursors Notice the Fetch Size in run time statistics output. @@ -2761,7 +2772,7 @@ =09{2,bb } =09{3,cc } SQL State : 42X31 -Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR1055'. +Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR528'. Make sure the contents of table are unchanged =09 C1,C2 =09 -- -- Index: java/testing/org/apache/derbyTesting/functionTests/master/jdk14/upda= tableResultSet.out =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatab= leResultSet.out=09(revision 159525) +++ java/testing/org/apache/derbyTesting/functionTests/master/jdk14/updatab= leResultSet.out=09(working copy) @@ -247,20 +247,31 @@ Positive Test9a - using correlation name for the table in the select sql i= s not a problem column 1 on this row is 1 now try to deleteRow -Positive Test9b - using correlation name for column names is not allowed w= ith updateXXX +Positive Test9b - using correlation name for updatable column name is not = allowed Table t1 has following rows =09 C1,C2 =09 -- -- =09{1,aa } =09{2,bb } =09{3,cc } -column 1 on this row is 1 -attempt to send updateXXX on correlation name column will fail -SQL State : XJ084 -Got expected exception Column does not correspond to a column in the base = table. Cant issue {0} on this column. +attempt to get an updatable resultset using correlation name for an updata= ble column +The sql is SELECT c1 as col1, c2 as col2 FROM t1 abcde FOR UPDATE of c1 +SQL State : 42X42 +Got expected exception Correlation name not allowed for column 'C1' becaus= e it is part of the FOR UPDATE list. +attempt to get an updatable resultset using correlation name for an readon= ly column. It should work +The sql is SELECT c1, c2 as col2 FROM t1 abcde FOR UPDATE of c1 Table t1 after updateRow has following rows =09 C1,C2 =09 -- -- +=09{11,aa } +=09{2,bb } +=09{3,cc } +Positive Test9c - try to updateXXX on a readonly column. Should get error +SQL State : 42X31 +Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR15'. +Table t1 after updateRow has following rows +=09 C1,C2 +=09 -- -- =09{1,aa } =09{2,bb } =09{3,cc } @@ -268,7 +279,7 @@ delete using first resultset attempt to send deleteRow on the same row through a different resultset sh= ould throw an exception SQL State : XCL08 -Got expected exception Cursor 'SQLCUR16' is not on a row. +Got expected exception Cursor 'SQLCUR17' is not on a row. Move to next row in the 2nd resultset and then delete using the second res= ultset Positive Test11 - setting the fetch size to > 1 will be ignored by updatab= le resultset. Same as updatable cursors Notice the Fetch Size in run time statistics output. @@ -3035,7 +3046,7 @@ =09{2,bb } =09{3,cc } SQL State : 42X31 -Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR1191'. +Got expected exception Column 'C2' is not in FOR UPDATE list of cursor 'SQ= LCUR536'. Make sure the contents of table are unchanged =09 C1,C2 =09 -- -- ------=_Part_985_20260064.1112243306194--