Skip to Content.
Sympa Menu

freetds - Re: dberrhandler() and dbmsghandler()

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Castellano, Nicholas" <Nicholas_Castellano AT acml.com>
  • To: "'TDS Development Group'" <freetds AT franklin.metalab.unc.edu>
  • Subject: Re: dberrhandler() and dbmsghandler()
  • Date: Fri, 6 Sep 2002 17:18:44 -0400


Fixed in revision 1.47 of src/tds/token.c which I just committed. Thanks
for the report!

By the way, it's a good idea to install your message handlers earlier, right
after dblogin(). Otherwise you might miss messages generated at dbopen()
time.

-----Original Message-----
From: bounce-freetds-145195 AT franklin.oit.unc.edu
[mailto:bounce-freetds-145195 AT franklin.oit.unc.edu]
Sent: Friday, September 06, 2002 3:00 PM
To: TDS Development Group
Subject: [freetds] Re: dberrhandler() and dbmsghandler()


"Lowden, James K" <LowdenJK AT bernstein.com> writes:

> If you will post a simple test program evincing the problem when
> linked with the most recent snapshot, I will look at it. The current
> code in
> src/tds/token.c::tds_process_msg() looks clean, but maybe under some
> circumstances it fetches a corrupted servername?

Using the freetds in:

ftp://ftp.ibiblio.org/pub/Linux/ALPHA/freetds/freetds-current.tgz

And this program:

#include <sybfront.h>
#include <sybdb.h>
#include <syberror.h>
#include <stdio.h>

/* Forward declarations of the error handler and message handler. */ int
err_handler(); int msg_handler();

FILE *ERR_CH;

int main(int argc, char *argv[])
{
LOGINREC *login; /* The login information */
DBPROCESS *dbproc;

if ((ERR_CH = fopen("TestTds.Err", "w")) == NULL) {
perror("TestTds.Err");
exit(1);
}

if (dbinit() == FAIL)
{
fprintf(stderr, "Database failure\n");
exit(1);
}

login = dblogin();
DBSETLUSER(login, "xxxxxx");
DBSETLPWD(login, "xxxxxxxxxxxxxxx");

dbproc = dbopen(login, NULL);

dberrhandle(err_handler);
dbmsghandle(msg_handler);

dbuse(dbproc, "ged");

printf("Do something here.\n");
}

int err_handler(DBPROCESS *dbproc, int severity, int dberr, int oserr,
char *dberrstr, char *oserrstr)
{
if ((dbproc == NULL) || (DBDEAD(dbproc)))
return(INT_EXIT);
else
{
fprintf (ERR_CH, "DB-Library error:\n\t%s\n", dberrstr);

if (oserr != DBNOERR)
fprintf (ERR_CH, "Operating-system error:\n\t%s\n", oserrstr);

return(INT_CANCEL);
}
}

int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
int severity, char *msgtext, char *srvname, char *procname,
int line)
{
fprintf (ERR_CH, "Msg %ld, Level %d, State %d\n",
msgno, severity, msgstate);

if (strlen(srvname) > 0)
fprintf (ERR_CH, "Server '%s', ", srvname);
if (strlen(procname) > 0)
fprintf (ERR_CH, "Procedure '%s', ", procname);
if (line > 0)
fprintf (ERR_CH, "Line %d", line);

fprintf (ERR_CH, "\n\t%s\n", msgtext);

return(0);
}

It crashes, here's the bt:

(gdb) bt
#0 0xdfb7d489 in strlen () from /usr/lib/libc.so.1
#1 0x8049787 in msg_handler (dbproc=0x8067df0, msgno=5701, msgstate=1,
severity=10, msgtext=0x8068c78 "Changed database context to 'ged'.\n",
srvname=0x8067aa0 "episun7", procname=0x0, line=-541110272) at
testtds.c:69 #2 0x804cd9e in dblib_handle_info_message (tds_ctx=0x8066ab0,
tds=0x8068f88,
msg=0x8069558) at dbutil.c:53
#3 0x804f7f7 in tds_process_msg (tds=0x8068f88, marker=229) at token.c:1289
#4 0x804dd6e in tds_process_default_tokens (tds=0x8068f88, marker=229)
at token.c:103
#5 0x804bf79 in dbsqlok (dbproc=0x8067df0) at dblib.c:1984
#6 0x804a363 in dbsqlexec (dbproc=0x8067df0) at dblib.c:617
#7 0x804a39f in dbuse (dbproc=0x8067df0, dbname=0x8058fdc "ged")
at dblib.c:627
#8 0x8049699 in main (argc=1, argv=0x804770c) at testtds.c:39

Thanks,
Steve

---
You are currently subscribed to freetds as: [Nicholas_Castellano AT acml.com]
To unsubscribe, forward this message to
$subst('Email.Unsub')


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 for certain accounts we do not accept
orders and/or instructions by e-mail, and for those accounts we will not be
responsible for carrying out such orders and/or instructions. Kindly refrain
from sending orders or instructions by e-mail unless you have confirmed that
we accept such communications for your account. Please also note that to
satisfy regulatory requirements we review the outgoing and incoming e-mail
correspondence of staff members serving certain functions.






Archive powered by MHonArc 2.6.24.

Top of Page