Commit e35d3ea8 by Robert Lyon Committed by Aaron Wells

Getting mysql not to use CAST() (bug #1081947)

In the 1.8+ codebase there are only two places where both mysql and
postgres use CAST(). So I've tried altering the calls so that mysql
doens't need to use CAST().

This will probably need to be tested with a large data mysql db site
to see if any speed gains are made, and also the calls are still
working correctly.

All other places it is being used by postgres only
Signed-off-by: Robert Lyon <robertl@catalyst.net.nz>

Change-Id: I9eaf196d062ef2a62bfdae0df179281f3411c392
parent 14bb34a5
......@@ -843,8 +843,8 @@ class ActivityTypeWatchlist extends ActivityType {
// mysql compatibility (sigh...)
$casturl = 'CAST(? AS TEXT)';
if (get_config('dbtype') == 'mysql') {
$casturl = 'CAST(? AS CHAR)'; // note, NOT varchar
if (is_mysql()) {
$casturl = '?';
}
$sql = 'SELECT u.*, p.method, ap.value AS lang, ' . $casturl . ' AS url
FROM {usr_watchlist_view} wv
......
......@@ -2592,8 +2592,12 @@ class View {
$expr = 'a.owner IS NOT NULL AND a.owner = ?';
array_unshift($selectph, $user->get('id'));
}
$type = is_mysql() ? 'UNSIGNED' : 'INTEGER';
$cols .= ", CAST($expr AS $type) AS editable";
if (is_mysql()) {
$cols .= ", ($expr) AS editable";
}
else {
$cols .= ", CAST($expr AS INTEGER) AS editable";
}
}
$artefacts = get_records_sql_assoc(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment