mbeccati                                 Fri, 25 Dec 2009 20:09:08 +0000

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

Log:
- Fixed bug #50575 (PDO_PGSQL LOBs are not compatible with PostgreSQL 8.5)
# Affects 5.2 only, no need to MFB

Bug: http://bugs.php.net/50575 (Open) PDO_PGSQL LOBs are not compatible with 
PostgreSQL 8.5
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS   2009-12-25 16:34:38 UTC (rev 292628)
+++ php/php-src/branches/PHP_5_2/NEWS   2009-12-25 20:09:08 UTC (rev 292629)
@@ -6,6 +6,8 @@

 - Fixed build of mysqli with MySQL 5.5.0-m2. (Andrey)

+- Fixed bug #50575 (PDO_PGSQL LOBs are not compatible with PostgreSQL 8.5).
+  (Matteo)
 - Fixed bug #50558 (Broken object model when extending tidy). (Pierrick)
 - Fixed bug #50540 (Crash while running ldap_next_reference test cases).
   (Sriram)

Modified: php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c        
2009-12-25 16:34:38 UTC (rev 292628)
+++ php/php-src/branches/PHP_5_2/ext/pdo_pgsql/pgsql_statement.c        
2009-12-25 20:09:08 UTC (rev 292629)
@@ -472,6 +472,24 @@
  */
 static unsigned char *php_pdo_pgsql_unescape_bytea(unsigned char *strtext, 
size_t *retbuflen)
 {
+#ifdef HAVE_PQUNESCAPEBYTEA
+       size_t tmp_len;
+       char *buffer;
+       char *tmp_ptr = PQunescapeBytea(strtext, &tmp_len);
+
+       if (!tmp_ptr) {
+               /* PQunescapeBytea returned an error, this
+                  function will return en empty string */
+               tmp_len = 0;
+               buffer = emalloc(0);
+       } else {
+               buffer = emalloc(tmp_len);
+               memcpy(buffer, tmp_ptr, tmp_len);
+               PQfreemem(tmp_ptr);
+       }
+       *retbuflen = tmp_len;
+       return buffer;
+#else
        size_t          buflen;
        unsigned char *buffer,
                           *sp,
@@ -480,6 +498,7 @@

        if (strtext == NULL)
                return NULL;
+
        buflen = strlen(strtext);       /* will shrink, also we discover if
                                                                 * strtext */
        buffer = (unsigned char *) emalloc(buflen);     /* isn't NULL 
terminated */
@@ -549,6 +568,7 @@

        *retbuflen = buflen;
        return buffer;
+#endif
 }

 static int pgsql_stmt_get_col(pdo_stmt_t *stmt, int colno, char **ptr, 
unsigned long *len, int *caller_frees  TSRMLS_DC)

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

Reply via email to