Added index hints for SQL Server. Improvements to existing query hints for Mysql and Cubrid.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9481 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-10-04 13:19:45 +00:00
parent eaa1a02adc
commit 3815aece09
19 changed files with 320 additions and 6 deletions

View file

@ -0,0 +1,64 @@
<?php
class MssqlIndexHintTest extends MssqlTest {
var $xmlPath = 'data/';
function MssqlIndexHintTest(){
$this->xmlPath = str_replace('MssqlIndexHintTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function _test($xml_file, $argsString, $expected){
$this->_testQuery($xml_file, $argsString, $expected, 'getSelectSql');
}
function testOneUseIndexHintAndOneTable(){
$xml_file = $this->xmlPath . "one_index_hint_one_table.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]))';
$this->_test($xml_file, $argsString, $expected);
}
function testTwoUseIndexHintsAndOneTable(){
$xml_file = $this->xmlPath . "two_index_hints_one_table.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]), index([idx_member_srl]))';
$this->_test($xml_file, $argsString, $expected);
}
function testThreeUseIndexHintsAndTwoTables(){
$xml_file = $this->xmlPath . "three_index_hints_two_tables.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]), index([idx_member_srl]))
, [xe_document] as [document] with(index([idx_document_srl]))';
$this->_test($xml_file, $argsString, $expected);
}
/**
* Tests that index is added if "for" attribute is "ALL"
*
* example: <index_hint for="ALL"> ... </index_hint>
*/
function testIndexHintForAll(){
$xml_file = $this->xmlPath . "index_hint_for_all.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member] with(index([idx_member_list_order]))';
$this->_test($xml_file, $argsString, $expected);
}
function testIgnoreIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "ignore_index_hint.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member]';
$this->_test($xml_file, $argsString, $expected);
}
function testMysqlIndexHintIsSkipped(){
$xml_file = $this->xmlPath . "mysql_index_hint.xml";
$argsString = '';
$expected = 'select * from [xe_member] as [member]';
$this->_test($xml_file, $argsString, $expected);
}
}
?>

View file

@ -0,0 +1,11 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -0,0 +1,11 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="ALL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -0,0 +1,11 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MYSQL">
<index table="member" name="idx_member_list_order" type="IGNORE" />
</index_hint>
</query>

View file

@ -0,0 +1,11 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
</index_hint>
</query>

View file

@ -0,0 +1,14 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
<table name="document" alias="document" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
<index table="document" name="idx_document_srl" type="USE" />
</index_hint>
</query>

View file

@ -0,0 +1,12 @@
<query id="index_hint" action="select">
<tables>
<table name="member" alias="member" />
</tables>
<columns>
<column name="*" />
</columns>
<index_hint for="MSSQL">
<index table="member" name="idx_member_list_order" type="USE" />
<index table="member" name="idx_member_srl" type="USE" />
</index_hint>
</query>