dberrhandler() and dbmsghandler()

Steven J. Backus backus at math.utah.edu
Fri Sep 6 11:59:33 EDT 2002


> In src/dblib/dblib.c we have definitions of dberrhandler() and
> dbmsghandler()...

This reminds me of another problem I have with freetds.  Here's the
msg_handler I use:

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);

--
This puppy crashes under freetds, but not with sybase's tds.  It
happens like this:

 dbmsghandle(msg_handler);  /* install msg_handler */

 dbuse(dbproc, "db");  /* Crash occurs at this line */

I've bt'd in gdb and the line that's blowing up is:

  if (strlen(srvname) > 0)
    fprintf (ERR_CH, "Server '%s', ", srvname);

The strlen is core dumping because srvname isn't initialized.  Any
chance of getting this fixed?  I forget to comment out this line
until a user calls me complaining.

Thanks,
  Steve



More information about the FreeTDS mailing list