freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] big commit: language command variable support added
- From: Frediano Ziglio <freddyz77 AT tin.it>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] big commit: language command variable support added
- Date: 07 Mar 2003 07:59:32 +0100
Il ven, 2003-03-07 alle 01:09, Mark J. Lilback ha scritto:
> I've committed changes to support variable bindings with TDS 5.0.
> I'll get to TDS 7/8 next.
>
> This required the addition of a parameter to tds_submit_query
> (otherwise, I'd be duplicating the function entirely), so this change
> touched a number of files.
>
> I also added a test for it, but it fails when talking to MS SQL
> Server since I haven't configured this to work with TDS 7. (But then,
> I got a failure on a make check because some of the dblib tests don't
> work with Sybase.)
>
> This change lets you send queries such as "insert into foo (col1,
> col2) values (@param1, @param2)" and then call ct_param to bind
> values to the variables by name or by order. I haven't implemented
> ct_setparam yet, but that should be pretty trivial to do. (Actually,
> it was all pretty easy to do thanks to Bill's work for rpc.)
>
> One thing that might be necessary to do is cleanup the CS_COMMAND
> structure more often. According to the Sybase docs, a call to
> ct_command, ct_cursor, ct_dynamic, or ct_sendpassthru (which we don't
> even stub out) causes any previously initiated command information to
> be discarded. We do not appear to be doing this anywhere. I added
> some code to the top of those functions to clear our the parameter
> information stored by ct_param, but we likely need a function that
> cleans up all the currently stored data so a new command can be
> initiated with the same structure.
Wonderful!!!
Only one point. In cs.c
case SYBINT1:
case SYBINT2:
case SYBINT4:
case SYBFLT8:
case SYBREAL:
case SYBBIT:
- case SYBBITN:
case SYBMONEY:
case SYBMONEY4:
case SYBDATETIME:
case SYBDATETIME4:
- if (src_len > destlen) {
- ret = CS_FAIL;
- } else {
- memcpy(dest, srcdata, src_len);
+ memcpy(dest, srcdata,
_cs_datatype_length(src_type));
if (resultlen != (CS_INT *) NULL)
- *resultlen = src_len;
+ *resultlen =
_cs_datatype_length(src_type);
ret = CS_SUCCEED;
- }
break;
+ case SYBBITN:
case SYBNUMERIC:
case SYBDECIMAL:
if (src_len > destlen) {
ret = CS_FAIL;
Why BITN are treated like numeric? Does ct_convert ignore destination
length for fixed types?
Also, to support the same on TDS7/8: use mix prepare and execute code
and call sp_prepexec RPC (it do something like sp_prepare, sp_execute,
sp_unprepare), see code in query.c.
freddy77
-
[freetds] big commit: language command variable support added,
Mark J. Lilback, 03/06/2003
-
Re: [freetds] big commit: language command variable support added,
Frediano Ziglio, 03/07/2003
- Re: [freetds] big commit: language command variable support added, Mark J. Lilback, 03/07/2003
- <Possible follow-up(s)>
- RE: [freetds] big commit: language command variable support added, ZIGLIO Frediano, 03/07/2003
- RE: [freetds] big commit: language command variable support added, ZIGLIO Frediano, 03/07/2003
- RE: [freetds] big commit: language command variable support added, Thompson, Bill D (London), 03/07/2003
- RE: [freetds] big commit: language command variable support added, Thompson, Bill D (London), 03/07/2003
-
RE: [freetds] big commit: language command variable support added,
Thompson, Bill D (London), 03/12/2003
-
RE: [freetds] big commit: language command variable support added,
Mark J. Lilback, 03/12/2003
- RE: [freetds] big commit: language command variable support added, Frediano Ziglio, 03/12/2003
-
RE: [freetds] big commit: language command variable support added,
Mark J. Lilback, 03/12/2003
- RE: [freetds] big commit: language command variable support added, Thompson, Bill D (London), 03/12/2003
-
Re: [freetds] big commit: language command variable support added,
Frediano Ziglio, 03/07/2003
Archive powered by MHonArc 2.6.24.