mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Implement a solution to the 'Turkish locale downcases I incorrectly'
problem, per previous discussion. Make some additional changes to centralize the knowledge of just how identifier downcasing is done, in hopes of simplifying any future tweaking in this area.
This commit is contained in:
@@ -9,7 +9,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.85 2003/11/29 19:51:47 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/define.c,v 1.86 2004/02/21 00:34:52 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The "DefineFoo" routines take the parse tree and pick out the
|
||||
@@ -38,24 +38,19 @@
|
||||
#include "catalog/namespace.h"
|
||||
#include "commands/defrem.h"
|
||||
#include "parser/parse_type.h"
|
||||
#include "parser/scansup.h"
|
||||
#include "utils/int8.h"
|
||||
|
||||
|
||||
/*
|
||||
* Translate the input language name to lower case.
|
||||
* Translate the input language name to lower case, and truncate if needed.
|
||||
*
|
||||
* Output buffer must be NAMEDATALEN long.
|
||||
* Returns a palloc'd string
|
||||
*/
|
||||
void
|
||||
case_translate_language_name(const char *input, char *output)
|
||||
char *
|
||||
case_translate_language_name(const char *input)
|
||||
{
|
||||
int i;
|
||||
|
||||
MemSet(output, 0, NAMEDATALEN); /* ensure result Name is
|
||||
* zero-filled */
|
||||
|
||||
for (i = 0; i < NAMEDATALEN - 1 && input[i]; ++i)
|
||||
output[i] = tolower((unsigned char) input[i]);
|
||||
return downcase_truncate_identifier(input, strlen(input), false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.43 2004/01/06 23:55:18 tgl Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/functioncmds.c,v 1.44 2004/02/21 00:34:52 tgl Exp $
|
||||
*
|
||||
* DESCRIPTION
|
||||
* These routines take the parse tree and pick out the
|
||||
@@ -401,7 +401,7 @@ CreateFunction(CreateFunctionStmt *stmt)
|
||||
Oid prorettype;
|
||||
bool returnsSet;
|
||||
char *language;
|
||||
char languageName[NAMEDATALEN];
|
||||
char *languageName;
|
||||
Oid languageOid;
|
||||
Oid languageValidator;
|
||||
char *funcname;
|
||||
@@ -437,7 +437,7 @@ CreateFunction(CreateFunctionStmt *stmt)
|
||||
&as_clause, &language, &volatility, &isStrict, &security);
|
||||
|
||||
/* Convert language name to canonical case */
|
||||
case_translate_language_name(language, languageName);
|
||||
languageName = case_translate_language_name(language);
|
||||
|
||||
/* Look up the language and validate permissions */
|
||||
languageTuple = SearchSysCache(LANGNAME,
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.52 2003/11/29 19:51:47 pgsql Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/commands/proclang.c,v 1.53 2004/02/21 00:34:52 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@@ -40,11 +40,12 @@
|
||||
void
|
||||
CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
{
|
||||
char languageName[NAMEDATALEN];
|
||||
char *languageName;
|
||||
Oid procOid,
|
||||
valProcOid;
|
||||
Oid funcrettype;
|
||||
Oid typev[FUNC_MAX_ARGS];
|
||||
NameData langname;
|
||||
char nulls[Natts_pg_language];
|
||||
Datum values[Natts_pg_language];
|
||||
Relation rel;
|
||||
@@ -66,7 +67,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
* Translate the language name and check that this language doesn't
|
||||
* already exist
|
||||
*/
|
||||
case_translate_language_name(stmt->plname, languageName);
|
||||
languageName = case_translate_language_name(stmt->plname);
|
||||
|
||||
if (SearchSysCacheExists(LANGNAME,
|
||||
PointerGetDatum(languageName),
|
||||
@@ -124,12 +125,13 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
}
|
||||
|
||||
i = 0;
|
||||
values[i++] = PointerGetDatum(languageName);
|
||||
values[i++] = BoolGetDatum(true); /* lanispl */
|
||||
values[i++] = BoolGetDatum(stmt->pltrusted);
|
||||
values[i++] = ObjectIdGetDatum(procOid);
|
||||
values[i++] = ObjectIdGetDatum(valProcOid);
|
||||
nulls[i] = 'n'; /* lanacl */
|
||||
namestrcpy(&langname, languageName);
|
||||
values[i++] = NameGetDatum(&langname); /* lanname */
|
||||
values[i++] = BoolGetDatum(true); /* lanispl */
|
||||
values[i++] = BoolGetDatum(stmt->pltrusted); /* lanpltrusted */
|
||||
values[i++] = ObjectIdGetDatum(procOid); /* lanplcallfoid */
|
||||
values[i++] = ObjectIdGetDatum(valProcOid); /* lanvalidator */
|
||||
nulls[i] = 'n'; /* lanacl */
|
||||
|
||||
rel = heap_openr(LanguageRelationName, RowExclusiveLock);
|
||||
|
||||
@@ -173,7 +175,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
|
||||
void
|
||||
DropProceduralLanguage(DropPLangStmt *stmt)
|
||||
{
|
||||
char languageName[NAMEDATALEN];
|
||||
char *languageName;
|
||||
HeapTuple langTup;
|
||||
ObjectAddress object;
|
||||
|
||||
@@ -189,7 +191,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
|
||||
* Translate the language name, check that this language exist and is
|
||||
* a PL
|
||||
*/
|
||||
case_translate_language_name(stmt->plname, languageName);
|
||||
languageName = case_translate_language_name(stmt->plname);
|
||||
|
||||
langTup = SearchSysCache(LANGNAME,
|
||||
CStringGetDatum(languageName),
|
||||
|
||||
Reference in New Issue
Block a user