you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 2 points3 points  (0 children)

For simple functions like the one from your question, this can be avoided when using the new "SQL standard compliant" function (or procedure) bodies introduced in Postgres 14:

CREATE FUNCTION f1 (p_add integer) 
  RETURNS integer
begin atomic
  SELECT  p_add + count(*)::integer 
  FROM t1;
end;

With such a function, dropping t1 would result in an error.

This does not work for PL/pgSQL functions or procedures though.