[MDEV-32441] SENT_ROWS shows random wrong values when stored function is selected Created: 2023-10-10  Updated: 2023-12-15  Resolved: 2023-11-03

Status: Closed
Project: MariaDB Server
Component/s: Information Schema, Stored routines
Affects Version/s: N/A
Fix Version/s: 11.3.1

Type: Bug Priority: Critical
Reporter: Elena Stepanova Assignee: Michael Widenius
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-3953 Add columns for ROWS_EXAMINED & ROWS_... Closed

 Description   

The test case if for reproducing purposes only, don't put it into the regression suite, please create a deterministic one instead.

--source include/have_sequence.inc
 
create function f() returns int return 1;
 
--connect(con1,localhost,root,,)
--let $conid= `select connection_id()`
--send
  select f() from seq_1_to_10000000 where seq%1000000 = 0;
 
--connection default
--let $sent_rows=
 
while (`select INFO is not null from information_schema.processlist where id = $conid`)
{
  --let $rows= `select sent_rows from information_schema.processlist where id = $conid`
  if ($rows != $sent_rows)
  {
    --echo # Found SENT_ROWS = $rows
    --let $sent_rows= $rows
  }
}
--enable_query_log
 
--connection con1
--reap
drop function f;

preview-11.3-preview b09e99ff759

connection default;
# Found SENT_ROWS = 0
# Found SENT_ROWS = 1
# Found SENT_ROWS = 0
# Found SENT_ROWS = 3
# Found SENT_ROWS = 7
# Found SENT_ROWS = 15
# Found SENT_ROWS = 31
# Found SENT_ROWS = 63
# Found SENT_ROWS = 127
# Found SENT_ROWS = 255
# Found SENT_ROWS = 511
# Found SENT_ROWS = 0
connection con1;
f()
1
1
1
1
1
1
1
1
1
1

Not only the values above are wrong (there are only 10 rows sent), but also it jumps from non-zero to zero again (0 => 1 => 0).

If the query is modified to

select f() from seq_1_to_10000000

without WHERE condition, then the SENT_ROWS often jumps from 0 to 2147483647 and back to 0 (but the test case won't work well, as the connection will hit net writing limit).

connect con1,localhost,root,,;
select f() from seq_1_to_10000000;
connection default;
# Found SENT_ROWS = 0
# Found SENT_ROWS = 2147483647
# Found SENT_ROWS = 0
# Found SENT_ROWS = 2147483647
# Found SENT_ROWS = 0
# Found SENT_ROWS = 2147483647
# Found SENT_ROWS = 0
...



 Comments   
Comment by Michael Widenius [ 2023-10-21 ]

This is a related bug (same variable name, different variable)
Running in 10.6:

flush status;
create function if not exists f() returns int return 1;
select f() from seq_1_to_10000000 where seq%1000000 = 0;
show status like "rows_sent";
-> 1023

Comment by Michael Widenius [ 2023-11-03 ]

Was fixed as part of MDEV-32441

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