| From: | Felix(dot)徐 <ygnhzeus(at)gmail(dot)com> |
|---|---|
| To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
| Subject: | How to convert a double value to a numeric datum type in pgsql? |
| Date: | 2014-02-24 06:45:30 |
| Message-ID: | CAPmhLM3gYve69WmbTXQQvSnSyKvfXhCN7y1jsR91GUVuOvzcUA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Hi all,
I'm talking about the source code of pgsql and I want to know how the
typing system works in pgsql.
A few functions can help us do the type conversion, for example:
Int32GetDatum -- convert a integer to a datum
Float8GetDatum -- convert double to a datum
cstring_to_text -- convert a string to a text
...
but there are a lot of types in pgsql,how to choose the corresponding
function? or is there a more automatic way to do the type conversion(raw
chars to a datum, suppose I have the corresponding Form_pg_type instance)?
I ask this question because I don't know how to convert a double value to a
numeric datum(the field's type is numeric(10,2)), pg_type shows that
numeric's typlen is -1 whose length is variable thus Float8GetDatum is not
working..
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Michael Paquier | 2014-02-24 07:11:58 | Re: How to continue streaming replication after this error? |
| Previous Message | Tom Lane | 2014-02-24 04:07:36 | Re: Why does PostgreSQL ftruncate before unlink? |