]> granicus.if.org Git - php/commitdiff
- Fixed bug #50575 (PDO_PGSQL LOBs are not compatible with PostgreSQL 8.5)
authorMatteo Beccati <mbeccati@php.net>
Fri, 25 Dec 2009 20:09:08 +0000 (20:09 +0000)
committerMatteo Beccati <mbeccati@php.net>
Fri, 25 Dec 2009 20:09:08 +0000 (20:09 +0000)
# Affects 5.2 only, no need to MFB

NEWS
ext/pdo_pgsql/pgsql_statement.c

diff --git a/NEWS b/NEWS
index e43bfe841d2651858367bf20ef299b754712b88a..7ec8926a4573b74044f083cfaf01348ab3a00091 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,8 @@ PHP                                                                        NEWS
 
 - 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)
index fbfdde1c07b22adba5d703a61ea493340fc90229..9985b2a25390e8cfc90c157f1d94bae2cb044207 100644 (file)
@@ -472,6 +472,24 @@ static int pgsql_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC)
  */
 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 @@ static unsigned char *php_pdo_pgsql_unescape_bytea(unsigned char *strtext, size_
 
        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 @@ static unsigned char *php_pdo_pgsql_unescape_bytea(unsigned char *strtext, size_
 
        *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)