<?xml version="1.0" encoding="utf-8"?>
<test>

<name>MVA and string via MySQL</name>

<requires> <variant_match /> </requires>

<config>
indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
}

source srcmain
{
	type			= mysql
	<sql_settings/>

	sql_query		= SELECT * FROM test_table
	sql_attr_uint	= idd
	sql_attr_string	= str1
	sql_attr_uint	= tag
<Dynamic>	
<Variant>
	sql_attr_multi = uint mva1 from field
	sql_attr_string	= str2
	sql_attr_multi = uint mva2 from field
</Variant>	
<Variant>
	sql_attr_multi = bigint mva1 from field
	sql_attr_string	= str2
	sql_attr_multi = bigint mva2 from field
</Variant>	
</Dynamic>	
}

index main
{
	source			= srcmain
	path			= <data_path/>/main140
}

source src_mva_64
{
	type			= mysql
	<sql_settings/>

	sql_query		= SELECT * FROM mva_64
	sql_attr_uint	= idd
	sql_attr_multi = bigint mva1 from field
}

index mva_64
{
	source			= src_mva_64
	path			= <data_path/>/mva_64
}

source src_groupby_64
{
	type			= mysql
	<sql_settings/>

	sql_query		= SELECT *, 1 as idd, 'dummy' as body FROM groupby_64
	sql_attr_uint	= idd
	sql_attr_multi = bigint mva1 from field
}

index groupby_64
{
	source			= src_groupby_64
	path			= <data_path/>/groupby_64
}

</config>

<sphqueries>
<sphinxql>select * from main order by idd asc</sphinxql>
<sphinxql>select * from main where match('main') order by idd asc</sphinxql>
<sphinxql>select * from main where match('delta') order by idd asc</sphinxql>
<sphinxql>select * from main where match('main | delta') order by idd asc</sphinxql>

<sphinxql>select * from mva_64</sphinxql>
<sphinxql>select * from mva_64 where mva1=-2099511627775 </sphinxql>
<sphinxql>select * from mva_64 where mva1=55599511627775 </sphinxql>
<sphinxql><![CDATA[ select * from mva_64 where mva1<-10 ]]></sphinxql>
<sphinxql><![CDATA[ select * from mva_64 where mva1<-1099511627775 ]]></sphinxql>
<sphinxql><![CDATA[ select * from mva_64 where mva1>50099511627775 ]]></sphinxql>

<!-- regression mva64 groupby was cut at 32bit -->
<sphinxql>select * from groupby_64</sphinxql>
<sphinxql>select * from groupby_64 group by mva1</sphinxql>
</sphqueries>

<queries>
<query index="mva_64"></query>
<query filter_value="-2099511627775" filter="mva1" index="mva_64"></query>
<query filter_value="55599511627775" filter="mva1" index="mva_64"></query>
<query filter_range="-3000000000000 -10" filter="mva1" index="mva_64"></query>
<query filter_range="-3000000000000 -1099511627776" filter="mva1" index="mva_64"></query>
<query filter_range="50099511627776 600000000000000" filter="mva1" index="mva_64"></query>
</queries>

<db_create>
CREATE TABLE `test_table`
(
	`document_id` int(11) NOT NULL default '0',
	`idd` int(11) NOT NULL default '0',
	`tag` int(11) NOT NULL default '0',
	`mva1` varchar(255) NOT NULL default '',
	`mva2` varchar(255) NOT NULL default '',
	`body` varchar(255) NOT NULL default '',
	`str1` varchar(255) NOT NULL default '',
	`str2` varchar(255) NOT NULL default ''
)
</db_create>

<db_drop>
DROP TABLE IF EXISTS `test_table`
</db_drop>

<db_insert>
INSERT INTO `test_table` VALUES
( 1, 1, 1, '',			'1 2 3','main and delta', 'some attribute', 'more data are here' ),
( 2, 2, 0, '2 22 222',	'',		'main and delta' , 'is it sunny', ''),
( 3, 3, 0, '3 33 333',	'5 6 7','main and delta' , '', 'cool place' ),
( 4, 4, 1, '', 			'',		'delta', '', '' ),
( 5, 5, 1, '', 			'',		'delta', 'good stuff', 'step ahead' ),
( 6, 6, 0, '6', 		'',		'delta', 'reality real', 'reality augumented' ),
( 7, 7, 1, '7', 		'',		'main', 'how its going', 'well' ),
( 8, 8, 1, '8',			'',		'main', 'its going...', '?!?!?!' ),
( 9, 9, 0, '1 10 100',	'9 0 1','delta', '', '' ),
(10, 10, 0, '2 20 200',	'',	 	'delta', '', 'a' ),
(11, 11, 0, '',			'',		'delta', 'b', '' )
</db_insert>

<db_create>
CREATE TABLE `mva_64`
(
	`id` int(11) NOT NULL default '0',
	`idd` int(11) NOT NULL default '0',
	`mva1` varchar(255) NOT NULL default '',
	`body` varchar(255) NOT NULL default ''
)
</db_create>

<db_drop>DROP TABLE IF EXISTS `mva_64`</db_drop>

<db_insert>
INSERT INTO `mva_64` VALUES
( 100,	1,	'1099511627775		50099511627775	-1099511627775		2099511627775',	'dummy' ),
( 200,	1,	'50099511627775	11099511627775	501099511627775	-2099511627775',	'dummy' ),
( 300,	2,	'-1099511627775	50099511627775	50099511627772	-2099511627771',	'dummy' ),
( 400,	2,	'-1099511627775	50099511627771	-1099511627775		55599511627775',	'dummy' )
</db_insert>

<db_create>
CREATE TABLE `groupby_64`
(
	`id` int(11) NOT NULL default '0',
	`mva1` varchar(255) NOT NULL default ''
)
</db_create>

<db_drop>DROP TABLE IF EXISTS `groupby_64`</db_drop>

<db_insert>
INSERT INTO `groupby_64` VALUES
( 100,	'281474992439296' ),
( 200,	'844424945860608' ),
( 300,	'1970324852703232' ),
( 400,	'281474992439296 	1970324852703232' )
</db_insert>

</test>
