]> granicus.if.org Git - php/commitdiff
Fixed bug #50195 (pg_copy_to() fails when table name contains schema).
authorIlia Alshanetsky <iliaa@php.net>
Wed, 25 Nov 2009 14:28:00 +0000 (14:28 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Wed, 25 Nov 2009 14:28:00 +0000 (14:28 +0000)
NEWS
ext/pgsql/pgsql.c

diff --git a/NEWS b/NEWS
index 653f37eee2a3a0135504994f7b8be09598f27721..35d1579bb0b032a488461c732c6a409c06307012 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -21,6 +21,7 @@ PHP                                                                        NEWS
   (Pierrick)
 - Fixed bug #50207 (segmentation fault when concatenating very large strings
   on 64bit linux). (Ilia)
+- Fixed bug #50195 (pg_copy_to() fails when table name contains schema. (Ilia)
 - Fixed bug #50185 (ldap_get_entries() return false instead of an empty array
   when there is no error). (Jani)
 - Fixed bug #50174 (Incorrectly matched docComment). (Felipe)
index ffc7eb8ea3df8db55070ab17b2b3bc9a989851c4..c5f75356362661a2dea8f24614a05dfa9455249e 100644 (file)
@@ -3341,7 +3341,11 @@ PHP_FUNCTION(pg_copy_to)
                pg_null_as = safe_estrdup("\\\\N");
        }
 
-       spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+       if (memchr(table_name, '.', table_name_len)) {
+               spprintf(&query, 0, "COPY %s TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+       } else {
+               spprintf(&query, 0, "COPY \"%s\" TO STDOUT DELIMITERS '%c' WITH NULL AS '%s'", table_name, *pg_delim, pg_null_as);
+       }
 
        while ((pgsql_result = PQgetResult(pgsql))) {
                PQclear(pgsql_result);