]> granicus.if.org Git - php/commitdiff
Update tests
authorYasuo Ohgaki <yohgaki@php.net>
Fri, 19 Apr 2002 12:24:58 +0000 (12:24 +0000)
committerYasuo Ohgaki <yohgaki@php.net>
Fri, 19 Apr 2002 12:24:58 +0000 (12:24 +0000)
ext/pgsql/tests/08escape.phpt
ext/pgsql/tests/10pg_convert.phpt
ext/pgsql/tests/11pg_metadata.phpt
ext/pgsql/tests/escape.inc

index a26e0162ed6e4d355572abc64474d92c374207ee..e6a8cf8731274cfc2e6d532ba0680efd9988fe95 100644 (file)
@@ -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
index ca54fdd50da7d6592ef88a028f1c166350f6063c..016c7e74d58f72ccddc6d6e4ba8ba5ef9887ba00 100644 (file)
@@ -9,7 +9,7 @@ include("pg_convert.inc");
 --EXPECT--
 array(3) {
   ["num"]=>
-  int(1234)
+  string(4) "1234"
   ["str"]=>
   string(5) "'AAA'"
   ["bin"]=>
index 08aab03a7706c657f3c294d6273663e99caf0567..6e08e2c609195a819846ea33f7802f40e1b6b7b8 100644 (file)
@@ -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)
   }
 }
-
index 7d65eb7391a3653c7125bc88c684f9118a871146..a39e1c16211326a16b2f065a49199fa35d0182ef 100644 (file)
@@ -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";
+// }
 
 ?>