mirror of
https://github.com/MariaDB/server.git
synced 2025-07-29 05:21:33 +03:00
Bug#49141: Encode function is significantly slower in 5.1 compared to 5.0
The problem was that the multiple evaluations of a ENCODE or DECODE function within a single statement caused the random generator to be reinitialized at each evaluation, even though the parameters were constants. The solution is to initialize the random generator only once if the password (seed) parameter is constant. This patch borrows code and ideas from Georgi Kodinov's patch. mysql-test/r/func_str.result: Add test case result. mysql-test/r/ps.result: Add test case result. mysql-test/t/func_str.test: Add test case for Bug#49141 mysql-test/t/ps.test: Add test case for Bug#49141 sql/item_strfunc.cc: Move seed generation code to a separate method. Seed only once if the password (seed) argument is constant. Remove duplicated code and use a transform method to apply encoding or decoding. sql/item_strfunc.h: Add parameter to signal whether the PRNG is already seeded. Introduce transform method. Combine val_str methods. sql/sql_crypt.cc: Remove method. sql/sql_crypt.h: Seed is supplied as two long integers.
This commit is contained in:
@ -28,14 +28,7 @@
|
||||
|
||||
#include "mysql_priv.h"
|
||||
|
||||
SQL_CRYPT::SQL_CRYPT(const char *password, uint length)
|
||||
{
|
||||
ulong rand_nr[2];
|
||||
hash_password(rand_nr,password, length);
|
||||
crypt_init(rand_nr);
|
||||
}
|
||||
|
||||
void SQL_CRYPT::crypt_init(ulong *rand_nr)
|
||||
void SQL_CRYPT::init(ulong *rand_nr)
|
||||
{
|
||||
uint i;
|
||||
randominit(&rand,rand_nr[0],rand_nr[1]);
|
||||
|
Reference in New Issue
Block a user