Skip to content

Commit 47442e5

Browse files
committed
Fix: Delete to be expired tiles at the same time as reading them
The TRUNCATE didn't work, because there can be tiles from more than one zoom level in the same table. Using DELETE ... RETURNING we are ensured to always delete exactly what we are getting back.
1 parent 429168d commit 47442e5

1 file changed

Lines changed: 1 addition & 3 deletions

File tree

src/gen/osm2pgsql-gen.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ void get_tiles_from_table(pg_conn_t const &connection, std::string const &table,
175175
std::vector<std::pair<uint32_t, uint32_t>> *tiles)
176176
{
177177
auto const result = connection.exec(
178-
R"(SELECT x, y FROM "{}" WHERE zoom = {})", table, zoom);
178+
R"(DELETE FROM "{}" WHERE zoom = {} RETURNING x, y)", table, zoom);
179179

180180
tiles->reserve(result.num_tuples());
181181

@@ -476,8 +476,6 @@ class genproc_t
476476
log_debug("Running generalizer for expire list from table '{}'...",
477477
table);
478478
get_tiles_from_table(db_connection, table, zoom, &tile_list);
479-
log_debug("Truncating table '{}'...", table);
480-
db_connection.exec("TRUNCATE {}", table);
481479
} else {
482480
auto const extent =
483481
get_extent_from_db(db_connection, m_dbschema, params, zoom);

0 commit comments

Comments
 (0)