From: | Joe Conway <mail(at)joeconway(dot)com> |
---|---|
To: | david(at)andl(dot)org, pgsql-general-owner+M220387=david=andl(dot)org(at)postgresql(dot)org |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: CStringGetTextDatum and other conversions in server-side code |
Date: | 2016-03-03 02:00:36 |
Message-ID: | 56D79AC4.5080107@joeconway.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On 03/02/2016 04:20 PM, david(at)andl(dot)org wrote:
> (please do not post HTML to these lists; see:
> https://wiki.postgresql.org/wiki/Mailing_Lists)
> [dmb>] I checked the list first: it looks like about 25-50% HTML.
> Happy to oblige, but I think you've got your work cut out.
Understood, but you should know that quite a few of the more experienced
people on these lists will totally ignore your HTML emails, so you do
yourself no favors by not following that advice.
> [dmb>] I have the source tree, I use grep and other tools, and I've
> read thousands of lines of code. There is a great deal of
> inconsistency, and much of the code looks like "Summer of Code", or
> has been written a number of years ago or talks about issues I know
> have been resolved, or says it's just 'legacy support'. The upshot
> is: I haven't yet been able to figure out the 'right' way to do
> things, or what might go wrong if I choose the 'wrong' way.
There is no specific "right" way per se. The postgres code base has been
evolving for going on 30 years, so yes, there are inconsistencies. As I
said, best advice is to find code similar to whatever you are trying to
achieve and emulate it.
> [dmb>] That was my plan. But I do prefer to emulate code that is
> 'right'.
If it is in the postgres source tree (i.e. contrib and src/pl) you can
consider it to be about as "right" as you can get because it is all
maintained to be that way. If it is an external project you'll have to
be more careful.
> [dmb>] So how would I go about finding a set of useful conversion
> functions for basic types (real, decimal, time, etc)?
Sorry I don't have a better answer than before: grep and/or read source
for other PLs.
FWIW here are examples from PL/R for incoming (argument) and outgoing
(result) conversions of scalar values:
https://github.com/jconway/plr/blob/master/pg_conversion.c#L632
https://github.com/jconway/plr/blob/master/pg_conversion.c#L1002
That same file also has routines for conversions of more complex data types.
Joe
--
Crunchy Data - http://crunchydata.com
PostgreSQL Support for Secure Enterprises
Consulting, Training, & Open Source Development
From | Date | Subject | |
---|---|---|---|
Next Message | John R Pierce | 2016-03-03 02:05:03 | Re: Re: could not migrate 8.0.13 database with large object data to 9.5.1 |
Previous Message | Premsun Choltanwanich | 2016-03-03 01:54:57 | Re: could not migrate 8.0.13 database with large object data to 9.5.1 |