From: | Martijn van Oosterhout <kleptog(at)svana(dot)org> |
---|---|
To: | Jason Armstrong <ja(at)riverdrums(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Returning bigint from C extension |
Date: | 2009-11-23 08:37:24 |
Message-ID: | 20091123083723.GA29028@svana.org |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mon, Nov 23, 2009 at 09:58:21AM +0200, Jason Armstrong wrote:
> How can I return a bigint value from a C extension function?
>
> I have a table with a bytea column:
>
> CREATE TABLE mydata(data bytea);
>
> I would like to select and index based on a subset of the data:
>
> CREATE FUNCTION get_key(bytea) returns BIGINT AS '/lib/data.so'
> LANGUAGE C IMMUTABLE;
> CREATE INDEX mydata_key_idx on mydata(get_key(data));
For a bigint you need to use the right return type: PG_RETURN_INT64()
> (And, as a side note, is the above code the correct way to use bytea
> data from C?)
Looks ok.
Have a nice day,
--
Martijn van Oosterhout <kleptog(at)svana(dot)org> http://svana.org/kleptog/
> Please line up in a tree and maintain the heap invariant while
> boarding. Thank you for flying nlogn airlines.
From | Date | Subject | |
---|---|---|---|
Next Message | Alexandra Roy | 2009-11-23 08:51:17 | Re: ora2pg and DBD::Pg |
Previous Message | Alexandra Roy | 2009-11-23 08:37:13 | Re: DBD::Pg 2.15.1 compilation failed |