16

Am I crazy or just plain dumb?

dev=# \df abuse_resolve 
List of functions
-[ RECORD 1 ]-------+------------------------------------------------------------------------------------------------------------------------------------
Schema | public
Name | abuse_resolve
Result data type | record
Argument data types | INOUT __abuse_id bigint, OUT __msg character varying
Type | normal
dev=# select abuse_resolve('30'::bigint); 
ERROR: function abuse_resolve(bigint) does not exist
LINE 1: select abuse_resolve('30'::bigint);
 ^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.

Here's the CREATE FUNCTION, I've omitted the meat of the code, but that should be irrelevant:

CREATE OR REPLACE FUNCTION abuse_resolve(INOUT __abuse_id bigint, OUT __msg character varying) RETURNS record AS $_$
DECLARE
 __abuse_status VARCHAR;
BEGIN
 ...snip...
 UPDATE abuse SET abuse_status = __abuse_status,
 edate = now(),
 closed_on = now()
 WHERE abuse_id = __abuse_id;
 __msg = 'SUCCESS';
END;
$_$ LANGUAGE plpgsql SECURITY DEFINER;

And just for giggles:

GRANT ALL ON FUNCTION abuse_resolve(INOUT __abuse_id, OUT __msg character varying) TO PUBLIC;
GRANT ALL ON FUNCTION abuse_resolve(INOUT __abuse_id, OUT __msg character varying) TO myuser;

That function seems like it exists. What could I be missing?

This is resolved, the answer is: I'm dumb. I had improperly defined the arguments originally, but my code was using the correct ones. There was an extra bigint that had no business being there.

asked Mar 13, 2012 at 6:41
3
  • 1
    Can you post the create function statement? Commented Mar 13, 2012 at 12:39
  • Did you execute both in the same session? Same user? Same search_path? Commented Mar 13, 2012 at 15:32
  • Yes, there's only one user. search_path is set to public, SHOW confirms this. I'll edit with CREATE FUNCTION Commented Mar 14, 2012 at 4:06

4 Answers 4

5

If you can and if is that problem. I recommend to use

"set search_path = mainSchemaName, secondOnes" 

to set correct schema where function is created or in a place where you call it directly specify the schema name

select schemaName.abuse_resolve('30'::bigint);
answered Apr 2, 2012 at 7:59
Sign up to request clarification or add additional context in comments.

1 Comment

This is it. right here. I forgot to define my schema name before my function and that was causing it to not work. Thanks!
4

Well, something is odd. I did:

steve@steve@[local] =# create function abuse_resolve(inout __abuse_id bigint,
 out __msg text) returns record language plpgsql as
 $$ begin __msg = 'ok'; end; $$;
CREATE FUNCTION
steve@steve@[local] =# \df abuse_resolve
List of functions
-[ RECORD 1 ]-------+----------------------------------------
Schema | so9679418
Name | abuse_resolve
Result data type | record
Argument data types | INOUT __abuse_id bigint, OUT __msg text
Type | normal
steve@steve@[local] =# select abuse_resolve('30'::bigint);
-[ RECORD 1 ]-+--------
abuse_resolve | (30,ok)

Have you had any other issues with this database? Can you copy it with dump/restore and try this on the new copy? Does explicitly qualifying the function name with the "public" schema help? Which version of PostgreSQL are you using?

update: sql function It also worked fine for me using:

create function abuse_resolve(inout __abuse_id bigint, out __msg text)
 language sql as $$ select 1,ドル 'ok'::text $$;
answered Mar 13, 2012 at 11:48

6 Comments

I was able to reproduce @echtish creating the function as sql without returns record. Then I saw your sample as plpgsql and dropped my own and created yours and it worked. Then dropped yours and I now can't reproduce the problem anymore with the same function with which I was reproducing the problem at first. I'm using 9.1 on Fedora 16
The only sensible explanation is that the search_path does not include the public schema. I bet that select public.abuse_resolve('30'::bigint); works.
@Clodoaldo: I can't reproduce it using a SQL function either (9.1, Debian)
@ErwinBrandstetter: but in that case, I would not expect the function to be findable with \df, which applies pg_function_is_visible.
You are right, it makes no sense. \df would not show the function then.
|
1

Try this syntax:

SELECT * FROM abuse_resolve('30'::bigint);
answered Mar 13, 2012 at 6:47

1 Comment

Thanks, but no joy. Still, ERROR: function abuse_resolve(bigint) does not exist
0

I had everything but no usage on the schema. Granting usage on schema fixed it.

answered Mar 3, 2021 at 8:09

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.