List:Commits« Previous MessageNext Message »
From:uwendel Date:September 13 2007 3:36pm
Subject:PHP mysqlnd svn commit: r1033 - trunk/tests/ext/mysql
View as plain text  
Author: uwendel
Date: 2007-09-13 15:36:25 +0200 (Thu, 13 Sep 2007)
New Revision: 1033

Added:
   trunk/tests/ext/mysql/mysql_query_load_data_openbasedir.phpt
Log:
Smells. But, as usual, libmysql smells more than mysqlnd.


Added: trunk/tests/ext/mysql/mysql_query_load_data_openbasedir.phpt
===================================================================
--- trunk/tests/ext/mysql/mysql_query_load_data_openbasedir.phpt	2007-09-13 11:56:08 UTC
(rev 1032)
+++ trunk/tests/ext/mysql/mysql_query_load_data_openbasedir.phpt	2007-09-13 13:36:25 UTC
(rev 1033)
@@ -0,0 +1,108 @@
+--TEST--
+LOAD DATA INFILE - open_basedir
+--SKIPIF--
+<?php
+require_once('skipif.inc');
+require_once('skipifconnectfailure.inc');
+
+if (file_exists('./simple.csv') && !unlink('./simple.csv'))
+	die("skip Cannot remove previous CSV file");
+
+if (!$fp = fopen('./simple.csv', 'w'))
+	die("skip Cannot create test CSV file");
+
+flose($fp);
+@unlink('./simple.csv');
+?>
+--INI--
+safe_mode=0
+open_basedir="."
+--FILE--
+<?php
+@include_once("connect.inc");
+if (!isset($db)) {
+	// run-tests, I love you for not allowing me to set ini settings dynamically
+	print "[006] [1148] The used command is not allowed with this MySQL version
+[007] [0]
+[008] LOAD DATA not run?
+[010] [1148] The used command is not allowed with this MySQL version
+done!";
+	die();
+}
+require('table.inc');
+mysql_close($link);
+if ($socket)
+	$host = sprintf("%s:%s", $host, $socket);
+else if ($port)
+	$host = sprintf("%s:%s", $host, $port);
+
+if (!$link = mysql_connect($host, $user, $passwd, true, 128)) {
+	printf("[001] Cannot connect using host '%s', user '%s', password '****', [%d] %s\n",
+		$host, $user, $passwd,
+		mysql_errno(), mysql_error());
+}
+
+if (!mysql_select_db($db, $link)) {
+	printf("[002] [%d] %s\n", mysql_errno($link), mysql_error($link));
+}
+
+if (file_exists('./simple.csv'))
+	unlink('./simple.csv');
+
+if (!$fp = fopen('./simple.csv', 'w'))
+	printf("[003] Cannot open CSV file\n");
+
+if (ini_get('unicode.semantics')) {
+	if (!fwrite($fp, (binary)"'97';'x';\n") ||
+		!fwrite($fp, (binary)"'98';'y';\n") ||
+		!fwrite($fp, (binary)"99;'z';\n")) {
+		printf("[004] Cannot write CVS file '%s'\n", $file);
+	}
+} else {
+	if (!fwrite($fp, "97;'x';\n") ||
+		!fwrite($fp, "98;'y';\n") ||
+		!fwrite($fp, "99;'z';\n")) {
+		printf("[005] Cannot write CVS file '%s'\n", $file);
+	}
+}
+fclose($fp);
+
+$sql = sprintf("LOAD DATA LOCAL INFILE '%s'
+			INTO TABLE test
+			FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+			LINES TERMINATED BY '\n'",
+			mysql_real_escape_string(realpath('./simple.csv'), $link));
+
+if (!mysql_query($sql, $link))
+	printf("[006] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+if (!($res = mysql_query('SELECT label FROM test WHERE id = 97', $link)) ||
+		!($row = mysql_fetch_assoc($res)) ||
+		!mysql_free_result($res))
+	printf("[007] [%d] '%s'\n", mysql_errno($link), mysql_error($link));
+
+if ($row['label'] != "x")
+	printf("[008] LOAD DATA not run?\n");
+
+if (!mysql_query('DELETE FROM test', $link))
+	printf("[009] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+$sql = "LOAD DATA LOCAL INFILE '/tmp/idonotexist'
+			INTO TABLE test
+			FIELDS TERMINATED BY ';' OPTIONALLY ENCLOSED BY '\''
+			LINES TERMINATED BY '\n'";
+
+if (!mysql_query($sql, $link))
+	printf("[010] [%d] %s\n", mysql_errno($link), mysql_error($link));
+
+mysql_close($link);
+unlink("./simple.csv");
+
+print "done!";
+?>
+--EXPECTF--
+[006] [1148] %s
+[007] [0] ''
+[008] LOAD DATA not run?
+[010] [1148] %s
+done!
\ No newline at end of file

Thread
PHP mysqlnd svn commit: r1033 - trunk/tests/ext/mysqluwendel13 Sep