独角兽企业重金招聘Python工程师标准>>>
CREATE DEFINER=`root`@`%` FUNCTION `request_count`(`p_id` INT) RETURNS int(11)
READS SQL DATA
COMMENT 'Active request count for a product'
BEGIN
DECLARE request_count INTEGER;
SELECT
COUNT(request_id)
INTO
request_count
FROM tbl_request
LEFT JOIN tbl_reviewer USING (reviewer_id)
WHERE
tbl_request.emailed=0 AND
tbl_request.hidden=0 AND
tbl_request.confirmed=0 AND
tbl_reviewer.banned=0 AND
tbl_reviewer.active_vouchers < tbl_reviewer.max_active_vouchers*2 AND
tbl_request.product_id=p_id;
RETURN request_count;
END
对于definer来说就是定义这个函数是哪个用户定义的。定义的用户拥有它的调用权。
如果想要给别人调用可以设置
当函数被定义成invoker的时候。任何人调用都是可以的