iliaa                                    Wed, 25 Nov 2009 14:28:00 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291312

Log:
Fixed bug #50195 (pg_copy_to() fails when table name contains schema).

Bug: http://bugs.php.net/50195 (Open) pg_copy_to does not allow schema in the 
tablename argument
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/pgsql/pgsql.c
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/pgsql/pgsql.c
    U   php/php-src/trunk/ext/pgsql/pgsql.c

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS   2009-11-25 14:08:34 UTC (rev 291311)
+++ php/php-src/branches/PHP_5_2/NEWS   2009-11-25 14:28:00 UTC (rev 291312)
@@ -21,6 +21,7 @@
   (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)

Modified: php/php-src/branches/PHP_5_2/ext/pgsql/pgsql.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pgsql/pgsql.c      2009-11-25 14:08:34 UTC 
(rev 291311)
+++ php/php-src/branches/PHP_5_2/ext/pgsql/pgsql.c      2009-11-25 14:28:00 UTC 
(rev 291312)
@@ -3341,7 +3341,11 @@
                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);

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2009-11-25 14:08:34 UTC (rev 291311)
+++ php/php-src/branches/PHP_5_3/NEWS   2009-11-25 14:28:00 UTC (rev 291312)
@@ -42,6 +42,7 @@
   (Ilia, shigeru_kitazaki at cybozu dot co dot jp)
 - 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 #50140 (With default compilation option, php symbols are

Modified: php/php-src/branches/PHP_5_3/ext/pgsql/pgsql.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/pgsql/pgsql.c      2009-11-25 14:08:34 UTC 
(rev 291311)
+++ php/php-src/branches/PHP_5_3/ext/pgsql/pgsql.c      2009-11-25 14:28:00 UTC 
(rev 291312)
@@ -3764,7 +3764,11 @@
                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);

Modified: php/php-src/trunk/ext/pgsql/pgsql.c
===================================================================
--- php/php-src/trunk/ext/pgsql/pgsql.c 2009-11-25 14:08:34 UTC (rev 291311)
+++ php/php-src/trunk/ext/pgsql/pgsql.c 2009-11-25 14:28:00 UTC (rev 291312)
@@ -3763,7 +3763,11 @@
                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);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to