[GENERAL] Re[2]: [GENERAL] SPI_execute_plan and vardata - Mailing list pgsql-general

From Арсен Арутюнян
Subject [GENERAL] Re[2]: [GENERAL] SPI_execute_plan and vardata
Date
Msg-id 1498203993.201742211@f326.i.mail.ru
Whole thread Raw
In response to Re: [GENERAL] SPI_execute_plan and vardata  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
Thank you

next question - how i can call pg_notify or NOTIFY query from c function

Arsen


Пятница, 23 июня 2017, 0:33 +03:00 от Tom Lane <tgl@sss.pgh.pa.us>:

Арсен Арутюнян <arutar@bk.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

pgsql-general by date:

Previous
From: Muhammad Hanif Abdul Hamid
Date:
Subject: Re: [GENERAL] Suddenly - LOG: could not open file "postmaster.pid":No such file or directory
Next
From: Achilleas Mantzios
Date:
Subject: Re: [GENERAL] pglogical vs. built-in logical replication in pg-10