skip-create-lang-dupe.patch
application/octet-stream
Filename: skip-create-lang-dupe.patch
Type: application/octet-stream
Part: 0
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: unified
| File | + | − |
|---|---|---|
| src/backend/commands/proclang.c | 0 | 0 |
diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c
index 9e80fd9..7823b6a 100644
*** a/src/backend/commands/proclang.c
--- b/src/backend/commands/proclang.c
*************** CreateProceduralLanguage(CreatePLangStmt
*** 71,87 ****
valOid;
Oid funcrettype;
Oid funcargtypes[1];
/*
! * Translate the language name and check that this language doesn't
! * already exist
*/
languageName = case_translate_language_name(stmt->plname);
! if (SearchSysCacheExists1(LANGNAME, PointerGetDatum(languageName)))
! ereport(ERROR,
! (errcode(ERRCODE_DUPLICATE_OBJECT),
! errmsg("language \"%s\" already exists", languageName)));
/*
* If we have template information for the language, ignore the supplied
--- 71,85 ----
valOid;
Oid funcrettype;
Oid funcargtypes[1];
+ bool langExists;
/*
! * Translate the language name and see if this language already
! * exists
*/
languageName = case_translate_language_name(stmt->plname);
! langExists = SearchSysCacheExists1(LANGNAME, PointerGetDatum(languageName));
/*
* If we have template information for the language, ignore the supplied
*************** CreateProceduralLanguage(CreatePLangStmt
*** 92,97 ****
--- 90,105 ----
List *funcname;
/*
+ * Check if language already exists; if it did, since this is
+ * a template language, issue a NOTICE instead of an ERROR.
+ */
+ if (langExists) {
+ ereport(NOTICE,
+ (errmsg("skipping identical CREATE LANGUAGE definition")));
+ return;
+ }
+
+ /*
* Give a notice if we are ignoring supplied parameters.
*/
if (stmt->plhandler)
*************** CreateProceduralLanguage(CreatePLangStmt
*** 237,242 ****
--- 245,258 ----
}
else
{
+ /* No template, and the language already existed, so we'll bail */
+
+ if (langExists)
+ ereport(ERROR,
+ (errcode(ERRCODE_DUPLICATE_OBJECT),
+ errmsg("language \"%s\" already exists", languageName)));
+
+
/*
* No template, so use the provided information. If there's no
* handler clause, the user is trying to rely on a template that we