summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-01-12 05:47:03 +0000
committerWez Furlong <wez@php.net>2005-01-12 05:47:03 +0000
commit459b4f85d36f50a54f8a12232fb2fd27cb1d01a9 (patch)
tree6c6fc91b7298861d7c42694ffb71fa2c55e312e4
parentdd842e4bf4914cd8524ef99a8500ee22f2c0636d (diff)
downloadphp-git-459b4f85d36f50a54f8a12232fb2fd27cb1d01a9.tar.gz
Add support for scrollable cursors.
Enable PDO_ATTR_PREFETCH and default it to 100Kb of prefetch buffer.
-rwxr-xr-xext/pdo_oci/config.m48
-rwxr-xr-xext/pdo_oci/config.w321
-rwxr-xr-xext/pdo_oci/oci_driver.c23
-rwxr-xr-xext/pdo_oci/oci_statement.c22
-rwxr-xr-xext/pdo_oci/pdo_oci.c2
-rwxr-xr-xext/pdo_oci/php_pdo_oci.h2
-rwxr-xr-xext/pdo_oci/php_pdo_oci_int.h6
7 files changed, 54 insertions, 10 deletions
diff --git a/ext/pdo_oci/config.m4 b/ext/pdo_oci/config.m4
index 7b31a953fc..40f8df4ea1 100755
--- a/ext/pdo_oci/config.m4
+++ b/ext/pdo_oci/config.m4
@@ -131,7 +131,13 @@ if test "$PHP_PDO_OCI" != "no"; then
-L$PDO_OCI_DIR/lib $PDO_OCI_SHARED_LIBADD
])
-
+ dnl Scrollable cursors?
+ PHP_CHECK_LIBRARY(clntsh, OCIStmtFetch2,
+ [
+ AC_DEFINE(HAVE_OCISTMTFETCH2,1,[ ])
+ ], [], [
+ -L$PDO_OCI_DIR/lib $PDO_OCI_SHARED_LIBADD
+ ])
PHP_NEW_EXTENSION(pdo_oci, pdo_oci.c oci_driver.c oci_statement.c, $ext_shared,,-I\$prefix/include/php/ext)
diff --git a/ext/pdo_oci/config.w32 b/ext/pdo_oci/config.w32
index 353e28f711..a1d3a25a30 100755
--- a/ext/pdo_oci/config.w32
+++ b/ext/pdo_oci/config.w32
@@ -32,6 +32,7 @@ if (PHP_PDO_OCI != "no") {
/* probe for some functions not present in older versions */
pdo_oci_inc_dir = FSO.GetFolder(pdo_oci_header);
CHECK_FUNC_IN_HEADER('oci.h', 'OCIEnvCreate', pdo_oci_inc_dir);
+ CHECK_FUNC_IN_HEADER('oci.h', 'OCIStmtFetch2', pdo_oci_inc_dir);
CHECK_FUNC_IN_HEADER('ociap.h', 'OCIEnvNlsCreate', pdo_oci_inc_dir);
} else {
diff --git a/ext/pdo_oci/oci_driver.c b/ext/pdo_oci/oci_driver.c
index 4f089e8219..1d72d2c55d 100755
--- a/ext/pdo_oci/oci_driver.c
+++ b/ext/pdo_oci/oci_driver.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -195,9 +195,18 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pd
{
pdo_oci_db_handle *H = (pdo_oci_db_handle *)dbh->driver_data;
pdo_oci_stmt *S = ecalloc(1, sizeof(*S));
+ ub4 prefetch;
+
+#if HAVE_OCISTMTFETCH2
+ S->exec_type = pdo_attr_lval(driver_options, PDO_ATTR_SCROLL,
+ 0 TSRMLS_CC) ? OCI_STMT_SCROLLABLE_READONLY : OCI_DEFAULT;
+#else
+ S->exec_type = OCI_DEFAULT;
+#endif
S->H = H;
+
/* create an OCI statement handle */
OCIHandleAlloc(H->env, (dvoid*)&S->stmt, OCI_HTYPE_STMT, 0, NULL);
@@ -214,6 +223,18 @@ static int oci_handle_preparer(pdo_dbh_t *dbh, const char *sql, long sql_len, pd
efree(S);
return 0;
}
+
+ }
+
+ prefetch = 1024 * pdo_attr_lval(driver_options, PDO_ATTR_PREFETCH, 100 TSRMLS_CC);
+ if (prefetch) {
+ H->last_err = OCIAttrSet(S->stmt, OCI_HTYPE_STMT, &prefetch, 0,
+ OCI_ATTR_PREFETCH_MEMORY, H->err);
+ if (!H->last_err) {
+ prefetch /= 1024;
+ H->last_err = OCIAttrSet(S->stmt, OCI_HTYPE_STMT, &prefetch, 0,
+ OCI_ATTR_PREFETCH_ROWS, H->err);
+ }
}
stmt->driver_data = S;
diff --git a/ext/pdo_oci/oci_statement.c b/ext/pdo_oci/oci_statement.c
index b35462c9d8..e8550c8e2e 100755
--- a/ext/pdo_oci/oci_statement.c
+++ b/ext/pdo_oci/oci_statement.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -109,7 +109,7 @@ static int oci_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
STMT_CALL(OCIStmtExecute, (S->H->svc, S->stmt, S->err,
S->stmt_type == OCI_STMT_SELECT ? 0 : 1, 0, NULL, NULL,
- (stmt->dbh->auto_commit && !stmt->dbh->in_txn) ? OCI_COMMIT_ON_SUCCESS : OCI_DEFAULT));
+ (stmt->dbh->auto_commit && !stmt->dbh->in_txn) ? OCI_COMMIT_ON_SUCCESS : S->exec_type));
if (!stmt->executed) {
ub4 colcount;
@@ -284,11 +284,27 @@ static int oci_stmt_param_hook(pdo_stmt_t *stmt, struct pdo_bound_param_data *pa
return 1;
}
-static int oci_stmt_fetch(pdo_stmt_t *stmt TSRMLS_DC)
+static int oci_stmt_fetch(pdo_stmt_t *stmt, enum pdo_fetch_orientation ori,
+ long offset TSRMLS_DC)
{
+#if HAVE_OCISTMTFETCH2
+ ub4 ociori;
+#endif
pdo_oci_stmt *S = (pdo_oci_stmt*)stmt->driver_data;
+#if HAVE_OCISTMTFETCH2
+ switch (ori) {
+ case PDO_FETCH_ORI_NEXT: ociori = OCI_FETCH_NEXT; break;
+ case PDO_FETCH_ORI_PRIOR: ociori = OCI_FETCH_PRIOR; break;
+ case PDO_FETCH_ORI_FIRST: ociori = OCI_FETCH_FIRST; break;
+ case PDO_FETCH_ORI_LAST: ociori = OCI_FETCH_LAST; break;
+ case PDO_FETCH_ORI_ABS: ociori = OCI_FETCH_ABSOLUTE; break;
+ case PDO_FETCH_ORI_REL: ociori = OCI_FETCH_RELATIVE; break;
+ }
+ S->last_err = OCIStmtFetch2(S->stmt, S->err, 1, ociori, offset, OCI_DEFAULT);
+#else
S->last_err = OCIStmtFetch(S->stmt, S->err, 1, OCI_FETCH_NEXT, OCI_DEFAULT);
+#endif
if (S->last_err == OCI_NO_DATA) {
/* no (more) data */
diff --git a/ext/pdo_oci/pdo_oci.c b/ext/pdo_oci/pdo_oci.c
index 5712f8634d..757877454e 100755
--- a/ext/pdo_oci/pdo_oci.c
+++ b/ext/pdo_oci/pdo_oci.c
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo_oci/php_pdo_oci.h b/ext/pdo_oci/php_pdo_oci.h
index fe9f24749f..7e37c3e60c 100755
--- a/ext/pdo_oci/php_pdo_oci.h
+++ b/ext/pdo_oci/php_pdo_oci.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
diff --git a/ext/pdo_oci/php_pdo_oci_int.h b/ext/pdo_oci/php_pdo_oci_int.h
index d20baba47c..2ebd4f2226 100755
--- a/ext/pdo_oci/php_pdo_oci_int.h
+++ b/ext/pdo_oci/php_pdo_oci_int.h
@@ -2,7 +2,7 @@
+----------------------------------------------------------------------+
| PHP Version 5 |
+----------------------------------------------------------------------+
- | Copyright (c) 1997-2004 The PHP Group |
+ | Copyright (c) 1997-2005 The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.0 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
@@ -60,8 +60,8 @@ typedef struct {
OCIStmt *stmt;
OCIError *err;
sword last_err;
- ub2 stmt_type;
-
+ ub2 stmt_type;
+ ub4 exec_type;
pdo_oci_column *cols;
pdo_oci_error_info einfo;
} pdo_oci_stmt;