1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-09 06:21:09 +03:00

Locale support is on by default. The choice of locale is done in initdb

and/or with GUC variables.
This commit is contained in:
Peter Eisentraut
2002-04-03 05:39:33 +00:00
parent 3d7755c8e9
commit 867901db9e
19 changed files with 554 additions and 479 deletions

View File

@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2001, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.90 2002/03/15 19:20:30 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.91 2002/04/03 05:39:29 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -22,9 +22,7 @@
#include <sys/time.h>
#include <sys/types.h>
#include <dirent.h>
#ifdef USE_LOCALE
#include <locale.h>
#endif
#include "access/clog.h"
#include "access/transam.h"
@@ -2081,10 +2079,7 @@ WriteControlFile(void)
{
int fd;
char buffer[BLCKSZ]; /* need not be aligned */
#ifdef USE_LOCALE
char *localeptr;
#endif
/*
* Initialize version and compatibility-check fields
@@ -2093,7 +2088,6 @@ WriteControlFile(void)
ControlFile->catalog_version_no = CATALOG_VERSION_NO;
ControlFile->blcksz = BLCKSZ;
ControlFile->relseg_size = RELSEG_SIZE;
#ifdef USE_LOCALE
localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr)
elog(PANIC, "invalid LC_COLLATE setting");
@@ -2115,10 +2109,6 @@ WriteControlFile(void)
"\n\tsuch queries, you may wish to set LC_COLLATE to \"C\" and"
"\n\tre-initdb. For more information see the Administrator's Guide.",
ControlFile->lc_collate);
#else /* not USE_LOCALE */
strcpy(ControlFile->lc_collate, "C");
strcpy(ControlFile->lc_ctype, "C");
#endif /* not USE_LOCALE */
/* Contents are protected with a CRC */
INIT_CRC64(ControlFile->crc);
@@ -2232,7 +2222,6 @@ ReadControlFile(void)
"\tbut the backend was compiled with RELSEG_SIZE %d.\n"
"\tIt looks like you need to initdb.",
ControlFile->relseg_size, RELSEG_SIZE);
#ifdef USE_LOCALE
if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL)
elog(PANIC,
"The database cluster was initialized with LC_COLLATE '%s',\n"
@@ -2245,15 +2234,6 @@ ReadControlFile(void)
"\twhich is not recognized by setlocale().\n"
"\tIt looks like you need to initdb.",
ControlFile->lc_ctype);
#else /* not USE_LOCALE */
if (strcmp(ControlFile->lc_collate, "C") != 0 ||
strcmp(ControlFile->lc_ctype, "C") != 0)
elog(PANIC,
"The database cluster was initialized with LC_COLLATE '%s' and\n"
"\tLC_CTYPE '%s', but the server was compiled without locale support.\n"
"\tIt looks like you need to initdb or recompile.",
ControlFile->lc_collate, ControlFile->lc_ctype);
#endif /* not USE_LOCALE */
}
void

View File

