Hi, The documentation on extending using C functions, leaves a blank on how to call other internal Postgres functions. This can leave first-timers hanging. I think it’d be helpful to spend some paragraphs on discussing the DirectFunctionCall API. Here’s an attempt (also a PR[0]). Here’s the relevant HTML snippet for convenience: To call another version-1 function, you can use Different flavors of similar macros can be found in For example, to call the In I’ve also added the below example function: PG_FUNCTION_INFO_V1(t_starts_with); Datum t_starts_with(PG_FUNCTION_ARGS) { Datum t1 = PG_GETARG_DATUM(0); Datum t2 = PG_GETARG_DATUM(1); bool bool_res; Datum datum_res = DirectFunctionCall2(text_starts_with, t1, t2); bool_res = DatumGetBool(datum_res); PG_RETURN_BOOL(bool_res); } PS1: I was not sure if src/tutorial is still relevant with this part of the documentation. If so, it needs updating too. |
0001-Add-some-documentation-on-how-to-call-internal-funct.patch
Description: Binary data