Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit 530acda

Browse files
committed
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.
1 parent 5c7603c commit 530acda

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/backend/commands/extension.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1394,12 +1394,16 @@ CreateExtension(CreateExtensionStmt *stmt)
13941394
*/
13951395
List *search_path = fetch_search_path(false);
13961396

1397-
if (search_path == NIL) /* probably can't happen */
1398-
elog(ERROR, "there is no default creation target");
1397+
if (search_path == NIL) /* nothing valid in search_path? */
1398+
ereport(ERROR,
1399+
(errcode(ERRCODE_UNDEFINED_SCHEMA),
1400+
errmsg("no schema has been selected to create in")));
13991401
schemaOid = linitial_oid(search_path);
14001402
schemaName = get_namespace_name(schemaOid);
14011403
if (schemaName == NULL) /* recently-deleted namespace? */
1402-
elog(ERROR, "there is no default creation target");
1404+
ereport(ERROR,
1405+
(errcode(ERRCODE_UNDEFINED_SCHEMA),
1406+
errmsg("no schema has been selected to create in")));
14031407

14041408
list_free(search_path);
14051409
}

0 commit comments

Comments
 (0)