mirror of
https://github.com/php/php-src.git
synced 2024-11-24 18:34:21 +08:00
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.
This commit is contained in:
parent
fb7d5bd780
commit
c5df14364b
@ -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;
|
||||
}
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user