diff options
Diffstat (limited to 'src/backend/catalog/pg_collation.c')
-rw-r--r-- | src/backend/catalog/pg_collation.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/src/backend/catalog/pg_collation.c b/src/backend/catalog/pg_collation.c index 6b1b72f245b..ca62896ecbb 100644 --- a/src/backend/catalog/pg_collation.c +++ b/src/backend/catalog/pg_collation.c @@ -37,6 +37,11 @@ * CollationCreate * * Add a new tuple to pg_collation. + * + * if_not_exists: if true, don't fail on duplicate name, just print a notice + * and return InvalidOid. + * quiet: if true, don't fail on duplicate name, just silently return + * InvalidOid (overrides if_not_exists). */ Oid CollationCreate(const char *collname, Oid collnamespace, @@ -45,7 +50,8 @@ CollationCreate(const char *collname, Oid collnamespace, int32 collencoding, const char *collcollate, const char *collctype, const char *collversion, - bool if_not_exists) + bool if_not_exists, + bool quiet) { Relation rel; TupleDesc tupDesc; @@ -77,7 +83,9 @@ CollationCreate(const char *collname, Oid collnamespace, Int32GetDatum(collencoding), ObjectIdGetDatum(collnamespace))) { - if (if_not_exists) + if (quiet) + return InvalidOid; + else if (if_not_exists) { ereport(NOTICE, (errcode(ERRCODE_DUPLICATE_OBJECT), @@ -119,7 +127,12 @@ CollationCreate(const char *collname, Oid collnamespace, Int32GetDatum(-1), ObjectIdGetDatum(collnamespace)))) { - if (if_not_exists) + if (quiet) + { + heap_close(rel, NoLock); + return InvalidOid; + } + else if (if_not_exists) { heap_close(rel, NoLock); ereport(NOTICE, |