You are viewing a plain text version of this content. The canonical link for it is here.
Posted to derby-commits@db.apache.org by rh...@apache.org on 2011/08/22 23:32:29 UTC

svn commit: r1160445 - in /db/derby/code/trunk/java: engine/org/apache/derby/vti/ testing/org/apache/derbyTesting/functionTests/tests/lang/

Author: rhillegas
Date: Mon Aug 22 21:32:29 2011
New Revision: 1160445

URL: http://svn.apache.org/viewvc?rev=1160445&view=rev
Log:
DERBY-5370: Checkin in Brett Bergquist's patch to make Restriction.toSQL() handle more data types.

Added:
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java   (with props)
Modified:
    db/derby/code/trunk/java/engine/org/apache/derby/vti/Restriction.java
    db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java

Modified: db/derby/code/trunk/java/engine/org/apache/derby/vti/Restriction.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/engine/org/apache/derby/vti/Restriction.java?rev=1160445&r1=1160444&r2=1160445&view=diff
==============================================================================
--- db/derby/code/trunk/java/engine/org/apache/derby/vti/Restriction.java (original)
+++ db/derby/code/trunk/java/engine/org/apache/derby/vti/Restriction.java Mon Aug 22 21:32:29 2011
@@ -235,10 +235,27 @@ public abstract class Restriction implem
 
             buffer.append( IdUtil.normalToDelimited( _columnName ) );
             buffer.append( " " + OPERATOR_SYMBOLS[ _comparisonOperator ] + " " );
-            if ( _constantOperand != null ) { buffer.append( _constantOperand ); }
+            if ( _constantOperand != null ) { buffer.append( toEscapedString( _constantOperand ) ); }
 
             return buffer.toString();
         }
+
+        protected String toEscapedString(Object o) {
+            if (o instanceof java.sql.Timestamp) {
+                return "TIMESTAMP('" + o.toString() + "')";
+            } else if (o instanceof java.sql.Date) {
+                return "DATE('" + o.toString() + "')";
+            } else if (o instanceof java.sql.Time) {
+                return "TIME('" + o.toString() + "')";
+            } else if (o instanceof String) {
+                return "\'" + o.toString() + "\'";
+            } else if (o instanceof byte[]) {
+                byte[] b = (byte[]) o;
+                return "X\'" + org.apache.derby.iapi.util.StringUtil.toHexString(b, 0, b.length) + "\'" ;
+            } else {
+                return o.toString();
+            }
+        }
     }
     
 }

Added: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java?rev=1160445&view=auto
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java (added)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedTableVTI.java Mon Aug 22 21:32:29 2011
@@ -0,0 +1,360 @@
+/*
+
+   Derby - Class org.apache.derbyTesting.functionTests.tests.lang.RestrictedTableVTI
+
+   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.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.sql.Blob;
+import java.sql.Clob;
+import java.sql.Connection;
+import java.sql.Date;
+import java.sql.DatabaseMetaData;
+import java.sql.DriverManager;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.ResultSetMetaData;
+import java.sql.SQLException;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.sql.Types;
+import java.util.Calendar;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.derby.vti.VTITemplate;
+import org.apache.derby.vti.RestrictedVTI;
+import org.apache.derby.vti.Restriction;
+
+/**
+ * <p>
+ * This class contains a table function which can be used to read data
+ * from a Derby table.
+ * </p>
+ */
+public	class   RestrictedTableVTI extends VTITemplate implements  RestrictedVTI
+{
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	CONSTANTS
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	STATE
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    private String  _schemaName;
+    private String  _tableName;
+    private Connection _connection;
+
+    private String[]    _columnNames;
+    private Restriction _restriction;
+
+    // this maps table function columns (0-based) to table column numbers (1-based) in
+    // the actual query
+    private int[]               _columnNumberMap;
+    private PreparedStatement   _preparedStatement;
+    private ResultSet           _resultSet;
+
+    private static  String  _lastQuery;
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	CONSTRUCTOR
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    protected  RestrictedTableVTI
+        (
+         String schemaName,
+         String tableName
+         )
+        throws Exception
+    {
+        _schemaName = schemaName;
+        _tableName = tableName;
+        _connection = getDerbyConnection();
+    }
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	TABLE FUNCTIONS
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Table function to read a table in Derby.
+     * </p>
+     */
+    public  static  RestrictedTableVTI readTable
+        (
+         String schemaName,
+         String tableName
+         )
+        throws Exception
+    {
+        return new RestrictedTableVTI( schemaName, tableName );
+    }
+
+    /**
+     * <p>
+     * Scalar function to retrieve the last query generated by this machinery.
+     * </p>
+     */
+    public  static  String  getLastQuery() { return _lastQuery; }
+    
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	ResultSet BEHAVIOR
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    public  void    close() throws SQLException
+    {
+        if ( !isClosed() )
+        {
+            _schemaName = null;
+            _tableName = null;
+            _connection = null;
+            _columnNames = null;
+            _restriction = null;
+            _columnNumberMap = null;
+
+            if ( _resultSet != null ) { _resultSet.close(); }
+            if ( _preparedStatement != null ) { _preparedStatement.close(); }
+
+            _resultSet = null;
+            _preparedStatement = null;
+        }
+    }
+
+    public  boolean next()  throws SQLException
+    {
+        if ( !isClosed() && (_resultSet == null) )
+        {
+            _preparedStatement = prepareStatement( _connection, makeQuery() );
+            _resultSet = _preparedStatement.executeQuery();
+        }
+
+        return _resultSet.next();
+    }
+
+    public boolean isClosed() { return (_connection == null); }
+
+    public  boolean wasNull()   throws SQLException
+    { return _resultSet.wasNull(); }
+
+    public  ResultSetMetaData   getMetaData()   throws SQLException
+    { return _resultSet.getMetaData(); }
+
+    public  InputStream 	getAsciiStream(int i) throws SQLException
+    { return _resultSet.getAsciiStream( mapColumnNumber( i ) ); }
+    
+    public  BigDecimal 	getBigDecimal(int i) throws SQLException
+    { return _resultSet.getBigDecimal( mapColumnNumber( i ) ); }
+    
+    public  BigDecimal 	getBigDecimal(int i, int scale) throws SQLException
+    { return _resultSet.getBigDecimal( mapColumnNumber( i ), scale ); }
+    
+    public  InputStream 	getBinaryStream(int i)  throws SQLException
+    { return _resultSet.getBinaryStream( mapColumnNumber( i ) ); }
+    
+    public  Blob 	getBlob(int i)  throws SQLException
+    { return _resultSet.getBlob( mapColumnNumber( i ) ); }
+    
+    public  boolean 	getBoolean(int i) throws SQLException
+    { return _resultSet.getBoolean( mapColumnNumber( i ) ); }
+    
+    public  byte 	getByte(int i)    throws SQLException
+    { return _resultSet.getByte( mapColumnNumber( i ) ); }
+    
+    public  byte[] 	getBytes(int i) throws SQLException
+    { return _resultSet.getBytes( mapColumnNumber( i ) ); }
+    
+    public  Reader 	getCharacterStream(int i) throws SQLException
+    { return _resultSet.getCharacterStream( mapColumnNumber( i ) ); }
+
+    public  Clob 	getClob(int i)  throws SQLException
+    { return _resultSet.getClob( mapColumnNumber( i ) ); }
+
+    public  Date 	getDate(int i)  throws SQLException
+    { return _resultSet.getDate( mapColumnNumber( i ) ); }
+
+    public  Date 	getDate(int i, Calendar cal)    throws SQLException
+    { return _resultSet.getDate( mapColumnNumber( i ), cal ); }
+
+    public  double 	getDouble(int i)    throws SQLException
+    { return _resultSet.getDouble( mapColumnNumber( i ) ); }
+
+    public  float 	getFloat(int i) throws SQLException
+    { return _resultSet.getFloat( mapColumnNumber( i ) ); }
+
+    public  int 	getInt(int i)   throws SQLException
+    { return _resultSet.getInt( mapColumnNumber( i ) ); }
+
+    public  long 	getLong(int i)  throws SQLException
+    { return _resultSet.getLong( mapColumnNumber( i ) ); }
+
+    public  Object 	getObject(int i)    throws SQLException
+    { return _resultSet.getObject( mapColumnNumber( i ) ); }
+
+    public  short 	getShort(int i) throws SQLException
+    { return _resultSet.getShort( mapColumnNumber( i ) ); }
+
+    public  String 	getString(int i)    throws SQLException
+    { return _resultSet.getString( mapColumnNumber( i ) ); }
+
+    public  Time 	getTime(int i)  throws SQLException
+    { return _resultSet.getTime( mapColumnNumber( i ) ); }
+
+    public  Time 	getTime(int i, Calendar cal)    throws SQLException
+    { return _resultSet.getTime( mapColumnNumber( i ), cal ); }
+
+    public  Timestamp 	getTimestamp(int i) throws SQLException
+    { return _resultSet.getTimestamp( mapColumnNumber( i ) ); }
+
+    public  Timestamp 	getTimestamp(int i, Calendar cal)   throws SQLException
+    { return _resultSet.getTimestamp( mapColumnNumber( i ), cal ); }
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	RestrictedVTI BEHAVIOR
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    public  void    initScan
+        ( String[] columnNames, Restriction restriction )
+        throws SQLException
+    {
+        _columnNames = columnNames;
+        _restriction = restriction;
+
+        int columnCount = _columnNames.length;
+
+        _columnNumberMap = new int[ columnCount ];
+        int foreignColumnID = 1;
+        for ( int i = 0; i < columnCount; i++ )
+        {
+            if ( columnNames[ i ] != null ) { _columnNumberMap[ i ] = foreignColumnID++; }
+        }
+    }
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	Connection MANAGEMENT
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    private static  Connection  getDerbyConnection() throws SQLException
+    {
+        return DriverManager.getConnection( "jdbc:default:connection" );
+    }
+
+
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	QUERY FACTORY
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Build the query which will be sent to the nested connection.
+     * </p>
+     */
+    private String  makeQuery()
+    {
+        StringBuffer   buffer = new StringBuffer();
+
+        buffer.append( "select " );
+
+        int possibleCount = _columnNames.length;
+        int actualCount = 0;
+        for ( int i = 0; i < possibleCount; i++ )
+        {
+            String  rawName = _columnNames[ i ];
+            if ( rawName == null ) { continue; }
+
+            if ( actualCount > 0 ) { buffer.append( ", " ); }
+            actualCount++;
+            
+            buffer.append( doubleQuote( rawName ) );
+        }
+
+        buffer.append( "\nfrom " );
+        buffer.append( doubleQuote( _schemaName ) );
+        buffer.append( '.' );
+        buffer.append( doubleQuote( _tableName ) );
+
+        if ( _restriction != null )
+        {
+            String  clause = _restriction.toSQL();
+
+            if (clause != null)
+            {
+                clause = clause.trim();
+                if ( clause.length() != 0 )
+                {
+                    buffer.append( "\nwhere " + clause );
+                }
+            }
+        }
+
+        _lastQuery = buffer.toString();
+
+        return _lastQuery;
+    }
+
+    private static  String  doubleQuote( String text )  { return '"' + text + '"'; }
+    private static  String  singleQuote( String text )  { return '\'' + text + '\''; }
+
+    private static  PreparedStatement   prepareStatement
+        ( Connection conn, String text )
+        throws SQLException
+    {
+        return conn.prepareStatement( text );
+    }
+
+    ////////////////////////////////////////////////////////////////////////
+    //
+    //	UTILITY METHODS
+    //
+    ////////////////////////////////////////////////////////////////////////
+
+    /**
+     * <p>
+     * Map a 1-based Derby column number to a 1-based column number in the
+     * query.
+     * </p>
+     */
+    private int mapColumnNumber( int derbyNumber )
+    {
+        return _columnNumberMap[ derbyNumber - 1 ];
+    }
+}
+

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

