felipe          Mon Oct 13 13:46:25 2008 UTC

  Added files:                 (Branch: PHP_5_2)
    /php-src/ext/pgsql/tests    bug37100.phpt 

  Modified files:              
    /php-src/ext/pgsql  pgsql.c 
  Log:
  MFH:
  - Fixed bug #37100 (data is returned truncated with BINARY CURSOR)
    Patch by Tony
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/pgsql.c?r1=1.331.2.13.2.29&r2=1.331.2.13.2.30&diff_format=u
Index: php-src/ext/pgsql/pgsql.c
diff -u php-src/ext/pgsql/pgsql.c:1.331.2.13.2.29 
php-src/ext/pgsql/pgsql.c:1.331.2.13.2.30
--- php-src/ext/pgsql/pgsql.c:1.331.2.13.2.29   Tue Oct  7 14:35:04 2008
+++ php-src/ext/pgsql/pgsql.c   Mon Oct 13 13:46:25 2008
@@ -20,7 +20,7 @@
    +----------------------------------------------------------------------+
  */
  
-/* $Id: pgsql.c,v 1.331.2.13.2.29 2008/10/07 14:35:04 iliaa Exp $ */
+/* $Id: pgsql.c,v 1.331.2.13.2.30 2008/10/13 13:46:25 felipe Exp $ */
 
 #include <stdlib.h>
 
@@ -1983,10 +1983,9 @@
        if (PQgetisnull(pgsql_result, pgsql_row, field_offset)) {
                Z_TYPE_P(return_value) = IS_NULL;
        } else {
-               Z_STRVAL_P(return_value) = PQgetvalue(pgsql_result, pgsql_row, 
field_offset);
-               Z_STRLEN_P(return_value) = (Z_STRVAL_P(return_value) ? 
strlen(Z_STRVAL_P(return_value)) : 0);
-               Z_STRVAL_P(return_value) = 
safe_estrndup(Z_STRVAL_P(return_value),Z_STRLEN_P(return_value));
-               Z_TYPE_P(return_value) = IS_STRING;
+               char *value = PQgetvalue(pgsql_result, pgsql_row, field_offset);
+               int value_len = PQgetlength(pgsql_result, pgsql_row, 
field_offset);
+               ZVAL_STRINGL(return_value, value, value_len, 1);
        }
 }
 /* }}} */

http://cvs.php.net/viewvc.cgi/php-src/ext/pgsql/tests/bug37100.phpt?view=markup&rev=1.1
Index: php-src/ext/pgsql/tests/bug37100.phpt
+++ php-src/ext/pgsql/tests/bug37100.phpt
--TEST--
Bug #37100 (data is returned truncated with BINARY CURSOR)
--SKIPIF--
<?php include("skipif.inc"); ?>
--FILE--
<?php

include 'config.inc';

$db = pg_connect($conn_str);

@pg_query('DROP TABLE test_bug');

pg_query('CREATE TABLE test_bug (binfield byteA) ;');
pg_query("INSERT INTO test_bug VALUES (decode('0103AA000812','hex'))");


$data = pg_query("SELECT binfield FROM test_bug");
$res = pg_fetch_result($data,0);
var_dump($res);
var_dump(bin2hex(pg_unescape_bytea($res)));

$sql = "BEGIN; DECLARE mycursor BINARY CURSOR FOR SELECT binfield FROM 
test_bug; FETCH ALL IN mycursor;";

$data = pg_query($sql);
$res = pg_fetch_result($data,0);

var_dump(strlen($res));
var_dump(bin2hex($res));

pg_close($db);

$db = pg_connect($conn_str);
pg_query('DROP TABLE test_bug');
pg_close($db);


?>
--EXPECT--
string(24) "\001\003\252\000\010\022"
string(12) "0103aa000812"
int(6)
string(12) "0103aa000812"



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

Reply via email to