]> granicus.if.org Git - php/commitdiff
- Fixed bug #50162 (Memory leak when fetching timestamp column from Oracle database)
authorFelipe Pena <felipe@php.net>
Sun, 6 Dec 2009 18:53:16 +0000 (18:53 +0000)
committerFelipe Pena <felipe@php.net>
Sun, 6 Dec 2009 18:53:16 +0000 (18:53 +0000)
- Fixed bug #34852 (Failure in odbc_exec() using oracle-supplied odbc driver) (patch by tim dot tassonis at trivadis dot com)

ext/odbc/php_odbc.c

index a87b9095800d23ca1878723588c497db2ae152bc..eddf0dc4635216387c0a090367c252a97c3c1e2e 100644 (file)
@@ -981,6 +981,10 @@ int odbc_bindcols(odbc_result *result TSRMLS_DC)
                                                                        NULL, 0, NULL, &displaysize);
                                displaysize = displaysize <= result->longreadlen ? displaysize : 
                                                                result->longreadlen;
+                               /* Workaround for Oracle ODBC Driver bug (#50162) when fetching TIMESTAMP column */
+                               if (result->values[i].coltype == SQL_TIMESTAMP) {
+                                       displaysize += 3;
+                               }
                                result->values[i].value = (char *)emalloc(displaysize + 1);
                                rc = SQLBindCol(result->stmt, (SQLUSMALLINT)(i+1), SQL_C_CHAR, result->values[i].value,
                                                        displaysize + 1, &result->values[i].vallen);
@@ -1176,13 +1180,7 @@ PHP_FUNCTION(odbc_prepare)
                        /* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
                           type if not possible.
                        */
-                       int cursortype = ODBCG(default_cursortype);
-                       if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype) == SQL_ERROR) {
-                               odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
-                               SQLFreeStmt(result->stmt, SQL_DROP);
-                               efree(result);
-                               RETURN_FALSE;
-                       }
+                       SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, ODBCG(default_cursortype));
                }
        } else {
                result->fetch_abs = 0;
@@ -1565,13 +1563,7 @@ PHP_FUNCTION(odbc_exec)
                        /* Try to set CURSOR_TYPE to dynamic. Driver will replace this with other
                           type if not possible.
                         */
-                       int cursortype = ODBCG(default_cursortype);
-                       if (SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, cursortype) == SQL_ERROR) {
-                               odbc_sql_error(conn, result->stmt, " SQLSetStmtOption");
-                               SQLFreeStmt(result->stmt, SQL_DROP);
-                               efree(result);
-                               RETURN_FALSE;
-                       }
+                       SQLSetStmtOption(result->stmt, SQL_CURSOR_TYPE, ODBCG(default_cursortype));
                }
        } else {
                result->fetch_abs = 0;