From: | Michael Paquier <michael(dot)paquier(at)gmail(dot)com> |
---|---|
To: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
Cc: | khuddleston(at)pivotal(dot)io, PostgreSQL mailing lists <pgsql-bugs(at)postgresql(dot)org> |
Subject: | Re: BUG #14706: Dependencies not recorded properly for base types |
Date: | 2017-06-15 06:05:01 |
Message-ID: | CAB7nPqRTpRtypR7gfqYLnmqytC1Xi_=sqnET=YWhSZENrNUz8g@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-bugs |
On Thu, Jun 15, 2017 at 1:53 PM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
> Michael Paquier <michael(dot)paquier(at)gmail(dot)com> writes:
>> On Thu, Jun 15, 2017 at 9:42 AM, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> wrote:
>>> ... but yeah, as long as we're supporting it at all, that shouldn't
>>> happen. Thanks for the report!
>
>> Tom, are you working on a patch? At quick glance, this is just missing a
>> call to recordDependencyOn() in SetFunctionReturnType().
>
> No, I'm going to bed soon. If you want to fix this, have at it.
Okay, here you do. The other two call sites of SetFunctionReturnType
involve triggers and PLs, but those are able to consider correctly
dependencies. For PLs:
=# CREATE FUNCTION mylang_call_handler() RETURNS opaque language c AS
'$libdir/plpgsql', $function$plpgsql_call_handler$function$;
CREATE FUNCTION
=# CREATE language mylang HANDLER mylang_call_handler;
WARNING: 42809: changing return type of function mylang_call_handler
from opaque to language_handler
LOCATION: CreateProceduralLanguage, proclang.c:283
CREATE LANGUAGE
=# drop function mylang_call_handler ();
ERROR: 2BP01: cannot drop function mylang_call_handler() because
other objects depend on it
DETAIL: language mylang depends on function mylang_call_handler()
HINT: Use DROP ... CASCADE to drop the dependent objects too.
LOCATION: reportDependentObjects, dependency.c:963
For triggers:
=# CREATE FUNCTION fn_x_before () RETURNS opaque AS $$
BEGIN
return NEW;
END;
$$ LANGUAGE plpgsql;
CREATE FUNCTION
=# CREATE TABLE aa (a int);
CREATE TABLE
=# CREATE TRIGGER aa_before BEFORE INSERT ON aa FOR EACH ROW EXECUTE
PROCEDURE fn_x_before();
WARNING: 01000: changing return type of function fn_x_before from
opaque to trigger
LOCATION: CreateTrigger, trigger.c:551
CREATE TRIGGER
=# DROP FUNCTION fn_x_before ;
ERROR: 2BP01: cannot drop function fn_x_before() because other
objects depend on it
DETAIL: trigger aa_before on table aa depends on function fn_x_before()
HINT: Use DROP ... CASCADE to drop the dependent objects too.
LOCATION: reportDependentObjects, dependency.c:963
Attached is an idea of patch, inputs welcome. Another idea would be to
deprecate things on HEAD and cause an ERROR when doing such things.
--
Michael
Attachment | Content-Type | Size |
---|---|---|
type-func-deps.patch | application/octet-stream | 4.6 KB |
From | Date | Subject | |
---|---|---|---|
Next Message | Michael Paquier | 2017-06-15 06:07:53 | Re: BUG #14706: Dependencies not recorded properly for base types |
Previous Message | Heikki Linnakangas | 2017-06-15 05:59:21 | Re: BUG #14706: Dependencies not recorded properly for base types |