postgresql jsonb processing with c api

From: Igor Stassiy <istassiy(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: postgresql jsonb processing with c api
Date: 2015-02-12 09:05:35
Message-ID: CAKVOjex6wtQmVFZSMX5vWHgFc3YymPp2dQNkCpPCbaUk+1pOUg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hi,

I am developing a postgres extension. The extension gets json data as a
string from external source and is supposed to be able to store this string
in a Jsonb type.

I am working with C API for postgres-9.4 installed from ubuntu trusty main
repo.

I would like to use a function that converts a cstring to Jsonb* structure
defined in

http://doxygen.postgresql.org/jsonb_8h.html

There are functions doing exactly this already defined in

http://doxygen.postgresql.org/jsonb_8c.html

Namely, the function Datum jsonb_in ( PG_FUNCTION_ARGS ), however I am not
sure if I can call this function from C API in a portable and safe manner.
As it seems it is intended for being called by postgres from first glance.

I could also use the function jsonb_from_cstring

http://doxygen.postgresql.org/jsonb_8c.html#ab23eca28d5880f86a0943d71c90d6654

but it is declared and defined in jsonb.c and not declared in json.h, and
hence linking with this function is not a very clean solution. I tried
finding the symbols for jsonb_from_cstring in libpq.so, however there are
none. I am guessing I need a non-standard build of postgres?

So the question is, what is the best way to convert a cstring to a Jsonb*
structure from within C API?

Thanks,
Igor

Browse pgsql-general by date

  From Date Subject
Next Message Gustavo Lopes 2015-02-12 09:33:44 EINTR causes panic (data dir on btrfs)
Previous Message Saimon Lim 2015-02-12 08:53:59 Re: How to hide stored procedure's bodies from specific user