@@ -275,75 +275,7 @@ public async Task<bool> ReadAsync(IOBehavior ioBehavior, CancellationToken cance
275275 }
276276 }
277277
278- if ( row is null )
279- {
280- bool isBinaryRow = false ;
281- if ( payload . HeaderByte == 0 && ! resultSet . Connection . IgnorePrepare )
282- {
283- // this might be a binary row, but it might also be a text row whose first column is zero bytes long; try reading
284- // the row as a series of length-encoded values (the text format) to see if this might plausibly be a text row
285- var isTextRow = false ;
286- var reader = new ByteArrayReader ( payload . Span ) ;
287- var columnCount = 0 ;
288- while ( reader . BytesRemaining > 0 )
289- {
290- int length ;
291- var firstByte = reader . ReadByte ( ) ;
292- if ( firstByte == 0xFB )
293- {
294- // NULL
295- length = 0 ;
296- }
297- else if ( firstByte == 0xFC )
298- {
299- // two-byte length-encoded integer
300- if ( reader . BytesRemaining < 2 )
301- break ;
302- length = unchecked ( ( int ) reader . ReadFixedLengthUInt32 ( 2 ) ) ;
303- }
304- else if ( firstByte == 0xFD )
305- {
306- // three-byte length-encoded integer
307- if ( reader . BytesRemaining < 3 )
308- break ;
309- length = unchecked ( ( int ) reader . ReadFixedLengthUInt32 ( 3 ) ) ;
310- }
311- else if ( firstByte == 0xFE )
312- {
313- // eight-byte length-encoded integer
314- if ( reader . BytesRemaining < 8 )
315- break ;
316- length = checked ( ( int ) reader . ReadFixedLengthUInt64 ( 8 ) ) ;
317- }
318- else if ( firstByte == 0xFF )
319- {
320- // invalid length prefix
321- break ;
322- }
323- else
324- {
325- // single-byte length
326- length = firstByte ;
327- }
328-
329- if ( reader . BytesRemaining < length )
330- break ;
331- reader . Offset += length ;
332- columnCount ++ ;
333-
334- if ( columnCount == resultSet . ColumnDefinitions ! . Length )
335- {
336- // if we used up all the bytes reading exactly 'ColumnDefinitions' length-encoded columns, then assume this is a text row
337- if ( reader . BytesRemaining == 0 )
338- isTextRow = true ;
339- break ;
340- }
341- }
342-
343- isBinaryRow = ! isTextRow ;
344- }
345- row = isBinaryRow ? ( Row ) new BinaryRow ( resultSet ) : new TextRow ( resultSet ) ;
346- }
278+ row ??= resultSet . Command . TryGetPreparedStatements ( ) is null ? new TextRow ( resultSet ) : new BinaryRow ( resultSet ) ;
347279 row . SetData ( payload . Memory ) ;
348280 resultSet . m_hasRows = true ;
349281 resultSet . BufferState = ResultSetState . ReadingRows ;
0 commit comments