include database version in sys info

This commit is contained in:
Shish 2020-03-26 16:57:08 +00:00
parent 2d0b107adb
commit 511a82f2ba
3 changed files with 23 additions and 3 deletions

View file

@ -139,6 +139,11 @@ class Database
return $this->engine->name;
}
public function get_version(): string
{
return $this->engine->get_version($this->db);
}
private function count_time(string $method, float $start, string $query, ?array $args): void
{
global $_tracer, $tracer_enabled;

View file

@ -31,6 +31,8 @@ abstract class DBEngine
}
abstract public function set_timeout(PDO $db, int $time);
abstract public function get_version(PDO $db): string;
}
class MySQL extends DBEngine
@ -68,12 +70,15 @@ class MySQL extends DBEngine
// These only apply to read-only queries, which appears to be the best we can to mysql-wise
// $db->exec("SET SESSION MAX_EXECUTION_TIME=".$time.";");
}
public function get_version(PDO $db): string
{
return $db->query('select version()')->fetch()[0];
}
}
class PostgreSQL extends DBEngine
{
/** @var string */
public $name = DatabaseDriver::PGSQL;
@ -110,6 +115,11 @@ class PostgreSQL extends DBEngine
{
$db->exec("SET statement_timeout TO ".$time.";");
}
public function get_version(PDO $db): string
{
return $db->query('select version()')->fetch()[0];
}
}
// shimmie functions for export to sqlite
@ -216,4 +226,9 @@ class SQLite extends DBEngine
{
// There doesn't seem to be such a thing for SQLite, so it does nothing
}
public function get_version(PDO $db): string
{
return $db->query('select sqlite_version()')->fetch()[0];
}
}

View file

@ -69,7 +69,7 @@ class ET extends Extension
'shimmie' => VERSION,
'schema' => $config->get_int("db_version"),
'php' => phpversion(),
'db' => $database->get_driver_name(),
'db' => $database->get_driver_name() . " " . $database->get_version(),
'os' => php_uname(),
'server' => isset($_SERVER["SERVER_SOFTWARE"]) ? $_SERVER["SERVER_SOFTWARE"] : 'unknown',
],