db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r944386 - in /db/derby/code/trunk/java: engine/org/apache/derby/iapi/sql/dictionary/ engine/org/apache/derby/impl/sql/catalog/ engine/org/apache/derby/impl/sql/compile/ testing/org/apache/derbyTesting/functionTests/tests/lang/ testing/org/a...
Date Fri, 14 May 2010 18:52:51 GMT
Author: rhillegas
Date: Fri May 14 18:52:51 2010
New Revision: 944386

URL: http://svn.apache.org/viewvc?rev=944386&view=rev
Log:
DERBY-4657: Allow functions to return BOOLEAN values.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java
  (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/dictionary/DataDictionary.java
Fri May 14 18:52:51 2010
@@ -119,6 +119,9 @@ public interface DataDictionary
 	/** Derby 10.6 System Catalog version */
 	public static final int DD_VERSION_DERBY_10_6		= 180;
 
+	/** Derby 10.7 System Catalog version */
+	public static final int DD_VERSION_DERBY_10_7		= 190;
+
 	// general info
 	public	static	final	String	DATABASE_ID = "derby.databaseID";
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DD_Version.java Fri
May 14 18:52:51 2010
@@ -156,6 +156,8 @@ public	class DD_Version implements	Forma
 			return "10.5";
 		case DataDictionary.DD_VERSION_DERBY_10_6:
 			return "10.6";
+		case DataDictionary.DD_VERSION_DERBY_10_7:
+			return "10.7";
 		default:
 			return null;
 		}

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/catalog/DataDictionaryImpl.java
Fri May 14 18:52:51 2010
@@ -490,7 +490,7 @@ public final class	DataDictionaryImpl
 	public void boot(boolean create, Properties startParams) 
 			throws StandardException
 	{
-		softwareVersion = new DD_Version(this, DataDictionary.DD_VERSION_DERBY_10_6);
+		softwareVersion = new DD_Version(this, DataDictionary.DD_VERSION_DERBY_10_7);
 
 		startupParameters = startParams;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/MethodCallNode.java
Fri May 14 18:52:51 2010
@@ -791,6 +791,7 @@ abstract class MethodCallNode extends Ja
 
 					if (!requiredType.equals(typeName)) {
 						switch (returnType.getJDBCTypeId()) {
+						case java.sql.Types.BOOLEAN:
 						case java.sql.Types.SMALLINT:
 						case java.sql.Types.INTEGER:
 						case java.sql.Types.BIGINT:

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/sqlgrammar.jj Fri May
14 18:52:51 2010
@@ -3899,7 +3899,7 @@ columnDefinition(TableElementList tableE
 
 	/* identifier() used to be columnName() */
 	columnName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true) 
-	[ ( typeDescriptor[0] = dataTypeDDL() ) ]
+	[ ( typeDescriptor[0] = dataTypeDDL( false ) ) ]
 	[ defaultNode = defaultAndConstraints(typeDescriptor, tableElementList, columnName, autoIncrementInfo)
]
 	{
 		// Only pass autoincrement info for autoincrement columns
@@ -3948,13 +3948,13 @@ defaultAndConstraints(DataTypeDescriptor
  * <A NAME="dataTypeDDL">dataTypeDDL</A>
  */
 DataTypeDescriptor
-dataTypeDDL() throws StandardException :
+dataTypeDDL( boolean booleanDatatypeAllowed ) throws StandardException :
 {
 	DataTypeDescriptor	typeDescriptor;
 }
 {
 	LOOKAHEAD( { commonDatatypeName(false) } )
-	typeDescriptor = dataTypeCommon()
+	typeDescriptor = dataTypeCommon( booleanDatatypeAllowed )
 	{
 		return typeDescriptor;
 	}
@@ -3971,12 +3971,12 @@ dataTypeDDL() throws StandardException :
    the Java interface TypeDescriptor.
 */
 TypeDescriptor
-catalogType() throws StandardException :
+catalogType( boolean booleanDatatypeAllowed ) throws StandardException :
 {
 	DataTypeDescriptor	typeDescriptor;
 }
 {
-	typeDescriptor = dataTypeDDL()
+	typeDescriptor = dataTypeDDL( booleanDatatypeAllowed )
 	{
 		return typeDescriptor.getCatalogType();
 	}
@@ -3995,7 +3995,7 @@ dataTypeCast() throws StandardException 
 	// This lookahead is required because the names of the built-in
 	// datatypes are not reserved words
 	LOOKAHEAD( { commonDatatypeName(true) } )
-	typeDescriptor = dataTypeCommon()
+	typeDescriptor = dataTypeCommon( false )
 	{
 		return typeDescriptor;
 	}
@@ -4010,7 +4010,7 @@ dataTypeCast() throws StandardException 
  * <A NAME="dataTypeCommon">dataTypeCommon</A>
  */
 DataTypeDescriptor
-dataTypeCommon() throws StandardException :
+dataTypeCommon( boolean booleanDatatypeAllowed ) throws StandardException :
 {
 	DataTypeDescriptor	typeDescriptor;
 	boolean checkCS = false;
@@ -4037,7 +4037,11 @@ dataTypeCommon() throws StandardExceptio
 	typeDescriptor = datetimeType()
 | <BOOLEAN>
 {
-	checkInternalFeature(TypeId.BOOLEAN_NAME);
+	if ( !booleanDatatypeAllowed) { checkInternalFeature(TypeId.BOOLEAN_NAME); }
+	if ((getCompilerContext().getReliability() & CompilerContext.INTERNAL_SQL_ILLEGAL) !=
0)
+    {
+        checkVersion(DataDictionary.DD_VERSION_DERBY_10_7, "BOOLEAN");
+    }
 	typeDescriptor = new DataTypeDescriptor(TypeId.BOOLEAN_ID, true);
 }
 |
@@ -7189,7 +7193,7 @@ DataTypeDescriptor xmlSerializeTargetTyp
 			ReuseFactory.getInteger(getToken(1).beginColumn));
 	}
 |
-	<AS> targetType = dataTypeDDL()
+	<AS> targetType = dataTypeDDL( false )
 	{
 		return targetType;
 	}
@@ -10736,7 +10740,7 @@ procedureParameterDefinition(Vector[] li
 	[   LOOKAHEAD( { dataTypeCheck(2) })
 	    parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
 	]
-	typeDescriptor = dataTypeDDL()
+	typeDescriptor = dataTypeDDL( false )
 	{
 		list[0].addElement(parameterName);
 		list[1].addElement(typeDescriptor.getCatalogType());
@@ -10831,7 +10835,7 @@ functionParameterDefinition(Vector[] lis
 	[   LOOKAHEAD( { dataTypeCheck(2) })
 	    parameterName = identifier(Limits.MAX_IDENTIFIER_LENGTH, true)
 	]
-	typeDescriptor = dataTypeDDL() 
+	typeDescriptor = dataTypeDDL( false ) 
 	{
 		list[0].addElement(parameterName);
 		list[1].addElement(typeDescriptor.getCatalogType());
@@ -10850,7 +10854,7 @@ functionReturnDataType() throws Standard
 }
 {
     (
-        typeDescriptor = catalogType()
+        typeDescriptor = catalogType( true )
          |
         typeDescriptor = functionTableType()
     )
@@ -10917,7 +10921,7 @@ throws StandardException :
 }
 {
 	name = identifier( Limits.MAX_IDENTIFIER_LENGTH, true )
-	typeDescriptor = dataTypeDDL()
+	typeDescriptor = dataTypeDDL( false )
 	{
 		names.add( name );
 		types.add( typeDescriptor.getCatalogType() );
@@ -13278,7 +13282,7 @@ columnAlterClause(String columnName) thr
 }
 {
 	LOOKAHEAD( {getToken(2).kind == DATA} )
-	<SET> <DATA> <TYPE> typeDescriptor = dataTypeDDL()
+	<SET> <DATA> <TYPE> typeDescriptor = dataTypeDDL( false )
 	{
 		return (TableElementNode) nodeFactory.getNode(
 						C_NodeTypes.MODIFY_COLUMN_TYPE_NODE,
@@ -13794,11 +13798,11 @@ List/*<TypeDescriptor>*/ parameterTypeLi
     TypeDescriptor type;
 }
 {
-    [ type = catalogType()
+    [ type = catalogType( false )
         {
             list.add(type);
         }
-      ( <COMMA> type = catalogType()
+      ( <COMMA> type = catalogType( false )
         {
             list.add(type);
         }

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignatures.java
Fri May 14 18:52:51 2010
@@ -52,6 +52,18 @@ public  class   AnsiSignatures
     ///////////////////////////////////////////////////////////////////
 
     //
+    // BOOLEAN
+    //
+    
+    // legal resolutions
+    public  static  boolean   boolean_boolean_int( int a ) { return true; }
+    public  static  Boolean boolean_Boolean_int( int a ) { return Boolean.TRUE; }
+
+    // bad return type
+    public  static  byte   boolean_badreturn_byte_int( int a ) { return (byte) -1; }
+
+    
+    //
     // SMALLINT
     //
     

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AnsiSignaturesTest.java
Fri May 14 18:52:51 2010
@@ -101,6 +101,19 @@ public class AnsiSignaturesTest extends 
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    public  void    test_boolean_boolean_int()
+        throws Exception
+    {
+        declareAndRunFunction
+            ( "boolean_boolean_int", "boolean", new String[] { "int" }, "3", "true" );
+    }
+    public  void    test_boolean_Boolean_int()
+        throws Exception
+    {
+        declareAndRunFunction
+            ( "boolean_Boolean_int", "boolean", new String[] { "int" }, "3", "true" );
+    }
+    
     public  void    test_smallint_short_short()
         throws Exception
     {
@@ -408,6 +421,13 @@ public class AnsiSignaturesTest extends 
     //
     ///////////////////////////////////////////////////////////////////////////////////
 
+    public  void    test_boolean_badreturn_byte_int()
+        throws Exception
+    {
+        declareAndFailFunction
+            ( "boolean_badreturn_byte_int", "boolean", new String[] { "int" }, "3", "true",
TRIED_ALL_COMBINATIONS );
+    }
+
     public  void    test_smallint_badreturn_byte_short()
         throws Exception
     {

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java?rev=944386&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java
Fri May 14 18:52:51 2010
@@ -0,0 +1,141 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.upgradeTests.Changes10_7
+
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements.  See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You under the Apache License, Version 2.0
+(the "License"); you may not use this file except in compliance with
+the License.  You may obtain a copy of the License at
+
+   http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+*/
+package org.apache.derbyTesting.functionTests.tests.upgradeTests;
+
+import org.apache.derbyTesting.junit.SupportFilesSetup;
+
+import org.apache.derbyTesting.junit.JDBCDataSource;
+import java.lang.reflect.Method;
+import java.sql.SQLException;
+import java.sql.Statement;
+import java.sql.Connection;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+
+import javax.sql.DataSource;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derby.catalog.types.RoutineAliasInfo;
+import org.apache.derby.catalog.TypeDescriptor;
+import org.apache.derbyTesting.junit.JDBC;
+
+
+/**
+ * Upgrade test cases for 10.7.
+ * If the old version is 10.7 or later then these tests
+ * will not be run.
+ * <BR>
+    10.7 Upgrade issues
+
+    <UL>
+    <LI>BOOLEAN data type support expanded.</LI>
+    </UL>
+
+ */
+public class Changes10_7 extends UpgradeChange
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private static final String SYNTAX_ERROR = "42X01";
+    private static final String  UPGRADE_REQUIRED = "XCL47";
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public Changes10_7(String name)
+    {
+        super(name);
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // JUnit BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Return the suite of tests to test the changes made in 10.7.
+     * @param phase an integer that indicates the current phase in
+     *              the upgrade test.
+     * @return the test suite created.
+     */
+    public static Test suite(int phase) {
+        TestSuite suite = new TestSuite("Upgrade test for 10.7");
+
+        suite.addTestSuite(Changes10_7.class);
+        return new SupportFilesSetup((Test) suite);
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // TESTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Make sure that that database is at level 10.7 in order to enjoy
+     * extended support for the BOOLEAN datatype.
+     */
+    public void testBoolean() throws SQLException
+    {
+        String booleanValuedFunction =
+            "create function f_4655( a varchar( 100 ) ) returns boolean\n" +
+            "language java parameter style java no sql deterministic\n" +
+            "external name 'Z.getBooleanValue'\n";
+
+        Statement s = createStatement();
+
+        switch ( getPhase() )
+        {
+        case PH_CREATE: // create with old version
+        case PH_POST_SOFT_UPGRADE: // soft-downgrade: boot with old version after soft-upgrade
+            assertStatementError(  SYNTAX_ERROR, s, booleanValuedFunction );
+            break;
+
+        case PH_SOFT_UPGRADE: // boot with new version and soft-upgrade
+            assertStatementError( UPGRADE_REQUIRED, s, booleanValuedFunction );
+            break;
+            
+        case PH_HARD_UPGRADE: // boot with new version and hard-upgrade
+            s.execute( booleanValuedFunction );
+            break;
+        }
+        
+        s.close();
+    }
+
+}

Propchange: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/Changes10_7.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java?rev=944386&r1=944385&r2=944386&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/upgradeTests/UpgradeRun.java
Fri May 14 18:52:51 2010
@@ -193,6 +193,8 @@ class UpgradeRun extends UpgradeClassLoa
                 	suite.addTest(Changes10_5.suite(phase));
                 if (oldMinor < 6)
                 	suite.addTest(Changes10_6.suite(phase));
+                if (oldMinor < 7)
+                	suite.addTest(Changes10_7.suite(phase));
             }
             
             // Add DatabaseMetaData tests. Since metadata



Mime
View raw message