mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-05-10 12:32:14 +09:00
add priority_hint to mysql
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9485 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
cc7477d4e3
commit
055b7e0d68
4 changed files with 30 additions and 9 deletions
|
|
@ -583,9 +583,10 @@
|
||||||
return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
return $select . ' ' . $from . ' ' . $where . ' ' . $index_hint_list . ' ' . $groupBy . ' ' . $orderBy . ' ' . $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDeleteSql($query, $with_values = true){
|
function getDeleteSql($query, $with_values = true, $with_priority = false){
|
||||||
$sql = 'DELETE ';
|
$sql = 'DELETE ';
|
||||||
|
|
||||||
|
$sql .= $with_priority?$query->getPriority():'';
|
||||||
$tables = $query->getTables();
|
$tables = $query->getTables();
|
||||||
|
|
||||||
$sql .= $tables[0]->getAlias();
|
$sql .= $tables[0]->getAlias();
|
||||||
|
|
@ -600,7 +601,7 @@
|
||||||
return $sql;
|
return $sql;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getUpdateSql($query, $with_values = true){
|
function getUpdateSql($query, $with_values = true, $with_priority = false){
|
||||||
$columnsList = $query->getUpdateString($with_values);
|
$columnsList = $query->getUpdateString($with_values);
|
||||||
if($columnsList == '') return new Object(-1, "Invalid query");
|
if($columnsList == '') return new Object(-1, "Invalid query");
|
||||||
|
|
||||||
|
|
@ -609,15 +610,18 @@
|
||||||
|
|
||||||
$where = $query->getWhereString($with_values);
|
$where = $query->getWhereString($with_values);
|
||||||
if($where != '') $where = ' WHERE ' . $where;
|
if($where != '') $where = ' WHERE ' . $where;
|
||||||
|
|
||||||
|
$priority = $with_priority?$query->getPriority():'';
|
||||||
|
|
||||||
return "UPDATE $tableName SET $columnsList ".$where;
|
return "UPDATE $priority $tableName SET $columnsList ".$where;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getInsertSql($query, $with_values = true){
|
function getInsertSql($query, $with_values = true, $with_priority = false){
|
||||||
$tableName = $query->getFirstTableName();
|
$tableName = $query->getFirstTableName();
|
||||||
$values = $query->getInsertString($with_values);
|
$values = $query->getInsertString($with_values);
|
||||||
|
$priority = $with_priority?$query->getPriority():'';
|
||||||
return "INSERT INTO $tableName \n $values";
|
|
||||||
|
return "INSERT $priority INTO $tableName \n $values";
|
||||||
}
|
}
|
||||||
|
|
||||||
function _getSlaveConnectionStringIndex() {
|
function _getSlaveConnectionStringIndex() {
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@
|
||||||
//$priority = '';
|
//$priority = '';
|
||||||
//if($output->priority) $priority = $output->priority['type'].'_priority';
|
//if($output->priority) $priority = $output->priority['type'].'_priority';
|
||||||
|
|
||||||
$query = $this->getInsertSql($queryObject);
|
$query = $this->getInsertSql($queryObject, true, true);
|
||||||
if(is_a($query, 'Object')) return;
|
if(is_a($query, 'Object')) return;
|
||||||
return $this->_query($query);
|
return $this->_query($query);
|
||||||
}
|
}
|
||||||
|
|
@ -383,7 +383,7 @@
|
||||||
//$priority = '';
|
//$priority = '';
|
||||||
//if($output->priority) $priority = $output->priority['type'].'_priority';
|
//if($output->priority) $priority = $output->priority['type'].'_priority';
|
||||||
|
|
||||||
$query = $this->getUpdateSql($queryObject);
|
$query = $this->getUpdateSql($queryObject, true, true);
|
||||||
if(is_a($query, 'Object')) return;
|
if(is_a($query, 'Object')) return;
|
||||||
return $this->_query($query);
|
return $this->_query($query);
|
||||||
}
|
}
|
||||||
|
|
@ -392,7 +392,7 @@
|
||||||
* @brief Handle deleteAct
|
* @brief Handle deleteAct
|
||||||
**/
|
**/
|
||||||
function _executeDeleteAct($queryObject) {
|
function _executeDeleteAct($queryObject) {
|
||||||
$query = $this->getDeleteSql($queryObject);
|
$query = $this->getDeleteSql($queryObject, true, true);
|
||||||
|
|
||||||
if(is_a($query, 'Object')) return;
|
if(is_a($query, 'Object')) return;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
class Query extends Object {
|
class Query extends Object {
|
||||||
var $queryID;
|
var $queryID;
|
||||||
var $action;
|
var $action;
|
||||||
|
var $priority;
|
||||||
|
|
||||||
var $columns;
|
var $columns;
|
||||||
var $tables;
|
var $tables;
|
||||||
|
|
@ -27,6 +28,7 @@
|
||||||
, $limit = null){
|
, $limit = null){
|
||||||
$this->queryID = $queryID;
|
$this->queryID = $queryID;
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
|
$this->priority = $priority;
|
||||||
|
|
||||||
if(!isset($tables)) return;
|
if(!isset($tables)) return;
|
||||||
$this->columns = $this->setColumns($columns);
|
$this->columns = $this->setColumns($columns);
|
||||||
|
|
@ -48,6 +50,10 @@
|
||||||
function setAction($action){
|
function setAction($action){
|
||||||
$this->action = $action;
|
$this->action = $action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function setPriority($priority){
|
||||||
|
$this->priority = $priority;
|
||||||
|
}
|
||||||
|
|
||||||
function setColumnList($columnList){
|
function setColumnList($columnList){
|
||||||
$this->columnList = $columnList;
|
$this->columnList = $columnList;
|
||||||
|
|
@ -152,6 +158,10 @@
|
||||||
function getAction(){
|
function getAction(){
|
||||||
return $this->action;
|
return $this->action;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPriority(){
|
||||||
|
return $this->priority?'LOW_PRIORITY':'';
|
||||||
|
}
|
||||||
|
|
||||||
function getSelectString($with_values = true){
|
function getSelectString($with_values = true){
|
||||||
foreach($this->columns as $column){
|
foreach($this->columns as $column){
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
class QueryTag {
|
class QueryTag {
|
||||||
var $action;
|
var $action;
|
||||||
var $query_id;
|
var $query_id;
|
||||||
|
var $priority;
|
||||||
var $column_type;
|
var $column_type;
|
||||||
var $query;
|
var $query;
|
||||||
|
|
||||||
|
|
@ -23,6 +24,7 @@ class QueryTag {
|
||||||
function QueryTag($query, $isSubQuery = false){
|
function QueryTag($query, $isSubQuery = false){
|
||||||
$this->action = $query->attrs->action;
|
$this->action = $query->attrs->action;
|
||||||
$this->query_id = $query->attrs->id;
|
$this->query_id = $query->attrs->id;
|
||||||
|
$this->priority = $query->attrs->priority;
|
||||||
$this->query = $query;
|
$this->query = $query;
|
||||||
$this->isSubQuery = $isSubQuery;
|
$this->isSubQuery = $isSubQuery;
|
||||||
if($this->isSubQuery) $this->action = 'select';
|
if($this->isSubQuery) $this->action = 'select';
|
||||||
|
|
@ -46,6 +48,10 @@ class QueryTag {
|
||||||
function getQueryId(){
|
function getQueryId(){
|
||||||
return $this->query->attrs->query_id ? $this->query->attrs->query_id : $this->query->attrs->id;
|
return $this->query->attrs->query_id ? $this->query->attrs->query_id : $this->query->attrs->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPriority(){
|
||||||
|
return $this->query->attrs->priority;
|
||||||
|
}
|
||||||
|
|
||||||
function getAction(){
|
function getAction(){
|
||||||
return $this->query->attrs->action;
|
return $this->query->attrs->action;
|
||||||
|
|
@ -124,6 +130,7 @@ class QueryTag {
|
||||||
$buff .= '$query = new Query();'.PHP_EOL;
|
$buff .= '$query = new Query();'.PHP_EOL;
|
||||||
$buff .= sprintf('$query->setQueryId("%s");%s', $this->query_id, "\n");
|
$buff .= sprintf('$query->setQueryId("%s");%s', $this->query_id, "\n");
|
||||||
$buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n");
|
$buff .= sprintf('$query->setAction("%s");%s', $this->action, "\n");
|
||||||
|
$buff .= sprintf('$query->setPriority("%s");%s', $this->priority, "\n");
|
||||||
$buff .= $this->preBuff;
|
$buff .= $this->preBuff;
|
||||||
if($this->columns)
|
if($this->columns)
|
||||||
$buff .= '$query->setColumns(' . $this->columns->toString() . ');'.PHP_EOL;
|
$buff .= '$query->setColumns(' . $this->columns->toString() . ');'.PHP_EOL;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue