Thread: Documentation of C functions

Documentation of C functions

From
"Janek Sendrowski"
Date:
Hi,
Is there a documentation of postgresql's C functions like SET_VARSIZE for exmaple?
 
Janek Sendrowski


Re: Documentation of C functions

From
Albe Laurenz
Date:
Janek Sendrowski wrote:
> Is there a documentation of postgresql's C functions like SET_VARSIZE for exmaple?

For things like this consult the source code.

In src/include/postgres.h you'll find:

/*
 * VARDATA, VARSIZE, and SET_VARSIZE are the recommended API for most code
 * for varlena datatypes.  Note that they only work on untoasted,
 * 4-byte-header Datums!
 *
 * Code that wants to use 1-byte-header values without detoasting should
 * use VARSIZE_ANY/VARSIZE_ANY_EXHDR/VARDATA_ANY.  The other macros here
 * should usually be used only by tuple assembly/disassembly code and
 * code that specifically wants to work with still-toasted Datums.
 *
 * WARNING: It is only safe to use VARDATA_ANY() -- typically with
 * PG_DETOAST_DATUM_PACKED() -- if you really don't care about the alignment.
 * Either because you're working with something like text where the alignment
 * doesn't matter or because you're not going to access its constituent parts
 * and just use things like memcpy on it anyways.
 */

The server side C API is not documented in the documentation, because
it is already (hopefully) well documented in the source.

Yours,
Laurenz Albe