From derby-commits-return-10924-apmail-db-derby-commits-archive=db.apache.org@db.apache.org Mon Nov 03 14:46:08 2008 Return-Path: Delivered-To: apmail-db-derby-commits-archive@www.apache.org Received: (qmail 99503 invoked from network); 3 Nov 2008 14:46:08 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 3 Nov 2008 14:46:08 -0000 Received: (qmail 71972 invoked by uid 500); 3 Nov 2008 14:46:14 -0000 Delivered-To: apmail-db-derby-commits-archive@db.apache.org Received: (qmail 71905 invoked by uid 500); 3 Nov 2008 14:46:14 -0000 Mailing-List: contact derby-commits-help@db.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: List-Post: Reply-To: "Derby Development" List-Id: Delivered-To: mailing list derby-commits@db.apache.org Received: (qmail 71896 invoked by uid 99); 3 Nov 2008 14:46:14 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Nov 2008 06:46:14 -0800 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 03 Nov 2008 14:45:06 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 90AFD2388878; Mon, 3 Nov 2008 06:45:17 -0800 (PST) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r710071 - in /db/derby/code/trunk/java: engine/org/apache/derby/impl/sql/compile/ResultColumnList.java testing/org/apache/derbyTesting/functionTests/tests/lang/GeneratedColumnsTest.java Date: Mon, 03 Nov 2008 14:45:17 -0000 To: derby-commits@db.apache.org From: rhillegas@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081103144517.90AFD2388878@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: rhillegas Date: Mon Nov 3 06:45:16 2008 New Revision: 710071 URL: http://svn.apache.org/viewvc?rev=710071&view=rev Log: DERBY-481: Allow DEFAULT literal on INSERTs into generated columns which don't have explicity target lists. Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/ResultColumnList.java 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=710071&r1=710070&r2=710071&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 Nov 3 06:45:16 2008 @@ -3899,7 +3899,16 @@ } // end of if () DefaultInfoImpl defaultInfo = (DefaultInfoImpl) cd.getDefaultInfo(); - if (defaultInfo != null) + + // + // For generated columns, we don't have enough context at this + // point to bind the generation clause (the default) and + // 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. + // + if ( (defaultInfo != null) && !defaultInfo.isGeneratedColumn() ) { /* Query is dependent on the DefaultDescriptor */ DefaultDescriptor defaultDescriptor = cd.getDefaultDescriptor(getDataDictionary()); 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=710071&r1=710070&r2=710071&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 Nov 3 06:45:16 2008 @@ -407,6 +407,11 @@ conn, "create unique index t_insert_2_b on t_insert_2( b )" ); + goodStatement + ( + conn, + "create table t_insert_3( a int, b int generated always as ( -a ) )" + ); goodStatement ( @@ -442,6 +447,17 @@ "insert into t_insert_2( a, b ) values ( 6, default )" ); + goodStatement + ( + conn, + "insert into t_insert_3 values ( 1, default )" + ); + goodStatement + ( + conn, + "insert into t_insert_3 values ( 2, default ), ( 3, default ), ( 4, default )" + ); + // // Verify that all of the expected rows are in the table having the // generated column. @@ -465,6 +481,20 @@ false ); + assertResults + ( + conn, + "select * from t_insert_3 order by a", + new String[][] + { + { "1" , "-1" }, + { "2" , "-2" }, + { "3" , "-3" }, + { "4" , "-4" }, + }, + false + ); + // fails trying to override a generation clause expectCompilationError (