Skip to content

Commit

Permalink
Correctly bind parameters if new_params_bound_flag is not provided
Browse files Browse the repository at this point in the history
See issue #3585 .
If new-params-bound-flag is not provided by the client while executing
COM_STMT_EXECUTE , proxysql was incorrectly computing the length of
parameters.
The issue was happening only if there were null parameters.

Removing comment
  • Loading branch information
renecannao committed Aug 30, 2021
1 parent 3f1b15a commit 0bef2e8
Show file tree
Hide file tree
Showing 2 changed files with 429 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/MySQL_Protocol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2233,6 +2233,14 @@ stmt_execute_metadata_t * MySQL_Protocol::get_binds_from_pkt(void *ptr, unsigned
my_bool is_null = (null_byte & ( 1 << idx )) >> idx;
is_nulls[i]=is_null;
binds[i].is_null=&is_nulls[i];
// set length, defaults to 0
// for parameters with not fixed length, that will be assigned later
// we moved this initialization here due to #3585
lengths[i]=0;
binds[i].length=&lengths[i];
// NOTE: We nullify buffers here to reflect that memory wasn't
// initalized. See #3546.
binds[i].buffer = NULL;
}
free(null_bitmap); // we are done with it

Expand All @@ -2251,10 +2259,6 @@ stmt_execute_metadata_t * MySQL_Protocol::get_binds_from_pkt(void *ptr, unsigned
binds[i].buffer_type=(enum enum_field_types)buffer_type;
p+=2;

// set length, defaults to 0
// for parameters with not fixed length, that will be assigned later
lengths[i]=0;
binds[i].length=&lengths[i];
}
}

Expand All @@ -2270,9 +2274,6 @@ stmt_execute_metadata_t * MySQL_Protocol::get_binds_from_pkt(void *ptr, unsigned
continue;
} else if (is_nulls[i]==true) {
// the parameter is NULL, no need to read any data from the packet
// NOTE: We nullify buffers here to reflect that memory wasn't
// initalized. See #3546.
binds[i].buffer = NULL;
continue;
}

Expand Down
Loading

0 comments on commit 0bef2e8

Please sign in to comment.