[PHP-CVS] cvs: php-src /ext/pdo pdo_stmt.c /ext/pdo_mysql/tests bug44327.phpt pdo_mysql_stmt_errorinfo.phpt pdo_mysql_stmt_multiquery.phpt

2009-03-24 Thread Felipe Pena
felipe  Tue Mar 24 19:32:07 2009 UTC

  Modified files:  
/php-src/ext/pdopdo_stmt.c 
/php-src/ext/pdo_mysql/testsbug44327.phpt 
pdo_mysql_stmt_errorinfo.phpt 
pdo_mysql_stmt_multiquery.phpt 
  Log:
  - Synced pieces of codes
  - Fixed tests
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.217r2=1.218diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.217 php-src/ext/pdo/pdo_stmt.c:1.218
--- php-src/ext/pdo/pdo_stmt.c:1.217Mon Mar 23 23:02:06 2009
+++ php-src/ext/pdo/pdo_stmt.c  Tue Mar 24 19:32:06 2009
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_stmt.c,v 1.217 2009/03/23 23:02:06 felipe Exp $ */
+/* $Id: pdo_stmt.c,v 1.218 2009/03/24 19:32:06 felipe Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -2650,6 +2650,7 @@
}
}
if (strcmp(Z_STRVAL_P(member), queryString) == 0) {
+   zval_ptr_dtor(return_value);
return std_object_handlers.read_property(object, 
member, IS_STRING TSRMLS_CC);
}
}
@@ -2694,28 +2695,18 @@
 
 static HashTable *row_get_properties(zval *object TSRMLS_DC)
 {
-   zval *tmp;
pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object 
TSRMLS_CC);
int i;
-   HashTable *ht;
-
-   MAKE_STD_ZVAL(tmp);
-   array_init(tmp);
 
for (i = 0; i  stmt-column_count; i++) {
zval *val;
MAKE_STD_ZVAL(val);
fetch_value(stmt, val, i, NULL TSRMLS_CC);
 
-   add_assoc_zval(tmp, stmt-columns[i].name, val);
+   zend_hash_update(stmt-properties, stmt-columns[i].name, 
stmt-columns[i].namelen + 1, (void *)val, sizeof(zval *), NULL);
}
 
-   ht = Z_ARRVAL_P(tmp);
-
-   ZVAL_NULL(tmp);
-   FREE_ZVAL(tmp);
-
-   return ht;
+   return stmt-properties;
 }
 
 static union _zend_function *row_method_get(
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_mysql/tests/bug44327.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/pdo_mysql/tests/bug44327.phpt
diff -u php-src/ext/pdo_mysql/tests/bug44327.phpt:1.1 
php-src/ext/pdo_mysql/tests/bug44327.phpt:1.2
--- php-src/ext/pdo_mysql/tests/bug44327.phpt:1.1   Mon Nov  3 15:31:51 2008
+++ php-src/ext/pdo_mysql/tests/bug44327.phpt   Tue Mar 24 19:32:06 2009
@@ -42,22 +42,22 @@
 ?
 --EXPECTF--
 object(PDORow)#%d (2) {
-  [queryString]=
-  string(17) SELECT 1 AS one
-  [one]=
+  [uqueryString]=
+  unicode(17) SELECT 1 AS one
+  [uone]=
   string(1) 1
 }
-string(1) 1
-string(1) 1
-string(17) SELECT 1 AS one
+unicode(1) 1
+unicode(1) 1
+unicode(17) SELECT 1 AS one
 --
 object(PDORow)#%d (2) {
-  [queryString]=
-  string(19) SELECT id FROM test
-  [id]=
-  string(1) 1
+  [uqueryString]=
+  unicode(19) SELECT id FROM test
+  [uid]=
+  unicode(1) 1
 }
-string(19) SELECT id FROM test
+unicode(19) SELECT id FROM test
 --
 
 Notice: Trying to get property of non-object in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt
diff -u php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt:1.1 
php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt:1.2
--- php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt:1.1   Mon Jul 
21 13:05:51 2008
+++ php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_errorinfo.phpt   Tue Mar 24 
19:32:06 2009
@@ -61,9 +61,13 @@
 ?
 --EXPECTF--
 Testing emulated PS...
-array(1) {
+array(3) {
   [0]=
   string(0) 
+  [1]=
+  NULL
+  [2]=
+  NULL
 }
 
 Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not 
found: 1146 Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
@@ -86,17 +90,25 @@
   [2]=
   string(%d) Table '%s.test' doesn't exist
 }
-array(1) {
+array(3) {
   [0]=
   string(5) 0
+  [1]=
+  NULL
+  [2]=
+  NULL
 }
 Testing native PS...
 
 Warning: PDO::prepare(): SQLSTATE[42S02]: Base table or view not found: 1146 
Table '%s.ihopeitdoesnotexist' doesn't exist in %s on line %d
 bool(false)
-array(1) {
+array(3) {
   [0]=
   string(0) 
+  [1]=
+  NULL
+  [2]=
+  NULL
 }
 
 Warning: PDOStatement::execute(): SQLSTATE[42S02]: Base table or view not 
found: 1146 Table '%s.test' doesn't exist in %s on line %d
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt?r1=1.1r2=1.2diff_format=u
Index: php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt
diff -u php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt:1.1 
php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt:1.2
--- php-src/ext/pdo_mysql/tests/pdo_mysql_stmt_multiquery.phpt:1.1  Mon Jul 
21 13:05:51 

[PHP-CVS] cvs: php-src /ext/pdo pdo_stmt.c /ext/pdo_mysql/tests bug44327.phpt

2008-11-03 Thread Felipe Pena
felipe  Mon Nov  3 15:31:51 2008 UTC

  Added files: 
/php-src/ext/pdo_mysql/testsbug44327.phpt 

  Modified files:  
/php-src/ext/pdopdo_stmt.c 
  Log:
  - Fixed bug #44327 (PDORow::queryString property  numeric offsets / Crash)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo/pdo_stmt.c?r1=1.204r2=1.205diff_format=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.204 php-src/ext/pdo/pdo_stmt.c:1.205
--- php-src/ext/pdo/pdo_stmt.c:1.204Sun Nov  2 21:10:10 2008
+++ php-src/ext/pdo/pdo_stmt.c  Mon Nov  3 15:31:51 2008
@@ -18,7 +18,7 @@
   +--+
 */
 
-/* $Id: pdo_stmt.c,v 1.204 2008/11/02 21:10:10 felipe Exp $ */
+/* $Id: pdo_stmt.c,v 1.205 2008/11/03 15:31:51 felipe Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -2622,6 +2622,10 @@
pdo_stmt_t * stmt = (pdo_stmt_t *) zend_object_store_get_object(object 
TSRMLS_CC);
int colno = -1;
 
+   if ((Z_TYPE_P(member) == IS_STRING || Z_TYPE_P(member) == IS_UNICODE) 
+   memcmp(Z_UNIVAL_P(member).v, queryString, 
sizeof(queryString)-1)) {
+   return std_object_handlers.read_property(object, member, 
IS_STRING TSRMLS_CC);
+   }
MAKE_STD_ZVAL(return_value);

if (Z_TYPE_P(member) == IS_LONG) {

http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_mysql/tests/bug44327.phpt?view=markuprev=1.1
Index: php-src/ext/pdo_mysql/tests/bug44327.phpt
+++ php-src/ext/pdo_mysql/tests/bug44327.phpt
--TEST--
Bug #44327 (PDORow::queryString property  numeric offsets / Crash)
--SKIPIF--
?php
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'skipif.inc');
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 'mysql_pdo_test.inc');
MySQLPDOTest::skip();
$db = MySQLPDOTest::factory();
?
--FILE--
?php
require_once(dirname(__FILE__) . DIRECTORY_SEPARATOR . 
'mysql_pdo_test.inc');
$db = MySQLPDOTest::factory();

$stmt = $db-prepare(SELECT 1 AS \one\); 
$stmt-execute(); 
$row = $stmt-fetch(PDO::FETCH_LAZY); 
var_dump($row);
var_dump($row-{0});
var_dump($row-one); 
var_dump($row-queryString);

print --\n;

@$db-exec(DROP TABLE test);
$db-exec(CREATE TABLE test (id INT));
$db-exec(INSERT INTO test(id) VALUES (1));
$stmt = $db-prepare(SELECT id FROM test);
$stmt-execute();
$row = $stmt-fetch(PDO::FETCH_LAZY);
var_dump($row);
var_dump($row-queryString);
@$db-exec(DROP TABLE test);

print --\n;

$stmt = $db-prepare('foo'); 
@$stmt-execute();
$row = $stmt-fetch();
var_dump($row-queryString);

?
--EXPECTF--
object(PDORow)#%d (2) {
  [queryString]=
  string(17) SELECT 1 AS one
  [one]=
  string(1) 1
}
string(1) 1
string(1) 1
string(17) SELECT 1 AS one
--
object(PDORow)#%d (2) {
  [queryString]=
  string(19) SELECT id FROM test
  [id]=
  string(1) 1
}
string(19) SELECT id FROM test
--

Notice: Trying to get property of non-object in %s on line %d
NULL



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