summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2016-11-22 00:46:03 +0100
committerAnatol Belski <ab@php.net>2016-11-22 00:46:03 +0100
commit58aa1a70a0debaaa30853e493021f5fdc8e58a7b (patch)
tree4aff0c691776030ea54658ac38964f0449c072e0
parent5e9b4c26a5e43a4c97555b69b105c265240febd2 (diff)
parent644e290fcdc228d1990d8010c807dc39af6de4d5 (diff)
downloadphp-git-58aa1a70a0debaaa30853e493021f5fdc8e58a7b.tar.gz
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6: Fix bug #73498 Add a test for bug 73498
-rw-r--r--ext/pgsql/pgsql.c4
-rw-r--r--ext/pgsql/tests/01createdb.phpt3
-rw-r--r--ext/pgsql/tests/06_bug73498.phpt20
-rw-r--r--ext/pgsql/tests/9999dropdb.phpt1
-rw-r--r--ext/pgsql/tests/config.inc4
5 files changed, 30 insertions, 2 deletions
diff --git a/ext/pgsql/pgsql.c b/ext/pgsql/pgsql.c
index 570e9ec735..46cf2fa262 100644
--- a/ext/pgsql/pgsql.c
+++ b/ext/pgsql/pgsql.c
@@ -4096,7 +4096,7 @@ PHP_FUNCTION(pg_copy_to)
free_pg_null = 1;
}
- spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
+ spprintf(&query, 0, "COPY %s TO STDOUT DELIMITER E'%c' NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
@@ -4229,7 +4229,7 @@ PHP_FUNCTION(pg_copy_from)
pg_null_as_free = 1;
}
- spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
+ spprintf(&query, 0, "COPY %s FROM STDIN DELIMITER E'%c' NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
while ((pgsql_result = PQgetResult(pgsql))) {
PQclear(pgsql_result);
}
diff --git a/ext/pgsql/tests/01createdb.phpt b/ext/pgsql/tests/01createdb.phpt
index 8f7a262841..aa2e43748f 100644
--- a/ext/pgsql/tests/01createdb.phpt
+++ b/ext/pgsql/tests/01createdb.phpt
@@ -29,6 +29,9 @@ else {
echo pg_last_error()."\n";
}
+// Create view here
+pg_query($db,$view_def);
+
pg_close($db);
echo "OK";
diff --git a/ext/pgsql/tests/06_bug73498.phpt b/ext/pgsql/tests/06_bug73498.phpt
new file mode 100644
index 0000000000..fdb2af2f97
--- /dev/null
+++ b/ext/pgsql/tests/06_bug73498.phpt
@@ -0,0 +1,20 @@
+--TEST--
+Bug 73498 Incorrect DELIMITER syntax for pg_copy_to()
+--SKIPIF--
+<?php include("skipif.inc"); ?>
+--FILE--
+<?php
+
+include('config.inc');
+
+$db = pg_connect($conn_str);
+
+$rows = pg_copy_to($db, "(select * from {$view_name})");
+
+var_dump(gettype($rows));
+var_dump(count($rows) > 0);
+
+?>
+--EXPECT--
+string(5) "array"
+bool(true)
diff --git a/ext/pgsql/tests/9999dropdb.phpt b/ext/pgsql/tests/9999dropdb.phpt
index 8cb178b2bf..80502e54b6 100644
--- a/ext/pgsql/tests/9999dropdb.phpt
+++ b/ext/pgsql/tests/9999dropdb.phpt
@@ -9,6 +9,7 @@ PostgreSQL drop db
include('config.inc');
$db = pg_connect($conn_str);
+pg_query($db, "DROP VIEW {$view_name}");
pg_query($db, "DROP TABLE ".$table_name);
@pg_query($db, "DROP TABLE ".$table_name_92);
diff --git a/ext/pgsql/tests/config.inc b/ext/pgsql/tests/config.inc
index 7be1e242ad..fbe58588a2 100644
--- a/ext/pgsql/tests/config.inc
+++ b/ext/pgsql/tests/config.inc
@@ -11,6 +11,10 @@ $table_name = "php_pgsql_test"; // test table that will be created
$table_name_92 = "php_pgsql_test_92"; // test table that will be created
$num_test_record = 1000; // Number of records to create
+// Test view
+$view_name = "php_pgsql_viewtest";
+$view_def = "CREATE VIEW {$view_name} AS SELECT * FROM {$table_name};";
+
// Test table
$table_def = "CREATE TABLE ${table_name} (num int, str text, bin bytea);";
$table_def_92 = "CREATE TABLE ${table_name_92} (textary text[], jsn json);";