Skip to Content.
Sympa Menu

freetds - Re: [freetds] ctlib - Stored Proc Return Status

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: Iain Calder <iain.calder AT blueyonder.co.uk>
  • To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
  • Subject: Re: [freetds] ctlib - Stored Proc Return Status
  • Date: Thu, 29 Jan 2004 20:07:07 +0000

Thompson, Bill D (London) wrote:

Iain,

thanks for the bug report. Your findings look valid to me.

I think we should save tds->ret_status before calling tds_free_all_results
etc, then use the saved value in the last statement of
_ct_process_return_status instead of tds->ret_status.

so....

<snip code block>

Can you do this fix locally and confirm the results ?

thanks,

Bill

The suggested fix works fine for me and I am now getting integer return status from my MSSQL stored proc calls :-)

I would like to thank everyone who worked on the ct_param support for freetds. It's great being able to call MSSQL stored procs properly from Linux code.

Bill - could you comment on the following patch too? - it fixes memory leaks when using ct_param to add stored procedure parameters. ct_param() seems to create temporary param structures which are not freed, and ct_cmd_drop() does not free cmd->rpc structures.

diff -uNr freetds-0.62/src/ctlib/ct.c freetds-0.62.new/src/ctlib/ct.c
--- freetds-0.62/src/ctlib/ct.c 2003-12-26 18:11:08.000000000 +0000
+++ freetds-0.62.new/src/ctlib/ct.c 2004-01-29 11:06:23.000000000 +0000
@@ -1446,6 +1446,12 @@
free(cmd->query);
if (cmd->input_params)
param_clear(cmd->input_params);
+ if (cmd->rpc) {
+ if (cmd->rpc->param_list)
+ param_clear(cmd->rpc->param_list);
+ free(cmd->rpc->name);
+ free(cmd->rpc);
+ }
free(cmd);
}
return CS_SUCCEED;
@@ -2657,16 +2663,14 @@
rpc = cmd->rpc;
pparam = &rpc->param_list;
if (*pparam == NULL) {
- *pparam = (CSREMOTE_PROC_PARAM *)
malloc(sizeof(CSREMOTE_PROC_PARAM));
+ *pparam = param;
} else {
while ((*pparam)->next != NULL) {
pparam = &(*pparam)->next;
}
-
- (*pparam)->next = (CSREMOTE_PROC_PARAM *)
malloc(sizeof(CSREMOTE_PROC_PARAM));
- pparam = &(*pparam)->next;
}
- *pparam = param;
+ (*pparam)->next = param;
+ pparam = &(*pparam)->next;
(*pparam)->next = NULL;
tdsdump_log(TDS_DBG_INFO1, " ct_param() added rpc parameter %s
\n", (*param).name);
return CS_SUCCEED;






Archive powered by MHonArc 2.6.24.

Top of Page