@@ -13,7 +13,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.49 2001/11/05 17:46:25 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.50 2002/04/03 05:39:29 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -21,9 +21,7 @@
#include <pwd.h>
#include <unistd.h>
#if defined(USE_LOCALE) || defined(ENABLE_NLS)
#include <locale.h>
#endif
#if defined(__alpha) && defined(__osf__)
#include <sys/sysinfo.h>
@@ -122,11 +120,25 @@ main(int argc, char *argv[])
new_argv[i] = strdup(argv[i]);
new_argv[argc] = NULL;
/* Initialize NLS settings so we can give localized error messages */
#ifdef ENABLE_NLS
/*
* Set up locale information from environment. Note that CTYPE
* and COLLATE will be overridden later from pg_control if we are
* in an already-initialized database. We set them here so that
* they will be available to fill pg_control during initdb. The
* other ones will get reset later in ResetAllOptions, but we set
* them here to get already localized behavior during startup
* (e.g., error messages).
*/
setlocale(LC_COLLATE, "");
setlocale(LC_CTYPE, "");
#ifdef LC_MESSAGES
setlocale(LC_MESSAGES, "");
#endif
setlocale(LC_MONETARY, "");
setlocale(LC_NUMERIC, "");
setlocale(LC_TIME, "");
#ifdef ENABLE_NLS
bindtextdomain("postgres", LOCALEDIR);
textdomain("postgres");
#endif
@@ -178,20 +190,6 @@ main(int argc, char *argv[])
}
}
/*
* Set up locale information from environment, in only the categories
* needed by Postgres; leave other categories set to default "C".
* (Note that CTYPE and COLLATE will be overridden later from
* pg_control if we are in an already-initialized database. We set
* them here so that they will be available to fill pg_control during
* initdb.)
*/
#ifdef USE_LOCALE
setlocale(LC_CTYPE, "");
setlocale(LC_COLLATE, "");
setlocale(LC_MONETARY, "");
#endif
/*
* Now dispatch to one of PostmasterMain, PostgresMain, or
* BootstrapMain depending on the program name (and possibly first

View File

@@ -9,7 +9,7 @@
* workings can be found in the book "Software Solutions in C" by
* Dale Schumacher, Academic Press, ISBN: 0-12-632360-7.
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.52 2002/02/19 22:19:34 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.53 2002/04/03 05:39:29 petere Exp $
*/
#include "postgres.h"
@@ -17,9 +17,7 @@
#include <limits.h>
#include <ctype.h>
#include <math.h>
#ifdef USE_LOCALE
#include <locale.h>
#endif
#include "miscadmin.h"
#include "utils/builtins.h"
@@ -83,11 +81,7 @@ cash_in(PG_FUNCTION_ARGS)
psymbol,
*nsymbol;
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
#endif
#ifdef USE_LOCALE
/*
* frac_digits will be CHAR_MAX in some locales, notably C. However,
@@ -108,14 +102,6 @@ cash_in(PG_FUNCTION_ARGS)
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
psymbol = ((*lconvert->positive_sign != '\0') ? *lconvert->positive_sign : '+');
nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");
#else
fpoint = 2;
dsymbol = '.';
ssymbol = ',';
csymbol = "$";
psymbol = '+';
nsymbol = "-";
#endif
#ifdef CASHDEBUG
printf("cashin- precision '%d'; decimal '%c'; thousands '%c'; currency '%s'; positive '%c'; negative '%s'\n",
@@ -241,11 +227,8 @@ cash_out(PG_FUNCTION_ARGS)
*nsymbol;
char convention;
#ifdef USE_LOCALE
struct lconv *lconvert = PGLC_localeconv();
#endif
#ifdef USE_LOCALE
/* see comments about frac_digits in cash_in() */
points = lconvert->frac_digits;
if (points < 0 || points > 10)
@@ -264,15 +247,6 @@ cash_out(PG_FUNCTION_ARGS)
dsymbol = ((*lconvert->mon_decimal_point != '\0') ? *lconvert->mon_decimal_point : '.');
csymbol = ((*lconvert->currency_symbol != '\0') ? lconvert->currency_symbol : "$");
nsymbol = ((*lconvert->negative_sign != '\0') ? lconvert->negative_sign : "-");
#else
points = 2;
mon_group = 3;
comma = ',';
convention = 0;
dsymbol = '.';
csymbol = "$";
nsymbol = "-";
#endif
point_pos = LAST_DIGIT - points;

View File

