CREATE PROCEDURE p_dir_info (in user varchar(20), in parent_path varchar(255))
BEGIN
select * from
(select d.user, d.path , d.parent_path, d.dir, d.create_time ,
(case isnull(sum(f.count)) when true then 0 else sum(f.count) end) as count,
(case isnull(sum(f.size)) when true then 0 else sum(f.size) end) as size
from t_directories d left join
(select path, count(file) as count, sum(size) as size from t_files group by path) f on instr(f.path, d.path) = 1
where d.user=user and d.parent_path=parent_path group by path) dir order by create_time;
END;
仅保留这些代码我是实的能用