Remove ancient downcasing code from procedural language operations.

A very long time ago, language names were specified as literals rather
than identifiers, so this code was added to do case-folding.  But that
style has ben deprecated for many years so this isn't needed any more.
Language names will still be downcased when specified as unquoted
identifiers, but quoted identifiers or the old style using string
literals will be left as-is.
This commit is contained in:
Robert Haas 2011-11-17 14:20:13 -05:00
parent ee3ef8f30c
commit 67dc4eed42
5 changed files with 17 additions and 60 deletions

View File

@ -143,9 +143,8 @@ CREATE [ OR REPLACE ] [ TRUSTED ] [ PROCEDURAL ] LANGUAGE <replaceable class="pa
<listitem>
<para>
The name of the new procedural language. The language name is
case insensitive. The name must be unique among the languages
in the database.
The name of the new procedural language.
The name must be unique among the languages in the database.
</para>
<para>

View File

@ -42,19 +42,6 @@
#include "parser/scansup.h"
#include "utils/int8.h"
/*
* Translate the input language name to lower case, and truncate if needed.
*
* Returns a palloc'd string
*/
char *
case_translate_language_name(const char *input)
{
return downcase_truncate_identifier(input, strlen(input), false);
}
/*
* Extract a string value (otherwise uninterpreted) from a DefElem.
*/

View File

@ -779,7 +779,6 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
Oid prorettype;
bool returnsSet;
char *language;
char *languageName;
Oid languageOid;
Oid languageValidator;
char *funcname;
@ -828,16 +827,13 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
&isStrict, &security,
&proconfig, &procost, &prorows);
/* Convert language name to canonical case */
languageName = case_translate_language_name(language);
/* Look up the language and validate permissions */
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(languageName));
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(language));
if (!HeapTupleIsValid(languageTuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language \"%s\" does not exist", languageName),
(PLTemplateExists(languageName) ?
errmsg("language \"%s\" does not exist", language),
(PLTemplateExists(language) ?
errhint("Use CREATE LANGUAGE to load the language into the database.") : 0)));
languageOid = HeapTupleGetOid(languageTuple);
@ -906,7 +902,7 @@ CreateFunction(CreateFunctionStmt *stmt, const char *queryString)
compute_attributes_with_style(stmt->withClause, &isStrict, &volatility);
interpret_AS_clause(languageOid, languageName, funcname, as_clause,
interpret_AS_clause(languageOid, language, funcname, as_clause,
&prosrc_str, &probin_str);
/*
@ -1964,7 +1960,6 @@ ExecuteDoStmt(DoStmt *stmt)
DefElem *as_item = NULL;
DefElem *language_item = NULL;
char *language;
char *languageName;
Oid laninline;
HeapTuple languageTuple;
Form_pg_language languageStruct;
@ -2008,16 +2003,13 @@ ExecuteDoStmt(DoStmt *stmt)
else
language = "plpgsql";
/* Convert language name to canonical case */
languageName = case_translate_language_name(language);
/* Look up the language and validate permissions */
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(languageName));
languageTuple = SearchSysCache1(LANGNAME, PointerGetDatum(language));
if (!HeapTupleIsValid(languageTuple))
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("language \"%s\" does not exist", languageName),
(PLTemplateExists(languageName) ?
errmsg("language \"%s\" does not exist", language),
(PLTemplateExists(language) ?
errhint("Use CREATE LANGUAGE to load the language into the database.") : 0)));
codeblock->langOid = HeapTupleGetOid(languageTuple);

View File

@ -64,7 +64,6 @@ static void AlterLanguageOwner_internal(HeapTuple tup, Relation rel,
void
CreateProceduralLanguage(CreatePLangStmt *stmt)
{
char *languageName;
PLTemplate *pltemplate;
Oid handlerOid,
inlineOid,
@ -72,16 +71,11 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
Oid funcrettype;
Oid funcargtypes[1];
/*
* Translate the language name to lower case
*/
languageName = case_translate_language_name(stmt->plname);
/*
* If we have template information for the language, ignore the supplied
* parameters (if any) and use the template information.
*/
if ((pltemplate = find_language_template(languageName)) != NULL)
if ((pltemplate = find_language_template(stmt->plname)) != NULL)
{
List *funcname;
@ -101,7 +95,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_INSUFFICIENT_PRIVILEGE),
errmsg("must be superuser to create procedural language \"%s\"",
languageName)));
stmt->plname)));
if (!pg_database_ownercheck(MyDatabaseId, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_DATABASE,
get_database_name(MyDatabaseId));
@ -226,7 +220,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
valOid = InvalidOid;
/* ok, create it */
create_proc_lang(languageName, stmt->replace, GetUserId(),
create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
handlerOid, inlineOid,
valOid, pltemplate->tmpltrusted);
}
@ -241,7 +235,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
ereport(ERROR,
(errcode(ERRCODE_UNDEFINED_OBJECT),
errmsg("unsupported language \"%s\"",
languageName),
stmt->plname),
errhint("The supported languages are listed in the pg_pltemplate system catalog.")));
/*
@ -301,7 +295,7 @@ CreateProceduralLanguage(CreatePLangStmt *stmt)
valOid = InvalidOid;
/* ok, create it */
create_proc_lang(languageName, stmt->replace, GetUserId(),
create_proc_lang(stmt->plname, stmt->replace, GetUserId(),
handlerOid, inlineOid,
valOid, stmt->pltrusted);
}
@ -521,21 +515,15 @@ PLTemplateExists(const char *languageName)
void
DropProceduralLanguage(DropPLangStmt *stmt)
{
char *languageName;
Oid oid;
ObjectAddress object;
/*
* Translate the language name, check that the language exists
*/
languageName = case_translate_language_name(stmt->plname);
oid = get_language_oid(languageName, stmt->missing_ok);
oid = get_language_oid(stmt->plname, stmt->missing_ok);
if (!OidIsValid(oid))
{
ereport(NOTICE,
(errmsg("language \"%s\" does not exist, skipping",
languageName)));
stmt->plname)));
return;
}
@ -544,7 +532,7 @@ DropProceduralLanguage(DropPLangStmt *stmt)
*/
if (!pg_language_ownercheck(oid, GetUserId()))
aclcheck_error(ACLCHECK_NOT_OWNER, ACL_KIND_LANGUAGE,
languageName);
stmt->plname);
object.classId = LanguageRelationId;
object.objectId = oid;
@ -587,10 +575,6 @@ RenameLanguage(const char *oldname, const char *newname)
HeapTuple tup;
Relation rel;
/* Translate both names for consistency with CREATE */
oldname = case_translate_language_name(oldname);
newname = case_translate_language_name(newname);
rel = heap_open(LanguageRelationId, RowExclusiveLock);
tup = SearchSysCacheCopy1(LANGNAME, CStringGetDatum(oldname));
@ -628,9 +612,6 @@ AlterLanguageOwner(const char *name, Oid newOwnerId)
HeapTuple tup;
Relation rel;
/* Translate name for consistency with CREATE */
name = case_translate_language_name(name);
rel = heap_open(LanguageRelationId, RowExclusiveLock);
tup = SearchSysCache1(LANGNAME, CStringGetDatum(name));

View File

@ -174,8 +174,6 @@ extern Datum transformGenericOptions(Oid catalogId,
/* support routines in commands/define.c */
extern char *case_translate_language_name(const char *input);
extern char *defGetString(DefElem *def);
extern double defGetNumeric(DefElem *def);
extern bool defGetBoolean(DefElem *def);