summaryrefslogtreecommitdiff
path: root/ext/pdo_dblib/dblib_stmt.c
diff options
context:
space:
mode:
authorWez Furlong <wez@php.net>2005-07-20 05:27:27 (GMT)
committerWez Furlong <wez@php.net>2005-07-20 05:27:27 (GMT)
commitec50ec65b9b781c3ccdbd38e175d24397d45c464 (patch)
tree214de31e3f7f8d964aab6105f120d52cfefa03f6 /ext/pdo_dblib/dblib_stmt.c
parent08891a1c1b6a409d48075c73331a731732316724 (diff)
downloadphp-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/dblib_stmt.c')
-rw-r--r--ext/pdo_dblib/dblib_stmt.c61
1 files changed, 33 insertions, 28 deletions
diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c
index 68b0f28..a6e8b49 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);