8000 Provide better message when CREATE EXTENSION can't find a target schema. · kosalalakshitha/postgres@2ff74ef · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ff74ef

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 612ecf3 commit 2ff74ef

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
@@ -1391,12 +1391,16 @@ CreateExtension(CreateExtensionStmt *stmt)
13911391
*/
13921392
List *search_path = fetch_search_path(false);
13931393

1394-
if (search_path == NIL) /* probably can't happen */
1395-
elog(ERROR, "there is no default creation target");
1394+
if (search_path == NIL) /* nothing valid in search_path? */
1395+
ereport(ERROR,
1396+
(errcode(ERRCODE_UNDEFINED_SCHEMA),
1397+
errmsg("no schema has been selected to create in")));
13961398
schemaOid = linitial_oid(search_path);
13971399
schemaName = get_namespace_name(schemaOid);
13981400
if (schemaName == NULL) /* recently-deleted namespace? */
1399-
elog(ERROR, "there is no default creation target");
1401+
ereport(ERROR,
1402+
(errcode(ERRCODE_UNDEFINED_SCHEMA),
1403+
errmsg("no schema has been selected to create in")));
14001404

14011405
list_free(search_path);
14021406
}

0 commit comments

Comments
 (0)
0