Re: pg_upgrade: make the locale comparison more tolerating

Lists: pgsql-hackers
From: Pavel Raiskup <praiskup(at)redhat(dot)com>
To: "'pgsql-hackers'" <pgsql-hackers(at)postgresql(dot)org>
Subject: pg_upgrade: make the locale comparison more tolerant
Date: 2013-12-21 15:24:07
Message-ID: 3356208.RhzgiJ6fXA@nb.usersys.redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello pg-hackers!

I tried to look at the problem resulting in changes mentioned here:
http://www.postgresql.org/message-id/20121002155857.GE30089@momjian.us

If the system locale is changed e.g. from en_US.utf8 to en_US.utf-8 before
upgrading the data stack for newer server, pg_upgrade fails. It is quite
awkward to ask users to change locale.conf contents just for upgrade
purposes; is there other known workaround?

I attached patch aimed to remove this hurdle. After its application, the
in-place upgrade finished successfully for me under mentioned conditions,
though I am not 100% sure about its correctness.

Thanks, Pavel

Attachment Content-Type Size
0001-pg_upgrade-tolerate-more-locale-spelling.patch text/x-patch 3.1 KB

From: Pavel Raiskup <praiskup(at)redhat(dot)com>
To: pgsql-hackers(at)postgresql(dot)org
Subject: Re: pg_upgrade: make the locale comparison more tolerating
Date: 2014-01-08 09:27:34
Message-ID: 4628051.BObrLhnj7b@nb.usersys.redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

I made the patch to be in context format and I'll add this issue to
CommitFest. Also, some code comments and style was changed to meet better
readability.

Attachment Content-Type Size
0001-pg_upgrade-make-the-locale-comparison-more-toleratin.patch text/x-patch 3.9 KB

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Pavel Raiskup <praiskup(at)redhat(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: make the locale comparison more tolerating
Date: 2014-01-24 09:24:49
Message-ID: CAGPqQf1MiRr6=FgGY+kmuo3b4FpASXgRi7yKc6MncZ1hU4_j7g@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hello,

I started reviewing the patch. Go through the original mail thread to
understand
the need of fix and the actual problem.

http://www.postgresql.org/message-id/20121002155857.GE30089@momjian.us

Patch is using pg_valid_server_encoding() to compare the encoding which
looks
more correct. Did code walk through and it looks good to me. I tried to test
the patch on CentOS and its working fine. I am not quite knowledgeable
about other OS so on that perspective would good to have others view.

Here are the comment about the patch:

.) Patch gets cleanly apply on master ( using patch -p1 )
.) compilation done successful
.) Code walk through and logic looks good
.) Manual testing worked good for me

To test the issue I set the old database locale to en_US.utf8 and for new
database
locale to en_US.utf-8. WIth this when I tried pg_upgrade it failed with
"lc_collate cluster
values do not match: old "en_US.utf8", new "en_US.UTF-8". With the patch
pg_upgrade
running fine.

Regards,


From: Pavel Raiskup <praiskup(at)redhat(dot)com>
To: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: make the locale comparison more tolerating
Date: 2014-01-24 16:19:18
Message-ID: 10152755.SVtzXS2QiT@nb.usersys.redhat.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Rushabh, really sorry I have to re-create the patch and thanks a
lot for looking at it!

Looking at the patch once again, I see that there were at least two
problems. Firstly, I used the equivalent_locale function also on the
encoding values. Even if that should not cause bugs (as it should result
in strncasecmp anyway), it was not pretty..

The second problem was assuming that the locale specifier "A" is not
longer then locale specifier B. Comparisons like 'en_US.utf8' with
'en_US_.utf8' would result in success. Bug resulting from this mistake is
not real probably but it is not nice anyway..

Rather cleaning the patch once more, attached,
Pavel

Attachment Content-Type Size
0001-pg_upgrade-make-the-locale-comparison-more-toleratin.patch text/x-patch 4.4 KB

From: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>
To: Pavel Raiskup <praiskup(at)redhat(dot)com>
Cc: PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: make the locale comparison more tolerating
Date: 2014-01-30 10:56:51
Message-ID: CAGPqQf2ApFiyXT5EHr1t4a62Sh19Ft0Yz3e9HU5qowJMWJc1Cg@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Hi Pavel,

I looked at your latest cleanup patch. Yes its looks more cleaner in term
equivalent_locale & equivalent_encoding separate functions.

I did run the test again on latest patch and all looks good.

Marking it as ready for committer.

Regards,

On Fri, Jan 24, 2014 at 9:49 PM, Pavel Raiskup <praiskup(at)redhat(dot)com> wrote:

> Rushabh, really sorry I have to re-create the patch and thanks a
> lot for looking at it!
>
> Looking at the patch once again, I see that there were at least two
> problems. Firstly, I used the equivalent_locale function also on the
> encoding values. Even if that should not cause bugs (as it should result
> in strncasecmp anyway), it was not pretty..
>
> The second problem was assuming that the locale specifier "A" is not
> longer then locale specifier B. Comparisons like 'en_US.utf8' with
> 'en_US_.utf8' would result in success. Bug resulting from this mistake is
> not real probably but it is not nice anyway..
>
> Rather cleaning the patch once more, attached,
> Pavel
>

--
Rushabh Lathia


From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Pavel Raiskup <praiskup(at)redhat(dot)com>
Cc: Rushabh Lathia <rushabh(dot)lathia(at)gmail(dot)com>, PostgreSQL Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: pg_upgrade: make the locale comparison more tolerating
Date: 2014-01-31 00:10:31
Message-ID: 26710.1391127031@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-hackers

Pavel Raiskup <praiskup(at)redhat(dot)com> writes:
> [ 0001-pg_upgrade-make-the-locale-comparison-more-toleratin.patch ]

Committed with minor adjustments (mostly, wordsmithing the comments).

Although this was categorized as a bug fix, I'm not sure it's worth
taking the risk of back-patching. We've not seen very many reports
of problems of this type. Of course, you're free to carry it as a
patch in Red Hat's packages if you differ ...

regards, tom lane