@@ -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+
437447flex_table_t &output_flex_t ::create_flex_table()
438448{
439449 std::string const table_name =
@@ -455,6 +465,11 @@ flex_table_t &output_flex_t::create_flex_table()
455465 if (lua_isstring (lua_state (), -1 )) {
456466 std::string const schema = lua_tostring (lua_state (), -1 );
457467 check_identifier (schema, " schema field" );
468+ if (!has_schema (schema)) {
469+ throw fmt_error (" Schema '{0}' not available."
470+ " Use 'CREATE SCHEMA \" {0}\" ;' to create it." ,
471+ schema);
472+ }
458473 new_table.set_schema (schema);
459474 }
460475 lua_pop (lua_state (), 1 );
@@ -486,6 +501,7 @@ flex_table_t &output_flex_t::create_flex_table()
486501 if (lua_isstring (lua_state (), -1 )) {
487502 std::string const tablespace = lua_tostring (lua_state (), -1 );
488503 check_identifier (tablespace, " data_tablespace field" );
504+ check_tablespace (tablespace);
489505 new_table.set_data_tablespace (tablespace);
490506 }
491507 lua_pop (lua_state (), 1 );
@@ -495,6 +511,7 @@ flex_table_t &output_flex_t::create_flex_table()
495511 if (lua_isstring (lua_state (), -1 )) {
496512 std::string const tablespace = lua_tostring (lua_state (), -1 );
497513 check_identifier (tablespace, " index_tablespace field" );
514+ check_tablespace (tablespace);
498515 new_table.set_index_tablespace (tablespace);
499516 }
500517 lua_pop (lua_state (), 1 );
0 commit comments