Postgresql - editing function signature

POSTGRESQL 8.4.3 - I created a function with this signature

CREATE OR REPLACE FUNCTION logcountforlasthour () RETURNS SETOF AS record

realized i wanted to change it to

CREATE OR REPLACE FUNCTION logcountforlasthour () RETURNS TABLE (ip bigint, count bigint) AS record

but when I apply this change in the query tool it is not accepted or rather it is accepted, there is no syntax error, but the function text has not been changed. even if I run "DROP FUNCTION logcountforlasthour ()" between changes the old syntax is returned

if i edit the body of the function it is fine it changes but not the signature

there is something that i am missing

thanks

+2


a source to share


1 answer


From Manual for PostgreSQL 8.4 :

To replace the current definition of an existing function, use CREATE OR REPLACE FUNCTION. It is not possible to change the names or types of function arguments in this way (if you tried, you would actually create a new, different function). Also, CREATE OR REPLACE FUNCTION will prevent you from changing the return type of an existing function. To do this, you must drop and recreate the function. (When you use OUT, it means that you cannot change the names or types of any OUT parameters, except for a function.)

If you dropped and then recreated functions, the new function is not the same object as the old one; you will have to discard existing rules, views, triggers, etc. that relate to the old function. Use the CREATE OR REPLACE FUNCTION to change the function definition without breaking the objects that belong to the function. Also, ALTER FUNCTION can be used to change most of the auxiliary properties of an existing function.

The user who creates the function becomes the owner of the function.



and also note:

... PostgreSQL allows function overloading; that is, the same name can be used for several different functions if they have different types of arguments.

+1


a source