@@ -1538,21 +1538,20 @@ int
15381538varstr_cmp (const char * arg1 ,int len1 ,const char * arg2 ,int len2 ,Oid collid )
15391539{
15401540int result ;
1541+ pg_locale_t mylocale ;
15411542
15421543check_collation_set (collid );
15431544
1544- if (lc_collate_is_c (collid ))
1545+ mylocale = pg_newlocale_from_collation (collid );
1546+
1547+ if (mylocale -> collate_is_c )
15451548{
15461549result = memcmp (arg1 ,arg2 ,Min (len1 ,len2 ));
15471550if ((result == 0 )&& (len1 != len2 ))
15481551result = (len1 < len2 ) ?-1 :1 ;
15491552}
15501553else
15511554{
1552- pg_locale_t mylocale ;
1553-
1554- mylocale = pg_newlocale_from_collation (collid );
1555-
15561555/*
15571556 * memcmp() can't tell us which of two unequal strings sorts first,
15581557 * but it's a cheap way to tell if they're equal. Testing shows that
@@ -1859,10 +1858,12 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
18591858bool abbreviate = ssup -> abbreviate ;
18601859bool collate_c = false;
18611860VarStringSortSupport * sss ;
1862- pg_locale_t locale = 0 ;
1861+ pg_locale_t locale ;
18631862
18641863check_collation_set (collid );
18651864
1865+ locale = pg_newlocale_from_collation (collid );
1866+
18661867/*
18671868 * If possible, set ssup->comparator to a function which can be used to
18681869 * directly compare two datums. If we can do this, we'll avoid the
@@ -1876,7 +1877,7 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
18761877 * varstrfastcmp_c, bpcharfastcmp_c, or namefastcmp_c, all of which use
18771878 * memcmp() rather than strcoll().
18781879 */
1879- if (lc_collate_is_c ( collid ) )
1880+ if (locale -> collate_is_c )
18801881{
18811882if (typid == BPCHAROID )
18821883ssup -> comparator = bpcharfastcmp_c ;
@@ -1893,13 +1894,6 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
18931894}
18941895else
18951896{
1896- /*
1897- * We need a collation-sensitive comparison. To make things faster,
1898- * we'll figure out the collation based on the locale id and cache the
1899- * result.
1900- */
1901- locale = pg_newlocale_from_collation (collid );
1902-
19031897/*
19041898 * We use varlenafastcmp_locale except for type NAME.
19051899 */
@@ -1950,7 +1944,10 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
19501944sss -> last_len2 = -1 ;
19511945/* Initialize */
19521946sss -> last_returned = 0 ;
1953- sss -> locale = locale ;
1947+ if (collate_c )
1948+ sss -> locale = NULL ;
1949+ else
1950+ sss -> locale = locale ;
19541951
19551952/*
19561953 * To avoid somehow confusing a strxfrm() blob and an original string,
@@ -2536,12 +2533,15 @@ btvarstrequalimage(PG_FUNCTION_ARGS)
25362533{
25372534/* Oidopcintype = PG_GETARG_OID(0); */
25382535Oid collid = PG_GET_COLLATION ();
2536+ pg_locale_t locale ;
25392537
25402538check_collation_set (collid );
25412539
2542- if (lc_collate_is_c (collid )||
2540+ locale = pg_newlocale_from_collation (collid );
2541+
2542+ if (locale -> collate_is_c ||
25432543collid == DEFAULT_COLLATION_OID ||
2544- get_collation_isdeterministic ( collid ))
2544+ pg_locale_deterministic ( locale ))
25452545PG_RETURN_BOOL (true);
25462546else
25472547PG_RETURN_BOOL (false);