3
* TOra - An Oracle Toolkit for DBA's and developers
4
* Copyright (C) 2003-2005 Quest Software, Inc
5
* Portions Copyright (C) 2005 Other Contributors
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; only version 2 of
10
* the License is valid for this program.
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
17
* You should have received a copy of the GNU General Public License
18
* along with this program; if not, write to the Free Software
19
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21
* As a special exception, you have permission to link this program
22
* with the Oracle Client libraries and distribute executables, as long
23
* as you follow the requirements of the GNU GPL in regard to all of the
24
* software in the executable aside from Oracle client libraries.
26
* Specifically you are not permitted to link this program with the
27
* Qt/UNIX, Qt/Windows or Qt Non Commercial products of TrollTech.
28
* And you are not permitted to distribute binaries compiled against
29
* these libraries without written consent from Quest Software, Inc.
30
* Observe that this does not disallow linking to the Qt Free Edition.
32
* You may link this product with any GPL'd Qt library such as Qt/Free
34
* All trademarks belong to their respective owners.
40
#include "tochangeconnection.h"
42
#include "toconnection.h"
43
#include "toextract.h"
44
#include "tohighlightedtext.h"
45
#include "totemporary.h"
47
#include "toresultextract.h"
48
#include "toresultlong.h"
49
#include "toresultview.h"
50
#include "tosgastatement.h"
55
# include <kmenubar.h>
59
#include <qlineedit.h>
62
#include <qpopupmenu.h>
63
#include <qprogressdialog.h>
64
#include <qsplitter.h>
66
#include <qtoolbutton.h>
67
#include <qworkspace.h>
69
#include "totemporary.moc"
71
#include "icons/refresh.xpm"
72
#include "icons/totemporary.xpm"
74
static toSQL SQLListTemporaryObjects("toTemporary:ListTemporaryObjects",
75
"SELECT s.sid || ',' || s.serial# \"Session\",\n"
76
" s.username \"User\",\n"
77
" u.TABLESPACE \"Tablespace\",\n"
78
" segtype \"Type\",\n"
79
" substr ( a.sql_text,1,50 ) \"SQL\",\n"
80
" round ( u.blocks * p.value / :siz<int>,2 )||:sizstr<char[50]> \"Size\",\n"
81
" s.sql_address || ':' || s.sql_hash_value \" \"\n"
82
" FROM v$sort_usage u,\n"
86
" WHERE s.saddr = u.session_addr\n"
87
" AND a.address ( + ) = s.sql_address\n"
88
" AND a.hash_value ( + ) = s.sql_hash_value\n"
89
" AND p.name = 'db_block_size'",
90
"Get temporary usage.", "0800");
92
static toSQL SQLListTemporaryObjects9("toTemporary:ListTemporaryObjects",
93
"SELECT s.sid || ',' || s.serial# \"Session\",\n"
94
" s.username \"User\",\n"
95
" u.TABLESPACE \"Tablespace\",\n"
96
" u.segtype \"Type\",\n"
97
" substr ( a.sql_text,1,50 ) \"SQL\",\n"
98
" round ( u.blocks * p.value / :siz<int>,2 )||:sizstr<char[50]> \"Size\",\n"
99
" s.sql_address || ':' || s.sql_hash_value \" \"\n"
100
" FROM v$tempseg_usage u,\n"
104
" WHERE s.saddr = u.session_addr\n"
105
" AND a.address ( + ) = s.sql_address\n"
106
" AND a.hash_value ( + ) = s.sql_hash_value\n"
107
" AND p.name = 'db_block_size'",
111
class toTemporaryTool : public toTool
113
virtual const char **pictureXPM(void)
115
return const_cast<const char**>(totemporary_xpm);
119
: toTool(130, "Temporary Objects")
121
virtual const char *menuItem()
123
return "Temporary Objects";
125
virtual QWidget *toolWindow(QWidget *parent, toConnection &connection)
127
return new toTemporary(parent, connection);
129
virtual bool canHandle(toConnection &conn)
131
if (!toIsOracle(conn))
133
if (conn.version() < "0800")
139
static toTemporaryTool TemporaryTool;
141
toTemporary::toTemporary(QWidget *main, toConnection &connection)
142
: toToolWidget(TemporaryTool, "temporary.html", main, connection)
144
QToolBar *toolbar = toAllocBar(this, tr("Temporary Objects"));
146
new QToolButton(QPixmap(const_cast<const char**>(refresh_xpm)),
149
this, SLOT(refresh()),
152
toolbar->setStretchableWidget(new QLabel(toolbar, TO_KDE_TOOLBAR_WIDGET));
153
new toChangeConnection(toolbar, TO_KDE_TOOLBAR_WIDGET);
155
QSplitter *splitter = new QSplitter(Vertical, this);
157
Objects = new toResultLong(false, false, toQuery::Background, splitter);
158
QString unit = toTool::globalConfig(CONF_SIZE_UNIT, DEFAULT_SIZE_UNIT);
160
toPush(args, toQValue(toSizeDecode(unit)));
161
toPush(args, toQValue(unit));
163
Objects->setSelectionMode(QListView::Single);
164
Objects->query(SQLListTemporaryObjects, args);
165
connect(Objects, SIGNAL(selectionChanged(QListViewItem *)),
166
this, SLOT(changeItem(QListViewItem *)));
168
Statement = new toSGAStatement(splitter);
171
connect(toMainWidget()->workspace(), SIGNAL(windowActivated(QWidget *)),
172
this, SLOT(windowActivated(QWidget *)));
174
setFocusProxy(Objects);
178
void toTemporary::windowActivated(QWidget *widget)
184
ToolMenu = new QPopupMenu(this);
185
ToolMenu->insertItem(QPixmap(const_cast<const char**>(refresh_xpm)), tr("&Refresh"),
186
this, SLOT(refresh(void)),
187
toKeySequence(tr("F5", "Temporary|Refresh")));
189
toMainWidget()->menuBar()->insertItem(tr("&Temporary"), ToolMenu, -1, toToolMenuIndex());
199
void toTemporary::refresh(void)
204
void toTemporary::changeItem(QListViewItem *item)
207
Statement->changeAddress(item->text(Objects->columns()));