Skip to Content.
Sympa Menu

freetds - DBlib and TDS patch

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Chris Eleveld <ihermit2 AT yahoo.com>
  • To: freetds AT franklin.oit.unc.edu
  • Subject: DBlib and TDS patch
  • Date: Wed, 23 Jan 2002 06:21:35 -0800 (PST)

Ok I am attempting to attach another patch to this
message since the cut and paste method seriously
garbled things.

The dblibpatch1 fixes up the error and message
handling prototypes and passes the line number
argument to the msg_handler.

The tdslibpatch2 handles a 0 length for a bound text
variable and conversions from DATETIME types and REAL
types. According to the documentation I have a 0
length means trust me to have the space but null
terminate the resulting string. I am a bit iffy on
this one sicne the change is in the TDS layer and I do
not know if it should carry over into the CTlib and
ODBC layers, or just the DBlib. Any wisdoms?


__________________________________________________
Do You Yahoo!?
Send FREE video emails in Yahoo! Mail!
http://promo.yahoo.com/videomail/*** freetds-0.53-orig/src/dblib/dbutil.c Tue Nov 13 23:52:33 2001
--- freetds-0.53/src/dblib/dbutil.c Fri Jan 18 15:09:41 2002
***************
*** 28,35 ****
no_unused_var_warn};


! extern int
(*g_dblib_msg_handler)(DBPROCESS*,TDS_SMALLINT,TDS_SMALLINT,TDS_SMALLINT,TDS_CHAR*,TDS_CHAR*,TDS_CHAR*);
! extern int
(*g_dblib_err_handler)(DBPROCESS*,TDS_SMALLINT,TDS_SMALLINT,TDS_SMALLINT,TDS_CHAR*,TDS_CHAR*);

/* The next 2 functions will be the reciever for the info and error messages
* that come from the TDS layer. The address of this function is passed to
--- 28,35 ----
no_unused_var_warn};


! extern MHANDLEFUNC g_dblib_msg_handler;
! extern EHANDLEFUNC g_dblib_err_handler;

/* The next 2 functions will be the reciever for the info and error messages
* that come from the TDS layer. The address of this function is passed to
***************
*** 47,56 ****
}
if( tds->msg_info->msg_number > 0 )
{
! /* now check to see if the user supplied a function, if not
ignore the
! * problem */
if(g_dblib_msg_handler)
{
g_dblib_msg_handler(dbproc,
tds->msg_info->msg_number,
tds->msg_info->msg_state,
--- 47,61 ----
}
if( tds->msg_info->msg_number > 0 )
{
! /*
! * now check to see if the user supplied a function, if
! * not ignore the problem
! */
if(g_dblib_msg_handler)
{
+ /*
+ * CRE 01182002 msg handler has 8 args last is line #
+ */
g_dblib_msg_handler(dbproc,
tds->msg_info->msg_number,
tds->msg_info->msg_state,
***************
*** 57,63 ****
tds->msg_info->msg_level,
tds->msg_info->message,
tds->msg_info->server,
! tds->msg_info->proc_name);
}
else
{
--- 62,69 ----
tds->msg_info->msg_level,
tds->msg_info->message,
tds->msg_info->server,
! tds->msg_info->proc_name,
! tds->msg_info->line_number);
}
else
{
*** freetds-0.53-orig/src/tds/convert.c Sun Dec 2 19:06:14 2001
--- freetds-0.53/src/tds/convert.c Tue Jan 22 12:33:12 2002
***************
*** 512,517 ****
--- 512,523 ----
TDS_INT dtdays, dttime;
time_t tmp_secs_from_epoch;

+ /*
+ * CRE 01/22/2002 If a destlnen is 0 db-lib assumes your buffer is
+ * large enough.
+ */
+ if (!destlen)
+ destlen = 20;
switch(desttype) {
case SYBCHAR:
case SYBVARCHAR:
***************
*** 560,565 ****
--- 566,578 ----
{
TDS_USMALLINT days, minutes;
time_t tmp_secs_from_epoch;
+
+ /*
+ * CRE 01/22/2002 If a destlnen is 0 db-lib assumes your buffer is
+ * large enough.
+ */
+ if (!destlen)
+ destlen = 20;

switch(desttype) {
case SYBCHAR:
***************
*** 645,652 ****
* so it should have >=23 bytes allocated (one for the terminating
* NULL), right?
*/
! if (destlen >= 0 && destlen < 23) return TDS_FAIL;
! sprintf(dest,"%.15g", the_value);
return strlen(dest);
case SYBREAL:
*((TDS_REAL *)dest) = the_value;
--- 658,677 ----
* so it should have >=23 bytes allocated (one for the terminating
* NULL), right?
*/
! /*
! * CRE 01/22/2002 If a destlnen is 0 db-lib assumes your buffer is
! * large enough.
! * also the_vaue is a double so use lg
! * also also sybase appears to guarantee atleast
! * one digit past the decimal
! * for the long run we might want to look at gcvt()
! */
! if (destlen > 0 && destlen < 23) return TDS_FAIL;
! sprintf(dest,"%0.15lg", the_value);
! if (!strchr(dest, '.') && !strchr(dest, 'e')) {
! if (!destlen || (destlen > (strlen(dest) + 3)))
! strcat(dest, ".0");
! }
return strlen(dest);
case SYBREAL:
*((TDS_REAL *)dest) = the_value;



Archive powered by MHonArc 2.6.24.

Top of Page