]> granicus.if.org Git - php/commitdiff
- Fix bug #38805 ( PDO Truncates Text from SQL Server Text Data Type Field)
authorSteph Fox <sfox@php.net>
Thu, 19 Mar 2009 22:15:03 +0000 (22:15 +0000)
committerSteph Fox <sfox@php.net>
Thu, 19 Mar 2009 22:15:03 +0000 (22:15 +0000)
- Bring behaviour into line with ext/mssql
- Several memleaks plugged

ext/pdo_dblib/dblib_driver.c
ext/pdo_dblib/dblib_stmt.c

index 7322e7026bf2e917397fddc4dc6a16a3c2a3f831..03609e62ce5b2a626c75379934fcebd2a775964b 100644 (file)
@@ -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;
        }
index fa2a95870dabdcc0326a461e71bea735f7771d3c..1677c4ab51f02e88c4b75f97b722782a5fa40295 100644 (file)
@@ -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);
                }
        }