Skip to content

Commit bfd9282

Browse files
committed
Check earlier that the database has a tablespace mentioned in the config
1 parent 83fadd4 commit bfd9282

File tree

2 files changed

+12
-10
lines changed

2 files changed

+12
-10
lines changed

src/flex-table.cpp

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,16 +253,6 @@ void table_connection_t::start(bool append)
253253
{
254254
assert(m_db_connection);
255255

256-
for (auto const &ts :
257-
{table().data_tablespace(), table().index_tablespace()}) {
258-
if (!has_tablespace(ts)) {
259-
throw fmt_error(
260-
"Tablespace '{0}' not available."
261-
" Use 'CREATE TABLESPACE \"{0}\" ...;' to create it.",
262-
ts);
263-
}
264-
}
265-
266256
m_db_connection->exec("SET client_min_messages = WARNING");
267257

268258
if (!append) {

src/output-flex.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -434,6 +434,16 @@ int output_flex_t::app_as_geometrycollection()
434434
return 1;
435435
}
436436

437+
static void check_tablespace(std::string const &tablespace)
438+
{
439+
if (!has_tablespace(tablespace)) {
440+
throw fmt_error(
441+
"Tablespace '{0}' not available."
442+
" Use 'CREATE TABLESPACE \"{0}\" ...;' to create it.",
443+
tablespace);
444+
}
445+
}
446+
437447
flex_table_t &output_flex_t::create_flex_table()
438448
{
439449
std::string const table_name =
@@ -491,6 +501,7 @@ flex_table_t &output_flex_t::create_flex_table()
491501
if (lua_isstring(lua_state(), -1)) {
492502
std::string const tablespace = lua_tostring(lua_state(), -1);
493503
check_identifier(tablespace, "data_tablespace field");
504+
check_tablespace(tablespace);
494505
new_table.set_data_tablespace(tablespace);
495506
}
496507
lua_pop(lua_state(), 1);
@@ -500,6 +511,7 @@ flex_table_t &output_flex_t::create_flex_table()
500511
if (lua_isstring(lua_state(), -1)) {
501512
std::string const tablespace = lua_tostring(lua_state(), -1);
502513
check_identifier(tablespace, "index_tablespace field");
514+
check_tablespace(tablespace);
503515
new_table.set_index_tablespace(tablespace);
504516
}
505517
lua_pop(lua_state(), 1);

0 commit comments

Comments
 (0)