summaryrefslogtreecommitdiff
path: root/ext/pgsql/tests
diff options
context:
space:
mode:
authorYasuo Ohgaki <yohgaki@php.net>2002-04-19 12:24:58 +0000
committerYasuo Ohgaki <yohgaki@php.net>2002-04-19 12:24:58 +0000
commit825e011805584d76c2eb029b2ce9f41402e9cc29 (patch)
tree273951139d675a18ca1b242e49339da3a0cccbfd /ext/pgsql/tests
parent7a8ad061212ebd5de619e010d92e6a248f11a43a (diff)
downloadphp-git-825e011805584d76c2eb029b2ce9f41402e9cc29.tar.gz
Update tests
Diffstat (limited to 'ext/pgsql/tests')
-rw-r--r--ext/pgsql/tests/08escape.phpt6
-rw-r--r--ext/pgsql/tests/10pg_convert.phpt2
-rw-r--r--ext/pgsql/tests/11pg_metadata.phpt7
-rw-r--r--ext/pgsql/tests/escape.inc33
4 files changed, 26 insertions, 22 deletions
diff --git a/ext/pgsql/tests/08escape.phpt b/ext/pgsql/tests/08escape.phpt
index a26e0162ed..e6a8cf8731 100644
--- a/ext/pgsql/tests/08escape.phpt
+++ b/ext/pgsql/tests/08escape.phpt
@@ -7,6 +7,8 @@ PostgreSQL escape functions
include("escape.inc");
?>
--EXPECT--
-pg_escape_string() is Ok
+pg_escape_string() is NOT Ok
+string(9) "ABC\ABC\'"
+string(12) "ABC\\ABC\\''"
+string(10) "ABC\\ABC\'"
pg_escape_bytea() is Ok
-pg_escape_bytea() actually works with databse
diff --git a/ext/pgsql/tests/10pg_convert.phpt b/ext/pgsql/tests/10pg_convert.phpt
index ca54fdd50d..016c7e74d5 100644
--- a/ext/pgsql/tests/10pg_convert.phpt
+++ b/ext/pgsql/tests/10pg_convert.phpt
@@ -9,7 +9,7 @@ include("pg_convert.inc");
--EXPECT--
array(3) {
["num"]=>
- int(1234)
+ string(4) "1234"
["str"]=>
string(5) "'AAA'"
["bin"]=>
diff --git a/ext/pgsql/tests/11pg_metadata.phpt b/ext/pgsql/tests/11pg_metadata.phpt
index 08aab03a77..6e08e2c609 100644
--- a/ext/pgsql/tests/11pg_metadata.phpt
+++ b/ext/pgsql/tests/11pg_metadata.phpt
@@ -18,7 +18,7 @@ array(3) {
int(4)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
["str"]=>
@@ -31,7 +31,7 @@ array(3) {
int(-1)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
["bin"]=>
@@ -44,8 +44,7 @@ array(3) {
int(-1)
["not null"]=>
bool(false)
- ["default"]=>
+ ["has default"]=>
bool(false)
}
}
-
diff --git a/ext/pgsql/tests/escape.inc b/ext/pgsql/tests/escape.inc
index 7d65eb7391..a39e1c1621 100644
--- a/ext/pgsql/tests/escape.inc
+++ b/ext/pgsql/tests/escape.inc
@@ -32,25 +32,28 @@ else {
}
// Test using database
-$fp = fopen(FILE_NAME,'r');
+$fp = fopen(FILE_NAME,'r');
$data = fread($fp, filesize(FILE_NAME));
+$db = pg_connect($conn_str);
-$db = pg_connect($conn_str);
+// Insert binary to DB
$escaped_data = pg_escape_bytea($data);
-//$out = fopen('php.gif_escaped','w');
-//fwrite($out, $escaped_data);
-//exit;
-pg_query("DELETE FROM ".$table_name." WHERE num = -2;");
-$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-2, '".$escaped_data."');";
+pg_query("DELETE FROM ".$table_name." WHERE num = -9999;");
+$sql = "INSERT INTO ".$table_name." (num, bin) VALUES (-9999, CAST ('".$escaped_data."' AS BYTEA));";
pg_query($db, $sql);
-$sql = "SELECT * FROM ".$table_name." WHERE num = -2";
+
+// Retrieve binary from DB
+$sql = "SELECT bin::bytea FROM ".$table_name." WHERE num = -9999";
$result = pg_query($db, $sql);
-$row = pg_fetch_row($result, 0);
-if ($data === $row['bin']) {
- echo "pg_escape_bytea() actually works with databse\n";
-}
-else {
- echo "pg_escape_bytea() is broken\n";
-}
+$row = pg_fetch_array($result, 0, PGSQL_ASSOC);
+
+// Compare
+// Need to wait PostgreSQL 7.3.x for PQunescapeBytea()
+// if ($data === pg_unescape_bytea($row['bin'])) {
+// echo "pg_escape_bytea() actually works with databse\n";
+// }
+// else {
+// echo "pg_escape_bytea() is broken\n";
+// }
?>