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

<name>attribute updates</name>

<config>
indexer
{
	mem_limit		= 16M
}

searchd
{
	<searchd_settings/>
}

source src
{
	type			= mysql
	<sql_settings/>
	sql_query = SELECT id, adtext, heading, postcode, lng, lat, section, make_id, transmission_id FROM test_table

	sql_attr_float	= lng
	sql_attr_float	= lat
	sql_attr_uint	= section
	sql_attr_uint	= make_id
	sql_attr_uint	= transmission_id
}

index idx
{
	source			= src
	path			= <data_path/>/main
    charset_type 	= utf-8
    docinfo			= extern
}

</config>

<custom_test><![CDATA[
$results = array ();

// update that block
for ( $i = 0; $i < 4; $i++)
{
	$results[] = sprintf( "iteration=%d", $i );
	
	$up = $client->UpdateAttributes ( "idx", array("section", "make_id"), array(1=>array(4, 15), 3=>array(221, 31)));
	if ( $up >= 0 )
		$results[] = sprintf("up.ok=%d", $up);
	else	
		$results[] = sprintf("up.err=%s", $client->GetLastError());
		
	StopSearchd ( 'config.conf', 'searchd.pid' );
	
	usleep ( 50000 );
	
	$error = "";
	$startSta = StartSearchd ( 'config.conf', 'error.txt', 'searchd.pid', $error );
	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 ( "Corsa4" );

// final fixup; we don't want to compare times
for ( $i=0; $i<count($results); $i++ )
	if ( is_array($results[$i]) )
		unset ( $results[$i]["time"] );

]]></custom_test>

  <DB_Create>
CREATE TABLE `test_table` (
  `id` int(11) NOT NULL auto_increment,
  `section` int(11) NOT NULL,
  `system_id` tinyint(4) NOT NULL,
  `adtext` varchar(255) NOT NULL,
  `heading` varchar(500) NOT NULL,
  `price` int(11) NOT NULL default '0',
  `postcode` varchar(10) NOT NULL,
  `gre` int(11) NOT NULL,
  `grn` int(11) NOT NULL,
  `str_at1` varchar(255) NOT NULL,
  `str_at2` varchar(255) NOT NULL,
  `str_at3` varchar(255) NOT NULL,
  `str_at4` varchar(255) NOT NULL,
  `str_at5` varchar(255) NOT NULL,
  `int_at1` int(11) default NULL,
  `int_at2` int(11) default NULL,
  `int_at3` int(11) default NULL,
  `int_at4` int(11) default NULL,
  `int_at5` int(11) default NULL,
  `float_at1` float default NULL,
  `float_at2` float default NULL,
  `float_at3` float default NULL,
  `lng` float NOT NULL default '0',
  `lat` float NOT NULL default '0',
  `make_id` int(11) NOT NULL,
  `transmission_id` tinyint(4) NOT NULL,
  PRIMARY KEY  (`id`)
)
  </DB_Create>

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

  <DB_Insert>
INSERT INTO `test_table` (`id`, `section`, `system_id`, `adtext`, `heading`, `price`, `postcode`, `gre`, `grn`, `str_at1`, `str_at2`, `str_at3`, `str_at4`, `str_at5`, `int_at1`, `int_at2`, `int_at3`, `int_at4`, `int_at5`, `float_at1`, `float_at2`, `float_at3`, `lng`, `lat`, `make_id`, `transmission_id`) VALUES 
(1, 1, 2, 'FORD', 'Ford KA', 2790, 'EN3 5BT', 535000, 197400,  'Ford', 'KA', 'Grey', 'Diesel', '', 18662, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -0.1798578, 0.937717, 8, 1),
(2, 1, 3, 'FORDE', 'Vauxhall Corsa1', 5800, 'BN42 4RN', 524000, 106100, 'Vauxhall', 'Corsa', 'Red', 'Petrol', '', 19296, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -0.2799989, 0.891975, 7, 2),
(3, 1, 4, 'FORDZ', 'Vauxhall Corsa2', 5200, 'BN42 4RN', 524000, 106100, 'Vauxhall', 'Corsa', 'Red', 'Petrol', '', 19296, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -0.3799989, 0.791975, 6, 3),
(4, 1, 5, 'FORDT', 'Vauxhall Corsa4', 3800, 'BN42 4N', 524000, 106100, 'Vauxhall', 'Corsa', 'Red', 'Petrol', '', 19296, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -0.4799989, 0.691975, 5, 4),
(211250, 0, 1, 'Quattro Roadster', 'Audi TT', 13995, 'E9 7DG', 535600, 184200, '', '', '', '', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, -0.5721455, 0.526761, 29, 5);
  </DB_Insert>
  
</test>
