re-use of dbprocess structure (was: Re: [freetds] state of dbrpcsend())

liam at inodes.org liam at inodes.org
Thu Jul 15 01:38:30 EDT 2004


On Thu, Jul 08, 2004 at 11:50:58AM +0200, Frediano Ziglio wrote:

> This patch should fix the problem (committed in 0.63, not in 0.62)

Unfortunately, that patch also introduces a bug where stored procedures 
with no arguments/paramaters can not be executed. The check to 
ensure malloc() has succeeded catches the case where param_info_alloc()
correctly does to return anything.

Here is a patch that fixes the issue.

--- rpc.c       2004-06-14 09:43:36.000000000 +1000
+++ rpc.c      2004-07-15 15:23:10.000000000 +1000
@@ -239,10 +239,22 @@
 
        for (rpc = dbproc->rpc; rpc != NULL; rpc = rpc->next) {
                int erc;
-               TDSPARAMINFO *pparam_info = param_info_alloc(dbproc->tds_socket, rpc);
+               TDSPARAMINFO *pparam_info = NULL;
+
+               /* liam at inodes.org: allow stored procedures to have no
+                * paramaters 
+                */
+               if (rpc->param_list != NULL) {
+                       pparam_info = param_info_alloc(dbproc->tds_socket, rpc);
+                       if (!pparam_info)
+                       return FAIL;
+               }
+
+               erc = tds_submit_rpc(dbproc->tds_socket, 
+                                    dbproc->rpc->name, pparam_info); 
+
+               tds_free_param_results(pparam_info);
 
-               erc = tds_submit_rpc(dbproc->tds_socket, dbproc->rpc->name, pparam_info);
-               ;

Can this be commited to CVS please.

I suspect the source distribution needs some more comprehensive RPC unit 
tests. Unless there are any objections, I will write some.

Cheers.



More information about the FreeTDS mailing list