File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -98,8 +98,16 @@ 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+ return ;
106+ }
107+ } catch (...) {
108+ // Fall through if std::stoi() fails in which case the version
109+ // is reported as 0.
110+ }
103111}
104112
105113} // anonymous namespace
@@ -114,8 +122,13 @@ void init_database_capabilities(pg_conn_t const &db_connection)
114122 try {
115123 log_info (" Database version: {}" ,
116124 capabilities ().settings .at (" server_version" ));
117- log_info (" PostGIS version: {}.{}" , capabilities ().postgis .major ,
118- capabilities ().postgis .minor );
125+
126+ if (capabilities ().postgis .major == 0 ) {
127+ log_info (" PostGIS version: could not be detected" );
128+ } else {
129+ log_info (" PostGIS version: {}.{}" , capabilities ().postgis .major ,
130+ capabilities ().postgis .minor );
131+ }
119132
120133 auto const version_str =
121134 capabilities ().settings .at (" server_version_num" );
You can’t perform that action at this time.
0 commit comments