Re: Status of UTF-8 support in 0.83 dev
"ZIGLIO, Frediano, VF-IT" <[email protected]>
| Newsgroups | gmane.comp.db.tds.freetds |
|---|---|
| Message-ID | <[email protected]> |
> > Frediano, > > I have just tested latest sources with SQLBindParameter using: > > ParameterType = SQL_WVARCHAR > ColumnSize = 2 > > It works now but I just wanted to confirm something with you: > > When binding with SQL_VARCHAR (no W) with ColumnSize=20, SQL Server > Profile trace shows the parameter for sp_prepare is defined as: > > @P1 VARCHAR(20) > > When binding with SQL_WVARCHAR, I see following type: > > @P1 NVARCHAR(40) > ^^----!!! > > Even if ColumnSize=20 ... > > Why 40 and not 20? Is this expected? > Try this patch freddy77 _______________________________________________ FreeTDS mailing list [email protected] http://lists.ibiblio.org/mailman/listinfo/freetds
vedi.diff
(application/octet-stream, 3.1 KB)
Index: src/tds/query.c
===================================================================
RCS file: /cvs/freetds/freetds/src/tds/query.c,v
retrieving revision 1.226
diff -u -1 -0 -r1.226 query.c
--- src/tds/query.c 4 Sep 2008 06:43:49 -0000 1.226
+++ src/tds/query.c 8 Sep 2008 14:18:33 -0000
@@ -48,20 +48,21 @@
TDS_RCSID(var, "$Id: query.c,v 1.226 2008/09/04 06:43:49 freddy77 Exp $");
static void tds_put_params(TDSSOCKET * tds, TDSPARAMINFO * info, int flags);
static void tds7_put_query_params(TDSSOCKET * tds, const char *query, int query_len);
static void tds7_put_params_definition(TDSSOCKET * tds, const char *param_definition, size_t param_length);
static int tds_put_data_info(TDSSOCKET * tds, TDSCOLUMN * curcol, int flags);
static int tds_put_data(TDSSOCKET * tds, TDSCOLUMN * curcol);
static char *tds7_build_param_def_from_query(TDSSOCKET * tds, const char* converted_query, int converted_query_len, TDSPARAMINFO * params, size_t *out_len);
static char *tds7_build_param_def_from_params(TDSSOCKET * tds, const char* query, size_t query_len, TDSPARAMINFO * params, size_t *out_len);
+static int tds_fix_column_size(TDSSOCKET * tds, TDSCOLUMN * curcol);
static int tds_send_emulated_execute(TDSSOCKET * tds, const char *query, TDSPARAMINFO * params);
static const char *tds_skip_comment(const char *s);
static int tds_count_placeholders_ucs2le(const char *query, const char *query_end);
#define TDS_PUT_DATA_USE_NAME 1
#define TDS_PUT_DATA_PREFIX_NAME 2
#undef MIN
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
@@ -606,24 +607,27 @@
* \param tds state information for the socket and the TDS protocol
* \param curcol column
* \param out buffer to hold declaration
* \return TDS_FAIL or TDS_SUCCEED
*/
static int
tds_get_column_declaration(TDSSOCKET * tds, TDSCOLUMN * curcol, char *out)
{
const char *fmt = NULL;
int max_len = IS_TDS7_PLUS(tds) ? 8000 : 255;
+ int size;
CHECK_TDS_EXTRA(tds);
CHECK_COLUMN_EXTRA(curcol);
+ size = tds_fix_column_size(tds, curcol);
+
switch (tds_get_conversion_type(curcol->on_server.column_type, curcol->on_server.column_size)) {
case XSYBCHAR:
case SYBCHAR:
fmt = "CHAR(%d)";
break;
case SYBVARCHAR:
case XSYBVARCHAR:
fmt = "VARCHAR(%d)";
break;
case SYBINT1:
@@ -690,49 +694,48 @@
break;
case SYBNTEXT:
if (IS_TDS7_PLUS(tds))
fmt = "NTEXT";
break;
case SYBNVARCHAR:
case XSYBNVARCHAR:
if (IS_TDS7_PLUS(tds)) {
fmt = "NVARCHAR(%d)";
max_len = 4000;
+ size /= 2;
}
break;
case XSYBNCHAR:
if (IS_TDS7_PLUS(tds)) {
fmt = "NCHAR(%d)";
max_len = 4000;
+ size /= 2;
}
break;
/* nullable types should not occur here... */
case SYBFLTN:
case SYBMONEYN:
case SYBDATETIMN:
case SYBBITN:
case SYBINTN:
assert(0);
/* TODO... */
case SYBVOID:
case SYBSINT1:
case SYBUINT2:
case SYBUINT4:
case SYBUINT8:
case SYBVARIANT:
break;
}
if (fmt) {
- TDS_INT size = curcol->on_server.column_size;
- if (!size)
- size = curcol->column_size;
/* fill out */
sprintf(out, fmt, size > 0 ? (size > max_len ? max_len : size) : 1);
return TDS_SUCCEED;
}
out[0] = 0;
return TDS_FAIL;
}
/**
smime.p7s
(application/x-pkcs7-signature, 3.1 KB) - not displayed