~ubuntu-branches/ubuntu/wily/tora/wily-proposed

« back to all changes in this revision

Viewing changes to src/tobrowserindexwidget.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-09-11 12:37:52 UTC
  • mfrom: (1.2.8 upstream) (3.3.2 sid)
  • Revision ID: james.westby@ubuntu.com-20090911123752-qhu322xlclo2hpqu
Tags: 2.1.0-1
* New upstream version, the rebuild closes: #540046.
* Bumped Standards-Version to 3.8.3, no changes needed.
* New project homepage.
* Removed no longer needed 01_missing_includes.dpatch.
* Removed no longer used dh_desktop call.
* Added README.source file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* BEGIN_COMMON_COPYRIGHT_HEADER
 
3
 *
 
4
 * TOra - An Oracle Toolkit for DBA's and developers
 
5
 * 
 
6
 * Shared/mixed copyright is held throughout files in this product
 
7
 * 
 
8
 * Portions Copyright (C) 2000-2001 Underscore AB
 
9
 * Portions Copyright (C) 2003-2005 Quest Software, Inc.
 
10
 * Portions Copyright (C) 2004-2009 Numerous Other Contributors
 
11
 * 
 
12
 * This program is free software; you can redistribute it and/or
 
13
 * modify it under the terms of the GNU General Public License
 
14
 * as published by the Free Software Foundation;  only version 2 of
 
15
 * the License is valid for this program.
 
16
 * 
 
17
 * This program is distributed in the hope that it will be useful,
 
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
20
 * GNU General Public License for more details.
 
21
 * 
 
22
 * You should have received a copy of the GNU General Public License
 
23
 * along with this program; if not, write to the Free Software
 
24
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 
25
 * 
 
26
 *      As a special exception, you have permission to link this program
 
27
 *      with the Oracle Client libraries and distribute executables, as long
 
28
 *      as you follow the requirements of the GNU GPL in regard to all of the
 
29
 *      software in the executable aside from Oracle client libraries.
 
30
 * 
 
31
 *      Specifically you are not permitted to link this program with the
 
32
 *      Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
 
33
 *      And you are not permitted to distribute binaries compiled against
 
34
 *      these libraries. 
 
35
 * 
 
36
 *      You may link this product with any GPL'd Qt library.
 
37
 * 
 
38
 * All trademarks belong to their respective owners.
 
39
 *
 
40
 * END_COMMON_COPYRIGHT_HEADER */
 
41
 
 
42
#include "tobrowserbasewidget.h"
 
43
#include "toresultextract.h"
 
44
#include "toresultitem.h"
 
45
#include "toresulttableview.h"
 
46
#include "tostorage.h"
 
47
#include "utils.h"
 
48
 
 
49
#include "tobrowserindexwidget.h"
 
50
 
 
51
 
 
52
static toSQL SQLIndexColsMySQL("toBrowser:IndexCols",
 
53
                               "SHOW INDEX FROM `:f1<noquote>`.`:f2<noquote>`",
 
54
                               "Display columns on which an index is built",
 
55
                               "3.23",
 
56
                               "MySQL");
 
57
static toSQL SQLIndexCols("toBrowser:IndexCols",
 
58
                          "SELECT a.Table_Name,a.Column_Name,a.Column_Length,a.Descend,b.Column_Expression \" \"\n"
 
59
                          "  FROM sys.All_Ind_Columns a,sys.All_Ind_Expressions b\n"
 
60
                          " WHERE a.Index_Owner = :f1<char[101]> AND a.Index_Name = :f2<char[101]>\n"
 
61
                          "   AND a.Index_Owner = b.Index_Owner(+) AND a.Index_Name = b.Index_Name(+)\n"
 
62
                          "   AND a.column_Position = b.Column_Position(+)\n"
 
63
                          " ORDER BY a.Column_Position",
 
64
                          "",
 
65
                          "0801");
 
66
static toSQL SQLIndexCols8("toBrowser:IndexCols",
 
67
                           "SELECT Table_Name,Column_Name,Column_Length,Descend\n"
 
68
                           "  FROM SYS.ALL_IND_COLUMNS\n"
 
69
                           " WHERE Index_Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>\n"
 
70
                           " ORDER BY Column_Position",
 
71
                           "",
 
72
                           "0800");
 
73
static toSQL SQLIndexCols7("toBrowser:IndexCols",
 
74
                           "SELECT Table_Name,Column_Name,Column_Length\n"
 
75
                           "  FROM SYS.ALL_IND_COLUMNS\n"
 
76
                           " WHERE Index_Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>\n"
 
77
                           " ORDER BY Column_Position",
 
78
                           "",
 
79
                           "0703");
 
