BUG #3634: Numeric and Array Data Type

From: "zhuge" <zhuge(at)Rinaix(dot)cn>
To: pgsql-bugs(at)postgresql(dot)org
Subject: BUG #3634: Numeric and Array Data Type
Date: 2007-09-25 09:32:30
Message-ID: 200709250932.l8P9WUwE054504@wwwmaster.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs


The following bug has been logged online:

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

To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)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

Browse pgsql-bugs by date

  From Date Subject
Next Message Pedro Gimeno 2007-09-25 11:31:13 Re: BUG #3628: Wrong schema picked
Previous Message andrew 2007-09-25 07:48:21 BUG #3632: couldn't start postgreSQL