Re: [PATCH] Add some documentation on how to call internal functions

Tom Lane <tgl@sss.pgh.pa.us>

From: Tom Lane <tgl@sss.pgh.pa.us>
To: Pavel Stehule <pavel.stehule@gmail.com>
Cc: Florents Tselai <florents.tselai@gmail.com>, pgsql-hackers <pgsql-hackers@lists.postgresql.org>
Date: 2024-10-18T20:23:43Z
Lists: pgsql-hackers

Attachments

Pavel Stehule <pavel.stehule@gmail.com> writes:
> I'll mark this patch as ready for committer

I spent a little time looking at this.  I agree that it's better to
show conversion of the example function's arguments to and from text*
rather than leaving them as Datum.  I also do think that we need to
incorporate the example into src/tutorial, if only because that
provides a chance to test it.  And indeed, testing exposed that the
example doesn't work:

$ cd src/tutorial
$ make
$ psql postgres 
psql (18devel)
Type "help" for help.

postgres=# \i funcs.sql 

psql:funcs.sql:152: ERROR:  could not determine which collation to use for string comparison
HINT:  Use the COLLATE clause to set the collation explicitly.

The problem here is that we failed to pass through the result of
PG_GET_COLLATION() to text_starts_with.  We could do that, certainly,
for a couple more lines of code.  But it feels like this is getting
into details that obscure the main point.  I wonder if it'd be better
to choose a different example that calls a non-collation-dependent
target function.

Anyway, proposed v3 attached.  I folded the two patches into one,
and editorialized on the text a little.

			regards, tom lane

Commits

  1. Add documentation about calling version-1 C functions from C.