From: | Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com> |
---|---|
To: | Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com> |
Cc: | "pgsql-general(at)postgresql(dot)org >> PG-General Mailing List" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: Receive a string in Composite-type Arguments |
Date: | 2017-08-11 15:12:27 |
Message-ID: | CAFj8pRCTNW40+JjgnG1y6Sw=-LQ1L9UfEnhdjBUMS5rgp87JyQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2017-08-11 16:39 GMT+02:00 Achilleas Mantzios <achill(at)matrix(dot)gatewaynet(dot)com>
:
> On 11/08/2017 16:09, Fabiana Zioti wrote:
>
> Hi!
>
> I am studying how to program extensions for PostgreSQL in C language.
>
> In the example to return to return Composite-type Arguments, from the
> PostgreSQL 9.6 documentation, I could not make the cash from a cstring to
> the HeapTupleHeader type.
>
> That is, instead of the function receive as a parameter a table:
>
> CREATE FUNCTION c_overpaid (emp, integer) RETURNS boolean
> AS DIRECTORY
>
> SELECT name, c_overpaid (emp, 1500) AS overpaid
> From emp
> WHERE name = 'Bill' OR name = 'Sam';
>
> And in the code in C receive the argument as:
>
> HeapTupleHeader t = PG_GETARG_HEAPTUPLEHEADER (0);
>
>
> The sql function would be defined as:
>
> CREATE FUNCTION c_overpaid (cstring, integer) RETURNS boolean
> AS 'DIRECTORY / funcs', 'c_overpaid'
> LANGUAGE C STRICT;
>
> But how would I receive this argument, for example:
> Char * str = PG_GETARG_CSTRING (0),
>
> And do the conversion to the HeapTupleHeader type?
>
>
Hi
you have to build tuple first. Later you can got a HeapTupleHeader
pl_toolbox has some functions for composite types
https://github.com/okbob/pltoolbox
Regards
Pavel Stehule
>
> Why do you want to convert this to HeapTupleHeader since this is *not* a
> tuple but a string value? What do you want to achieve? IMHO you better
> start with simpler examples, make them run, and proceed as you understand
> more and more.
>
>
> What do you guys suggest?
>
> Thanks in advance
>
>
> --
> Achilleas Mantzios
> IT DEV Lead
> IT DEPT
> Dynacom Tankers Mgmt
>
>
From | Date | Subject | |
---|---|---|---|
Next Message | Peter Eisentraut | 2017-08-11 19:35:30 | Re: Fwd: 2 process postgres -D for one instance |
Previous Message | Achilleas Mantzios | 2017-08-11 14:39:24 | Re: Receive a string in Composite-type Arguments |