# plpgsql_check — Postgres extension

> Lint PL/pgSQL functions before they run.

Source: https://scribase.com/extensions/plpgsql_check

Category: Development. Version: 2.10. Optional, enabled per project.

## About

PL/pgSQL only checks a function body when each statement runs, so a typo in a rarely used branch can sit unnoticed. plpgsql_check analyses the whole function ahead of time: unknown columns, type mismatches, unused variables and missing RETURN paths.

## Enable it

```sql
create extension if not exists plpgsql_check with schema extensions;
```

## Example

```sql
select * from plpgsql_check_function('public.handle_new_user()');

-- every PL/pgSQL function in public
select p.proname, c.*
from pg_proc p
cross join lateral plpgsql_check_function(p.oid) c
where p.pronamespace = 'public'::regnamespace
  and p.prolang = (select oid from pg_language where lanname = 'plpgsql');
```

Upstream: https://github.com/okbob/plpgsql_check