db-derby-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From rhille...@apache.org
Subject svn commit: r1561668 - in /db/derby/code/trunk: java/engine/org/apache/derby/iapi/sql/execute/ java/engine/org/apache/derby/impl/sql/compile/ java/engine/org/apache/derby/impl/sql/execute/ java/engine/org/apache/derby/vti/ java/testing/org/apache/derby...
Date Mon, 27 Jan 2014 13:28:09 GMT
Author: rhillegas
Date: Mon Jan 27 13:28:09 2014
New Revision: 1561668

URL: http://svn.apache.org/r1561668
Log:
DERBY-6117: Give table functions more information about their execution environment; commit
derby-6117-01-ab-AwareVTI.diff.

Added:
    db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java   (with props)
    db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java   (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java
  (with props)
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DummyAwareVTI.java
  (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.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/StaticMethodCallNode.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
    db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
    db/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
    db/derby/code/trunk/tools/javadoc/publishedapi.ant

Modified: db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/iapi/sql/execute/ResultSetFactory.java
Mon Jan 27 13:28:09 2014
@@ -668,6 +668,8 @@ public interface ResultSetFactory {
 		@param returnTypeNumber	Which saved object contains the return type (a multi-set) serialized
as a byte array
 		@param vtiProjectionNumber	Which saved object contains the projection for a RestrictedVTI
 		@param vtiRestrictionNumber	Which saved object contains the restriction for a RestrictedVTI
+        @param   vtiSchema   Name of the schema holding the table function.
+        @param   vtiName      Name of the table function.
 		@return the row as a result set.
 		@exception StandardException thrown when unable to create the
 			result set
@@ -687,7 +689,9 @@ public interface ResultSetFactory {
                                      boolean isDerbyStyleTableFunction,
                                      int returnTypeNumber,
                                      int vtiProjectionNumber,
-                                     int vtiRestrictionNumber
+                                     int vtiRestrictionNumber,
+                                     String vtiSchema,
+                                     String vtiName
                                           )
 		 throws StandardException;
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/FromVTI.java Mon Jan
27 13:28:09 2014
@@ -1731,7 +1731,12 @@ class FromVTI extends FromTable implemen
         mb.push( storeObjectInPS( acb, projectedColumnNames ) );
         mb.push( storeObjectInPS( acb, vtiRestriction ) );        
 
-		return 18;
+        // push the schema name and unqualified name of the table function
+        TableName   fullName = methodCall.getFullName();
+		mb.push( (fullName == null) ? "" : fullName.getSchemaName() );
+		mb.push( (fullName == null) ? "" : fullName.getTableName() );
+
+		return 20;
 	}
     /** Store an object in the prepared statement.  Returns -1 if the object is
      * null. Otherwise returns the object's retrieval handle.

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=1561668&r1=1561667&r2=1561668&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
Mon Jan 27 13:28:09 2014
@@ -113,6 +113,17 @@ abstract class MethodCallNode extends Ja
 	}
 
     /**
+     * <p>
+     * Get the schema-qualified name of the the routine. Is non-null only for
+     * StaticMethodCallNodes.
+     * </p>
+     */
+    TableName getFullName()
+	{
+		return  null;
+	}
+
+    /**
      * @return the name of the class that contains the method, null if not known. It may
not be known
      *         until this node has been bound.
      */

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/compile/StaticMethodCallNode.java
Mon Jan 27 13:28:09 2014
@@ -176,6 +176,12 @@ class StaticMethodCallNode extends Metho
     /** Flag that this function invocation appears in a GROUP BY clause */
     public  void    setAppearsInGroupBy() { appearsInGroupBy = true; }
     
+    @Override
+    TableName getFullName()
+	{
+		return  procedureName;
+	}
+
 	/**
 	 * Bind this expression.  This means binding the sub-expressions,
 	 * as well as figuring out what the return type is for this expression.

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
(original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/GenericResultSetFactory.java
Mon Jan 27 13:28:09 2014
@@ -463,7 +463,9 @@ public class GenericResultSetFactory imp
                                      boolean isDerbyStyleTableFunction,
                                      int returnTypeNumber,
                                      int vtiProjectionNumber,
-                                     int vtiRestrictionNumber
+                                     int vtiRestrictionNumber,
+                                     String vtiSchema,
+                                     String vtiName
                                           )
 		throws StandardException
 	{
@@ -481,7 +483,9 @@ public class GenericResultSetFactory imp
 								isDerbyStyleTableFunction,
                                 returnTypeNumber,
                                 vtiProjectionNumber,
-                                vtiRestrictionNumber
+                                vtiRestrictionNumber,
+                                vtiSchema,
+                                vtiName
                                 );
 	}
 

Modified: db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/impl/sql/execute/VTIResultSet.java Mon
Jan 27 13:28:09 2014
@@ -54,8 +54,10 @@ import org.apache.derby.iapi.services.io
 import org.apache.derby.vti.DeferModification;
 import org.apache.derby.vti.IFastPath;
 import org.apache.derby.vti.VTIEnvironment;
+import org.apache.derby.vti.AwareVTI;
 import org.apache.derby.vti.RestrictedVTI;
 import org.apache.derby.vti.Restriction;
+import org.apache.derby.vti.VTIContext;
 
 import java.sql.PreparedStatement;
 import java.sql.ResultSet;
@@ -99,6 +101,9 @@ class VTIResultSet extends NoPutResultSe
     private String[] vtiProjection;
     private Restriction vtiRestriction;
 
+    private String  vtiSchema;
+    private String  vtiName;
+
 	/**
 		Specified isolation level of SELECT (scan). If not set or
 		not application, it will be set to TransactionControl.UNSPECIFIED_ISOLATION_LEVEL
@@ -122,7 +127,9 @@ class VTIResultSet extends NoPutResultSe
 				 boolean isDerbyStyleTableFunction,
                  int returnTypeNumber,
                  int vtiProjectionNumber,
-                 int vtiRestrictionNumber
+                 int vtiRestrictionNumber,
+                 String vtiSchema,
+                 String vtiName
                  ) 
 		throws StandardException
 	{
@@ -136,6 +143,8 @@ class VTIResultSet extends NoPutResultSe
 		this.pushedQualifiers = pushedQualifiers;
 		this.scanIsolationLevel = scanIsolationLevel;
 		this.isDerbyStyleTableFunction = isDerbyStyleTableFunction;
+        this.vtiSchema = vtiSchema;
+        this.vtiName = vtiName;
 
         ExecPreparedStatement ps = activation.getPreparedStatement();
 
@@ -247,6 +256,21 @@ class VTIResultSet extends NoPutResultSe
 
                     restrictedVTI.initScan( vtiProjection, cloneRestriction( activation )
);
                 }
+
+                if ( userVTI instanceof AwareVTI )
+                {
+                    AwareVTI awareVTI = (AwareVTI) userVTI;
+
+                    awareVTI.setContext
+                        (
+                         new VTIContext
+                         (
+                          vtiSchema,
+                          vtiName,
+                          activation.getLanguageConnectionContext().getStatementContext().getStatementText()
+                          )
+                         );
+                }
 			}
 
 			// Set up the nullablity of the runtime columns, may be delayed

Added: db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java?rev=1561668&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java Mon Jan 27 13:28:09
2014
@@ -0,0 +1,44 @@
+/*
+
+   Derby - Class org.apache.derby.vti.AwareVTI
+
+   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.derby.vti;
+
+/**
+ * <p>
+ * Interface describing a table function which can be given information about the context
+ * in which it runs.
+ * </p>
+ */
+public interface AwareVTI
+{
+    /////////////////////////////////////////////////////////////////
+    //
+    //  PUBLIC BEHAVIOR
+    //
+    /////////////////////////////////////////////////////////////////
+
+    /** Get the table function context */
+    public  VTIContext  getContext();
+
+    /** Set the table function context */
+    public  void    setContext( VTIContext context );
+    
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/vti/AwareVTI.java
------------------------------------------------------------------------------
    svn:eol-style = native

Added: db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java?rev=1561668&view=auto
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java (added)
+++ db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java Mon Jan 27 13:28:09
2014
@@ -0,0 +1,89 @@
+/*
+
+   Derby - Class org.apache.derby.vti.VTIContext
+
+   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.derby.vti;
+
+/**
+ * <p>
+ * Context parameter which is passed to an AwareVTI.
+ * </p>
+ */
+public class VTIContext
+{
+    /////////////////////////////////////////////////////////////////
+    //
+    //  CONSTANTS
+    //
+    /////////////////////////////////////////////////////////////////
+    
+    /////////////////////////////////////////////////////////////////
+    //
+    //  STATE
+    //
+    /////////////////////////////////////////////////////////////////
+
+    private String  _vtiSchema;
+    private String  _vtiTable;
+    private String  _statementText;
+    
+    /////////////////////////////////////////////////////////////////
+    //
+    //  CONSTRUCTOR
+    //
+    /////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Construct from pieces.
+     * </p>
+     *
+     * @param   vtiSchema   Name of the schema holding the table function.
+     * @param   vtiTable      Name of the table function.
+     * @param   statementText   Text of the statement which is invoking the table function.
+     */
+    public  VTIContext
+        (
+         String vtiSchema,
+         String vtiTable,
+         String statementText
+         )
+    {
+        _vtiSchema = vtiSchema;
+        _vtiTable = vtiTable;
+        _statementText = statementText;
+    }
+    
+    /////////////////////////////////////////////////////////////////
+    //
+    //  PUBLIC BEHAVIOR
+    //
+    /////////////////////////////////////////////////////////////////
+
+    /** Return the name of the schema holding the table function */
+    public  String  vtiSchema() { return _vtiSchema; }
+
+    /** Return the unqualified table function name */
+    public  String  vtiTable()  { return _vtiTable; }
+
+    /** Return the text of the statement which invoked the table function */
+    public  String  statementText() { return _statementText; }
+    
+}

Propchange: db/derby/code/trunk/java/engine/org/apache/derby/vti/VTIContext.java
------------------------------------------------------------------------------
    svn:eol-style = native

Modified: db/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/vti/VTITemplate.java Mon Jan 27 13:28:09
2014
@@ -68,8 +68,10 @@ import java.util.Map;
 	For table functions and virtual tables, the database engine only calls methods defined
 	in the JDBC 2.0 definition of java.sql.ResultSet.
  */
-public abstract class VTITemplate   implements ResultSet
+public abstract class VTITemplate   implements ResultSet, AwareVTI
 {
+    private VTIContext  _vtiContext;
+    
     public  boolean 	isWrapperFor(Class<?> iface) throws SQLException { throw notImplemented(
"isWrapperFor" ); }
     public  <T> T unwrap(Class<T> iface) throws SQLException { throw notImplemented(
"unwrap" ); }
 
@@ -278,6 +280,15 @@ public abstract class VTITemplate   impl
     
     /////////////////////////////////////////////////////////////////////////
     //
+    //  AwareVTI BEHAVIOR
+    //
+    /////////////////////////////////////////////////////////////////////////
+
+    public  VTIContext  getContext() { return _vtiContext; }
+    public  void    setContext( VTIContext context )    { _vtiContext = context; }
+
+    /////////////////////////////////////////////////////////////////////////
+    //
     //  MINIONS
     //
     /////////////////////////////////////////////////////////////////////////

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java?rev=1561668&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/AwareVTITest.java
Mon Jan 27 13:28:09 2014
@@ -0,0 +1,147 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.lang.AwareVTITest
+
+   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.lang;
+
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.Statement;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.derbyTesting.junit.TestConfiguration;
+import org.apache.derbyTesting.junit.CleanDatabaseTestSetup;
+import org.apache.derbyTesting.junit.JDBC;
+
+/**
+ * <p>
+ * Test AwareVTIs. See DERBY-6117.
+ * </p>
+ */
+public class AwareVTITest  extends GeneratedColumnsHelper
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTANTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * Create a new instance.
+     */
+
+    public AwareVTITest(String name)
+    {
+        super(name);
+    }
+    
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // JUnit BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+
+    /**
+     * Construct top level suite in this JUnit test
+     */
+    public static Test suite()
+    {
+        TestSuite suite = (TestSuite) TestConfiguration.embeddedSuite(AwareVTITest.class);
+        Test        result = new CleanDatabaseTestSetup( suite );
+
+        return result;
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // TESTS
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Basic test of AwareVTIs.
+     * </p>
+     */
+    public void test_01_basic() throws Exception
+    {
+        Connection conn = getConnection();
+
+        vetBasic( conn, "s1", "f1" );
+        vetBasic( conn, "s2", "f2" );
+    }
+    private void    vetBasic( Connection conn, String schema, String function ) throws Exception
+    {
+        goodStatement( conn, "create schema " + schema );
+        goodStatement
+            (
+             conn,
+             "create function " + schema + "." + function + "() returns table\n" +
+             "(\n" +
+             "    schema_name varchar( 20 ),\n" +
+             "    vti_name varchar( 20 ),\n" +
+             "    statement_text varchar( 100 )\n" +
+             ")\n" +
+             "language java parameter style derby_jdbc_result_set no sql\n" +
+             "external name 'org.apache.derbyTesting.functionTests.tests.lang.AwareVTITest.dummyAwareVTI'\n"
+             );
+
+        String  query = "select * from table( " + schema + "." + function + "() ) s";
+        assertResults
+            (
+             conn,
+             query,
+             new String[][]
+             {
+                 { schema.toUpperCase(), function.toUpperCase(), query },
+             },
+             false
+             );
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // ROUTINES
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  static  DummyAwareVTI   dummyAwareVTI()
+    {
+        return new DummyAwareVTI();
+    }
+
+}
+

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

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DummyAwareVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DummyAwareVTI.java?rev=1561668&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DummyAwareVTI.java
(added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/DummyAwareVTI.java
Mon Jan 27 13:28:09 2014
@@ -0,0 +1,85 @@
+/*
+
+Derby - Class org.apache.derbyTesting.functionTests.tests.lang.DummyAwareVTI
+
+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.lang;
+
+import java.sql.SQLException;
+
+import org.apache.derby.vti.AwareVTI;
+import org.apache.derby.vti.StringColumnVTI;
+import org.apache.derby.vti.VTIContext;
+
+/**
+ * A VTI which reports its context
+ */
+public class DummyAwareVTI extends StringColumnVTI
+{
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // STATE
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    private VTIContext  _context;
+    private int     _rowCount = 0;
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // CONSTRUCTOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public  DummyAwareVTI()
+    {
+        super( new String[] { "SCHEMA_NAME", "VTI_NAME", "STATEMENT_TEXT" } );
+    }
+
+    ///////////////////////////////////////////////////////////////////////////////////
+    //
+    // StringColumnVTI BEHAVIOR
+    //
+    ///////////////////////////////////////////////////////////////////////////////////
+
+    public boolean  next()
+    {
+        if ( _rowCount > 0 ) { return false; }
+
+        _rowCount++;
+
+        return true;
+    }
+
+    public  void    close() {}
+
+    protected String getRawColumn(int columnNumber)
+        throws java.sql.SQLException
+    {
+        switch( columnNumber )
+        {
+        case 1: return getContext().vtiSchema();
+        case 2: return getContext().vtiTable();
+        case 3: return getContext().statementText();
+
+        default: throw new SQLException( "Illegal columnNumber " + columnNumber );
+        }
+    }
+
+}

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
(original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/_Suite.java
Mon Jan 27 13:28:09 2014
@@ -219,6 +219,7 @@ public class _Suite extends BaseTestCase
         suite.addTest(GeneratedColumnsTest.suite());
         suite.addTest(GeneratedColumnsPermsTest.suite());
         suite.addTest(RestrictedVTITest.suite());
+        suite.addTest(AwareVTITest.suite());
         suite.addTest(UDTTest.suite());
         suite.addTest(UDTPermsTest.suite());
         suite.addTest(BooleanValuesTest.suite());

Modified: db/derby/code/trunk/tools/javadoc/publishedapi.ant
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/tools/javadoc/publishedapi.ant?rev=1561668&r1=1561667&r2=1561668&view=diff
==============================================================================
--- db/derby/code/trunk/tools/javadoc/publishedapi.ant (original)
+++ db/derby/code/trunk/tools/javadoc/publishedapi.ant Mon Jan 27 13:28:09 2014
@@ -52,11 +52,13 @@ org/apache/derby/tools/dblook.java
 
 # package: org.apache.derby.vti
 
+org/apache/derby/vti/AwareVTI.java
 org/apache/derby/vti/ForeignTableVTI.java
 org/apache/derby/vti/RestrictedVTI.java
 org/apache/derby/vti/Restriction.java
 org/apache/derby/vti/StringColumnVTI.java
 org/apache/derby/vti/VTICosting.java
+org/apache/derby/vti/VTIContext.java
 org/apache/derby/vti/VTIEnvironment.java
 org/apache/derby/vti/VTITemplate.java
 



Mime
View raw message