summaryrefslogtreecommitdiff
path: root/sql/sql_crypt.h
diff options
context:
space:
mode:
authorDavi Arnaut <Davi.Arnaut@Sun.COM>2009-12-04 13:36:58 -0200
committerDavi Arnaut <Davi.Arnaut@Sun.COM>2009-12-04 13:36:58 -0200
commit96a3a92c71555d675b25449d692c3ceb4a5b1e2b (patch)
tree86207ce5eb51d9a27926e9ebb0aa7770a85e7fe8 /sql/sql_crypt.h
parenta2d630d055a63931638427967aa3cb9bfbd53b5e (diff)
downloadmariadb-git-96a3a92c71555d675b25449d692c3ceb4a5b1e2b.tar.gz
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.
Diffstat (limited to 'sql/sql_crypt.h')
-rw-r--r--sql/sql_crypt.h8
1 files changed, 4 insertions, 4 deletions
diff --git a/sql/sql_crypt.h b/sql/sql_crypt.h
index a5a6bee8a58..2b56c387bd1 100644
--- a/sql/sql_crypt.h
+++ b/sql/sql_crypt.h
@@ -23,15 +23,15 @@ class SQL_CRYPT :public Sql_alloc
struct rand_struct rand,org_rand;
char decode_buff[256],encode_buff[256];
uint shift;
- void crypt_init(ulong *seed);
public:
- SQL_CRYPT(const char *seed, uint length);
+ SQL_CRYPT() {}
SQL_CRYPT(ulong *seed)
{
- crypt_init(seed);
+ init(seed);
}
~SQL_CRYPT() {}
- void init() { shift=0; rand=org_rand; }
+ void init(ulong *seed);
+ void reinit() { shift=0; rand=org_rand; }
void encode(char *str, uint length);
void decode(char *str, uint length);
};