Skip to content

Commit fc7d6e3

Browse files
committed
Merge branch 'PHP-7.0' into PHP-7.1
* PHP-7.0: Fix bug #73498 Add a test for bug 73498
2 parents d61db8d + 58aa1a7 commit fc7d6e3

File tree

5 files changed

+30
-2
lines changed

5 files changed

+30
-2
lines changed

ext/pgsql/pgsql.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4135,7 +4135,7 @@ PHP_FUNCTION(pg_copy_to)
41354135
free_pg_null = 1;
41364136
}
41374137

4138-
spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
4138+
spprintf(&query, 0, "COPY %s TO STDOUT DELIMITER E'%c' NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
41394139

41404140
while ((pgsql_result = PQgetResult(pgsql))) {
41414141
PQclear(pgsql_result);
@@ -4268,7 +4268,7 @@ PHP_FUNCTION(pg_copy_from)
42684268
pg_null_as_free = 1;
42694269
}
42704270

4271-
spprintf(&query, 0, "COPY %s FROM STDIN DELIMITERS E'%c' WITH NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
4271+
spprintf(&query, 0, "COPY %s FROM STDIN DELIMITER E'%c' NULL AS E'%s'", table_name, *pg_delim, pg_null_as);
42724272
while ((pgsql_result = PQgetResult(pgsql))) {
42734273
PQclear(pgsql_result);
42744274
}

ext/pgsql/tests/01createdb.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ else {
2929
echo pg_last_error()."\n";
3030
}
3131

32+
// Create view here
33+
pg_query($db,$view_def);
34+
3235
pg_close($db);
3336

3437
echo "OK";

ext/pgsql/tests/06_bug73498.phpt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--TEST--
2+
Bug 73498 Incorrect DELIMITER syntax for pg_copy_to()
3+
--SKIPIF--
4+
<?php include("skipif.inc"); ?>
5+
--FILE--
6+
<?php
7+
8+
include('config.inc');
9+
10+
$db = pg_connect($conn_str);
11+
12+
$rows = pg_copy_to($db, "(select * from {$view_name})");
13+
14+
var_dump(gettype($rows));
15+
var_dump(count($rows) > 0);
16+
17+
?>
18+
--EXPECT--
19+
string(5) "array"
20+
bool(true)

ext/pgsql/tests/9999dropdb.phpt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ PostgreSQL drop db
99
include('config.inc');
1010

1111
$db = pg_connect($conn_str);
12+
pg_query($db, "DROP VIEW {$view_name}");
1213
pg_query($db, "DROP TABLE ".$table_name);
1314
@pg_query($db, "DROP TABLE ".$table_name_92);
1415

ext/pgsql/tests/config.inc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ $table_name = "php_pgsql_test"; // test table that will be created
1111
$table_name_92 = "php_pgsql_test_92"; // test table that will be created
1212
$num_test_record = 1000; // Number of records to create
1313

14+
// Test view
15+
$view_name = "php_pgsql_viewtest";
16+
$view_def = "CREATE VIEW {$view_name} AS SELECT * FROM {$table_name};";
17+
1418
// Test table
1519
$table_def = "CREATE TABLE ${table_name} (num int, str text, bin bytea);";
1620
$table_def_92 = "CREATE TABLE ${table_name_92} (textary text[], jsn json);";

0 commit comments

Comments
 (0)