@@ -2207,29 +2207,43 @@ QString QgsPostgresProvider::Conn::postgisVersion()
22072207 postgisVersionMajor = postgisVersionParts[0 ].toInt ();
22082208 postgisVersionMinor = postgisVersionParts[1 ].toInt ();
22092209
2210- // assume no capabilities
2211- geosAvailable = false ;
2212- gistAvailable = false ;
2213- projAvailable = false ;
2210+ mUseWkbHex = postgisVersionMajor < 1 ;
22142211
2215- // parse out the capabilities and store them
2216- QStringList geos = postgisParts.filter ( " GEOS" );
2217- if ( geos.size () == 1 )
2218- {
2219- geosAvailable = ( geos[0 ].indexOf ( " =1" ) > -1 );
2220- }
2221- QStringList gist = postgisParts.filter ( " STATS" );
2222- if ( gist.size () == 1 )
2212+ // apparently postgis 1.5.2 doesn't report capabilities in postgis_version() anymore
2213+ if ( postgisVersionMajor > 1 || ( postgisVersionMajor == 1 && postgisVersionMinor >= 5 ) )
22232214 {
2224- gistAvailable = ( geos[0 ].indexOf ( " =1" ) > -1 );
2215+ result = PQexec ( " select postgis_geos_version(),postgis_proj_version()" );
2216+ geosAvailable = PQntuples ( result ) == 1 && !PQgetisnull ( result, 0 , 0 );
2217+ projAvailable = PQntuples ( result ) == 1 && !PQgetisnull ( result, 0 , 1 );
2218+ QgsDebugMsg ( QString ( " geos:%1 proj:%2" )
2219+ .arg ( geosAvailable ? PQgetvalue ( result, 0 , 0 ) : " none" )
2220+ .arg ( projAvailable ? PQgetvalue ( result, 0 , 1 ) : " none" ) );
2221+ gistAvailable = true ;
22252222 }
2226- QStringList proj = postgisParts.filter ( " PROJ" );
2227- if ( proj.size () == 1 )
2223+ else
22282224 {
2229- projAvailable = ( proj[0 ].indexOf ( " =1" ) > -1 );
2230- }
2225+ // assume no capabilities
2226+ geosAvailable = false ;
2227+ gistAvailable = false ;
2228+ projAvailable = false ;
22312229
2232- mUseWkbHex = postgisVersionMajor < 1 ;
2230+ // parse out the capabilities and store them
2231+ QStringList geos = postgisParts.filter ( " GEOS" );
2232+ if ( geos.size () == 1 )
2233+ {
2234+ geosAvailable = ( geos[0 ].indexOf ( " =1" ) > -1 );
2235+ }
2236+ QStringList gist = postgisParts.filter ( " STATS" );
2237+ if ( gist.size () == 1 )
2238+ {
2239+ gistAvailable = ( geos[0 ].indexOf ( " =1" ) > -1 );
2240+ }
2241+ QStringList proj = postgisParts.filter ( " PROJ" );
2242+ if ( proj.size () == 1 )
2243+ {
2244+ projAvailable = ( proj[0 ].indexOf ( " =1" ) > -1 );
2245+ }
2246+ }
22332247
22342248 gotPostgisVersion = true ;
22352249
0 commit comments