From: Teodor Sigaev Date: Thu, 26 Jun 2008 16:06:37 +0000 (+0000) Subject: Fix bug "select lower('asd') = 'asd'" returns false with multibyte encoding X-Git-Tag: recoveryinfrav9~896 X-Git-Url: http://waps.l3s.uni-hannover.de/gitweb/?a=commitdiff_plain;h=71d3285af15e35ca2a50634bb0b1997f898929d7;p=users%2Fsimon%2Fpostgres.git 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. --- diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index a823a5b9ab..dfe9d8efbf 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1454,7 +1454,7 @@ str_tolower(char *buff, size_t nbytes) /* Output workspace cannot have more codes than input bytes */ workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t)); - char2wchar(workspace, nbytes + 1, buff, nbytes + 1); + char2wchar(workspace, nbytes + 1, buff, nbytes); for (curr_char = 0; workspace[curr_char] != 0; curr_char++) workspace[curr_char] = towlower(workspace[curr_char]); @@ -1502,7 +1502,7 @@ str_toupper(char *buff, size_t nbytes) /* Output workspace cannot have more codes than input bytes */ workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t)); - char2wchar(workspace, nbytes + 1, buff, nbytes + 1); + char2wchar(workspace, nbytes + 1, buff, nbytes); for (curr_char = 0; workspace[curr_char] != 0; curr_char++) workspace[curr_char] = towupper(workspace[curr_char]); @@ -1551,7 +1551,7 @@ str_initcap(char *buff, size_t nbytes) /* Output workspace cannot have more codes than input bytes */ workspace = (wchar_t *) palloc((nbytes + 1) * sizeof(wchar_t)); - char2wchar(workspace, nbytes + 1, buff, nbytes + 1); + char2wchar(workspace, nbytes + 1, buff, nbytes); for (curr_char = 0; workspace[curr_char] != 0; curr_char++) {