Modified: db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java
URL: http://svn.apache.org/viewvc/db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java?rev=1160445&r1=1160444&r2=1160445&view=diff
==============================================================================
--- db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java (original)
+++ db/derby/code/trunk/java/testing/org/apache/derbyTesting/functionTests/tests/lang/RestrictedVTITest.java Mon Aug 22 21:32:29 2011
@@ -170,6 +170,59 @@ public class RestrictedVTITest  extends 
                  ".integerListSpecialColNames'\n"
                  );
         }
+        if ( !routineExists( conn, "MAKEBLOB5370" ) )
+        {
+            goodStatement
+                (
+                 conn,
+                 "create function makeBlob5370( ) returns blob\n" +
+                 "language java parameter style java no sql deterministic\n" +
+                 "external name 'org.apache.derbyTesting.functionTests.tests.lang.BooleanValuesTest.makeSimpleBlob'\n"
+                 );
+        }
+        if ( !routineExists( conn, "LASTQUERY5370" ) )
+        {
+            goodStatement
+                (
+                 conn,
+                 "create function lastQuery5370() returns varchar( 32672 )\n" +
+                 "language java parameter style java no sql\n" +
+                 "external name 'org.apache.derbyTesting.functionTests.tests.lang.RestrictedTableVTI.getLastQuery'\n"
+                 );
+        }
+        if ( !routineExists( conn, "RESTRICTED5370" ) )
+        {
+            goodStatement
+                (
+                 conn,
+                 "create function restricted5370( schemaName varchar( 32672 ), tableName varchar( 32672 ) )\n" +
+                 "returns table\n" +
+                 "(\n" +
+                 "    key_col int,\n" +
+                 "    boolean_col  BOOLEAN,\n" +
+                 "    bigint_col  BIGINT,\n" +
+                 "    blob_col  BLOB(2147483647),\n" +
+                 "    char_col  CHAR(10),\n" +
+                 "    char_for_bit_data_col  CHAR (10) FOR BIT DATA,\n" +
+                 "    clob_col  CLOB,\n" +
+                 "    date_col  DATE,\n" +
+                 "    decimal_col  DECIMAL(5,2),\n" +
+                 "    real_col  REAL,\n" +
+                 "    double_col  DOUBLE,\n" +
+                 "    int_col  INTEGER,\n" +
+                 "    long_varchar_col  LONG VARCHAR,\n" +
+                 "    long_varchar_for_bit_data_col  LONG VARCHAR FOR BIT DATA,\n" +
+                 "    numeric_col  NUMERIC(5,2), \n" +
+                 "    smallint_col  SMALLINT,\n" +
+                 "    time_col  TIME,\n" +
+                 "    timestamp_col  TIMESTAMP,\n" +
+                 "    varchar_col  VARCHAR(10),\n" +
+                 "    varchar_for_bit_data_col  VARCHAR (10) FOR BIT DATA\n" +
+                 ")\n" +
+                 "language java parameter style derby_jdbc_result_set reads sql data\n" +
+                 "external name 'org.apache.derbyTesting.functionTests.tests.lang.RestrictedTableVTI.readTable'\n"
+                 );
+        }
         if ( !tableExists( conn, "T_4357_1" ) )
         {
             goodStatement
@@ -183,6 +236,130 @@ public class RestrictedVTITest  extends 
                  "insert into t_4357_1( a ) values cast( null as int), ( 1 ), ( 100 ), ( 1000 ), ( 10000)\n"
                  );
         }
