Thread: PATCH: Improve DROP FUNCTION hint

PATCH: Improve DROP FUNCTION hint

From
Dean Rasheed
Date:
Hi,

Attached is a small patch to improve the HINT message produced by
CREATE OR REPLACE FUNCTION when the new function definition conflicts
with the old definition. With this patch the hint now includes the
function's name and signature as a directly pasteable SQL command. So,
for example, instead of

psql:functions.sql:70: ERROR:  cannot change return type of existing function
HINT:  Use DROP FUNCTION first.

it now says

psql:functions.sql:70: ERROR:  cannot change return type of existing function
HINT:  Use DROP FUNCTION foo(integer,integer) first.

which saves having to open the file, find the function and then type
in the DROP statement manually.

Regards,
Dean

Attachment

Re: PATCH: Improve DROP FUNCTION hint

From
Robert Haas
Date:
On Sat, Jun 9, 2012 at 11:42 AM, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
> Hi,
>
> Attached is a small patch to improve the HINT message produced by
> CREATE OR REPLACE FUNCTION when the new function definition conflicts
> with the old definition. With this patch the hint now includes the
> function's name and signature as a directly pasteable SQL command. So,
> for example, instead of
>
> psql:functions.sql:70: ERROR:  cannot change return type of existing function
> HINT:  Use DROP FUNCTION first.
>
> it now says
>
> psql:functions.sql:70: ERROR:  cannot change return type of existing function
> HINT:  Use DROP FUNCTION foo(integer,integer) first.
>
> which saves having to open the file, find the function and then type
> in the DROP statement manually.

+1.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


Re: PATCH: Improve DROP FUNCTION hint

From
Robert Haas
Date:
On Mon, Jun 11, 2012 at 11:12 AM, Robert Haas <robertmhaas@gmail.com> wrote:
> On Sat, Jun 9, 2012 at 11:42 AM, Dean Rasheed <dean.a.rasheed@gmail.com> wrote:
>> Hi,
>>
>> Attached is a small patch to improve the HINT message produced by
>> CREATE OR REPLACE FUNCTION when the new function definition conflicts
>> with the old definition. With this patch the hint now includes the
>> function's name and signature as a directly pasteable SQL command. So,
>> for example, instead of
>>
>> psql:functions.sql:70: ERROR:  cannot change return type of existing function
>> HINT:  Use DROP FUNCTION first.
>>
>> it now says
>>
>> psql:functions.sql:70: ERROR:  cannot change return type of existing function
>> HINT:  Use DROP FUNCTION foo(integer,integer) first.
>>
>> which saves having to open the file, find the function and then type
>> in the DROP statement manually.
>
> +1.

Committed.

--
Robert Haas
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company