Skip to content
Permalink
Browse files

0003852: Startup on Postgres no relation for gp_id

  • Loading branch information...
erilong committed Jan 9, 2019
1 parent 48953ca commit 45ef15b93dbee05a6eefc54adf544a8db2b25011
@@ -300,21 +300,15 @@ public static synchronized IDatabasePlatform createNewPlatformInstance(DataSourc
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) {
@@ -326,7 +320,7 @@ private static boolean isGreenplumDatabase(Connection connection) {
} catch (SQLException ex) {
}
}
return isGreenplum;
return greenplumCount > 0;
}

private static boolean isRedshiftDatabase(Connection connection) {
@@ -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) {

0 comments on commit 45ef15b

Please sign in to comment.
You can’t perform that action at this time.