@@ -1,7 +1,7 @@
/* -----------------------------------------------------------------------
* formatting.c
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.51 2002/03/06 06:10:12 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.52 2002/04/03 05:39:29 petere Exp $
*
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
@@ -72,9 +72,7 @@
#include <ctype.h>
#include <sys/time.h>
#include <unistd.h>
#ifdef USE_LOCALE
#include <locale.h>
#endif
#include <math.h>
#include <float.h>
@@ -3380,9 +3378,6 @@ int_to_roman(int number)
static void
NUM_prepare_locale(NUMProc *Np)
{
#ifdef USE_LOCALE
if (Np->Num->need_locale)
{
@@ -3436,8 +3431,6 @@ NUM_prepare_locale(NUMProc *Np)
}
else
{
#endif
/*
* Default values
*/
@@ -3446,10 +3439,7 @@ NUM_prepare_locale(NUMProc *Np)
Np->decimal = ".";
Np->L_thousands_sep = ",";
Np->L_currency_symbol = " ";
#ifdef USE_LOCALE
}
#endif
}
/* ----------

View File

@@ -1,173 +1,144 @@
/* -----------------------------------------------------------------------
* pg_locale.c
/*-----------------------------------------------------------------------
*
* The PostgreSQL locale utils.
* PostgreSQL locale utilities
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.16 2002/04/03 05:39:31 petere Exp $
*
* $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.15 2002/03/06 06:10:14 momjian Exp $
* Portions Copyright (c) 2002, PostgreSQL Global Development Group
*
* Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group
*
* Karel Zak
*
* -----------------------------------------------------------------------
*-----------------------------------------------------------------------
*/
#include "postgres.h"
#ifdef USE_LOCALE
#include "utils/pg_locale.h"
#include <locale.h>
#include "utils/pg_locale.h"
/* #define DEBUG_LOCALE_UTILS */
/* GUC storage area */
char * locale_messages;
char * locale_monetary;
char * locale_numeric;
char * locale_time;
static bool CurrentLocaleConvValid = false;
static struct lconv CurrentLocaleConv;
/* GUC parse hooks */
static void PGLC_setlocale(PG_LocaleCategories *lc);
/*------
* Frees memory used in PG_LocaleCategories -- this memory is
* allocated in PGLC_current().
*------
*/
void
PGLC_free_categories(PG_LocaleCategories *lc)
{
if (lc->lc_ctype)
pfree(lc->lc_ctype);
if (lc->lc_numeric)
pfree(lc->lc_numeric);
if (lc->lc_time)
pfree(lc->lc_time);
if (lc->lc_collate)
pfree(lc->lc_collate);
if (lc->lc_monetary);
pfree(lc->lc_monetary);
#ifdef LC_MESSAGES
if (lc->lc_messages)
pfree(lc->lc_messages);
#endif
}
/*------
* Return in PG_LocaleCategories the current locale settings.
*
* NB: strings are allocated in the current memory context!
*------
*/
void
PGLC_current(PG_LocaleCategories *lc)
{
lc->lang = getenv("LANG");
lc->lc_ctype = pstrdup(setlocale(LC_CTYPE, NULL));
lc->lc_numeric = pstrdup(setlocale(LC_NUMERIC, NULL));
lc->lc_time = pstrdup(setlocale(LC_TIME, NULL));
lc->lc_collate = pstrdup(setlocale(LC_COLLATE, NULL));
lc->lc_monetary = pstrdup(setlocale(LC_MONETARY, NULL));
#ifdef LC_MESSAGES
lc->lc_messages = pstrdup(setlocale(LC_MESSAGES, NULL));
#endif
}
#ifdef DEBUG_LOCALE_UTILS
/*------
* Print a PG_LocaleCategories struct as DEBUG
*------
*/
static void
PGLC_debug_lc(PG_LocaleCategories *lc)
bool locale_messages_check(const char *proposed)
{
#ifdef LC_MESSAGES
elog(LOG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\nLC_MESSAGES:\t%s\n",
lc->lang,
lc->lc_ctype,
lc->lc_numeric,
lc->lc_time,
lc->lc_collate,
lc->lc_monetary,
lc->lc_messages);
return chklocale(LC_MESSAGES, proposed);
#else
elog(LOG, "CURRENT LOCALE ENVIRONMENT:\n\nLANG: \t%s\nLC_CTYPE:\t%s\nLC_NUMERIC:\t%s\nLC_TIME:\t%s\nLC_COLLATE:\t%s\nLC_MONETARY:\t%s\n",
lc->lang,
lc->lc_ctype,
lc->lc_numeric,
lc->lc_time,
lc->lc_collate,
lc->lc_monetary);
/* We return true here so LC_MESSAGES can be set in the
configuration file on every system. */
return true;
#endif
}
#endif
/*------
* Set locales via a PG_LocaleCategories struct
*
* NB: it would be very dangerous to set the locale values to any random
* choice of locale, since that could cause indexes to become corrupt, etc.
* Therefore this routine is NOT exported from this module. It should be
* used only to restore previous locale settings during PGLC_localeconv.
*------
*/
static void
PGLC_setlocale(PG_LocaleCategories *lc)
bool locale_monetary_check(const char *proposed)
{
if (!setlocale(LC_COLLATE, lc->lc_collate))
elog(WARNING, "pg_setlocale(): 'LC_COLLATE=%s' cannot be honored.",
lc->lc_collate);
return chklocale(LC_MONETARY, proposed);
}
if (!setlocale(LC_CTYPE, lc->lc_ctype))
elog(WARNING, "pg_setlocale(): 'LC_CTYPE=%s' cannot be honored.",
lc->lc_ctype);
bool locale_numeric_check(const char *proposed)
{
return chklocale(LC_NUMERIC, proposed);
}
if (!setlocale(LC_NUMERIC, lc->lc_numeric))
elog(WARNING, "pg_setlocale(): 'LC_NUMERIC=%s' cannot be honored.",
lc->lc_numeric);
bool locale_time_check(const char *proposed)
{
return chklocale(LC_TIME, proposed);
}
if (!setlocale(LC_TIME, lc->lc_time))
elog(WARNING, "pg_setlocale(): 'LC_TIME=%s' cannot be honored.",
lc->lc_time);
if (!setlocale(LC_MONETARY, lc->lc_monetary))
elog(WARNING, "pg_setlocale(): 'LC_MONETARY=%s' cannot be honored.",
lc->lc_monetary);
/* GUC assign hooks */
void locale_messages_assign(const char *value)
{
#ifdef LC_MESSAGES
if (!setlocale(LC_MESSAGES, lc->lc_messages))
elog(WARNING, "pg_setlocale(): 'LC_MESSAGES=%s' cannot be honored.",
lc->lc_messages);
setlocale(LC_MESSAGES, value);
#endif
}
/*------
* Return the POSIX lconv struct (contains number/money formatting information)
* with locale information for all categories. Note that returned lconv
* does not depend on currently active category settings, but on external
* environment variables for locale.
*------
void locale_monetary_assign(const char *value)
{
setlocale(LC_MONETARY, value);
}
void locale_numeric_assign(const char *value)
{
setlocale(LC_NUMERIC, value);
}
void locale_time_assign(const char *value)
{
setlocale(LC_TIME, value);
}
/*
* Returns true if the proposed string represents a valid locale of
* the given category. This is probably pretty slow, but it's not
* called in critical places.
*/
bool
chklocale(int category, const char *proposed)
{
char *save;
save = setlocale(category, NULL);
if (!save)
return false;
if (!setlocale(category, proposed))
return false;
setlocale(category, save);
return true;
}
/*
* We'd like to cache whether LC_COLLATE is C (or POSIX), so we can
* optimize a few code paths in various places.
*/
bool
lc_collate_is_c(void)
{
/* Cache result so we only have to compute it once */
static int result = -1;
char *localeptr;
if (result >= 0)
return (bool) result;
localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr)
elog(PANIC, "Invalid LC_COLLATE setting");
if (strcmp(localeptr, "C") == 0)
result = true;
else if (strcmp(localeptr, "POSIX") == 0)
result = true;
else
result = false;
return (bool) result;
}
/*
* Return the POSIX lconv struct (contains number/money formatting
* information) with locale information for all categories.
*/
struct lconv *
PGLC_localeconv(void)
{
PG_LocaleCategories lc;
struct lconv *extlconv;
static bool CurrentLocaleConvValid = false;
static struct lconv CurrentLocaleConv;
/* Did we do it already? */
if (CurrentLocaleConvValid)
return &CurrentLocaleConv;
/* Save current locale setting to lc */
PGLC_current(&lc);
/* Set all locale categories based on postmaster's environment vars */
setlocale(LC_ALL, "");
/* Get formatting information for the external environment */
extlconv = localeconv();
@@ -187,14 +158,6 @@ PGLC_localeconv(void)
CurrentLocaleConv.negative_sign = strdup(extlconv->negative_sign);
CurrentLocaleConv.positive_sign = strdup(extlconv->positive_sign);
/* Restore Postgres' internal locale settings */
PGLC_setlocale(&lc);
/* Deallocate category settings allocated in PGLC_current() */
PGLC_free_categories(&lc);
CurrentLocaleConvValid = true;
return &CurrentLocaleConv;
}
#endif /* USE_LOCALE */

