1--TEST-- 2mysqli_set_local_infile_handler() - run new query on db link 3--SKIPIF-- 4<?php 5require_once('skipif.inc'); 6require_once('skipifemb.inc'); 7require_once('skipifconnectfailure.inc'); 8 9if (!function_exists('mysqli_set_local_infile_handler')) 10 die("skip - function not available."); 11 12require_once('connect.inc'); 13if (!$TEST_EXPERIMENTAL) 14 die("skip - experimental (= unsupported) feature"); 15 16if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket)) 17 die("skip Cannot connect to MySQL"); 18 19include_once("local_infile_tools.inc"); 20if ($msg = check_local_infile_support($link, $engine)) 21 die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error)); 22 23mysqli_close($link); 24?> 25--INI-- 26mysqli.allow_local_infile=1 27--FILE-- 28<?php 29 require_once('connect.inc'); 30 require_once('local_infile_tools.inc'); 31 require_once('table.inc'); 32 33 function callback_new_query($fp, &$buffer, $buflen, &$error) { 34 global $link; 35 static $invocation = 0; 36 37 printf("Callback: %d\n", $invocation++); 38 flush(); 39 if (is_object($link)) { 40 if (!$res = mysqli_query($link, "SELECT id, label FROM test")) { 41 printf("[Callback 001 - %03d] Cannot run query, [%d] %s\n", 42 $invocation, mysqli_errno($link), mysqli_error($link)); 43 } 44 if ($res) 45 mysqli_free_result($res); 46 } 47 $buffer = "1;'a';\n"; 48 if ($invocation > 10) 49 return 0; 50 51 mysqli_set_local_infile_default($link); 52 return strlen($buffer); 53 } 54 55 $file = create_standard_csv(1); 56 $expected = array(array('id' => 1, 'label' => 'a')); 57 try_handler(20, $link, $file, 'callback_new_query', $expected); 58 59 mysqli_close($link); 60 print "done!"; 61?> 62--CLEAN-- 63<?php 64 require_once("clean_table.inc"); 65?> 66--EXPECTF-- 67Callback set to 'callback_new_query' 68Callback: 0 69[Callback 001 - 001] Cannot run query, [2014] Commands out of sync; you can't run this command now 70[022] LOAD DATA failed, [2000] Can't execute load data local init callback function 71done!