cannot use prepared statement with timestamptz

Bug #1896625 reported by Alexander Radzin
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Redshift
New
Undecided
Unassigned

Bug Description

Redshift has 2 timestamp types: timestamp and timestamptz. Type timestamp can be used with prepared statement while attempt to do this with timestamptz throws exception.

The following SQL statement creates table that helps to reproduce the issue:

create table test_time_types (
 id int,
 d date,
 ts timestamp,
 ts_tz TIMESTAMPTZ
)

Here is a minimal java example that can help to reproduce the problem:

public class TryPs {
    public static void main(String[] args) throws SQLException {
        String url = args[0];
        String user = args[1];
        String password = args[2];
        String query = args[3];
        PreparedStatement ps = DriverManager.getConnection(url, user, password).prepareStatement(query);
        ps.setTimestamp(1, new Timestamp(System.currentTimeMillis()));
        ResultSet rs = ps.executeQuery();
        while (rs.next()) {
            System.out.println("column 1 = " + rs.getObject(1));
        }
    }
}

This utility accepts the following CLI arguments: URL, user, password, query.

This query works well: select * from test_time_types where ts<?
The following query does not work: select * from test_time_types where ts_tz<?

Exception in thread "main" java.sql.SQLDataException: [Amazon][JDSI](20320) Data type not supported: 1111
 at com.amazon.redshift.api.PGDataTypeUtilities.createTypeMetadata(PGDataTypeUtilities.java:855)
 at com.amazon.redshift.api.PGDataTypeUtilities.createParameter(PGDataTypeUtilities.java:2053)
 at com.amazon.redshift.client.PGClient.prepareStatement(PGClient.java:1917)
 at com.amazon.redshift.dataengine.PGQueryExecutor.<init>(PGQueryExecutor.java:106)
 at com.amazon.redshift.dataengine.PGDataEngine.prepare(PGDataEngine.java:195)
 at com.amazon.jdbc.common.SPreparedStatement.<init>(Unknown Source)
 at com.amazon.jdbc.jdbc41.S41PreparedStatement.<init>(Unknown Source)
 at com.amazon.jdbc.jdbc42.S42PreparedStatement.<init>(Unknown Source)
 at com.amazon.redshift.core.jdbc42.PGJDBC42PreparedStatement.<init>(PGJDBC42PreparedStatement.java:48)
 at com.amazon.redshift.core.jdbc42.PGJDBC42ObjectFactory.createPreparedStatement(PGJDBC42ObjectFactory.java:122)
 at com.amazon.jdbc.common.SConnection.prepareStatement(Unknown Source)
 at com.amazon.jdbc.common.SConnection.prepareStatement(Unknown Source)
Caused by: com.amazon.support.exceptions.DataException: [Amazon][JDSI](20320) Data type not supported: 1111
 ... 12 more

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.