Skip to content

Commit 23f4da9

Browse files
author
Ilia Alshanetsky
committed
Fixed bug #50195 (pg_copy_to() fails when table name contains schema).
1 parent bf7ed5e commit 23f4da9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ PHP NEWS
4242
(Ilia, shigeru_kitazaki at cybozu dot co dot jp)
4343
- Fixed bug #50207 (segmentation fault when concatenating very large strings on
4444
64bit linux). (Ilia)
45+
- Fixed bug #50195 (pg_copy_to() fails when table name contains schema. (Ilia)
4546
- Fixed bug #50185 (ldap_get_entries() return false instead of an empty array
4647
when there is no error). (Jani)
4748
- Fixed bug #50140 (With default compilation option, php symbols are

ext/pgsql/pgsql.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3764,7 +3764,11 @@ PHP_FUNCTION(pg_copy_to)
37643764
pg_null_as = safe_estrdup("\\\\N");
37653765
}
37663766

3767-
spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
3767+
if (memchr(table_name, '.', table_name_len)) {
3768+
spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
3769+
} else {
3770+
spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
3771+
}
37683772

37693773
while ((pgsql_result = PQgetResult(pgsql))) {
37703774
PQclear(pgsql_result);

0 commit comments

Comments
 (0)