wez             Sun Oct 30 21:07:39 2005 EDT

  Modified files:              (Branch: PHP_5_1)
    /php-src/ext/pdo    pdo_stmt.c php_pdo_driver.h 
    /php-src/ext/pdo/tests      bug_34630.phpt pecl_bug_5772.phpt 
                                pecl_bug_5809.phpt 
  Log:
  improve test portability.
  improve infrastructure for LOB support.
  
  
http://cvs.php.net/diff.php/php-src/ext/pdo/pdo_stmt.c?r1=1.118.2.12&r2=1.118.2.13&ty=u
Index: php-src/ext/pdo/pdo_stmt.c
diff -u php-src/ext/pdo/pdo_stmt.c:1.118.2.12 
php-src/ext/pdo/pdo_stmt.c:1.118.2.13
--- php-src/ext/pdo/pdo_stmt.c:1.118.2.12       Sun Oct 30 17:17:52 2005
+++ php-src/ext/pdo/pdo_stmt.c  Sun Oct 30 21:07:37 2005
@@ -18,7 +18,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: pdo_stmt.c,v 1.118.2.12 2005/10/30 22:17:52 helly Exp $ */
+/* $Id: pdo_stmt.c,v 1.118.2.13 2005/10/31 02:07:37 wez Exp $ */
 
 /* The PDO Statement Handle Class */
 
@@ -474,8 +474,16 @@
                        if (value == NULL) {
                                ZVAL_NULL(dest);
                        } else if (value_len == 0) {
-                               php_stream_to_zval((php_stream*)value, dest);
-                       } else {
+                               if (stmt->dbh->stringify) {
+                                       char *buf = NULL;
+                                       size_t len;
+                                       len = 
php_stream_copy_to_mem((php_stream*)value, &buf, PHP_STREAM_COPY_ALL, 0);
+                                       ZVAL_STRINGL(dest, buf, len, 0);
+                                       php_stream_close((php_stream*)value);
+                               } else {
+                                       php_stream_to_zval((php_stream*)value, 
dest);
+                               }
+                       } else if (!stmt->dbh->stringify) {
                                /* they gave us a string, but LOBs are 
represented as streams in PDO */
                                php_stream *stm;
 #ifdef TEMP_STREAM_TAKE_BUFFER
@@ -2075,13 +2083,23 @@
        efree(stmt);
 }
 
-void pdo_dbstmt_free_storage(pdo_stmt_t *stmt TSRMLS_DC)
+PDO_API void php_pdo_stmt_addref(pdo_stmt_t *stmt TSRMLS_DC)
+{
+       stmt->refcount++;
+}
+
+PDO_API void php_pdo_stmt_delref(pdo_stmt_t *stmt TSRMLS_DC)
 {
        if (--stmt->refcount == 0) {
                free_statement(stmt TSRMLS_CC);
        }
 }
 
+void pdo_dbstmt_free_storage(pdo_stmt_t *stmt TSRMLS_DC)
+{
+       php_pdo_stmt_delref(stmt TSRMLS_CC);
+}
+
 zend_object_value pdo_dbstmt_new(zend_class_entry *ce TSRMLS_DC)
 {
        zend_object_value retval;
http://cvs.php.net/diff.php/php-src/ext/pdo/php_pdo_driver.h?r1=1.66.2.5&r2=1.66.2.6&ty=u
Index: php-src/ext/pdo/php_pdo_driver.h
diff -u php-src/ext/pdo/php_pdo_driver.h:1.66.2.5 
php-src/ext/pdo/php_pdo_driver.h:1.66.2.6
--- php-src/ext/pdo/php_pdo_driver.h:1.66.2.5   Thu Oct 27 15:39:38 2005
+++ php-src/ext/pdo/php_pdo_driver.h    Sun Oct 30 21:07:37 2005
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_driver.h,v 1.66.2.5 2005/10/27 19:39:38 tony2001 Exp $ */
+/* $Id: php_pdo_driver.h,v 1.66.2.6 2005/10/31 02:07:37 wez Exp $ */
 
 #ifndef PHP_PDO_DRIVER_H
 #define PHP_PDO_DRIVER_H
@@ -44,7 +44,7 @@
 # define FALSE 0
 #endif
 
-#define PDO_DRIVER_API 20051002
+#define PDO_DRIVER_API 20051031
 
 enum pdo_param_type {
        PDO_PARAM_NULL,
@@ -645,6 +645,10 @@
 PDO_API void pdo_raise_impl_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt,
        const char *sqlstate, const char *supp TSRMLS_DC);
 
+PDO_API void php_pdo_stmt_addref(pdo_stmt_t *stmt TSRMLS_DC);
+PDO_API void php_pdo_stmt_delref(pdo_stmt_t *stmt TSRMLS_DC);
+
+
 #endif /* PHP_PDO_DRIVER_H */
 /*
  * Local variables:
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/bug_34630.phpt?r1=1.1.2.2&r2=1.1.2.3&ty=u
Index: php-src/ext/pdo/tests/bug_34630.phpt
diff -u php-src/ext/pdo/tests/bug_34630.phpt:1.1.2.2 
php-src/ext/pdo/tests/bug_34630.phpt:1.1.2.3
--- php-src/ext/pdo/tests/bug_34630.phpt:1.1.2.2        Mon Oct  3 11:06:27 2005
+++ php-src/ext/pdo/tests/bug_34630.phpt        Sun Oct 30 21:07:38 2005
@@ -13,27 +13,44 @@
 if (getenv('REDIR_TEST_DIR') === false) 
putenv('REDIR_TEST_DIR='.dirname(__FILE__) . '/../../pdo/tests/');
 require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
 $db = PDOTest::factory();
-$db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val VARCHAR(256))');
+
+$is_oci = $db->getAttribute(PDO::ATTR_DRIVER_NAME) == 'oci';
+
+if ($is_oci) {
+       $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val BLOB)');
+} else {
+       $db->exec('CREATE TABLE test (id int NOT NULL PRIMARY KEY, val 
VARCHAR(256))');
+}
 $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
 
 $fp = tmpfile();
 fwrite($fp, "I am the LOB data");
 rewind($fp);
 
-$insert = $db->prepare("insert into test (id, val) values (1, ?)");
-$insert->bindValue(1, $fp, PDO::PARAM_LOB);
+if ($is_oci) {
+       /* oracle is a bit different; you need to initiate a transaction 
otherwise
+        * the empty blob will be committed implicitly when the statement is
+        * executed */
+       $db->beginTransaction();
+       $insert = $db->prepare("insert into test (id, val) values (1, 
EMPTY_BLOB()) RETURNING val INTO :blob");
+} else {
+       $insert = $db->prepare("insert into test (id, val) values (1, :blob)");
+}
+$insert->bindValue(':blob', $fp, PDO::PARAM_LOB);
 $insert->execute();
