File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed
Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change 1010#include " flex-table.hpp"
1111#include " format.hpp"
1212#include " logging.hpp"
13+ #include " pgsql-capabilities.hpp"
1314#include " pgsql-helper.hpp"
1415#include " util.hpp"
1516
@@ -189,6 +190,30 @@ void table_connection_t::start(bool append)
189190{
190191 assert (m_db_connection);
191192
193+ if (!has_schema (*m_db_connection, table ().schema ())) {
194+ throw std::runtime_error{
195+ " Schema '{0}' not available. "
196+ " Use 'CREATE SCHEMA \" {0}\" ;' to create it." _format (
197+ table ().schema ())};
198+ }
199+
200+ for (auto const &ts :
201+ {table ().data_tablespace (), table ().index_tablespace ()}) {
202+ if (!has_tablespace (*m_db_connection, ts)) {
203+ throw std::runtime_error{
204+ " Tablespace '{0}' not available. "
205+ " Use 'CREATE TABLESPACE \" {0}\" ...;' to create it." _format (
206+ ts)};
207+ }
208+ }
209+
210+ if (table ().has_hstore_column ()) {
211+ if (!has_extension (*m_db_connection, " hstore" )) {
212+ throw std::runtime_error{" Extension 'hstore' not available. Use "
213+ " 'CREATE EXTENSION hstore;' to load it." };
214+ }
215+ }
216+
192217 m_db_connection->exec (" SET client_min_messages = WARNING" );
193218
194219 if (!append) {
Original file line number Diff line number Diff line change @@ -110,6 +110,14 @@ class flex_table_t
110110 return m_geom_column != std::numeric_limits<std::size_t >::max ();
111111 }
112112
113+ bool has_hstore_column () const noexcept
114+ {
115+ auto const it = std::find_if (begin (), end (), [&](auto const &column) {
116+ return column.type () == table_column_type::hstore;
117+ });
118+ return it != end ();
119+ }
120+
113121 // / Get the (first, if there are multiple) geometry column.
114122 flex_table_column_t const &geom_column () const noexcept
115123 {
You can’t perform that action at this time.
0 commit comments