Re: SPI_execute_plan and vardata

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Арсен Арутюнян <arutar(at)bk(dot)ru>
Cc: pgsql-general <pgsql-general(at)postgresql(dot)org>
Subject: Re: SPI_execute_plan and vardata
Date: 2017-06-22 21:32:53
Message-ID: 15983.1498167173@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

=?UTF-8?B?0JDRgNGB0LXQvSDQkNGA0YPRgtGO0L3Rj9C9?= <arutar(at)bk(dot)ru> writes:
> Datum Values[2];

> Values[0]-is integer type 
> but Values[1] is string type so 

> Values[0] = SET_4_BYTES(227);

This is really bad practice. It might accidentally work, but the
right way to do it is more like

Values[0] = Int32GetDatum(227);

or possibly Int64GetDatum if you're thinking of bigint rather than int4.

> please assist how can i convert som char* string to Datum

You're not being too clear about which "string type" you have in mind,
but if it's text, good practice would be

Values[1] = CStringGetTextDatum(char-*-ptr);

regards, tom lane

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Muhammad Hanif Abdul Hamid 2017-06-23 04:24:38 Suddenly - LOG: could not open file "postmaster.pid": No such file or directory
Previous Message Tom Lane 2017-06-22 21:27:17 Re: 10beta1 role