sixd            Fri Aug 31 21:08:48 2007 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src/ext/pdo_oci        config.m4 oci_driver.c oci_statement.c 
                                php_pdo_oci_int.h 
  Log:
  Add $dbh->getAttribute() support for ATTR_SERVER_VERSION, ATTR_SERVER_INFO, 
ATTR_CLIENT_VERSION, ATTR_AUTOCOMMIT. Sync WS between PHP 5 & 6 and add a 
couple of casts.
  
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_oci/config.m4?r1=1.14.2.5.2.5&r2=1.14.2.5.2.6&diff_format=u
Index: php-src/ext/pdo_oci/config.m4
diff -u php-src/ext/pdo_oci/config.m4:1.14.2.5.2.5 
php-src/ext/pdo_oci/config.m4:1.14.2.5.2.6
--- php-src/ext/pdo_oci/config.m4:1.14.2.5.2.5  Fri Aug 17 13:30:36 2007
+++ php-src/ext/pdo_oci/config.m4       Fri Aug 31 21:08:48 2007
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.14.2.5.2.5 2007/08/17 13:30:36 sixd Exp $
+dnl $Id: config.m4,v 1.14.2.5.2.6 2007/08/31 21:08:48 sixd Exp $
 
 if test "$PHP_PDO" != "no"; then
 
@@ -24,7 +24,7 @@
       PDO_OCI_VERSION=8.1
     fi
   else
-    AC_MSG_ERROR(Oracle-OCI needed libraries not found under $PDO_OCI_DIR)
+    AC_MSG_ERROR(Oracle OCI libraries not found under $PDO_OCI_DIR)
   fi
   AC_MSG_RESULT($PDO_OCI_VERSION)
 ])                                                                             
                                                                                
   
@@ -54,7 +54,7 @@
 ])
 
 PHP_ARG_WITH(pdo-oci, Oracle OCI support for PDO,
-[  --with-pdo-oci[=DIR]      PDO: Oracle-OCI support. DIR defaults to 
\$ORACLE_HOME.
+[  --with-pdo-oci[=DIR]      PDO: Oracle OCI support. DIR defaults to 
\$ORACLE_HOME.
                             Use --with-pdo-oci=instantclient,prefix,version 
                             for an Oracle Instant Client SDK. 
                             For Linux with 10.2.0.3 RPMs (for example) use:
@@ -67,12 +67,12 @@
   else
     PDO_OCI_DIR=$PHP_PDO_OCI
   fi
-  AC_MSG_RESULT($PDO_OCI_DIR :$PHP_PDO_OCI:)
+  AC_MSG_RESULT($PHP_PDO_OCI)
 
   AC_MSG_CHECKING([if that is sane])
   if test -z "$PDO_OCI_DIR"; then
     AC_MSG_ERROR([
-You need to tell me where to find your oracle SDK, or set ORACLE_HOME.
+You need to tell me where to find your Oracle Instant Client SDK, or set 
ORACLE_HOME.
 ])
   else
     AC_MSG_RESULT([yes])
@@ -251,6 +251,8 @@
   [
     PHP_ADD_EXTENSION_DEP(pdo_oci, pdo)
   ])
+
+  AC_DEFINE_UNQUOTED(PHP_PDO_OCI_CLIENT_VERSION, "$PDO_OCI_VERSION", [ ])
 fi
 
 fi
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_oci/oci_driver.c?r1=1.24.2.4.2.6&r2=1.24.2.4.2.7&diff_format=u
Index: php-src/ext/pdo_oci/oci_driver.c
diff -u php-src/ext/pdo_oci/oci_driver.c:1.24.2.4.2.6 
php-src/ext/pdo_oci/oci_driver.c:1.24.2.4.2.7
--- php-src/ext/pdo_oci/oci_driver.c:1.24.2.4.2.6       Tue Jul  3 04:32:26 2007
+++ php-src/ext/pdo_oci/oci_driver.c    Fri Aug 31 21:08:48 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: oci_driver.c,v 1.24.2.4.2.6 2007/07/03 04:32:26 sixd Exp $ */
+/* $Id: oci_driver.c,v 1.24.2.4.2.7 2007/08/31 21:08:48 sixd Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -31,6 +31,8 @@
 #include "php_pdo_oci_int.h"
 #include "Zend/zend_exceptions.h"
 
+static inline ub4 pdo_oci_sanitize_prefetch(long prefetch);
+
 static int pdo_oci_fetch_error_func(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval 
*info TSRMLS_DC) /* {{{ */
 {
        pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
@@ -285,14 +287,14 @@
 
        }
 
-       prefetch = 1024 * pdo_attr_lval(driver_options, PDO_ATTR_PREFETCH, 100 
TSRMLS_CC);
+       prefetch = pdo_oci_sanitize_prefetch(pdo_attr_lval(driver_options, 
PDO_ATTR_PREFETCH, PDO_OCI_PREFETCH_DEFAULT TSRMLS_CC));
        if (prefetch) {
                H->last_err = OCIAttrSet(S->stmt, OCI_HTYPE_STMT, &prefetch, 0,
-                       OCI_ATTR_PREFETCH_MEMORY, H->err);
+                       OCI_ATTR_PREFETCH_ROWS, H->err);
                if (!H->last_err) {
-                       prefetch /= 1024;
+                       prefetch *= PDO_OCI_PREFETCH_ROWSIZE;
                        H->last_err = OCIAttrSet(S->stmt, OCI_HTYPE_STMT, 
&prefetch, 0,
-                               OCI_ATTR_PREFETCH_ROWS, H->err);
+                               OCI_ATTR_PREFETCH_MEMORY, H->err);
                }
        }
 
