Annotation of embedaddon/php/ext/mysqli/tests/mysqli_set_local_infile_handler_kill_link.phpt, revision 1.1
1.1 ! misho 1: --TEST--
! 2: mysqli_set_local_infile_handler() - kill database link
! 3: --SKIPIF--
! 4: <?php
! 5: require_once('skipif.inc');
! 6: require_once('skipifemb.inc');
! 7: require_once('skipifconnectfailure.inc');
! 8:
! 9: if (!function_exists('mysqli_set_local_infile_handler'))
! 10: die("skip - function not available.");
! 11:
! 12: require_once('connect.inc');
! 13: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
! 14: die("skip Cannot connect to MySQL");
! 15:
! 16: include_once("local_infile_tools.inc");
! 17: if ($msg = check_local_infile_support($link, $engine))
! 18: die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
! 19:
! 20: mysqli_close($link);
! 21: ?>
! 22: --INI--
! 23: mysqli.allow_local_infile=1
! 24: --FILE--
! 25: <?php
! 26: require("table.inc");
! 27: require_once('local_infile_tools.inc');
! 28:
! 29: function callback_kill_link($fp, &$buffer, $buflen, &$error) {
! 30: global $link;
! 31: static $invocation = 0;
! 32:
! 33: printf("Callback: %d\n", $invocation++);
! 34: flush();
! 35: if (is_object($link))
! 36: mysqli_kill($link, mysqli_thread_id($link));
! 37:
! 38: $buffer = "1;'a';\n";
! 39: if ($invocation > 10)
! 40: return 0;
! 41:
! 42: mysqli_set_local_infile_default($link);
! 43: return strlen($buffer);
! 44: }
! 45:
! 46: $file = create_standard_csv(1);
! 47: $expected = array(array('id' => 1, 'label' => 'a'));
! 48: try_handler(20, $link, $file, 'callback_kill_link', $expected);
! 49:
! 50: mysqli_close($link);
! 51: print "done!";
! 52: ?>
! 53: --CLEAN--
! 54: <?php
! 55: require_once("clean_table.inc");
! 56: ?>
! 57: --EXPECTF--
! 58: Callback set to 'callback_kill_link'
! 59: Callback: 0
! 60: [022] LOAD DATA failed, [2000] Can't execute load data local init callback function
! 61: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>