[freetds] Bug: severity in handler called by dberrhandle()

Michael Peppler mpeppler at peppler.org
Tue Jun 24 01:26:54 EDT 2008

James K. Lowden wrote:
> Norbert Sendetzky wrote:
>> If a SQL statement is executed which refers to a non-existing table, the
>> library (0.82) returns a severity of 16 inside the installed error
>> handler.  According to the Sybase documentation and syberror.h, valid
>> severities are  from 1 to 11. The severity of this particular error
>> should be more like  EXUSER (2), EXNONFATAL (3) or EXSERVER (5).
> 1> select 8 from notable
> 2> go
> Msg 208, Level 16, State 1
> Server 'TITAN', Line 1
> Invalid object name 'notable'.
> That message and its severity comes from the server.  FreeTDS merely
> passes it on.  

Actually (as I'm sure you already know) there are two types of messages 
in DBlib - the "message" (handled by dbmsghandle()) which process server 
side errors, and the "err" (handled by dberrhandle()) which process 
client-side errors.

The client-side errors should have severities like EXUSER, etc., and 
refers to client-side issues such as OS errors and the like. When a 
server side error occurs the Sybase DBlib errhandler is also called, 
with a generic error of the type "please check errors from the server", 
which is pretty useless, and which is usually suppressed.

For example, the default handlers in sybperl's Sybase::DBlib package do 

sub error_handler {
     my ($db, $severity, $error, $os_error, $error_msg, $os_error_msg)
	= @_;
     # Check the error code to see if we should report this.
     if ($error != SYBESMSG) {
	print STDERR ("Sybase error: ", $error_msg, "\n");
	print STDERR ("OS Error: ", $os_error_msg, "\n") if defined 


Michael Peppler           -                 Peppler Consulting SaRL
mpeppler at peppler.org      -                  http://www.peppler.org
Sybase DBA/Developer      -   TeamSybase: http://www.teamsybase.com
Sybase on Linux FAQ       -   http://www.peppler.org/FAQ/linux.html

More information about the FreeTDS mailing list