From: Wez Furlong Date: Mon, 27 Mar 2006 21:04:12 +0000 (+0000) Subject: Fix for #36342; ODBC won't let you bind variables by buffer after "long" X-Git-Tag: php-5.1.3RC2~19 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c5df14364b8178ba5557308e1ebbfadae2d94453;p=php Fix for #36342; ODBC won't let you bind variables by buffer after "long" columns. We simply add a flag that indicates if we've seen any long columns and will continue to bind the columns the slow way. While we're at it, increase the maximum length of the column names that we can handle. --- diff --git a/ext/pdo_odbc/odbc_stmt.c b/ext/pdo_odbc/odbc_stmt.c index 803aa5d3f1..628779f033 100755 --- a/ext/pdo_odbc/odbc_stmt.c +++ b/ext/pdo_odbc/odbc_stmt.c @@ -146,6 +146,7 @@ static int odbc_stmt_execute(pdo_stmt_t *stmt TSRMLS_DC) stmt->column_count = (int)colcount; S->cols = ecalloc(colcount, sizeof(pdo_odbc_column)); + S->going_long = 0; } return 1; @@ -399,8 +400,9 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) col->param_type = PDO_PARAM_STR; /* tell ODBC to put it straight into our buffer, but only if it - * isn't "long" data */ - if (colsize < 256) { + * isn't "long" data, and only if we haven't already bound a long + * column. */ + if (colsize < 256 && !S->going_long) { S->cols[colno].data = emalloc(colsize+1); rc = SQLBindCol(S->stmt, colno+1, SQL_C_CHAR, S->cols[colno].data, @@ -414,6 +416,7 @@ static int odbc_stmt_describe(pdo_stmt_t *stmt, int colno TSRMLS_DC) /* allocate a smaller buffer to keep around for smaller * "long" columns */ S->cols[colno].data = emalloc(256); + S->going_long = 1; } return 1; @@ -589,6 +592,7 @@ static int odbc_stmt_next_rowset(pdo_stmt_t *stmt TSRMLS_DC) SQLNumResultCols(S->stmt, &colcount); stmt->column_count = (int)colcount; S->cols = ecalloc(colcount, sizeof(pdo_odbc_column)); + S->going_long = 0; return 1; } diff --git a/ext/pdo_odbc/php_pdo_odbc_int.h b/ext/pdo_odbc/php_pdo_odbc_int.h index 72a65ede29..8e6630052e 100755 --- a/ext/pdo_odbc/php_pdo_odbc_int.h +++ b/ext/pdo_odbc/php_pdo_odbc_int.h @@ -136,7 +136,7 @@ typedef struct { unsigned long datalen; long fetched_len; SWORD coltype; - char colname[32]; + char colname[128]; } pdo_odbc_column; typedef struct { @@ -144,6 +144,8 @@ typedef struct { pdo_odbc_column *cols; pdo_odbc_db_handle *H; pdo_odbc_errinfo einfo; + unsigned going_long:1; + unsigned _spare:31; } pdo_odbc_stmt; typedef struct {