Skip to content

Commit 5ff9899

Browse files
committed
Fix bug "select lower('asd') = 'asd'" returns false with multibyte encoding
and non-C locale. Fix is just to use correct source's length for char2wchar call.
1 parent 13c843d commit 5ff9899

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/backend/utils/adt/formatting.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* -----------------------------------------------------------------------
22
* formatting.c
33
*
4-
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.143 2008/06/23 19:27:19 momjian Exp $
4+
* $PostgreSQL: pgsql/src/backend/utils/adt/formatting.c,v 1.144 2008/06/26 16:06:37 teodor Exp $
55
*
66
*
77
* Portions Copyright (c) 1999-2008, PostgreSQL Global Development Group
@@ -1454,7 +1454,7 @@ str_tolower(char *buff, size_t nbytes)
14541454
/* Output workspace cannot have more codes than input bytes */
14551455
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
14561456

1457-
char2wchar(workspace, nbytes + 1, buff, nbytes + 1);
1457+
char2wchar(workspace, nbytes + 1, buff, nbytes);
14581458

14591459
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
14601460
workspace[curr_char] = towlower(workspace[curr_char]);
@@ -1502,7 +1502,7 @@ str_toupper(char *buff, size_t nbytes)
15021502
/* Output workspace cannot have more codes than input bytes */
15031503
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
15041504

1505-
char2wchar(workspace, nbytes + 1, buff, nbytes + 1);
1505+
char2wchar(workspace, nbytes + 1, buff, nbytes);
15061506

15071507
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
15081508
workspace[curr_char] = towupper(workspace[curr_char]);
@@ -1551,7 +1551,7 @@ str_initcap(char *buff, size_t nbytes)
15511551
/* Output workspace cannot have more codes than input bytes */
15521552
workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t));
15531553

1554-
char2wchar(workspace, nbytes + 1, buff, nbytes + 1);
1554+
char2wchar(workspace, nbytes + 1, buff, nbytes);
15551555

15561556
for (curr_char = 0; workspace[curr_char] != 0; curr_char++)
15571557
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy