Re: Case Conversion Fix for MB Chars

From: Devrim GUNDUZ <devrim(at)gunduz(dot)org>
To: Bruce Momjian <pgman(at)candle(dot)pha(dot)pa(dot)us>
Cc: Volkan YAZICI <volkan(dot)yazici(at)gmail(dot)com>, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>, pgsql-patches(at)postgresql(dot)org
Subject: Re: Case Conversion Fix for MB Chars
Date: 2005-12-01 21:30:55
Message-ID: Pine.LNX.4.63.0512012327240.31106@mail.kivi.com.tr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-patches pgsql-tr-genel


Hi,

On Thu, 1 Dec 2005, Bruce Momjian wrote:

> Where are we on this patch? Is it to be applied?

The patch worked on FreeBSD 5.4-CURRENT. Maybe what Tom wants is more port
reports, hmm?

Volkan stated out the reasons that why we need this patch, I'll not repeat
it again.

Regards,
--
Devrim GUNDUZ
Kivi Bilişim Teknolojileri - http://www.kivi.com.tr
devrim~gunduz.org, devrim~PostgreSQL.org, devrim.gunduz~linux.org.tr
http://www.gunduz.org
>From pgsql-patches-owner(at)postgresql(dot)org Thu Dec 1 17:34:52 2005
X-Original-To: pgsql-patches-postgresql(dot)org(at)localhost(dot)postgresql(dot)org
Received: from localhost (av.hub.org [200.46.204.144])
by postgresql.org (Postfix) with ESMTP id D48B79DD6B6
for <pgsql-patches-postgresql(dot)org(at)localhost(dot)postgresql(dot)org>; Thu, 1 Dec 2005 17:34:50 -0400 (AST)
Received: from postgresql.org ([200.46.204.71])
by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024)
with ESMTP id 92049-09
for <pgsql-patches-postgresql(dot)org(at)localhost(dot)postgresql(dot)org>;
Thu, 1 Dec 2005 17:34:47 -0400 (AST)
X-Greylist: from auto-whitelisted by SQLgrey-
Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130])
by postgresql.org (Postfix) with ESMTP id 5B39B9DD64F
for <pgsql-patches(at)postgreSQL(dot)org>; Thu, 1 Dec 2005 17:34:47 -0400 (AST)
Received: from sss2.sss.pgh.pa.us (tgl(at)localhost [127.0.0.1])
by sss.pgh.pa.us (8.13.1/8.13.1) with ESMTP id jB1LYkFL017377;
Thu, 1 Dec 2005 16:34:46 -0500 (EST)
To: pgsql-patches(at)postgreSQL(dot)org
cc: Qingqing Zhou <zhouqq(at)cs(dot)toronto(dot)edu>
Subject: Re: Fork-based version of pgbench
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="----- =_aaaaaaaaaa0"
Content-ID: <17371(dot)1133472864(dot)0(at)sss(dot)pgh(dot)pa(dot)us>
Date: Thu, 01 Dec 2005 16:34:46 -0500
Message-ID: <17376(dot)1133472886(at)sss(dot)pgh(dot)pa(dot)us>
From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
X-Virus-Scanned: by amavisd-new at hub.org
X-Spam-Status: No, score=0 required=5 tests=[none]
X-Spam-Score: 0
X-Spam-Level:
X-Archive-Number: 200512/18
X-Sequence-Number: 17977

------- =_aaaaaaaaaa0
Content-Type: text/plain; charset="us-ascii"
Content-ID: <17371(dot)1133472864(dot)1(at)sss(dot)pgh(dot)pa(dot)us>

Argh, I'm an idiot ... a big part of the problem with the original
fork-based pgbench is that I'd rearranged the startup code without
noticing a data dependency. You can't initialize the default scripts
until you've gotten the correct value of "tps" by inspecting the
database. What was happening was that it was making tps = 1 always,
which meant that every transaction tried to update the bid = 1 row
of "branches", which resulted in strict serialization of transactions.
Performance of the attached version is markedly better ;-)

regards, tom lane

------- =_aaaaaaaaaa0
Content-Type: application/octet-stream
Content-ID: <17371(dot)1133472864(dot)2(at)sss(dot)pgh(dot)pa(dot)us>
Content-Description: pgbench.c
Content-Transfer-Encoding: base64

LyoKICogJFBvc3RncmVTUUw6IHBnc3FsL2NvbnRyaWIvcGdiZW5jaC9wZ2JlbmNoLmMsdiAxLjQ4
IDIwMDUvMTEvMjMgMTI6MTk6MTIgaXNoaWkgRXhwICQKICoKICogcGdiZW5jaDogYSBzaW1wbGUg
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7CgoJCXJl
c3VsdCA9IGZvcmsoKTsKCQlpZiAocmVzdWx0ID09IChwaWRfdCkgLTEpCgkJewoJCQkvKiBmb3Jr
IGZhaWxlZCAqLwoJCQlmcHJpbnRmKHN0ZGVyciwgImZvcmsgZmFpbGVkOiAlc1xuIiwgc3RyZXJy
b3IoZXJybm8pKTsKCQkJZXhpdCgxKTsKCQl9CgkJZWxzZSBpZiAocmVzdWx0ID09IDApCgkJewoJ
CQkvKiBmb3JrIHN1Y2NlZWRlZCwgaW4gY2hpbGQgKi8KCQkJZXhpdChkb0NsaWVudChyZW1haW5z
LCBkZWJ1ZykpOwoJCX0KCQllbHNlCgkJewoJCQkvKiBmb3JrIHN1Y2NlZWRlZCwgaW4gcGFyZW50
ICovCgkJCXJlbWFpbnMrKzsKCQl9Cgl9CgoJLyogV2FpdCBmb3IgYWxsIHRoZSBjbGllbnRzIHRv
IGZpbmlzaCAqLwoJbmZhaWxlZCA9IDA7Cgl3aGlsZSAocmVtYWlucyA+IDApCgl7CgkJaW50CQlz
dGF0dXM7CgoJCWlmICh3YWl0KCZzdGF0dXMpICE9IChwaWRfdCkgLTEpCgkJewoJCQlpZiAoc3Rh
dHVzICE9IDApCgkJCQluZmFpbGVkKys7CgkJCXJlbWFpbnMtLTsKCQl9Cgl9CgoJLyogQ2xpZW50
cyBhbGwgZ29uZSwgc28gY2xlYW4gdXAgKi8KCgkvKiBnZXQgZW5kIHRpbWUgKi8KCWdldHRpbWVv
ZmRheSgmdHYyLCBOVUxMKTsKCXByaW50UmVzdWx0cyh0dHlwZSwgbmZhaWxlZCwgJnR2MSwgJnR2
Mik7CglpZiAoTE9HRklMRSkKCQlmY2xvc2UoTE9HRklMRSk7CgoJcmV0dXJuIDA7Cn0K

------- =_aaaaaaaaaa0--

In response to

Browse pgsql-patches by date

  From Date Subject
Next Message Joachim Wieland 2005-12-01 23:25:07 TODO-Item: include for guc
Previous Message Bruce Momjian 2005-12-01 21:21:23 Re: Case Conversion Fix for MB Chars

Browse pgsql-tr-genel by date

  From Date Subject
Next Message Volkan YAZICI 2005-12-01 22:29:32 Re: Veri özeti, Like ile arama performans'ı
Previous Message Bruce Momjian 2005-12-01 21:21:23 Re: Case Conversion Fix for MB Chars