File tree Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Expand file tree Collapse file tree 1 file changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,15 @@ void init_postgis_version(pg_conn_t const &db_connection)
9898 capabilities ().database_name );
9999 }
100100
101- capabilities ().postgis = {std::stoi (std::string{res.get (0 , 0 )}),
102- std::stoi (std::string{res.get (1 , 0 )})};
101+ try {
102+ if (res.num_tuples () >= 2 ) {
103+ capabilities ().postgis = {std::stoi (std::string{res.get (0 , 0 )}),
104+ std::stoi (std::string{res.get (1 , 0 )})};
105+ }
106+ } catch (...) {
107+ // Fall through if std::stoi() fails in which case the version
108+ // is reported as 0.
109+ }
103110}
104111
105112} // anonymous namespace
@@ -114,8 +121,13 @@ void init_database_capabilities(pg_conn_t const &db_connection)
114121 try {
115122 log_info (" Database version: {}" ,
116123 capabilities ().settings .at (" server_version" ));
117- log_info (" PostGIS version: {}.{}" , capabilities ().postgis .major ,
118- capabilities ().postgis .minor );
124+
125+ if (capabilities ().postgis .major == 0 ) {
126+ log_info (" PostGIS version: could not be detected" );
127+ } else {
128+ log_info (" PostGIS version: {}.{}" , capabilities ().postgis .major ,
129+ capabilities ().postgis .minor );
130+ }
119131
120132 auto const version_str =
121133 capabilities ().settings .at (" server_version_num" );
You can’t perform that action at this time.
0 commit comments