[freetds] Transaction weirdness

James K. Lowden jklowden at schemamania.org
Wed Oct 8 21:40:00 EDT 2003


On 08 Oct 2003 21:51:07 +0200, John Anderson <panic at semiosix.com> wrote:
> 
> I'm doing a transaction that contains one select statement with
> associated data retrieval and then a stored procedure execute 
> statement.
> Committing the transaction using either SQLTransact or 
> SQLEndTran fails with
> 
> Error: 0, SQLState: S1000, [FreeTDS][SQL Server]Could not 
> perform COMMIT or ROLLBACK

You seem to be missing an earlier error.  In the log:

21:38:14.403685 processing row tokens.  marker is  d1(ROW)
21:38:14.403709 processing row.  column is 0 varint size = 1
21:38:14.403728 processing row.  column size is 5 
21:38:14.403746 clearing column 0 NULL bit
21:38:14.403763 swapping numeric data...

	You're receiving a row, but

convert_tds2sql: src is 108 dest = 1
convert_tds2sql: outputting character data destlen = 41 
SQLTransact(0x0,0x807a550,0)
change_transaction(0x807a550,1)
tds_submit_query(): state is PENDING

	That's an error.  At that point, you should get an error along the lines
of "Attempt to initiate a new SQL Server operation with results pending." 
The ensuing data follow:

SQLFreeHandle(3, 0x80af790)
Sending packet @ 21:38:14.406642
0000 06 01 00 08 00 00 01 00-                        |........|

21:38:14.406748 tds_process_default_tokens() marker is ff(DONEINPROC)
21:38:14.406772 tds_process_end: more_results = 1
21:38:14.406781                  was_cancelled = 0
21:38:14.406789                  error = 0
21:38:14.406795                  done_count_valid = 1
21:38:14.406813                  rows_affected = 1
(etc.)

The rule is, you must fetch or cancel all results before sending more data
to the server.  Why this works with Microsoft's driver, I don't know. 
Maybe they cache your transaction request until the proper time.  



More information about the FreeTDS mailing list