Skip to content

Commit 40f1067

Browse files
authored
Merge pull request #1924 from joto/move-expire-table-create
Move table creation for expire tables where it belongs
2 parents cdcaa99 + 4dd6261 commit 40f1067

File tree

3 files changed

+19
-8
lines changed

3 files changed

+19
-8
lines changed

src/expire-output.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,14 @@ expire_output_t::output_tiles_to_table(quadkey_list_t const &tiles_at_maxzoom,
6969

7070
return count;
7171
}
72+
73+
void expire_output_t::create_output_table(pg_conn_t const &connection) const
74+
{
75+
auto const qn = qualified_name(m_schema, m_table);
76+
connection.exec("CREATE TABLE IF NOT EXISTS {} ("
77+
" zoom int4 NOT NULL,"
78+
" x int4 NOT NULL,"
79+
" y int4 NOT NULL,"
80+
" PRIMARY KEY (zoom, x, y))",
81+
qn);
82+
}

src/expire-output.hpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
#include <string>
1616
#include <utility>
1717

18+
class pg_conn_t;
19+
1820
/**
1921
* Output for tile expiry.
2022
*/
@@ -70,6 +72,11 @@ class expire_output_t
7072
std::size_t output_tiles_to_table(quadkey_list_t const &tiles_at_maxzoom,
7173
std::string const &conninfo) const;
7274

75+
/**
76+
* Create table for tiles.
77+
*/
78+
void create_output_table(pg_conn_t const &connection) const;
79+
7380
private:
7481
/// The internal (unique) name of the output
7582
std::string m_name;

src/output-flex.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1275,14 +1275,7 @@ create_expire_tables(std::vector<expire_output_t> const &expire_outputs,
12751275
connection.exec("SET client_min_messages = WARNING");
12761276
for (auto &expire_output : expire_outputs) {
12771277
if (!expire_output.table().empty()) {
1278-
auto const qn =
1279-
qualified_name(expire_output.schema(), expire_output.table());
1280-
connection.exec("CREATE TABLE IF NOT EXISTS {} ("
1281-
" zoom int4 NOT NULL,"
1282-
" x int4 NOT NULL,"
1283-
" y int4 NOT NULL,"
1284-
" PRIMARY KEY (zoom, x, y))",
1285-
qn);
1278+
expire_output.create_output_table(connection);
12861279
}
12871280
}
12881281
}

0 commit comments

Comments
 (0)