db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r722214 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ engine/org/apache/derby/impl/sql/execute/ engine/org/apache/derby/loc/ testing/org/apache/derbyTesting/functionTests/tests/lang/
Date Mon, 01 Dec 2008 20:27:42 GMT
Author: rhillegas
Date: Mon Dec  1 12:27:42 2008
New Revision: 722214

URL: http://svn.apache.org/viewvc?rev=722214&view=rev
Log:
DERBY-481: Incorporate Dag's patch review feedback.

Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java
Mon Dec  1 12:27:42 2008
@@ -3906,7 +3906,8 @@
                 // unfortunately that step occurs very soon after defaults are substituted
in. The
                 // parsing and binding of generation clauses happens considerably
                 // later on. At this juncture, we can be patient and just plug
-                // in a NULL literal as a placeholder.
+                // in a NULL literal as a placeholder. For generated columns,
+                // the generation clause tree is plugged in in DMLModStatementNode.parseAndBindGenerationClauses().
                 //
 				if ( (defaultInfo != null) && !defaultInfo.isGeneratedColumn() )
 				{

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/AlterTableConstantAction.java
Mon Dec  1 12:27:42 2008
@@ -1486,6 +1486,11 @@
             
             activation.addWarning
                 ( StandardException.newWarning( SQLState.LANG_GEN_COL_DROPPED, generatedColumnName,
td.getName() ) );
+
+            //
+            // We can only recurse 2 levels since a generation clause cannot
+            // refer to other generated columns.
+            //
             dropColumnFromTable( activation, generatedColumnName );
         }
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NoRowsResultSetImpl.java
Mon Dec  1 12:27:42 2008
@@ -74,9 +74,13 @@
 	protected long beginExecutionTime;
 	protected long endExecutionTime;
 
-    private int                             firstColumn = -1;
-    private int[]                           generatedColumnPositions; // 1-based positions
-    private DataValueDescriptor[]  normalizedGeneratedValues; // one for  each slot in generatedColumnPositions
+    private int                             firstColumn = -1;    // First column being stuffed.
For UPDATES, this lies in the second half of the row.
+    private int[]                           generatedColumnPositions; // 1-based positions
of generated columns in the target row
+
+    // One cell for  each slot in generatedColumnPositions. These are temporary
+    // values which hold the result of running the generation clause before we
+    // stuff the result into the target row.
+    private DataValueDescriptor[]  normalizedGeneratedValues;
 
 	NoRowsResultSetImpl(Activation activation)
 		throws StandardException
@@ -663,7 +667,8 @@
 	}
 
 	/**
-	  * Construct support for normalizing generated columns.
+	  * Construct support for normalizing generated columns. This figures out
+	  * which columns in the target row have generation clauses which need to be run.
 	  */
     private void    setupGeneratedColumns( Activation activation, ValueRow newRow )
         throws StandardException

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/NormalizeResultSet.java
Mon Dec  1 12:27:42 2008
@@ -272,6 +272,9 @@
     /**
      * <p>
      * Compute the start column for an update/insert.
+     *
+     * @param isUpdate  True if we are executing an UPDATE statement
+     * @param desc Metadata describing a result row
      * </p>
      */
     public  static  int computeStartColumn( boolean isUpdate, ResultDescription desc )
@@ -292,17 +295,20 @@
 
     
 	/**
-	 * Normalize a row.  For now, this means calling constructors through
+	 * Normalize a column.  For now, this means calling constructors through
 	 * the type services to normalize a type to itself.  For example,
 	 * if you're putting a char(30) value into a char(15) column, it
 	 * calls a SQLChar constructor with the char(30) value, and the
 	 * constructor truncates the value and makes sure that no non-blank
 	 * characters are truncated.
 	 *
-	 * In the future, this mechanism will be extended to do type conversions,
-	 * as well.  I didn't implement type conversions yet because it looks
-	 * like a lot of work, and we needed char and varchar right away.
-	 *
+     *
+     * @param dtd Data type to coerce to
+     * @param sourceRow row holding the source column
+     * @param sourceColumnPosition position of column in row
+     * @param resultCol where to stuff the coerced value
+     * @param desc Additional metadata for error reporting if necessary
+     *
  	 * @exception StandardException thrown on failure 
 	 */
 	public  static  DataValueDescriptor normalizeColumn
@@ -331,17 +337,9 @@
 	//
 	// class implementation
 	//
+    
 	/**
-	 * Normalize a row.  For now, this means calling constructors through
-	 * the type services to normalize a type to itself.  For example,
-	 * if you're putting a char(30) value into a char(15) column, it
-	 * calls a SQLChar constructor with the char(30) value, and the
-	 * constructor truncates the value and makes sure that no non-blank
-	 * characters are truncated.
-	 *
-	 * In the future, this mechanism will be extended to do type conversions,
-	 * as well.  I didn't implement type conversions yet because it looks
-	 * like a lot of work, and we needed char and varchar right away.
+	 * Normalize a row.
 	 *
 	 * @param sourceRow		The row to normalize
 	 *

Modified: db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/loc/messages.xml Mon Dec  1 12:27:42
2008
@@ -2002,7 +2002,7 @@
 
             <msg>
                 <name>42XA6</name>
-                <text>'{0}' is a generated column. It cannot be part of a foreign key
whose referential action is SET NULL or SET DEFAULT or whose update rule is ON UPDATE CASCADE.</text>
+                <text>'{0}' is a generated column. It cannot be part of a foreign key
whose referential action for DELETE is SET NULL or SET DEFAULT, or whose referential action
for UPDATE is CASCADE.</text>
                 <arg>columnName</arg>
             </msg>
 

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java?rev=722214&r1=722213&r2=722214&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java
Mon Dec  1 12:27:42 2008
@@ -1502,7 +1502,11 @@
     /**
      * <p>
      * Test that the declared datatype of a generated column can be anything that the
-     * generation clause can be assigned to.
+     * generation clause can be assigned to. The legal assignments are described
+     * in the Reference Guide in the section titled "Data type assignments and comparison,
sorting, and ordering".
+     * Note that this is a subset of the legal casts described for the CAST
+     * operator. Here we are verifying the behavior described in the SQL
+     * standard, Part 2, section 11.4, syntax rule 9.
      * </p>
      */
     public  void    test_014_assignment()
@@ -2253,7 +2257,7 @@
              conn,
              "create table t_cc_varchar\n" +
              "(\n" +
-             "    a char( 10 ),\n" +
+             "    a varchar( 10 ),\n" +
              "    b char( 5 ) generated always as( upper( a ) ),\n" +
              "    c char( 10 ) generated always as( upper( a ) ),\n" +
              "    d char( 15 ) generated always as( upper( a ) ),\n" +



Mime
View raw message