=== modified file 'driver/execute.c' --- driver/execute.c 2009-12-18 09:46:17 +0000 +++ driver/execute.c 2010-01-18 05:19:38 +0000 @@ -53,10 +53,12 @@ if ( !myodbc_casecmp(pos,"select",6) ) { uint length= strlen(pos); + int pos_for_update= is_for_update_statement(pos, length); if ( (tmp_buffer= my_malloc(length+30,MYF(0))) ) { memcpy(tmp_buffer,pos,length); - sprintf(tmp_buffer+length, " limit %lu", + sprintf(tmp_buffer + length - pos_for_update, + pos_for_update ? " LIMIT %lu FOR UPDATE" : " LIMIT %lu", (unsigned long)stmt->stmt_options.max_rows); if ( query != stmt->query ) my_free(query,MYF(0)); === modified file 'driver/utility.c' --- driver/utility.c 2009-12-18 09:46:17 +0000 +++ driver/utility.c 2010-01-18 05:16:26 +0000 @@ -2687,6 +2687,28 @@ /** + Detect if a statement ends with FOR UPDATE. +*/ +int is_for_update_statement(SQLCHAR *query, uint len) +{ + SQLCHAR *query_end= query + len - 1; + SQLCHAR *save_pos= query_end; + /* Skip trailing spaces and semicolons */ + while (query_end && (query < query_end) && + (isspace(*query_end) || (*query_end==';'))) + query_end--; + + if (query < query_end - 10) + { + query_end-= 10; + if(myodbc_casecmp((char *)query_end, "FOR UPDATE", 10)) + return save_pos - query_end + 1; + } + return 0; +} + + +/** Adjust a pointer based on bind offset and bind type. @param[in] ptr The base pointer