1
0
mirror of https://github.com/postgres/postgres.git synced 2026-01-26 09:41:40 +03:00

Clean up ICU includes.

Remove ICU includes from pg_locale.h, and instead include them in the
few C files that need ICU. Clean up a few other includes in passing.

Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/48911db71d953edec66df0d2ce303563d631fbe0.camel@j-davis.com
This commit is contained in:
Jeff Davis
2026-01-06 17:19:51 -08:00
parent 75609fded3
commit af2d4ca191
6 changed files with 30 additions and 25 deletions

View File

@@ -14,6 +14,10 @@
*/
#include "postgres.h"
#ifdef USE_ICU
#include <unicode/uloc.h>
#endif
#include "access/htup_details.h"
#include "access/table.h"
#include "access/xact.h"

View File

@@ -68,17 +68,9 @@
#include <math.h>
#include <float.h>
#include <limits.h>
#include <wctype.h>
#ifdef USE_ICU
#include <unicode/ustring.h>
#endif
#include "catalog/pg_collation.h"
#include "catalog/pg_type.h"
#include "common/int.h"
#include "common/unicode_case.h"
#include "common/unicode_category.h"
#include "mb/pg_wchar.h"
#include "nodes/miscnodes.h"
#include "parser/scansup.h"

View File

@@ -32,6 +32,9 @@
#include "postgres.h"
#include <time.h>
#ifdef USE_ICU
#include <unicode/ucol.h>
#endif
#include "access/htup_details.h"
#include "catalog/pg_collation.h"
@@ -1645,6 +1648,17 @@ pg_towlower(pg_wchar wc, pg_locale_t locale)
return locale->ctype->wc_tolower(wc, locale);
}
/* version of Unicode used by ICU */
const char *
pg_icu_unicode_version()
{
#ifdef USE_ICU
return U_UNICODE_VERSION;
#else
return NULL;
#endif
}
/*
* Return required encoding ID for the given locale, or -1 if any encoding is
* valid for the locale.

View File

@@ -12,7 +12,9 @@
#include "postgres.h"
#ifdef USE_ICU
#include <unicode/ucasemap.h>
#include <unicode/ucnv.h>
#include <unicode/ucol.h>
#include <unicode/ustring.h>
/*

View File

@@ -5381,11 +5381,12 @@ unicode_version(PG_FUNCTION_ARGS)
Datum
icu_unicode_version(PG_FUNCTION_ARGS)
{
#ifdef USE_ICU
PG_RETURN_TEXT_P(cstring_to_text(U_UNICODE_VERSION));
#else
PG_RETURN_NULL();
#endif
const char *version = pg_icu_unicode_version();
if (version)
PG_RETURN_TEXT_P(cstring_to_text(version));
else
PG_RETURN_NULL();
}
/*

View File

@@ -14,16 +14,6 @@
#include "mb/pg_wchar.h"
#ifdef USE_ICU
/* only include the C APIs, to avoid errors in cpluspluscheck */
#undef U_SHOW_CPLUSPLUS_API
#define U_SHOW_CPLUSPLUS_API 0
#undef U_SHOW_CPLUSPLUS_HEADER_API
#define U_SHOW_CPLUSPLUS_HEADER_API 0
#include <unicode/ucol.h>
#include <unicode/ucasemap.h>
#endif
/* use for libc locale names */
#define LOCALE_NAME_BUFLEN 128
@@ -167,9 +157,9 @@ struct pg_locale_struct
struct
{
const char *locale;
UCollator *ucol;
struct UCollator *ucol;
struct UCaseMap *ucasemap;
locale_t lt;
UCaseMap *ucasemap;
} icu;
#endif
};
@@ -223,6 +213,8 @@ extern bool pg_iswcased(pg_wchar wc, pg_locale_t locale);
extern pg_wchar pg_towupper(pg_wchar wc, pg_locale_t locale);
extern pg_wchar pg_towlower(pg_wchar wc, pg_locale_t locale);
extern const char *pg_icu_unicode_version(void);
extern int builtin_locale_encoding(const char *locale);
extern const char *builtin_validate_locale(int encoding, const char *locale);
extern void icu_validate_locale(const char *loc_str);