summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-07-20 05:27:27 +0000
committerWez Furlong <wez@php.net>2005-07-20 05:27:27 +0000
commitec50ec65b9b781c3ccdbd38e175d24397d45c464 (patch)
tree214de31e3f7f8d964aab6105f120d52cfefa03f6 /ext/pdo_dblib
parent08891a1c1b6a409d48075c73331a731732316724 (diff)
downloadphp-git-ec50ec65b9b781c3ccdbd38e175d24397d45c464.tar.gz
use pdo core test suite.
Now passes all but one test. Volunteers that want to track down the cause for test pdo_018.phpt not passing are welcome.
Diffstat (limited to 'ext/pdo_dblib')
-rw-r--r--ext/pdo_dblib/dblib_driver.c9
-rw-r--r--ext/pdo_dblib/dblib_stmt.c61
-rw-r--r--ext/pdo_dblib/pdo_dblib.c16
-rw-r--r--ext/pdo_dblib/tests/common.phpt23
4 files changed, 72 insertions, 37 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c
index 0b469d666d..23087775a5 100644
--- a/ext/pdo_dblib/dblib_driver.c
+++ b/ext/pdo_dblib/dblib_driver.c
@@ -44,15 +44,18 @@ static int dblib_fetch_error(pdo_dbh_t *dbh, pdo_stmt_t *stmt, zval *info TSRMLS
S = (pdo_dblib_stmt*)stmt->driver_data;
einfo = &S->err;
}
-
+
if (einfo->dberr == SYBESMSG && einfo->lastmsg) {
msg = einfo->lastmsg;
+ } else if (einfo->dberr == SYBESMSG && DBLIB_G(err).lastmsg) {
+ msg = DBLIB_G(err).lastmsg;
+ DBLIB_G(err).lastmsg = NULL;
} else {
msg = einfo->dberrstr;
}
- spprintf(&message, 0, "%s [%d] (severity %d)",
- msg, einfo->dberr, einfo->severity);
+ spprintf(&message, 0, "%s [%d] (severity %d) [%s]",
+ msg, einfo->dberr, einfo->severity, stmt ? stmt->active_query_string : "");
add_next_index_long(info, einfo->dberr);
add_next_index_string(info, message, 0);
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 68b0f287f1..a6e8b492d6 100644
--- a/ext/pdo_dblib/dblib_stmt.c
+++ b/ext/pdo_dblib/dblib_stmt.c
@@ -47,6 +47,7 @@ static void free_rows(pdo_dblib_stmt *S TSRMLS_DC)
}
efree(S->rows);
S->rows = NULL;
+ S->nrows = 0;
}
static int pdo_dblib_stmt_dtor(pdo_stmt_t *stmt TSRMLS_DC)
@@ -96,7 +97,7 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
ret = dbnextrow(H->link);
if (ret == NO_MORE_ROWS) {
- return 0;
+ return 1;
}
if (!S->cols) {
@@ -139,33 +140,38 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
for (i = 0; i < S->ncols; i++) {
pdo_dblib_colval *val = &S->rows[S->nrows * S->ncols + i];
- switch (S->cols[i].coltype) {
- case SQLCHAR:
- case SQLTEXT:
- case SQLVARBINARY:
- case SQLBINARY:
- case SQLIMAGE:
- val->len = dbdatlen(H->link, i+1);
- val->data = emalloc(val->len + 1);
- memcpy(val->data, dbdata(H->link, i+1), val->len);
- val->data[val->len] = '\0';
- break;
-
- default:
- if (dbwillconvert(S->cols[i].coltype, SQLCHAR)) {
- val->len = 32 + (2 * dbdatlen(H->link, i+1));
- val->data = emalloc(val->len);
-
- val->len = dbconvert(NULL, S->cols[i].coltype, dbdata(H->link, i+1),
- dbdatlen(H->link, i+1), SQLCHAR, val->data, val->len);
-
- if (val->len >= 0) {
- val->data[val->len] = '\0';
+ if (dbdatlen(H->link, i+1) == 0 && dbdata(H->link, i+1) == NULL) {
+ val->len = 0;
+ val->data = NULL;
+ } else {
+ switch (S->cols[i].coltype) {
+ case SQLCHAR:
+ case SQLTEXT:
+ case SQLVARBINARY:
+ case SQLBINARY:
+ case SQLIMAGE:
+ val->len = dbdatlen(H->link, i+1);
+ val->data = emalloc(val->len + 1);
+ memcpy(val->data, dbdata(H->link, i+1), val->len);
+ val->data[val->len] = '\0';
+ break;
+
+ default:
+ if (dbwillconvert(S->cols[i].coltype, SQLCHAR)) {
+ val->len = 32 + (2 * dbdatlen(H->link, i+1));
+ val->data = emalloc(val->len);
+
+ val->len = dbconvert(NULL, S->cols[i].coltype, dbdata(H->link, i+1),
+ dbdatlen(H->link, i+1), SQLCHAR, val->data, val->len);
+
+ if (val->len >= 0) {
+ val->data[val->len] = '\0';
+ }
+ } else {
+ val->len = 0;
+ val->data = NULL;
}
- } else {
- val->len = 0;
- val->data = NULL;
- }
+ }
}
}
@@ -178,7 +184,6 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC)
}
} while (ret != FAIL && ret != NO_MORE_ROWS);
-
if (resret != NO_MORE_RESULTS) {
/* there are additional result sets available */
dbresults(H->link);
diff --git a/ext/pdo_dblib/pdo_dblib.c b/ext/pdo_dblib/pdo_dblib.c
index 5bacec148c..87ae0bdb48 100644
--- a/ext/pdo_dblib/pdo_dblib.c
+++ b/ext/pdo_dblib/pdo_dblib.c
@@ -114,14 +114,18 @@ int msg_handler(DBPROCESS *dbproc, DBINT msgno, int msgstate,
pdo_dblib_err *einfo;
TSRMLS_FETCH();
- einfo = (pdo_dblib_err*)dbgetuserdata(dbproc);
- if (!einfo) einfo = &DBLIB_G(err);
+ if (severity) {
+ einfo = (pdo_dblib_err*)dbgetuserdata(dbproc);
+ if (!einfo) {
+ einfo = &DBLIB_G(err);
+ }
- if (einfo->lastmsg) {
- efree(einfo->lastmsg);
- }
+ if (einfo->lastmsg) {
+ efree(einfo->lastmsg);
+ }
- einfo->lastmsg = estrdup(msgtext);
+ einfo->lastmsg = estrdup(msgtext);
+ }
#if 0
php_error_docref(NULL TSRMLS_CC, E_WARNING, "dblib message: %s (severity %d)", msgtext, severity);
diff --git a/ext/pdo_dblib/tests/common.phpt b/ext/pdo_dblib/tests/common.phpt
new file mode 100644
index 0000000000..8cd1c40885
--- /dev/null
+++ b/ext/pdo_dblib/tests/common.phpt
@@ -0,0 +1,23 @@
+--TEST--
+DBLIB
+--SKIPIF--
+<?php # vim:ft=php
+if (!extension_loaded('pdo_dblib')) print 'skip'; ?>
+--REDIRECTTEST--
+# magic auto-configuration
+
+$config = array(
+ 'TESTS' => 'ext/pdo/tests'
+);
+
+
+if (false !== getenv('PDO_DBLIB_TEST_DSN')) {
+ # user set them from their shell
+ $config['ENV']['PDOTEST_DSN'] = getenv('PDO_DBLIB_TEST_DSN');
+ $config['ENV']['PDOTEST_USER'] = getenv('PDO_DBLIB_TEST_USER');
+ $config['ENV']['PDOTEST_PASS'] = getenv('PDO_DBLIB_TEST_PASS');
+ if (false !== getenv('PDO_DBLIB_TEST_ATTR')) {
+ $config['ENV']['PDOTEST_ATTR'] = getenv('PDO_DBLIB_TEST_ATTR');
+ }
+}
+return $config;