2

How can I know table (table_1) is being used in which all UDF?

Below query gives me table's details:

SELECT * FROM information_schema.tables;

Below Query gives UDF details:

select * FROM pg_proc;

But how can I know that table1 is used in which all UDF?

1 Answer 1

2

A string search in the prosrc column of pg_proc is the only way if you want to find dependencies between functions and tables.

Of course that is not very satisfying, because it would be rather difficult to say if – say – an occurrence of table_1 is a reference to the table or a variable name. Also, you cannot find the source of C functions in the catalog.

To get a reliable answer, you would need insight into the language in which the function is written, and here is the core of the problem: PostgreSQL does not have any insight into the language! PostgreSQL's fabled extensibility allows you to define new languages for functions, and only the language handler knows how to interpret the string that is the function body. That also holds for PL/pgSQL which is shipped with PostgreSQL.

That is also the reason why there are no pg_depend entries for objects used in functions.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.