diff options
author | unknown <guilhem@mysql.com> | 2004-10-19 22:27:19 +0200 |
---|---|---|
committer | unknown <guilhem@mysql.com> | 2004-10-19 22:27:19 +0200 |
commit | afe39f259042a5a6dfa558d4b96b214b84be5926 (patch) | |
tree | 7f6c082dfcfda2b4cd6cb85dd9c54d984d87268a /sql/slave.cc | |
parent | 221d51ebb1b178061904e68cc2ff40a11da835d1 (diff) | |
download | mariadb-git-afe39f259042a5a6dfa558d4b96b214b84be5926.tar.gz |
Optimization: in the replication slave, we can avoid doing one strlen() per event's execution,
as we already have db_len in Log_event. Only if rewrite_db() changed the db we need a strlen
(so we now do the strlen() in rewrite_db). Plus a test (we had none for --replicate-rewrite-db :( ).
sql/log_event.cc:
The goal is to get of rid of one strlen() per replication event in slave:
we don't need to compute strlen(thd->db) as we already have db_len in the event;
only case where we need to do a strlen() is if rewrite_db() changed the db.
Note that db_len is always a meaningful value. It's 0 if event's db is 0.
sql/slave.cc:
rewrite_db now returns the len of the returned db.
print_slave_db_safe() needn't call rewrite_db() as rewrite_db() is already called by caller.
sql/slave.h:
declaration updates for slave.cc
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 4ef8715f1e6..d5278e06d8a 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -1032,7 +1032,7 @@ bool net_request_file(NET* net, const char* fname) } -const char *rewrite_db(const char* db) +const char *rewrite_db(const char* db, uint *new_len) { if (replicate_rewrite_db.is_empty() || !db) return db; @@ -1042,7 +1042,10 @@ const char *rewrite_db(const char* db) while ((tmp=it++)) { if (!strcmp(tmp->key, db)) + { + *new_len= strlen(tmp->val); return tmp->val; + } } return db; } @@ -1056,7 +1059,7 @@ const char *rewrite_db(const char* db) const char *print_slave_db_safe(const char* db) { - return (db ? rewrite_db(db) : ""); + return (db ? db : ""); } /* |