Skip to content

Commit

Permalink
Reword error msgs in loader
Browse files Browse the repository at this point in the history
  • Loading branch information
cevian authored and dschniepp committed Apr 26, 2018
1 parent b5f3025 commit bd4920c
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion src/extension.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ extension_check_version(const char *so_version)
{
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("Mismatched timescaledb version. Shared object file %s, SQL %s", so_version, sql_version)));
errmsg("extension \"%s\" version mismatch: shared library version %s; SQL version %s", EXTENSION_NAME, so_version, sql_version)));
}


Expand Down
8 changes: 4 additions & 4 deletions src/extension_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension_version(void)

if (sql_version == NULL)
{
elog(ERROR, "Extension not found when getting version");
elog(ERROR, "extension not found while getting version");
}
return sql_version;
}
Expand Down Expand Up @@ -136,7 +136,7 @@ extension_is_transitioning()
char *current_extension_name = get_extension_name(CurrentExtensionObject);

if (NULL == current_extension_name)
elog(ERROR, "Unknown current extension while creating");
elog(ERROR, "current extension name is missing");

if (strcmp(EXTENSION_NAME, current_extension_name) == 0)
return true;
Expand Down Expand Up @@ -200,7 +200,7 @@ extension_load_without_preload()
char *config_file = GetConfigOptionByName("config_file", NULL, false);

ereport(FATAL,
(errmsg("The timescaledb library is not preloaded"),
(errmsg("extension \"%s\" must be preloaded", EXTENSION_NAME),
errhint("Please preload the timescaledb library via shared_preload_libraries.\n\n"
"This can be done by editing the config file at: %1$s\n"
"and adding 'timescaledb' to the list in the shared_preload_libraries config.\n"
Expand All @@ -214,7 +214,7 @@ extension_load_without_preload()
else
{
ereport(FATAL,
(errmsg("The timescaledb library is not preloaded"),
(errmsg("extension \"%s\" must be preloaded", EXTENSION_NAME),
errhint("Please preload the timescaledb library via shared_preload_libraries.\n\n"
"This can be done by editing the postgres config file \n"
"and adding 'timescaledb' to the list in the shared_preload_libraries config.\n"
Expand Down
11 changes: 6 additions & 5 deletions src/loader/loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ should_load_on_alter_extension(Node *utility_stmt)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("extension \"%s\" cannot be updated after the old version has already been loaded", stmt->extname),
errhint("You should start a new session and execute ALTER EXTENSION as the first command")));

errhint("Start a new session and execute ALTER EXTENSION as the first command. "
"Make sure to pass the \"-X\" flag to psql.")));
/* do not load the current (old) version's .so */
return false;
}
Expand Down Expand Up @@ -159,9 +159,10 @@ should_load_on_create_extension(Node *utility_stmt)
/* disallow loading two .so from different versions */
ereport(ERROR,
(errcode(ERRCODE_DUPLICATE_OBJECT),
errmsg("the session already has another shared library loaded for extension \"%s\"", stmt->extname),
errdetail("The loaded version is \"%s\"", soversion),
errhint("You should start a new session and execute CREATE EXTENSION as the first command")));
errmsg("extension \"%s\" has already been loaded with another version", stmt->extname),
errdetail("The loaded version is \"%s\".", soversion),
errhint("Start a new session and execute CREATE EXTENSION as the first command. "
"Make sure to pass the \"-X\" flag to psql.")));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion test/expected/drop_extension.out
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ CREATE EXTENSION timescaledb;
-- Test that calling twice generates proper error
\set ON_ERROR_STOP 0
CREATE EXTENSION timescaledb;
ERROR: the session already has another shared library loaded for extension "timescaledb"
ERROR: extension "timescaledb" has already been loaded with another version
\set ON_ERROR_STOP 1
\c single :ROLE_DEFAULT_PERM_USER
-- CREATE twice with IF NOT EXISTS should be OK
Expand Down
10 changes: 5 additions & 5 deletions test/expected/loader.out
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ WARNING: mock post_analyze_hook "mock-1"
\set ON_ERROR_STOP 0
--test that we cannot accidentally load another library version
CREATE EXTENSION IF NOT EXISTS timescaledb VERSION 'mock-2';
ERROR: the session already has another shared library loaded for extension "timescaledb"
ERROR: extension "timescaledb" has already been loaded with another version
\set ON_ERROR_STOP 1
\c single :ROLE_SUPERUSER
--no extension
Expand Down Expand Up @@ -376,7 +376,7 @@ SELECT 1;
\set ON_ERROR_STOP 0
--mock-4 has mismatched versions, so the .so load should throw an error
CREATE EXTENSION timescaledb VERSION 'mock-4';
ERROR: Mismatched timescaledb version. Shared object file mock-4-mismatch, SQL mock-4
ERROR: extension "timescaledb" version mismatch: shared library version mock-4-mismatch; SQL version mock-4
\set ON_ERROR_STOP 1
--mock-4 not installed.
\dx
Expand All @@ -389,7 +389,7 @@ ERROR: Mismatched timescaledb version. Shared object file mock-4-mismatch, SQL
\set ON_ERROR_STOP 0
--should not allow since the errored-out mock-4 above already poisoned the well.
CREATE EXTENSION timescaledb VERSION 'mock-5';
ERROR: the session already has another shared library loaded for extension "timescaledb"
ERROR: extension "timescaledb" has already been loaded with another version
\set ON_ERROR_STOP 1
\c single_2 :ROLE_SUPERUSER
--broken version and drop
Expand Down Expand Up @@ -463,7 +463,7 @@ WARNING: mock init "mock-6"
--This should be an error.
SELECT mock_function();
WARNING: mock post_analyze_hook "mock-6"
ERROR: Mismatched timescaledb version. Shared object file mock-5, SQL mock-6
ERROR: extension "timescaledb" version mismatch: shared library version mock-5; SQL version mock-6
\set ON_ERROR_STOP 1
\dx
WARNING: mock post_analyze_hook "mock-6"
Expand Down Expand Up @@ -498,7 +498,7 @@ WARNING: mock post_analyze_hook "mock-1"

\set ON_ERROR_STOP 0
CREATE EXTENSION timescaledb VERSION 'mock-2';
ERROR: the session already has another shared library loaded for extension "timescaledb"
ERROR: extension "timescaledb" has already been loaded with another version
\set ON_ERROR_STOP 1
\dx
List of installed extensions
Expand Down

0 comments on commit bd4920c

Please sign in to comment.