[freetds] dblib bcp, t0017 broken

Frediano Ziglio freddyz77 at tin.it
Sat Jan 28 03:23:51 EST 2006


Il giorno ven, 27/01/2006 alle 15.10 -0500, Lowden, James K ha scritto:
> > From: ZIGLIO, Frediano, VF-IT
> > Sent: Friday, January 27, 2006 11:31 AM
> > 
> > I agree more verbose is better. I noted that in dblib unittests
> > there are a lot of
> > 
> >      while (dbresults(dbproc) != NO_MORE_RESULTS) {
> >              /* nop */
> >      }
> 
> 	:-(  Your're right, there should be a test for error.  That's
> actually related to the next point.  
>  
> > I don't understand INT_CANCEL problem... which error is not reported?
> > I noted that t0017 just store error in ret variable... 
> 
>         fprintf(stderr, "bcp_exec ... ");
>         ret = bcp_exec(dbproc, &rows_copied);
>         if (ret != SUCCEED)
>                 failed = 1;
>         else
>                 fprintf(stderr, "done\n");
> 
> Output:
> 
> 	bcp_exec... DB-LIBRARY error (severity 3, dberr 20070, oserr 0,
> dberrstr I/O error while reading bcp datafile, oserrstr Undefined error:
> 0):
> 	done
> 

Mmm... here there should be no error, probably bcp.c detect eof like
error.

> The error was not detected (ret == SUCCEED), but not for the reason I
> thought.  _bcp_read_hostfile had no way to return a fatal EOF condition,
> so the caller never detected and never returned the error to the
> application.  Fixed in CVS HEAD.
> 
> > > 3.  (small problem) the common.c error handler writes to stderr,
> > > making it unclear amidst stdout where precisely the message
> > > occured.
> > >  For that
> > > reason, I modified t0017 to write some of its feedback to stderr.
> > > Do you think the handler should use stdout instead?
> > > 
> > 
> > I think stderr is for error while stdout for normal output.
> 
> Normally I agree.  The problem is that unit test errors can be
> confusing.  When t0017 writes normal messages to stdout and its error
> handler writes to stderr, I get this:
> 
> bcp_exec... done
> DB-LIBRARY error (severity 3, dberr 20070, oserr 0, dberrstr I/O error
> while reading bcp datafile, oserrstr Undefined error: 0):
> 
> which makes it look like the error came after successful completion of
> bcp_exec.  Writing "bcp_exec... done" to stderr causes the message to be
> interleaved properly:
> 
> bcp_exec... DB-LIBRARY error (severity 3, dberr 20070, oserr 0, dberrstr
> I/O error while reading bcp datafile, oserrstr Undefined error: 0):
> done
> 

This has to to with buffering using setbuf(stdout, NULL); setbuf(stderr,
NULL) will fix this problem. Or use a function that always flush stderr,
something like

void err_printf(const char *fmt, ...)
{
	fflush(stdout);
	...
	vfprintf(stderr, ...);
	fflush(stderr);
}

and always use err_printf instead of fprintf(stderr, ...). For instance
we use fflush on dump.

> > > I don't know how much of this affects 0.64.
> > 
> > I think all :)
> 
> Then I think we should delay the release until we either fix it or give
> up.  I'll work on the RC anyway, betting Bill has his arms around this
> one.  
> 

I think is better to release an RC1 with a known problem (native bcp).

freddy77




More information about the FreeTDS mailing list