array('create-functions', '', 0, 1, 0, 0, 'bool', 'Create functions'),
array('enable-diff-updates', '', 0, 1, 0, 0, 'bool', 'Turn on the code required to make diff updates work'),
array('enable-debug-statements', '', 0, 1, 0, 0, 'bool', 'Include debug warning statements in pgsql commands'),
+ array('ignore-errors', '', 0, 1, 0, 0, 'bool', 'Continue import even when errors in SQL are present (EXPERT)'),
array('create-minimal-tables', '', 0, 1, 0, 0, 'bool', 'Create minimal main tables'),
array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'),
array('create-partition-tables', '', 0, 1, 0, 0, 'bool', 'Create required partition tables'),
{
pgsqlRunScript('update country_name set partition = 0');
}
+
+ // the following will be needed by create_functions later but
+ // is only defined in the subsequently called create_tables.
+ // Create dummies here that will be overwritten by the proper
+ // versions in create-tables.
+ pgsqlRunScript('CREATE TABLE place_boundingbox ()');
+ pgsqlRunScript('create type wikipedia_article_match as ()');
}
if ($aCMDResult['import-data'] || $aCMDResult['all'])
}
fclose($ahPipes[1]);
- proc_close($hProcess);
+ $iReturn = proc_close($hProcess);
+ if ($iReturn > 0)
+ {
+ fail("pgsql returned with error code ($iReturn)");
+ }
if ($ahGzipPipes)
{
fclose($ahGzipPipes[1]);
function pgsqlRunScript($sScript)
{
+ global $aCMDResult;
// 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['ignore-errors'])
+ $sCMD .= ' -v ON_ERROR_STOP=1';
$aDescriptors = array(
0 => array('pipe', 'r'),
1 => STDOUT,
while(strlen($sScript))
{
$written = fwrite($ahPipes[0], $sScript);
+ if ($written <= 0) break;
$sScript = substr($sScript, $written);
}
fclose($ahPipes[0]);
- proc_close($hProcess);
+ $iReturn = proc_close($hProcess);
+ if ($iReturn > 0)
+ {
+ fail("pgsql returned with error code ($iReturn)");
+ }
}
function pgsqlRunRestoreData($sDumpFile)
}
fclose($ahPipes[1]);
- proc_close($hProcess);
+ $iReturn = proc_close($hProcess);
}
function pgsqlRunDropAndRestore($sDumpFile)
}
fclose($ahPipes[1]);
- proc_close($hProcess);
+ $iReturn = proc_close($hProcess);
}
function passthruCheckReturn($cmd)