Annotation of embedaddon/php/ext/mysqli/tests/mysqli_set_local_infile_handler_negative_len.phpt, revision 1.1.1.1
1.1 misho 1: --TEST--
2: mysqli_set_local_infile_handler() - negative return value/buflen to indicate an error
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 (!$TEST_EXPERIMENTAL)
14: die("skip - experimental (= unsupported) feature");
15:
16: if (!$link = my_mysqli_connect($host, $user, $passwd, $db, $port, $socket))
17: die("skip Cannot connect to MySQL");
18:
19: include_once("local_infile_tools.inc");
20: if ($msg = check_local_infile_support($link, $engine))
21: die(sprintf("skip %s, [%d] %s", $msg, $link->errno, $link->error));
22:
23: mysqli_close($link);
24: ?>
25: --INI--
26: mysqli.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_negative_len($fp, &$buffer, $buflen, &$error) {
34: static $invocation = 0;
35:
36: printf("Callback: %d\n", $invocation);
37: $buffer = fread($fp, $buflen);
38:
39: $error = "negative length means error";
40: return -1;
41: }
42:
43: $file = create_standard_csv(1);
44: $expected = array();
45: try_handler(20, $link, $file, 'callback_negative_len', $expected);
46:
47: mysqli_close($link);
48: print "done!";
49: ?>
50: --CLEAN--
51: <?php
52: require_once("clean_table.inc");
53: ?>
54: --EXPECTF--
55: Callback set to 'callback_negative_len'
56: Callback: 0
57: [022] LOAD DATA failed, [2000] negative length means error
58: done!
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>