(please do not post HTML to these lists; see: https://wiki.postgresql.org/wiki/Mailing_Lists)
On 03/02/2016 03:06 PM, da...@andl.org wrote: > Writing a language handler: pl_language_handler. Need to do a variety of > data conversions. One of them is char* C-string to and from Text/Varchar. > > The include file postgres.h has the macro CStringGetDatum but this is of > no use: it’s just a cast. > > There is a builtin macro CStringGetTextDatum which calls a function and > looks like it might work. Questions: > > 1. Is this the right function? > 2. Is it OK to use, or are there restrictions? > 3. Does it have friends: are there other conversion functions like > this for other data types (decimal, time in particular)? > 4. Is there any particular documentation I can read? Your best bet is to look at examples. The code in the source tree under contrib has many examples, and more specifically src/pl/* should have even more relevant examples. Remember, grep is your friend -- get a copy of the source tree and try: cd <location-of-postgres-source-code> grep -rni CStringGetTextDatum src/pl/* --include=*.c grep -rni CStringGetTextDatum contrib/* --include=*.c grep -rni TextDatumGetCstring contrib/* --include=*.c Additionally there are external projects that implement postgres procedural language handlers, e.g.: https://github.com/jconway/plr Lots of good examples there too. Google for others. Basically any symbol exported from the postgres backend can be used by your PL. There is not a lot of documentation other than in the source code itself. Look at examples, see what they do, emulate it. HTH, Joe -- Crunchy Data - http://crunchydata.com PostgreSQL Support for Secure Enterprises Consulting, Training, & Open Source Development
signature.asc
Description: OpenPGP digital signature