pgsqlRunScript('ALTER FUNCTION ST_Distance_Spheroid(geometry, geometry, spheroid) RENAME TO ST_DistanceSpheroid');
}
+ $i = chksql($oDB->getOne("select count(*) from pg_user where usename = '".CONST_Database_Web_User."'"));
+ if ($i == 0) {
+ echo "\nERROR: Web user '".CONST_Database_Web_User."' does not exist. Create it with:\n";
+ echo "\n createuser ".CONST_Database_Web_User."\n\n";
+ exit(1);
+ }
+
+ // Try accessing the C module, so we know early if something is wrong
+ // and can simply error out.
+ $sSQL = "CREATE FUNCTION nominatim_test_import_func(text) RETURNS text AS '";
+ $sSQL .= CONST_InstallPath."/module/nominatim.so', 'transliteration' LANGUAGE c IMMUTABLE STRICT";
+ $sSQL .= ';DROP FUNCTION nominatim_test_import_func(text);';
+ $oResult = $oDB->query($sSQL);
+
+ if (PEAR::isError($oResult)) {
+ echo "\nERROR: Failed to load nominatim module. Reason:\n";
+ echo $oResult->userinfo."\n\n";
+ exit(1);
+ }
+
if (!file_exists(CONST_ExtraDataPath.'/country_osm_grid.sql.gz')) {
echo "Error: you need to download the country_osm_grid first:";
echo "\n wget -O ".CONST_ExtraDataPath."/country_osm_grid.sql.gz http://www.nominatim.org/data/country_grid.sql.gz\n";
function pgsqlRunScriptFile($sFilename)
{
+ global $aCMDResult;
if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
// Convert database DSN to psql parameters
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
+ if (!$aCMDResult['verbose']) {
+ $sCMD .= ' -q';
+ }
$ahGzipPipes = null;
if (preg_match('/\\.gz$/', $sFilename)) {
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) $aDSNInfo['port'] = 5432;
$sCMD = 'psql -p '.$aDSNInfo['port'].' -d '.$aDSNInfo['database'];
+ if (!$aCMDResult['verbose']) {
+ $sCMD .= ' -q';
+ }
if ($bfatal && !$aCMDResult['ignore-errors'])
$sCMD .= ' -v ON_ERROR_STOP=1';
$aDescriptors = array(