001/*
002// This software is subject to the terms of the Eclipse Public License v1.0
003// Agreement, available at the following URL:
004// http://www.eclipse.org/legal/epl-v10.html.
005// You must accept the terms of that agreement to use this software.
006//
007// Copyright (C) 2013 Pentaho
008// All Rights Reserved.
009*/
010package mondrian.spi.impl;
011
012import mondrian.olap.Util;
013
014import java.sql.Connection;
015import java.sql.SQLException;
016import java.util.List;
017
018/**
019 * User: cboyden
020 * Date: 2/8/13
021 */
022public class RedshiftDialect extends PostgreSqlDialect {
023    /**
024     * Creates a RedshiftDialect.
025     *
026     * @param connection Connection
027     */
028    public RedshiftDialect(Connection connection) throws SQLException {
029        super(connection);
030    }
031
032    public static final JdbcDialectFactory FACTORY =
033        new JdbcDialectFactory(
034            RedshiftDialect.class,
035            DatabaseProduct.POSTGRESQL)
036        {
037            protected boolean acceptsConnection(Connection connection) {
038                return super.acceptsConnection(connection)
039                    && isDatabase(DatabaseProduct.REDSHIFT, connection);
040            }
041        };
042
043    public DatabaseProduct getDatabaseProduct() {
044        return DatabaseProduct.REDSHIFT;
045    }
046
047    @Override
048    public String generateInline(
049        List<String> columnNames,
050        List<String> columnTypes,
051        List<String[]> valueList)
052    {
053        return generateInlineGeneric(
054            columnNames, columnTypes, valueList, null, false);
055    }
056
057    @Override
058    public void quoteStringLiteral(
059        StringBuilder buf,
060        String value)
061    {
062        // '\' to '\\'
063        Util.singleQuoteString(value.replaceAll("\\\\", "\\\\\\\\"), buf);
064    }
065
066    @Override
067    public boolean allowsRegularExpressionInWhereClause() {
068        return false;
069    }
070
071    @Override
072    public String generateRegularExpression(
073        String source,
074        String javaRegExp)
075    {
076        return null;
077    }
078}
079
080// End RedshiftDialect.java