January 2019
Beginner
556 pages
14h 19m
English
When using PostgreSQL functions, you need to be careful not to end up with dangling functions, since the dependency between functions is not well maintained in the PostgreSQL system catalog. The following example shows how you can end up with a dangling function:
CREATE OR REPLACE FUNCTION test_dep (INT) RETURNS INT AS $$BEGIN RETURN $1;END;$$LANGUAGE plpgsql;CREATE OR REPLACE FUNCTION test_dep_2(INT) RETURNS INT AS $$BEGIN RETURN test_dep($1);END;$$LANGUAGE plpgsql;DROP FUNCTION test_dep(int);
The test_dep_2 function is dangling. When this function is invoked, an error will be raised, as follows:
SELECT test_dep_2 (5);ERROR: function test_dep(integer) does not existLINE 1: SELECT test_dep($1)^HINT: No function matches ...
Read now
Unlock full access