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

<name>SQL-compliant result set vs max_matches</name>

<config>
indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
	compat_sphinxql_magics = 0
}

source test1
{
	type			= mysql
	<sql_settings/>
	sql_query		= select id, gid, gid as a, title from test_table
	sql_attr_uint	= gid
	sql_attr_uint	= a
}

source test2 : test1
{
	sql_query		= select id+10, gid, gid as b, title from test_table
	sql_attr_uint	= gid
	sql_attr_uint	= b
}


source test3 : test1
{
	sql_query		= select id+20, gid, gid+1 as c, gid+2 as b, title from test_table
	sql_attr_uint	= gid
	sql_attr_uint	= c
	sql_attr_uint	= b
}

source test4 : test1
{
	sql_query		= select id+30, gid, gid+3 as d, gid+5 as b, title from test_table
	sql_attr_uint	= gid
	sql_attr_uint	= d
	sql_attr_uint	= b
}

index test1
{
	source			= test1
	path			= <data_path/>/test1
}

index test2
{
	source			= test2
	path			= <data_path/>/test2
}

index test3
{
	source			= test3
	path			= <data_path/>/test3
}

index test4
{
	source			= test4
	path			= <data_path/>/test4
}

index dist1
{
	type			= distributed
	local			= test1
	local			= test2
}

index dist2
{
	type			= distributed
	local			= test2
	local			= test3
}

index dist3
{
	type			= distributed
	local			= test2
	agent			= <my_address/>:idx52
	local			= test4
	agent_connect_timeout	= 1000
	agent_query_timeout	= 3000
}
</config>

<db_create>
create table test_table
(
	id int not null,
	gid int not null,
	title varchar(255) not null
);
</db_create>
<db_drop>drop table if exists test_table;</db_drop>
<db_insert>insert into test_table values ( 1, 123, 'hello world' );</db_insert>
<db_insert>insert into test_table values ( 2, 123, 'hello world' );</db_insert>
<db_insert>insert into test_table values ( 3, 123, 'hello world' );</db_insert>

<sphqueries>
<sphinxql>select gid from dist1 where match('hello') option max_matches=2</sphinxql>
<sphinxql>select b from dist2 where match('hello') option max_matches=2</sphinxql>
<sphinxql>select b from dist3 where match('hello') option max_matches=2</sphinxql>
<!-- regression crash at option named list -->
<sphinxql>select id, gid from dist1 where match('hello') option field_weights=(none1=1000, title=1)</sphinxql>
</sphqueries>

</test>