+$insert = null;
 
-print_r($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC));
+$db->setAttribute(PDO::ATTR_STRINGIFY_FETCHES, true);
+var_dump($db->query("SELECT * from test")->fetchAll(PDO::FETCH_ASSOC));
 
 ?>
 --EXPECT--
-Array
-(
-    [0] => Array
-        (
-            [id] => 1
-            [val] => I am the LOB data
-        )
-
-)
+array(1) {
+  [0]=>
+  array(2) {
+    ["id"]=>
+    string(1) "1"
+    ["val"]=>
+    string(17) "I am the LOB data"
+  }
+}
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/pecl_bug_5772.phpt?r1=1.1.2.1&r2=1.1.2.2&ty=u
Index: php-src/ext/pdo/tests/pecl_bug_5772.phpt
diff -u php-src/ext/pdo/tests/pecl_bug_5772.phpt:1.1.2.1 
php-src/ext/pdo/tests/pecl_bug_5772.phpt:1.1.2.2
--- php-src/ext/pdo/tests/pecl_bug_5772.phpt:1.1.2.1    Fri Oct 28 23:11:46 2005
+++ php-src/ext/pdo/tests/pecl_bug_5772.phpt    Sun Oct 30 21:07:38 2005
@@ -14,7 +14,7 @@
 require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
 $db = PDOTest::factory();
 
-$db->exec("CREATE TABLE test (id int(10) NOT NULL, PRIMARY KEY (id))");
+$db->exec("CREATE TABLE test (id int NOT NULL, PRIMARY KEY (id))");
 $db->exec("INSERT INTO test (id) VALUES (1)");
 
 function heLLO($row) {
http://cvs.php.net/diff.php/php-src/ext/pdo/tests/pecl_bug_5809.phpt?r1=1.1.2.1&r2=1.1.2.2&ty=u
Index: php-src/ext/pdo/tests/pecl_bug_5809.phpt
diff -u php-src/ext/pdo/tests/pecl_bug_5809.phpt:1.1.2.1 
php-src/ext/pdo/tests/pecl_bug_5809.phpt:1.1.2.2
--- php-src/ext/pdo/tests/pecl_bug_5809.phpt:1.1.2.1    Fri Oct 28 23:01:19 2005
+++ php-src/ext/pdo/tests/pecl_bug_5809.phpt    Sun Oct 30 21:07:38 2005
@@ -14,7 +14,7 @@
 require_once getenv('REDIR_TEST_DIR') . 'pdo_test.inc';
 $db = PDOTest::factory();
 
-$db->exec("CREATE TABLE test (id int(10) NOT NULL, PRIMARY KEY (id))");
+$db->exec("CREATE TABLE test (id int NOT NULL, PRIMARY KEY (id))");
 $db->exec("INSERT INTO test (id) VALUES (1)");
 
 $values = array(1);

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

Reply via email to