BUG #3634: Numeric and Array Data Type

Started by zhugeover 18 years ago1 messagesbugs
Jump to latest
#1zhuge
zhuge@Rinaix.cn

The following bug has been logged online:

Bug reference: 3634
Logged by: zhuge
Email address: zhuge@Rinaix.cn
PostgreSQL version: 8.1.9
Operating system: Linux
Description: Numeric and Array Data Type
Details:

To: Tom Lane <tgl@sss.pgh.pa.us>

Thank you for your help. You are right.

Today, I write a function, get_order_total_amount(_order_code_ text), which
reads the order table and compute the amount and return the amount. The
amount belongs to "numeric" data type, but the C function has no relative
numeric data type. If I write the script like the following:

CREATE OR REPLACE FUNCTION get_order_total_amount(text)
RETURNS numeric --> Here, if float8, then right
AS 'libdpa-pg_sql_c_func', 'get_order_total_amount'
LANGUAGE C STRICT;

then error occurs . The C function returns double (i.e. float8). How can I
let the C function return the numeric data type?

And I have another question: How can I access the array argument elements
(passed from SQL script like the following) in C function?

CREATE OR REPLACE FUNCTION get_order_total_amount(text[])
RETURNS numeric
AS 'libdpa-pg_sql_c_func', 'get_order_total_amount'
LANGUAGE C STRICT;

Note that the argument, text[], is array type different from the above
argument, text. In C function, how to access the array elements?

Please help me.

Thank you agian.

zhuge