Skip to Content.
Sympa Menu

freetds - RE: [freetds] ODBC bug: server errors not reported

freetds AT lists.ibiblio.org

Subject: FreeTDS Development Group

List archive

Chronological Thread  
  • From: "Lowden, James K" <LowdenJK AT bernstein.com>
  • To: "FreeTDS Development Group" <freetds AT lists.ibiblio.org>
  • Subject: RE: [freetds] ODBC bug: server errors not reported
  • Date: Wed, 10 Mar 2004 13:06:07 -0500

> From: ZIGLIO, Frediano, VF-IT [mailto:Frediano.Ziglio AT vodafone.com]
> Sent: March 10, 2004 3:36 AM
> >
> > if (discard_test < 1) {
> > /* generate an error */
> > printf("discard_test is %d\n", discard_test);
> > result = CommandWithResult(Statement, "EXEC testerror");
>
> Using ODBC you must read all results, or call
> SQLFreeStmt(CLOSE/DROP)/SQLFreeHandle/SQLCloseCursor.

I committed a corrected version. It executes the query and fetches the
results, looking for errors from SQLFetch & Co., and (while we're at it)
makes sure the fetched value matches the inserted value. ;-)

We're out of spec, I'm sure. The docs say that if a row has an error (e.g.
division by zero), SQLFetch eventually returns SQL_SUCCESS_WITH_INFO "unless
an error occurs in every row ... in which case it returns SQL_ERROR. In
particular, if the rowset size is 1 and an error occurs in that row, SQLFetch
returns SQL_ERROR."

Our SQLFetch is wrong on both counts. It's returning SQL_SUCCESS when it
should at least return SQL_SUCCESS_WITH_INFO. My test tries the more extreme
case, where every row (or the only row) has a division-by-zero error, which
should return SQL_ERROR.

DBD::ODBC is somehow finding the error, BTW. Perhaps it's inspecting the row
status array.

> This raise another question: what's correct result calling
> SQLFreeStmt(CLOSE/DROP)/SQLFreeHandle/SQLCloseCursor with
> error pending??

You listening, Steve Murphree? Feel free to jump in any time.

> We are not speaking about how to read data from a
> simple select but how and when retrieve an error when a given weird
> condition happen!

I agree, it's progress, that's for sure. :-)

It's really not so very weird, though. It's quite common for stored
procedures to include multiple result sets. And, even though it never
happens to you or me, it's also not all that rare for them to generate
errors. Really, you'd be amazed.

Now that the basic functionality is there, I think we're finding that our
testing methodology needs revamping. What we really need is one "isql" for
each API that is specialized to test SQL scripts. The "isql" would be
generalized handle all the kinds of results (regular, compute, parameter,
return status) we can handle, and could also exercise the forthcoming
column-wise fetching. It would serve not only as a test harness, but also as
an example of correct use of the API.

With a program like that, we could try to generate errors and such just by
altering the external SQL. (We'd need some special syntax to test
placeholders.)

+++

Freddy, if you can see your way to fixing this, I'd like to issue a new
release this weekend. How does that strike you?

Regards,

--jkl

-----------------------------------------
The information contained in this transmission may contain privileged and
confidential information and is intended only for the use of the person(s)
named above. If you are not the intended recipient, or an employee or agent
responsible for delivering this message to the intended recipient, any
review, dissemination, distribution or duplication of this communication is
strictly prohibited. If you are not the intended recipient, please contact
the sender immediately by reply e-mail and destroy all copies of the original
message. Please note that we do not accept account orders and/or instructions
by e-mail, and therefore will not be responsible for carrying out such orders
and/or instructions.
If you, as the intended recipient of this message, the purpose of which is to
inform and update our clients, prospects and consultants of developments
relating to our services and products, would not like to receive further
e-mail correspondence from the sender, please "reply" to the sender
indicating your wishes. In the U.S.: 1345 Avenue of the Americas, New York,
NY 10105.






Archive powered by MHonArc 2.6.24.

Top of Page