Re: more docs on extending postgres in C

From: Greg Smith <greg(at)2ndquadrant(dot)com>
To: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: more docs on extending postgres in C
Date: 2010-01-20 21:30:51
Message-ID: 4B57760B.4010701@2ndquadrant.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Ivan Sergio Borgonovo wrote:
> It would be nice to at least a list of functions that could be used
> in extension development to avoid reading all the source.
>
psql -E
\df *

This will dump out a list of all the built-in functions in the server.
It will also show you the query that did so, I get one that looks like this:

SELECT n.nspname as "Schema",
p.proname as "Name",
pg_catalog.pg_get_function_result(p.oid) as "Result data type",
pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",
CASE
WHEN p.proisagg THEN 'agg'
WHEN p.proiswindow THEN 'window'
WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN
'trigger'
ELSE 'normal'
END as "Type"
FROM pg_catalog.pg_proc p
LEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE pg_catalog.pg_function_is_visible(p.oid)
AND n.nspname <> 'pg_catalog'
AND n.nspname <> 'information_schema'
ORDER BY 1, 2, 4;

If you run that, and maybe filter it down to only look at stuff similar
to what you're looking for (example: only show things where the Result
data type returns 'text' because that's what you need), that will give
you an idea what functions might be suitable to borrow from. grep for
them in the source code, you'll find them only once in the table that
maps them to actual function names on the code. Grab that name, grep
for it, and then you'll be sitting at example code that might be
interesting to you.

The other thing I'd recommend is surfing the code via
http://doxygen.postgresql.org/ , along with reading through the modules
in contrib/ as already suggested (which won't be found by the query
above because they're optional).

--
Greg Smith 2ndQuadrant Baltimore, MD
PostgreSQL Training, Services and Support
greg(at)2ndQuadrant(dot)com www.2ndQuadrant.com

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Amy Smith 2010-01-21 03:59:18 port question
Previous Message Ricardo Fuentes 2010-01-20 20:52:05 Re: Can I use LIKE to achieve the following result