diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2013-06-04 17:22:29 -0400 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2013-06-04 17:22:43 -0400 |
commit | 2ff74efa40adac394f11070af8d2ee8c79ba96c0 (patch) | |
tree | e22d81b43f61e594b999ed23f64d4f6f1fb62f98 /src | |
parent | 612ecf311bf253cdb0c54252854c5298aa668203 (diff) |
Provide better message when CREATE EXTENSION can't find a target schema.
The new message (and SQLSTATE) matches the corresponding error cases in
namespace.c.
This was thought to be a "can't happen" case when extension.c was written,
so we didn't think hard about how to report it. But it definitely can
happen in 9.2 and later, since we no longer require search_path to contain
any valid schema names. It's probably also possible in 9.1 if search_path
came from a noninteractive source. So, back-patch to all releases
containing this code.
Per report from Sean Chittenden, though this isn't exactly his patch.
Diffstat (limited to 'src')
-rw-r--r-- | src/backend/commands/extension.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c index 23c9d66f194..1fd132fee52 100644 --- a/src/backend/commands/extension.c +++ b/src/backend/commands/extension.c @@ -1391,12 +1391,16 @@ CreateExtension(CreateExtensionStmt *stmt) */ List *search_path = fetch_search_path(false); - if (search_path == NIL) /* probably can't happen */ - elog(ERROR, "there is no default creation target"); + if (search_path == NIL) /* nothing valid in search_path? */ + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_SCHEMA), + errmsg("no schema has been selected to create in"))); schemaOid = linitial_oid(search_path); schemaName = get_namespace_name(schemaOid); if (schemaName == NULL) /* recently-deleted namespace? */ - elog(ERROR, "there is no default creation target"); + ereport(ERROR, + (errcode(ERRCODE_UNDEFINED_SCHEMA), + errmsg("no schema has been selected to create in"))); list_free(search_path); } |