]> granicus.if.org Git - postgresql/commitdiff
Remove ancient downcasing code from procedural language operations.
authorRobert Haas <rhaas@postgresql.org>
Thu, 17 Nov 2011 19:20:13 +0000 (14:20 -0500)
committerRobert Haas <rhaas@postgresql.org>
Thu, 17 Nov 2011 19:25:18 +0000 (14:25 -0500)
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.

doc/src/sgml/ref/create_language.sgml
src/backend/commands/define.c
src/backend/commands/functioncmds.c
src/backend/commands/proclang.c
src/include/commands/defrem.h

index 6e72892375b5f8aa9d99806188afc8c24552a6ae..0995b13623cae3e0308f672adb82f239bd5149a5 100644 (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>
index eda3b7a9cee9ca9917c4c431c6f1d009fc2c97e1..9dcc581c98544060b76ec3be901da60bad8b88b3 100644 (file)
 #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.
  */
index 92abd44a600e4c8e034f6c9a9081309f61ef32f4..c4746618ae5525318717675283d0a1942fa329d9 100644 (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);
index 98770c5a61afc3b6d474feea50ed0ef947156a24..7a37e96c402cce64091e00e241a14840027a00b4 100644 (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));
index 64eeb736701f2cd521fc86f7ba9977edd12ac4bb..a466e2edb05493f7b175490a2a0a48229644ac6b 100644 (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);