Revision: 6293
http://squirrel-sql.svn.sourceforge.net/squirrel-sql/?rev=6293&view=rev
Author: gerdwagner
Date: 2011-06-05 17:39:52 +0000 (Sun, 05 Jun 2011)
Log Message:
-----------
Greenplum plugin, Adam Winn's patch ID 3217167
Modified Paths:
--------------
trunk/sql12/doc/src/main/resources/changes.txt
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactory.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactoryImpl.java
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/IDialectFactory.java
Added Paths:
-----------
trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/GreenplumDialectExt.java
trunk/sql12/plugins/greenplum/
trunk/sql12/plugins/greenplum/src/
trunk/sql12/plugins/greenplum/src/main/
trunk/sql12/plugins/greenplum/src/main/java/
trunk/sql12/plugins/greenplum/src/main/java/net/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/GreenplumPlugin.java
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableInodeExpanderFactory.java
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableParentExpander.java
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/tab/
trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/tab/GreenplumExternalTableDetailsTab.java
trunk/sql12/plugins/greenplum/src/main/resources/
trunk/sql12/plugins/greenplum/src/main/resources/doc/
trunk/sql12/plugins/greenplum/src/main/resources/doc/changes.txt
trunk/sql12/plugins/greenplum/src/main/resources/doc/licence.txt
trunk/sql12/plugins/greenplum/src/main/resources/net/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/plugins/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/plugins/greenplum/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/plugins/greenplum/I18NStrings.properties
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/plugins/greenplum/tab/
trunk/sql12/plugins/greenplum/src/main/resources/net/sourceforge/squirrel_sql/plugins/greenplum/tab/I18NStrings.properties
Modified: trunk/sql12/doc/src/main/resources/changes.txt
===================================================================
--- trunk/sql12/doc/src/main/resources/changes.txt 2011-06-05 13:28:35 UTC (rev 6292)
+++ trunk/sql12/doc/src/main/resources/changes.txt 2011-06-05 17:39:52 UTC (rev 6293)
@@ -7,6 +7,10 @@
Enhancements:
+New Plugin: Greenplum DB Plugin
+ New Plugin for the Greenplum DB. Thanks to Adam Winn for the patch (Patch ID 3217167)
+
+
Feature Request 1744964: Copy text from the SQL editor panel as rich text.
This functionality is available via the pop-up menu and the tools pop-up. To use this, the RSyntax editor (Syntax Plugin) must be activated.
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactory.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactory.java 2011-06-05 13:28:35 UTC (rev 6292)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactory.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -93,6 +93,8 @@
private static final NetezzaDialextExt netezzaDialect = new NetezzaDialextExt();
+ private static final GreenplumDialectExt greenplumDialect = new GreenplumDialectExt();
+
private static final OracleDialectExt oracle9iDialect = new OracleDialectExt();
private static final PointbaseDialectExt pointbaseDialect = new PointbaseDialectExt();
@@ -150,6 +152,7 @@
dbNameDialectMap.put(mckoiDialect.getDisplayName(), mckoiDialect);
dbNameDialectMap.put(mysqlDialect.getDisplayName(), mysqlDialect);
dbNameDialectMap.put(netezzaDialect.getDisplayName(), netezzaDialect);
+ dbNameDialectMap.put(greenplumDialect.getDisplayName(), greenplumDialect);
dbNameDialectMap.put(oracle9iDialect.getDisplayName(), oracle9iDialect);
dbNameDialectMap.put(pointbaseDialect.getDisplayName(), pointbaseDialect);
dbNameDialectMap.put(postgreSQLDialect.getDisplayName(), postgreSQLDialect);
@@ -250,6 +253,11 @@
return dialectSupportsProduct(md, netezzaDialect);
}
+ public static boolean isGreenplum(ISQLDatabaseMetaData md)
+ {
+ return dialectSupportsProduct(md, greenplumDialect);
+ }
+
public static boolean isOracle(ISQLDatabaseMetaData md)
{
return dialectSupportsProduct(md, oracle9iDialect);
@@ -374,6 +382,7 @@
if (isMySQL5(md)) { return mysql5Dialect; }
if (isMSSQLServer(md)) { return sqlserverDialect; }
if (isNetezza(md)) { return netezzaDialect; }
+ if (isGreenplum(md)) { return greenplumDialect; }
if (isOracle(md)) { return oracle9iDialect; }
if (isPointbase(md)) { return pointbaseDialect; }
if (isPostgreSQL(md)) { return postgreSQLDialect; }
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactoryImpl.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactoryImpl.java 2011-06-05 13:28:35 UTC (rev 6292)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/DialectFactoryImpl.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -207,6 +207,15 @@
/**
* @see net.sourceforge.squirrel_sql.fw.dialects.IDialectFactory#
+ * isGreenplum(net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData)
+ */
+ public boolean isGreenplum(ISQLDatabaseMetaData md)
+ {
+ return DialectFactory.isGreenplum(md);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.IDialectFactory#
* isOracle(net.sourceforge.squirrel_sql.fw.sql.ISQLDatabaseMetaData)
*/
public boolean isOracle(ISQLDatabaseMetaData md)
Added: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/GreenplumDialectExt.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/GreenplumDialectExt.java (rev 0)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/GreenplumDialectExt.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,767 @@
+/*
+ * Copyright (C) 2011 Adam Winn
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sourceforge.squirrel_sql.fw.dialects;
+
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.ADD_COLUMN_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.COLUMN_DROP_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.COLUMN_NULL_ALTER_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.COLUMN_TYPE_ALTER_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.CREATE_INDEX_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.DROP_INDEX_TYPE;
+import static net.sourceforge.squirrel_sql.fw.dialects.DialectUtils.getUnsupportedMessage;
+
+import java.sql.Types;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.fw.sql.ITableInfo;
+import net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo;
+
+import org.antlr.stringtemplate.StringTemplate;
+import org.hibernate.HibernateException;
+
+/**
+ * Dialect for the Greenplum NPS database server.
+ */
+public class GreenplumDialectExt extends CommonHibernateDialect
+{
+
+ // Note that Greenplum 4.6 doesn't have support for LOB data types. Under the hood, it appears to use
+ // PostgreSQL, but with some limitations.
+ private class GreenplumDialectHelper extends org.hibernate.dialect.PostgreSQLDialect
+ {
+ public GreenplumDialectHelper()
+ {
+ super();
+ registerColumnType(Types.BIGINT, "bigint");
+ registerColumnType(Types.BIT, "bool");
+ registerColumnType(Types.BOOLEAN, "bool");
+ registerColumnType(Types.CHAR, 64000, "char($l)");
+ registerColumnType(Types.CHAR, "char(64000)");
+ // Greenplum 4.6 doesn't support text or any large character object data type
+ // registerColumnType(Types.CLOB, "text");
+ registerColumnType(Types.DATE, "date");
+ registerColumnType(Types.DECIMAL, "decimal($p,2)");
+ registerColumnType(Types.DOUBLE, "double precision");
+ registerColumnType(Types.FLOAT, 15, "float($p)");
+ registerColumnType(Types.FLOAT, "float(15)");
+ registerColumnType(Types.INTEGER, "int");
+ // Greenplum 4.6 doesn't appear to support bytea or any binary type.
+ // registerColumnType(Types.LONGVARBINARY, "bytea");
+ registerColumnType(Types.LONGVARCHAR, "char(64000)");
+ registerColumnType(Types.NUMERIC, "numeric($p,$s)");
+ registerColumnType(Types.REAL, "real");
+ registerColumnType(Types.SMALLINT, "smallint");
+ registerColumnType(Types.TIME, "time");
+ registerColumnType(Types.TIMESTAMP, "timestamp");
+ registerColumnType(Types.TINYINT, "byteint");
+ // Greenplum 4.6 doesn't appear to support bytea or any binary type.
+ // registerColumnType(Types.VARBINARY, "bytea");
+ registerColumnType(Types.VARCHAR, 64000, "varchar($l)");
+ registerColumnType(Types.VARCHAR, "varchar(64000)");
+ }
+ }
+
+ /** extended hibernate dialect used in this wrapper */
+ private GreenplumDialectHelper _dialect = new GreenplumDialectHelper();
+
+ private String cascadeClause;
+
+ @Override
+ public DialectType getDialectType()
+ {
+ return DialectType.NETEZZA;
+ }
+
+ @Override
+ public String getDisplayName()
+ {
+ return "Greenplum";
+ }
+
+ @Override
+ public String getDropSequenceSQL(String sequenceName, boolean cascade, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ // "DROP SEQUENCE $sequenceName$ $cascade$";
+ StringTemplate st = new StringTemplate(ST_DROP_SEQUENCE_STYLE_ONE);
+
+ HashMap<String, String> valuesMap = DialectUtils.getValuesMap(ST_SEQUENCE_NAME_KEY, sequenceName);
+
+ return DialectUtils.bindTemplateAttributes(this, st, valuesMap, qualifier, prefs);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getMaxPrecision(int)
+ */
+ @Override
+ public int getMaxPrecision(int dataType)
+ {
+ return 38;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getMaxScale(int)
+ */
+ @Override
+ public int getMaxScale(int dataType)
+ {
+ // user guide says scale can be 0 to as large as the precision. It cannot be
+ // greater than the precision.
+ return 38;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getPrecisionDigits(int, int)
+ */
+ @Override
+ public int getPrecisionDigits(int columnSize, int dataType)
+ {
+ // Greenplum correctly reports the size of the column in digits.
+ return columnSize;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getTypeName(int, int, int, int)
+ */
+ @Override
+ public String getTypeName(int code, int length, int precision, int scale) throws HibernateException
+ {
+ return _dialect.getTypeName(code, length, precision, scale);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAccessMethods()
+ */
+ @Override
+ public boolean supportsAccessMethods()
+ {
+ // Access methods have to do with indexes. Since Greenplum disallows users from creating or changing
+ // indexes, this is unsupported
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAddColumn()
+ */
+ @Override
+ public boolean supportsAddColumn()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAddForeignKeyConstraint()
+ */
+ @Override
+ public boolean supportsAddForeignKeyConstraint()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAddUniqueConstraint()
+ */
+ @Override
+ public boolean supportsAddUniqueConstraint()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAlterColumnDefault()
+ */
+ @Override
+ public boolean supportsAlterColumnDefault()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAlterColumnNull()
+ */
+ @Override
+ public boolean supportsAlterColumnNull()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAlterColumnType()
+ */
+ @Override
+ public boolean supportsAlterColumnType()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAlterSequence()
+ */
+ @Override
+ public boolean supportsAlterSequence()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsAutoIncrement()
+ */
+ @Override
+ public boolean supportsAutoIncrement()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCheckOptionsForViews()
+ */
+ @Override
+ public boolean supportsCheckOptionsForViews()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsColumnComment()
+ */
+ @Override
+ public boolean supportsColumnComment()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCorrelatedSubQuery()
+ */
+ @Override
+ public boolean supportsCorrelatedSubQuery()
+ {
+ // Although Greenplum claims to support correlated sub-queries, the type of sub-query we want is not
+ // supported:
+ // update TOTABLE t set t.MYDESC =
+ // (
+ // select
+ // f.MYDESC
+ // from FROMTABLE f
+ // where f.myid = t.myid
+ // )
+ // Furthermore, the only refactoring that currently uses this is MergeTable which also requires
+ // add column support, which Greenplum also doesn't seem to have.
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCreateIndex()
+ */
+ @Override
+ public boolean supportsCreateIndex()
+ {
+ // Since Greenplum disallows users from creating or changing indexes, this is unsupported
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCreateSequence()
+ */
+ @Override
+ public boolean supportsCreateSequence()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCreateTable()
+ */
+ @Override
+ public boolean supportsCreateTable()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsCreateView()
+ */
+ @Override
+ public boolean supportsCreateView()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsDropColumn()
+ */
+ @Override
+ public boolean supportsDropColumn()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsDropConstraint()
+ */
+ @Override
+ public boolean supportsDropConstraint()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsDropIndex()
+ */
+ @Override
+ public boolean supportsDropIndex()
+ {
+ // Since Greenplum disallows users from creating or changing indexes, this is unsupported
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsDropSequence()
+ */
+ @Override
+ public boolean supportsDropSequence()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsDropView()
+ */
+ @Override
+ public boolean supportsDropView()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsEmptyTables()
+ */
+ @Override
+ public boolean supportsEmptyTables()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsIndexes()
+ */
+ @Override
+ public boolean supportsIndexes()
+ {
+ // Since Greenplum disallows users from creating or changing indexes, this is unsupported
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsInsertInto()
+ */
+ @Override
+ public boolean supportsInsertInto()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsMultipleRowInserts()
+ */
+ @Override
+ public boolean supportsMultipleRowInserts()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsProduct(java.lang.String,
+ * java.lang.String)
+ */
+ @Override
+ public boolean supportsProduct(String databaseProductName, String databaseProductVersion)
+ {
+ if (databaseProductName == null) { return false; }
+ if (databaseProductName.trim().startsWith("PostgreSQL"))
+ {
+ // We don't yet have the need to discriminate by version.
+ return true;
+ }
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsRenameColumn()
+ */
+ @Override
+ public boolean supportsRenameColumn()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsRenameTable()
+ */
+ @Override
+ public boolean supportsRenameTable()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsRenameView()
+ */
+ @Override
+ public boolean supportsRenameView()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsSchemasInTableDefinition()
+ */
+ @Override
+ public boolean supportsSchemasInTableDefinition()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsSequence()
+ */
+ @Override
+ public boolean supportsSequence()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsSequenceInformation()
+ */
+ @Override
+ public boolean supportsSequenceInformation()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsTablespace()
+ */
+ @Override
+ public boolean supportsTablespace()
+ {
+ return false;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsUpdate()
+ */
+ @Override
+ public boolean supportsUpdate()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#supportsViewDefinition()
+ */
+ @Override
+ public boolean supportsViewDefinition()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getTableDropSQL(net.sourceforge.squirrel_sql.fw.sql.ITableInfo,
+ * boolean, boolean, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public List<String> getTableDropSQL(ITableInfo tableInfo, boolean cascadeConstraints,
+ boolean isMaterializedView, DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ final boolean supportsCascade = false;
+ final boolean supportsMatViews = true;
+ return DialectUtils.getTableDropSQL(tableInfo, supportsCascade, cascadeConstraints, supportsMatViews,
+ cascadeClause, isMaterializedView, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getColumnDropSQL(java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getColumnDropSQL(String tableName, String columnName, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs) throws UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, COLUMN_DROP_TYPE));
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getCreateIndexSQL(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String[], boolean, java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getCreateIndexSQL(String indexName, String tableName, String accessMethod, String[] columns,
+ boolean unique, String tablespace, String constraints, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, CREATE_INDEX_TYPE));
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getDropIndexSQL(java.lang.String,
+ * java.lang.String, boolean, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getDropIndexSQL(String tableName, String indexName, boolean cascade,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, DROP_INDEX_TYPE));
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getAddColumnSQL(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getAddColumnSQL(TableColumnInfo column, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, ADD_COLUMN_TYPE));
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getColumnNullableAlterSQL(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getColumnNullableAlterSQL(TableColumnInfo info, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, COLUMN_NULL_ALTER_TYPE));
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getColumnTypeAlterSQL(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public List<String> getColumnTypeAlterSQL(TableColumnInfo from, TableColumnInfo to,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs) throws UnsupportedOperationException
+ {
+ throw new UnsupportedOperationException(getUnsupportedMessage(this, COLUMN_TYPE_ALTER_TYPE));
+
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getColumnDefaultAlterSQL(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getColumnDefaultAlterSQL(TableColumnInfo info, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ String alterClause = DialectUtils.ALTER_COLUMN_CLAUSE;
+ boolean specifyType = false;
+ String defaultClause = DialectUtils.SET_DEFAULT_CLAUSE;
+ return DialectUtils.getColumnDefaultAlterSQL(this, info, alterClause, specifyType, defaultClause,
+ qualifier, prefs);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getColumnNameAlterSQL(net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getColumnNameAlterSQL(TableColumnInfo from, TableColumnInfo to,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ String alterClause = DialectUtils.RENAME_COLUMN_CLAUSE;
+ String renameToClause = DialectUtils.TO_CLAUSE;
+ return DialectUtils.getColumnNameAlterSQL(from, to, alterClause, renameToClause, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getRenameTableSQL(java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getRenameTableSQL(String oldTableName, String newTableName,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ return DialectUtils.getRenameTableSQL(oldTableName, newTableName, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getCreateViewSQL(java.lang.String,
+ * java.lang.String, java.lang.String,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getCreateViewSQL(String viewName, String definition, String checkOption,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ return DialectUtils.getCreateViewSQL(viewName, definition, checkOption, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getRenameViewSQL(java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getRenameViewSQL(String oldViewName, String newViewName,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+
+ String commandPrefix = DialectUtils.ALTER_VIEW_CLAUSE;
+ String renameClause = DialectUtils.RENAME_TO_CLAUSE;
+ return new String[] { DialectUtils.getRenameViewSQL(commandPrefix, renameClause, oldViewName,
+ newViewName, qualifier, prefs, this) };
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getViewDefinitionSQL(java.lang.String,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getViewDefinitionSQL(String viewName, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ return "SELECT 'create or replace view ' || v.VIEWNAME || ' as ' || "
+ + "v.definition FROM _v_view v, _v_objs_owned o " + "where v.objid = o.objid "
+ + "and o.DATABASE = '" + qualifier.getCatalog() + "' " + "and v.VIEWNAME = '" + viewName + "'";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getCreateSequenceSQL(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getCreateSequenceSQL(String sequenceName, String increment, String minimum, String maximum,
+ String start, String cache, boolean cycle, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ final String minimumClause = DialectUtils.MINVALUE_CLAUSE;
+ final String maximumClause = DialectUtils.MAXVALUE_CLAUSE;
+
+ String cycleClause = DialectUtils.CYCLE_CLAUSE;
+ if (!cycle)
+ {
+ cycleClause = DialectUtils.NO_CYCLE_CLAUSE;
+ }
+
+ return DialectUtils.getCreateSequenceSQL(sequenceName, increment, minimumClause, minimum,
+ maximumClause, maximum, start, cache, cycleClause, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getAlterSequenceSQL(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.lang.String, boolean,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getAlterSequenceSQL(String sequenceName, String increment, String minimum, String maximum,
+ String restart, String cache, boolean cycle, DatabaseObjectQualifier qualifier,
+ SqlGenerationPreferences prefs)
+ {
+ String cycleClause = DialectUtils.CYCLE_CLAUSE;
+ if (!cycle)
+ {
+ cycleClause = DialectUtils.NO_CYCLE_CLAUSE;
+ }
+
+ return new String[] { DialectUtils.getAlterSequenceSQL(sequenceName, increment, minimum, maximum,
+ restart, cache, cycleClause, qualifier, prefs, this) };
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getSequencePropertyMutability()
+ */
+ @Override
+ public SequencePropertyMutability getSequencePropertyMutability()
+ {
+ SequencePropertyMutability result = new SequencePropertyMutability();
+ result.setCache(false);
+ return result;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getAddForeignKeyConstraintSQL(java.lang.String,
+ * java.lang.String, java.lang.String, java.lang.Boolean, java.lang.Boolean, java.lang.Boolean,
+ * boolean, java.lang.String, java.util.Collection, java.lang.String, java.lang.String,
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getAddForeignKeyConstraintSQL(String localTableName, String refTableName,
+ String constraintName, Boolean deferrable, Boolean initiallyDeferred, Boolean matchFull,
+ boolean autoFKIndex, String fkIndexName, Collection<String[]> localRefColumns, String onUpdateAction,
+ String onDeleteAction, DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ return DialectUtils.getAddForeignKeyConstraintSQL(localTableName, refTableName, constraintName,
+ deferrable, initiallyDeferred, matchFull, autoFKIndex, fkIndexName, localRefColumns, onUpdateAction,
+ onDeleteAction, qualifier, prefs, this);
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getAddUniqueConstraintSQL(java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.sql.TableColumnInfo[],
+ * net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String[] getAddUniqueConstraintSQL(String tableName, String constraintName,
+ TableColumnInfo[] columns, DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ return new String[] { DialectUtils.getAddUniqueConstraintSQL(tableName, constraintName, columns,
+ qualifier, prefs, this) };
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.fw.dialects.CommonHibernateDialect#getDropConstraintSQL(java.lang.String,
+ * java.lang.String, net.sourceforge.squirrel_sql.fw.dialects.DatabaseObjectQualifier,
+ * net.sourceforge.squirrel_sql.fw.dialects.SqlGenerationPreferences)
+ */
+ @Override
+ public String getDropConstraintSQL(String tableName, String constraintName,
+ DatabaseObjectQualifier qualifier, SqlGenerationPreferences prefs)
+ {
+ return DialectUtils.getDropConstraintSQL(tableName, constraintName, qualifier, prefs, this)
+ + " RESTRICT";
+ }
+
+}
Modified: trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/IDialectFactory.java
===================================================================
--- trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/IDialectFactory.java 2011-06-05 13:28:35 UTC (rev 6292)
+++ trunk/sql12/fw/src/main/java/net/sourceforge/squirrel_sql/fw/dialects/IDialectFactory.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -223,6 +223,16 @@
boolean isNetezza(ISQLDatabaseMetaData md);
/**
+ * Returns a boolean value indicating whether or not the specified metadata indicates that it is Greenplum
+ *
+ * @param md
+ * The SQLDatabaseMetaData retrieved from either ISQLConnection.getSQLMetaData() or
+ * ISession.getMetaData()
+ * @return boolean indicating whether or not the specified metadata matches the database type
+ */
+ boolean isGreenplum(ISQLDatabaseMetaData md);
+
+ /**
* Returns a boolean value indicating whether or not the specified metadata indicates that it is Oracle
*
* @param md
Added: trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/GreenplumPlugin.java
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/GreenplumPlugin.java (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/GreenplumPlugin.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,209 @@
+/*
+ * Copyright (C) 2011 Adam Winn
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+package net.sourceforge.squirrel_sql.plugins.greenplum;
+
+import net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin;
+import net.sourceforge.squirrel_sql.client.plugin.PluginException;
+import net.sourceforge.squirrel_sql.client.plugin.PluginQueryTokenizerPreferencesManager;
+import net.sourceforge.squirrel_sql.client.plugin.PluginSessionCallback;
+import net.sourceforge.squirrel_sql.client.plugin.gui.PluginGlobalPreferencesTab;
+import net.sourceforge.squirrel_sql.client.plugin.gui.PluginQueryTokenizerPreferencesPanel;
+import net.sourceforge.squirrel_sql.client.preferences.IGlobalPreferencesPanel;
+import net.sourceforge.squirrel_sql.client.session.IObjectTreeAPI;
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.expanders.SchemaExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.DatabaseObjectInfoTab;
+import net.sourceforge.squirrel_sql.fw.dialects.DialectFactory;
+import net.sourceforge.squirrel_sql.fw.gui.GUIUtils;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+import net.sourceforge.squirrel_sql.plugins.greenplum.exp.GreenplumExtTableInodeExpanderFactory;
+import net.sourceforge.squirrel_sql.plugins.greenplum.tab.GreenplumExternalTableDetailsTab;
+
+/**
+ * The main controller class for the Greenplum plugin.
+ */
+public class GreenplumPlugin extends DefaultSessionPlugin
+{
+
+ /**
+ * Internationalized strings for this class.
+ */
+ private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(GreenplumPlugin.class);
+
+ private static ILogger s_log = LoggerController.createLogger(GreenplumPlugin.class);
+
+ /** manages our query tokenizing preferences */
+ private PluginQueryTokenizerPreferencesManager _prefsManager = null;
+
+ static interface i18n
+ {
+ // i18n[GreenplumPlugin.prefsHint=Preferences for Greenplum]
+ String PREFS_HINT = s_stringMgr.getString("GreenplumPlugin.prefsHint");
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getAuthor()
+ */
+ @Override
+ public String getAuthor()
+ {
+ return "Adam Winn";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getDescriptiveName()
+ */
+ @Override
+ public String getDescriptiveName()
+ {
+ return "Greenplum External Tables Plugin";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getInternalName()
+ */
+ @Override
+ public String getInternalName()
+ {
+ return "greenplum";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.IPlugin#getVersion()
+ */
+ @Override
+ public String getVersion()
+ {
+ return "0.01";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#getChangeLogFileName()
+ */
+ @Override
+ public String getChangeLogFileName()
+ {
+ return "changes.txt";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#getHelpFileName()
+ */
+ @Override
+ public String getHelpFileName()
+ {
+ return ""; //"readme.html";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#getLicenceFileName()
+ */
+ @Override
+ public String getLicenceFileName()
+ {
+ return "licence.txt";
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin#allowsSessionStartedInBackground()
+ */
+ @Override
+ public boolean allowsSessionStartedInBackground()
+ {
+ return true;
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultSessionPlugin#isPluginSession(net.sourceforge.squirrel_sql.client.session.ISession)
+ */
+ @Override
+ protected boolean isPluginSession(ISession session)
+ {
+ return DialectFactory.isGreenplum(session.getMetaData());
+ }
+
+ /**
+ * Create panel for the Global Properties dialog.
+ *
+ * @return properties panel.
+ */
+ public IGlobalPreferencesPanel[] getGlobalPreferencePanels()
+ {
+ PluginQueryTokenizerPreferencesPanel _prefsPanel = new PluginQueryTokenizerPreferencesPanel(_prefsManager, "Greenplum");
+
+ PluginGlobalPreferencesTab tab = new PluginGlobalPreferencesTab(_prefsPanel);
+
+ tab.setHint(i18n.PREFS_HINT);
+ tab.setTitle("Greenplum");
+
+ return new IGlobalPreferencesPanel[] { tab };
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.DefaultPlugin#initialize()
+ */
+ @Override
+ public void initialize() throws PluginException
+ {
+ _prefsManager = new PluginQueryTokenizerPreferencesManager();
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.plugin.ISessionPlugin#sessionStarted(net.sourceforge.squirrel_sql.client.session.ISession)
+ */
+ @Override
+ public PluginSessionCallback sessionStarted(final ISession session)
+ {
+ if(!DialectFactory.isGreenplum(session.getMetaData()))
+ {
+ return null;
+ }
+
+ GUIUtils.processOnSwingEventThread(new Runnable()
+ {
+
+ @Override
+ public void run()
+ {
+ updateObjectTree(session.getObjectTreeAPIOfActiveSessionWindow());
+ }
+
+ });
+
+ return null;
+ }
+
+ private void updateObjectTree(final IObjectTreeAPI objTree)
+ {
+ // ////// Object Tree Expanders ////////
+
+ // Schema Expander - external tables
+ objTree.addExpander(DatabaseObjectType.SCHEMA, new SchemaExpander(new GreenplumExtTableInodeExpanderFactory(), DatabaseObjectType.TABLE_TYPE_DBO));
+
+ objTree.addDetailTab(DatabaseObjectType.TABLE_TYPE_DBO, new GreenplumExternalTableDetailsTab());
+ }
+
+
+}
Added: trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableInodeExpanderFactory.java
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableInodeExpanderFactory.java (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableInodeExpanderFactory.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 Adam Winn
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+package net.sourceforge.squirrel_sql.plugins.greenplum.exp;
+
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory;
+import net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType;
+
+/**
+ * Implementation of INodeExpanderFactory for Greenplum external tables
+ *
+ */
+public class GreenplumExtTableInodeExpanderFactory implements INodeExpanderFactory
+{
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory#createExpander(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
+ */
+ public INodeExpander createExpander(DatabaseObjectType type)
+ {
+ return new GreenplumExtTableParentExpander();
+ }
+
+ /**
+ * @see net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpanderFactory#getParentLabelForType(net.sourceforge.squirrel_sql.fw.sql.DatabaseObjectType)
+ */
+ public String getParentLabelForType(DatabaseObjectType type)
+ {
+ return "EXTERNAL TABLE";
+ }
+
+}
Added: trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableParentExpander.java
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableParentExpander.java (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/exp/GreenplumExtTableParentExpander.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,111 @@
+package net.sourceforge.squirrel_sql.plugins.greenplum.exp;
+
+/*
+ * Copyright (C) 2011 Adam Winn
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.INodeExpander;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.ObjectTreeNode;
+import net.sourceforge.squirrel_sql.client.session.schemainfo.ObjFilterMatcher;
+import net.sourceforge.squirrel_sql.fw.sql.*;
+
+/**
+ * This class handles the expanding of the "External Table" node. It will give a list of all the External
+ * Tables available in the schema.
+ */
+public class GreenplumExtTableParentExpander implements INodeExpander
+{
+ /**
+ * Default ctor.
+ */
+ public GreenplumExtTableParentExpander()
+ {
+ super();
+ }
+
+ /** SQL used to load external tables */
+ private static final String SQL =
+ "SELECT c.relname " +
+ " FROM pg_class c " +
+ " LEFT OUTER JOIN pg_namespace nspace ON (nspace.oid=c.relnamespace) " +
+ " LEFT OUTER JOIN pg_exttable ext ON (ext.reloid=c.oid) " +
+ " LEFT OUTER JOIN pg_authid auth ON (auth.oid=c.relowner) " +
+ " WHERE (c.relkind = 'x' OR (c.relkind = 'r' AND c.relstorage = 'x')) " +
+ " AND nspname = ? " +
+ //" AND rolname = ? " +
+ //" AND dbname = ? " +
+ " ORDER BY relname ";
+
+ /*
+ * Create the child nodes for the passed parent node and return them. Note that this method should
+ * <B>not</B> actually add the child nodes to the parent node as this is taken care of in the caller.
+ *
+ * @param session
+ * Current session.
+ * @param node
+ * Node to be expanded.
+ *
+ * @return A list of <TT>ObjectTreeNode</TT> objects representing the child nodes for the passed node.
+ */
+ public List<ObjectTreeNode> createChildren(ISession session, ObjectTreeNode parentNode)throws SQLException
+ {
+ final List<ObjectTreeNode> childNodes = new ArrayList<ObjectTreeNode>();
+ final IDatabaseObjectInfo parentDbinfo = parentNode.getDatabaseObjectInfo();
+ final ISQLConnection conn = session.getSQLConnection();
+ final SQLDatabaseMetaData md = session.getSQLConnection().getSQLMetaData();
+ final String catalogName = parentDbinfo.getCatalogName();
+ final String schemaName = parentDbinfo.getSchemaName();
+ final ObjFilterMatcher filterMatcher = new ObjFilterMatcher(session.getProperties());
+
+ PreparedStatement pstmt = null;
+ ResultSet rs = null;
+ try
+ {
+ pstmt = conn.prepareStatement(SQL);
+
+ pstmt.setString(1, schemaName);
+
+ //I dont know how to get the user and db_name
+ //pstmt.setString(2, "gpadmin");
+ //pstmt.setString(3, "db_name");
+
+ rs = pstmt.executeQuery();
+
+ while(rs.next())
+ {
+ IDatabaseObjectInfo si = new DatabaseObjectInfo(catalogName, schemaName, rs.getString(1), DatabaseObjectType.TABLE_TYPE_DBO, md);
+
+ if(filterMatcher.matches(si.getSimpleName()))
+ {
+ childNodes.add(new ObjectTreeNode(session, si));
+ }
+ }
+ }
+ finally
+ {
+ SQLUtilities.closeResultSet(rs, true);
+ }
+ return childNodes;
+ }
+}
Added: trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/tab/GreenplumExternalTableDetailsTab.java
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/tab/GreenplumExternalTableDetailsTab.java (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/java/net/sourceforge/squirrel_sql/plugins/greenplum/tab/GreenplumExternalTableDetailsTab.java 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,103 @@
+package net.sourceforge.squirrel_sql.plugins.greenplum.tab;
+
+/*
+ * Copyright (C) 2011 Adam Winn
+ *
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+import java.sql.PreparedStatement;
+import java.sql.SQLException;
+
+import net.sourceforge.squirrel_sql.client.session.ISession;
+import net.sourceforge.squirrel_sql.client.session.mainpanel.objecttree.tabs.BasePreparedStatementTab;
+import net.sourceforge.squirrel_sql.fw.sql.IDatabaseObjectInfo;
+import net.sourceforge.squirrel_sql.fw.util.StringManager;
+import net.sourceforge.squirrel_sql.fw.util.StringManagerFactory;
+import net.sourceforge.squirrel_sql.fw.util.log.ILogger;
+import net.sourceforge.squirrel_sql.fw.util.log.LoggerController;
+
+/**
+ * This class will display the details for a Greenplum external table.
+ */
+public class GreenplumExternalTableDetailsTab extends BasePreparedStatementTab
+{
+ private static final StringManager s_stringMgr = StringManagerFactory.getStringManager(GreenplumExternalTableDetailsTab.class);
+
+ private static ILogger s_log = LoggerController.createLogger(GreenplumExternalTableDetailsTab.class);
+
+ /**
+ * This interface defines locale specific strings. This should be replaced with a property file.
+ */
+ private interface i18n
+ {
+ // i18n[GreenplumExternalTableDetailsTab.title=External Table Details]
+ String TITLE = s_stringMgr.getString("ExternalTableDetailsTab.title");
+
+ // i18n[GreenplumExternalTableDetailsTab.hint=Display external table details]
+ String HINT = s_stringMgr.getString("ExternalTableDetailsTab.hint");
+ }
+
+ /** SQL that retrieves the data. */
+ private static final String SQL =
+ "SELECT " +
+ " nspace.nspname as schema, "+
+ " class.relname as external_table_name, "+
+ " auth.rolname as owner, "+
+ " array_to_string(ARRAY(SELECT att.attname FROM pg_class class LEFT OUTER JOIN pg_attribute att ON (att.attrelid=class.oid) WHERE attstattarget = -1 and relname = ?), ', ') as column_names, "+
+ " array_to_string(class.relacl, ', ') as permissions, "+
+ " array_to_string(ext.location, ', ') as file_location, " +
+ " ext.fmtopts as options, " +
+ " ext.command as command, " +
+ " ext.rejectlimit as reject_limit, " +
+ " ext.rejectlimittype as reject_limit_type, " +
+ " ext.fmterrtbl as error_table " +
+ "FROM pg_class class " +
+ " LEFT OUTER JOIN pg_namespace nspace ON (nspace.oid=class.relnamespace) " +
+ " LEFT OUTER JOIN pg_exttable ext ON (ext.reloid=class.oid) " +
+ " LEFT OUTER JOIN pg_authid auth ON (auth.oid=class.relowner) " +
+ " LEFT OUTER JOIN pg_attribute att ON (att.attrelid=class.oid) " +
+ "WHERE (class.relkind = 'x' OR (class.relkind = 'r' AND class.relstorage = 'x')) " +
+ " AND nspname = ? " +
+ " AND class.relname = ? ";
+ //" AND rolname = ? " +
+ //" AND dbname = ? " +
+
+
+ public GreenplumExternalTableDetailsTab()
+ {
+ super(i18n.TITLE, i18n.HINT, true);
+ }
+
+ protected PreparedStatement createStatement() throws SQLException
+ {
+ //System.out.println(SQL);
+
+ ISession session = getSession();
+ IDatabaseObjectInfo doi = getDatabaseObjectInfo();
+
+ PreparedStatement pstmt = session.getSQLConnection().prepareStatement(SQL);
+ pstmt.setString(1, doi.getSimpleName());
+ pstmt.setString(2, doi.getSchemaName());
+ pstmt.setString(3, doi.getSimpleName());
+
+ //I dont know how to get the user and db_name
+ //pstmt.setString(4, "gpadmin");
+ //pstmt.setString(5, "db_name");
+
+ return pstmt;
+ }
+
+}
Added: trunk/sql12/plugins/greenplum/src/main/resources/doc/changes.txt
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/resources/doc/changes.txt (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/resources/doc/changes.txt 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,7 @@
+Greenplum External Tables Plugin Change Log
+=====================
+
+0.01
+====
+
+- Initial release.
Added: trunk/sql12/plugins/greenplum/src/main/resources/doc/licence.txt
===================================================================
--- trunk/sql12/plugins/greenplum/src/main/resources/doc/licence.txt (rev 0)
+++ trunk/sql12/plugins/greenplum/src/main/resources/doc/licence.txt 2011-06-05 17:39:52 UTC (rev 6293)
@@ -0,0 +1,503 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL. It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+ Preamble
+
+ The licenses for most software are designed to take away your
+freedom to share and change it. By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+ This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it. You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+ When we speak of free software, we are referring to freedom of use,
+not price. Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+ To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights. These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+ For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you. You must make sure that they, too, receive or can get the source
+code. If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it. And you must show them these terms so they know their rights.
+
+ We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+ To protect each distributor, we want to make it very clear that
+there is no warranty for the free library. Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+ Finally, software patents pose a constant threat to the existence of
+any free program. We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder. Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+ Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License. This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License. We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+ When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library. The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom. The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+ We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License. It also provides other free software developers Less
+of an advantage over competing non-free programs. These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries. However, the Lesser license provides advantages in certain
+special circumstances.
+
+ For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard. To achieve this, non-free programs must be
+allowed to use the library. A more frequent case is that a free
+library does the same job as widely used non-free libraries. In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+ In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software. For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+ Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+ The precise terms and conditions for copying, distribution and
+modification follow. Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library". The
+former contains code derived from the lib...
[truncated message content] |