Patches for Binary fields, AIX/xlc

Gary D. Duzan gdd0 at gte.com
Tue Apr 4 09:45:06 EDT 2000


   Included below are the changes we made to the CVS version get
the driver working for us here. We are using FreeTDS with DBD::Sybase
on AIX to talk to Sybase 11.9.2.
   A few words about the changes. The change to tds.h is one of
compiler portability. Standard C/C++ doesn't allow the trailing
comma in the enumerator list (allowing it is a gcc extension) and
the xlc compiler properly rejects it. It would be fine for a private
header, but DBD::Sybase reads it, and that is compiled with xlc.
   The ct.c changes include a minor typo fix and a fairly serious
bug fix. The SYBBINARY type wasn't being properly recognized,
leading to formatting problems in the output. Namely, it was basing
the output buffer size on the column name, which truncated the
output when the column name was smaller than the output. We would
additionally suggest adding default clauses to all switches to
catch and warn about this sort of thing in the future.
   The last change was to convert.c, with its main purpose being
to add the trailing null to the string length to be consistent with
the format of other strings. We also modified the loop slightly to
help clarify it in our minds; we are less concerned about that
change.
   If there are any questions, let me know.

					Gary Duzan
					GTE Laboratories



Index: include/tds.h
===================================================================
RCS file: /Repository/freetds/include/tds.h,v
retrieving revision 1.52
diff -c -r1.52 tds.h
*** tds.h	2000/03/13 12:56:47	1.52
--- tds.h	2000/04/04 13:09:28
***************
*** 283,289 ****
  	TDS_PENDING,
  	TDS_COMPLETED,
  	TDS_CANCELED,
! 	TDS_DEAD,
  };
  
  typedef struct tds_compute_info {
--- 283,289 ----
  	TDS_PENDING,
  	TDS_COMPLETED,
  	TDS_CANCELED,
! 	TDS_DEAD
  };
  
  typedef struct tds_compute_info {
Index: src/ctlib/ct.c
===================================================================
RCS file: /Repository/freetds/src/ctlib/ct.c,v
retrieving revision 1.45
diff -c -r1.45 ct.c
*** ct.c	2000/01/28 00:10:53	1.45
--- ct.c	2000/04/04 13:09:30
***************
*** 434,440 ****
  			}
  		}
     		if (curcol->column_lenbind) {
!    			tdsdump_log("%L inside _ct_bind_data() length binding len = %d", len);
  		   	*((CS_INT *)curcol->column_lenbind) = len;
  		}
  	}
--- 434,440 ----
  			}
  		}
     		if (curcol->column_lenbind) {
!    			tdsdump_log("%L inside _ct_bind_data() length binding len = %d\n", len);
  		   	*((CS_INT *)curcol->column_lenbind) = len;
  		}
  	}
***************
*** 539,544 ****
--- 539,547 ----
  		break;
           case SYBDECIMAL:
        		return CS_DECIMAL_TYPE;
+ 		break;
+ 	 case SYBBINARY:
+ 		return CS_BINARY_TYPE;
  		break;
           case SYBVARBINARY:
        		return CS_VARBINARY_TYPE;
Index: src/tds/convert.c
===================================================================
RCS file: /Repository/freetds/src/tds/convert.c,v
retrieving revision 1.39
diff -c -r1.39 convert.c
*** convert.c	2000/03/13 12:56:47	1.39
--- convert.c	2000/04/04 13:09:30
***************
*** 120,130 ****
  	 d=0;
  	 dest[d++]='0';
  	 dest[d++]='x';
!          for (s=0;s<srclen && d+2<destlen;s++) {
!              dest[d++]=src[s]/16 > 9 ? 87 + (src[s]/16) : '0' + (src[s]/16);
!              dest[d++]=src[s]%16 > 9 ? 87 + (src[s]%16) : '0' + (src[s]%16);
           }
! 	 dest[d]='\0';
           return d;
        case SYBBINARY:
  	 cplen = srclen > destlen ? destlen : srclen;
--- 120,130 ----
  	 d=0;
  	 dest[d++]='0';
  	 dest[d++]='x';
!          for (s=0;s<srclen && d < destlen-2;s++, d+=2) {
!              dest[d]=src[s]/16 > 9 ? 87 + (src[s]/16) : '0' + (src[s]/16);
!              dest[d+1]=src[s]%16 > 9 ? 87 + (src[s]%16) : '0' + (src[s]%16);
           }
! 	 dest[d++]='\0';
           return d;
        case SYBBINARY:
  	 cplen = srclen > destlen ? destlen : srclen;



More information about the FreeTDS mailing list