[freetds] freebcp loads -1 rows

Frediano Ziglio freddyz77 at tin.it
Mon Jun 9 10:19:06 EDT 2003

Il ven, 2003-06-06 alle 21:39, Lowden, James K ha scritto:
> > From: Lowden, James K [mailto:LowdenJK at bernstein.com]
> > Sent: June 5, 2003 1:35 PM
> > 
> > The message from freebcp is "-1 rows copied."
> > 
> > I have a feeling tds_process_simple_query() isn't playing 
> > nicely in _bcp_exec_in(), but it's not clear to me what 
> > should be done.  
> Freddy, 
> For the time being, I added "tds_do_until_done()" and substituted it for
> tds_process_simple_query() at the tail end of _bcp_exec_in().  freebcp now
> loads the table it was failing to load, as it had done with bcp.c revision
> 1.65.  
> My fix probably leaves TDS 5.0 broken, because that branch of the code
> relies on tds_process_simple_query().  I left it that way in case you're
> intending to fix/replace tds_process_simple_query() yourself.  Let me know
> which way you want to go.  
> The problem, as you can see by comparing the two functions, is that
> tds_process_simple_query() wasn't setting tds->rows_affected.  I think
> that's because it doesn't insist on seeing a TDS_DONE_TOKEN before it
> returns.  That is, it returns too early, resulting in an incomplete TDS
> conversation, and the server never commits the row(s).  

tds_process_simple_query should set rows_affected using
tds_process_end... tds_process_simple_query read from wire until state
is complete or a failure is detected. Perhaps this is the real problem
(some TDS_DONE_TOKEN overwrite your rows count)...

> Perhaps tds_process_simple_query() should be called
> "tds_discard_query_results()"?  
> Bill, Marc, please try tonight's snapshot and tell me how you fare.  


More information about the FreeTDS mailing list