freetds AT lists.ibiblio.org
Subject: FreeTDS Development Group
List archive
Re: [freetds] mssql_execute(): stored procedure execution failed
- From: Robert Gonzalez <robert AT robert-gonzalez.com>
- To: FreeTDS Development Group <freetds AT lists.ibiblio.org>
- Subject: Re: [freetds] mssql_execute(): stored procedure execution failed
- Date: Wed, 2 Jun 2010 10:10:05 -0700
If you are good with the notion of rewriting your code, you could always hit
the database directly with mssql_query(). You can use mssql_next_result()
for multiple result sets with it too. I do that all the time in all of my
SQL Server code. But that would probably require you to rewrite all of your
queries. Not sure if that is something you are interested in doing.
Another, better, option is to do what you are doing with wrapping the calls.
The one thing you need to do though is free up your result instead of just
returning it. But that carries with it the additional overhead of converting
all of your result resources into arrays before returning them, which can
get memory intensive for a large volume of queries or for very large data
sets. Seems to me to be a bit of catch 22 in this case.
On Wed, Jun 2, 2010 at 3:06 AM, Sylvain Viart - Gmail <
sylvain.viart AT gmail.com> wrote:
> Hi Robert,
>
> On 28/05/2010 17:44, Robert Gonzalez wrote:
> > The fix is to free your result resources before sending another init
> request
> > to the server. I think you are running into something that has been
> causing
> > issues for a while, most recently in PDO as an unbuffered query error.
> What
> > is happening is the server is sending back a result but the response is
> > being held open on it until the next direct query is sent. But since you
> are
> > not sending a query and rather sending an init call the server is choking
> on
> > the request.
> >
> > After every one of your queries and subsequent result reads, try adding
> in a
> > call to mssql_free_result($yourResultVar). That should make your problem
> go
> > away. At least it did for me in my testing just now
> Yes, may be.
> I'm gonna try that.
>
> One try we made, which totaly crash the lib (may be somewhere in apache
> + persistent connection + freetds)
>
> Was to replace the most failing mssql_init() call with a function wrapper :
>
> here's the wrapper code
>
> // $rt = call_proc("linsyn_mail_exclusion_get",
> // "@id", $in,
> // "@type", $tag_mail
> // );
> function call_proc($procname)
> {
> global $conn;
> $sql = "EXEC $procname ";
>
> // lecture des paramètres en paire
> $n = func_num_args();
> for($i = 1;$i < $n; $i += 2)
> {
> $param = func_get_arg($i);
> $var = func_get_arg($i + 1);
>
> // composition
> $sql .= "$param = ";
>
> if(is_int($var))
> {
> $sql .= $var;
> }
> else
> {
> $sql .= "'$var'";
> }
>
> if($i < $n - 2)
> $sql .= ', ';
> }
>
> my_log("call_proc($sql)");
> return mssql_query($sql, $conn);
> }
>
>
> This code (legacy):
> $ps = mssql_init("linsyn_priv_get");
> $result = mssql_execute($ps);
> mssql_free_statement($ps);
>
>
> became:
>
> $result = call_proc("linsyn_priv_get");
>
> It makes all mssql_init() failing, on all query and all pages on the web
> site, nothing works anymore.
> I've to revert the code and restart apache to get it back.
>
> hum...
> If only I was able to get a valuable error log...
>
> Regards,
> Sylvain.
>
> _______________________________________________
> FreeTDS mailing list
> FreeTDS AT lists.ibiblio.org
> http://lists.ibiblio.org/mailman/listinfo/freetds
>
--
Robert Gonzalez
http://www.robert-gonzalez.com
http://twitter.com/RobertGonzalez
http://www.linkedin.com/in/robertanthonygonzalez
-
Re: [freetds] mssql_execute(): stored procedure execution failed,
Sylvain Viart - Gmail, 06/02/2010
-
Re: [freetds] mssql_execute(): stored procedure execution failed,
Robert Gonzalez, 06/02/2010
- Re: [freetds] mssql_execute(): stored procedure execution failed, Sylvain Viart - Gmail, 06/08/2010
-
Re: [freetds] mssql_execute(): stored procedure execution failed,
Robert Gonzalez, 06/02/2010
Archive powered by MHonArc 2.6.24.