@@ -1641,31 +1641,29 @@ str_tolower(const char *buff, size_t nbytes, Oid collid)
1641
1641
if (!buff )
1642
1642
return NULL ;
1643
1643
1644
+ if (!OidIsValid (collid ))
1645
+ {
1646
+ /*
1647
+ * This typically means that the parser could not resolve a
1648
+ * conflict of implicit collations, so report it that way.
1649
+ */
1650
+ ereport (ERROR ,
1651
+ (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1652
+ errmsg ("could not determine which collation to use for %s function" ,
1653
+ "lower()" ),
1654
+ errhint ("Use the COLLATE clause to set the collation explicitly." )));
1655
+ }
1656
+
1644
1657
/* C/POSIX collations use this path regardless of database encoding */
1645
1658
if (lc_ctype_is_c (collid ))
1646
1659
{
1647
1660
result = asc_tolower (buff , nbytes );
1648
1661
}
1649
1662
else
1650
1663
{
1651
- pg_locale_t mylocale = 0 ;
1664
+ pg_locale_t mylocale ;
1652
1665
1653
- if (collid != DEFAULT_COLLATION_OID )
1654
- {
1655
- if (!OidIsValid (collid ))
1656
- {
1657
- /*
1658
- * This typically means that the parser could not resolve a
1659
- * conflict of implicit collations, so report it that way.
1660
- */
1661
- ereport (ERROR ,
1662
- (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1663
- errmsg ("could not determine which collation to use for %s function" ,
1664
- "lower()" ),
1665
- errhint ("Use the COLLATE clause to set the collation explicitly." )));
1666
- }
1667
- mylocale = pg_newlocale_from_collation (collid );
1668
- }
1666
+ mylocale = pg_newlocale_from_collation (collid );
1669
1667
1670
1668
#ifdef USE_ICU
1671
1669
if (mylocale && mylocale -> provider == COLLPROVIDER_ICU )
@@ -1765,31 +1763,29 @@ str_toupper(const char *buff, size_t nbytes, Oid collid)
1765
1763
if (!buff )
1766
1764
return NULL ;
1767
1765
1766
+ if (!OidIsValid (collid ))
1767
+ {
1768
+ /*
1769
+ * This typically means that the parser could not resolve a
1770
+ * conflict of implicit collations, so report it that way.
1771
+ */
1772
+ ereport (ERROR ,
1773
+ (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1774
+ errmsg ("could not determine which collation to use for %s function" ,
1775
+ "upper()" ),
1776
+ errhint ("Use the COLLATE clause to set the collation explicitly." )));
1777
+ }
1778
+
1768
1779
/* C/POSIX collations use this path regardless of database encoding */
1769
1780
if (lc_ctype_is_c (collid ))
1770
1781
{
1771
1782
result = asc_toupper (buff , nbytes );
1772
1783
}
1773
1784
else
1774
1785
{
1775
- pg_locale_t mylocale = 0 ;
1786
+ pg_locale_t mylocale ;
1776
1787
1777
- if (collid != DEFAULT_COLLATION_OID )
1778
- {
1779
- if (!OidIsValid (collid ))
1780
- {
1781
- /*
1782
- * This typically means that the parser could not resolve a
1783
- * conflict of implicit collations, so report it that way.
1784
- */
1785
- ereport (ERROR ,
1786
- (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1787
- errmsg ("could not determine which collation to use for %s function" ,
1788
- "upper()" ),
1789
- errhint ("Use the COLLATE clause to set the collation explicitly." )));
1790
- }
1791
- mylocale = pg_newlocale_from_collation (collid );
1792
- }
1788
+ mylocale = pg_newlocale_from_collation (collid );
1793
1789
1794
1790
#ifdef USE_ICU
1795
1791
if (mylocale && mylocale -> provider == COLLPROVIDER_ICU )
@@ -1890,31 +1886,29 @@ str_initcap(const char *buff, size_t nbytes, Oid collid)
1890
1886
if (!buff )
1891
1887
return NULL ;
1892
1888
1889
+ if (!OidIsValid (collid ))
1890
+ {
1891
+ /*
1892
+ * This typically means that the parser could not resolve a
1893
+ * conflict of implicit collations, so report it that way.
1894
+ */
1895
+ ereport (ERROR ,
1896
+ (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1897
+ errmsg ("could not determine which collation to use for %s function" ,
1898
+ "initcap()" ),
1899
+ errhint ("Use the COLLATE clause to set the collation explicitly." )));
1900
+ }
1901
+
1893
1902
/* C/POSIX collations use this path regardless of database encoding */
1894
1903
if (lc_ctype_is_c (collid ))
1895
1904
{
1896
1905
result = asc_initcap (buff , nbytes );
1897
1906
}
1898
1907
else
1899
1908
{
1900
- pg_locale_t mylocale = 0 ;
1909
+ pg_locale_t mylocale ;
1901
1910
1902
- if (collid != DEFAULT_COLLATION_OID )
1903
- {
1904
- if (!OidIsValid (collid ))
1905
- {
1906
- /*
1907
- * This typically means that the parser could not resolve a
1908
- * conflict of implicit collations, so report it that way.
1909
- */
1910
- ereport (ERROR ,
1911
- (errcode (ERRCODE_INDETERMINATE_COLLATION ),
1912
- errmsg ("could not determine which collation to use for %s function" ,
1913
- "initcap()" ),
1914
- errhint ("Use the COLLATE clause to set the collation explicitly." )));
1915
- }
1916
- mylocale = pg_newlocale_from_collation (collid );
1917
- }
1911
+ mylocale = pg_newlocale_from_collation (collid );
1918
1912
1919
1913
#ifdef USE_ICU
1920
1914
if (mylocale && mylocale -> provider == COLLPROVIDER_ICU )
0 commit comments