+        if ( !tableExists( conn, "T_5370" ) )
+        {
+            goodStatement
+                (
+                 conn,
+                 "create table t_5370\n" +
+                 "(\n" +
+                 "    key_col int,\n" +
+                 "    boolean_col  BOOLEAN,\n" +
+                 "    bigint_col  BIGINT,\n" +
+                 "    blob_col  BLOB(2147483647),\n" +
+                 "    char_col  CHAR(10),\n" +
+                 "    char_for_bit_data_col  CHAR (10) FOR BIT DATA,\n" +
+                 "    clob_col  CLOB,\n" +
+                 "    date_col  DATE,\n" +
+                 "    decimal_col  DECIMAL(5,2),\n" +
+                 "    real_col  REAL,\n" +
+                 "    double_col  DOUBLE,\n" +
+                 "    int_col  INTEGER,\n" +
+                 "    long_varchar_col  LONG VARCHAR,\n" +
+                 "    long_varchar_for_bit_data_col  LONG VARCHAR FOR BIT DATA,\n" +
+                 "    numeric_col  NUMERIC(5,2), \n" +
+                 "    smallint_col  SMALLINT,\n" +
+                 "    time_col  TIME,\n" +
+                 "    timestamp_col  TIMESTAMP,\n" +
+                 "    varchar_col  VARCHAR(10),\n" +
+                 "    varchar_for_bit_data_col  VARCHAR (10) FOR BIT DATA\n" +
+                 ")\n"
+                 );
+            goodStatement
+                (
+                 conn,
+                 "insert into t_5370\n" +
+                 "(\n" +
+                 "    key_col,\n" +
+                 "    boolean_col,\n" +
+                 "    bigint_col,\n" +
+                 "    blob_col,\n" +
+                 "    char_col,\n" +
+                 "    char_for_bit_data_col,\n" +
+                 "    clob_col,\n" +
+                 "    date_col,\n" +
+                 "    decimal_col,\n" +
+                 "    real_col,\n" +
+                 "    double_col,\n" +
+                 "    int_col,\n" +
+                 "    long_varchar_col,\n" +
+                 "    long_varchar_for_bit_data_col,\n" +
+                 "    numeric_col, \n" +
+                 "    smallint_col,\n" +
+                 "    time_col,\n" +
+                 "    timestamp_col,\n" +
+                 "    varchar_col,\n" +
+                 "    varchar_for_bit_data_col\n" +
+                 ")\n" +
+                 "values\n" +
+                 "(\n" +
+                 "    0,\n" +
+                 "    false,\n" +
+                 "    0,\n" +
+                 "    makeBlob5370(),\n" +
+                 "    '0',\n" +
+                 "    X'DE',\n" +
+                 "    '0',\n" +
+                 "    date('1994-02-23'),\n" +
+                 "    0.00,\n" +
+                 "    0.0,\n" +
+                 "    0.0,\n" +
+                 "    0,\n" +
+                 "    '0',\n" +
+                 "    X'DE',\n" +
+                 "    0.00, \n" +
+                 "    0,\n" +
+                 "    time('15:09:02'),\n" +
+                 "    timestamp('1962-09-23 03:23:34.234'),\n" +
+                 "    '0',\n" +
+                 "    X'DE'\n" +
+                 "),\n" +
+                 "(\n" +
+                 "    1,\n" +
+                 "    true,\n" +
+                 "    1,\n" +
+                 "    makeBlob5370(),\n" +
+                 "    '1',\n" +
+                 "    X'DD',\n" +
+                 "    '1',\n" +
+                 "    date('1994-02-24'),\n" +
+                 "    1.00,\n" +
+                 "    1.0,\n" +
+                 "    1.0,\n" +
+                 "    1,\n" +
+                 "    '1',\n" +
+                 "    X'DE',\n" +
+                 "    1.00, \n" +
+                 "    1,\n" +
+                 "    time('15:09:03'),\n" +
+                 "    timestamp('1963-09-23 03:23:34.234'),\n" +
+                 "    '1',\n" +
+                 "    X'DD'\n" +
+                 "),\n" +
+                 "(\n" +
+                 "    2,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null,\n" +
+                 "    null\n" +
+                 ")\n"
+                 );
+        }
     }
 
     ///////////////////////////////////////////////////////////////////////////////////
