plpgsql_check is a linter tool (does source code static analyze) for the PostgreSQL language plpgsql (the native language for PostgreSQL store procedures).
show shared_preload_libraries;
plpgsql,pg_stat_statements,plpgsql_check
SELECT VERSION();
PostgreSQL 15.4 (Debian 15.4-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
create or replace procedure demo_procedure() as
$body$
declare
l_cur refcursor;
l_str varchar;
begin
open l_cur for execute 'select $1 as p_x' using 'some text';
FETCH l_cur INTO l_str;
raise notice '%', l_str;
end;
$body$ language plpgsql;
set plpgsql_check.profiler = on;
call demo_procedure();
fails with error:
[42P02] ERROR: there is no parameter $1
PL/pgSQL function demo_procedure() line 13 at OPEN
Hi Here is a test:
when profiler is off, same code works well