[freetds] Problem with FreeTDS validating SQL commands

Stephane Magne smagne at atimi.com
Mon May 19 20:13:47 EDT 2008


I'm currently converting PPC based Mac Software to Universal  
binaries, and I'm using FreeTDS as the replacement for the  
SybaseOpenClient framework.  We used the 0.64 source to build a  
Mac .framework which is what we're still using.  I've built a new  
framework from the 0.82 source, but it did not address the problem  
I'm seeing.

The basic problem that I am having is that when I attempt to execute  
an incorrectly formatted SQL statement, or a stored procedure that  
isn't properly stored on the server, the FreeTDS library returns a  
CS_SUCCEED result instead of CS_FAIL.  Does anyone know if this is a  
known issue with FreeTDS or if there is a workaround?

I'll attach the code below that we are using to execute our query:

		theRetcode = ct_command(itsCmdPtr, CS_LANG_CMD, aCmdStr,  
		if (theRetcode != CS_SUCCEED) return (theRetcode) ;

		/* Send the command to the server */
		theRetcode = ct_send (itsCmdPtr) ;
		if (theRetcode != CS_SUCCEED) return (theRetcode) ;
		/* Process the results of the command */
		theResType = 0 ;
		DisposeData		() ;
		DisposeParam	() ;
		DisposeStatus	() ;
		DisposeCompute	() ;

		while ((theRetcode = ct_results(itsCmdPtr, &theResType)) ==  

So, basically, we're calling ct_command() and then calling ct_send()  
right after.

Please correct me if I'm wrong, but it's my understanding that  
ct_command() is used to initiate the SQL request and will also  
determine if it is valid SQL syntax or if the Stored Procedure call  
is valid.

In contrast, the SybaseOpenClient framework will return the CS_FAIL  
result if the SQL isn't properly formatted.  However, the source  
isn't readily available to us so we can't compare the two.

Thanks for any feedback, your time is appreciated,

Stephane Magne
Atimi Software Inc.
smagne at atimi.com

More information about the FreeTDS mailing list