mirror of
https://github.com/php/php-src.git
synced 2025-01-15 16:24:37 +08:00
Merge branch 'PHP-7.1'
* PHP-7.1: Fix bug #73498 Add a test for bug 73498
This commit is contained in:
commit
6bf85617c5
@ -4121,7 +4121,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);
|
||||
@ -4254,7 +4254,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);
|
||||
}
|
||||
|
@ -29,6 +29,9 @@ else {
|
||||
echo pg_last_error()."\n";
|
||||
}
|
||||
|
||||
// Create view here
|
||||
pg_query($db,$view_def);
|
||||
|
||||
pg_close($db);
|
||||
|
||||
echo "OK";
|
||||
|
20
ext/pgsql/tests/06_bug73498.phpt
Normal file
20
ext/pgsql/tests/06_bug73498.phpt
Normal file
@ -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)
|
@ -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);
|
||||
|
||||
|
@ -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);";
|
||||
|
Loading…
Reference in New Issue
Block a user