@@ -446,6 +448,69 @@
        } else {
                return 0;
        }
+       
+}
+/* }}} */
+
+static int oci_handle_get_attribute(pdo_dbh_t *dbh, long attr, zval 
*return_value TSRMLS_DC)  /* {{{ */
+{
+       pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
+
+       switch (attr) {
+               case PDO_ATTR_SERVER_VERSION:
+               case PDO_ATTR_SERVER_INFO:
+               {
+                       text infostr[512];
+                       char verstr[15];
+                       ub4  vernum;
+                       
+                       if (OCIServerRelease(H->svc, H->err, infostr, 
(ub4)sizeof(infostr), (ub1)OCI_HTYPE_SVCCTX, &vernum))
+                       {
+                               ZVAL_STRING(return_value, "<<Unknown>>", 1);
+                       } else {
+                               if (attr == PDO_ATTR_SERVER_INFO) {
+                                       ZVAL_STRING(return_value, (char 
*)infostr, 1);
+                               } else {
+                                       slprintf(verstr, sizeof(verstr), 
"%d.%d.%d.%d.%d", 
+                                                        (int)((vernum>>24) & 
0xFF),  /* version number */
+                                                        (int)((vernum>>20) & 
0x0F),  /* release number*/
+                                                        (int)((vernum>>12) & 
0xFF),  /* update number */
+                                                        (int)((vernum>>8)  & 
0x0F),  /* port release number */
+                                                        (int)((vernum>>0)  & 
0xFF)); /* port update number */
+                                       
+                                       ZVAL_STRING(return_value, verstr, 1);
+                               }
+                       }
+                       return TRUE;
+               }
+
+               case PDO_ATTR_CLIENT_VERSION:
+               {
+#if OCI_MAJOR_VERSION > 10 || (OCI_MAJOR_VERSION == 10 && OCI_MINOR_VERSION >= 
2)
+                       /* Run time client version */
+                       sword major, minor, update, patch, port_update;
+                       char verstr[15];
+
+                       OCIClientVersion(&major, &minor, &update, &patch, 
&port_update);
+                       slprintf(verstr, sizeof(verstr), "%d.%d.%d.%d.%d", 
major, minor, update, patch, port_update);
+                       ZVAL_STRING(return_value, verstr, 1);
+#else
+                       /* Compile time client version */
+                       ZVAL_STRING(return_value, PHP_PDO_OCI_CLIENT_VERSION, 
1);
+#endif /* Check for OCIClientVersion() support */
+
+                       return TRUE;
+               }
+
+               case PDO_ATTR_AUTOCOMMIT:
+                       ZVAL_BOOL(return_value, dbh->auto_commit);
+                       return TRUE;
+
+               default:
+                       return FALSE;
+
+       }
+       return FALSE;
 
 }
 /* }}} */
@@ -461,7 +526,7 @@
        oci_handle_set_attribute,
        NULL,
        pdo_oci_fetch_error_func,
-       NULL,   /* get_attr */
+       oci_handle_get_attribute,
        NULL,   /* check_liveness */
        NULL    /* get_driver_methods */
 };
