increased speed to create_sql
All checks were successful
Build (and tag) Images / build (push) Successful in 47s

This commit is contained in:
aso 2025-10-14 18:32:33 +02:00
commit 6c8f5cce81
3 changed files with 11 additions and 43 deletions

View file

@ -23,7 +23,7 @@ if($mysqli->connect_errno) {
echo "Error while connecting to DB : $mysqli->error \n" ;
exit(1);
}
$mysqli->autocommit(FALSE);
if (! ($deleteStmt = $mysqli->prepare("DELETE FROM position WHERE id=?"))) {
echo "Error while preparing delete position statement : " . $mysqli->error ;
@ -153,9 +153,6 @@ function endElement ($parser, $name) {
if ($deleteStmt->affected_rows > 0) {
$sql_statement = $sql_statement . "DELETE FROM position WHERE id=$id;\n";
$sql_statement = $sql_statement . "DELETE FROM tag WHERE id=$id;\n";
$countDelete++;
$mysqli->commit();
printDebugCurNode();
}
} else if ($mode == 'modify' || $mode == 'create') {
@ -163,12 +160,11 @@ function endElement ($parser, $name) {
&& array_key_exists('man_made', $curNodeTags)
&& $curNodeTags['man_made'] == 'surveillance') {
printDebugCurNode();
$id = $curNodeAttrs['id'];
if ($mode == 'modify') {
$countModify++;
if (USE_STATISTICS) {
if (! $deleteStatsStmt->execute()) {
@ -183,7 +179,6 @@ function endElement ($parser, $name) {
echo "***** Error : Deleting $id for modification : ". $deleteStmt->error . "\n";
}
} else {
$countCreate++;
}
$latitude = (int) ($curNodeAttrs['lat'] * 10000000);
@ -264,10 +259,6 @@ function endElement ($parser, $name) {
if ($deleteStmt->affected_rows > 0) {
$sql_statement = $sql_statement . "DELETE FROM position WHERE id=$id;\n";
$sql_statement = $sql_statement . "DELETE FROM tag WHERE id=$id;\n";
$countModifyDelete++;
$mysqli->commit();
printDebugCurNode();
echo " ==> delete because modified to non-surveillance node\n";
}
}
}
@ -297,13 +288,11 @@ while ($data = fread($fp, 4096)) {
$sql="UPDATE sync_state SET v='" . $_SERVER['argv'][1] ."' WHERE k='sequenceNumber';";
$mysqli->query($sql);
$mysqli->commit();
$sql_statement = $sql_statement . "UPDATE sync_state SET v='" . $_SERVER['argv'][1] ."' WHERE k='sequenceNumber';\n";
$sql_statement = $sql_statement . "COMMIT;";
$sql_file = "/migrations/".$_SERVER['argv'][1].".sql";
file_put_contents($sql_file, $sql_statement);
printDebug();
$mysqli->close();
?>