@@ -339,6 +339,38 @@ defmodule MyXQL.Protocol do
339
339
decode_resultset ( payload , next_data , state , & Values . decode_text_row / 2 )
340
340
end
341
341
342
+ # Handle 10-byte packet (DorisDB/Apache Doris - without num_warnings field)
343
+ # DorisDB sends: [0x00 status (1 byte) | statement_id (4 bytes) | num_columns (2 bytes) | num_params (2 bytes) | 0x00 reserved (1 byte)]
344
+ # Total: 10 bytes (missing the 2-byte num_warnings field that MySQL includes after the reserved byte)
345
+ def decode_com_stmt_prepare_response (
346
+ << 0x00 , statement_id :: uint4 ( ) , num_columns :: uint2 ( ) , num_params :: uint2 ( ) , 0x00 >> ,
347
+ next_data ,
348
+ :initial
349
+ ) do
350
+ # DorisDB sends 10-byte packets without num_warnings field
351
+ # Default num_warnings to 0 for compatibility
352
+ result =
353
+ com_stmt_prepare_ok (
354
+ statement_id: statement_id ,
355
+ num_columns: num_columns ,
356
+ num_params: num_params ,
357
+ num_warnings: 0
358
+ )
359
+
360
+ cond do
361
+ num_params > 0 ->
362
+ { :cont , { result , :params , num_params , num_columns } }
363
+
364
+ num_columns > 0 ->
365
+ { :cont , { result , :columns , num_columns } }
366
+
367
+ true ->
368
+ "" = next_data
369
+ { :halt , result }
370
+ end
371
+ end
372
+
373
+ # Handle 12-byte packet (Standard MySQL - with num_warnings field)
342
374
def decode_com_stmt_prepare_response (
343
375
<< 0x00 , statement_id :: uint4 ( ) , num_columns :: uint2 ( ) , num_params :: uint2 ( ) , 0 ,
344
376
num_warnings :: uint2 ( ) >> ,
0 commit comments