Skip to Content.
Sympa Menu

freetds - RE: [freetds] Status: bcp

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: 'FreeTDS Development Group' <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] Status: bcp
  • Date: Fri, 19 Dec 2003 10:28:04 -0500

> From: ZIGLIO Frediano [mailto:Frediano.Ziglio AT vodafone.com]
> Sent: December 19, 2003 9:14 AM
>
> There are some comments in tds_client_msg
>
> /*
> * error handler may return:
> * INT_EXIT -- Print an error message, and exit
> application, . returning an error to the OS.
> * INT_CANCEL -- Return FAIL to the db-lib function that
> caused the error.
> * For SQLETIME errors only, call dbcancel() to try to
> cancel the current command batch
> * and flush any pending results. Break the
> connection if dbcancel() times out,
> * INT_CONTINUE -- For SQLETIME, wait for one additional
> time-out period, then call the error handler again.
> * Else treat as INT_CANCEL.
> */
>
> and
>
> /* message handler returned FAIL/CS_FAIL
> * mark socket as dead */
>
>
> Which one is the correct one?

I added the INT_EXIT, etc. comment yesterday, based on db-lib documentation.


> err_handler is libTDS, not dblib so it
> shouldn't return db-lib result (INT_EXIT, INT_CANCEL, INT_CONTINUE)...

tds_ctx->err_handler points to a user-provided callback function installed
by the application. That function could be written to the db-lib or ct-lib
spec, and thus could return any of INT_EXIT, INT_CANCEL, INT_CONTINUE,
CS_SUCCEED, or CS_FAIL.

> dblib_handle_err_message returns SUCCEED/FAIL codes... err_handler
> should return TDS_SUCCEED/TDS_FAIL and tds_client_msg should check ret
> == TDS_FAIL (or ret != TDS_SUCCEED), not ret (that means if
> succeed set
> state to DEAD... I don't understand why code worked...).

It barely works. It's vested with db-lib assumptions, and the documented
effect of a handler's return code isn't implemented.

Nick wrote the beginnings of a better framework, based on ct-lib, cf.
src/ctlib/ct.c::_ctclient_msg(). We should move some of that stuff into
libtds and rip out tds_client_msg(). Here's a noodle of its replacement:

int
tds_call_client_handler(int message_number,
int *phandler_retcode);

The function returns TDS_SUCCEED/TDS_FAIL, and we react accordingly. The
function calls an intermediary in the API layer, which looks up the message
text, etc. for message_number and calls the client-installed handler. The
intermediary stuffs the handler's return code into phandler_retcode, and
interprets it as success/failure, which it returns to
tds_call_client_handler(). That way, whoever calls
tds_call_client_handler() has a good/bad indicator (in the return code) and
the handler's own return code. If the caller was a libtds function, it can
branch on the return code. If the caller was in the API layer, it can pay
attention to the handler's return code (in *phandler_retcode). End noodle.


FreeTDS began as a db-lib implementation. Until this year, our ct-lib was
missing a lot of functionality. Now that it's maturing (thanks, Bill!) we
need a more generalized error emmission system, and a centralized,
documented table of diagnostic messages. In 0.63 or so, perhaps.

--jkl
-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.






Archive powered by MHonArc 2.6.24.

Top of Page