On Mon, Oct 30, 2006 at 07:37:47PM +0000, Martin J. Evans wrote:
> I'm trying to debug a DBD::ODBC problem and the code is full of:
>
> if (ODBC_TRACE_LEVEL(imp_sth) >= 2) {
> PerlIO_printf(DBIc_LOGPIO(imp_dbh), "something");
> PerlIO_flush(DBIc_LOGPIO(imp_dbh));
> }
>
> Are all those PerlIO_flush calls required? I'm finding it difficult to
> see the wood for the trees and I notice other DBDs don't use
> PerlIO_flush. Can they be removed?
Probably. The trick is to set the filehandle to automatic flushing.
Sadly that's a little tricky to do in a perl-version-portable way
(long story) so the DBI does it's best with:
/* If the tests fail with errors about 'setlinebuf' then try */
/* deleting the lines in the block below except the setvbuf one */
#ifndef PerlIO_setlinebuf
#ifdef HAS_SETLINEBUF
#define PerlIO_setlinebuf(f) setlinebuf(f)
#else
#ifndef USE_PERLIO
#define PerlIO_setlinebuf(f) setvbuf(f, Nullch, _IOLBF, 0)
#endif
#endif
#endif
and this in set_trace_file():
/* if this line causes your compiler or linker to choke */
/* then just comment it out, it's not essential. */
PerlIO_setlinebuf(fp); /* force line buffered output */
Tim.