Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit466dac8

Browse files
committed
Fix make_greater_string to not have an undocumented collation assumption.
The previous coding worked only if ltproc->fn_collation was always eitherDEFAULT_COLLATION_OID or a C-compatible locale. While that's true at themoment, it wasn't documented (and in fact wasn't true when this code wascommitted...). But it only takes a couple more lines to make its internalcaching behavior locale-aware, so let's do that.
1 parentcdcdfca commit466dac8

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

‎src/backend/utils/adt/selfuncs.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5436,7 +5436,8 @@ pattern_selectivity(Const *patt, Pattern_Type ptype)
54365436
* in the form of a Const node; else return NULL.
54375437
*
54385438
* The caller must provide the appropriate "less than" comparison function
5439-
* for testing the strings.
5439+
* for testing the strings. In particular, ltproc->fn_collation specifies
5440+
* the locale for comparisons.
54405441
*
54415442
* The key requirement here is that given a prefix string, say "foo",
54425443
* we must be able to generate another string "fop" that is greater than
@@ -5504,19 +5505,21 @@ make_greater_string(const Const *str_const, FmgrInfo *ltproc)
55045505
{
55055506
/* If first time through, determine the suffix to use */
55065507
staticcharsuffixchar=0;
5508+
staticOidsuffixcollation=0;
55075509

5508-
if (!suffixchar)
5510+
if (!suffixchar||suffixcollation!=ltproc->fn_collation)
55095511
{
55105512
char*best;
55115513

55125514
best="Z";
5513-
if (varstr_cmp(best,1,"z",1,DEFAULT_COLLATION_OID)<0)
5515+
if (varstr_cmp(best,1,"z",1,ltproc->fn_collation)<0)
55145516
best="z";
5515-
if (varstr_cmp(best,1,"y",1,DEFAULT_COLLATION_OID)<0)
5517+
if (varstr_cmp(best,1,"y",1,ltproc->fn_collation)<0)
55165518
best="y";
5517-
if (varstr_cmp(best,1,"9",1,DEFAULT_COLLATION_OID)<0)
5519+
if (varstr_cmp(best,1,"9",1,ltproc->fn_collation)<0)
55185520
best="9";
55195521
suffixchar=*best;
5522+
suffixcollation=ltproc->fn_collation;
55205523
}
55215524

55225525
/* And build the string to compare to */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp