I wonder if it is possible to rename Postgres table without cascading type change to dependent objects? For example,
create table test_1(id int);
create function test_1_funct (param test_1[]) returns void as $body$
begin
return;
end
$body$
language plpgsql;
alter table test_1 rename to test_2 ;
-- function test_1_funct signature silently changed,
-- so it now accepts test_2[].
I want to emulate behaviour similar to what Oracle would do – mark function invalid, let me create table with the old name, and recompile the function on demand . As it is, it doesn't let me drop table test_2
.
Best Answer
It isn't. Not should it be. Tables resolve to an oid that represents their relation.
Changing their "name" is essentially a catalog update on
relname
. How would what you're talking about look anyway: what would happen if you calledtest_1_funct
after the rename? What type would it expect?