Обсуждение: [HACKERS] Rust bindings to pgtypes lib

Поиск
Список
Период
Сортировка

[HACKERS] Rust bindings to pgtypes lib

От
Kaare Rasmussen
Дата:
Hi

For learning purposes (and because I probably need it) , I've started to make 
Rust bindings to the pgtypes Library.

One problem I'm thinking about right now is how to know if, and where, the 
library and the include files are installed. One way to avoid that problem is 
to include the source of pgtypeslib in my project, and let the rust build 
system take care of it *.

But is this possible, or feasible? I see that the makefile refers to 
Makefile.global, and also includes stuff from ecpg, aat least. I don't want to 
include the whole pg source tree, just the nice, safe, little corner that 
would be used for this purpose.

How much of the source tree would I have to carve out?
Or from another perspective; how do other language (if any) solve this?

* Not sure it can, but other rust crates seem to do it that way, e.g. https://
github.com/alexcrichton/bzip2-rs

-- 
Med venlig hilsen
Kaare Rasmussen, Jasonic

Jasonic:  Nordre Fasanvej 12, 2000 Frederiksberg




Re: [HACKERS] Rust bindings to pgtypes lib

От
Michael Meskes
Дата:
> But is this possible, or feasible? I see that the makefile refers to 

Possible yes, but in general I'm not a big fan of duplicating code. I
spend too much time to keep those copies in sync.

> Makefile.global, and also includes stuff from ecpg, aat least. I don't want to 

Yes, but these should be minor. Makefile.global is mostly included for
some rules and other than some includes I don't know what else is taken
from ecpg.

However, there are a couple small files that are taken from teh backend
source tree, like pgstrcasecmp.c

> How much of the source tree would I have to carve out?
> Or from another perspective; how do other language (if any) solve this?

I'm not aware of any other language binding for pgtypeslib.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL



Re: [HACKERS] Rust bindings to pgtypes lib

От
Andres Freund
Дата:
Hi,

On 2017-07-06 20:26:29 +0200, Michael Meskes wrote:
> > But is this possible, or feasible? I see that the makefile refers to 
> 
> Possible yes, but in general I'm not a big fan of duplicating code. I
> spend too much time to keep those copies in sync.

Indeed. I'm quite strongly against exposing / using pgtypeslib in more
places. If anything it should be phased out. Because that code is
definitely not always kept up2date, and it's a lot of work to do so.  If
anything the code should be rewritten to *not* require so much
duplication, then we could talk.


> > How much of the source tree would I have to carve out?
> > Or from another perspective; how do other language (if any) solve this?
> 
> I'm not aware of any other language binding for pgtypeslib.

Some people use http://libpqtypes.esilo.com/

Greetings,

Andres Freund



Re: [HACKERS] Rust bindings to pgtypes lib

От
Michael Meskes
Дата:
> Indeed. I'm quite strongly against exposing / using pgtypeslib in more
> places. If anything it should be phased out. Because that code is

Feel free to come up with a replacement. :)

> definitely not always kept up2date, and it's a lot of work to do so.  If
> anything the code should be rewritten to *not* require so much
> duplication, then we could talk.

Agreed. However, it could be argued that the code is not duplication
(anymore) but a separate implementation of these datatypes.

>> I'm not aware of any other language binding for pgtypeslib.
> 
> Some people use http://libpqtypes.esilo.com/

Never before saw this. It does not seem to have more in common than the
name, though.

Michael
-- 
Michael Meskes
Michael at Fam-Meskes dot De, Michael at Meskes dot (De|Com|Net|Org)
Meskes at (Debian|Postgresql) dot Org
Jabber: michael at xmpp dot meskes dot org
VfL Borussia! Força Barça! Go SF 49ers! Use Debian GNU/Linux, PostgreSQL



Re: [HACKERS] Rust bindings to pgtypes lib

От
Kaare Rasmussen
Дата:
I agree with Michael Meskes that duplicating the code is probably not a good 
idea. Now I see other rust crates just depend on the right libraries to be 
installed by the developer, so I'll punt the problem until it bites me for 
real.

This confuses me, though

> Indeed. I'm quite strongly against exposing / using pgtypeslib in more
> places. If anything it should be phased out. Because that code is
> definitely not always kept up2date, and it's a lot of work to do so.  If
> anything the code should be rewritten to *not* require so much
> duplication, then we could talk

Is this a widespread opinion?  If so, perhaps it would be an idea to mention 
that somewhere in the docs. Just reading them, it would seem to be a nice 
interface to a library that can do datetime and arbitrary numeric calculation 
for you. Both areas are very hard to get right.

No problem on my part. The target of my small project was to learn some rust 
by throing myself at it. And I learned more than expected, so the outcome is 
already fine. If the resulting project also could be of use to me and anybody 
else, it would just be an extra win.

-- 
Med venlig hilsen
Kaare Rasmussen, Jasonic

Jasonic:  Nordre Fasanvej 12, 2000 Frederiksberg




Re: [HACKERS] Rust bindings to pgtypes lib

От
Andres Freund
Дата:
On 2017-07-07 12:54:33 +0200, Michael Meskes wrote:
> > Some people use http://libpqtypes.esilo.com/
>
> Never before saw this. It does not seem to have more in common than the
> name, though.

It has binary to text conversion functionality for various types.  I
don't exactly know what Kaare needs, but that seems like a relevant
need.

- Andres