Re: 38.10.6. Composite-Type Arguments C-language function code demo works for int, but not for numeric. - Mailing list pgsql-general

From Tom Lane
Subject Re: 38.10.6. Composite-Type Arguments C-language function code demo works for int, but not for numeric.
Date
Msg-id 1369043.1675263944@sss.pgh.pa.us
Whole thread Raw
In response to 38.10.6. Composite-Type Arguments C-language function code demo works for int, but not for numeric.  (jian he <jian.universality@gmail.com>)
List pgsql-general
jian he <jian.universality@gmail.com> writes:
> column "salary" int data type works fine. But it does not work if the
> "salary" column data type is numeric.

Your problem is that numeric is not a primitive C type:

>     PG_RETURN_BOOL(DatumGetNumericCopy(salary) > limit);

That is comparing two pointers-to-numerics, not the values of
the numerics.  You'd need to invoke numeric_cmp() if you
want a sensible result.

            regards, tom lane



pgsql-general by date:

Previous
From: Mateusz Henicz
Date:
Subject: Re: pg_rewind and replication user
Next
From: Wim Bertels
Date:
Subject: Re: Best Open Source OS for Postgresql