mirror of
https://github.com/postgres/postgres.git
synced 2025-06-17 17:02:08 +03:00
Change collate and ctype fields to type text
This changes the data type of the catalog fields datcollate, datctype, collcollate, and collctype from name to text. There wasn't ever a really good reason for them to be of type name; presumably this was just carried over from when they were fixed-size fields in pg_control, first into the corresponding pg_database fields, and then to pg_collation. The values are not identifiers or object names, and we don't ever look them up that way. Changing to type text saves space in the typical case, since locale names are typically only a few bytes long. But it is also possible that an ICU locale name with several customization options appended could be longer than 63 bytes, so this also enables that case, which was previously probably broken. Reviewed-by: Julien Rouhaud <rjuju123@gmail.com> Discussion: https://www.postgresql.org/message-id/flat/5e756dd6-0e91-d778-96fd-b1bcb06c161a@2ndquadrant.com
This commit is contained in:
@ -2368,7 +2368,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
|||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>collcollate</structfield> <type>name</type>
|
<structfield>collcollate</structfield> <type>text</type>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<symbol>LC_COLLATE</symbol> for this collation object
|
<symbol>LC_COLLATE</symbol> for this collation object
|
||||||
@ -2377,7 +2377,7 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
|||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>collctype</structfield> <type>name</type>
|
<structfield>collctype</structfield> <type>text</type>
|
||||||
</para>
|
</para>
|
||||||
<para>
|
<para>
|
||||||
<symbol>LC_CTYPE</symbol> for this collation object
|
<symbol>LC_CTYPE</symbol> for this collation object
|
||||||
@ -2951,24 +2951,6 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
|||||||
</para></entry>
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
<row>
|
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
|
||||||
<structfield>datcollate</structfield> <type>name</type>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
LC_COLLATE for this database
|
|
||||||
</para></entry>
|
|
||||||
</row>
|
|
||||||
|
|
||||||
<row>
|
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
|
||||||
<structfield>datctype</structfield> <type>name</type>
|
|
||||||
</para>
|
|
||||||
<para>
|
|
||||||
LC_CTYPE for this database
|
|
||||||
</para></entry>
|
|
||||||
</row>
|
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>datistemplate</structfield> <type>bool</type>
|
<structfield>datistemplate</structfield> <type>bool</type>
|
||||||
@ -3043,6 +3025,24 @@ SCRAM-SHA-256$<replaceable><iteration count></replaceable>:<replaceable>&l
|
|||||||
</para></entry>
|
</para></entry>
|
||||||
</row>
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>datcollate</structfield> <type>text</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
LC_COLLATE for this database
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
|
<row>
|
||||||
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
|
<structfield>datctype</structfield> <type>text</type>
|
||||||
|
</para>
|
||||||
|
<para>
|
||||||
|
LC_CTYPE for this database
|
||||||
|
</para></entry>
|
||||||
|
</row>
|
||||||
|
|
||||||
<row>
|
<row>
|
||||||
<entry role="catalog_table_entry"><para role="column_definition">
|
<entry role="catalog_table_entry"><para role="column_definition">
|
||||||
<structfield>datacl</structfield> <type>aclitem[]</type>
|
<structfield>datacl</structfield> <type>aclitem[]</type>
|
||||||
|
@ -58,9 +58,7 @@ CollationCreate(const char *collname, Oid collnamespace,
|
|||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Datum values[Natts_pg_collation];
|
Datum values[Natts_pg_collation];
|
||||||
bool nulls[Natts_pg_collation];
|
bool nulls[Natts_pg_collation];
|
||||||
NameData name_name,
|
NameData name_name;
|
||||||
name_collate,
|
|
||||||
name_ctype;
|
|
||||||
Oid oid;
|
Oid oid;
|
||||||
ObjectAddress myself,
|
ObjectAddress myself,
|
||||||
referenced;
|
referenced;
|
||||||
@ -163,10 +161,8 @@ CollationCreate(const char *collname, Oid collnamespace,
|
|||||||
values[Anum_pg_collation_collprovider - 1] = CharGetDatum(collprovider);
|
values[Anum_pg_collation_collprovider - 1] = CharGetDatum(collprovider);
|
||||||
values[Anum_pg_collation_collisdeterministic - 1] = BoolGetDatum(collisdeterministic);
|
values[Anum_pg_collation_collisdeterministic - 1] = BoolGetDatum(collisdeterministic);
|
||||||
values[Anum_pg_collation_collencoding - 1] = Int32GetDatum(collencoding);
|
values[Anum_pg_collation_collencoding - 1] = Int32GetDatum(collencoding);
|
||||||
namestrcpy(&name_collate, collcollate);
|
values[Anum_pg_collation_collcollate - 1] = CStringGetTextDatum(collcollate);
|
||||||
values[Anum_pg_collation_collcollate - 1] = NameGetDatum(&name_collate);
|
values[Anum_pg_collation_collctype - 1] = CStringGetTextDatum(collctype);
|
||||||
namestrcpy(&name_ctype, collctype);
|
|
||||||
values[Anum_pg_collation_collctype - 1] = NameGetDatum(&name_ctype);
|
|
||||||
if (collversion)
|
if (collversion)
|
||||||
values[Anum_pg_collation_collversion - 1] = CStringGetTextDatum(collversion);
|
values[Anum_pg_collation_collversion - 1] = CStringGetTextDatum(collversion);
|
||||||
else
|
else
|
||||||
|
@ -129,18 +129,30 @@ DefineCollation(ParseState *pstate, List *names, List *parameters, bool if_not_e
|
|||||||
{
|
{
|
||||||
Oid collid;
|
Oid collid;
|
||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
|
Datum datum;
|
||||||
|
bool isnull;
|
||||||
|
|
||||||
collid = get_collation_oid(defGetQualifiedName(fromEl), false);
|
collid = get_collation_oid(defGetQualifiedName(fromEl), false);
|
||||||
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
||||||
if (!HeapTupleIsValid(tp))
|
if (!HeapTupleIsValid(tp))
|
||||||
elog(ERROR, "cache lookup failed for collation %u", collid);
|
elog(ERROR, "cache lookup failed for collation %u", collid);
|
||||||
|
|
||||||
collcollate = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collcollate));
|
|
||||||
collctype = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collctype));
|
|
||||||
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
||||||
collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic;
|
collisdeterministic = ((Form_pg_collation) GETSTRUCT(tp))->collisdeterministic;
|
||||||
collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
|
collencoding = ((Form_pg_collation) GETSTRUCT(tp))->collencoding;
|
||||||
|
|
||||||
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
|
||||||
|
if (!isnull)
|
||||||
|
collcollate = TextDatumGetCString(datum);
|
||||||
|
else
|
||||||
|
collcollate = NULL;
|
||||||
|
|
||||||
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collctype, &isnull);
|
||||||
|
if (!isnull)
|
||||||
|
collctype = TextDatumGetCString(datum);
|
||||||
|
else
|
||||||
|
collctype = NULL;
|
||||||
|
|
||||||
ReleaseSysCache(tp);
|
ReleaseSysCache(tp);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -314,7 +326,7 @@ AlterCollation(AlterCollationStmt *stmt)
|
|||||||
Oid collOid;
|
Oid collOid;
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_collation collForm;
|
Form_pg_collation collForm;
|
||||||
Datum collversion;
|
Datum datum;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
char *oldversion;
|
char *oldversion;
|
||||||
char *newversion;
|
char *newversion;
|
||||||
@ -332,11 +344,12 @@ AlterCollation(AlterCollationStmt *stmt)
|
|||||||
elog(ERROR, "cache lookup failed for collation %u", collOid);
|
elog(ERROR, "cache lookup failed for collation %u", collOid);
|
||||||
|
|
||||||
collForm = (Form_pg_collation) GETSTRUCT(tup);
|
collForm = (Form_pg_collation) GETSTRUCT(tup);
|
||||||
collversion = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion,
|
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collversion, &isnull);
|
||||||
&isnull);
|
oldversion = isnull ? NULL : TextDatumGetCString(datum);
|
||||||
oldversion = isnull ? NULL : TextDatumGetCString(collversion);
|
|
||||||
|
|
||||||
newversion = get_collation_actual_version(collForm->collprovider, NameStr(collForm->collcollate));
|
datum = SysCacheGetAttr(COLLOID, tup, Anum_pg_collation_collcollate, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
newversion = get_collation_actual_version(collForm->collprovider, TextDatumGetCString(datum));
|
||||||
|
|
||||||
/* cannot change from NULL to non-NULL or vice versa */
|
/* cannot change from NULL to non-NULL or vice versa */
|
||||||
if ((!oldversion && newversion) || (oldversion && !newversion))
|
if ((!oldversion && newversion) || (oldversion && !newversion))
|
||||||
@ -383,8 +396,9 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
Oid collid = PG_GETARG_OID(0);
|
Oid collid = PG_GETARG_OID(0);
|
||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
char *collcollate;
|
|
||||||
char collprovider;
|
char collprovider;
|
||||||
|
Datum datum;
|
||||||
|
bool isnull;
|
||||||
char *version;
|
char *version;
|
||||||
|
|
||||||
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
||||||
@ -393,12 +407,13 @@ pg_collation_actual_version(PG_FUNCTION_ARGS)
|
|||||||
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
(errcode(ERRCODE_UNDEFINED_OBJECT),
|
||||||
errmsg("collation with OID %u does not exist", collid)));
|
errmsg("collation with OID %u does not exist", collid)));
|
||||||
|
|
||||||
collcollate = pstrdup(NameStr(((Form_pg_collation) GETSTRUCT(tp))->collcollate));
|
|
||||||
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
collprovider = ((Form_pg_collation) GETSTRUCT(tp))->collprovider;
|
||||||
|
|
||||||
ReleaseSysCache(tp);
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
version = get_collation_actual_version(collprovider, TextDatumGetCString(datum));
|
||||||
|
|
||||||
version = get_collation_actual_version(collprovider, collcollate);
|
ReleaseSysCache(tp);
|
||||||
|
|
||||||
if (version)
|
if (version)
|
||||||
PG_RETURN_TEXT_P(cstring_to_text(version));
|
PG_RETURN_TEXT_P(cstring_to_text(version));
|
||||||
@ -546,7 +561,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
|||||||
#ifdef READ_LOCALE_A_OUTPUT
|
#ifdef READ_LOCALE_A_OUTPUT
|
||||||
{
|
{
|
||||||
FILE *locale_a_handle;
|
FILE *locale_a_handle;
|
||||||
char localebuf[NAMEDATALEN]; /* we assume ASCII so this is fine */
|
char localebuf[LOCALE_NAME_BUFLEN];
|
||||||
int nvalid = 0;
|
int nvalid = 0;
|
||||||
Oid collid;
|
Oid collid;
|
||||||
CollAliasData *aliases;
|
CollAliasData *aliases;
|
||||||
@ -570,7 +585,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
|
|||||||
{
|
{
|
||||||
size_t len;
|
size_t len;
|
||||||
int enc;
|
int enc;
|
||||||
char alias[NAMEDATALEN];
|
char alias[LOCALE_NAME_BUFLEN];
|
||||||
|
|
||||||
len = strlen(localebuf);
|
len = strlen(localebuf);
|
||||||
|
|
||||||
|
@ -570,10 +570,8 @@ createdb(ParseState *pstate, const CreatedbStmt *stmt)
|
|||||||
DirectFunctionCall1(namein, CStringGetDatum(dbname));
|
DirectFunctionCall1(namein, CStringGetDatum(dbname));
|
||||||
new_record[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(datdba);
|
new_record[Anum_pg_database_datdba - 1] = ObjectIdGetDatum(datdba);
|
||||||
new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
|
new_record[Anum_pg_database_encoding - 1] = Int32GetDatum(encoding);
|
||||||
new_record[Anum_pg_database_datcollate - 1] =
|
new_record[Anum_pg_database_datcollate - 1] = CStringGetTextDatum(dbcollate);
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(dbcollate));
|
new_record[Anum_pg_database_datctype - 1] = CStringGetTextDatum(dbctype);
|
||||||
new_record[Anum_pg_database_datctype - 1] =
|
|
||||||
DirectFunctionCall1(namein, CStringGetDatum(dbctype));
|
|
||||||
new_record[Anum_pg_database_datistemplate - 1] = BoolGetDatum(dbistemplate);
|
new_record[Anum_pg_database_datistemplate - 1] = BoolGetDatum(dbistemplate);
|
||||||
new_record[Anum_pg_database_datallowconn - 1] = BoolGetDatum(dballowconnections);
|
new_record[Anum_pg_database_datallowconn - 1] = BoolGetDatum(dballowconnections);
|
||||||
new_record[Anum_pg_database_datconnlimit - 1] = Int32GetDatum(dbconnlimit);
|
new_record[Anum_pg_database_datconnlimit - 1] = Int32GetDatum(dbconnlimit);
|
||||||
@ -1867,6 +1865,9 @@ get_db_info(const char *name, LOCKMODE lockmode,
|
|||||||
|
|
||||||
if (strcmp(name, NameStr(dbform->datname)) == 0)
|
if (strcmp(name, NameStr(dbform->datname)) == 0)
|
||||||
{
|
{
|
||||||
|
Datum datum;
|
||||||
|
bool isnull;
|
||||||
|
|
||||||
/* oid of the database */
|
/* oid of the database */
|
||||||
if (dbIdP)
|
if (dbIdP)
|
||||||
*dbIdP = dbOid;
|
*dbIdP = dbOid;
|
||||||
@ -1893,9 +1894,17 @@ get_db_info(const char *name, LOCKMODE lockmode,
|
|||||||
*dbTablespace = dbform->dattablespace;
|
*dbTablespace = dbform->dattablespace;
|
||||||
/* default locale settings for this database */
|
/* default locale settings for this database */
|
||||||
if (dbCollate)
|
if (dbCollate)
|
||||||
*dbCollate = pstrdup(NameStr(dbform->datcollate));
|
{
|
||||||
|
datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datcollate, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
*dbCollate = TextDatumGetCString(datum);
|
||||||
|
}
|
||||||
if (dbCtype)
|
if (dbCtype)
|
||||||
*dbCtype = pstrdup(NameStr(dbform->datctype));
|
{
|
||||||
|
datum = SysCacheGetAttr(DATABASEOID, tuple, Anum_pg_database_datctype, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
*dbCtype = TextDatumGetCString(datum);
|
||||||
|
}
|
||||||
ReleaseSysCache(tuple);
|
ReleaseSysCache(tuple);
|
||||||
result = true;
|
result = true;
|
||||||
break;
|
break;
|
||||||
|
@ -179,7 +179,7 @@ pg_perm_setlocale(int category, const char *locale)
|
|||||||
*/
|
*/
|
||||||
if (category == LC_CTYPE)
|
if (category == LC_CTYPE)
|
||||||
{
|
{
|
||||||
static char save_lc_ctype[NAMEDATALEN + 20];
|
static char save_lc_ctype[LOCALE_NAME_BUFLEN];
|
||||||
|
|
||||||
/* copy setlocale() return value before callee invokes it again */
|
/* copy setlocale() return value before callee invokes it again */
|
||||||
strlcpy(save_lc_ctype, result, sizeof(save_lc_ctype));
|
strlcpy(save_lc_ctype, result, sizeof(save_lc_ctype));
|
||||||
@ -1288,17 +1288,21 @@ lookup_collation_cache(Oid collation, bool set_flags)
|
|||||||
{
|
{
|
||||||
/* Attempt to set the flags */
|
/* Attempt to set the flags */
|
||||||
HeapTuple tp;
|
HeapTuple tp;
|
||||||
Form_pg_collation collform;
|
Datum datum;
|
||||||
|
bool isnull;
|
||||||
const char *collcollate;
|
const char *collcollate;
|
||||||
const char *collctype;
|
const char *collctype;
|
||||||
|
|
||||||
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
|
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collation));
|
||||||
if (!HeapTupleIsValid(tp))
|
if (!HeapTupleIsValid(tp))
|
||||||
elog(ERROR, "cache lookup failed for collation %u", collation);
|
elog(ERROR, "cache lookup failed for collation %u", collation);
|
||||||
collform = (Form_pg_collation) GETSTRUCT(tp);
|
|
||||||
|
|
||||||
collcollate = NameStr(collform->collcollate);
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
|
||||||
collctype = NameStr(collform->collctype);
|
Assert(!isnull);
|
||||||
|
collcollate = TextDatumGetCString(datum);
|
||||||
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collctype, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
collctype = TextDatumGetCString(datum);
|
||||||
|
|
||||||
cache_entry->collate_is_c = ((strcmp(collcollate, "C") == 0) ||
|
cache_entry->collate_is_c = ((strcmp(collcollate, "C") == 0) ||
|
||||||
(strcmp(collcollate, "POSIX") == 0));
|
(strcmp(collcollate, "POSIX") == 0));
|
||||||
@ -1484,7 +1488,7 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
const char *collctype pg_attribute_unused();
|
const char *collctype pg_attribute_unused();
|
||||||
struct pg_locale_struct result;
|
struct pg_locale_struct result;
|
||||||
pg_locale_t resultp;
|
pg_locale_t resultp;
|
||||||
Datum collversion;
|
Datum datum;
|
||||||
bool isnull;
|
bool isnull;
|
||||||
|
|
||||||
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
tp = SearchSysCache1(COLLOID, ObjectIdGetDatum(collid));
|
||||||
@ -1492,8 +1496,12 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
elog(ERROR, "cache lookup failed for collation %u", collid);
|
elog(ERROR, "cache lookup failed for collation %u", collid);
|
||||||
collform = (Form_pg_collation) GETSTRUCT(tp);
|
collform = (Form_pg_collation) GETSTRUCT(tp);
|
||||||
|
|
||||||
collcollate = NameStr(collform->collcollate);
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collcollate, &isnull);
|
||||||
collctype = NameStr(collform->collctype);
|
Assert(!isnull);
|
||||||
|
collcollate = TextDatumGetCString(datum);
|
||||||
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collctype, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
collctype = TextDatumGetCString(datum);
|
||||||
|
|
||||||
/* We'll fill in the result struct locally before allocating memory */
|
/* We'll fill in the result struct locally before allocating memory */
|
||||||
memset(&result, 0, sizeof(result));
|
memset(&result, 0, sizeof(result));
|
||||||
@ -1587,13 +1595,15 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
#endif /* not USE_ICU */
|
#endif /* not USE_ICU */
|
||||||
}
|
}
|
||||||
|
|
||||||
collversion = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collversion,
|
datum = SysCacheGetAttr(COLLOID, tp, Anum_pg_collation_collversion,
|
||||||
&isnull);
|
&isnull);
|
||||||
if (!isnull)
|
if (!isnull)
|
||||||
{
|
{
|
||||||
char *actual_versionstr;
|
char *actual_versionstr;
|
||||||
char *collversionstr;
|
char *collversionstr;
|
||||||
|
|
||||||
|
collversionstr = TextDatumGetCString(datum);
|
||||||
|
|
||||||
actual_versionstr = get_collation_actual_version(collform->collprovider, collcollate);
|
actual_versionstr = get_collation_actual_version(collform->collprovider, collcollate);
|
||||||
if (!actual_versionstr)
|
if (!actual_versionstr)
|
||||||
{
|
{
|
||||||
@ -1606,7 +1616,6 @@ pg_newlocale_from_collation(Oid collid)
|
|||||||
(errmsg("collation \"%s\" has no actual version, but a version was specified",
|
(errmsg("collation \"%s\" has no actual version, but a version was specified",
|
||||||
NameStr(collform->collname))));
|
NameStr(collform->collname))));
|
||||||
}
|
}
|
||||||
collversionstr = TextDatumGetCString(collversion);
|
|
||||||
|
|
||||||
if (strcmp(actual_versionstr, collversionstr) != 0)
|
if (strcmp(actual_versionstr, collversionstr) != 0)
|
||||||
ereport(WARNING,
|
ereport(WARNING,
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#include "storage/sync.h"
|
#include "storage/sync.h"
|
||||||
#include "tcop/tcopprot.h"
|
#include "tcop/tcopprot.h"
|
||||||
#include "utils/acl.h"
|
#include "utils/acl.h"
|
||||||
|
#include "utils/builtins.h"
|
||||||
#include "utils/fmgroids.h"
|
#include "utils/fmgroids.h"
|
||||||
#include "utils/guc.h"
|
#include "utils/guc.h"
|
||||||
#include "utils/memutils.h"
|
#include "utils/memutils.h"
|
||||||
@ -306,6 +307,8 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
|
|||||||
{
|
{
|
||||||
HeapTuple tup;
|
HeapTuple tup;
|
||||||
Form_pg_database dbform;
|
Form_pg_database dbform;
|
||||||
|
Datum datum;
|
||||||
|
bool isnull;
|
||||||
char *collate;
|
char *collate;
|
||||||
char *ctype;
|
char *ctype;
|
||||||
|
|
||||||
@ -389,8 +392,12 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
|
|||||||
PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT);
|
PGC_BACKEND, PGC_S_DYNAMIC_DEFAULT);
|
||||||
|
|
||||||
/* assign locale variables */
|
/* assign locale variables */
|
||||||
collate = NameStr(dbform->datcollate);
|
datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_datcollate, &isnull);
|
||||||
ctype = NameStr(dbform->datctype);
|
Assert(!isnull);
|
||||||
|
collate = TextDatumGetCString(datum);
|
||||||
|
datum = SysCacheGetAttr(DATABASEOID, tup, Anum_pg_database_datctype, &isnull);
|
||||||
|
Assert(!isnull);
|
||||||
|
ctype = TextDatumGetCString(datum);
|
||||||
|
|
||||||
if (pg_perm_setlocale(LC_COLLATE, collate) == NULL)
|
if (pg_perm_setlocale(LC_COLLATE, collate) == NULL)
|
||||||
ereport(FATAL,
|
ereport(FATAL,
|
||||||
|
@ -53,6 +53,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
/* yyyymmddN */
|
/* yyyymmddN */
|
||||||
#define CATALOG_VERSION_NO 202201201
|
#define CATALOG_VERSION_NO 202201271
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -39,9 +39,9 @@ CATALOG(pg_collation,3456,CollationRelationId)
|
|||||||
char collprovider; /* see constants below */
|
char collprovider; /* see constants below */
|
||||||
bool collisdeterministic BKI_DEFAULT(t);
|
bool collisdeterministic BKI_DEFAULT(t);
|
||||||
int32 collencoding; /* encoding for this collation; -1 = "all" */
|
int32 collencoding; /* encoding for this collation; -1 = "all" */
|
||||||
NameData collcollate; /* LC_COLLATE setting */
|
|
||||||
NameData collctype; /* LC_CTYPE setting */
|
|
||||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
||||||
|
text collcollate BKI_FORCE_NOT_NULL; /* LC_COLLATE setting */
|
||||||
|
text collctype BKI_FORCE_NOT_NULL; /* LC_CTYPE setting */
|
||||||
text collversion BKI_DEFAULT(_null_); /* provider-dependent
|
text collversion BKI_DEFAULT(_null_); /* provider-dependent
|
||||||
* version of collation
|
* version of collation
|
||||||
* data */
|
* data */
|
||||||
|
@ -40,12 +40,6 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
|
|||||||
/* character encoding */
|
/* character encoding */
|
||||||
int32 encoding;
|
int32 encoding;
|
||||||
|
|
||||||
/* LC_COLLATE setting */
|
|
||||||
NameData datcollate;
|
|
||||||
|
|
||||||
/* LC_CTYPE setting */
|
|
||||||
NameData datctype;
|
|
||||||
|
|
||||||
/* allowed as CREATE DATABASE template? */
|
/* allowed as CREATE DATABASE template? */
|
||||||
bool datistemplate;
|
bool datistemplate;
|
||||||
|
|
||||||
@ -65,6 +59,12 @@ CATALOG(pg_database,1262,DatabaseRelationId) BKI_SHARED_RELATION BKI_ROWTYPE_OID
|
|||||||
Oid dattablespace BKI_LOOKUP(pg_tablespace);
|
Oid dattablespace BKI_LOOKUP(pg_tablespace);
|
||||||
|
|
||||||
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
#ifdef CATALOG_VARLEN /* variable-length fields start here */
|
||||||
|
/* LC_COLLATE setting */
|
||||||
|
text datcollate BKI_FORCE_NOT_NULL;
|
||||||
|
|
||||||
|
/* LC_CTYPE setting */
|
||||||
|
text datctype BKI_FORCE_NOT_NULL;
|
||||||
|
|
||||||
/* access permissions */
|
/* access permissions */
|
||||||
aclitem datacl[1];
|
aclitem datacl[1];
|
||||||
#endif
|
#endif
|
||||||
|
@ -34,6 +34,8 @@
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
/* use for libc locale names */
|
||||||
|
#define LOCALE_NAME_BUFLEN 128
|
||||||
|
|
||||||
/* GUC settings */
|
/* GUC settings */
|
||||||
extern char *locale_messages;
|
extern char *locale_messages;
|
||||||
|
Reference in New Issue
Block a user