]> 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)
ext/pgsql/pgsql.c

index 6e76dfa9bf801701a06adfff63c9b0b4b21bc30d..7b4152631808355e4a7d377d416706a60b8a6dd7 100644 (file)
@@ -3763,7 +3763,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);