Improved error message for CREATE EXTENSION patch...
I ran in to the following situation:
SET search_path = ENOENT, also_does_not_exist;
CREATE EXTENSION pg_repack;
ERROR: XX000: there is no default creation target
LOCATION: CreateExtension, extension.c:1395
Which left me checking out the source code to figure out exactly what the problem was. Attached is an improved error message:
"ERROR: XX000: no schemas in search_path are available for CREATE EXTENSION"
-sc
Attachments:
src-backend-commands-extension.c.patchapplication/octet-stream; name=src-backend-commands-extension.c.patchDownload
diff --git a/src/backend/commands/extension.c b/src/backend/commands/extension.c
index 2d84ac8..f04db3d 100644
--- a/src/backend/commands/extension.c
+++ b/src/backend/commands/extension.c
@@ -1394,12 +1394,12 @@ 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) /* none of the schemas in search_path exist/writable? */
+ elog(ERROR, "no schemas in search_path are available for CREATE EXTENSION");
schemaOid = linitial_oid(search_path);
schemaName = get_namespace_name(schemaOid);
if (schemaName == NULL) /* recently-deleted namespace? */
- elog(ERROR, "there is no default creation target");
+ elog(ERROR, "no schemas in search_path are available for CREATE EXTENSION");
list_free(search_path);
}
Sean Chittenden <sean@chittenden.org> writes:
I ran in to the following situation:
SET search_path = ENOENT, also_does_not_exist;
CREATE EXTENSION pg_repack;
ERROR: XX000: there is no default creation target
LOCATION: CreateExtension, extension.c:1395
Which left me checking out the source code to figure out exactly what the problem was. Attached is an improved error message:
"ERROR: XX000: no schemas in search_path are available for CREATE EXTENSION"
Hm, I'm not sure that's much better than the existing wording. The
bigger point here though is that if we consider this to be a user-facing
error case, it ought to be ereport not elog.
I checked what you get for the normal non-extension case:
regression=# set search_path = bogus;
SET
regression=# create table t1 (f1 int);
ERROR: no schema has been selected to create in
regression=# \set VERBOSITY verbose
regression=# create table t1 (f1 int);
ERROR: 3F000: no schema has been selected to create in
LOCATION: RangeVarGetCreationNamespace, namespace.c:485
Seems like we ought to use the same message (and SQLSTATE) as in
namespace.c, since nobody's complained about that one.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
"ERROR: XX000: no schemas in search_path are available for CREATE EXTENSION"
Hm, I'm not sure that's much better than the existing wording. The
bigger point here though is that if we consider this to be a user-facing
error case, it ought to be ereport not elog.I checked what you get for the normal non-extension case:
regression=# set search_path = bogus;
SET
regression=# create table t1 (f1 int);
ERROR: no schema has been selected to create in
regression=# \set VERBOSITY verbose
regression=# create table t1 (f1 int);
ERROR: 3F000: no schema has been selected to create in
LOCATION: RangeVarGetCreationNamespace, namespace.c:485Seems like we ought to use the same message (and SQLSTATE) as in
namespace.c, since nobody's complained about that one.
Sounds good to me and is clear enough that it would unblock me w/o having to resort to the source tree. -sc
--
Sean Chittenden
sean@chittenden.org
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers
Sean Chittenden <sean@chittenden.org> writes:
Seems like we ought to use the same message (and SQLSTATE) as in
namespace.c, since nobody's complained about that one.
Sounds good to me and is clear enough that it would unblock me w/o having to resort to the source tree. -sc
OK, done that way.
regards, tom lane
--
Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers