db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From d..@apache.org
Subject svn commit: r397959 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
Date Fri, 28 Apr 2006 17:25:04 GMT
Author: djd
Date: Fri Apr 28 10:25:02 2006
New Revision: 397959

URL: http://svn.apache.org/viewcvs?rev=397959&view=rev
Log:
DERBY-1258 Change the generated code for a new/old column in a row trigger to access columns
by position and not name to avoid the case-insensitive name lookup specified by JDBC.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java?rev=397959&r1=397958&r2=397959&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/CreateTriggerNode.java
Fri Apr 28 10:25:02 2006
@@ -587,7 +587,11 @@
 		**
 		** 		cast (org.apache.derby.iapi.db.Factory::
 		**			getTriggerExecutionContext().getNewRow().
-		**				getObject('<colName>') AS DECIMAL(6,2))
+		**				getObject(<colPosition>) AS DECIMAL(6,2))
+        **
+        ** Column position is used to avoid the wrong column being
+        ** selected problem (DERBY-1258) caused by the case insensitive
+        ** JDBC rules for fetching a column by name.
 		**
 		** The cast back to the SQL Domain may seem redundant
 		** but we need it to make the column reference appear
@@ -599,9 +603,11 @@
 		**		CREATE TRIGGER ... INSERT INTO T length(Column), ...
 		*/
 		StringBuffer methodCall = new StringBuffer();
-		methodCall.append("cast (org.apache.derby.iapi.db.Factory::getTriggerExecutionContext().");
+		methodCall.append("CAST (org.apache.derby.iapi.db.Factory::getTriggerExecutionContext().");
 		methodCall.append(isOldTable ? "getOldRow()" : "getNewRow()");
-		methodCall.append(".getObject('"+colName+"') AS ");
+		methodCall.append(".getObject(");
+        methodCall.append(colDesc.getPosition());
+        methodCall.append(") AS ");
 		DataTypeDescriptor dts = colDesc.getType();
 		TypeId typeId = dts.getTypeId();
 
@@ -611,8 +617,9 @@
 		** case.
 		*/
 		methodCall.append(
-		  (typeId.userType() ? typeId.getSQLTypeName() : dts.getSQLstring())
-				 + ") ");
+		  (typeId.userType() ? typeId.getSQLTypeName() : dts.getSQLstring()));
+        
+        methodCall.append(") ");
 
 		return methodCall.toString();
 	}

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
URL: http://svn.apache.org/viewcvs/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out?rev=397959&r1=397958&r2=397959&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/master/triggerGeneral.out
Fri Apr 28 10:25:02 2006
@@ -1069,7 +1069,7 @@
 select * from tsn_t;
 A          |B          
 -----------------------
-1          |1          
+1          |234        
 ij> drop table tsn;
 0 rows inserted/updated/deleted
 ij> drop table tsn_t;



Mime
View raw message