plpgsql_check is a linter tool (does source code static analyze) for the PostgreSQL language plpgsql (the native language for PostgreSQL store procedures).
Found below observation when trigger function returns scaler variable instead of TRIGGER.
Please refer below example, where I am getting cache lookup failed error in RETURN error.
create table t1 (v1 int);
CREATE OR REPLACE FUNCTION public.test_fun()
RETURNS trigger
LANGUAGE plpgsql
AS $function$
declare
v1 int:=10;
BEGIN
update t1 set v1=10;
RETURN v1;
END;
$function$;
create or replace trigger trig1
before update on t1
for each row
execute function test_fun();
plpgsql_check_db@115226=#select * from plpgsql_check_function('test_fun()', 't1');
plpgsql_check_function
-----------------------------------------------------
error:XX000:6:RETURN:cache lookup failed for type 0
(1 row)
I think, here we should throw some meaningful error message.
Found below observation when trigger function returns scaler variable instead of TRIGGER.
Please refer below example, where I am getting cache lookup failed error in RETURN error.
I think, here we should throw some meaningful error message.