80
static toSQL SQLIndexColsPgSQL("toBrowser:IndexCols",
 
81
                               "SELECT a.attname,\n"
 
82
                               "       format_type(a.atttypid, a.atttypmod) as FORMAT,\n"
 
83
                               "       a.attnotnull,\n"
 
84
                               "       a.atthasdef\n"
 
85
                               "  FROM pg_class c LEFT OUTER JOIN pg_namespace n ON c.relnamespace=n.oid,\n"
 
86
                               "       pg_attribute a\n"
 
87
                               " WHERE (n.nspname = :f1 OR n.oid IS NULL)\n"
 
88
                               "   AND a.attrelid = c.oid AND c.relname = :f2\n"
 
89
                               "   AND a.attnum > 0\n"
 
90
                               " ORDER BY a.attnum\n",
 
91
                               "",
 
92
                               "7.1",
 
93
                               "PostgreSQL");
 
94
static toSQL SQLIndexColsSapDb("toBrowser:IndexCols",
 
95
                               "SELECT tablename,columnname,len \"Length\",DataType,Sort \n"
 
96
                               " FROM indexcolumns \n"
 
97
                               " WHERE  owner = upper(:f1<char[101]>) and indexname = upper(:f2<char[101]>)\n"
 
98
                               " ORDER BY indexname,columnno",
 
99
                               "",
 
100
                               "",
 
101
                               "SapDB");
 
102
 
 
103
static toSQL SQLIndexInfoSapDb("toBrowser:IndexInformation",
 
104
                               "SELECT  INDEXNAME,TABLENAME, TYPE, CREATEDATE,CREATETIME,INDEX_USED, DISABLED \n"
 
105
                               " FROM indexes\n"
 
106
                               " WHERE  owner = upper(:f1<char[101]>) and indexname = :f2<char[101]>\n",
 
107
                               "Display information about an index",
 
108
                               "",
 
109
                               "SapDB");
 
110
static toSQL SQLIndexInfo("toBrowser:IndexInformation",
 
111
                          "SELECT * FROM SYS.ALL_INDEXES\n"
 
112
                          " WHERE Owner = :f1<char[101]> AND Index_Name = :f2<char[101]>",
 
113
                          "");
 
114
static toSQL SQLIndexStatistic("toBrowser:IndexStatstics",
 
115
                               "SELECT description \"Description\", value(char_value,numeric_value) \"Value\" \n"
 
116
                               " FROM indexstatistics \n"
 
117
                               " WHERE owner = upper(:f1<char[101]>) and indexname = :f2<char[101]>",
 
118
                               "Index Statistics",
 
119
                               "",
 
120
                               "SapDB");
 
121
 
 
122
 
 
123
 
 
124
toBrowserIndexWidget::toBrowserIndexWidget(QWidget * parent)
 
125
    : toBrowserBaseWidget(parent)
 
126
{
 
127
    setObjectName("toBrowserIndexWidget");
 
128
 
 
129
    columnView = new toResultTableView(this);
 
130
    columnView->setObjectName("columnView");
 
131
    columnView->setSQL(SQLIndexCols);
 
132
    columnView->setReadAll(true);
 
133
 
 
134
    resultInfo = new toResultItem(this);
 
135
    resultInfo->setObjectName("resultInfo");
 
136
    resultInfo->setSQL(SQLIndexInfo);
 
137
 
 
138
    extentsView = new toResultExtent(this);
 
139
    extentsView->setObjectName("extentsView");
 
140
 
 
141
    extractView = new toResultExtract(this);
 
142
    extractView->setObjectName("extractView");
 
143
 
 
144
    statisticView = new toResultTableView(this);
 
145
    statisticView->setObjectName("statisticView");
 
146
    statisticView->setSQL(SQLIndexStatistic);
 
147
    statisticView->setReadAll(true);
 
148
 
 
149
    changeConnection();
 
150
}
 
151
 
 
152
void toBrowserIndexWidget::changeConnection()
 
153
{
 
154
    toBrowserBaseWidget::changeConnection();
 
155
 
 
156
    toConnection & c = toCurrentConnection(this);
 
157
 
 
158
    addTab(columnView, "&Columns");
 
159
 
 
160
    if (toIsOracle(c) || toIsSapDB(c))
 
161
        addTab(resultInfo, "Informations");
 
162
    else
 
163
        resultInfo->hide();
 
164
 
 
165
    if (toIsOracle(c))
 
166
        addTab(extentsView, "Extents");
 
167
    else
 
168
        extentsView->hide();
 
169
 
 
170
    if (toIsSapDB(c))
 
171
        addTab(statisticView, tr("&Statistic"));
 
172
    else
 
173
        statisticView->hide();
 
174
 
 
175
    if (toIsOracle(c))
 
176
        addTab(extractView, "Script");
 
177
    else
 
178
        extractView->hide();
 
179
}