[MDEV-19143] Unexpected data from server for specific scenario of statement execution with mysql_stmt_send_long_data Created: 2019-04-02  Updated: 2019-04-06

Status: Open
Project: MariaDB Server
Component/s: Prepared Statements, Protocol
Affects Version/s: 10.3.13
Fix Version/s: 10.3

Type: Bug Priority: Major
Reporter: Anatoly Ikorsky Assignee: Oleksandr Byelkin
Resolution: Unresolved Votes: 0
Labels: None

Attachments: File test.c    

 Description   

Steps to reproduce:

  • Prepare statement SELECT ?
  • Execute with MYSQL_TYPE_LONGLONG parameter (e.g. 42)
  • Read result (will be 42 as expected)
  • Execute with MYSQL_TYPE_VAR_STRING using mysql_stmt_send_long_data (e.g. 'AAAAAAAA')
  • Read incorrect result (will be '94624714364288' instead of expected 'AAAAAAAA')

At the protocol level (without packet headers):

Prepare:
1653 454c 4543 5420 3f
Response:
0002 0000 0001 0001 0000 0000 <-- OK
0364 6566 0000 0001 3f00 0c3f 0000 0000 0006 8000 0000 00 <-- param definition
fe00 0002 00 <-- EOF
0364 6566 0000 0001 3f00 0c3f 0000 0000 0006 8000 0000 00 <-- column definition
fe00 0002 00 <-- EOF
 
Execute with LONGLONG 0x44332211223344:
1702 0000 0000 0100 0000 0001 0800 4433 2211 1122 3344
Response:
01 <-- columns count
0364 6566 0000 0001 3f00 0c3f 0015 0000 0008 8100 0000 00 <-- column definition
fe00 0002 00 <-- EOF
0000 4433 2211 1122 3344 <- row
fe00 0002 00 <-- EOF
 
Execute with VAR_STRING 'AAAAAAAA':
1802 0000 0000 0041 4141 4141 4141 41 <-- send long data
1702 0000 0000 0100 0000 0101 fd00 <-- execute
Response:
01 <-- columns count
03 6465 6600 0000 013f 000c 3f00 1500 0000 fd81 0000 0000 <-- column definition
fe00 0002 00 <-- EOF
00 000e 3934 3632 3437 3134 3336 3432 3838 <-- row with unexpected bytes
fe00 0002 00 <-- EOF

Code:

The code to reproduce the issue is in attachement (test.c).
It's quite messy but do the job. Originally this behavior was revealed during tests of the native rust driver against latest 10.3 and latest 10.4 (on circleci).

Info

MariaDb 5.5 is not affected.
Unexpected string ('94624714364288') is always the same, i.e something like this:
PREPARE SELECT ?, ?, ?
EXECUTE WITH 42, 42, 42 -> (42, 42, 42)
EXECUTE WITH 'AAAA', 'AAAA', 42 -> ('94624714364288', '94624714364288', 42)


Generated at Thu Feb 08 08:49:23 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.