From f397e29ae59ad749e6fb0747239db562a09dd3dc Mon Sep 17 00:00:00 2001 From: Brian Quinion Date: Wed, 6 Mar 2013 13:31:39 +0000 Subject: [PATCH] check versions --- utils/setup.php | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/utils/setup.php b/utils/setup.php index 349bda64..c9ea9ebf 100755 --- a/utils/setup.php +++ b/utils/setup.php @@ -62,7 +62,6 @@ } } - // This is a pretty hard core default - the number of processors in the box - 1 $iInstances = isset($aCMDResult['threads'])?$aCMDResult['threads']:(getProcessorCount()-1); if ($iInstances < 1) @@ -106,6 +105,15 @@ // TODO: path detection, detection memory, etc. $oDB =& getDB(); + + $sVersionString = $oDB->getOne('select version()'); + preg_match('#PostgreSQL ([0-9]+)[.]([0-9]+)[.]([0-9]+) #', $sVersionString, $aMatches); + if (((float)($aMatches[1].'.'.$aMatches[2])) > 9.1) + { + echo "ERROR: PostgreSQL versions > 9.1 not supported. Please use the latest development version from github.\n"; + exit; + } + passthru('createlang plpgsql '.$aDSNInfo['database']); $pgver = (float) CONST_Postgresql_Version; if ($pgver < 9.1) { @@ -115,6 +123,15 @@ } pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/postgis.sql'); pgsqlRunScriptFile(CONST_Path_Postgresql_Postgis.'/spatial_ref_sys.sql'); + + $sVersionString = $oDB->getOne('select postgis_full_version()'); + preg_match('#POSTGIS="([0-9]+)[.]([0-9]+)[.]([0-9]+)( r([0-9]+))?"#', $sVersionString, $aMatches); + if (((float)($aMatches[1].'.'.$aMatches[2])) >= 2.0) + { + echo "ERROR: PostGIS version >= 2 is not supported. Please use the latest development version from github.\n"; + exit; + } + pgsqlRunScriptFile(CONST_BasePath.'/data/country_name.sql'); pgsqlRunScriptFile(CONST_BasePath.'/data/country_naturalearthdata.sql'); pgsqlRunScriptFile(CONST_BasePath.'/data/country_osm_grid.sql');