"Fossies" - the Fresh Open Source Software Archive

Member "DbVisualizer/resources/profiles/postgresql.xml" (3 Nov 2019, 20589 Bytes) of package /linux/misc/dbvis_unix_10_0_24.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) XML source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 <?xml version="1.0" encoding="UTF-8" ?>
    2 <!--
    3   ~ Copyright (c) DbVis Software AB. All Rights Reserved.
    4   -->
    5 
    6 <!DOCTYPE DatabaseProfile SYSTEM "dbvis-defs.dtd">
    7 
    8 <DatabaseProfile
    9         desc="Profile for PostgreSQL"
   10         minver="9.5"
   11         extends="generic">
   12 
   13    <!-- =================================================================== -->
   14    <!-- Definition of the commands -->
   15    <!-- =================================================================== -->
   16 
   17    <Commands extends="true">
   18 
   19       <!--
   20         The "getTableNamesFor" command is used by Database getTableNamesFor().
   21         It must return table names for the catalog and schema named by
   22         the ${table_catalog} and ${table_catalog} variables in the first
   23         column.
   24       -->
   25       <Command id="postgresql.getTableNamesFor">
   26         <SQL>
   27           <![CDATA[
   28 select TABLE_NAME
   29 from INFORMATION_SCHEMA.TABLES
   30 where TABLE_CATALOG = '${table_catalog}' and TABLE_SCHEMA = '${table_schema}'
   31 order by TABLE_NAME
   32             ]]>
   33         </SQL>   
   34       </Command>
   35 
   36       <!--
   37         The "getColumnNamesFor" command is used by Database getColumnNamesFor().
   38         It must return column names for the catalog, schema and table named by
   39         the ${table_catalog}, ${table_catalog} and ${table_name} variables in
   40         the first column.
   41       -->
   42       <Command id="postgresql.getColumnNamesFor">
   43         <SQL>
   44           <![CDATA[
   45 select COLUMN_NAME
   46 from INFORMATION_SCHEMA.COLUMNS
   47 where TABLE_CATALOG = '${table_catalog}' and TABLE_SCHEMA = '${table_schema}'
   48 and TABLE_NAME = '${table_name}'
   49 order by COLUMN_NAME
   50             ]]>
   51         </SQL>   
   52       </Command>
   53 
   54       <Command id="postgresql.getCatalogs">
   55          <SQL>
   56             <![CDATA[
   57 select * from pg_catalog.pg_database
   58             ]]>
   59          </SQL>
   60       </Command>
   61 
   62       <Command id="postgresql.getTables">
   63          <SQL>
   64             <![CDATA[
   65 select * from pg_tables where schemaname != 'pg_catalog'
   66             ]]>
   67          </SQL>
   68       </Command>
   69 
   70       <Command id="postgresql.getTable">
   71          <SQL>
   72             <![CDATA[
   73 select * from pg_tables where tablename = '${table}'
   74             ]]>
   75          </SQL>
   76       </Command>
   77 
   78       <!-- ================================================================= -->
   79       <!-- DBA related commands requiring certain privileges in the database -->
   80       <!-- ================================================================= -->
   81 
   82       <Command id="postgresql.getUsers">
   83          <SQL>
   84             <![CDATA[
   85 select * from pg_user
   86             ]]>
   87          </SQL>
   88       </Command>
   89 
   90       <Command id="postgresql.getGroups">
   91          <SQL>
   92             <![CDATA[
   93 select * from pg_group
   94             ]]>
   95          </SQL>
   96       </Command>
   97 
   98       <Command id="postgresql.getSettings">
   99          <SQL>
  100             <![CDATA[
  101 select * from pg_settings
  102             ]]>
  103          </SQL>
  104       </Command>
  105 
  106       <Command id="postgresql.getSessions">
  107          <SQL>
  108             <![CDATA[
  109 select * from pg_stat_activity
  110             ]]>
  111          </SQL>
  112       </Command>
  113 
  114       <Command id="postgresql.getLocks">
  115          <SQL>
  116             <![CDATA[
  117 select * from pg_locks
  118             ]]>
  119          </SQL>
  120       </Command>
  121 
  122    </Commands>
  123 
  124    <!-- =================================================================== -->
  125    <!-- Definition of the object actions that are used by the tree and views -->
  126    <!-- =================================================================== -->
  127 
  128    <ObjectsActionDef extends="false">
  129 
  130       <ActionGroup type="Tables">
  131          <Action id="postgresql-tables-create-table" label="Create Table"
  132                  icon="add" reload="true"
  133                  class="tableCreateOrAlter"
  134                  classargs="create"/>
  135       </ActionGroup>
  136 
  137       <ActionGroup type="Table">
  138          <Action id="postgresql-tables-alter-table" label="Alter Table"
  139                  icon="edit" reload="true"
  140                  class="tableCreateOrAlter"
  141                  classargs="alter"/>
  142 
  143          <Action id="postgresql-table-create-index" label="Create Index" reload="true">
  144             <Input label="Table" style="text" editable="false">
  145                <Default>${objectname}</Default>
  146             </Input>
  147             <Input label="Index Name" name="indexname" style="text"/>
  148             <Input label="Unique" name="unique" style="check">
  149                <Values>unique</Values>
  150             </Input>
  151 
  152             <Input label="Columns" style="separator"/>
  153 
  154             <Input name="columns" style="grid">
  155                <Arg name="output" value='"${columnname}"${_sortorder}'/>
  156                <Arg name="newline" value=", "/>
  157 
  158                <Input name="columnname" label="Column Name" style="list">
  159                   <Values column="4">
  160                      <Command idref="getColumnNamesFor">
  161                         <Input name="table_catalog" value="${catalog}"/>
  162                         <Input name="table_schema" value="${schema}"/>
  163                         <Input name="table_name" value="${objectname}"/>
  164                      </Command>
  165                   </Values>
  166                   <Default>${0}</Default>
  167                </Input>
  168                <Input name="sortorder" label="Sort Order" style="radio">
  169                   <Labels>ASC|DESC|Default</Labels>
  170                   <Values>ASC|DESC|</Values>
  171                   <Default>ASC</Default>
  172                </Input>
  173                <SetVar name="_sortorder" value='#sortorder.equals("") ? "" : " " + #sortorder'/>
  174             </Input>
  175 
  176             <SetVar name="_unique" value='#unique.equals("") ? "" : " " + #unique'/>
  177             <SetVar name="_columns" value='#columns.trim().equals("") ? "" : "(" + #columns + ")"'/>
  178             <SetVar name="_indexname" value='#indexname.trim().equals("") ? "" : " \"" + #indexname + "\""'/>
  179 
  180             <Command>
  181                <SQL>
  182                   <![CDATA[create${_unique} index${_indexname} on "${objectname}" ${_columns}]]>
  183                </SQL>
  184             </Command>
  185             <Confirm>
  186                <![CDATA[Create index "${indexname}"?]]>
  187             </Confirm>
  188             <Result>
  189                <![CDATA[Index "${indexname}" created!]]>
  190             </Result>
  191          </Action>
  192 
  193          <Action id="postgresql-table-import-table-data" label="Import Table Data" icon="import"
  194                  class="tableDataImport"/>
  195 
  196          <Action id="postgresql-table-export" label="Export Table" icon="export"
  197                  class="tableExport"
  198                  doclink="http://www.dbvis.com/doclink/export-table"/>
  199 
  200          <Separator/>
  201 
  202          <Action id="postgresql-table-script" label="Script Table" icon="scriptObject"
  203                  class="sqlBuilder"
  204                  classargs="script-dialog,SELECT,SELECT *,INSERT,UPDATE,DELETE,CREATE,DROP"/>
  205 
  206       </ActionGroup>
  207 
  208       <ActionGroup type="Index">
  209          <Action id="postgresql-index-drop" label="Drop Index" reload="true" icon="remove">
  210             <Input label="Index" style="text" editable="false">
  211                <Default>${objectname}</Default>
  212             </Input>
  213             <Command><SQL><![CDATA[drop index ${objectname}]]></SQL></Command>
  214             <Confirm>
  215                Really drop index "${objectname}"?
  216             </Confirm>
  217             <Result>
  218                Index "${objectname}" dropped!
  219             </Result>
  220          </Action>
  221       </ActionGroup>
  222 
  223    </ObjectsActionDef>
  224 
  225    <!-- =================================================================== -->
  226    <!-- Definition of the database objects tree structure -->
  227    <!-- PostgreSQL only allows browsing default database specified in the -->
  228    <!-- URL. This definition simply makes non default databases  -->
  229    <!-- e.g catalogs as leaf nodes. -->
  230    <!-- All nodes below the default database is listed as owner.object -->
  231    <!-- =================================================================== -->
  232 
  233    <ObjectsTreeDef extends="false">
  234 
  235       <GroupNode type="Databases" label="Databases">
  236          <DataNode type="Catalog" label="${getCatalogs.TABLE_CAT}" drop-label-not-equal="${dbvis-defaultCatalogOrSchema}">
  237             <SetVar name="catalog" value="${getCatalogs.TABLE_CAT}"/>
  238             <Command idref="getCatalogs">
  239                <Filter index="TABLE_CAT" label="Name"/>
  240             </Command>
  241 
  242             <DataNode type="Tables" label="${getTableTypes.TABLE_TYPE}" is-empty-output="continue">
  243                <SetVar name="tableType" value="${getTableTypes.TABLE_TYPE}"/>
  244                <Command idref="getTableTypes"/>
  245 
  246                <!-- PostgreSQL 7.2 and older versions doesn't support schemas -->
  247                <!-- Note: The PostgresSQL driver doesn't implement            -->
  248                <!--       #dm.getDatabaseMajor/Minor -version ... that's why  -->
  249                <!--       the not so optimal use of startsWith()              -->
  250                <If test="#dm.getDatabaseProductVersion().startsWith('7.0') or
  251                          #dm.getDatabaseProductVersion().startsWith('7.1') or
  252                          #dm.getDatabaseProductVersion().startsWith('7.2')">
  253                   <DataNode type="Table" label="${getTables.TABLE_NAME}">
  254                      <SetVar name="objectname" value="${getTables.TABLE_NAME}"/>
  255                      <SetVar name="rowcount" value="true"/>
  256                      <SetVar name="acceptInQB" value="true"/>
  257                      <Command idref="getTables">
  258                         <Input name="catalog" value="${catalog}"/>
  259                         <Input name="objectname" value="%"/>
  260                         <Input name="tableType" value="${tableType}"/>
  261                      </Command>
  262 
  263                      <!-- Need to keep the objectname for the current table in
  264                        a new variable so that the viewers will be able to pick up
  265                        the correct input to display -->
  266                      <SetVar name="theTableName" value="${objectname}"/>
  267 
  268                      <GroupNode type="Columns" label="Columns">
  269                         <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
  270                                   label1="${getColumnDefinitions.TYPE_NAME}"
  271                                   isLeaf="true" 
  272                                   icon="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'PrimaryKey' : 'Column'"
  273                                   tip="#dataMap.get('getColumnDefinitions.IS_PRIMARY_KEY') eq true ? 'This is a primary key column' : ''">
  274                            <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
  275                            <Command idref="getColumnDefinitions">
  276                               <Input name="schema" value="${schema}"/>
  277                               <Input name="objectname" value="${theTableName}"/>
  278                               <Input name="tableType" value="Table"/>
  279                               <Filter index="TYPE_NAME" label="Type"/>
  280                            </Command>
  281                         </DataNode>
  282                      </GroupNode>
  283 
  284                      <GroupNode type="Indexes" label="Indexes">
  285                         <DataNode type="Index" label="${getIndexes.INDEX_NAME}"
  286                                   label1="${getIndexes.ORDINAL_POSITION}:${getIndexes.COLUMN_NAME}"
  287                                   isLeaf="true">
  288                            <SetVar name="objectname" value="${getIndexes.INDEX_NAME}"/>
  289                            <Command idref="getIndexes">
  290                               <Input name="catalog" value="${catalog}"/>
  291                               <Input name="objectname" value="${theTableName}"/>
  292                               <ProcessDataSet action="removeisnullrows" index="INDEX_NAME"/>
  293                            </Command>
  294                         </DataNode>
  295                      </GroupNode>
  296                   </DataNode>
  297                </If>
  298                <Else>
  299                   <DataNode type="Table" label="${getTables.TABLE_SCHEM}.${getTables.TABLE_NAME}">
  300                      <SetVar name="schema" value="${getTables.TABLE_SCHEM}"/>
  301                      <SetVar name="objectname" value="${getTables.TABLE_NAME}"/>
  302                      <SetVar name="rowcount" value="true"/>
  303                      <SetVar name="acceptInQB" value="true"/>
  304                      <Command idref="getTables">
  305                         <Input name="catalog" value="${catalog}"/>
  306                         <Input name="objectname" value="%"/>
  307                         <Input name="tableType" value="${tableType}"/>
  308                      </Command>
  309 
  310                      <!-- Need to keep the objectname for the current table in
  311                        a new variable so that the viewers will be able to pick up
  312                        the correct input to display -->
  313                      <SetVar name="theTableName" value="${objectname}"/>
  314 
  315                      <GroupNode type="Columns" label="Columns">
  316                         <DataNode type="Column" label="${getColumnDefinitions.COLUMN_NAME}"
  317                                   label1="${getColumnDefinitions.TYPE_NAME}"
  318                                   isLeaf="true">
  319                            <SetVar name="objectname" value="${getColumnDefinitions.COLUMN_NAME}"/>
  320                            <Command idref="getColumnDefinitions">
  321                               <Input name="schema" value="${schema}"/>
  322                               <Input name="objectname" value="${theTableName}"/>
  323                               <Input name="tableType" value="Table"/>
  324                               <Filter index="TYPE_NAME" label="Type"/>
  325                            </Command>
  326                         </DataNode>
  327                      </GroupNode>
  328 
  329                      <GroupNode type="Indexes" label="Indexes">
  330                         <DataNode type="Index" label="${getIndexes.INDEX_NAME}"
  331                                   label1="${getIndexes.ORDINAL_POSITION}:${getIndexes.COLUMN_NAME}"
  332                                   isLeaf="true">
  333                            <SetVar name="objectname" value="${getIndexes.INDEX_NAME}"/>
  334                            <Command idref="getIndexes">
  335                               <Input name="catalog" value="${catalog}"/>
  336                               <Input name="schema" value="${schema}"/>
  337                               <Input name="objectname" value="${theTableName}"/>
  338                               <ProcessDataSet action="removeisnullrows" index="INDEX_NAME"/>
  339                            </Command>
  340                         </DataNode>
  341                      </GroupNode>
  342                   </DataNode>
  343                </Else>
  344             </DataNode>
  345 
  346             <GroupNode type="Procedures" label="Functions">
  347                <DataNode type="Procedure" label="${getProcedures.PROCEDURE_SCHEM}.${getProcedures.PROCEDURE_NAME}" isLeaf="true">
  348                   <SetVar name="schema" value="${getProcedures.PROCEDURE_SCHEM}"/>
  349                   <SetVar name="objectname" value="${getProcedures.PROCEDURE_NAME}"/>
  350                   <Command idref="getProcedures">
  351                      <Input name="catalog" value="${catalog}"/>
  352                      <Input name="schema" value="${schema}"/>
  353                      <Filter index="PROCEDURE_NAME" label="Name"/>
  354                   </Command>
  355                </DataNode>
  356             </GroupNode>
  357          </DataNode>
  358       </GroupNode>
  359 
  360       <GroupNode type="DBA" label="DBA Views">
  361          <GroupNode type="Users" label="Users">
  362             <DataNode type="User" label="${postgresql.getUsers.usename}" isLeaf="true">
  363                <SetVar name="objectname" value="${postgresql.getUsers.usename}"/>
  364                <Command idref="postgresql.getUsers"/>
  365             </DataNode>
  366          </GroupNode>
  367          <GroupNode type="Groups" label="Groups">
  368             <DataNode type="Group" label="${postgresql.getGroups.groname}" isLeaf="true">
  369                <SetVar name="objectname" value="${postgresql.getGroups.groname}"/>
  370                <Command idref="postgresql.getGroups"/>
  371             </DataNode>
  372          </GroupNode>
  373          <GroupNode type="Settings" label="Settings" isLeaf="true"/>
  374          <GroupNode type="Locks" label="Locks" isLeaf="true"/>
  375          <GroupNode type="Sessions" label="Sessions" isLeaf="true"/>
  376       </GroupNode>
  377 
  378    </ObjectsTreeDef>
  379 
  380    <!-- =================================================================== -->
  381    <!-- Definition of the database objects views -->
  382    <!-- =================================================================== -->
  383 
  384    <ObjectsViewDef extends="true">
  385 
  386       <ObjectView type="Databases">
  387          <DataView id="postgresql-databases-databases" icon="Catalog" label="Databases" viewer="grid">
  388             <Command idref="postgresql.getCatalogs"/>
  389             <Message>
  390                <![CDATA[
  391 <html>
  392 List of all available databases in the database server. Only the default
  393 database can be browsed in DbVisualizer. To browse any of the other databases
  394 then supply the name for it in the URL during connect.
  395 </html>
  396                ]]>
  397             </Message>
  398          </DataView>
  399       </ObjectView>
  400 
  401       <ObjectView type="Catalog" action="drop"/>
  402 
  403       <ObjectView type="Tables">
  404          <DataView id="generic-tables-tables" action="drop"/>
  405          <DataView id="generic-tables-references" action="drop"/>
  406          
  407          <DataView id="postgresql-tables-tables" icon="Tables" label="Tables" viewer="grid">
  408             <Input name="menuItem" value="Open in New Tab...">
  409                <Input name="action" value="open-object-in-new-tab-command ${schema||table_schem}${object||table_name}"/>
  410             </Input>
  411             <Input name="menuItem" value="Open in Floating Tab...">
  412                <Input name="action" value="open-object-in-floating-tab-command ${catalog||table_schem}${object||table_name}"/>
  413             </Input>
  414             <Input name="menuItem" value="Script: SELECT ALL">
  415                <Input name="command" value="select * from ${schema||table_schem}${object||table_name}"/>
  416             </Input>
  417             <Input name="menuItem" value="Script: DROP TABLE">
  418                <Input name="command" value="drop table ${schema||table_schem}${object||table_name}"/>
  419             </Input>
  420             <Command idref="getTables">
  421                <Input name="catalog" value="${catalog}"/>
  422                <Input name="schema" value="${schema}"/>
  423                <Input name="objectname" value="%"/>
  424                <Input name="tableType" value="${tableType}"/>
  425             </Command>
  426          </DataView>
  427          <DataView id="postgresql-tables-references" icon="References" label="References" viewer="tables-refs">
  428             <Command idref="getTables">
  429                <Input name="catalog" value="${catalog}"/>
  430                <Input name="schema" value="${schema}"/>
  431                <Input name="objectname" value="%"/>
  432                <Input name="tableType" value="${tableType}"/>
  433             </Command>
  434          </DataView>
  435       </ObjectView>
  436 
  437       <ObjectView type="Table">
  438          <DataView id="generic-table-ddl">
  439             <Input name="formatSQL" value="true"/>
  440             <Message/>
  441          </DataView>
  442       </ObjectView>
  443 
  444       <!-- DBA views -->
  445 
  446       <ObjectView type="Users">
  447          <DataView id="postgresql-users-users" icon="Users" label="Users" viewer="grid">
  448             <Command idref="postgresql.getUsers"/>
  449          </DataView>
  450       </ObjectView>
  451 
  452       <ObjectView type="User">
  453          <DataView id="postgresql-user-info" icon="Info" label="Info" viewer="node-form"/>
  454       </ObjectView>
  455 
  456       <ObjectView type="Groups">
  457          <DataView id="postgresql-groups-groups" icon="Groups" label="Groups" viewer="grid">
  458             <Command idref="postgresql.getGroups"/>
  459          </DataView>
  460       </ObjectView>
  461 
  462       <ObjectView type="Group">
  463          <DataView id="postgresql-group-info" icon="Info" label="Info" viewer="node-form"/>
  464       </ObjectView>
  465 
  466       <ObjectView type="Settings">
  467          <DataView id="postgresql-settings-settings" icon="Settings" label="Settings" viewer="grid">
  468             <Command idref="postgresql.getSettings"/>
  469          </DataView>
  470       </ObjectView>
  471 
  472       <ObjectView type="Sessions">
  473          <DataView id="postgresql-sessions-sessions" icon="Sessions" label="Sessions" viewer="grid">
  474             <Command idref="postgresql.getSessions"/>
  475          </DataView>
  476       </ObjectView>
  477 
  478       <ObjectView type="Locks">
  479          <DataView id="postgresql-locks-locks" icon="Locks" label="Locks" viewer="grid">
  480             <Command idref="postgresql.getLocks"/>
  481          </DataView>
  482       </ObjectView>
  483 
  484    </ObjectsViewDef>
  485 
  486 </DatabaseProfile>