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

« back to all changes in this revision

Viewing changes to src/tonoblockquery.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michael Meskes
  • Date: 2009-04-07 13:16:05 UTC
  • mfrom: (1.2.7 upstream) (3.1.3 sid)
  • Revision ID: james.westby@ubuntu.com-20090407131605-u422yigfv7jgg0l0
Tags: 2.0.0-3
* Cleaned up packaging a little bit.
* Added homepage information to control file.
* Bumped Standards-Version to 3.8.1.
* Released to unstable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*****
2
 
*
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
6
 
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.
11
 
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.
16
 
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.
20
 
*
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.
25
 
*
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.
31
 
*
32
 
*      You may link this product with any GPL'd Qt library such as Qt/Free
33
 
*
34
 
* All trademarks belong to their respective owners.
35
 
*
36
 
*****/
 
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-2008 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 */
37
41
 
38
42
#include "utils.h"
39
43
 
46
50
 
47
51
#include <signal.h>
48
52
#include <sys/types.h>
49
 
#ifndef WIN32
 
53
#ifndef Q_OS_WIN32
50
54
#include <unistd.h>
51
55
#endif
52
56
#include <stdio.h>
64
68
        bool eof = true;
65
69
        {
66
70
            toLocker lock (Parent.Lock)
67
 
                ;
 
71
            ;
68
72
            if (Parent.Query)
69
73
            {
70
74
                Parent.Description = Parent.Query->describe();
83
87
                    toQValue value(Parent.Query->readValueNull());
84
88
                    {
85
89
                        toLocker lock (Parent.Lock)
86
 
                            ;
 
90
                        ;
87
91
                        Parent.ReadingValues.insert(Parent.ReadingValues.end(), value);
88
92
                        if (Parent.ReadingValues.size() == 1)
89
93
                        {
99
103
                    }
100
104
                }
101
105
                toLocker lock (Parent.Lock)
102
 
                    ;
 
106
                ;
103
107
                if (!Parent.Query || Parent.Query->eof())
104
108
                    break;
105
109
                else
124
128
    catch (const toConnection::exception &str)
125
129
    {
126
130
        toLocker lock (Parent.Lock)
127
 
            ;
 
131
        ;
128
132
        Parent.Error = str;
129
133
    }
130
134
    catch (const QString &str)
131
135
    {
132
136
        toLocker lock (Parent.Lock)
133
 
            ;
 
137
        ;
134
138
        Parent.Error = str;
135
139
    }
136
140
    catch (...)
137
141
    {
138
142
        toLocker lock (Parent.Lock)
139
 
            ;
 
143
        ;
140
144
        Parent.Error = qApp->translate("toNoBlockQuery", "Unknown exception");
141
145
    }
142
146
 
143
147
    toLocker lock (Parent.Lock)
144
 
        ;
145
 
    if (!Parent.Error && !Parent.Query->eof())
 
148
    ;
 
149
    if (!Parent.Error.isNull() && !Parent.Query->eof())
146
150
        try
147
151
        {
148
152
            Parent.Query->cancel();
149
153
        }
150
154
        catch (...)
151
 
        {}
 
155
            {}
152
156
    delete Parent.Query;
153
157
    Parent.Query = NULL;
154
158
    Parent.Running.up();
165
169
        if (!eoq)
166
170
            Running.down();
167
171
        toLocker lock (Lock)
168
 
            ;
 
172
        ;
169
173
        Values = ReadingValues;
170
174
        CurrentValue = Values.begin();
171
175
        ReadingValues.clear();
205
209
        delete Query;
206
210
        Query = NULL;
207
211
        Error = qApp->translate("toNoBlockQuery", "Couldn't open query");
208
 
        return ;
 
212
        throw;
209
213
    }
210
214
 
211
215
    try
218
222
        Statistics = NULL;
219
223
    }
220
224
 
221
 
    int val = toConfigurationSingle::Instance().globalConfig(CONF_AUTO_LONG, "0").toInt();
 
225
    int val = toConfigurationSingle::Instance().autoLong();
222
226
    if (val != 0)
223
227
        Started = time(NULL) + val;
224
228
    else
225
229
        Started = 0;
226
230
 
227
231
    toLocker lock (Lock)
228
 
        ;
 
232
    ;
229
233
    try
230
234
    {
231
235
        toThread *thread = new toThread(new queryTask(*this));
249
253
        Param(param),
250
254
        Statistics(stats)
251
255
{
 
256
    CurrentValue = Values.end();
 
257
    Quit = EOQ = false;
 
258
    Processed = 0;
 
259
 
252
260
    try
253
261
    {
254
262
        Query = NULL;
259
267
        delete Query;
260
268
        Query = NULL;
261
269
        Error = qApp->translate("toNoBlockQuery", "Couldn't open query");
262
 
        return ;
 
270
        throw;
263
271
    }
264
 
    CurrentValue = Values.end();
265
 
    Quit = EOQ = false;
266
 
    Processed = 0;
267
272
 
268
273
    try
269
274
    {
275
280
        Statistics = NULL;
276
281
    }
277
282
 
278
 
    int val = toConfigurationSingle::Instance().globalConfig(CONF_AUTO_LONG, "0").toInt();
 
283
    int val = toConfigurationSingle::Instance().autoLong();
279
284
    if (val != 0)
280
285
        Started = time(NULL) + val;
281
286
    else
282
287
        Started = 0;
283
288
 
284
289
    toLocker lock (Lock)
285
 
        ;
 
290
    ;
286
291
    try
287
292
    {
288
293
        toThread *thread = new toThread(new queryTask(*this));
302
307
toQDescList &toNoBlockQuery::describe(void)
303
308
{
304
309
    toLocker lock (Lock)
305
 
        ;
 
310
    ;
306
311
    checkError();
307
312
    return Description;
308
313
}
310
315
bool toNoBlockQuery::eof(void)
311
316
{
312
317
    toLocker lock (Lock)
313
 
        ;
 
318
    ;
314
319
    checkError();
315
320
    return EOQ && CurrentValue == Values.end() && !ReadingValues.size();
316
321
}
318
323
int toNoBlockQuery::rowsProcessed(void)
319
324
{
320
325
    toLocker lock (Lock)
321
 
        ;
 
326
    ;
322
327
    checkError();
323
328
    return Processed;
324
329
}
376
381
    if (Running.getValue() > 0)
377
382
    {
378
383
        toLocker lock (Lock)
379
 
            ;
 
384
        ;
380
385
        count += ReadingValues.size();
381
386
    }
382
387
 
395
400
                Lock.unlock();
396
401
                stop();
397
402
                toLocker lock (Lock)
398
 
                    ;
 
403
                ;
399
404
                while (Running.getValue() > 0)
400
405
                    Running.down();
401
406
                while (Continue.getValue() > 0)
402
407
                    Continue.down();
403
 
                Error = QString::null;
 
408
                Error = QString();
404
409
                ReadingValues.clear();
405
410
                Values.clear();
406
411
                CurrentValue = Values.end();