changeset 1552:b081cd84b96f

upgrade package freetds to cvs
author Mark Brand <mabrand@mabrand.nl>
date Tue, 18 Jan 2011 00:24:03 +0100
parents 906b674321d5
children cf541f507c71
files src/freetds-1-fastforward.patch
diffstat 1 files changed, 420 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/freetds-1-fastforward.patch	Mon Jan 17 09:55:21 2011 +0100
+++ b/src/freetds-1-fastforward.patch	Tue Jan 18 00:24:03 2011 +0100
@@ -164951,3 +164951,423 @@
  }
  
  static char *
+
+commit a2c523f6ab36056f46d0436ef3d3ca3d35747e7f
+Author: freddy77 <freddy77>
+Date:   Mon Jan 17 22:05:37 2011 +0000
+
+    silly format improve
+
+diff --git a/src/odbc/unittests/data.c b/src/odbc/unittests/data.c
+index c5889e5..2f26163 100644
+--- a/src/odbc/unittests/data.c
++++ b/src/odbc/unittests/data.c
+@@ -13,7 +13,7 @@
+  * Also we have to check normal char and wide char
+  */
+ 
+-static char software_version[] = "$Id: data.c,v 1.37 2011/01/08 01:19:48 freddy77 Exp $";
++static char software_version[] = "$Id: data.c,v 1.38 2011/01/17 22:05:37 freddy77 Exp $";
+ static void *no_unused_var_warn[] = { software_version, no_unused_var_warn };
+ 
+ static int result = 0;
+@@ -96,7 +96,7 @@ Test(const char *type, const char *value_to_convert, SQLSMALLINT out_c_type, con
+ 	}
+ 
+ 	if (strcmp(sbuf, expected) != 0) {
+-		fprintf(stderr, "Wrong result\n  Got: %s\n  Expected: %s\n", sbuf, expected);
++		fprintf(stderr, "Wrong result\n  Got:      %s\n  Expected: %s\n", sbuf, expected);
+ 		result = 1;
+ 	}
+ }
+
+commit c4cc0e315a3849befcec5c5e8d874703903ae13e
+Author: freddy77 <freddy77>
+Date:   Mon Jan 17 22:27:40 2011 +0000
+
+    unify metadata read from server
+
+diff --git a/ChangeLog b/ChangeLog
+index 2c6206e..ca49421 100644
+--- a/ChangeLog
++++ b/ChangeLog
+@@ -1,3 +1,7 @@
++Mon Jan 17 23:27:25 CET 2011    Frediano Ziglio <freddy77_A_gmail_D_com>
++	* include/tds.h src/tds/data.c src/tds/token.c:
++	- unify metadata read from server
++
+ Fri Jan 14 15:15:21 CET 2011    Frediano Ziglio <freddy77_A_gmail_D_com>
+ 	* src/dblib/bcp.c src/dblib/dblib.c: minor dblib results changes
+ 
+@@ -3142,4 +3146,4 @@ Wed Jan  9 19:54:43 EST 2008	JK Lowden <jklowden@freetds.org>
+ 	* ChangeLog-0.82 added because of release
+ 	
+ $FreeTDS$
+-$Id: ChangeLog,v 1.3192 2011/01/14 14:18:14 freddy77 Exp $
++$Id: ChangeLog,v 1.3193 2011/01/17 22:27:40 freddy77 Exp $
+diff --git a/include/tds.h b/include/tds.h
+index 4d32887..3955b48 100644
+--- a/include/tds.h
++++ b/include/tds.h
+@@ -1,6 +1,6 @@
+ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
+  * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005  Brian Bruns
+- * Copyright (C) 2010  Frediano Ziglio
++ * Copyright (C) 2010, 2011  Frediano Ziglio
+  *
+  * This library is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Library General Public
+@@ -21,7 +21,7 @@
+ #ifndef _tds_h_
+ #define _tds_h_
+ 
+-/* $Id: tds.h,v 1.348 2010/12/30 18:54:08 freddy77 Exp $ */
++/* $Id: tds.h,v 1.349 2011/01/17 22:27:40 freddy77 Exp $ */
+ 
+ #include <stdarg.h>
+ #include <stdio.h>
+@@ -1520,6 +1520,7 @@ int tds_process_tokens(TDSSOCKET * tds, /*@out@*/ TDS_INT * result_type, /*@out@
+ /* data.c */
+ void tds_set_param_type(TDSSOCKET * tds, TDSCOLUMN * curcol, TDS_SERVER_TYPE type);
+ void tds_set_column_type(TDSSOCKET * tds, TDSCOLUMN * curcol, int type);
++TDS_INT tds_data_get_info(TDSSOCKET *tds, TDSCOLUMN *col);
+ 
+ 
+ /* tds_convert.c */
+diff --git a/src/tds/data.c b/src/tds/data.c
+index fdd4034..c06a21e 100644
+--- a/src/tds/data.c
++++ b/src/tds/data.c
+@@ -1,5 +1,5 @@
+ /* FreeTDS - Library of routines accessing Sybase and Microsoft databases
+- * Copyright (C) 2003-2010 Frediano Ziglio
++ * Copyright (C) 2003-2011 Frediano Ziglio
+  *
+  * This library is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU Library General Public
+@@ -35,7 +35,7 @@
+ #include <dmalloc.h>
+ #endif
+ 
+-TDS_RCSID(var, "$Id: data.c,v 1.27 2010/11/26 08:41:26 freddy77 Exp $");
++TDS_RCSID(var, "$Id: data.c,v 1.28 2011/01/17 22:27:41 freddy77 Exp $");
+ 
+ /**
+  * Set type of column initializing all dependency 
+@@ -183,4 +183,77 @@ tds_get_cardinal_type(int datatype, int usertype)
+ 	return datatype;
+ }
+ 
++TDS_INT
++tds_data_get_info(TDSSOCKET *tds, TDSCOLUMN *col)
++{
++	switch (col->column_varint_size) {
++	case 8:
++		col->column_size = 0x7ffffffflu;
++		break;
++	case 5:
++	case 4:
++		col->column_size = tds_get_int(tds);
++		break;
++	case 2:
++		/* assure > 0 */
++		col->column_size = tds_get_smallint(tds);
++		/* under TDS9 this means ?var???(MAX) */
++		if (col->column_size < 0 && IS_TDS72_PLUS(tds)) {
++			col->column_size = 0x3ffffffflu;
++			col->column_varint_size = 8;
++		}
++		break;
++	case 1:
++		col->column_size = tds_get_byte(tds);
++		break;
++	case 0:
++		col->column_size = tds_get_size_by_type(col->column_type);
++		break;
++	}
++
++	/* numeric and decimal have extra info */
++	if (is_numeric_type(col->column_type)) {
++		col->column_prec = tds_get_byte(tds);        /* precision */
++		col->column_scale = tds_get_byte(tds);       /* scale */
++		/* FIXME check prec/scale, don't let server crash us */
++	}
++
++	if (IS_TDS71_PLUS(tds) && is_collate_type(col->on_server.column_type)) {
++		/* based on true type as sent by server */
++		/*
++		 * first 2 bytes are windows code (such as 0x409 for english)
++		 * other 2 bytes ???
++		 * last bytes is id in syscharsets
++		 */
++		tds_get_n(tds, col->column_collation, 5);
++		col->char_conv =
++			tds_iconv_from_collate(tds, col->column_collation);
++	}
++
++	/* Only read table_name for blob columns (eg. not for SYBLONGBINARY) */
++	if (is_blob_type(col->on_server.column_type)) {
++		/* discard this additional byte */
++		if (IS_TDS72_PLUS(tds)) {
++			unsigned char num_parts = tds_get_byte(tds);
++			/* TODO do not discard first ones */
++			for (; num_parts; --num_parts) {
++				col->table_namelen =
++				tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1);
++			}
++		} else {
++			col->table_namelen =
++				tds_get_string(tds, tds_get_smallint(tds), col->table_name, sizeof(col->table_name) - 1);
++		}
++	} else if (IS_TDS72_PLUS(tds) && col->on_server.column_type == SYBMSXML) {
++		unsigned char has_schema = tds_get_byte(tds);
++		if (has_schema) {
++			/* discard schema informations */
++			tds_get_string(tds, tds_get_byte(tds), NULL, 0);        /* dbname */
++			tds_get_string(tds, tds_get_byte(tds), NULL, 0);        /* schema owner */
++			tds_get_string(tds, tds_get_smallint(tds), NULL, 0);    /* schema collection */
++		}
++	}
++	return TDS_SUCCEED;
++}
++
+ #include "types.h"
+diff --git a/src/tds/token.c b/src/tds/token.c
+index 6769888..254f84f 100644
+--- a/src/tds/token.c
++++ b/src/tds/token.c
+@@ -43,7 +43,7 @@
+ #include <dmalloc.h>
+ #endif
+ 
+-TDS_RCSID(var, "$Id: token.c,v 1.395 2011/01/08 01:19:48 freddy77 Exp $");
++TDS_RCSID(var, "$Id: token.c,v 1.396 2011/01/17 22:27:41 freddy77 Exp $");
+ 
+ #define USE_ICONV tds->use_iconv
+ 
+@@ -1404,19 +1404,8 @@ tds_process_compute_result(TDSSOCKET * tds)
+ 
+ 		tds_set_column_type(tds, curcol, tds_get_byte(tds));
+ 
+-		switch (curcol->column_varint_size) {
+-		case 4:
+-			curcol->column_size = tds_get_int(tds);
+-			break;
+-		case 2:
+-			curcol->column_size = tds_get_smallint(tds);
+-			break;
+-		case 1:
+-			curcol->column_size = tds_get_byte(tds);
+-			break;
+-		case 0:
+-			break;
+-		}
++		tds_data_get_info(tds, curcol);
++
+ 		tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size);
+ 
+ 		/* Adjust column size according to client's encoding */
+@@ -1474,76 +1463,14 @@ tds7_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol)
+ 
+ 	curcol->column_timestamp = (curcol->column_type == SYBBINARY && curcol->column_usertype == TDS_UT_TIMESTAMP);
+ 
+-	switch (curcol->column_varint_size) {
+-	case 8:
+-		curcol->column_size = 0x7ffffffflu;
+-		break;
+-	case 4:
+-		curcol->column_size = tds_get_int(tds);
+-		break;
+-	case 2:
+-		curcol->column_size = tds_get_smallint(tds);
+-		/* under TDS7.2 this means ?var???(MAX) */
+-		if (curcol->column_size < 0 && IS_TDS72_PLUS(tds)) {
+-			curcol->column_size = 0x3ffffffflu;
+-			curcol->column_varint_size = 8;
+-		}
+-		break;
+-	case 1:
+-		curcol->column_size = tds_get_byte(tds);
+-		break;
+-	case 0:
+-		break;
+-	}
++	tds_data_get_info(tds, curcol);
+ 
+ 	/* Adjust column size according to client's encoding */
+ 	curcol->on_server.column_size = curcol->column_size;
+ 
+-	/* numeric and decimal have extra info */
+-	if (is_numeric_type(curcol->column_type)) {
+-		curcol->column_prec = tds_get_byte(tds);	/* precision */
+-		curcol->column_scale = tds_get_byte(tds);	/* scale */
+-		/* FIXME check prec/scale, don't let server crash us */
+-	}
+-
+-	if (IS_TDS71_PLUS(tds) && is_collate_type(curcol->on_server.column_type)) {
+-		/* based on true type as sent by server */
+-		/*
+-		 * first 2 bytes are windows code (such as 0x409 for english)
+-		 * other 2 bytes ???
+-		 * last bytes is id in syscharsets
+-		 */
+-		tds_get_n(tds, curcol->column_collation, 5);
+-		curcol->char_conv =
+-			tds_iconv_from_collate(tds, curcol->column_collation);
+-	}
+-
+ 	/* NOTE adjustements must be done after curcol->char_conv initialization */
+ 	adjust_character_column_size(tds, curcol);
+ 
+-	if (is_blob_type(curcol->column_type)) {
+-		/* discard this additional byte */
+-		if (IS_TDS72_PLUS(tds)) {
+-			unsigned char num_parts = tds_get_byte(tds);
+-			/* TODO do not discard first ones */
+-			for (; num_parts; --num_parts) {
+-				curcol->table_namelen =
+-					tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1);
+-			}
+-		} else {
+-			curcol->table_namelen =
+-				tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1);
+-		}
+-	} else if (IS_TDS72_PLUS(tds) && curcol->column_type == SYBMSXML) {
+-		unsigned char has_schema = tds_get_byte(tds);
+-		if (has_schema) {
+-			/* discard schema informations */
+-			tds_get_string(tds, tds_get_byte(tds), NULL, 0);	/* dbname */
+-			tds_get_string(tds, tds_get_byte(tds), NULL, 0);	/* schema owner */
+-			tds_get_string(tds, tds_get_smallint(tds), NULL, 0);	/* schema collection */
+-		}
+-	}
+-
+ 	/*
+ 	 * under 7.0 lengths are number of characters not
+ 	 * number of bytes...tds_get_string handles this
+@@ -1722,45 +1649,10 @@ tds_get_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int is_param)
+ 
+ 	tdsdump_log(TDS_DBG_INFO1, "processing result. type = %d(%s), varint_size %d\n",
+ 		    curcol->column_type, tds_prtype(curcol->column_type), curcol->column_varint_size);
+-	switch (curcol->column_varint_size) {
+-	case 4:
+-		curcol->column_size = tds_get_int(tds);
+-		/* Only read table_name for blob columns (eg. not for SYBLONGBINARY) */
+-		if (is_blob_type (curcol->column_type)) {
+-			curcol->table_namelen =
+-				tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1);
+-		}
+-		break;
+-	case 2:
+-		/* assure > 0 */
+-		curcol->column_size = tds_get_smallint(tds);
+-                /* under TDS9 this means ?var???(MAX) */
+-		if (curcol->column_size < 0 && IS_TDS72_PLUS(tds)) {
+-			curcol->column_size = 0x3ffffffflu;
+-			curcol->column_varint_size = 8;
+-		}
+-		break;
+-	case 1:
+-		curcol->column_size = tds_get_byte(tds);
+-		break;
+-	case 0:
+-		break;
+-	}
+-	tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size);
+ 
+-	/* numeric and decimal have extra info */
+-	if (is_numeric_type(curcol->column_type)) {
+-		curcol->column_prec = tds_get_byte(tds);	/* precision */
+-		curcol->column_scale = tds_get_byte(tds);	/* scale */
+-		/* FIXME check prec/scale, don't let server crash us */
+-	}
++	tds_data_get_info(tds, curcol);
+ 
+-	/* read sql collation info */
+-	if (IS_TDS71_PLUS(tds) && is_collate_type(curcol->on_server.column_type)) {
+-		tds_get_n(tds, curcol->column_collation, 5);
+-		curcol->char_conv =
+-			tds_iconv_from_collate(tds, curcol->column_collation);
+-	}
++	tdsdump_log(TDS_DBG_INFO1, "processing result. column_size %d\n", curcol->column_size);
+ 
+ 	/* Adjust column size according to client's encoding */
+ 	curcol->on_server.column_size = curcol->column_size;
+@@ -1925,37 +1817,7 @@ tds5_process_result(TDSSOCKET * tds)
+ 
+ 		tds_set_column_type(tds, curcol, tds_get_byte(tds));
+ 
+-		switch (curcol->column_varint_size) {
+-		case 4:
+-			if (curcol->column_type == SYBTEXT || curcol->column_type == SYBIMAGE) {
+-				curcol->column_size = tds_get_int(tds);
+-
+-				/* save name */
+-				curcol->table_namelen =
+-					tds_get_string(tds, tds_get_smallint(tds), curcol->table_name, sizeof(curcol->table_name) - 1);
+-			} else
+-				tdsdump_log(TDS_DBG_INFO1, "UNHANDLED TYPE %x\n", curcol->column_type);
+-			break;
+-		case 5:
+-			curcol->column_size = tds_get_int(tds);
+-			break;
+-		case 2:
+-			curcol->column_size = tds_get_smallint(tds);
+-			break;
+-		case 1:
+-			curcol->column_size = tds_get_byte(tds);
+-			break;
+-		case 0:
+-			curcol->column_size = tds_get_size_by_type(curcol->column_type);
+-			break;
+-		}
+-
+-		/* numeric and decimal have extra info */
+-		if (is_numeric_type(curcol->column_type)) {
+-			curcol->column_prec = tds_get_byte(tds);	/* precision */
+-			curcol->column_scale = tds_get_byte(tds);	/* scale */
+-			/* FIXME check prec/scale, don't let server crash us */
+-		}
++		tds_data_get_info(tds, curcol);
+ 
+ 		/* Adjust column size according to client's encoding */
+ 		curcol->on_server.column_size = curcol->column_size;
+@@ -3023,37 +2885,7 @@ tds5_process_dyn_result2(TDSSOCKET * tds)
+ 		/* column type */
+ 		tds_set_column_type(tds, curcol, tds_get_byte(tds));
+ 
+-		/* column size */
+-		switch (curcol->column_varint_size) {
+-		case 5:
+-			curcol->column_size = tds_get_int(tds);
+-			break;
+-		case 4:
+-			if (curcol->column_type == SYBTEXT || curcol->column_type == SYBIMAGE) {
+-				curcol->column_size = tds_get_int(tds);
+-				/* read table name */
+-				curcol->table_namelen =
+-					tds_get_string(tds, tds_get_smallint(tds), curcol->table_name,
+-						       sizeof(curcol->table_name) - 1);
+-			} else
+-				tdsdump_log(TDS_DBG_INFO1, "UNHANDLED TYPE %x\n", curcol->column_type);
+-			break;
+-		case 2:
+-			curcol->column_size = tds_get_smallint(tds);
+-			break;
+-		case 1:
+-			curcol->column_size = tds_get_byte(tds);
+-			break;
+-		case 0:
+-			break;
+-		}
+-
+-		/* numeric and decimal have extra info */
+-		if (is_numeric_type(curcol->column_type)) {
+-			curcol->column_prec = tds_get_byte(tds);	/* precision */
+-			curcol->column_scale = tds_get_byte(tds);	/* scale */
+-			/* FIXME check prec/scale, don't let server crash us */
+-		}
++		tds_data_get_info(tds, curcol);
+ 
+ 		/* Adjust column size according to client's encoding */
+ 		curcol->on_server.column_size = curcol->column_size;