add a db_version and a feature check function to determine if we support skip locks in the query. Use it to disable the feature in filter view.

pull/3669/merge
Isaac Connor 2023-02-25 11:44:44 -05:00
parent a62f4b2e77
commit 39de76e989
2 changed files with 24 additions and 1 deletions

View File

@ -379,4 +379,24 @@ function getTableDescription( $table, $asString=1 ) {
}
return $columns;
}
function db_version() {
return dbFetchOne('SELECT VERSION()', 'VERSION()');
}
function db_supports_feature($feature) {
$version = db_version();
if ($feature == 'skip_locks') {
$just_the_version = strstr($version, '-MariaDB', true);
ZM\Debug("Just the version $just_the_version from $version");
if (false === $just_the_version) {
# Is MYSQL
return version_compare($version, '8.0.1', '>=');
} else {
return version_compare($just_the_version, '10.6', '>=');
}
} else {
ZM\Warning("Unknown feature requested $feature");
}
}
?>

View File

@ -218,7 +218,10 @@ echo htmlSelect('filter[Query][sort_asc]', $sort_dirns, $filter->sort_asc());
<?php
echo htmlSelect('filter[Query][skip_locked]',
array('0'=>translate('No'), '1'=>translate('Yes')),
$filter->skip_locked());
$filter->skip_locked(),
( db_supports_feature('skip_locks') ? []: ['disabled'=>'disabled', 'title'=>'Database does not support the skip locked feature.'])
);
?>
</td>
<td>