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

<test>
<name>persistent MVA updates surviving after hard killing part 2 - *nix only</name>

<requires>
<non-windows/>
<variant_match/>
</requires>

<config>
indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
	binlog_flush = 1
	binlog_path = <data_path/>
	workers = threads
}

source src
{
	type			= mysql
	<sql_settings/>
	sql_query = SELECT id, text, section, mva1 FROM test_table
	sql_attr_uint	= section
<Dynamic>
	<Variant>sql_attr_multi = uint mva1 from field mva1</Variant>
	<Variant>sql_attr_multi = bigint mva1 from field mva1</Variant>
</Dynamic>	
}

index idx_131
{
	source			= src
	path			= <data_path/>/idx_131
    docinfo			= extern
}

index incorrectrt
{
	type = rt
	path = <data_path/>/incorrectrt
	rt_field = data
	rt_attr_uint = gid
	blend_chars = /
	exceptions = <this_test/>/exceptions.txt
}

</config>

<custom_test><![CDATA[

global $error;

$results = array ();

// update that block
for ( $i = 0; $i < 4; $i++)
{
	$results[] = sprintf( "iteration=%d", $i );

	$up = $client->UpdateAttributes ( "idx_131", array("mva1"), array(1=>array(array(2,3,4)), 3=>array(array(6,7,8))),true);
	if ( $up >= 0 )
		$results[] = sprintf("up.ok=%d", $up);
	else
		$results[] = sprintf("up.err=%s", $client->GetLastError());

	$stop = StopWaitSearchd ('config.conf', 'searchd.pid');
	$results[] = 'stoped='.($stop==0 ? 'ok' : 'err' ) . '(code=' . $stop . ')';

	$startSta = StartSearchd ( 'config.conf', 'error.txt', 'searchd.pid', $error, true );
	if ( $startSta == 0 || $startSta == 2 )
	{
		$results[] = "started=ok";
	}
	else
		$results[] = sprintf("start.err=%d local=%s client=%s", $startSta, $error, $client->GetLastError());
}

// find the updated match
$results[] = $client->Query ( "test3");

// final fixup; we don't want to compare times
for ( $i=0; $i<count($results); $i++ )
	CompareResultSetFixup ( $results[$i], 0, true );

]]></custom_test>

  <DB_Create>
CREATE TABLE `test_table` (
  `id` int(11) DEFAULT NULL,
  `text` varchar (255) NOT NULL,
  `section` int(11) DEFAULT NULL,
  `mva1` varchar(255) NOT NULL
)
  </DB_Create>

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

  <DB_Insert>
INSERT INTO `test_table` (`id`, `text`, `section`, `mva1`) VALUES
(1, 'test1', 101, '1001'),
(2, 'test2', 102, '1002 1023 4456'),
(3, 'test3', 103, '1003 1008 1010'),
(4, 'test4', 104, '1004 1005 1006');
  </DB_Insert>

</test>
