<?xml version="1.0" encoding="UTF-8" ?>
<!--
  ~ Copyright (c) DbVis Software AB. All Rights Reserved.
  -->

<!DOCTYPE DatabaseProfile SYSTEM "dbvis-defs.dtd">

<DatabaseProfile
        desc="Profile for Greenplum"
        minver="9.5"
        extends="generic">

   <!-- =================================================================== -->
   <!-- Definition of initialization commands                               -->
   <!-- =================================================================== -->

   <InitCommands extends="true">

   </InitCommands>

   <!-- =================================================================== -->
   <!-- Definition of the commands -->
   <!-- =================================================================== -->

   <Commands extends="true">

      <Command id="greenplum.getCatalogs">
         <SQL>
            <![CDATA[
select * from pg_catalog.pg_database
            ]]>
         </SQL>
         <ProcessDataSet action="movecolumn" index="datname" value="first"/>
         <ProcessDataSet action="addrow" index="first" value="${#db.loginDatabase}"/>
         <ProcessDataSet action="distinct" index="1"/>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getConnectableDatabases">
         <SQL>
            <![CDATA[
SELECT
    *
FROM
    pg_catalog.pg_database
WHERE
    datallowconn IS true
AND datistemplate IS false
             ]]>
         </SQL>
         <ProcessDataSet action="movecolumn" index="datname" value="first"/>
         <ProcessDataSet action="addrow" index="last" value="${#db.loginDatabase}"/>
         <ProcessDataSet action="distinct" index="1"/>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getSchemas">
         <SQL>
            <![CDATA[
SELECT n.nspname                                         AS "Name",
       r.usename                                         AS "Owner",
       pg_catalog.obj_description(n.oid, 'pg_namespace') AS "Comment"
FROM pg_catalog.pg_namespace n
   LEFT JOIN pg_catalog.pg_user r ON n.nspowner= r.usesysid
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getSchemaNames">
         <SQL>
            <![CDATA[
SELECT n.nspname                                         AS "Name",
       r.usename                                         AS "Owner",
       pg_catalog.obj_description(n.oid, 'pg_namespace') AS "Comment"
FROM pg_catalog.pg_namespace n
   LEFT JOIN pg_catalog.pg_user r ON n.nspowner= r.usesysid
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
         <!--Must have Filter element here since this command is fetched from code-->
         <Filter index="Name" label="Name"/>
      </Command>

      <Command id="greenplum.getTables">
         <SQL>
            <![CDATA[
    SELECT c.relname                                 AS "Name",
       n.nspname                                     AS "Schema",
       pg_get_userbyid(c.relowner)                   AS "Owner",
       t.spcname                                     AS "Tablespace",
       c.relhasindex                                 AS "Has Indexes",
       c.relhasrules                                 AS "Has Rules",
       c.relisshared                                 AS "Is Shared",
       c.relnatts                                    AS "N Cols",
       pg_catalog.obj_description(c.oid, 'pg_class') AS "Comment",
       p.schemaname
FROM   pg_class c
   LEFT JOIN pg_namespace n   ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t  ON t.oid = c.reltablespace
  LEFT OUTER JOIN pg_catalog.pg_partitions p
	on c.relname = p.partitiontablename and n.nspname = p.schemaname
WHERE n.nspname LIKE '${schema}'
AND   c.relname LIKE '${table}'
AND c.relkind in ('r'::"char", 'p'::"char")
AND p.partitiontablename is null
]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getTablePartitions">
         <SQL>
            <![CDATA[
select p.relname                                     AS "Name",
       pn.nspname                                    AS "Schema",
       pg_get_userbyid(p.relowner)                   AS "Owner",
       pt.spcname                                    AS "Tablespace",
       p.relhasindex                                 AS "Has Indexes",
       p.relhasrules                                 AS "Has Rules",
       p.relisshared                                 AS "Is Shared",
       p.relnatts                                    AS "N Cols",
       pg_catalog.obj_description(p.oid, 'pg_class') AS "Comment",
       p.oid,
       c.relname                                     AS "Parent Table",
       n.nspname                                     AS "Parent Table Schema",
       pg_get_userbyid(c.relowner)                   AS "Parent Table Owner"
FROM pg_class c
LEFT JOIN pg_namespace n   ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t  ON t.oid = c.reltablespace
LEFT JOIN pg_depend d ON d.refobjid = c.oid
LEFT JOIN pg_class p ON p.oid = d.objid
LEFT JOIN pg_namespace pn   ON pn.oid = p.relnamespace
LEFT JOIN pg_tablespace pt  ON pt.oid = p.reltablespace
WHERE pn.nspname LIKE '${schema}'
AND c.relname LIKE '${table}'
AND c.relkind in ('r'::"char", 'p'::"char")
AND   p.relkind in ('r'::"char", 'p'::"char")
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="3,1"/>
      </Command>

      <Command id="greenplum.getForeignTables">
         <SQL>
            <![CDATA[
SELECT c.relname                                     AS "Name",
       n.nspname                                     AS "Schema",
       fs.srvname                                    AS "Foreign Server",
       ft.ftoptions                                  AS "Options",
       pg_get_userbyid(c.relowner)                   AS "Owner",
       t.spcname                                     AS "Tablespace",
       c.relhasindex                                 AS "Has Indexes",
       c.relhasrules                                 AS "Has Rules",
       c.relisshared                                 AS "Is Shared",
       c.relnatts                                    AS "N Cols",
       pg_catalog.obj_description(c.oid, 'pg_class') AS "Comment"
FROM   pg_class c
   LEFT JOIN pg_namespace n   ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t  ON t.oid = c.reltablespace
   LEFT JOIN pg_foreign_table ft  ON ft.ftrelid = c.oid
   LEFT JOIN pg_foreign_server fs  ON ft.ftserver = fs.oid
WHERE c.relkind = 'f'::"char"
AND   n.nspname = '${schema}'
AND   c.relname LIKE '%'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getViews">
         <SQL>
            <![CDATA[
SELECT c.relname                                      AS "Name",
       n.nspname                                      AS "Schema",
       pg_get_userbyid(c.relowner)                    AS "Owner",
       t.spcname                                      AS "Tablespace",
       c.relhasindex                                  AS "Has Indexes",
       c.relhasrules                                  AS "Has Rules",
       c.relisshared                                  AS "Is Shared",
       c.relnatts                                     AS "N Cols",
       pg_catalog.obj_description(c.oid, 'pg_class')  AS "Comment"
FROM   pg_class c
   LEFT JOIN pg_namespace n   ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t  ON t.oid = c.reltablespace
WHERE c.relkind = 'v'::"char"
AND   n.nspname LIKE '${schema}'
AND   c.relname LIKE '${table}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getIndexes">
         <SQL>
            <![CDATA[
SELECT i.relname                                             AS "Index Name",
       n.nspname                                             AS "Schema Name",
       c.relname                                             AS "Table Name",
       t.spcname                                             AS "Tablespace",
       x.indisunique                                         AS "Unique",
       x.indisprimary                                        AS "Primary",
       x.indisclustered                                      AS "Clustered",
       x.indnatts                                            AS "N Cols",
       pg_catalog.obj_description(x.indexrelid, 'pg_class')  AS "Comment"
FROM   pg_index x
   JOIN   pg_class c ON c.oid = x.indrelid
   JOIN   pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
WHERE (c.relkind = 'r'::"char" OR c.relkind = 'm')
AND   i.relkind = 'i'::"char"
AND i.relname NOT IN
(
    SELECT
        cr.constraint_name
    FROM
        information_schema.table_constraints cr
    WHERE
        n.nspname = cr.table_schema
    AND c.relname = cr.table_name
)
AND   n.nspname LIKE '${schema}'
AND   c.relname LIKE '${table}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getIndexSource">
         <SQL>
            <![CDATA[
SELECT pg_get_indexdef(i.oid) AS indexdef
FROM   pg_index x JOIN pg_class c ON c.oid = x.indrelid
   JOIN   pg_class i ON i.oid = x.indexrelid
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
   LEFT JOIN pg_tablespace t ON t.oid = i.reltablespace
WHERE c.relkind = 'r'::"char" AND i.relkind = 'i'::"char"
AND   i.relname = '${indexname}' AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
      </Command>

     <!-- Getting functions and procedures. (Functions kind ='f', Procedures kind = 'p'  -->
      <Command id="greenplum.getFunctions">
         <SQL>
            <![CDATA[
SELECT p.proname AS "Function Name",
       n.nspname AS "Schema Name",
      CASE WHEN p.proretset THEN 'setof ' ELSE '' END ||
      pg_catalog.format_type(p.prorettype, NULL) AS "Result data type",
      pg_catalog.oidvectortypes(p.proargtypes) AS "Argument data types",
      r.usename AS "Owner",
      l.lanname AS "Language",
      pg_catalog.obj_description(p.oid, 'pg_proc') AS "Comment"
FROM pg_catalog.pg_proc p
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
   LEFT JOIN pg_catalog.pg_language l ON l.oid = p.prolang
   LEFT JOIN pg_catalog.pg_user r ON r.usesysid = p.proowner
WHERE p.prorettype <> 'pg_catalog.cstring'::pg_catalog.regtype
   AND (p.proargtypes[0] IS NULL
      OR   p.proargtypes[0] <> 'pg_catalog.cstring'::pg_catalog.regtype)
   AND NOT p.proisagg
   AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1,3,4"/>
      </Command>

      <Command id="greenplum.getFunctionSource">
         <SQL>
            <![CDATA[
SELECT p.prosrc as "Source code"
FROM pg_catalog.pg_proc p
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE n.nspname = '${schema}'
AND p.proname = '${funcname}';
            ]]>
         </SQL>
      </Command>
      <!-- Getting RULES. (Table kind ='r', View kind = 'v'  -->
      <Command id="greenplum.getRules">
         <SQL>
            <![CDATA[
SELECT r.rulename AS "Rule Name",
       n.nspname AS "Schema Name",
       c.relname as "Table Name",
       u.usename AS "Owner",
       CASE r.ev_type
         WHEN '1' THEN 'SELECT'
         WHEN '2' THEN 'UPDATE'
         WHEN '3' THEN 'INSERT'
         WHEN '4' THEN 'DELETE'
         ELSE 'UNKNOWN'
       END AS "Rule Event"
FROM pg_rewrite r
  JOIN pg_class c on r.ev_class = c.oid
  LEFT JOIN pg_namespace n on n.oid = c.relnamespace
  LEFT JOIN pg_description d on r.oid = d.objoid
  LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner
  WHERE c.relkind = '${kind}'
  AND n.nspname LIKE '${schema}'
  AND c.relname LIKE '${tableNamePattern}'
           ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,3,1"/>
      </Command>

      <Command id="greenplum.getRuleDdl">
         <SQL>
            <![CDATA[
SELECT definition AS DDL FROM pg_rules
WHERE schemaname='${schemaname}'
AND tablename='${tablename}'
AND rulename='${rulename}'
         ]]>
         </SQL>
      </Command>

      <Command id="greenplum.getSequences">
         <SQL>
            <![CDATA[
SELECT c.relname                                                           AS "Sequence Name",
       n.nspname                                                           AS "Schema Name",
       c.oid                                                               AS "Rel Id",
       (pg_stat_get_blocks_fetched(c.oid) - pg_stat_get_blocks_hit(c.oid)) AS "Blocks Read",
       pg_stat_get_blocks_hit(c.oid)                                       AS "Blocks Hit",
       pg_catalog.obj_description(c.oid, 'pg_class')                       AS "Comment"
FROM   pg_class c
   LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
WHERE c.relkind = 'S'::"char"
AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getSequence">
         <SQL>
               <![CDATA[
SELECT sequence_name AS "Sequence Name",
       last_value    AS "Last Value",
       increment_by  AS "Increment By",
       max_value     AS "Max Value",
       min_value     AS "Min Value",
       cache_value   AS "Cache Value",
       log_cnt       AS "Log Cnt",
       is_cycled     AS "Is Cycled",
       is_called     AS "Is Called"
FROM "${schema}"."${seqname}"
]]>
         </SQL>
      </Command>

      <Command id="greenplum.getDomains">
         <SQL>
            <![CDATA[
SELECT t.typname                                          AS "Domain Name",
       n.nspname                                          AS "Schema Name",
       pg_catalog.format_type(t.typbasetype, t.typtypmod) AS "Type",
       CASE WHEN  t.typdefault IS NOT NULL
          THEN ''||t.typdefault
          ELSE ''
       END                                                AS "Default",
       CASE WHEN t.typnotnull
          THEN 'Yes'
          ELSE 'No'
       END                                                AS "Not null",
       pg_catalog.pg_get_constraintdef(r.oid, true)       AS "Check",
       pg_catalog.obj_description(t.oid, 'pg_type')       AS "Comment"
FROM pg_catalog.pg_type t
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
   LEFT JOIN pg_catalog.pg_constraint r ON t.oid = r.contypid
WHERE t.typtype = 'd' 
AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getAggregates">
         <SQL>
            <![CDATA[
SELECT p.proname AS "Aggregate Name",
       n.nspname as "Schema Name",
   CASE p.proargtypes[0]
      WHEN 'pg_catalog."any"'::pg_catalog.regtype
      THEN CAST('(all types)' AS pg_catalog.text)
      ELSE pg_catalog.oidvectortypes(p.proargtypes)
   END AS "Data Type",
   pg_catalog.obj_description(p.oid, 'pg_proc') AS "Comment"
FROM pg_catalog.pg_proc p
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE p.proisagg
   AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1,2,3"/>
      </Command>

      <Command id="greenplum.getOperators">
         <SQL>
            <![CDATA[
SELECT o.oprname                                                  AS "Operator Name",
       n.nspname                                                  AS "Schema Name",
       CASE WHEN o.oprkind='l'
          THEN NULL
          ELSE pg_catalog.format_type(o.oprleft, NULL)
       END                                                        AS "Left arg type",
       CASE WHEN o.oprkind='r'
          THEN NULL
          ELSE pg_catalog.format_type(o.oprright, NULL)
       END                                                        AS "Right arg type",
       pg_catalog.format_type(o.oprresult, NULL)                  AS "Result type",
       coalesce(pg_catalog.obj_description(o.oid, 'pg_operator'),
                pg_catalog.obj_description(o.oprcode, 'pg_proc')) AS "Comment"
FROM pg_catalog.pg_operator o
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = o.oprnamespace
WHERE n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1,3,4"/>
      </Command>

      <Command id="greenplum.getTypes">
         <SQL>
            <![CDATA[
SELECT  pg_catalog.format_type(t.oid, NULL)                  AS "Type Name",
   n.nspname                                                 AS "Schema Name",
   pg_catalog.obj_description(t.oid, 'pg_type')              AS "Comment",
   CASE WHEN t.typtype = 'e' THEN 'EnumType' ELSE 'Type' END AS "Kind of Type" 
FROM pg_catalog.pg_type t
   LEFT JOIN pg_catalog.pg_namespace n ON n.oid = t.typnamespace
WHERE (t.typrelid = 0 OR (SELECT c.relkind = 'c' FROM pg_catalog.pg_class c WHERE c.oid = t.typrelid)) AND t.typname !~ '^_'
   AND t.typtype != 'd'
   AND n.nspname LIKE '${schema}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="2,1"/>
      </Command>

      <Command id="greenplum.getTypeInfo">
         <SQL>
            <![CDATA[
SELECT
    '${typename}'                 AS "Type Name",
    '${schema}'                   AS "Schema Name",
    enum_range(NULL::${typename}) AS "Values",
    '${comment}'                  AS "Comment";
            ]]>
         </SQL>
      </Command>

      <!-- ================================================================= -->
      <!-- DBA related commands requiring certain privileges in the database -->
      <!-- ================================================================= -->

      <Command id="greenplum.getUsers">
         <SQL>
            <![CDATA[
select * from pg_user
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getSettings">
         <SQL>
            <![CDATA[
select * from pg_settings
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getSessions">
         <SQL>
            <![CDATA[
select * from pg_stat_activity
            ]]>
         </SQL>
      </Command>

      <Command id="greenplum.getLocks">
         <SQL>
            <![CDATA[
select * from pg_locks
            ]]>
         </SQL>
      </Command>

      <Command id="greenplum.getMaterializedViews">
         <SQL>
            <![CDATA[
select *
from pg_matviews
where schemaname = '${owner}' order by matviewname
            ]]>
         </SQL>
      </Command>

      <Command id="greenplum.getMaterializedViewSource">
         <SQL>
            <![CDATA[
select definition
from pg_matviews
where schemaname = '${owner}' and matviewname = '${name}'
            ]]>
         </SQL>
      </Command>

      <Command id="greenplum.getPrivileges">
         <SQL>
            <![CDATA[
SELECT
    table_catalog as "TABLE_CAT",
    table_schema AS "TABLE_SCHEM",
    table_name AS "TABLE_NAME",
    grantor AS "GRANTOR",
    grantee AS "GRANTEE",
    privilege_type AS "PRIVILEGE",
    with_hierarchy AS "IS_GRANTABLE"
FROM
    information_schema.table_privileges
WHERE
    table_catalog = '${catalog}'
AND table_schema = '${schema}'
AND table_name = '${objectname}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="6"/>
      </Command>

      <!--
         pg_size_pretty         since 8.1
         pg_tablespace_location since 9.3
      -->
      <Command id="greenplum.getTablespaces">
         <SQL><![CDATA[SELECT
    ts.spcname "Tablespace",
    ro.rolname "Owner",
    ]]>
            <If test="#util.isDatabaseVersionGTE(6,0)">
               <![CDATA[
    pg_size_pretty(pg_tablespace_size(spcname)) "Size",
    pg_tablespace_location(ts.oid) "Location",
    ts.spcoptions "Options"
]]>
            </If>
            <Else>
<![CDATA[
    ts.*
]]>
            </Else>
            <![CDATA[
            FROM
    pg_catalog.pg_tablespace ts,
    pg_catalog.pg_roles ro
WHERE
    ts.spcowner = ro.oid
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
         <ProcessDataSet action="dropcolumn" index="spcowner"/>
         <ProcessDataSet action="dropcolumn" index="spclocation"/>
         <ProcessDataSet action="dropcolumn" index="spcprilocations"/>
         <ProcessDataSet action="dropcolumn" index="spcmirlocations"/>

      </Command>

      <Command id="greenplum.getForeignServers">
         <SQL>
            <![CDATA[
SELECT
    fs.srvname,
    sh.usename,
    fs.srvtype,
    fs.srvversion,
    fs.srvacl,
    fs.srvoptions
FROM
    pg_catalog.pg_foreign_server fs,
    pg_catalog.pg_user sh
WHERE
    fs.srvowner = sh.usesysid
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

      <Command id="greenplum.getUserMappings">
         <SQL>
            <![CDATA[
SELECT
    au.rolname AS "Local User",
    um.srvname AS "Foreign Server",
    um.usename AS "Foreign User",
    um.umoptions AS "Options"
FROM
    pg_catalog.pg_user_mappings um,
    pg_catalog.pg_authid au
WHERE
    um.umuser = au.oid
    AND um.srvname LIKE '${server}'
            ]]>
         </SQL>
         <ProcessDataSet action="sortcolumn" index="1"/>
      </Command>

   </Commands>

   <!-- =================================================================== -->
   <!-- Definition of the object actions that are used by the tree and views -->
   <!-- =================================================================== -->

   <ObjectsActionDef extends="false">

      <ActionGroup type="Databases">
         <Action id="greenplum-database-create" label="Create Database" reload="true"
                 resetcatalogs="true" icon="add">
            <Input label="New Database Name" name="newDatabase" style="text"/>
            <Input label="Owner" name="owner" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[select '' union select usename from pg_catalog.pg_user]]>
                     </SQL>
                  </Command>
               </Values>
            </Input>
            <Input label="Template" name="template" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[SELECT '' UNION SELECT datname FROM pg_catalog.pg_database WHERE datistemplate IS true ORDER BY 1]]>
                     </SQL>
                  </Command>
               </Values>
            </Input>
            <Input label="Encoding" name="encoding" style="list">
               <Values>
|BIG5|EUC_CN|EUC_JP|EUC_KR|EUC_TW|GB18030|GBK|ISO_8859_5|ISO_8859_6|ISO_8859_7|ISO_8859_8|JOHAB|KOI8|LATIN1|LATIN2|LATIN3|LATIN4|LATIN5|LATIN6|LATIN7|LATIN8|LATIN9|LATIN10|MULE_INTERNAL|SJIS|SQL_ASCII|UHC|UTF8|WIN866|WIN874|WIN1250|WIN1251|WIN1252|WIN1253|WIN1254|WIN1255|WIN1256|WIN1257|WIN1258
               </Values>
            </Input>
            <!--Collations supported from 6.0-->
            <If test="#util.isDatabaseVersionGTE(6,0)">
               <Input label="Collation" name="lc_collate" style="list">
                  <Values>
                     <Command>
                        <SQL>
                           <![CDATA[SELECT collcollate FROM pg_catalog.pg_collation ORDER BY 1]]>
                        </SQL>
                     </Command>
                  </Values>
               </Input>
               <Input label="Character Classification" name="lc_ctype" style="list">
                  <Values>
                     <Command>
                        <SQL>
                           <![CDATA[SELECT collctype FROM pg_catalog.pg_collation ORDER BY 1]]>
                        </SQL>
                     </Command>
                  </Values>
               </Input>
            </If>
            <Input label="Tablespace" name="tablespace" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[SELECT '' UNION SELECT spcname FROM pg_catalog.pg_tablespace ORDER BY 1]]>
                     </SQL>
                  </Command>
               </Values>
            </Input>
            <Input label="Max Connections" name="connlimit" style="number">
               <Default>-1</Default>
            </Input>

            <SetVar name="_owner" value='#owner.equals("") ? "" : "owner = \&quot;" + #owner + "\&quot;"'/>
            <SetVar name="_template" value='#template.equals("") ? "" : "template = \&quot;" + #template + "\&quot;"'/>
            <SetVar name="_encoding" value='#encoding.equals("") ? "" : "encoding = &apos;" + #encoding + "&apos;"'/>
            <If test="#util.isDatabaseVersionGTE(6,0)">
               <SetVar name="_lc_collate" value='#lc_collate.equals("") ? "" : "lc_collate = &apos;" + #lc_collate + "&apos;"'/>
               <SetVar name="_lc_ctype" value='#lc_ctype.equals("") ? "" : "lc_ctype = &apos;" + #lc_ctype + "&apos;"'/>
            </If>
            <SetVar name="_tablespace" value='#tablespace.equals("") ? "" : "tablespace =  \&quot;" + #tablespace + "\&quot;"'/>
            <SetVar name="_connlimit" value='#connlimit.equals("-1") ? "" : "connection limit = " + #connlimit'/>
            <Command>
               <SQL>
                  <![CDATA[create database ${QB}${newDatabase}${QE} ${_owner} ${_template} ${_encoding} ${_lc_collate} ${_lc_ctype} ${_tablespace} ${_connlimit}]]></SQL>
            </Command>
            <Confirm>
               Confirm create of database ${newDatabase}?
            </Confirm>
            <Result>
               Database ${newDatabase} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Catalog">
         <Action id="greenplum-database-drop" label="Drop Database" reload="true"
                 resetcatalogs="true" icon="remove">
            <Message>
               <![CDATA[<html>
A database can only be dropped if there are no physical connections to it.
Make sure that the database node has never been expanded since connect and
that no <b>Object View</b>, <b>SQL Commander</b> or <b>Monitor</b> is
using the database before dropping it.
</html>
               ]]>
            </Message>
            <Input label="Database" style="text" editable="false">
               <Default>${catalog}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[                  
drop database "${catalog}";
                  ]]>
               </SQL>
            </Command>
            <Confirm>
               Really drop database ${catalog}?
            </Confirm>
            <Result>
               database ${catalog} has been dropped!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Schemas">
         <Action id="greenplum-schemas-create-schema" label="Create Schema" reload="true" resetschemas="true" icon="add">
            <Input label="Schema" name="newschema" style="text" editable="true"/>
            <Input label="Authorization" name="authorization" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[select '' union select usename from pg_user]]></SQL>
                  </Command>
               </Values>
            </Input>

            <SetVar name="_authorization" value='#authorization.equals("") ? "" : " authorization " + #authorization'/>

            <Command>
               <SQL>
                  <![CDATA[create schema ${QB}${newschema}${QE}${_authorization}]]></SQL>
            </Command>
            <Confirm>
               Create new schema ${newschema}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="Schema">
         <Action id="greenplum-schema-drop" label="Drop Schema" reload="true" resetschemas="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL><![CDATA[drop schema "${schema}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop schema ${schema}?
            </Confirm>
         </Action>
         <Action id="greenplum-schema-comment" label="Comment Schema" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getSchemas.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on schema "${schema}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}?
            </Confirm>
         </Action>
         <Action id="greenplum-schema-export" label="Export Schema"
                 icon="export" reload="false"
                 class="schemaExport"
                 doclink="/doclink/export-schema"/>
      </ActionGroup>

      <ActionGroup type="Tables">
         <Action id="greenplum-tables-create-table" label="Create Table"
                 icon="add" reload="true"
                 class="tableCreate"
                 classargs="create"
                 doclink="/doclink/create-table"/>
         <Action id="greenplum-tables-import-table-data"
                 label="Import Table Data"
                 icon="import"
                 reload="true"
                 class="tableDataImport"
                 doclink="/doclink/import-table"/>
      </ActionGroup>

      <ActionGroup type="Table">
         <Action id="greenplum-tables-alter-table" label="Alter Table"
                 icon="edit" reload="true"
                 class="tableAlter"
                 classargs="alter"
                 doclink="/doclink/alter-table"/>

         <Action id="greenplum-table-rename" label="Rename Table" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Table Name" name="newTable" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter table "${schema}"."${objectname}" rename to ${QB}${newTable}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newTable}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="greenplum-table-clear" label="Empty Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Use Command" name="useCommand" style="radio">
               <Values>TRUNCATE|DELETE</Values>
               <Default>TRUNCATE</Default>
            </Input>

            <SetVar name="_command" value="#useCommand.equals('TRUNCATE') ? 'truncate table' : 'delete from'"/>

            <Command>
               <SQL><![CDATA[${_command} "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really remove all rows in table ${schema}.${objectname}?
            </Confirm>
            <Result>
               All rows in table ${schema}.${objectname} has been removed!
            </Result>
         </Action>

         <Action id="greenplum-table-drop" label="Drop Table" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Drop Dependent Object(s)" name="cascade" style="check"
                   tip="Automatically drop objects that depend on the table (such as views)">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop table "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="greenplum-table-comment" label="Comment Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getTables.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="greenplum-table-import-table-data" label="Import Table Data" icon="import"
                 class="tableDataImport"
                 doclink="/doclink/import-table"/>

         <Action id="greenplum-table-export" label="Export Table" icon="export"
                 class="tableExport"
                 doclink="/doclink/export-table"/>

         <Separator/>

         <Action id="greenplum-table-create-index" label="Create Index" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Index Name" name="indexname" style="text"/>
            <Input label="Unique" name="unique" style="check">
               <Values>unique</Values>
            </Input>

            <Input label="Columns" style="separator"/>

            <Input name="columns" style="grid">
               <Arg name="output" value='"${columnname}"${_sortorder}'/>
               <Arg name="newline" value=", "/>

               <Input name="columnname" label="Column Name" style="list">
                  <Values column="4">
                     <Command idref="getColumnNamesFor">
                        <Input name="table_catalog" value="${catalog}"/>
                        <Input name="table_schema" value="${schema}"/>
                        <Input name="table_name" value="${objectname}"/>
                     </Command>
                  </Values>
                  <Default>${0}</Default>
               </Input>
               <If test="#util.isDatabaseVersionGTE(6,0)">
                 <Input name="sortorder" label="Sort Order" style="radio">
                    <Labels>ASC|DESC|Default</Labels>
                    <Values>ASC|DESC|</Values>
                    <Default>ASC</Default>
                 </Input>
                 <SetVar name="_sortorder" value='#sortorder.equals("") ? "" : " " + #sortorder'/>

               </If>
               <Else>
                  <SetVar name="_sortorder" value='""'/>
               </Else>
            </Input>
            <SetVar name="_using" value='#unique.equals("") ? "" : " " + #unique'/>

            <SetVar name="_unique" value='#unique.equals("") ? "" : " " + #unique'/>
            <SetVar name="_columns" value='#columns.trim().equals("") ? "" : "(" + #columns + ")"'/>
            <SetVar name="_indexname" value='#indexname.trim().equals("") ? "" : " " + #QB + #indexname + #QE'/>             

            <Command>
               <SQL>
                  <![CDATA[create${_unique} index${_indexname} on "${schema}"."${objectname}" ${_columns}]]>
               </SQL>
            </Command>
            <Confirm>
               <![CDATA[Create index "${indexname}"?]]>
            </Confirm>
            <Result>
               <![CDATA[Index "${indexname}" created!]]>
            </Result>
         </Action>

         <Separator/>

         <Action id="greenplum-table-script" label="Script Table" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Column">
         <Action id="greenplum-column-comment" label="Comment Column" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${theTableName}</Default>
            </Input>
            <Input label="Column" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>

            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${theColumnComment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on column "${schema}"."${theTableName}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${theTableName}.${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="ForeignTable">
         <Action id="greenplum-foreign-table-drop" label="Drop Table" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Drop Dependent Object(s)" name="cascade" style="check"
                   tip="Automatically drop objects that depend on the foreign table (such as views)">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop foreign table "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop foreign table ${schema}.${objectname}?
            </Confirm>
            <Result>
               Table ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="greenplum-foreign-table-comment" label="Comment Table" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getForeignTables.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on foreign table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Separator/>

         <Action id="greenplum-table-script2" label="Script Table" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE"/>

      </ActionGroup>

      <ActionGroup type="View">
         <Action id="greenplum-view-drop" label="Drop View" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop view "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop view ${schema}.${objectname}?
            </Confirm>
            <Result>
               View ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="greenplum-view-rename" label="Rename View" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New View Name" name="newTable" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter table "${schema}"."${objectname}" rename to ${QB}${newTable}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newTable}?
            </Confirm>
            <Result>
               View ${schema}.${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="greenplum-view-comment" label="Comment View" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getViews.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on view "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Action id="greenplum-view-export" label="Export View" icon="export"
                 class="viewExport"
                 doclink="/doclink/export-view"/>

         <Separator/>

         <Action id="greenplum-view-script" label="Script View" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="MaterializedView">
         <Action id="greenplum-materializedview-drop" label="Drop Materialized View" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop materialized view "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really drop materialized view ${schema}.${objectname}?
            </Confirm>
            <Result>
               Materialized view ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="greenplum-materializedview-refresh" label="Refresh Materialized View" reload="false">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Option" name="option" style="radio">
               <Labels>WITH DATA|WITH NO DATA
               </Labels>
               <Values>WITH DATA|WITH NO DATA</Values>
            </Input>

            <Command exectype="asis">
               <SQL>
                  <![CDATA[REFRESH MATERIALIZED VIEW "${schema}"."${objectname}" ${option}]]></SQL>
            </Command>
            <Confirm>
               Really refresh materialized view ${schema}.${objectname}?
            </Confirm>
            <Result>
               Materialized view ${schema}.${objectname} has been refreshed!
            </Result>
         </Action>

         <Action id="greenplum-materializedview-comment" label="Comment Materialized View">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Materialized View" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>
                  <Command>
                     <SQL>
                        <![CDATA[
SELECT
   d.description
FROM
   pg_catalog.pg_description d,
   pg_catalog.pg_class c,
   pg_catalog.pg_namespace n
WHERE
   d.objoid = c.oid
AND c.relnamespace = n.oid
AND d.objsubid = 0
AND c.relname = '${objectname}'
AND n.nspname = '${schema}'
                        ]]>
                     </SQL>
                  </Command>
               </Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on materialized view "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>
         
         <Separator/>

         <Action id="greenplum-materializedview-script" label="Script Materialized View" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,SELECT,SELECT *"/>
      </ActionGroup>

      <ActionGroup type="Index">
         <Action id="greenplum-index-drop" label="Drop Index" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop index "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop index ${schema}.${objectname}?
            </Confirm>
            <Result>
               Index ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="greenplum-index-rename" label="Rename Index" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Index Name" name="newTable" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter index "${schema}"."${objectname}" rename to ${QB}${newTable}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of index ${schema}.${objectname} to ${newTable}?
            </Confirm>
            <Result>
               Index ${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="greenplum-index-rebuild" label="Rebuild Index">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[reindex index "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Confirm rebuild of index ${schema}.${objectname}?
            </Confirm>
            <Result>
               Index ${schema}.${objectname} rebuilt!
            </Result>
         </Action>

         <Action id="greenplum-index-comment" label="Comment Index" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Index" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getIndexes.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on index "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>

         <Separator/>

         <Action id="greenplum-index-script" label="Script Index" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Partition">
         <Action id="greenplum-partition-rename" label="Rename Partition" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Partition" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Partition Name" name="newTable" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter table "${schema}"."${objectname}" rename to ${QB}${newTable}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newTable}?
            </Confirm>
            <Result>
               Partition ${schema}.${objectname} renamed to ${newTable}!
            </Result>
         </Action>

         <Action id="greenplum-partition-clear" label="Empty Partition" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Partition" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Use Command" name="useCommand" style="radio">
               <Values>TRUNCATE|DELETE</Values>
               <Default>TRUNCATE</Default>
            </Input>

            <SetVar name="_command" value="#useCommand.equals('TRUNCATE') ? 'truncate table' : 'delete from'"/>

            <Command>
               <SQL><![CDATA[${_command} "${schema}"."${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really remove all rows in partition ${schema}.${objectname}?
            </Confirm>
            <Result>
               All rows in partition ${schema}.${objectname} has been removed!
            </Result>
         </Action>

         <Action id="greenplum-partition-drop" label="Drop Partition" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Partition" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Drop Dependent Object(s)" name="cascade" style="check"
                   tip="Automatically drop objects that depend on the table (such as views)">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop table "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop partition ${schema}.${objectname}?
            </Confirm>
            <Result>
               Partition ${schema}.${objectname} has been dropped!
            </Result>
         </Action>
         
         <Action id="greenplum-partition-comment" label="Comment Partition" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Partition" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getTablePartitions.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on table "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>
         
         <Action id="greenplum-partition-create-index" label="Create Index" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Partition" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Index Name" name="indexname" style="text"/>
            <Input label="Unique" name="unique" style="check">
               <Values>unique</Values>
            </Input>

            <Input label="Columns" style="separator"/>

            <Input name="columns" style="grid">
               <Arg name="output" value='"${columnname}"${_sortorder}'/>
               <Arg name="newline" value=", "/>

               <Input name="columnname" label="Column Name" style="list">
                  <Values column="4">
                     <Command idref="getColumnNamesFor">
                        <Input name="table_catalog" value="${catalog}"/>
                        <Input name="table_schema" value="${schema}"/>
                        <Input name="table_name" value="${objectname}"/>
                     </Command>
                  </Values>
                  <Default>${0}</Default>
               </Input>
               <Input name="sortorder" label="Sort Order" style="radio">
                  <Labels>ASC|DESC|Default</Labels>
                  <Values>ASC|DESC|</Values>
                  <Default>ASC</Default>
               </Input>
               <SetVar name="_sortorder" value='#sortorder.equals("") ? "" : " " + #sortorder'/>
            </Input>

            <SetVar name="_unique" value='#unique.equals("") ? "" : " " + #unique'/>
            <SetVar name="_columns" value='#columns.trim().equals("") ? "" : "(" + #columns + ")"'/>
            <SetVar name="_indexname" value='#indexname.trim().equals("") ? "" : " " + #QB + #indexname + #QE'/>             

            <Command>
               <SQL>
                  <![CDATA[create${_unique} index${_indexname} on "${schema}"."${objectname}" ${_columns}]]>
               </SQL>
            </Command>
            <Confirm>
               <![CDATA[Create index "${indexname}"?]]>
            </Confirm>
            <Result>
               <![CDATA[Index "${indexname}" created!]]>
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Functions">
         <Action id="greenplum-functions-create" label="Create Function" reload="true" icon="add"
                 doclink="/doclink/create-function">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" name="functionName" style="text"/>

            <Input label="Options" style="separator"/>
            <Input label="Return Data Type" name="returns" style="text">
               <Default>INTEGER</Default>
            </Input>
            <!--
                        <Input label="Language" name="language" style="radio">
                           <Values>SQL|C|INTERNAL</Values>
                           <Default>SQL</Default>
                        </Input>
                        <Input label="Volatility" name="volatility" style="radio">
                           <Values>VOLATILE|STABLE|IMMUTABLE</Values>
                           <Default>VOLATILE</Default>
                        </Input>
                        <Input label="Returns Set" name="returnsSet" style="check">
                           <Values>SETOF </Values>
                        </Input>
                        <Input label="Strict" name="strict" style="check">
                           <Values>STRICT</Values>
                        </Input>
                        <Input label="Security of Definer" name="security" style="check">
                           <Values>SECURITY DEFINER</Values>
                        </Input>
            -->
            <Input label="Parameters" style="separator"/>

            <Input name="parameters" style="grid">
               <Arg name="output" value="${direction} ${QB}${name}${QE} ${type}"/>
               <Arg name="newline" value=", "/>
              
               <Input name="direction" label="Direction" style="list">
                   <If test="#util.isDatabaseVersionGTE(5,0)">
                      <Values>IN|INOUT|OUT|VARIADIC</Values>
                  </If>
                  <Else>
                      <Values>IN|INOUT|OUT</Values>
                  </Else>
                  <Default>IN</Default>
               </Input>
               <Input name="name" label="Name" style="text">
                  <Default>parm</Default>
               </Input>
               <Input name="type" label="Type" style="text">
                  <Default>INTEGER</Default>
               </Input>
            </Input>

            <SetVar name="_parameters" value='#parameters.trim().equals("") ? "()" : "(" + #parameters + ")"'/>
            <Input label="Source" style="separator"/>
            <Input name="body" style="text-editor">
               <Default>select 100</Default>
            </Input>
            <Command exectype="asis">
               <SQL>
                  <![CDATA[
CREATE FUNCTION "${schema}".${QB}${functionName}${QE}
${_parameters}
RETURNS ${returns} 
AS $body$
  ${body}
$body$
LANGUAGE sql]]>
               </SQL>
            </Command>
            <Result>
               <![CDATA[Function "${schema}"."${functionName}" created!]]>
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Function">
         <Action id="greenplum-function-drop" label="Drop Function" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop function "${schema}"."${objectname}" (${greenplum.getFunctions.Argument data types}) ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop function ${schema}.${objectname}?
            </Confirm>
            <Result>
               Function ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="greenplum-function-rename" label="Rename Function" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Function Name" name="newFunction" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter function "${schema}"."${objectname}" (${greenplum.getFunctions.Argument data types}) rename to ${QB}${newFunction}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of function ${objectname} to ${newFunction}?
            </Confirm>
            <Result>
               Function ${objectname} renamed to ${newFunction}!
            </Result>
         </Action>

         <Action id="greenplum-function-comment" label="Comment Function" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Function" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getFunctions.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on function "${schema}"."${objectname}" (${greenplum.getFunctions.Argument data types}) is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${getDDLName}?
            </Confirm>
         </Action>

         <Action id="greenplum-function-export" label="Export Function" icon="export"
                 class="functionExport"
                 doclink="/doclink/export-code-object"/>

         <Separator/>

         <Action id="greenplum-function-script" label="Script Function" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CALL,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Sequences">
         <Action id="greenplum-sequences-create" label="Create Sequence" reload="true" icon="add">
            <Input label="Sequence Owner" name="owner" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[
SELECT trim(n.nspname) FROM pg_catalog.pg_namespace n LEFT JOIN pg_catalog.pg_user r ON n.nspowner=r.usesysid
WHERE n.nspname NOT IN ('pg_catalog', 'information_schema', 'pg_toast') ORDER BY 1;
                        ]]>
                     </SQL>
                  </Command>
               </Values>
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence Name" name="sequenceName" style="text"/>
            <Input label="Start With" name="startWith" style="text">
               <Default>1</Default>
            </Input>
            <Input label="Increment By" name="increment" style="text">
               <Default>1</Default>
            </Input>
            <Input label="Cached Values" name="cache" style="text">
               <Default>20</Default>
            </Input>
            <Input label="Cycle" name="cycle" style="radio">
               <Labels>Cycle|No Cycle</Labels>
               <Values>cycle|no cycle</Values>
               <Default>no cycle</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[create sequence "${owner}".${QB}${sequenceName}${QE} start with ${startWith} increment by ${increment} no maxvalue no minvalue cache ${cache} ${cycle}]]></SQL>
            </Command>
            <Result>
               Sequence ${owner}.${sequenceName} created!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Sequence">
         <Action id="greenplum-sequence-drop" label="Drop Sequence" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop sequence "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop sequence ${schema}.${objectname}?
            </Confirm>
            <Result>
               Sequence ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="greenplum-sequence-comment" label="Comment Sequence" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Sequence" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getSequences.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on sequence "${schema}"."${objectname}" is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>
         
         <Separator/>

         <Action id="greenplum-sequence-script" label="Script Sequence" icon="scriptObject"
                 class="sqlBuilder"
                 classargs="script-dialog,CREATE,DROP"/>
      </ActionGroup>

      <ActionGroup type="Rule">
         <Action id="greenplum-rule-rename" label="Rename Rule" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${eventtable}</Default>
            </Input>
            <Input label="Rule" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Rule Name" name="newRule" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter rule "${objectname}" on "${schema}"."${eventtable}" rename to ${newRule}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of rule ${objectname} to ${newRule}?
            </Confirm>
            <Result>
               Rule ${objectname} renamed to ${newRule}!
            </Result>
         </Action>

         <Action id="greenplum-rule-drop" label="Drop Rule" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Table" style="text" editable="false">
               <Default>${eventtable}</Default>
            </Input>
            <Input label="Rule" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop rule if exists "${objectname}" on "${schema}"."${eventtable}" ${cascade} ]]></SQL>
            </Command>
            <Confirm>
               Really drop Rule ${objectname}?
            </Confirm>
            <Result>
               Rule ${objectname} dropped!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Domain">
         <Action id="greenplum-domain-drop" label="Drop Domain" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Domain" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop domain "${schema}"."${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop domain ${schema}.${objectname}?
            </Confirm>
            <Result>
               Domain ${schema}.${objectname} dropped!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Aggregate">
         <Action id="greenplum-aggregate-drop" label="Drop Aggregate" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Aggregate" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop aggregate "${schema}"."${objectname}" (${greenplum.getAggregates.Data Type})  ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop aggregate ${schema}.${objectname}?
            </Confirm>
            <Result>
               Aggregate ${schema}.${objectname} has been dropped!
            </Result>
         </Action>

         <Action id="greenplum-aggregate-rename" label="Rename Aggregate" reload="true" icon="rename">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Aggregate" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="New Aggregate Name" name="newAggregate" style="text"/>
            <Command>
               <SQL>
                  <![CDATA[alter aggregate "${schema}"."${objectname}" (${greenplum.getAggregates.Data Type}) rename to ${QB}${newAggregate}${QE}]]></SQL>
            </Command>
            <Confirm>
               Confirm rename of ${schema}.${objectname} to ${newAggregate}?
            </Confirm>
            <Result>
               Aggregate ${schema}.${objectname} renamed to ${newAggregate}!
            </Result>
         </Action>
      </ActionGroup>

      <ActionGroup type="Type">
         <Action id="greenplum-type-drop" label="Drop Type" reload="true" icon="remove">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Type" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Cascade" name="cascade" style="check">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop type ${objectname} ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop type ${schema}.${objectname}?
            </Confirm>
            <Result>
               Type ${schema}.${objectname} dropped!
            </Result>
         </Action>

         <Action id="greenplum-type-comment" label="Comment Type" reload="true">
            <Input label="Schema" style="text" editable="false">
               <Default>${schema}</Default>
            </Input>
            <Input label="Type" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Comment" name="comment" style="wrapped-text-editor">
               <Default>${greenplum.getTypes.Comment}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[comment on type ${objectname} is '${comment}']]></SQL>
            </Command>
            <Confirm>
               Apply new comment on ${schema}.${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="Tablespaces">
         <Action id="greenplum-tablespace-create" label="Create Tablespace" reload="true" icon="add">
            <Input label="Tablespace Name" name="tablespace" style="text"/>
            <Input label="Owner" name="owner" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[select '' union select rolname from pg_catalog.pg_roles order by 1]]>
                     </SQL>
                  </Command>
               </Values>
            </Input>
            <Input label="Location" name="location" style="text"/>
            <SetVar name="_owner" value='#owner.equals("") ? "" : "owner \&quot;" + #owner + "\&quot;"'/>
            <Command>
               <SQL>
                  <![CDATA[create tablespace ${QB}${tablespace}${QE} ${_owner} location '${location}']]></SQL>
            </Command>
            <Confirm>
               Confirm create of tablespace ${tablespace}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="Tablespace">
         <Action id="greenplum-tablespace-drop" label="Drop Tablespace" reload="true" icon="remove">
            <Input label="Tablespace Name" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL><![CDATA[drop tablespace "${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really drop tablespace ${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="ForeignServer">
         <Action id="greenplum-foreign-server-drop" label="Drop Foreign Server" reload="true" icon="remove">
            <Input label="Server Name" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Input label="Drop Dependent Objects" name="cascade" style="check"
                   tip="Enable this to drop all dependent objects, e.g User Mappings">
               <Values>cascade</Values>
            </Input>
            <Command>
               <SQL><![CDATA[drop server "${objectname}" ${cascade}]]></SQL>
            </Command>
            <Confirm>
               Really drop foreign server ${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="UserMapping">
         <Action id="greenplum-user-mapping-drop" label="Drop User Mapping" reload="true" icon="remove">
            <Input label="Server Name" style="text" editable="false">
               <Default>${server}</Default>
            </Input>
            <Input label="User Name" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>
            <Command>
               <SQL>
                  <![CDATA[drop user mapping for "${objectname}" server "${server}"]]></SQL>
            </Command>
            <Confirm>
               Really drop user mapping for ${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="Settings">
         <Action id="greenplum-reload-config" label="Reload Configuration">
            <Command>
               <SQL>
                  <![CDATA[
select pg_reload_conf();
                    ]]>
               </SQL>
            </Command>
            <Confirm>
               Really reload the configuration settings?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="Users">
         <Action id="greenplum-users-create-user" label="Create User" reload="true" icon="add">
           <Input label="User" name="newuser" style="text" editable="true"/>
            <Input label="Password" name="password" style="password" editable="true"/>
            <Input label="In Role" name="role" style="list">
               <Values>
                  <Command>
                     <SQL>
                        <![CDATA[select '' union select rolname from pg_roles]]></SQL>
                  </Command>
               </Values>
            </Input>
            <SetVar name="_role" value='#role.equals("") ? "" : "in role " + "\""+ #role + "\""'/>

            <Input label="Create DB" name="createdb" style="check">
               <Values>CREATEDB</Values>
            </Input>
            <Input label="Create Role" name="createrole" style="check">
               <Values>CREATEROLE</Values>
            </Input>
            <Input label="Inherit" name="inherit" style="check">
               <Values>INHERIT</Values>
            </Input>
            <Input label="Super User" name="superuser" style="check">
               <Values>SUPERUSER</Values>
            </Input>
            <Input label="Login" name="login" style="check">
               <Values>LOGIN|NOLOGIN</Values>
                 <Default>LOGIN</Default>
            </Input>
            <Input label="Connection Limit" name="connectionlimit" style="number">
                 <Default>-1</Default>
            </Input>

            <SetVar name="_connectlimit" value="#connectionlimit > 0 ? 'CONNECTION LIMIT ' +  #connectionlimit  : ''"/>

            <Command>
               <SQL>
                  <![CDATA[create user ${QB}${newuser}${QE} with password '${password}' ${_role} ${createdb} ${superuser} ${login} ${_connectlimit} ${inherit}]]></SQL>
            </Command>
            <Confirm>
               Create new user ${newuser}?
            </Confirm>
         </Action>
      </ActionGroup>

      <ActionGroup type="User">
         <Action id="greenplum-user-drop-user" label="Drop User" reload="true" icon="remove">
            <Input label="User" style="text" editable="false">
               <Default>${objectname}</Default>
            </Input>

            <Command>
               <SQL><![CDATA[drop user "${objectname}"]]></SQL>
            </Command>
            <Confirm>
               Really drop user ${objectname}?
            </Confirm>
         </Action>
      </ActionGroup>


   </ObjectsActionDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects tree structure -->
   <!-- greenplum only allows browsing default database specified in the -->
   <!-- URL. This definition simply makes non default databases  -->
   <!-- e.g catalogs as leaf nodes. -->
   <!-- All nodes below the default database is listed as owner.object -->
   <!-- =================================================================== -->

   <ObjectsTreeDef extends="false">

      <GroupNode type="Databases" label="Databases">
         <DataNode type="Catalog" label="${greenplum.getConnectableDatabases.datname}" is-catalog-database="true">
            <SetVar name="catalog" value="${greenplum.getConnectableDatabases.datname}"/>
            <Command idref="greenplum.getConnectableDatabases">
               <Filter index="datname" label="Name"/>
            </Command>

            <GroupNode type="Schemas" label="Schemas">
               <DataNode type="Schema" label="${greenplum.getSchemas.Name}">
                  <SetVar name="schema" value="${greenplum.getSchemas.Name}"/>
                  <Command idref="greenplum.getSchemas">
                     <Filter index="Name" label="Name"/>
                  </Command>

                  <GroupNode type="Tables" label="Tables">
                     <DataNode type="Table" label="${greenplum.getTables.Name}">
                        <SetVar name="objectname" value="${greenplum.getTables.Name}"/>
                        <SetVar name="rowcount" value="true"/>
                        <SetVar name="acceptInQB" value="true"/>
                        <Command idref="greenplum.getTables">
                           <Input name="schema" value="${schema}"/>
                           <Input name="table" value="%"/>
                        </Command>

                        <!-- Need to keep the objectname for the current table in
                       a new variable so that the viewers will be able to pick up
                       the correct input to display -->
                        <SetVar name="theTableName" value="${objectname}"/>

                        <GroupNode type="Columns" label="Columns">
                           <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
                                     label1="${getColumnDefinitions.TYPE_NAME}"
                                     isLeaf="true"
                                     icon="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'PrimaryKey' : 'Column'"
                                     tip="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'This is a primary key column' : ''">
                              <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                              <SetVar name="theColumnComment" value="${getColumnDefinitions.COMMENT}"/>

                              <Command idref="getColumnDefinitions">
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="objectname" value="${theTableName}"/>
                                 <Input name="tableType" value="Table"/>
                                 <Filter index="TYPE_NAME" label="Type"/>
                              </Command>
                           </DataNode>
                        </GroupNode>

                        <GroupNode type="Indexes" label="Indexes">
                           <DataNode type="Index" label="${greenplum.getIndexes.Index Name}" isLeaf="true">
                              <SetVar name="objectname" value="${greenplum.getIndexes.Index Name}"/>
                              <Command idref="greenplum.getIndexes">
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="table" value="${theTableName}"/>
                              </Command>
                           </DataNode>
                        </GroupNode>

                        <GroupNode type="Rules" label="Rules" >
                           <DataNode type="Rule" label="${greenplum.getRules.Rule Name}"
                              label1="${greenplum.getRules.Rule Event}"
                              isLeaf="true">
                              <SetVar name="objectname" value="${greenplum.getRules.Rule Name}"/>
                              <SetVar name="eventtable" value="${greenplum.getRules.Table Name}"/>
                              <Command idref="greenplum.getRules">
                                 <Input name="kind" value="r"/>
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="tableNamePattern" value="${theTableName}"/>
                              </Command>
                           </DataNode>
                        </GroupNode>

                        <If test="#util.isDatabaseVersionGTE(4,3)">
                           <GroupNode type="Partitions" label="Partitions">
                              <DataNode type="Partition" label="${greenplum.getTablePartitions.Name}" isLeaf="false">
                                 <SetVar name="objectname" value="${greenplum.getTablePartitions.Name}"/>
                                 <SetVar name="parentName" value="${greenplum.getTablePartitions.Parent Table}"/>
                                 <SetVar name="parentSchema" value="${greenplum.getTablePartitions.Parent Table Schema}"/>
                                 <Command idref="greenplum.getTablePartitions">
                                    <Input name="schema" value="${schema}"/>
                                    <Input name="table" value="${theTableName}"/>
                                 </Command>
                                 <GroupNode type="PartitionIndexes" label="Indexes">
                                    <DataNode type="Index" label="${greenplum.getIndexes.Index Name}" isLeaf="true">
                                       <SetVar name="objectname" value="${greenplum.getIndexes.Index Name}"/>
                                       <Command idref="greenplum.getIndexes">
                                          <Input name="schema" value="${schema}"/>
                                          <Input name="table" value="${objectname}"/>
                                       </Command>
                                    </DataNode>
                                 </GroupNode>
                                 <GroupNode type="SubPartitions" label="Partitions">
                                    <DataNode type="Partition" label="${greenplum.getTablePartitions.Name}" isLeaf="false">
                                       <SetVar name="objectname" value="${greenplum.getTablePartitions.Name}"/>
                                       <SetVar name="parentName" value="${greenplum.getTablePartitions.Parent Table}"/>
                                       <SetVar name="parentSchema" value="${greenplum.getTablePartitions.Parent Table Schema}"/>
                                       <Command idref="greenplum.getTablePartitions">
                                          <Input name="schema" value="${schema}"/>
                                          <Input name="table" value="${objectname}"/>
                                       </Command>
                                       <GroupNode type="PartitionIndexes" label="Indexes">
                                          <DataNode type="Index" label="${greenplum.getIndexes.Index Name}" isLeaf="true">
                                             <SetVar name="objectname" value="${greenplum.getIndexes.Index Name}"/>
                                             <Command idref="greenplum.getIndexes">
                                                <Input name="schema" value="${schema}"/>
                                                <Input name="table" value="${objectname}"/>
                                             </Command>
                                          </DataNode>
                                       </GroupNode>
                                    </DataNode>
                                 </GroupNode>
                              </DataNode>
                           </GroupNode>
                        </If>
                     </DataNode>
                  </GroupNode>

                  <If test="#util.isDatabaseVersionGTE(6,0)">
                     <GroupNode type="ForeignTables" label="Foreign Tables">
                        <DataNode type="ForeignTable" label="${greenplum.getForeignTables.Name}">
                           <SetVar name="objectname" value="${greenplum.getForeignTables.Name}"/>
                           <SetVar name="rowcount" value="true"/>
                           <SetVar name="acceptInQB" value="true"/>
                           <Command idref="greenplum.getForeignTables">
                              <Input name="schema" value="${schema}"/>
                              <Input name="table" value="%"/>
                           </Command>
                           <!-- Need to keep the objectname for the current table in
                           a new variable so that the viewers will be able to pick up
                           the correct input to display -->
                           <SetVar name="theTableName" value="${objectname}"/>

                           <GroupNode type="Columns" label="Columns">
                              <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
                                        label1="${getColumnDefinitions.TYPE_NAME}"
                                        isLeaf="true">
                                 <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                                 <SetVar name="theColumnComment" value="${getColumnDefinitions.COMMENT}"/>

                                 <Command idref="getColumnDefinitions">
                                    <Input name="schema" value="${schema}"/>
                                    <Input name="objectname" value="${theTableName}"/>
                                    <Input name="tableType" value="Table"/>
                                    <Filter index="TYPE_NAME" label="Type"/>
                                 </Command>
                              </DataNode>
                           </GroupNode>

                        </DataNode>
                     </GroupNode>
                  </If>

                  <GroupNode type="Views" label="Views">
                     <DataNode type="View" label="${greenplum.getViews.Name}">
                        <SetVar name="objectname" value="${greenplum.getViews.Name}"/>
                        <SetVar name="rowcount" value="true"/>
                        <SetVar name="acceptInQB" value="true"/>
                        <Command idref="greenplum.getViews">
                           <Input name="schema" value="${schema}"/>
                           <Input name="table" value="%"/>
                        </Command>
                        
                        <!-- Need to keep the objectname for the current view in
                       a new variable so that the viewers will be able to pick up
                       the correct input to display -->
                        <SetVar name="theTableName" value="${objectname}"/>

                        <GroupNode type="Columns" label="Columns">
                           <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
                                     label1="${getColumnDefinitions.TYPE_NAME}" isLeaf="true">
                              <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
                              <SetVar name="theColumnComment" value="${getColumnDefinitions.COMMENT}"/>

                              <Command idref="getColumnDefinitions">
                                 <Input name="catalog" value="${catalog}"/>
                                 <Input name="schema" value="${schema}"/>
                                 <Input name="objectname" value="${theTableName}"/>
                                 <Input name="tableType" value="View"/>
                                 <Filter index="TYPE_NAME" label="Type"/>
                              </Command>
                           </DataNode>
                        </GroupNode>
                     </DataNode>
                  </GroupNode>

                  <If test="#util.isDatabaseVersionGTE(6,0)">
                     <GroupNode type="MaterializedViews" label="Materialized Views">
                        <DataNode type="MaterializedView" label="${greenplum.getMaterializedViews.matviewname}" isLeaf="false">
                           <SetVar name="objectname" value="${greenplum.getMaterializedViews.matviewname}"/>
                           <SetVar name="rowcount" value="true"/>
                           <SetVar name="acceptInQB" value="true"/>
                           <Command idref="greenplum.getMaterializedViews">
                              <Input name="owner" value="${schema}"/>
                           </Command>

                           <!-- Need to keep the objectname for the current view in
                           a new variable so that the viewers will be able to pick up
                           the correct input to display -->
                           <SetVar name="theTableName" value="${objectname}"/>

                           <GroupNode type="Columns" label="Columns">
                              <DataNode type="Column" label="${getColumns.COLUMN_NAME}"
                                        label1="${getColumns.TYPE_NAME}" isLeaf="true">
                                 <SetVar name="objectname" value="${getColumns.COLUMN_NAME}"/>
                                 <SetVar name="theColumnComment" value="${getColumns.REMARKS}"/>

                                 <!-- Materialized View columns are not included in the views
                                      used for getColumnDefinitions so we use getColumns here.
                                 -->
                                 <Command idref="getColumns">
                                    <Input name="owner" value="${schema}"/>
                                    <Input name="table" value="${objectname}"/>
                                 </Command>
                              </DataNode>
                           </GroupNode>

                           <!-- greenplum.getIndexes is used both to list all indexes in
                           the schema and indexes related to a specific table.
                           This variable is needed in order to either get all indexes
                           (even those not related to a table) or indexes that
                           really are associated with a table -->
                           <SetVar name="indexOwnerSQL" value="table_owner = '${schema}'"/>

                           <GroupNode type="Indexes" label="Indexes">
                              <DataNode type="Index" label="${greenplum.getIndexes.Index Name}" isLeaf="true">
                                 <SetVar name="objectname" value="${greenplum.getIndexes.Index Name}"/>
                                 <Command idref="greenplum.getIndexes">
                                    <Input name="schema" value="${schema}"/>
                                    <Input name="table" value="${theTableName}"/>
                                 </Command>
                              </DataNode>
                           </GroupNode>
                        </DataNode>
                     </GroupNode>
                  </If>

                  <SetVar name="theTableName" value="%"/>

                  <GroupNode type="Indexes" label="Indexes">
                     <DataNode type="Index" label="${greenplum.getIndexes.Index Name}"
                               label1="${greenplum.getIndexes.Schema Name}.${greenplum.getIndexes.Table Name}"
                               isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getIndexes.Index Name}"/>
                        <Command idref="greenplum.getIndexes">
                           <Input name="schema" value="${schema}"/>
                           <Input name="table" value="%"/>
                           <Filter index="Table Name" label="Table Name"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Functions" label="Functions">
                     <DataNode type="Function" label="${greenplum.getFunctions.Function Name} (${greenplum.getFunctions.Argument data types})"
                               isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getFunctions.Function Name}"/>
                        <SetVar name="getDDLName" value="${greenplum.getFunctions.Function Name} (${greenplum.getFunctions.Argument data types})"/>
                        <Command idref="greenplum.getFunctions">
                           <Input name="schema" value="${schema}"/>
                           <Input name="kind" value="f"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Rules" label="Rules">
                     <DataNode type="Rule" label="${greenplum.getRules.Rule Name}"
                        label1="${greenplum.getRules.Table Name}/${greenplum.getRules.Rule Event}"
                        isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getRules.Rule Name}"/>
                        <SetVar name="eventtable" value="${greenplum.getRules.Table Name}"/>
                        <Command idref="greenplum.getRules">
                           <Input name="kind" value="r"/>
                           <Input name="schema" value="${schema}"/>
                           <Input name="tableNamePattern" value="%"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Sequences" label="Sequences">
                     <DataNode type="Sequence" label="${greenplum.getSequences.Sequence Name}" isLeaf="true">
                        <SetVar name="schema" value="${greenplum.getSequences.Schema Name}"/>
                        <SetVar name="objectname" value="${greenplum.getSequences.Sequence Name}"/>
                        <Command idref="greenplum.getSequences"/>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Domains" label="Domains">
                     <DataNode type="Domain" label="${greenplum.getDomains.Domain Name}" isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getDomains.Domain Name}"/>
                        <Command idref="greenplum.getDomains">
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Aggregates" label="Aggregates">
                     <DataNode type="Aggregate" label="${greenplum.getAggregates.Aggregate Name}"
                               label1="${greenplum.getAggregates.Data Type}"
                               isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getAggregates.Aggregate Name}"/>
                        <Command idref="greenplum.getAggregates">
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Operators" label="Operators" icon="mathOperator">
                     <DataNode type="Operator" label="${greenplum.getOperators.Operator Name}"
                              icon="mathOperator"
                               label1="${greenplum.getOperators.Left arg type},${greenplum.getOperators.Right arg type}"
                               isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getOperators.Operator Name}"/>
                        <Command idref="greenplum.getOperators">
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <GroupNode type="Types" label="Types">
                     <DataNode type="${greenplum.getTypes.Kind of Type}" label="${greenplum.getTypes.Type Name}" isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getTypes.Type Name}"/>
                        <SetVar name="comment" value="${greenplum.getTypes.Comment}"/>
                        <Command idref="greenplum.getTypes">
                           <Input name="schema" value="${schema}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>

                  <!-- todo? <GroupNode type="Rules" label="Rules"/> -->

               </DataNode>
            </GroupNode>

         </DataNode>
      </GroupNode>

      <!-- ================================================================= -->
      <!-- DBA Nodes -->
      <!-- ================================================================= -->

      <GroupNode type="DBA" label="DBA Views">
         <GroupNode type="Users" label="Users">
            <DataNode type="User" label="${greenplum.getUsers.usename}" isLeaf="true">
               <SetVar name="objectname" value="${greenplum.getUsers.usename}"/>
               <Command idref="greenplum.getUsers"/>
            </DataNode>
         </GroupNode>

         <GroupNode type="Settings" label="Settings" isLeaf="true"/>
         <GroupNode type="Locks" label="Locks" isLeaf="true"/>
         <GroupNode type="Sessions" label="Sessions" isLeaf="true"/>
         <GroupNode type="Tablespaces" label="Tablespaces" isLeaf="false">
            <DataNode type="Tablespace" label="${greenplum.getTablespaces.Tablespace}" isLeaf="true">
               <SetVar name="objectname" value="${greenplum.getTablespaces.Tablespace}"/>
               <Command idref="greenplum.getTablespaces"/>
            </DataNode>
         </GroupNode>
         <If test="#util.isDatabaseVersionGTE(6,0)">
            <GroupNode type="ForeignServers" label="Foreign Servers" isLeaf="false">
               <DataNode type="ForeignServer" label="${greenplum.getForeignServers.srvname}" isLeaf="false">
                  <SetVar name="objectname" value="${greenplum.getForeignServers.srvname}"/>
                  <SetVar name="server" value="${greenplum.getForeignServers.srvname}"/>
                  <Command idref="greenplum.getForeignServers"/>

                  <GroupNode type="UserMappings" label="User Mappings" isLeaf="false">
                     <DataNode type="UserMapping" label="${greenplum.getUserMappings.Local User}" isLeaf="true">
                        <SetVar name="objectname" value="${greenplum.getUserMappings.Local User}"/>
                        <Command idref="greenplum.getUserMappings">
                           <Input name="server" value="${server}"/>
                        </Command>
                     </DataNode>
                  </GroupNode>
               </DataNode>
            </GroupNode>
         </If>
      </GroupNode>

   </ObjectsTreeDef>

   <!-- =================================================================== -->
   <!-- Definition of the database objects views -->
   <!-- =================================================================== -->

   <ObjectsViewDef extends="true">

      <ObjectView type="Databases">
         <DataView id="greenplum-databases-databases" icon="Catalog" label="Databases" viewer="grid">
            <Command idref="greenplum.getCatalogs"/>
            <Message>
               <![CDATA[
<html>
List of all available databases in the database server. 
</html>
               ]]>
            </Message>
         </DataView>
      </ObjectView>

      <ObjectView type="Catalog" drop-on-condition="always"/>

      <ObjectView type="Schemas">
         <DataView id="generic-schemas-schemas" drop-on-condition="always"/>

         <DataView id="greenplum-schemas-schemas" icon="Schemas" label="Schemas" viewer="grid">
            <Command idref="greenplum.getSchemas"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Schema">
         <DataView id="generic-schema-tables" drop-on-condition="always"/>
         <DataView id="generic-schema-references" drop-on-condition="always"/>

         <DataView id="greenplum-schema-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Tables">
         <DataView id="generic-tables-tables" drop-on-condition="always"/>
         <DataView id="generic-tables-references" drop-on-condition="always"/>

         <DataView id="greenplum-tables-tables" icon="Tables" label="Tables" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop table ${schema||Schema}${object||Name}"/>
            </Input>

            <Command idref="greenplum.getTables">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="%"/>
            </Command>
         </DataView>
         <DataView id="greenplum-tables-references" icon="References" label="References" viewer="tables-refs"
                   doclink="/doclink/show-references">
            <Command idref="getTables">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="%"/>
               <Input name="tableType" value="SYSTEM TABLE,TABLE"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Table">
         <DataView id="generic-table-info" drop-on-condition="always"/>

         <DataView id="greenplum-table-info" icon="Info" label="Info" viewer="form" order-before="0">
            <Command idref="greenplum.getTables">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="generic-table-ddl">
            <Input name="formatSQL" value="true"/>
            <Message/>
         </DataView>
      </ObjectView>

      <ObjectView type="ForeignTables">
         <DataView id="greenplum-foreign-tables-tables" icon="ForeignTables" label="Foreign Tables" viewer="grid">
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP TABLE">
               <Input name="command" value="drop foreign table ${schema||Schema}${object||Name}"/>
            </Input>

            <Command idref="greenplum.getForeignTables">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="ForeignTable">
         <DataView id="postgres8-foreign-table-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="postgres8-foreign-table-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="getColumns">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="postgres8-foreign-table-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="postgres8-foreign-table-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
         <DataView id="postgres8-foreign-table-grants" icon="TablePrivileges" label="Grants" viewer="grid">
            <Command idref="getPrivileges">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Views">
         <DataView id="greenplum-views-views" icon="Views" label="Views" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||Schema}${object||Name}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP VIEW">
               <Input name="command" value="drop view ${schema||Schema}${object||Name}"/>
            </Input>

            <Command idref="greenplum.getViews">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="View">
         <DataView id="greenplum-view-info" icon="Info" label="Info" viewer="form">
            <Command idref="greenplum.getViews">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-view-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="getColumns">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-view-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="greenplum-view-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
         <DataView id="greenplum-view-indexes" icon="Index" label="Indexes" viewer="grid">
            <Command idref="getIndexes">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-view-grants" icon="TablePrivileges" label="Grants" viewer="grid">
            <Command idref="greenplum.getPrivileges">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-view-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="View"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
      </ObjectView>

      <ObjectView type="MaterializedViews">
         <DataView id="greenplum-materializedviews-materializedviews" icon="MaterializedViews" label="Materialized Views" viewer="grid">
            <Input name="menuItem" value="Open in New Tab...">
               <Input name="action" value="open-object-in-new-tab-command ${schema||schemaname}${object||matviewname}"/>
            </Input>
            <Input name="menuItem" value="Open in Floating Tab...">
               <Input name="action" value="open-object-in-floating-tab-command ${schema||schemaname}${object||matviewname}"/>
            </Input>
            <Input name="menuItem" value="Script: SELECT ALL">
               <Input name="command" value="select * from ${schema||schemaname}${object||matviewname}"/>
            </Input>
            <Input name="menuItem" value="Script: DROP MATERIALIZED VIEW">
               <Input name="command" value="drop materialized view ${schema||schemaname}${object||matviewname}"/>
            </Input>

            <Command idref="greenplum.getMaterializedViews">
               <Input name="owner" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="MaterializedView">
         <DataView id="greenplum-materializedview-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="greenplum-materializedview-columns" icon="Columns" label="Columns" viewer="grid">
            <Command idref="getColumns">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-materializedview-data" icon="Data" label="Data" viewer="table-data" doclink="/doclink/table-data"/>
         <DataView id="greenplum-materializedview-rowcount" icon="RowCount" label="Row Count" viewer="table-rowcount"/>
         <DataView id="greenplum-materializedview-indexes" icon="Index" label="Indexes" viewer="grid">
            <Command idref="greenplum.getIndexes">
               <Input name="owner" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-materializedview-selectsql" icon="Source" label="Select SQL" viewer="text">
            <Input name="formatSQL" value="true"/>
            <Input name="dataColumn" value="definition"/>
            <Command idref="greenplum.getMaterializedViewSource">
               <Input name="owner" value="${schema}"/>
               <Input name="name" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Indexes">
         <DataView id="generic-indexes-indexes" drop-on-condition="always"/>

         <DataView id="greenplum-indexes-indexes" icon="Indexes" label="Indexes" viewer="grid">
            <Command idref="greenplum.getIndexes">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${theTableName}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="PartitionIndexes">
         <DataView id="greenplum-partition-indexes-indexes" icon="Indexes" label="Indexes" viewer="grid">
            <Command idref="greenplum.getIndexes">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Index">
         <!--todo?
                  <DataView type="Columns" label="Columns" viewer="grid">
                     <Command idref="greenplum.getIndexColumns">
                        <Input name="indexname" value="${objectname}"/>
                     </Command>
                  </DataView>
         -->
         <DataView id="greenplum-index-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="Index"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
         <!--
                  <DataView type="Source" label="Native DDL" viewer="text">
                     <Input name="formatSQL" value="true"/>
                     <Command idref="greenplum.getIndexSource">
                        <Input name="schema" value="${schema}"/>
                        <Input name="indexname" value="${objectname}"/>
                     </Command>
                     <Message>
                        <![CDATA[
         <html>
         This view shows the complete DDL used to create the object.
         </html>
                       ]]>
                     </Message>
                  </DataView>
         -->
      </ObjectView>

      <ObjectView type="Partitions">
         <DataView id="greenplum-partitions-partitions" icon="Partitions" label="Partitions" viewer="grid">
            <Command idref="greenplum.getTablePartitions">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${theTableName}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Partition">
         <DataView id="greenplum-partition-info" icon="Info" label="Info" viewer="node-form"/>
         <DataView id="greenplum-partition-indexes" icon="Index" label="Indexes" viewer="grid">
            <Command idref="getIndexes">
               <Input name="catalog" value="${catalog}"/>
               <Input name="schema" value="${schema}"/>
               <Input name="objectname" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="SubPartitions">
         <DataView id="greenplum-subpartitions-partitions" icon="Partitions" label="Partitions" viewer="grid">
            <Command idref="greenplum.getTablePartitions">
               <Input name="schema" value="${schema}"/>
               <Input name="table" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequences">
         <DataView id="greenplum-sequences-sequences" icon="Sequences" label="Sequences" viewer="grid">
            <Command idref="greenplum.getSequences"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Sequence">
         <DataView id="greenplum-sequence-info" icon="Info" label="Info" viewer="form">
            <Command idref="greenplum.getSequence">
               <Input name="schema" value="${schema}"/>
               <Input name="seqname" value="${objectname}"/>
            </Command>
         </DataView>
         <DataView id="greenplum-sequence-ddl" icon="Source" label="DDL" viewer="ddl">
            <Input name="objectType" value="Sequence"/>
            <Input name="formatSQL" value="true"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Functions">
         <DataView id="greenplum-functions-functions" icon="Functions" label="Functions" viewer="grid">
            <Command idref="greenplum.getFunctions">
               <Input name="schema" value="${schema}"/>
               <Input name="kind" value="f"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Function">
         <DataView classargs="FUNCTION" id="greenplum-function-functioneditor" icon="SourceEditor" label="Function Editor" viewer="procedure-editor"
                   doclink="/doclink/edit-code-object">
         </DataView>
         <DataView id="greenplum-function-info" icon="Info" label="Info" viewer="node-form"/>
         <!--
                  <DataView type="Source" label="Source" viewer="text">
                     <Command idref="greenplum.getFunctionSource">
                        <Input name="schema" value="${schema}"/>
                        <Input name="funcname" value="${objectname}"/>
                     </Command>
                  </DataView>
         -->
      </ObjectView>

      <ObjectView type="Rules">
         <DataView id="greenplum-rules-rules" icon="Rules" label="Rules" viewer="grid">
            <Command idref="greenplum.getRules">
               <Input name="schema" value="${schema}"/>
               <Input name="kind" value="r"/>
               <Input name="tableNamePattern" value="${theTableName}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Rule">
         <DataView id="greenplum-rule-info" icon="Rule" label="Info" viewer="node-form"/>
         <DataView id="greenplum-rule-ddl" icon="Source" label="DDL" viewer="text">
            <Command idref="greenplum.getRuleDdl">
               <Input name="schemaname" value="${schema}"/>
               <Input name="tablename" value="${eventtable}"/>
               <Input name="rulename" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Domains">
         <DataView id="greenplum-domains-domains" icon="Domains" label="Domains" viewer="grid">
            <Command idref="greenplum.getDomains">
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Domain">
         <DataView id="greenplum-domain-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Aggregates">
         <DataView id="greenplum-aggregates-aggregates" icon="Aggregates" label="Aggregates" viewer="grid">
            <Command idref="greenplum.getAggregates">
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Aggregate">
         <DataView id="greenplum-aggregate-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Operators">
         <DataView id="greenplum-operators-operators" icon="Operators" label="Operators" viewer="grid">
            <Command idref="greenplum.getOperators">
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Operator">
         <DataView id="greenplum-operator-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Types">
         <DataView id="greenplum-types-types" icon="Types" label="Types" viewer="grid">
            <Command idref="greenplum.getTypes">
               <Input name="schema" value="${schema}"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="Type">
         <DataView id="greenplum-type-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="EnumType">
         <DataView id="greenplum-enum-type-info" icon="Info" label="Info" viewer="form">
            <Command idref="greenplum.getTypeInfo">
               <Input name="schema" value="${schema}"/>
               <Input name="typename" value="${objectname}"/>
            </Command>
         </DataView>
      </ObjectView>

      <!-- DBA views -->

      <ObjectView type="Users">
         <DataView id="greenplum-users-users" icon="Users" label="Users" viewer="grid">
            <Command idref="greenplum.getUsers"/>
         </DataView>
      </ObjectView>

      <ObjectView type="User">
         <DataView id="greenplum-user-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Groups">
         <DataView id="greenplum-groups-groups" icon="Groups" label="Groups" viewer="grid">
            <Command idref="greenplum.getGroups"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Group">
         <DataView id="greenplum-group-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="Settings">
         <DataView id="greenplum-settings-settings" icon="Settings" label="Settings" viewer="grid">
            <Command idref="greenplum.getSettings"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Sessions">
         <DataView id="greenplum-sessions-sessions" icon="Sessions" label="Sessions" viewer="grid">
            <Command idref="greenplum.getSessions"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Locks">
         <DataView id="greenplum-locks-locks" icon="Locks" label="Locks" viewer="grid">
            <Command idref="greenplum.getLocks"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Tablespaces">
         <DataView id="greenplum-tablespaces-tablespaces" icon="Tablespaces" label="Tablespaces" viewer="grid">
            <Command idref="greenplum.getTablespaces"/>
         </DataView>
      </ObjectView>

      <ObjectView type="Tablespace">
         <DataView id="greenplum-tablespace-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="ForeignServers">
         <DataView id="greenplum-foreign-servers" icon="ForeignServers" label="Foreign Servers" viewer="grid">
            <Command idref="greenplum.getForeignServers"/>
         </DataView>
      </ObjectView>

      <ObjectView type="ForeignServer">
         <DataView id="greenplum-foreign-server-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

      <ObjectView type="UserMappings">
         <DataView id="greenplum-user-mappings" icon="UserMappings" label="User Mappings" viewer="grid">
            <Command idref="greenplum.getUserMappings">
               <Input name="server" value="%"/>
            </Command>
         </DataView>
      </ObjectView>

      <ObjectView type="UserMapping">
         <DataView id="greenplum-user-mapping-info" icon="Info" label="Info" viewer="node-form"/>
      </ObjectView>

   </ObjectsViewDef>

</DatabaseProfile>
