From 538d3ca9742087da65eba3df1ee1e14d740b2c64 Mon Sep 17 00:00:00 2001 From: Eric Long Date: Wed, 9 Jan 2019 14:04:30 -0500 Subject: [PATCH] 0003852: Startup on Postgres no relation for gp_id --- .../platform/JdbcDatabasePlatformFactory.java | 18 ++++++------------ .../platform/greenplum/GreenplumPlatform.java | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/JdbcDatabasePlatformFactory.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/JdbcDatabasePlatformFactory.java index 7640ad8eab..f773c1d8a7 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/JdbcDatabasePlatformFactory.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/JdbcDatabasePlatformFactory.java @@ -295,21 +295,15 @@ public static String[] determineDatabaseNameVersionSubprotocol(DataSource dataSo private static boolean isGreenplumDatabase(Connection connection) { Statement stmt = null; ResultSet rs = null; - String productName = null; - boolean isGreenplum = false; + int greenplumCount = 0; try { stmt = connection.createStatement(); - rs = stmt.executeQuery(GreenplumPlatform.SQL_GET_GREENPLUM_NAME); - while (rs.next()) { - productName = rs.getString(1); - } - if (productName != null && productName.equalsIgnoreCase("Greenplum")) { - isGreenplum = true; + rs = stmt.executeQuery(GreenplumPlatform.SQL_GET_GREENPLUM_COUNT); + if (rs.next()) { + greenplumCount = rs.getInt(1); } } catch (SQLException ex) { - // ignore the exception, if it is caught, then this is most likely - // not - // a greenplum database + throw new RuntimeException(ex); } finally { try { if (rs != null) { @@ -321,7 +315,7 @@ private static boolean isGreenplumDatabase(Connection connection) { } catch (SQLException ex) { } } - return isGreenplum; + return greenplumCount > 0; } private static boolean isRedshiftDatabase(Connection connection) { diff --git a/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/greenplum/GreenplumPlatform.java b/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/greenplum/GreenplumPlatform.java index 5c1c42f72a..782c4846a7 100644 --- a/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/greenplum/GreenplumPlatform.java +++ b/symmetric-jdbc/src/main/java/org/jumpmind/db/platform/greenplum/GreenplumPlatform.java @@ -31,7 +31,7 @@ public class GreenplumPlatform extends PostgreSqlDatabasePlatform { /* PostgreSql can be either PostgreSql or Greenplum. Metadata queries to determine which one */ - public static final String SQL_GET_GREENPLUM_NAME = "select gpname from gp_id"; + public static final String SQL_GET_GREENPLUM_COUNT = "select count(*) from information_schema.tables where table_name = 'gp_id'"; public static final String SQL_GET_GREENPLUM_VERSION = "select productversion from gp_version_at_initdb"; public GreenplumPlatform(DataSource dataSource, SqlTemplateSettings settings) {