MySQL: Speed up updating rows without numeric or UTF-8 primary key
This commit is contained in:
parent
8e0ead4678
commit
7dd90f56f1
|
@ -375,10 +375,6 @@ WHERE OBJECT_NAME(i.object_id) = " . q($table)
|
|||
return nl_br(h(preg_replace('~^(\\[[^]]*])+~m', '', $connection->error)));
|
||||
}
|
||||
|
||||
function exact_value($val) {
|
||||
return q($val);
|
||||
}
|
||||
|
||||
function create_database($db, $collation) {
|
||||
return queries("CREATE DATABASE " . idf_escape($db) . (eregi('^[a-z0-9_]+$', $collation) ? " COLLATE $collation" : ""));
|
||||
}
|
||||
|
|
|
@ -532,14 +532,6 @@ if (!defined("DRIVER")) {
|
|||
}
|
||||
}
|
||||
|
||||
/** Return expression for binary comparison
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function exact_value($val) {
|
||||
return q($val) . " COLLATE utf8_bin";
|
||||
}
|
||||
|
||||
/** Create database
|
||||
* @param string
|
||||
* @param string
|
||||
|
@ -983,7 +975,7 @@ if (!defined("DRIVER")) {
|
|||
$return = "UNHEX($return)";
|
||||
}
|
||||
if ($field["type"] == "bit") {
|
||||
return "CONV($return, 2, 10) + 0";
|
||||
$return = "CONV($return, 2, 10) + 0";
|
||||
}
|
||||
if (ereg("geometry|point|linestring|polygon", $field["type"])) {
|
||||
$return = "GeomFromText($return)";
|
||||
|
|
|
@ -270,10 +270,6 @@ ORDER BY uc.constraint_type, uic.column_position", $connection2) as $row) {
|
|||
return h($connection->error); //! highlight sqltext from offset
|
||||
}
|
||||
|
||||
function exact_value($val) {
|
||||
return q($val);
|
||||
}
|
||||
|
||||
function explain($connection, $query) {
|
||||
$connection->query("EXPLAIN PLAN FOR $query");
|
||||
return $connection->query("SELECT * FROM plan_table");
|
||||
|
|
|
@ -326,10 +326,6 @@ ORDER BY conkey, conname") as $row) {
|
|||
return nl_br($return);
|
||||
}
|
||||
|
||||
function exact_value($val) {
|
||||
return q($val);
|
||||
}
|
||||
|
||||
function create_database($db, $collation) {
|
||||
return queries("CREATE DATABASE " . idf_escape($db) . ($collation ? " ENCODING " . idf_escape($collation) : ""));
|
||||
}
|
||||
|
|
|
@ -348,10 +348,6 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||
return h($connection->error);
|
||||
}
|
||||
|
||||
function exact_value($val) {
|
||||
return q($val);
|
||||
}
|
||||
|
||||
function check_sqlite_name($name) {
|
||||
// avoid creating PHP files on unsecured servers
|
||||
global $connection;
|
||||
|
|
|
@ -333,9 +333,16 @@ function where($where, $fields = array()) {
|
|||
$function_pattern = '(^[\w\(]+' . str_replace("_", ".*", preg_quote(idf_escape("_"))) . '\)+$)'; //! columns looking like functions
|
||||
foreach ((array) $where["where"] as $key => $val) {
|
||||
$key = bracket_escape($key, 1); // 1 - back
|
||||
$return[] = (preg_match($function_pattern, $key) ? $key : idf_escape($key)) //! SQL injection
|
||||
. (($jush == "sql" && ereg('\\.', $val)) || $jush == "mssql" ? " LIKE " . exact_value(addcslashes($val, "%_\\")) : " = " . unconvert_field($fields[$key], exact_value($val))) // LIKE because of floats, but slow with ints, in MS SQL because of text
|
||||
$column = (preg_match($function_pattern, $key) ? $key : idf_escape($key)); //! SQL injection
|
||||
$return[] = $column
|
||||
. (($jush == "sql" && ereg('^[0-9]*\\.[0-9]*$', $val)) || $jush == "mssql"
|
||||
? " LIKE " . q(addcslashes($val, "%_\\"))
|
||||
: " = " . unconvert_field($fields[$key], q($val))
|
||||
) // LIKE because of floats but slow with ints, in MS SQL because of text
|
||||
; //! enum and set
|
||||
if ($jush == "sql" && ereg("[^ -@]", $val)) { // not just [a-z] to catch non-ASCII characters
|
||||
$return[] = "$column = " . q($val) . " COLLATE utf8_bin";
|
||||
}
|
||||
}
|
||||
foreach ((array) $where["null"] as $key) {
|
||||
$return[] = idf_escape($key) . " IS NULL";
|
||||
|
|
|
@ -5,6 +5,7 @@ Don't use LIMIT 1 if inline updating unique row
|
|||
Don't check previous checkbox on added column in create table (bug #3614245)
|
||||
Order table list by name
|
||||
Verify UTF-8 encoding of CSV import
|
||||
MySQL: Speed up updating rows without numeric or UTF-8 primary key
|
||||
PostgreSQL: Fix detecting oid column in PDO
|
||||
PostgreSQL: Handle timestamp types (bug #3614086)
|
||||
Add Korean translation
|
||||
|
|
|
@ -143,7 +143,7 @@ ORDER BY ORDINAL_POSITION", null, "") as $row) { //! requires MySQL 5
|
|||
// find all used ids
|
||||
$ids = array();
|
||||
foreach ($rows as $row) {
|
||||
$ids[$row[$key]] = exact_value($row[$key]);
|
||||
$ids[$row[$key]] = q($row[$key]);
|
||||
}
|
||||
// uses constant number of queries to get the descriptions, join would be complex, multiple queries would be slow
|
||||
$descriptions = $this->_values[$table];
|
||||
|
|
Loading…
Reference in a new issue