View File

@@ -15,7 +15,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.106 2002/03/08 04:29:01 momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.107 2002/04/03 05:39:31 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -70,9 +70,7 @@
#include <ctype.h>
#include <math.h>
#ifdef USE_LOCALE
#include <locale.h>
#endif
#include "access/heapam.h"
#include "catalog/catname.h"
@@ -95,6 +93,7 @@
#include "utils/datum.h"
#include "utils/int8.h"
#include "utils/lsyscache.h"
#include "utils/pg_locale.h"
#include "utils/selfuncs.h"
#include "utils/syscache.h"
@@ -2240,19 +2239,16 @@ convert_one_string_to_scalar(unsigned char *value, int rangelo, int rangehi)
/*
* Convert a string-type Datum into a palloc'd, null-terminated string.
*
* If USE_LOCALE is defined, we must pass the string through strxfrm()
* When using a non-C locale, we must pass the string through strxfrm()
* before continuing, so as to generate correct locale-specific results.
*/
static unsigned char *
convert_string_datum(Datum value, Oid typid)
{
char *val;
#ifdef USE_LOCALE
char *xfrmstr;
size_t xfrmsize;
size_t xfrmlen;
#endif
switch (typid)
{
@@ -2290,21 +2286,22 @@ convert_string_datum(Datum value, Oid typid)
return NULL;
}
#ifdef USE_LOCALE
/* Guess that transformed string is not much bigger than original */
xfrmsize = strlen(val) + 32; /* arbitrary pad value here... */
xfrmstr = (char *) palloc(xfrmsize);
xfrmlen = strxfrm(xfrmstr, val, xfrmsize);
if (xfrmlen >= xfrmsize)
if (!lc_collate_is_c())
{
/* Oops, didn't make it */
pfree(xfrmstr);
xfrmstr = (char *) palloc(xfrmlen + 1);
xfrmlen = strxfrm(xfrmstr, val, xfrmlen + 1);
/* Guess that transformed string is not much bigger than original */
xfrmsize = strlen(val) + 32; /* arbitrary pad value here... */
xfrmstr = (char *) palloc(xfrmsize);
xfrmlen = strxfrm(xfrmstr, val, xfrmsize);
if (xfrmlen >= xfrmsize)
{
/* Oops, didn't make it */
pfree(xfrmstr);
xfrmstr = (char *) palloc(xfrmlen + 1);
xfrmlen = strxfrm(xfrmstr, val, xfrmlen + 1);
}
pfree(val);
val = xfrmstr;
}
pfree(val);
val = xfrmstr;
#endif
return (unsigned char *) val;
}
@@ -3147,44 +3144,28 @@ pattern_selectivity(char *patt, Pattern_Type ptype)
return result;
}
/*
* Test whether the database's LOCALE setting is safe for LIKE/regexp index
* optimization. The key requirement here is that given a prefix string,
* say "foo", we must be able to generate another string "fop" that is
* greater than all strings "foobar" starting with "foo". Unfortunately,
* many non-C locales have bizarre collation rules in which "fop" > "foo"
* is not sufficient to ensure "fop" > "foobar". Until we can come up
* with a more bulletproof way of generating the upper-bound string,
* disable the optimization in locales where it is not known to be safe.
* We want test whether the database's LC_COLLATE setting is safe for
* LIKE/regexp index optimization.
*
* The key requirement here is that given a prefix string, say "foo",
* we must be able to generate another string "fop" that is greater
* than all strings "foobar" starting with "foo". Unfortunately, a
* non-C locale may have arbitrary collation rules in which "fop" >
* "foo" is not sufficient to ensure "fop" > "foobar". Until we can
* come up with a more bulletproof way of generating the upper-bound
* string, the optimization is disabled in all non-C locales.
*
* (In theory, locales other than C may be LIKE-safe so this function
* could be different from lc_collate_is_c(), but in a different
* theory, non-C locales are completely unpredicable so it's unlikely
* to happen.)
*/
bool
locale_is_like_safe(void)
{
#ifdef USE_LOCALE
/* Cache result so we only have to compute it once */
static int result = -1;
char *localeptr;
if (result >= 0)
return (bool) result;
localeptr = setlocale(LC_COLLATE, NULL);
if (!localeptr)
elog(PANIC, "Invalid LC_COLLATE setting");
/*
* Currently we accept only "C" and "POSIX" (do any systems still
* return "POSIX"?). Which other locales allow safe optimization?
*/
if (strcmp(localeptr, "C") == 0)
result = true;
else if (strcmp(localeptr, "POSIX") == 0)
result = true;
else
result = false;
return (bool) result;
#else /* not USE_LOCALE */
return true; /* We must be in C locale, which is OK */
#endif /* USE_LOCALE */
return lc_collate_is_c();
}
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.81 2002/04/01 03:34:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.82 2002/04/03 05:39:32 petere Exp $
*
*-------------------------------------------------------------------------
*/
@@ -19,6 +19,7 @@
#include "mb/pg_wchar.h"
#include "miscadmin.h"
#include "utils/builtins.h"
#include "utils/pg_locale.h"
static int text_cmp(text *arg1, text *arg2);
@@ -493,29 +494,36 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2)
char *a1p,
*a2p;
#ifdef USE_LOCALE
a1p = (char *) palloc(len1 + 1);
a2p = (char *) palloc(len2 + 1);
/*
* Unfortunately, there is no strncoll(), so in the non-C locale
* case we have to do some memory copying. This turns out to be
* significantly slower, so we optimize the case were LC_COLLATE
* is C.
*/
if (!lc_collate_is_c())
{
a1p = (char *) palloc(len1 + 1);
a2p = (char *) palloc(len2 + 1);
memcpy(a1p, arg1, len1);
*(a1p + len1) = '\0';
memcpy(a2p, arg2, len2);
*(a2p + len2) = '\0';
memcpy(a1p, arg1, len1);
*(a1p + len1) = '\0';
memcpy(a2p, arg2, len2);
*(a2p + len2) = '\0';
result = strcoll(a1p, a2p);
result = strcoll(a1p, a2p);
pfree(a1p);
pfree(a2p);
pfree(a1p);
pfree(a2p);
}
else
{
a1p = arg1;
a2p = arg2;
#else
a1p = arg1;
a2p = arg2;
result = strncmp(a1p, a2p, Min(len1, len2));
if ((result == 0) && (len1 != len2))
result = (len1 < len2) ? -1 : 1;
#endif
result = strncmp(a1p, a2p, Min(len1, len2));
if ((result == 0) && (len1 != len2))
result = (len1 < len2) ? -1 : 1;
}
return result;
}

