Re: more docs on extending postgres in C - Mailing list pgsql-general

From Greg Smith
Subject Re: more docs on extending postgres in C
Date
Msg-id 4B57760B.4010701@2ndquadrant.com
Whole thread Raw
In response to Re: more docs on extending postgres in C  (Ivan Sergio Borgonovo <mail@webthatworks.it>)
List 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@2ndQuadrant.com  www.2ndQuadrant.com


pgsql-general by date:

Previous
From: Ricardo Fuentes
Date:
Subject: Re: Can I use LIKE to achieve the following result
Next
From: beulah prasanthi
Date:
Subject: helo