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.
This commit is contained in:
Wez Furlong 2005-07-20 05:27:27 +00:00
parent 08891a1c1b
commit ec50ec65b9
4 changed files with 69 additions and 34 deletions

View File

@ -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);

View File

@ -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;
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);
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);
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 (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);

View File

@ -114,15 +114,19 @@ 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);
#endif

View File

@ -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;