@@ -778,6 +955,110 @@ public class RestrictedVTITest  extends 
         JDBC.assertUnorderedResultSet(rs, expectedRows);
     }
 
+    /**
+     * Verify that Restriction.toSQL() returns usable SQL for all of the
+     * comparable types.
+     */
+    public void test_11_5370() throws Exception
+    {
+        Connection conn = getConnection();
+
+        // if this fails, then we need to add a new data type to this test
+        vetDatatypeCount( conn, 22 );
+        
+        // comparable types
+        vet5370positive( conn, "BOOLEAN_COL", "false", "false" );
+        vet5370positive( conn, "BIGINT_COL", "0", "0" );
+        vet5370positive( conn, "CHAR_COL", "'0'", "0         " );
+        vet5370positive( conn, "CHAR_FOR_BIT_DATA_COL", "X'de'", "de202020202020202020" );
+        vet5370positive( conn, "DATE_COL", "DATE('1994-02-23')", "1994-02-23" );
+        vet5370positive( conn, "DECIMAL_COL", "0.00", "0.00" );
+        vet5370positive( conn, "REAL_COL", "0.0", "0.0" );
+        vet5370positive( conn, "DOUBLE_COL", "0.0", "0.0" );
+        vet5370positive( conn, "INT_COL", "0", "0" );
+        vet5370positive( conn, "NUMERIC_COL", "0.00", "0.00" );
+        vet5370positive( conn, "SMALLINT_COL", "0", "0" );
+        vet5370positive( conn, "TIME_COL", "TIME('15:09:02')", "15:09:02" );
+        vet5370positive( conn, "TIMESTAMP_COL", "TIMESTAMP('1962-09-23 03:23:34.234')", "1962-09-23 03:23:34.234" );
+        vet5370positive( conn, "VARCHAR_COL", "'0'", "0" );
+        vet5370positive( conn, "VARCHAR_FOR_BIT_DATA_COL", "X'de'", "de" );
+
+        //
+        // The following all fail. If these comparisons start working, then this
+        // test should be revisited to make sure that Restriction.toSQL() handles
+        // the types which used to not be comparable.
+        //
+        vet5370negative( "BLOB_COL", "makeBlob5370()" );
+        vet5370negative( "CLOB_COL", "'0'" );
+        vet5370negative( "LONG_VARCHAR_COL", "'0'" );
+        vet5370negative( "LONG_VARCHAR_FOR_BIT_DATA_COL", "X'de'" );
+    }
+    private void    vet5370positive
+        (
+         Connection conn,
+         String columnName,
+         String columnValue,
+         String expectedValue
+         )
+        throws Exception
+    {
+        assertResults
+            (
+             conn,
+             "select " + columnName + " from table( restricted5370( 'APP', 'T_5370' ) ) s\n" +
+             "where " + columnName + " = " + columnValue,
+             new String[][] { new String[] { expectedValue } },
+             false
+             );
+
+        assertResults
+            (
+             conn,
+             "values( lastQuery5370() )",
+             new String[][]
+             {
+                 new String[]
+                 {
+                     "select " + doubleQuote( columnName ) + "\n" +
+                     "from " + doubleQuote( "APP" ) + "." + doubleQuote( "T_5370" ) + "\n" +
+                     "where " + doubleQuote( columnName ) + " = " + columnValue
+                 }
+             },
+             false
+             );
+    }
+    private static  String  doubleQuote( String text )  { return '"' + text + '"'; }
+    private void    vet5370negative
+        (
+         String columnName,
+         String columnValue
+         )
+        throws Exception
+    {
+        expectCompilationError
+            (
+             "42818",
+             "select " + columnName + " from table( restricted5370( 'APP', 'T_5370' ) ) s\n" +
+             "where " + columnName + " = " + columnValue
+             );
+
+    }
+    private int vetDatatypeCount( Connection conn, int expectedTypeCount ) throws Exception
+    {
+        //
+        // If this fails, it means that we need to add another datatype to
+        //
+        
+        ResultSet rs = conn.getMetaData().getTypeInfo();
+        int actualTypeCount = 0;
+        while ( rs.next() ) { actualTypeCount++; }
+        rs.close();
+
+        assertEquals( expectedTypeCount, actualTypeCount );
+
+        return actualTypeCount;
+    }
+    
     ///////////////////////////////////////////////////////////////////////////////////
     //
     // SQL ROUTINES