Re: CStringGetTextDatum and other conversions in server-side code

Поиск
Список
Период
Сортировка
От Joe Conway
Тема Re: CStringGetTextDatum and other conversions in server-side code
Дата
Msg-id 56D79AC4.5080107@joeconway.com
обсуждение исходный текст
Ответ на Re: CStringGetTextDatum and other conversions in server-side code  (<david@andl.org>)
Ответы Re: CStringGetTextDatum and other conversions in server-side code  (<david@andl.org>)
Список pgsql-general
On 03/02/2016 04:20 PM, david@andl.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


Вложения

В списке pgsql-general по дате отправления:

Предыдущее
От: "Premsun Choltanwanich"
Дата:
Сообщение: Re: could not migrate 8.0.13 database with large object data to 9.5.1
Следующее
От: John R Pierce
Дата:
Сообщение: Re: Re: could not migrate 8.0.13 database with large object data to 9.5.1