Re: COLLATE - Mailing list pgsql-general

From Kevin Murphy
Subject Re: COLLATE
Date
Msg-id 44E484CB.5090209@genome.chop.edu
Whole thread Raw
In response to Re: COLLATE  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-general
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
JoeConway's pg_strxfrm.c code on the web, and it always refers to the Warn_restart variable, which doesn't seem to
existin 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


pgsql-general by date:

Previous
From: Berend Tober
Date:
Subject: Re: Best approach for a "gap-less" sequence
Next
From: AgentM
Date:
Subject: Re: Best approach for a "gap-less" sequence