diff options
author | Steph Fox <sfox@php.net> | 2009-03-19 22:16:29 +0000 |
---|---|---|
committer | Steph Fox <sfox@php.net> | 2009-03-19 22:16:29 +0000 |
commit | f5a65cabfde854100143fb5c01480f797c263264 (patch) | |
tree | 27f1e89f2e8fe2bbb10c4e2b65b5e292f3af91cd /ext/pdo_dblib | |
parent | 91d325dd729391b74d1cf5410778a27bbba84041 (diff) | |
download | php-git-f5a65cabfde854100143fb5c01480f797c263264.tar.gz |
MFH
- Fix bug #38805 ( PDO Truncates Text from SQL Server Text Data Type Field)
- Bring behaviour into line with ext/mssql
- Several memleaks plugged
Diffstat (limited to 'ext/pdo_dblib')
-rw-r--r-- | ext/pdo_dblib/dblib_driver.c | 6 | ||||
-rw-r--r-- | ext/pdo_dblib/dblib_stmt.c | 29 |
2 files changed, 24 insertions, 11 deletions
diff --git a/ext/pdo_dblib/dblib_driver.c b/ext/pdo_dblib/dblib_driver.c index e2883c3747..d34c14a333 100644 --- a/ext/pdo_dblib/dblib_driver.c +++ b/ext/pdo_dblib/dblib_driver.c @@ -229,7 +229,11 @@ static int pdo_dblib_handle_factory(pdo_dbh_t *dbh, zval *driver_options TSRMLS_ if (H->link == NULL) { goto cleanup; } - + + if (DBSETOPT(H->link, DBTEXTLIMIT, "2147483647") == FAIL) { + goto cleanup; + } + if (vars[3].optval && FAIL == dbuse(H->link, vars[3].optval)) { goto cleanup; } diff --git a/ext/pdo_dblib/dblib_stmt.c b/ext/pdo_dblib/dblib_stmt.c index 0e7f0d4da6..c8bf9f7305 100644 --- a/ext/pdo_dblib/dblib_stmt.c +++ b/ext/pdo_dblib/dblib_stmt.c @@ -113,18 +113,27 @@ static int pdo_dblib_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) stmt->column_count = S->ncols; for (i = 0, j = 0; i < S->ncols; i++) { + char *tmp = NULL; + S->cols[i].coltype = dbcoltype(H->link, i+1); - S->cols[i].name = dbcolname(H->link, i+1); - if (S->cols[i].name) { - S->cols[i].name = estrdup(S->cols[i].name); - } else if (j) { - spprintf(&S->cols[i].name, 0, "computed%d", j++); - } else { - S->cols[i].name = estrdup("computed"); - j++; + S->cols[i].name = (char*)dbcolname(H->link, i+1); + + if (!strlen(S->cols[i].name)) { + if (j) { + spprintf(&tmp, 0, "computed%d", j++); + strlcpy(S->cols[i].name, tmp, strlen(tmp)+1); + efree(tmp); + } else { + S->cols[i].name = "computed"; + j++; + } } - S->cols[i].source = dbcolsource(H->link, i+1); - S->cols[i].source = estrdup(S->cols[i].source ? S->cols[i].source : ""); + + S->cols[i].source = (char*)dbcolsource(H->link, i+1); + tmp = estrdup(S->cols[i].source ? S->cols[i].source : ""); + S->cols[i].source = tmp; + efree(tmp); + S->cols[i].maxlen = dbcollen(H->link, i+1); } } |