@@ -1538,21 +1538,20 @@ int
1538
1538
varstr_cmp (const char * arg1 , int len1 , const char * arg2 , int len2 , Oid collid )
1539
1539
{
1540
1540
int result ;
1541
+ pg_locale_t mylocale ;
1541
1542
1542
1543
check_collation_set (collid );
1543
1544
1544
- if (lc_collate_is_c (collid ))
1545
+ mylocale = pg_newlocale_from_collation (collid );
1546
+
1547
+ if (mylocale -> collate_is_c )
1545
1548
{
1546
1549
result = memcmp (arg1 , arg2 , Min (len1 , len2 ));
1547
1550
if ((result == 0 ) && (len1 != len2 ))
1548
1551
result = (len1 < len2 ) ? -1 : 1 ;
1549
1552
}
1550
1553
else
1551
1554
{
1552
- pg_locale_t mylocale ;
1553
-
1554
- mylocale = pg_newlocale_from_collation (collid );
1555
-
1556
1555
/*
1557
1556
* memcmp() can't tell us which of two unequal strings sorts first,
1558
1557
* 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)
1859
1858
bool abbreviate = ssup -> abbreviate ;
1860
1859
bool collate_c = false;
1861
1860
VarStringSortSupport * sss ;
1862
- pg_locale_t locale = 0 ;
1861
+ pg_locale_t locale ;
1863
1862
1864
1863
check_collation_set (collid );
1865
1864
1865
+ locale = pg_newlocale_from_collation (collid );
1866
+
1866
1867
/*
1867
1868
* If possible, set ssup->comparator to a function which can be used to
1868
1869
* 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)
1876
1877
* varstrfastcmp_c, bpcharfastcmp_c, or namefastcmp_c, all of which use
1877
1878
* memcmp() rather than strcoll().
1878
1879
*/
1879
- if (lc_collate_is_c ( collid ) )
1880
+ if (locale -> collate_is_c )
1880
1881
{
1881
1882
if (typid == BPCHAROID )
1882
1883
ssup -> comparator = bpcharfastcmp_c ;
@@ -1893,13 +1894,6 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
1893
1894
}
1894
1895
else
1895
1896
{
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
-
1903
1897
/*
1904
1898
* We use varlenafastcmp_locale except for type NAME.
1905
1899
*/
@@ -1950,7 +1944,10 @@ varstr_sortsupport(SortSupport ssup, Oid typid, Oid collid)
1950
1944
sss -> last_len2 = -1 ;
1951
1945
/* Initialize */
1952
1946
sss -> last_returned = 0 ;
1953
- sss -> locale = locale ;
1947
+ if (collate_c )
1948
+ sss -> locale = NULL ;
1949
+ else
1950
+ sss -> locale = locale ;
1954
1951
1955
1952
/*
1956
1953
* To avoid somehow confusing a strxfrm() blob and an original string,
@@ -2536,12 +2533,15 @@ btvarstrequalimage(PG_FUNCTION_ARGS)
2536
2533
{
2537
2534
/* Oid opcintype = PG_GETARG_OID(0); */
2538
2535
Oid collid = PG_GET_COLLATION ();
2536
+ pg_locale_t locale ;
2539
2537
2540
2538
check_collation_set (collid );
2541
2539
2542
- if (lc_collate_is_c (collid ) ||
2540
+ locale = pg_newlocale_from_collation (collid );
2541
+
2542
+ if (locale -> collate_is_c ||
2543
2543
collid == DEFAULT_COLLATION_OID ||
2544
- get_collation_isdeterministic ( collid ))
2544
+ pg_locale_deterministic ( locale ))
2545
2545
PG_RETURN_BOOL (true);
2546
2546
else
2547
2547
PG_RETURN_BOOL (false);
0 commit comments