Re: COLLATE
Filip Rembiałkowski wrote:
Greg Stark wrote:
But the closest partial solution suggested so far is the pg_xfrm (sic) function that
has been implemented and posted at least three times by three different
posters to the postgres mailing lists. In the interest of avoiding a fourth
independent implementation I'll attach the one I use below, it's not big.But I have no idea how to compile/install it.
I tried compiling but it failed:
pgdba ( at ) sulaco:~/src/postgresql-8.1.3/src$ gcc -I ./include -fPIC -c pg_strxfrm.c
pg_strxfrm.c: In function 'pg_strxfrm':
pg_strxfrm.c:98: error: 'Warn_restart' undeclared (first use in this function)
pg_strxfrm.c:98: error: (Each undeclared identifier is reported only once
pg_strxfrm.c:98: error: for each function it appears in.)
What is the answer to Filip's question? I didn't see an answer in the list archives. I've seen several copies of Joe Conway's pg_strxfrm.c code on the web, and it always refers to the Warn_restart variable, which doesn't seem to exist in the 8.1.4 code that I'm using.
I am working with a database in UTF-8 encoding using "C" collation - but I'd occasionally like to ORDER BY columns containing real UTF-8 data.
Would the pg_strxfrm() function get used in a new operator class function? I'll read up on operator classes in chapter 32.14 of the docs, but if someone has a simple example, it might help other searchers of the archives.
Thanks,
Kevin Murphy
Kevin Murphy <murphy@genome.chop.edu> writes:
What is the answer to Filip's question? I didn't see an answer in the list archives. I've seen several copies of Joe Conway's pg_strxfrm.c code on the web, and it always refers to the Warn_restart variable, which doesn't seem to exist in the 8.1.4 code that I'm using.
Warn_restart hasn't existed since PG 7.4. I would imagine that the code
needs to be tweaked to use a PG_TRY construct instead of direct setjmp
hacking.
regards, tom lane
Tom Lane wrote:
Kevin Murphy <murphy@genome.chop.edu> writes:
What is the answer to Filip's question? I didn't see an answer in the list archives. I've seen several copies of Joe Conway's pg_strxfrm.c code on the web, and it always refers to the Warn_restart variable, which doesn't seem to exist in the 8.1.4 code that I'm using.
Warn_restart hasn't existed since PG 7.4. I would imagine that the code
needs to be tweaked to use a PG_TRY construct instead of direct setjmp
hacking.
Yes, I'm a user, not a hacker. I was hoping that someone had done this
already. Anyway, I gave PG_TRY a try, and the code superficially works.
I have no idea what I'm doing; you can see what I did below.
Confirm that instead of:
memcpy(&save_restart, &Warn_restart, sizeof(save_restart));
if (sigsetjmp(Warn_restart, 1) != 0)
{
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
newlocale = setlocale(LC_COLLATE, oldlocale);
if (!newlocale)
elog(PANIC, "setlocale failed to reset locale:
%s", localestr);
siglongjmp(Warn_restart, 1);
}
...
code here
...
memcpy(&Warn_restart, &save_restart, sizeof(Warn_restart));
it should be:
PG_TRY();
{
...
code here
...
}
PG_CATCH();
{
newlocale = setlocale(LC_COLLATE, oldlocale);
if (!newlocale)
elog(PANIC, "setlocale failed to reset locale: %s",
localestr);
}
PG_END_TRY();
Thanks,
Kevin Murphy