Re: How to determine if a function exists - Mailing list pgsql-novice

From Tom Lane
Subject Re: How to determine if a function exists
Date
Msg-id 13147.1346883049@sss.pgh.pa.us
Whole thread Raw
In response to How to determine if a function exists  ("lmanorders" <lmanorders@gmail.com>)
Responses Re: How to determine if a function exists  ("lmanorders" <lmanorders@gmail.com>)
List pgsql-novice
"lmanorders" <lmanorders@gmail.com> writes:
> I'm attempting to determine if a stored procedure exists. If it doesn't, then I want to create it. I'm developing in
C++using the libpq interface. I found the following suggestion in the docs to determine if a function exists or not. I
triedcreating what I think is an identical query in pgAdmin and it seems to work ok. Can anyone tell me why the
followingalways returns PGRES_TUPLE_OK, whether the function exists or not? 

PGRES_TUPLES_OK means you successfully executed a SELECT (or other
command capable of returning tuples).  It doesn't imply anything about
how many tuples were returned.  In this case, you'd want to check for
PQntuples() > 0, as well.  And perhaps think about what you'd do if
you got more than one match, which is quite possible in view of function
overloading, schema search path, etc.

            regards, tom lane


pgsql-novice by date:

Previous
From: "lmanorders"
Date:
Subject: How to determine if a function exists
Next
From: "lmanorders"
Date:
Subject: Re: How to determine if a function exists