set sql_mode=oracle;
drop table t1;
create table t1 (c1 varchar(30),c2 varchar(150));
insert into t1 values ('A','A');
insert into t1 values ('B','B');
insert into t1 values ('C','C');
create unique index t1_idx on t1(c2,c1);
select max(c1)
    from t1
   where c2='A';
select found_rows();
delimiter @
create or replace procedure p1 (wcount IN OUT VARCHAR(30), wres IN OUT varchar(30))
IS
  c varchar(10);
  fr integer;
begin
  select max(c1) into wres
    from t1
   where c2='A'  ;
  --   group by c2;
  fr:=found_rows();
  if (fr = 0) then
    wcount:='found_rows() is wrong :'||fr;
  else
    wcount:='found rows is ok :'||fr;
  end if;
end;
@
-- Bad result : found_rows() return 0
declare wcount varchar(30);
        wres varchar(30);
begin
  call p1(wcount,wres);
  select wcount,wres;
end
@
drop index t1_idx on t1
@
-- Bad result : found_rows() return 0
declare wcount varchar(30);
        wres varchar(30);
begin
  call p1(wcount,wres);
  select wcount,wres;
end
@


