mirror of
https://github.com/php/php-src.git
synced 2026-04-28 02:33:17 +02:00
Add support for scrollable cursors.
Enable PDO_ATTR_PREFETCH and default it to 100Kb of prefetch buffer.
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 */
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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 |
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user