mirror of
https://github.com/EGroupware/egroupware.git
synced 2025-01-03 04:29:28 +01:00
MariaDB before 10.3 could not update same table used in a sub-query
This commit is contained in:
parent
b7eb1f866b
commit
3bf72f39d8
@ -647,12 +647,32 @@ function api_upgrade19_1()
|
|||||||
$max_endtime = $endtime->format(Api\DateTime::DATABASE);
|
$max_endtime = $endtime->format(Api\DateTime::DATABASE);
|
||||||
|
|
||||||
// set timestamps in estimated update window to the one of the preceeding row
|
// set timestamps in estimated update window to the one of the preceeding row
|
||||||
$GLOBALS['egw_setup']->db->query('UPDATE egw_history_log SET history_timestamp='.
|
$prev_timestamp = '(SELECT history_timestamp FROM egw_history_log prev WHERE egw_history_log.history_id > prev.history_id AND prev.history_old_value != '.
|
||||||
'(SELECT history_timestamp FROM egw_history_log prev WHERE egw_history_log.history_id > prev.history_id AND prev.history_old_value != '.
|
$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER).' ORDER BY prev.history_id DESC LIMIT 1)';
|
||||||
$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER).' ORDER BY prev.history_id DESC LIMIT 1)'.
|
|
||||||
" WHERE history_timestamp BETWEEN '$broken_update_starttime' AND '$max_endtime'".
|
// MariaDB before 10.3 could not update same table used in a sub-query (not sure about MySQL, so handle it like older MariaDB)
|
||||||
" AND history_old_value=".$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER),
|
if ($GLOBALS['egw_setup']->db->Type === 'mysql' && (float)$$GLOBALS['egw_setup']->db->ServerInfo['version'] < 10.3)
|
||||||
__LINE__, __FILE__);
|
{
|
||||||
|
// iterate over queried timestamps to update them from PHP
|
||||||
|
foreach($GLOBALS['egw_setup']->db->select('egw_history_log', "history_id,$prev_timestamp AS prev_timestamp", [
|
||||||
|
"history_timestamp BETWEEN '$broken_update_starttime' AND '$max_endtime'",
|
||||||
|
'history_old_value' => Api\Storage\Tracking::DIFF_MARKER,
|
||||||
|
], __LINE__, __FILE__) as $row)
|
||||||
|
{
|
||||||
|
$GLOBALS['egw_setup']->db->update('egw_history_log', [
|
||||||
|
'history_timestamp' => $row['prev_timestamp'],
|
||||||
|
], [
|
||||||
|
'history_id' => $row['history_id'],
|
||||||
|
], __LINE__, __FILE__);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$GLOBALS['egw_setup']->db->query("UPDATE egw_history_log SET history_timestamp=$prev_timestamp".
|
||||||
|
" WHERE history_timestamp BETWEEN '$broken_update_starttime' AND '$max_endtime'".
|
||||||
|
" AND history_old_value=".$GLOBALS['egw_setup']->db->quote(Api\Storage\Tracking::DIFF_MARKER),
|
||||||
|
__LINE__, __FILE__);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return $GLOBALS['setup_info']['api']['currentver'] = '19.1.001';
|
return $GLOBALS['setup_info']['api']['currentver'] = '19.1.001';
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user