@@ -483,7 +548,7 @@
        /* allocate an environment */
 #if HAVE_OCIENVNLSCREATE
        if (vars[0].optval) {
-               H->charset = OCINlsCharSetNameToId(pdo_oci_Env, vars[0].optval);
+               H->charset = OCINlsCharSetNameToId(pdo_oci_Env, (const oratext 
*)vars[0].optval);
                if (!H->charset) {
                        oci_init_error("OCINlsCharSetNameToId: unknown 
character set name");
                        goto cleanup;
@@ -598,6 +663,17 @@
        pdo_oci_handle_factory
 };
 
+static inline ub4 pdo_oci_sanitize_prefetch(long prefetch) /* {{{ */
+{
+       if (prefetch < 0) {
+               prefetch = 0;
+       } else if (prefetch > UB4MAXVAL / PDO_OCI_PREFETCH_ROWSIZE) {
+               prefetch = PDO_OCI_PREFETCH_DEFAULT;
+       }
+       return ((ub4)prefetch);
+}
+/* }}} */
+
 /*
  * Local variables:
  * tab-width: 4
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_oci/oci_statement.c?r1=1.16.2.10.2.6&r2=1.16.2.10.2.7&diff_format=u
Index: php-src/ext/pdo_oci/oci_statement.c
diff -u php-src/ext/pdo_oci/oci_statement.c:1.16.2.10.2.6 
php-src/ext/pdo_oci/oci_statement.c:1.16.2.10.2.7
--- php-src/ext/pdo_oci/oci_statement.c:1.16.2.10.2.6   Sat Jun 30 02:30:34 2007
+++ php-src/ext/pdo_oci/oci_statement.c Fri Aug 31 21:08:48 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: oci_statement.c,v 1.16.2.10.2.6 2007/06/30 02:30:34 sixd Exp $ */
+/* $Id: oci_statement.c,v 1.16.2.10.2.7 2007/08/31 21:08:48 sixd Exp $ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
@@ -31,8 +31,8 @@
 #include "php_pdo_oci_int.h"
 #include "Zend/zend_extensions.h"
 
-#define STMT_CALL(name, params)        \
-       do { \
+#define STMT_CALL(name, params)                                                
                                        \
+       do {                                                                    
                                                        \
                S->last_err = name params;                                      
                                        \
                S->last_err = _oci_error(S->err, stmt->dbh, stmt, #name, 
S->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC); \
                if (S->last_err) {                                              
                                                \
@@ -40,8 +40,8 @@
                }                                                               
                                                                \
        } while(0)
 
-#define STMT_CALL_MSG(name, msg, params)       \
-       do { \
+#define STMT_CALL_MSG(name, msg, params)                                       
                        \
+       do {                                                                    
                                                        \
                S->last_err = name params;                                      
                                        \
                S->last_err = _oci_error(S->err, stmt->dbh, stmt, #name ": " 
#msg, S->last_err, FALSE, __FILE__, __LINE__ TSRMLS_CC); \
                if (S->last_err) {                                              
                                                \
@@ -529,7 +529,7 @@
        col->precision = scale;
        col->maxlen = data_size;
        col->namelen = namelen;
-       col->name = estrndup(colname, namelen);
+       col->name = estrndup((char *)colname, namelen);
 
        S->cols[colno].dtype = dtype;
 
http://cvs.php.net/viewvc.cgi/php-src/ext/pdo_oci/php_pdo_oci_int.h?r1=1.4.2.2.2.3&r2=1.4.2.2.2.4&diff_format=u
Index: php-src/ext/pdo_oci/php_pdo_oci_int.h
diff -u php-src/ext/pdo_oci/php_pdo_oci_int.h:1.4.2.2.2.3 
php-src/ext/pdo_oci/php_pdo_oci_int.h:1.4.2.2.2.4
--- php-src/ext/pdo_oci/php_pdo_oci_int.h:1.4.2.2.2.3   Sat Jun 30 02:30:35 2007
+++ php-src/ext/pdo_oci/php_pdo_oci_int.h       Fri Aug 31 21:08:48 2007
@@ -16,7 +16,7 @@
   +----------------------------------------------------------------------+
 */
 
-/* $Id: php_pdo_oci_int.h,v 1.4.2.2.2.3 2007/06/30 02:30:35 sixd Exp $ */
+/* $Id: php_pdo_oci_int.h,v 1.4.2.2.2.4 2007/08/31 21:08:48 sixd Exp $ */
 
 #include <oci.h>
 
@@ -31,15 +31,15 @@
 typedef struct {
        OCIServer       *server;
        OCISession      *session;
-       OCIEnv          *env;
+       OCIEnv          *env;
        OCIError        *err;
-       OCISvcCtx       *svc;
+       OCISvcCtx       *svc;
        /* OCI9; 0 == use NLS_LANG */
        ub2                     charset;
        sword           last_err;
 
-       unsigned attached:1;
-       unsigned _reserved:31;
+       unsigned        attached:1;
+       unsigned        _reserved:31;
 
        pdo_oci_error_info einfo;
 } pdo_oci_db_handle;
@@ -62,15 +62,15 @@
        OCIStmt         *stmt;
        OCIError        *err;
        sword           last_err;
-       ub2             stmt_type;
-       ub4             exec_type;
+       ub2                     stmt_type;
+       ub4                     exec_type;
        pdo_oci_column *cols;
        pdo_oci_error_info einfo;
        unsigned int have_blobs:1;
 } pdo_oci_stmt;
 
 typedef struct {
-       OCIBind         *bind;  /* allocated by OCI */
+       OCIBind         *bind;  /* allocated by OCI */
        sb2                     oci_type;
        sb2                     indicator;
        ub2                     retcode;
@@ -93,3 +93,8 @@
 
 extern struct pdo_stmt_methods oci_stmt_methods;
 
+/* Default prefetch size in number of rows */
+#define PDO_OCI_PREFETCH_DEFAULT 100
+
+/* Arbitrary assumed row length for prefetch memory limit calcuation */
+#define PDO_OCI_PREFETCH_ROWSIZE 1024

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

Reply via email to