Skip to content

Commit

Permalink
Merge pull request zerebubuth#454 from mmd-osm/patch/type_name_inline
Browse files Browse the repository at this point in the history
Adjustments for libpqxx-7.x, clang++, macOS
  • Loading branch information
mmd-osm authored Sep 8, 2024
2 parents fcacb52 + f6f72fd commit 0df23d6
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 16 deletions.
3 changes: 1 addition & 2 deletions include/cgimap/backend/apidb/pqxx_string_traits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ struct array_string_traits
template<> \
struct string_traits<type> : cgimap::array_string_traits<type> {}; \
\
template<> std::string const type_name<type>{#type}; \
template<> inline std::string const type_name<type>{#type}; \


#endif
Expand All @@ -127,7 +127,6 @@ PQXX_ARRAY_STRING_TRAITS(std::vector<tile_id_t>);
PQXX_ARRAY_STRING_TRAITS(std::vector<osm_changeset_id_t>);
PQXX_ARRAY_STRING_TRAITS(std::set<osm_changeset_id_t>);
PQXX_ARRAY_STRING_TRAITS(std::vector<std::string>);
PQXX_ARRAY_STRING_TRAITS(std::vector<bool>);

} // namespace pqxx

Expand Down
11 changes: 4 additions & 7 deletions src/backend/apidb/changeset_upload/relation_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1239,17 +1239,16 @@ void ApiDB_Relation_Updater::update_current_relations(

m.prepare("update_current_relations",
R"(
WITH u(id, changeset_id, visible, version) AS (
WITH u(id, changeset_id, version) AS (
SELECT * FROM
UNNEST( CAST($1 AS bigint[]),
CAST($2 AS bigint[]),
CAST($3 AS boolean[]),
CAST($4 AS bigint[])
CAST($3 AS bigint[])
)
)
UPDATE current_relations AS r
SET changeset_id = u.changeset_id,
visible = u.visible,
visible = CAST($4 as boolean),
timestamp = (now() at time zone 'utc'),
version = u.version + 1
FROM u
Expand All @@ -1260,20 +1259,18 @@ void ApiDB_Relation_Updater::update_current_relations(

std::vector<osm_nwr_signed_id_t> ids;
std::vector<osm_changeset_id_t> cs;
std::vector<bool> visibles;
std::vector<osm_version_t> versions;
std::map<osm_nwr_id_t, osm_nwr_signed_id_t> id_to_old_id;

for (const auto &relation : relations) {
ids.emplace_back(relation.id);
cs.emplace_back(relation.changeset_id);
visibles.push_back(visible);
versions.emplace_back(relation.version);
id_to_old_id[relation.id] = relation.old_id;
}

pqxx::result r =
m.exec_prepared("update_current_relations", ids, cs, visibles, versions);
m.exec_prepared("update_current_relations", ids, cs, versions, visible);

if (r.affected_rows() != relations.size())
throw http::server_error("Could not update all current relations");
Expand Down
11 changes: 4 additions & 7 deletions src/backend/apidb/changeset_upload/way_updater.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -642,17 +642,16 @@ void ApiDB_Way_Updater::update_current_ways(const std::vector<way_t> &ways,
return;

m.prepare("update_current_ways", R"(
WITH u(id, changeset_id, visible, version) AS (
WITH u(id, changeset_id, version) AS (
SELECT * FROM
UNNEST( CAST($1 AS bigint[]),
CAST($2 AS bigint[]),
CAST($3 AS boolean[]),
CAST($4 AS bigint[])
CAST($3 AS bigint[])
)
)
UPDATE current_ways AS w
SET changeset_id = u.changeset_id,
visible = u.visible,
visible = CAST($4 as boolean),
timestamp = (now() at time zone 'utc'),
version = u.version + 1
FROM u
Expand All @@ -663,20 +662,18 @@ void ApiDB_Way_Updater::update_current_ways(const std::vector<way_t> &ways,

std::vector<osm_nwr_signed_id_t> ids;
std::vector<osm_changeset_id_t> cs;
std::vector<bool> visibles;
std::vector<osm_version_t> versions;
std::map<osm_nwr_id_t, osm_nwr_signed_id_t> id_to_old_id;

for (const auto &way : ways) {
ids.emplace_back(way.id);
cs.emplace_back(way.changeset_id);
visibles.push_back(visible);
versions.emplace_back(way.version);
id_to_old_id[way.id] = way.old_id;
}

pqxx::result r =
m.exec_prepared("update_current_ways", ids, cs, visibles, versions);
m.exec_prepared("update_current_ways", ids, cs, versions, visible);

if (r.affected_rows() != ways.size())
throw http::server_error("Could not update all current ways");
Expand Down

0 comments on commit 0df23d6

Please sign in to comment.