2
/* BEGIN_COMMON_COPYRIGHT_HEADER
4
* TOra - An Oracle Toolkit for DBA's and developers
6
* Shared/mixed copyright is held throughout files in this product
8
* Portions Copyright (C) 2000-2001 Underscore AB
9
* Portions Copyright (C) 2003-2005 Quest Software, Inc.
10
* Portions Copyright (C) 2004-2008 Numerous Other Contributors
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.
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.
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.
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.
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
36
* You may link this product with any GPL'd Qt library.
38
* All trademarks belong to their respective owners.
40
* END_COMMON_COPYRIGHT_HEADER */
45
#include "toeventquerytask.h"
46
#include "toresultstats.h"
48
#include "toresultstats.h"
49
#include "toconfiguration.h"
51
#include <QApplication>
52
#include <QMutexLocker>
56
static const int FIREWALL_TIMEOUT = 240000;
60
catch(const toConnection::exception &str) { \
66
catch(const QString &str) { \
74
emit error(tr("Unknown exception")); \
80
toEventQueryTask::toEventQueryTask(QObject *parent,
93
setObjectName("toEventQueryTask");
97
void toEventQueryTask::run(void) {
99
Query = new toQuery(*Connection);
100
Query->execute(SQL, Params);
103
SIGNAL(readRequested(bool)),
106
Qt::QueuedConnection);
108
toQDescList desc = Query->describe();
109
Columns = Query->columns();
110
emit headers(desc, Columns);
120
if(toConfigurationSingle::Instance().firewallMode())
121
QTimer::singleShot(FIREWALL_TIMEOUT, this, SLOT(timeout()));
123
// begin thread's event loop
133
Statistics->changeSession(*Query);
140
QMutexLocker lock(&CloseLock);
153
toEventQueryTask::~toEventQueryTask() {
157
void toEventQueryTask::close() {
161
disconnect(this, 0, 0, 0);
163
QMutexLocker lock(&CloseLock);
173
// exit thread event loop. safe to call before event loop starts.
179
void toEventQueryTask::read(bool all) {
180
emit readRequested(all);
184
void toEventQueryTask::pread(bool all) {
185
if(!Query || Columns < 1) {
190
int maxRead = toConfigurationSingle::Instance().maxNumber();
196
for(int row = 0; row < maxRead; row++) {
197
for(int i = 0; i < Columns && !Query->eof(); i++)
198
values.append(Query->readValueNull());
201
if(values.size() > 0)
202
emit data(values); // must not access after this line
203
} while(all && !Query->eof());
208
if(!Query || Query->eof())
215
void toEventQueryTask::timeout()
222
// check again in case config changes
223
if(toConfigurationSingle::Instance().firewallMode())
224
QTimer::singleShot(FIREWALL_TIMEOUT, this, SLOT(timeout()));