Re: Collation rules and multi-lingual databases - Mailing list pgsql-hackers

From Peter Eisentraut
Subject Re: Collation rules and multi-lingual databases
Date
Msg-id Pine.LNX.4.44.0308230055530.3377-100000@peter.localdomain
Whole thread Raw
In response to Re: Collation rules and multi-lingual databases  (Greg Stark <gsstark@mit.edu>)
List pgsql-hackers
Greg Stark writes:

> This is my first C function so I'm really unsure that I've done the right
> thing. For the most part I pattern-matched off the string_io code in the
> contrib directory.

That was just about the worst example you could have picked.  Please
forget everything you have seen and start by reading the documentation.
In particular, learn about the version 1 call convention and about the
PostgreSQL license.  And read some code under src/backend/utils/adt.

> In particular I'm unsure about the code postgres-interfacing code in
> c_varcharxfrm which makes an extra copy of both parameters that are passed in
> and an extra copy of the result value. Are varchars guaranteed to be
> nul-terminated?

They are guaranteed not to be null-terminated.

> But more generally. Would it make more sense to use text or bytea or something
> else to store these opaque binary strings? At least with glibc they tend to be
> unreadable anyways.

bytea

> If it's deemed a reasonable approach and nobody has any fatal flaws then I
> expect it would be useful to put in the contrib directory?

I'd expect it to be too slow to be useful.  Have you run performance tests?

-- 
Peter Eisentraut   peter_e@gmx.net



pgsql-hackers by date:

Previous
From: Josh Berkus
Date:
Subject: Re: Single-file DBs WAS: Need concrete "Why Postgres
Next
From: Stephan Szabo
Date:
Subject: Re: Collation rules and multi-lingual databases