On 03/02/2016 04:20 PM, david@xxxxxxxx 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
Attachment:
signature.asc
Description: OpenPGP digital signature