Skip to content

Commit 58aa1a7

Browse files
committed
Merge branch 'PHP-5.6' into PHP-7.0
* PHP-5.6: Fix bug #73498 Add a test for bug 73498
2 parents 5e9b4c2 + 644e290 commit 58aa1a7

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
@@ -4096,7 +4096,7 @@ PHP_FUNCTION(pg_copy_to)
40964096
free_pg_null = 1;
40974097
}
40984098

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

41014101
while ((pgsql_result = PQgetResult(pgsql))) {
41024102
PQclear(pgsql_result);
@@ -4229,7 +4229,7 @@ PHP_FUNCTION(pg_copy_from)
42294229
pg_null_as_free = 1;
42304230
}
42314231

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

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)