View File

@@ -4,7 +4,7 @@
* Support for grand unified configuration scheme, including SET
* command, configuration file, and command line options.
*
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.64 2002/04/01 03:34:26 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.65 2002/04/03 05:39:32 petere Exp $
*
* Copyright 2000 by PostgreSQL Global Development Group
* Written by Peter Eisentraut <peter_e@gmx.net>.
@@ -41,6 +41,7 @@
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/elog.h"
#include "utils/pg_locale.h"
#include "pgstat.h"
@@ -585,6 +586,26 @@ static struct config_string
PG_KRB_SRVTAB, NULL, NULL
},
{
"lc_messages", PGC_POSTMASTER, PGC_S_DEFAULT, &locale_messages,
"", locale_messages_check, locale_messages_assign
},
{
"lc_monetary", PGC_POSTMASTER, PGC_S_DEFAULT, &locale_monetary,
"", locale_monetary_check, locale_monetary_assign
},
{
"lc_numeric", PGC_POSTMASTER, PGC_S_DEFAULT, &locale_numeric,
"", locale_numeric_check, locale_numeric_assign
},
{
"lc_time", PGC_POSTMASTER, PGC_S_DEFAULT, &locale_time,
"", locale_time_check, locale_time_assign
},
{
"server_min_messages", PGC_USERSET, PGC_S_DEFAULT, &server_min_messages_str,
server_min_messages_str_default, check_server_min_messages,