|
View:
New views
6 Messages
—
Rating Filter:
Alert me
|
|
|
[PATCH] fix for max_length field to be populated for prepared statementsWithout this attribute set, max_length field is not filled for
prepared statements. This is from http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html : If you are using prepared statements, max_length is not set by default because for the binary protocol the lengths of the values depend on the types of the values in the result set. (See Section 20.9.5, “C API Prepared Statement Data types”.) If you want the max_length values anyway, enable the STMT_ATTR_UPDATE_MAX_LENGTH option with mysql_stmt_attr_set() and the lengths will be set when you call mysql_stmt_store_result(). (See Section 20.9.7.3, “mysql_stmt_attr_set()”, and Section 20.9.7.27, “mysql_stmt_store_result()”.) diff --git a/dbd/apr_dbd_mysql.c b/dbd/apr_dbd_mysql.c index 01afed2..0d206ac 100644 --- a/dbd/apr_dbd_mysql.c +++ b/dbd/apr_dbd_mysql.c @@ -581,8 +581,14 @@ static int dbd_mysql_prepare(apr_pool_t *pool, apr_dbd_t *sql, (*statement)->stmt = mysql_stmt_init(sql->conn); if ((*statement)->stmt) { + my_bool update_max_length = 1; + apr_pool_cleanup_register(pool, (*statement)->stmt, stmt_close, apr_pool_cleanup_null); + + mysql_stmt_attr_set((*statement)->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, + &update_max_length); + ret = mysql_stmt_prepare((*statement)->stmt, query, strlen(query)); if (ret != 0) { -- Marko Kevac Sent from Moscow, Mow, Russia |
|
|
Re: [PATCH] fix for max_length field to be populated for prepared statementshttps://issues.apache.org/bugzilla/show_bug.cgi?id=47932
On Thu, Oct 1, 2009 at 2:20 PM, Kevac Marko <marko@...> wrote: > Without this attribute set, max_length field is not filled for > prepared statements. > > This is from http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html : > > If you are using prepared statements, max_length is not set by default > because for the binary protocol the lengths of the values depend on > the types of the values in the result set. (See Section 20.9.5, “C API > Prepared Statement Data types”.) If you want the max_length values > anyway, enable the STMT_ATTR_UPDATE_MAX_LENGTH option with > mysql_stmt_attr_set() and the lengths will be set when you call > mysql_stmt_store_result(). (See Section 20.9.7.3, > “mysql_stmt_attr_set()”, and Section 20.9.7.27, > “mysql_stmt_store_result()”.) > > diff --git a/dbd/apr_dbd_mysql.c b/dbd/apr_dbd_mysql.c > index 01afed2..0d206ac 100644 > --- a/dbd/apr_dbd_mysql.c > +++ b/dbd/apr_dbd_mysql.c > @@ -581,8 +581,14 @@ static int dbd_mysql_prepare(apr_pool_t *pool, > apr_dbd_t *sql, > (*statement)->stmt = mysql_stmt_init(sql->conn); > > if ((*statement)->stmt) { > + my_bool update_max_length = 1; > + > apr_pool_cleanup_register(pool, (*statement)->stmt, > stmt_close, apr_pool_cleanup_null); > + > + mysql_stmt_attr_set((*statement)->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, > + &update_max_length); > + > ret = mysql_stmt_prepare((*statement)->stmt, query, strlen(query)); > > if (ret != 0) { > > > -- > Marko Kevac > Sent from Moscow, Mow, Russia > -- Marko Kevac Sent from Moscow, Mow, Russia |
|
|
Re: [PATCH] fix for max_length field to be populated for prepared statementsI would like to head word or two from apr-lib mantainers about this
patch. Thanks. On Fri, Oct 2, 2009 at 10:51 AM, Kevac Marko <marko@...> wrote: > https://issues.apache.org/bugzilla/show_bug.cgi?id=47932 > > On Thu, Oct 1, 2009 at 2:20 PM, Kevac Marko <marko@...> wrote: >> Without this attribute set, max_length field is not filled for >> prepared statements. >> >> This is from http://dev.mysql.com/doc/refman/5.0/en/c-api-datatypes.html : >> >> If you are using prepared statements, max_length is not set by default >> because for the binary protocol the lengths of the values depend on >> the types of the values in the result set. (See Section 20.9.5, “C API >> Prepared Statement Data types”.) If you want the max_length values >> anyway, enable the STMT_ATTR_UPDATE_MAX_LENGTH option with >> mysql_stmt_attr_set() and the lengths will be set when you call >> mysql_stmt_store_result(). (See Section 20.9.7.3, >> “mysql_stmt_attr_set()”, and Section 20.9.7.27, >> “mysql_stmt_store_result()”.) >> >> diff --git a/dbd/apr_dbd_mysql.c b/dbd/apr_dbd_mysql.c >> index 01afed2..0d206ac 100644 >> --- a/dbd/apr_dbd_mysql.c >> +++ b/dbd/apr_dbd_mysql.c >> @@ -581,8 +581,14 @@ static int dbd_mysql_prepare(apr_pool_t *pool, >> apr_dbd_t *sql, >> (*statement)->stmt = mysql_stmt_init(sql->conn); >> >> if ((*statement)->stmt) { >> + my_bool update_max_length = 1; >> + >> apr_pool_cleanup_register(pool, (*statement)->stmt, >> stmt_close, apr_pool_cleanup_null); >> + >> + mysql_stmt_attr_set((*statement)->stmt, STMT_ATTR_UPDATE_MAX_LENGTH, >> + &update_max_length); >> + >> ret = mysql_stmt_prepare((*statement)->stmt, query, strlen(query)); >> >> if (ret != 0) { >> >> >> -- >> Marko Kevac >> Sent from Moscow, Mow, Russia >> > > > > -- > Marko Kevac > Sent from Moscow, Mow, Russia > -- Marko Kevac Sent from Moscow, Mow, Russia |
|
|
Re: [PATCH] fix for max_length field to be populated for prepared statementsOn Thu, 2009-10-01 at 14:20 +0400, Kevac Marko wrote:
> Without this attribute set, max_length field is not filled for > prepared statements. I'm not seeing use of max_length in the driver. Can you elaborate a bit more what this is for? >From what I can see we rely on buffer_length for prepared stuff, no? -- Bojan |
|
|
Re: [PATCH] fix for max_length field to be populated for prepared statementsWell, yes. It is not used in apr_dbd_mysql.
For our project we are using apr_dbd, which don't have enough features yet for our needs. For example, we are using information from MYSQL_FIELD structure, which, again, is not available from apr_dbd.h functions. Anyway, with some dark "hack" magic one can access it (of course in non-portable manner). Variable max_length in MYSQL_FIELD is not populated for prepared statements without flag in patch. This is why we need it. Maybe this violates some kind of "not needed feature" rule. If so, than what is your advice? Thanks. On Sat, Oct 10, 2009 at 7:29 AM, Bojan Smojver <bojan@...> wrote: > On Thu, 2009-10-01 at 14:20 +0400, Kevac Marko wrote: >> Without this attribute set, max_length field is not filled for >> prepared statements. > > I'm not seeing use of max_length in the driver. Can you elaborate a bit > more what this is for? > > >From what I can see we rely on buffer_length for prepared stuff, no? > > -- > Bojan > > -- Marko Kevac Sent from Moscow, Mow, Russia |
|
|
Re: [PATCH] fix for max_length field to be populated for prepared statementsOn Sat, 2009-10-10 at 10:55 +0400, Kevac Marko wrote:
> For example, we are using information from MYSQL_FIELD structure, > which, again, is not available from apr_dbd.h functions. Anyway, with > some dark "hack" magic one can access it (of course in non-portable > manner). I'm guessing you are getting the handle directly with apr_dbd_native_handle() and then executing MySQL calls on it, right? > Variable max_length in MYSQL_FIELD is not populated for prepared > statements without flag in patch. This is why we need it. Normally, the driver will contain stuff it needs in order to satisfy its own API. If you are using hacks to get to MySQL stuff, maybe you can set STMT_ATTR_UPDATE_MAX_LENGTH directly after getting the prepared statement using another hack? -- Bojan |
| Free embeddable forum powered by Nabble | Forum Help |