Skip to Content.
Sympa Menu

freetds - Re: [freetds] How to break a run

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Frank von Daak" <frank.fun AT kpage.de>
  • To: "Brian Bruns" <camber AT ais.org>
  • Cc: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] How to break a run
  • Date: 19 Feb 2003 15:11:51 +0100

Hi,

my program is written in Qt (C++).
I send the login-Information and do the connect once - then I leave the
connection open...
The only thing, I do after this is to send querys...
Now, I send a query, that results in a very large resultset (blob).
While this query is running, I set the 'break_run'-variable and
'tds_send_canel()' and 'tds_process_canel()' are called - the query stops
immediatly.
Without doing anything else, the next query I send does not run, because
'tds_process_result_tokens(tds)' does not return 'TDS_SUCCEED'.

Can you help ?

Here's the code-snippet:

bool TSQLCont::tsql_doQuery(const QString &query)
{
break_run = FALSE;
QTime time;
time.start();
QValueList<QStringList> all_rows[2048];
int rows, num_columns;

QStringList columns[2048], row;
QStringList tableInfo;
QString rec;
QString tmp_src;
int i, ctype, tab_cnt, rows_cnt, cancelled, marker;
TDS_INT srclen;
unsigned char *src;
TDSCOLINFO *col;
CONV_RESULT dres;

rows = num_columns = tab_cnt = rows_cnt = 0;

rows = 0;
if ( tds_submit_query(tds,(const char*)query) != TDS_SUCCEED ) {
emit tsql_fatal(I18N_NOOP("tds_submit_query() failed\n"));
return FALSE;
}

while ((tds_process_result_tokens(tds))==TDS_SUCCEED) {
if ( break_run ) {
// tds_send_canel()
tds->out_flag=0x06;
tds_flush_packet(tds);

// tds_process_canel()
do {
marker=tds_get_byte(tds);
if (marker==TDS_DONE_TOKEN) {
tds_process_end(tds, marker, NULL,
&cancelled);
} else if (marker==0) {
cancelled = 1;
} else {

tds_process_default_tokens(tds,marker);
}
} while (!cancelled);
tds->state = TDS_COMPLETED;
break_run = FALSE;
continue;
}

if (tds->res_info) {
num_columns = tds->res_info->num_cols;
for (i=0; i<tds->res_info->num_cols; i++) {
rec.sprintf("%s\t",
tds->res_info->columns[i]->column_name);
columns[tab_cnt].append(rec);
}
}

while ((tds_process_row_tokens(tds))==TDS_SUCCEED) {
if ( break_run ) {
// tds_send_canel()
tds->out_flag=0x06;
tds_flush_packet(tds);

// tds_process_canel()
do {
marker=tds_get_byte(tds);
if (marker==TDS_DONE_TOKEN) {
tds_process_end(tds, marker,
NULL, &cancelled);
} else if (marker==0) {
cancelled = 1;
} else {

tds_process_default_tokens(tds,marker);
}
} while (!cancelled);
tds->state = TDS_COMPLETED;
break_run = FALSE;
continue;
}
<SNIP>
... (the rest of the code is doing the normal processing of the results...)



Am Wednesday 19 February 2003 14:38 schrieb Brian Bruns:
> If you do a tds_send_cancel() followed by a tds_process_cancel() you
> should be back to the default state. wanna provide some sample code
> that demos what you're seeing?
>
> Brian
>
> On 19 Feb 2003, Frank von Daak wrote:
> > Hi,
> >
> > I've used the 'tds_process_cancel()'-function in my code, now.
> > This is working very fine. But if I try to run the next query, I
> > immediatly get 'TDS_SUCCEED' when doing a 'tds_process_result_tokens()'.
> >
> > Do I've to free/reset the tds-structure after the 'tds_process_cancel()'
> > ? If yes - how can I do this ?
> >
> > Thank you very much,
> > Frank
> >
> > Am Wednesday 19 February 2003 12:19 schrieb Brian Bruns:
> > > in dblib it's dbcancel(), ctlib is ct_cancel()
> > >
> > > On 19 Feb 2003, Frank von Daak wrote:
> > > > Hello,
> > > >
> > > > I've one silly question:
> > > > How do I stop a running tds-Query in a C-program ?
> > > >
> > > > Thank you very much !
> > > > Frank
> > >
> > > _______________________________________________
> > > FreeTDS mailing list
> > > FreeTDS AT lists.ibiblio.org
> > > http://lists.ibiblio.org/mailman/listinfo/freetds
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds

--
--
Frank von Daak
frank.fun AT kpage.de




Archive powered by MHonArc 2.6.24.

Top of Page