BUG #3634: Numeric and Array Data Type - Mailing list pgsql-bugs

From zhuge
Subject BUG #3634: Numeric and Array Data Type
Date
Msg-id 200709250932.l8P9WUwE054504@wwwmaster.postgresql.org
Whole thread Raw
List pgsql-bugs
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

pgsql-bugs by date:

Previous
From: "andrew"
Date:
Subject: BUG #3632: couldn't start postgreSQL
Next
From: Michael Meskes
Date:
Subject: Re: BUG #3623: initialisation probl.