0

For example, I want to rename some function and all it's calls from other functions. I would write the function rename_func(schema_name text, old_func_name text, new_func_name text), which must edit other functions.

Where does PostgreSQL store the body of functions (using plpgsql)? I cann't find such column in system tables.

I just can get all functions with

SELECT f.proname, f.prosrc, f.probin   -- trouble: f.prosrc and f.probin are empty
FROM pg_proc f;

but I cann't access to their code.

Evgeny Nozdrev
  • 1,530
  • 12
  • 15
  • 2
    prosrc has the body – Vao Tsun Dec 08 '17 at 09:57
  • Are you sure that those functions with empty body are not internal/c language functions? They used to have empty body indicating that Postgres should call internal/c function using the same name as Postgres function. I don't see any reason anyone would want to rename those. – Łukasz Kamiński Dec 08 '17 at 10:43
  • @ŁukaszKamiński no, that functions has such name as my functions – Evgeny Nozdrev Dec 08 '17 at 11:26

1 Answers1

0

I just couldn't see content of pg_proc.prosrc, but it was present. May be, cause is that it contains multiple strings (I used pgAdmin III). I used it in queries and it worked.

Moreover, I found that pg_get_functiondef(func.oid) returns DDL script which I can modify and execute later to save changes to function.

Thanks to this answer to other question.

Evgeny Nozdrev
  • 1,530
  • 12
  • 15