@@ -75,18 +75,16 @@ flex_table_column_t &flex_table_t::add_column(std::string const &name,
7575
7676std::string flex_table_t::build_sql_prepare_get_wkb () const
7777{
78- if (has_geom_column ()) {
79- if (has_multicolumn_id_index ()) {
80- return " PREPARE get_wkb(char(1), bigint) AS"
81- " SELECT \" {}\" FROM {} WHERE \" {}\" = $1 AND \" {}\" = $2" _format (
82- geom_column ().name (), full_name (), m_columns[0 ].name (),
83- m_columns[1 ].name ());
84- }
85- return " PREPARE get_wkb(bigint) AS"
86- " SELECT \" {}\" FROM {} WHERE \" {}\" = $1" _format (
87- geom_column ().name (), full_name (), id_column_names ());
78+ if (has_multicolumn_id_index ()) {
79+ return " PREPARE get_wkb(char(1), bigint) AS"
80+ " SELECT \" {}\" FROM {} WHERE \" {}\" = $1 AND \" {}\" = $2" _format (
81+ geom_column ().name (), full_name (), m_columns[0 ].name (),
82+ m_columns[1 ].name ());
8883 }
89- return " PREPARE get_wkb(bigint) AS SELECT ''" ;
84+
85+ return " PREPARE get_wkb(bigint) AS"
86+ " SELECT \" {}\" FROM {} WHERE \" {}\" = $1" _format (
87+ geom_column ().name (), full_name (), id_column_names ());
9088}
9189
9290std::string flex_table_t::build_sql_create_table (table_type ttype,
@@ -302,6 +300,14 @@ void table_connection_t::stop(bool updateable, bool append)
302300 teardown ();
303301}
304302
303+ void table_connection_t::prepare ()
304+ {
305+ assert (m_db_connection);
306+ if (table ().has_id_column () && table ().has_geom_column ()) {
307+ m_db_connection->exec (table ().build_sql_prepare_get_wkb ());
308+ }
309+ }
310+
305311pg_result_t table_connection_t::get_geom_by_id (osmium::item_type type,
306312 osmid_t id) const
307313{
0 commit comments