On 12/16/21 13:48, Jiří Činčura wrote:
Afraid there is - as always :( - no protocol
description except source code. Key ops are op_batch_msg,
op_batch_blob_stream & also op_batch_cs (retuning batch execution state
to client).
Can you create some simple paragraph with the description? Because fishing it 
out from source code takes time and also misses often important details of 
handling some edge cases.

I'm trying to make it work now mostly with hardcoded values and later somehow 
fit it into DbBatch 
(https://docs.microsoft.com/en-us/dotnet/api/system.data.common.dbbatch?view=net-6.0)
 which is new in recent .NET 6. But that has broader features than what's 
possible in Firebird now.
I do op_allocate_statement and op_prepare_statement and then I'm trying op_batch_create. That seems to be reasonable order. But I'm getting (in)famous SQL error code = -804, SQLDA error (isc_sqlerr, isc_dsql_sqlda_err). I'm sending:
0,0,0,99 (op_batch_create)
0,0,0,2 (p_batch_statement - (from op_allocate_statement))
0,0,0,12 (buffer length)
5,2,4,0,2,0,8,0,7,0,255,76 (p_batch_blr buffer)
0,0,0,0,0,0,0,12 (p_batch_msglen)
0,0,0,10 (buffer length)
1,2,4,0,0,0,1,0,0,0 (p_batch_pb buffer - (TAG_RECORD_COUNTS,1))
0,0 (pad)

The BLR is if I'm not mistaken (1 bigint parameter):
5 => blr_version5
2 => blr_begin
4 => blr_message
0 => constant
2,0 => 1 param * 2
8 => blr_long
0 => scale
7 => blr_short
0 => constant
255 => blr_end
76 => blr_eoc

That all looks (obviously :)) correct to me. But it's not, why else would 
server complain? :D What looks weird to me is the length in p_batch_msglen, 
because it's already sent as part of the buffer sending. I'm playing with that 
now.


What makes me very hard to answer your question is that I've never used to look at wire protocol on that low level like exact bytes sequence when writing and debugging batch code. (I've used to do that once, when fixed sending decfloat values between LE/BE machines, but that was only once - and only that problematic 16 bytes.) There are standard ways to send and receive standard things over the wire, and I need not care what exactly was sent.

p_batch_msglen is needed for server to check that in matches message size, calculated based on BLR. And it seems that in your case it does not match - may be because you want bigint parameter but use blr_long.




Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to