developers
Threads by month
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
October 2009
- 18 participants
- 235 discussions
[Maria-developers] Updated (by Guest): Add a mysqlbinlog option to change the used database (36)
by worklog-noreply@askmonty.org 03 Oct '09
by worklog-noreply@askmonty.org 03 Oct '09
03 Oct '09
-----------------------------------------------------------------------
WORKLOG TASK
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TASK...........: Add a mysqlbinlog option to change the used database
CREATION DATE..: Fri, 07 Aug 2009, 14:57
SUPERVISOR.....: Monty
IMPLEMENTOR....:
COPIES TO......:
CATEGORY.......: Server-RawIdeaBin
TASK ID........: 36 (http://askmonty.org/worklog/?tid=36)
VERSION........: Server-9.x
STATUS.........: Un-Assigned
PRIORITY.......: 60
WORKED HOURS...: 0
ESTIMATE.......: 0 (hours remain)
ORIG. ESTIMATE.: 0
PROGRESS NOTES:
-=-=(Guest - Sat, 03 Oct 2009, 02:27)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.23366 2009-10-03 02:27:45.000000000 +0300
+++ /tmp/wklog.36.new.23366 2009-10-03 02:27:45.000000000 +0300
@@ -1,77 +1 @@
-Context
--------
-(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
-overview)
-At the moment, the server has a replication slave option
-
- --replicate-rewrite-db="from->to"
-
-the option affects
-- Table_map_log_event (all RBR events)
-- Load_log_event (LOAD DATA)
-- Query_log_event (SBR-based updates, with the usual assumption that the
- statement refers to tables in current database, so that changing the current
- database will make the statement to work on a table in a different database).
-
-See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
-merged into MariaDB at the time of writing, but planned to be merged before
-release.
-
-What we could do
-----------------
-
-Option1: make mysqlbinlog accept --replicate-rewrite-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
-same extent as replication slave would process --replicate-rewrite-db option.
-
-
-Option2: Add database-agnostic RBR events and --strip-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Right now RBR events require a databasename. It is not possible to have RBR
-event stream that won't mention which database the events are for. When I
-tried to use debugger and specify empty database name, attempt to apply the
-binlog resulted in this error:
-
-090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
-opening tables,
-
-We could do as follows:
-- Make the server interpret empty database name in RBR event (i.e. in a
- Table_map_log_event) as "use current database". Binlog slave thread
- probably should not allow such events as it doesn't have a natural current
- database.
-- Add a mysqlbinlog --strip-db option that would
- = not produce any "USE dbname" statements
- = change databasename for all RBR events to be empty
-
-That way, mysqlbinlog output will be database-agnostic and apply to the
-current database.
-(this will have the usual limitations that we assume that all statements in
-the binlog refer to the current database).
-
-Option3: Enhance database rewrite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If there is a need to support database change for statements that use
-dbname.tablename notation and are replicated as statements (i.e. are DDL
-statements and/or DML statements that are binlogged as statements),
-then that could be supported as follows:
-
-- Make the server's parser recognize special form of comments
-
- /* !database-alias(oldname,newname) */
-
- and save the mapping somewhere
-
-- Put the hooks in table open and name resolution code to use the saved
- mapping.
-
-
-Once we've done the above, it will be easy to perform a complete,
-no-compromise or restrictions database name change in binary log.
-
-It will be possible to do the rewrites either on the slave (
---replicate-rewrite-db will work for all kinds of statements), or in
-mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
-parse the statement).
-
+G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
-=-=(Guest - Tue, 15 Sep 2009, 18:04)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.19322 2009-09-15 18:04:49.000000000 +0300
+++ /tmp/wklog.36.new.19322 2009-09-15 18:04:49.000000000 +0300
@@ -191,7 +191,7 @@
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
- events lis above), e.g.:
+ events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
-=-=(Guest - Tue, 15 Sep 2009, 15:53)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.13421 2009-09-15 15:53:31.000000000 +0300
+++ /tmp/wklog.36.new.13421 2009-09-15 15:53:31.000000000 +0300
@@ -150,10 +150,17 @@
following events (see process_event() function):
- Query_log_event
-- Execute_load_query_log_event
-- Create_file_log_event
-
-TODO. Needed to check this list requires carefully !!!
+- Load_log_event
+- Execute_load_query_log_event [ :public Query_log_event ]
+- Create_file_log_event [ :public Load_log_event ]
+
+TODO. Needed to check this list carefully (not sure for Create_file_log_event)
+ Notes.
+ - In replication, only Query_log_event and Load_log_event uses
+ rpl_filter->get_rewrite_db();
+ - In mysqlbinlog (process_event), Execute_load_query_log_event
+ and Create_file_log_event are processed in separate switch
+ cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
@@ -182,8 +189,9 @@
*/
}
-- In process_event() function add print_use_stmt() invocations where
- needed (according to the events lis above), e.g.:
+- In process_event() function add switch case for Load_log_event and
+ add print_use_stmt() invocations where needed (according to the
+ events lis above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
@@ -207,6 +215,11 @@
}
break;
...
+ case LOAD_EVENT:
+ print_use_stmt((Load_log_event*)ev, print_event_info);
+ break;
+ default:
+ ...
}
...
}
-=-=(Guest - Tue, 15 Sep 2009, 12:12)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3961 2009-09-15 12:12:26.000000000 +0300
+++ /tmp/wklog.36.new.3961 2009-09-15 12:12:26.000000000 +0300
@@ -144,6 +144,8 @@
3. Supporting rewrite-db for SBR events
---------------------------------------
+Limited to emiting USE <db_to> instead of USE <db_from>.
+
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
-=-=(Guest - Tue, 15 Sep 2009, 12:08)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3794 2009-09-15 12:08:54.000000000 +0300
+++ /tmp/wklog.36.new.3794 2009-09-15 12:08:54.000000000 +0300
@@ -1 +1,229 @@
+Content
+-------
+1. Adding rewrite-db option
+2. Supporting rewrite-db option for RBR events
+3. Supporting rewrite-db option for SBR events
+ (Limited to affecting only USE statements)
+4. Current status
+
+1. Adding rewrite-db option
+---------------------------
+
+1.1. Syntax:
+ --rewrite-db='db_from->db_to'
+
+1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
+
+1.3. In mysqlbinlog.cc:
+
+- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
+- Add Rpl_filter object to mysqlbinlog.cc
+
+ Rpl_filter* binlog_filter;
+
+- Add corresponding switch case to get_one_option():
+
+ case OPT_REWRITE_DB:
+ <extract db-from and db-to strings>
+ binlog_filter->add_db_rewrite(db_from, db_to);
+ break;
+ .
+Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
+additional changes are required:
+
+- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
+ uses sql_alloc() which is THD dependent. These are to be modified
+ as follows:
+
+ #ifdef MYSQL_CLIENT
+ extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
+ #endif
+
+ class Sql_alloc
+ { ...
+ static void *operator new(size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ static void *operator new[](size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ ...
+ }
+
+- In rpl_filter.cc:
+
+ Rpl_filter::Rpl_filter() :
+ ...
+ {
+ #ifdef MYSQL_CLIENT
+ init_alloc_root(&sql_list_client_mem_root, ...);
+ #endif
+ ...
+ }
+
+ Rpl_filter::~Rpl_filter()
+ { ...
+ #ifdef MYSQL_CLIENT
+ free_root(&sql_list_client_mem_root, ...);
+ #endif
+ }
+
+2. Supporting rewrite-db for RBR events
+---------------------------------------
+
+In binlog, each row operation event is preceded by Table map event(s) which maps
+table id(s) to database and table names. So, it's enough to support rewriting
+database name in a Table map.
+
+2.1. Add rewrite_db() member to Table_map_log_event:
+
+ int Table_map_log_event::rewrite_db(
+ const char* new_db,
+ size_t new_db_len,
+ const Format_description_log_event* desc)
+ {
+ /* 1. In temp_buf member (possibly reallocating it) rewrite
+ event length, db length, and db parts
+ 2. Change m_dblen and m_dbnam members
+ */
+ }
+
+Comment. This function assumes that temp_buf member contains Table map
+binlog representaion (temp_buf is used for creating corresponding
+BINLOG statement).
+
+2.2. In mysqlbinlog modify corresponding switch case in the
+process_event() function:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ ...
+ case TABLE_MAP_EVENT:
+ {
+ Table_map_log_event *map= ((Table_map_log_event *)ev);
+ if (shall_skip_database(map->get_db_name()))
+ { ...
+ }
+ // WL36
+ size_t new_len= 0;
+ const char* new_db= binlog_filter->get_rewrite_db(
+ map->get_db_name(), &new_len);
+ if (new_len && map->rewrite_db(new_db, new_len,
+ glob_description_event))
+ { error("Could not rewrite database name");
+ goto err;
+ }
+ }
+ case WRITE_ROWS_EVENT:
+ case DELETE_ROWS_EVENT:
+ case UPDATE_ROWS_EVENT:
+ ...
+ }
+ ...
+ }
+
+Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
+a (db_from, db_to) pair, this function returns pointer to db_to and
+sets len = db_to length; otherwise, it returns db_from and does not
+change len value.
+
+3. Supporting rewrite-db for SBR events
+---------------------------------------
+
+USE statements can be emited by mysqlbinlog as a result of processing the
+following events (see process_event() function):
+
+- Query_log_event
+- Execute_load_query_log_event
+- Create_file_log_event
+
+TODO. Needed to check this list requires carefully !!!
+
+Conditions for emiting use-statement:
+- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
+ (e.g. it is ON for 'create database' statement)
+- event's db name differs from db_name in PRINT_EVENT_INFO
+ (PRINT_EVENT_INFO keeps db name of the last issued USE statement;
+ initially, this db name is empty).
+
+3.1. In mysqlbinlog.cc
+
+- Add the following function:
+
+ void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
+ {
+ if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
+ return;
+ /*
+ - For events listed above get db_from = event->db;
+ - If db_from is the same as pinfo->db then return;
+ - If there is rewrite-db rule db_from->db_to,
+ set db = db_to. Else set db = db_from;
+ - Print "use <db>" to mysqlbinlog output
+ - Set pinfo->db = db_from
+ (this suppresses emiting use-statements by corresponding
+ log_event's print-function)
+ */
+ }
+
+- In process_event() function add print_use_stmt() invocations where
+ needed (according to the events lis above), e.g.:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ case QUERY_EVENT:
+ if (shall_skip_database(((Query_log_event*)ev)->db))
+ goto end;
+ if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+ {
+ // Possibly in case of rewite-db rule for ev->db
+ // a warning should be emited here (see note below)
+ ... write_event_header_and_base64(ev, ...) ...
+ }
+ else
+ {
+ print_use_stmt((Query_log_event*)ev, print_event_info);
+ ev->print(result_file, print_event_info);
+ }
+ break;
+ ...
+ }
+ ...
+ }
+
+Note. write_event_header_and_base64() does not print use-statement. It
+produces BINLOG statement using ev->temp_buf content (i.e. the binary
+log representation of the event). We don't rewrite temp_buf here with
+db_to name (as we do it for Table map event) - this implies the
+limitation 3 mentioned above.
+Question: Is supporting of rewite_db + --base64-output really needed
+currently?
+
+4. Current status
+-----------------
+
+The outlined design (implemented for mysql-5.1.37) is tested for
+simple test-cases.
+
+TODO. 1. Check list of events which can emit use-statement.
+ 2. Supporting of rewite_db + --base64-output ?
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9711 2009-09-14 11:51:43.000000000 +0300
+++ /tmp/wklog.36.new.9711 2009-09-14 11:51:43.000000000 +0300
@@ -1 +1 @@
-Pay no attention: just check for having access
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9678 2009-09-14 11:51:28.000000000 +0300
+++ /tmp/wklog.36.new.9678 2009-09-14 11:51:28.000000000 +0300
@@ -1 +1 @@
-
+Pay no attention: just check for having access
-=-=(Knielsen - Mon, 17 Aug 2009, 12:44)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.7834 2009-08-17 12:44:17.000000000 +0300
+++ /tmp/wklog.36.new.7834 2009-08-17 12:44:17.000000000 +0300
@@ -13,7 +13,9 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
-See also MySQL BUG#42941.
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
What we could do
----------------
-=-=(Guest - Sun, 16 Aug 2009, 17:11)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.27162 2009-08-16 17:11:12.000000000 +0300
+++ /tmp/wklog.36.new.27162 2009-08-16 17:11:12.000000000 +0300
@@ -13,6 +13,8 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
+See also MySQL BUG#42941.
+
What we could do
----------------
-=-=(Psergey - Mon, 10 Aug 2009, 15:41)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.13035 2009-08-10 15:41:51.000000000 +0300
+++ /tmp/wklog.36.new.13035 2009-08-10 15:41:51.000000000 +0300
@@ -1,5 +1,7 @@
Context
-------
+(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
+overview)
At the moment, the server has a replication slave option
--replicate-rewrite-db="from->to"
------------------------------------------------------------
-=-=(View All Progress Notes, 14 total)=-=-
http://askmonty.org/worklog/index.pl?tid=36&nolimit=1
DESCRIPTION:
Sometimes there is a need to take a binary log and apply it to a database with
a different name than the original name of the database on binlog producer.
If one is using statement-based replication, he can achieve this by grepping
out "USE dbname" statements out of the output of mysqlbinlog(*). With
row-based replication this is no longer possible, as database name is encoded
within the the BINLOG '....' statement.
This task is about adding an option to mysqlbinlog that would allow to change
the names of used databases in both RBR and SBR events.
(*) this implies that all statements refer to tables in the current database,
doesn't catch updates made inside stored functions and so forth, but still
works for a practially-important subset of cases.
HIGH-LEVEL SPECIFICATION:
G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
LOW-LEVEL DESIGN:
Content
-------
1. Adding rewrite-db option
2. Supporting rewrite-db option for RBR events
3. Supporting rewrite-db option for SBR events
(Limited to affecting only USE statements)
4. Current status
1. Adding rewrite-db option
---------------------------
1.1. Syntax:
--rewrite-db='db_from->db_to'
1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
1.3. In mysqlbinlog.cc:
- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
- Add Rpl_filter object to mysqlbinlog.cc
Rpl_filter* binlog_filter;
- Add corresponding switch case to get_one_option():
case OPT_REWRITE_DB:
<extract db-from and db-to strings>
binlog_filter->add_db_rewrite(db_from, db_to);
break;
.
Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
additional changes are required:
- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
uses sql_alloc() which is THD dependent. These are to be modified
as follows:
#ifdef MYSQL_CLIENT
extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
#endif
class Sql_alloc
{ ...
static void *operator new(size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
static void *operator new[](size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
...
}
- In rpl_filter.cc:
Rpl_filter::Rpl_filter() :
...
{
#ifdef MYSQL_CLIENT
init_alloc_root(&sql_list_client_mem_root, ...);
#endif
...
}
Rpl_filter::~Rpl_filter()
{ ...
#ifdef MYSQL_CLIENT
free_root(&sql_list_client_mem_root, ...);
#endif
}
2. Supporting rewrite-db for RBR events
---------------------------------------
In binlog, each row operation event is preceded by Table map event(s) which maps
table id(s) to database and table names. So, it's enough to support rewriting
database name in a Table map.
2.1. Add rewrite_db() member to Table_map_log_event:
int Table_map_log_event::rewrite_db(
const char* new_db,
size_t new_db_len,
const Format_description_log_event* desc)
{
/* 1. In temp_buf member (possibly reallocating it) rewrite
event length, db length, and db parts
2. Change m_dblen and m_dbnam members
*/
}
Comment. This function assumes that temp_buf member contains Table map
binlog representaion (temp_buf is used for creating corresponding
BINLOG statement).
2.2. In mysqlbinlog modify corresponding switch case in the
process_event() function:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
...
case TABLE_MAP_EVENT:
{
Table_map_log_event *map= ((Table_map_log_event *)ev);
if (shall_skip_database(map->get_db_name()))
{ ...
}
// WL36
size_t new_len= 0;
const char* new_db= binlog_filter->get_rewrite_db(
map->get_db_name(), &new_len);
if (new_len && map->rewrite_db(new_db, new_len,
glob_description_event))
{ error("Could not rewrite database name");
goto err;
}
}
case WRITE_ROWS_EVENT:
case DELETE_ROWS_EVENT:
case UPDATE_ROWS_EVENT:
...
}
...
}
Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
a (db_from, db_to) pair, this function returns pointer to db_to and
sets len = db_to length; otherwise, it returns db_from and does not
change len value.
3. Supporting rewrite-db for SBR events
---------------------------------------
Limited to emiting USE <db_to> instead of USE <db_from>.
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
- Query_log_event
- Load_log_event
- Execute_load_query_log_event [ :public Query_log_event ]
- Create_file_log_event [ :public Load_log_event ]
TODO. Needed to check this list carefully (not sure for Create_file_log_event)
Notes.
- In replication, only Query_log_event and Load_log_event uses
rpl_filter->get_rewrite_db();
- In mysqlbinlog (process_event), Execute_load_query_log_event
and Create_file_log_event are processed in separate switch
cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
(e.g. it is ON for 'create database' statement)
- event's db name differs from db_name in PRINT_EVENT_INFO
(PRINT_EVENT_INFO keeps db name of the last issued USE statement;
initially, this db name is empty).
3.1. In mysqlbinlog.cc
- Add the following function:
void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
{
if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
return;
/*
- For events listed above get db_from = event->db;
- If db_from is the same as pinfo->db then return;
- If there is rewrite-db rule db_from->db_to,
set db = db_to. Else set db = db_from;
- Print "use <db>" to mysqlbinlog output
- Set pinfo->db = db_from
(this suppresses emiting use-statements by corresponding
log_event's print-function)
*/
}
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
case QUERY_EVENT:
if (shall_skip_database(((Query_log_event*)ev)->db))
goto end;
if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
{
// Possibly in case of rewite-db rule for ev->db
// a warning should be emited here (see note below)
... write_event_header_and_base64(ev, ...) ...
}
else
{
print_use_stmt((Query_log_event*)ev, print_event_info);
ev->print(result_file, print_event_info);
}
break;
...
case LOAD_EVENT:
print_use_stmt((Load_log_event*)ev, print_event_info);
break;
default:
...
}
...
}
Note. write_event_header_and_base64() does not print use-statement. It
produces BINLOG statement using ev->temp_buf content (i.e. the binary
log representation of the event). We don't rewrite temp_buf here with
db_to name (as we do it for Table map event) - this implies the
limitation 3 mentioned above.
Question: Is supporting of rewite_db + --base64-output really needed
currently?
4. Current status
-----------------
The outlined design (implemented for mysql-5.1.37) is tested for
simple test-cases.
TODO. 1. Check list of events which can emit use-statement.
2. Supporting of rewite_db + --base64-output ?
ESTIMATED WORK TIME
ESTIMATED COMPLETION DATE
-----------------------------------------------------------------------
WorkLog (v3.5.9)
2
1
[Maria-developers] Updated (by Knielsen): Add a mysqlbinlog option to change the used database (36)
by worklog-noreply@askmonty.org 03 Oct '09
by worklog-noreply@askmonty.org 03 Oct '09
03 Oct '09
-----------------------------------------------------------------------
WORKLOG TASK
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TASK...........: Add a mysqlbinlog option to change the used database
CREATION DATE..: Fri, 07 Aug 2009, 14:57
SUPERVISOR.....: Monty
IMPLEMENTOR....:
COPIES TO......:
CATEGORY.......: Server-RawIdeaBin
TASK ID........: 36 (http://askmonty.org/worklog/?tid=36)
VERSION........: Server-9.x
STATUS.........: Un-Assigned
PRIORITY.......: 60
WORKED HOURS...: 0
ESTIMATE.......: 0 (hours remain)
ORIG. ESTIMATE.: 0
PROGRESS NOTES:
-=-=(Knielsen - Sat, 03 Oct 2009, 08:34)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.5353 2009-10-03 08:34:43.000000000 +0300
+++ /tmp/wklog.36.new.5353 2009-10-03 08:34:43.000000000 +0300
@@ -1 +1,77 @@
-G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
+Context
+-------
+(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
+overview)
+At the moment, the server has a replication slave option
+
+ --replicate-rewrite-db="from->to"
+
+the option affects
+- Table_map_log_event (all RBR events)
+- Load_log_event (LOAD DATA)
+- Query_log_event (SBR-based updates, with the usual assumption that the
+ statement refers to tables in current database, so that changing the current
+ database will make the statement to work on a table in a different database).
+
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
+
+What we could do
+----------------
+
+Option1: make mysqlbinlog accept --replicate-rewrite-db option
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
+same extent as replication slave would process --replicate-rewrite-db option.
+
+
+Option2: Add database-agnostic RBR events and --strip-db option
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Right now RBR events require a databasename. It is not possible to have RBR
+event stream that won't mention which database the events are for. When I
+tried to use debugger and specify empty database name, attempt to apply the
+binlog resulted in this error:
+
+090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
+opening tables,
+
+We could do as follows:
+- Make the server interpret empty database name in RBR event (i.e. in a
+ Table_map_log_event) as "use current database". Binlog slave thread
+ probably should not allow such events as it doesn't have a natural current
+ database.
+- Add a mysqlbinlog --strip-db option that would
+ = not produce any "USE dbname" statements
+ = change databasename for all RBR events to be empty
+
+That way, mysqlbinlog output will be database-agnostic and apply to the
+current database.
+(this will have the usual limitations that we assume that all statements in
+the binlog refer to the current database).
+
+Option3: Enhance database rewrite
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If there is a need to support database change for statements that use
+dbname.tablename notation and are replicated as statements (i.e. are DDL
+statements and/or DML statements that are binlogged as statements),
+then that could be supported as follows:
+
+- Make the server's parser recognize special form of comments
+
+ /* !database-alias(oldname,newname) */
+
+ and save the mapping somewhere
+
+- Put the hooks in table open and name resolution code to use the saved
+ mapping.
+
+
+Once we've done the above, it will be easy to perform a complete,
+no-compromise or restrictions database name change in binary log.
+
+It will be possible to do the rewrites either on the slave (
+--replicate-rewrite-db will work for all kinds of statements), or in
+mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
+parse the statement).
+
-=-=(Guest - Sat, 03 Oct 2009, 02:27)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.23366 2009-10-03 02:27:45.000000000 +0300
+++ /tmp/wklog.36.new.23366 2009-10-03 02:27:45.000000000 +0300
@@ -1,77 +1 @@
-Context
--------
-(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
-overview)
-At the moment, the server has a replication slave option
-
- --replicate-rewrite-db="from->to"
-
-the option affects
-- Table_map_log_event (all RBR events)
-- Load_log_event (LOAD DATA)
-- Query_log_event (SBR-based updates, with the usual assumption that the
- statement refers to tables in current database, so that changing the current
- database will make the statement to work on a table in a different database).
-
-See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
-merged into MariaDB at the time of writing, but planned to be merged before
-release.
-
-What we could do
-----------------
-
-Option1: make mysqlbinlog accept --replicate-rewrite-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
-same extent as replication slave would process --replicate-rewrite-db option.
-
-
-Option2: Add database-agnostic RBR events and --strip-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Right now RBR events require a databasename. It is not possible to have RBR
-event stream that won't mention which database the events are for. When I
-tried to use debugger and specify empty database name, attempt to apply the
-binlog resulted in this error:
-
-090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
-opening tables,
-
-We could do as follows:
-- Make the server interpret empty database name in RBR event (i.e. in a
- Table_map_log_event) as "use current database". Binlog slave thread
- probably should not allow such events as it doesn't have a natural current
- database.
-- Add a mysqlbinlog --strip-db option that would
- = not produce any "USE dbname" statements
- = change databasename for all RBR events to be empty
-
-That way, mysqlbinlog output will be database-agnostic and apply to the
-current database.
-(this will have the usual limitations that we assume that all statements in
-the binlog refer to the current database).
-
-Option3: Enhance database rewrite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If there is a need to support database change for statements that use
-dbname.tablename notation and are replicated as statements (i.e. are DDL
-statements and/or DML statements that are binlogged as statements),
-then that could be supported as follows:
-
-- Make the server's parser recognize special form of comments
-
- /* !database-alias(oldname,newname) */
-
- and save the mapping somewhere
-
-- Put the hooks in table open and name resolution code to use the saved
- mapping.
-
-
-Once we've done the above, it will be easy to perform a complete,
-no-compromise or restrictions database name change in binary log.
-
-It will be possible to do the rewrites either on the slave (
---replicate-rewrite-db will work for all kinds of statements), or in
-mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
-parse the statement).
-
+G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
-=-=(Guest - Tue, 15 Sep 2009, 18:04)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.19322 2009-09-15 18:04:49.000000000 +0300
+++ /tmp/wklog.36.new.19322 2009-09-15 18:04:49.000000000 +0300
@@ -191,7 +191,7 @@
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
- events lis above), e.g.:
+ events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
-=-=(Guest - Tue, 15 Sep 2009, 15:53)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.13421 2009-09-15 15:53:31.000000000 +0300
+++ /tmp/wklog.36.new.13421 2009-09-15 15:53:31.000000000 +0300
@@ -150,10 +150,17 @@
following events (see process_event() function):
- Query_log_event
-- Execute_load_query_log_event
-- Create_file_log_event
-
-TODO. Needed to check this list requires carefully !!!
+- Load_log_event
+- Execute_load_query_log_event [ :public Query_log_event ]
+- Create_file_log_event [ :public Load_log_event ]
+
+TODO. Needed to check this list carefully (not sure for Create_file_log_event)
+ Notes.
+ - In replication, only Query_log_event and Load_log_event uses
+ rpl_filter->get_rewrite_db();
+ - In mysqlbinlog (process_event), Execute_load_query_log_event
+ and Create_file_log_event are processed in separate switch
+ cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
@@ -182,8 +189,9 @@
*/
}
-- In process_event() function add print_use_stmt() invocations where
- needed (according to the events lis above), e.g.:
+- In process_event() function add switch case for Load_log_event and
+ add print_use_stmt() invocations where needed (according to the
+ events lis above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
@@ -207,6 +215,11 @@
}
break;
...
+ case LOAD_EVENT:
+ print_use_stmt((Load_log_event*)ev, print_event_info);
+ break;
+ default:
+ ...
}
...
}
-=-=(Guest - Tue, 15 Sep 2009, 12:12)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3961 2009-09-15 12:12:26.000000000 +0300
+++ /tmp/wklog.36.new.3961 2009-09-15 12:12:26.000000000 +0300
@@ -144,6 +144,8 @@
3. Supporting rewrite-db for SBR events
---------------------------------------
+Limited to emiting USE <db_to> instead of USE <db_from>.
+
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
-=-=(Guest - Tue, 15 Sep 2009, 12:08)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3794 2009-09-15 12:08:54.000000000 +0300
+++ /tmp/wklog.36.new.3794 2009-09-15 12:08:54.000000000 +0300
@@ -1 +1,229 @@
+Content
+-------
+1. Adding rewrite-db option
+2. Supporting rewrite-db option for RBR events
+3. Supporting rewrite-db option for SBR events
+ (Limited to affecting only USE statements)
+4. Current status
+
+1. Adding rewrite-db option
+---------------------------
+
+1.1. Syntax:
+ --rewrite-db='db_from->db_to'
+
+1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
+
+1.3. In mysqlbinlog.cc:
+
+- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
+- Add Rpl_filter object to mysqlbinlog.cc
+
+ Rpl_filter* binlog_filter;
+
+- Add corresponding switch case to get_one_option():
+
+ case OPT_REWRITE_DB:
+ <extract db-from and db-to strings>
+ binlog_filter->add_db_rewrite(db_from, db_to);
+ break;
+ .
+Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
+additional changes are required:
+
+- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
+ uses sql_alloc() which is THD dependent. These are to be modified
+ as follows:
+
+ #ifdef MYSQL_CLIENT
+ extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
+ #endif
+
+ class Sql_alloc
+ { ...
+ static void *operator new(size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ static void *operator new[](size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ ...
+ }
+
+- In rpl_filter.cc:
+
+ Rpl_filter::Rpl_filter() :
+ ...
+ {
+ #ifdef MYSQL_CLIENT
+ init_alloc_root(&sql_list_client_mem_root, ...);
+ #endif
+ ...
+ }
+
+ Rpl_filter::~Rpl_filter()
+ { ...
+ #ifdef MYSQL_CLIENT
+ free_root(&sql_list_client_mem_root, ...);
+ #endif
+ }
+
+2. Supporting rewrite-db for RBR events
+---------------------------------------
+
+In binlog, each row operation event is preceded by Table map event(s) which maps
+table id(s) to database and table names. So, it's enough to support rewriting
+database name in a Table map.
+
+2.1. Add rewrite_db() member to Table_map_log_event:
+
+ int Table_map_log_event::rewrite_db(
+ const char* new_db,
+ size_t new_db_len,
+ const Format_description_log_event* desc)
+ {
+ /* 1. In temp_buf member (possibly reallocating it) rewrite
+ event length, db length, and db parts
+ 2. Change m_dblen and m_dbnam members
+ */
+ }
+
+Comment. This function assumes that temp_buf member contains Table map
+binlog representaion (temp_buf is used for creating corresponding
+BINLOG statement).
+
+2.2. In mysqlbinlog modify corresponding switch case in the
+process_event() function:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ ...
+ case TABLE_MAP_EVENT:
+ {
+ Table_map_log_event *map= ((Table_map_log_event *)ev);
+ if (shall_skip_database(map->get_db_name()))
+ { ...
+ }
+ // WL36
+ size_t new_len= 0;
+ const char* new_db= binlog_filter->get_rewrite_db(
+ map->get_db_name(), &new_len);
+ if (new_len && map->rewrite_db(new_db, new_len,
+ glob_description_event))
+ { error("Could not rewrite database name");
+ goto err;
+ }
+ }
+ case WRITE_ROWS_EVENT:
+ case DELETE_ROWS_EVENT:
+ case UPDATE_ROWS_EVENT:
+ ...
+ }
+ ...
+ }
+
+Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
+a (db_from, db_to) pair, this function returns pointer to db_to and
+sets len = db_to length; otherwise, it returns db_from and does not
+change len value.
+
+3. Supporting rewrite-db for SBR events
+---------------------------------------
+
+USE statements can be emited by mysqlbinlog as a result of processing the
+following events (see process_event() function):
+
+- Query_log_event
+- Execute_load_query_log_event
+- Create_file_log_event
+
+TODO. Needed to check this list requires carefully !!!
+
+Conditions for emiting use-statement:
+- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
+ (e.g. it is ON for 'create database' statement)
+- event's db name differs from db_name in PRINT_EVENT_INFO
+ (PRINT_EVENT_INFO keeps db name of the last issued USE statement;
+ initially, this db name is empty).
+
+3.1. In mysqlbinlog.cc
+
+- Add the following function:
+
+ void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
+ {
+ if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
+ return;
+ /*
+ - For events listed above get db_from = event->db;
+ - If db_from is the same as pinfo->db then return;
+ - If there is rewrite-db rule db_from->db_to,
+ set db = db_to. Else set db = db_from;
+ - Print "use <db>" to mysqlbinlog output
+ - Set pinfo->db = db_from
+ (this suppresses emiting use-statements by corresponding
+ log_event's print-function)
+ */
+ }
+
+- In process_event() function add print_use_stmt() invocations where
+ needed (according to the events lis above), e.g.:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ case QUERY_EVENT:
+ if (shall_skip_database(((Query_log_event*)ev)->db))
+ goto end;
+ if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+ {
+ // Possibly in case of rewite-db rule for ev->db
+ // a warning should be emited here (see note below)
+ ... write_event_header_and_base64(ev, ...) ...
+ }
+ else
+ {
+ print_use_stmt((Query_log_event*)ev, print_event_info);
+ ev->print(result_file, print_event_info);
+ }
+ break;
+ ...
+ }
+ ...
+ }
+
+Note. write_event_header_and_base64() does not print use-statement. It
+produces BINLOG statement using ev->temp_buf content (i.e. the binary
+log representation of the event). We don't rewrite temp_buf here with
+db_to name (as we do it for Table map event) - this implies the
+limitation 3 mentioned above.
+Question: Is supporting of rewite_db + --base64-output really needed
+currently?
+
+4. Current status
+-----------------
+
+The outlined design (implemented for mysql-5.1.37) is tested for
+simple test-cases.
+
+TODO. 1. Check list of events which can emit use-statement.
+ 2. Supporting of rewite_db + --base64-output ?
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9711 2009-09-14 11:51:43.000000000 +0300
+++ /tmp/wklog.36.new.9711 2009-09-14 11:51:43.000000000 +0300
@@ -1 +1 @@
-Pay no attention: just check for having access
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9678 2009-09-14 11:51:28.000000000 +0300
+++ /tmp/wklog.36.new.9678 2009-09-14 11:51:28.000000000 +0300
@@ -1 +1 @@
-
+Pay no attention: just check for having access
-=-=(Knielsen - Mon, 17 Aug 2009, 12:44)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.7834 2009-08-17 12:44:17.000000000 +0300
+++ /tmp/wklog.36.new.7834 2009-08-17 12:44:17.000000000 +0300
@@ -13,7 +13,9 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
-See also MySQL BUG#42941.
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
What we could do
----------------
-=-=(Guest - Sun, 16 Aug 2009, 17:11)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.27162 2009-08-16 17:11:12.000000000 +0300
+++ /tmp/wklog.36.new.27162 2009-08-16 17:11:12.000000000 +0300
@@ -13,6 +13,8 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
+See also MySQL BUG#42941.
+
What we could do
----------------
------------------------------------------------------------
-=-=(View All Progress Notes, 15 total)=-=-
http://askmonty.org/worklog/index.pl?tid=36&nolimit=1
DESCRIPTION:
Sometimes there is a need to take a binary log and apply it to a database with
a different name than the original name of the database on binlog producer.
If one is using statement-based replication, he can achieve this by grepping
out "USE dbname" statements out of the output of mysqlbinlog(*). With
row-based replication this is no longer possible, as database name is encoded
within the the BINLOG '....' statement.
This task is about adding an option to mysqlbinlog that would allow to change
the names of used databases in both RBR and SBR events.
(*) this implies that all statements refer to tables in the current database,
doesn't catch updates made inside stored functions and so forth, but still
works for a practially-important subset of cases.
HIGH-LEVEL SPECIFICATION:
Context
-------
(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
overview)
At the moment, the server has a replication slave option
--replicate-rewrite-db="from->to"
the option affects
- Table_map_log_event (all RBR events)
- Load_log_event (LOAD DATA)
- Query_log_event (SBR-based updates, with the usual assumption that the
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
merged into MariaDB at the time of writing, but planned to be merged before
release.
What we could do
----------------
Option1: make mysqlbinlog accept --replicate-rewrite-db option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
same extent as replication slave would process --replicate-rewrite-db option.
Option2: Add database-agnostic RBR events and --strip-db option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Right now RBR events require a databasename. It is not possible to have RBR
event stream that won't mention which database the events are for. When I
tried to use debugger and specify empty database name, attempt to apply the
binlog resulted in this error:
090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
opening tables,
We could do as follows:
- Make the server interpret empty database name in RBR event (i.e. in a
Table_map_log_event) as "use current database". Binlog slave thread
probably should not allow such events as it doesn't have a natural current
database.
- Add a mysqlbinlog --strip-db option that would
= not produce any "USE dbname" statements
= change databasename for all RBR events to be empty
That way, mysqlbinlog output will be database-agnostic and apply to the
current database.
(this will have the usual limitations that we assume that all statements in
the binlog refer to the current database).
Option3: Enhance database rewrite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If there is a need to support database change for statements that use
dbname.tablename notation and are replicated as statements (i.e. are DDL
statements and/or DML statements that are binlogged as statements),
then that could be supported as follows:
- Make the server's parser recognize special form of comments
/* !database-alias(oldname,newname) */
and save the mapping somewhere
- Put the hooks in table open and name resolution code to use the saved
mapping.
Once we've done the above, it will be easy to perform a complete,
no-compromise or restrictions database name change in binary log.
It will be possible to do the rewrites either on the slave (
--replicate-rewrite-db will work for all kinds of statements), or in
mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
parse the statement).
LOW-LEVEL DESIGN:
Content
-------
1. Adding rewrite-db option
2. Supporting rewrite-db option for RBR events
3. Supporting rewrite-db option for SBR events
(Limited to affecting only USE statements)
4. Current status
1. Adding rewrite-db option
---------------------------
1.1. Syntax:
--rewrite-db='db_from->db_to'
1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
1.3. In mysqlbinlog.cc:
- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
- Add Rpl_filter object to mysqlbinlog.cc
Rpl_filter* binlog_filter;
- Add corresponding switch case to get_one_option():
case OPT_REWRITE_DB:
<extract db-from and db-to strings>
binlog_filter->add_db_rewrite(db_from, db_to);
break;
.
Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
additional changes are required:
- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
uses sql_alloc() which is THD dependent. These are to be modified
as follows:
#ifdef MYSQL_CLIENT
extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
#endif
class Sql_alloc
{ ...
static void *operator new(size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
static void *operator new[](size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
...
}
- In rpl_filter.cc:
Rpl_filter::Rpl_filter() :
...
{
#ifdef MYSQL_CLIENT
init_alloc_root(&sql_list_client_mem_root, ...);
#endif
...
}
Rpl_filter::~Rpl_filter()
{ ...
#ifdef MYSQL_CLIENT
free_root(&sql_list_client_mem_root, ...);
#endif
}
2. Supporting rewrite-db for RBR events
---------------------------------------
In binlog, each row operation event is preceded by Table map event(s) which maps
table id(s) to database and table names. So, it's enough to support rewriting
database name in a Table map.
2.1. Add rewrite_db() member to Table_map_log_event:
int Table_map_log_event::rewrite_db(
const char* new_db,
size_t new_db_len,
const Format_description_log_event* desc)
{
/* 1. In temp_buf member (possibly reallocating it) rewrite
event length, db length, and db parts
2. Change m_dblen and m_dbnam members
*/
}
Comment. This function assumes that temp_buf member contains Table map
binlog representaion (temp_buf is used for creating corresponding
BINLOG statement).
2.2. In mysqlbinlog modify corresponding switch case in the
process_event() function:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
...
case TABLE_MAP_EVENT:
{
Table_map_log_event *map= ((Table_map_log_event *)ev);
if (shall_skip_database(map->get_db_name()))
{ ...
}
// WL36
size_t new_len= 0;
const char* new_db= binlog_filter->get_rewrite_db(
map->get_db_name(), &new_len);
if (new_len && map->rewrite_db(new_db, new_len,
glob_description_event))
{ error("Could not rewrite database name");
goto err;
}
}
case WRITE_ROWS_EVENT:
case DELETE_ROWS_EVENT:
case UPDATE_ROWS_EVENT:
...
}
...
}
Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
a (db_from, db_to) pair, this function returns pointer to db_to and
sets len = db_to length; otherwise, it returns db_from and does not
change len value.
3. Supporting rewrite-db for SBR events
---------------------------------------
Limited to emiting USE <db_to> instead of USE <db_from>.
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
- Query_log_event
- Load_log_event
- Execute_load_query_log_event [ :public Query_log_event ]
- Create_file_log_event [ :public Load_log_event ]
TODO. Needed to check this list carefully (not sure for Create_file_log_event)
Notes.
- In replication, only Query_log_event and Load_log_event uses
rpl_filter->get_rewrite_db();
- In mysqlbinlog (process_event), Execute_load_query_log_event
and Create_file_log_event are processed in separate switch
cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
(e.g. it is ON for 'create database' statement)
- event's db name differs from db_name in PRINT_EVENT_INFO
(PRINT_EVENT_INFO keeps db name of the last issued USE statement;
initially, this db name is empty).
3.1. In mysqlbinlog.cc
- Add the following function:
void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
{
if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
return;
/*
- For events listed above get db_from = event->db;
- If db_from is the same as pinfo->db then return;
- If there is rewrite-db rule db_from->db_to,
set db = db_to. Else set db = db_from;
- Print "use <db>" to mysqlbinlog output
- Set pinfo->db = db_from
(this suppresses emiting use-statements by corresponding
log_event's print-function)
*/
}
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
case QUERY_EVENT:
if (shall_skip_database(((Query_log_event*)ev)->db))
goto end;
if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
{
// Possibly in case of rewite-db rule for ev->db
// a warning should be emited here (see note below)
... write_event_header_and_base64(ev, ...) ...
}
else
{
print_use_stmt((Query_log_event*)ev, print_event_info);
ev->print(result_file, print_event_info);
}
break;
...
case LOAD_EVENT:
print_use_stmt((Load_log_event*)ev, print_event_info);
break;
default:
...
}
...
}
Note. write_event_header_and_base64() does not print use-statement. It
produces BINLOG statement using ev->temp_buf content (i.e. the binary
log representation of the event). We don't rewrite temp_buf here with
db_to name (as we do it for Table map event) - this implies the
limitation 3 mentioned above.
Question: Is supporting of rewite_db + --base64-output really needed
currently?
4. Current status
-----------------
The outlined design (implemented for mysql-5.1.37) is tested for
simple test-cases.
TODO. 1. Check list of events which can emit use-statement.
2. Supporting of rewite_db + --base64-output ?
ESTIMATED WORK TIME
ESTIMATED COMPLETION DATE
-----------------------------------------------------------------------
WorkLog (v3.5.9)
1
0
[Maria-developers] Updated (by Knielsen): Add a mysqlbinlog option to change the used database (36)
by worklog-noreply@askmonty.org 03 Oct '09
by worklog-noreply@askmonty.org 03 Oct '09
03 Oct '09
-----------------------------------------------------------------------
WORKLOG TASK
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TASK...........: Add a mysqlbinlog option to change the used database
CREATION DATE..: Fri, 07 Aug 2009, 14:57
SUPERVISOR.....: Monty
IMPLEMENTOR....:
COPIES TO......:
CATEGORY.......: Server-RawIdeaBin
TASK ID........: 36 (http://askmonty.org/worklog/?tid=36)
VERSION........: Server-9.x
STATUS.........: Un-Assigned
PRIORITY.......: 60
WORKED HOURS...: 0
ESTIMATE.......: 0 (hours remain)
ORIG. ESTIMATE.: 0
PROGRESS NOTES:
-=-=(Knielsen - Sat, 03 Oct 2009, 08:34)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.5353 2009-10-03 08:34:43.000000000 +0300
+++ /tmp/wklog.36.new.5353 2009-10-03 08:34:43.000000000 +0300
@@ -1 +1,77 @@
-G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
+Context
+-------
+(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
+overview)
+At the moment, the server has a replication slave option
+
+ --replicate-rewrite-db="from->to"
+
+the option affects
+- Table_map_log_event (all RBR events)
+- Load_log_event (LOAD DATA)
+- Query_log_event (SBR-based updates, with the usual assumption that the
+ statement refers to tables in current database, so that changing the current
+ database will make the statement to work on a table in a different database).
+
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
+
+What we could do
+----------------
+
+Option1: make mysqlbinlog accept --replicate-rewrite-db option
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
+same extent as replication slave would process --replicate-rewrite-db option.
+
+
+Option2: Add database-agnostic RBR events and --strip-db option
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+Right now RBR events require a databasename. It is not possible to have RBR
+event stream that won't mention which database the events are for. When I
+tried to use debugger and specify empty database name, attempt to apply the
+binlog resulted in this error:
+
+090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
+opening tables,
+
+We could do as follows:
+- Make the server interpret empty database name in RBR event (i.e. in a
+ Table_map_log_event) as "use current database". Binlog slave thread
+ probably should not allow such events as it doesn't have a natural current
+ database.
+- Add a mysqlbinlog --strip-db option that would
+ = not produce any "USE dbname" statements
+ = change databasename for all RBR events to be empty
+
+That way, mysqlbinlog output will be database-agnostic and apply to the
+current database.
+(this will have the usual limitations that we assume that all statements in
+the binlog refer to the current database).
+
+Option3: Enhance database rewrite
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+If there is a need to support database change for statements that use
+dbname.tablename notation and are replicated as statements (i.e. are DDL
+statements and/or DML statements that are binlogged as statements),
+then that could be supported as follows:
+
+- Make the server's parser recognize special form of comments
+
+ /* !database-alias(oldname,newname) */
+
+ and save the mapping somewhere
+
+- Put the hooks in table open and name resolution code to use the saved
+ mapping.
+
+
+Once we've done the above, it will be easy to perform a complete,
+no-compromise or restrictions database name change in binary log.
+
+It will be possible to do the rewrites either on the slave (
+--replicate-rewrite-db will work for all kinds of statements), or in
+mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
+parse the statement).
+
-=-=(Guest - Sat, 03 Oct 2009, 02:27)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.23366 2009-10-03 02:27:45.000000000 +0300
+++ /tmp/wklog.36.new.23366 2009-10-03 02:27:45.000000000 +0300
@@ -1,77 +1 @@
-Context
--------
-(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
-overview)
-At the moment, the server has a replication slave option
-
- --replicate-rewrite-db="from->to"
-
-the option affects
-- Table_map_log_event (all RBR events)
-- Load_log_event (LOAD DATA)
-- Query_log_event (SBR-based updates, with the usual assumption that the
- statement refers to tables in current database, so that changing the current
- database will make the statement to work on a table in a different database).
-
-See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
-merged into MariaDB at the time of writing, but planned to be merged before
-release.
-
-What we could do
-----------------
-
-Option1: make mysqlbinlog accept --replicate-rewrite-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
-same extent as replication slave would process --replicate-rewrite-db option.
-
-
-Option2: Add database-agnostic RBR events and --strip-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Right now RBR events require a databasename. It is not possible to have RBR
-event stream that won't mention which database the events are for. When I
-tried to use debugger and specify empty database name, attempt to apply the
-binlog resulted in this error:
-
-090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
-opening tables,
-
-We could do as follows:
-- Make the server interpret empty database name in RBR event (i.e. in a
- Table_map_log_event) as "use current database". Binlog slave thread
- probably should not allow such events as it doesn't have a natural current
- database.
-- Add a mysqlbinlog --strip-db option that would
- = not produce any "USE dbname" statements
- = change databasename for all RBR events to be empty
-
-That way, mysqlbinlog output will be database-agnostic and apply to the
-current database.
-(this will have the usual limitations that we assume that all statements in
-the binlog refer to the current database).
-
-Option3: Enhance database rewrite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If there is a need to support database change for statements that use
-dbname.tablename notation and are replicated as statements (i.e. are DDL
-statements and/or DML statements that are binlogged as statements),
-then that could be supported as follows:
-
-- Make the server's parser recognize special form of comments
-
- /* !database-alias(oldname,newname) */
-
- and save the mapping somewhere
-
-- Put the hooks in table open and name resolution code to use the saved
- mapping.
-
-
-Once we've done the above, it will be easy to perform a complete,
-no-compromise or restrictions database name change in binary log.
-
-It will be possible to do the rewrites either on the slave (
---replicate-rewrite-db will work for all kinds of statements), or in
-mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
-parse the statement).
-
+G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
-=-=(Guest - Tue, 15 Sep 2009, 18:04)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.19322 2009-09-15 18:04:49.000000000 +0300
+++ /tmp/wklog.36.new.19322 2009-09-15 18:04:49.000000000 +0300
@@ -191,7 +191,7 @@
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
- events lis above), e.g.:
+ events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
-=-=(Guest - Tue, 15 Sep 2009, 15:53)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.13421 2009-09-15 15:53:31.000000000 +0300
+++ /tmp/wklog.36.new.13421 2009-09-15 15:53:31.000000000 +0300
@@ -150,10 +150,17 @@
following events (see process_event() function):
- Query_log_event
-- Execute_load_query_log_event
-- Create_file_log_event
-
-TODO. Needed to check this list requires carefully !!!
+- Load_log_event
+- Execute_load_query_log_event [ :public Query_log_event ]
+- Create_file_log_event [ :public Load_log_event ]
+
+TODO. Needed to check this list carefully (not sure for Create_file_log_event)
+ Notes.
+ - In replication, only Query_log_event and Load_log_event uses
+ rpl_filter->get_rewrite_db();
+ - In mysqlbinlog (process_event), Execute_load_query_log_event
+ and Create_file_log_event are processed in separate switch
+ cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
@@ -182,8 +189,9 @@
*/
}
-- In process_event() function add print_use_stmt() invocations where
- needed (according to the events lis above), e.g.:
+- In process_event() function add switch case for Load_log_event and
+ add print_use_stmt() invocations where needed (according to the
+ events lis above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
@@ -207,6 +215,11 @@
}
break;
...
+ case LOAD_EVENT:
+ print_use_stmt((Load_log_event*)ev, print_event_info);
+ break;
+ default:
+ ...
}
...
}
-=-=(Guest - Tue, 15 Sep 2009, 12:12)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3961 2009-09-15 12:12:26.000000000 +0300
+++ /tmp/wklog.36.new.3961 2009-09-15 12:12:26.000000000 +0300
@@ -144,6 +144,8 @@
3. Supporting rewrite-db for SBR events
---------------------------------------
+Limited to emiting USE <db_to> instead of USE <db_from>.
+
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
-=-=(Guest - Tue, 15 Sep 2009, 12:08)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3794 2009-09-15 12:08:54.000000000 +0300
+++ /tmp/wklog.36.new.3794 2009-09-15 12:08:54.000000000 +0300
@@ -1 +1,229 @@
+Content
+-------
+1. Adding rewrite-db option
+2. Supporting rewrite-db option for RBR events
+3. Supporting rewrite-db option for SBR events
+ (Limited to affecting only USE statements)
+4. Current status
+
+1. Adding rewrite-db option
+---------------------------
+
+1.1. Syntax:
+ --rewrite-db='db_from->db_to'
+
+1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
+
+1.3. In mysqlbinlog.cc:
+
+- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
+- Add Rpl_filter object to mysqlbinlog.cc
+
+ Rpl_filter* binlog_filter;
+
+- Add corresponding switch case to get_one_option():
+
+ case OPT_REWRITE_DB:
+ <extract db-from and db-to strings>
+ binlog_filter->add_db_rewrite(db_from, db_to);
+ break;
+ .
+Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
+additional changes are required:
+
+- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
+ uses sql_alloc() which is THD dependent. These are to be modified
+ as follows:
+
+ #ifdef MYSQL_CLIENT
+ extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
+ #endif
+
+ class Sql_alloc
+ { ...
+ static void *operator new(size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ static void *operator new[](size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ ...
+ }
+
+- In rpl_filter.cc:
+
+ Rpl_filter::Rpl_filter() :
+ ...
+ {
+ #ifdef MYSQL_CLIENT
+ init_alloc_root(&sql_list_client_mem_root, ...);
+ #endif
+ ...
+ }
+
+ Rpl_filter::~Rpl_filter()
+ { ...
+ #ifdef MYSQL_CLIENT
+ free_root(&sql_list_client_mem_root, ...);
+ #endif
+ }
+
+2. Supporting rewrite-db for RBR events
+---------------------------------------
+
+In binlog, each row operation event is preceded by Table map event(s) which maps
+table id(s) to database and table names. So, it's enough to support rewriting
+database name in a Table map.
+
+2.1. Add rewrite_db() member to Table_map_log_event:
+
+ int Table_map_log_event::rewrite_db(
+ const char* new_db,
+ size_t new_db_len,
+ const Format_description_log_event* desc)
+ {
+ /* 1. In temp_buf member (possibly reallocating it) rewrite
+ event length, db length, and db parts
+ 2. Change m_dblen and m_dbnam members
+ */
+ }
+
+Comment. This function assumes that temp_buf member contains Table map
+binlog representaion (temp_buf is used for creating corresponding
+BINLOG statement).
+
+2.2. In mysqlbinlog modify corresponding switch case in the
+process_event() function:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ ...
+ case TABLE_MAP_EVENT:
+ {
+ Table_map_log_event *map= ((Table_map_log_event *)ev);
+ if (shall_skip_database(map->get_db_name()))
+ { ...
+ }
+ // WL36
+ size_t new_len= 0;
+ const char* new_db= binlog_filter->get_rewrite_db(
+ map->get_db_name(), &new_len);
+ if (new_len && map->rewrite_db(new_db, new_len,
+ glob_description_event))
+ { error("Could not rewrite database name");
+ goto err;
+ }
+ }
+ case WRITE_ROWS_EVENT:
+ case DELETE_ROWS_EVENT:
+ case UPDATE_ROWS_EVENT:
+ ...
+ }
+ ...
+ }
+
+Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
+a (db_from, db_to) pair, this function returns pointer to db_to and
+sets len = db_to length; otherwise, it returns db_from and does not
+change len value.
+
+3. Supporting rewrite-db for SBR events
+---------------------------------------
+
+USE statements can be emited by mysqlbinlog as a result of processing the
+following events (see process_event() function):
+
+- Query_log_event
+- Execute_load_query_log_event
+- Create_file_log_event
+
+TODO. Needed to check this list requires carefully !!!
+
+Conditions for emiting use-statement:
+- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
+ (e.g. it is ON for 'create database' statement)
+- event's db name differs from db_name in PRINT_EVENT_INFO
+ (PRINT_EVENT_INFO keeps db name of the last issued USE statement;
+ initially, this db name is empty).
+
+3.1. In mysqlbinlog.cc
+
+- Add the following function:
+
+ void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
+ {
+ if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
+ return;
+ /*
+ - For events listed above get db_from = event->db;
+ - If db_from is the same as pinfo->db then return;
+ - If there is rewrite-db rule db_from->db_to,
+ set db = db_to. Else set db = db_from;
+ - Print "use <db>" to mysqlbinlog output
+ - Set pinfo->db = db_from
+ (this suppresses emiting use-statements by corresponding
+ log_event's print-function)
+ */
+ }
+
+- In process_event() function add print_use_stmt() invocations where
+ needed (according to the events lis above), e.g.:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ case QUERY_EVENT:
+ if (shall_skip_database(((Query_log_event*)ev)->db))
+ goto end;
+ if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+ {
+ // Possibly in case of rewite-db rule for ev->db
+ // a warning should be emited here (see note below)
+ ... write_event_header_and_base64(ev, ...) ...
+ }
+ else
+ {
+ print_use_stmt((Query_log_event*)ev, print_event_info);
+ ev->print(result_file, print_event_info);
+ }
+ break;
+ ...
+ }
+ ...
+ }
+
+Note. write_event_header_and_base64() does not print use-statement. It
+produces BINLOG statement using ev->temp_buf content (i.e. the binary
+log representation of the event). We don't rewrite temp_buf here with
+db_to name (as we do it for Table map event) - this implies the
+limitation 3 mentioned above.
+Question: Is supporting of rewite_db + --base64-output really needed
+currently?
+
+4. Current status
+-----------------
+
+The outlined design (implemented for mysql-5.1.37) is tested for
+simple test-cases.
+
+TODO. 1. Check list of events which can emit use-statement.
+ 2. Supporting of rewite_db + --base64-output ?
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9711 2009-09-14 11:51:43.000000000 +0300
+++ /tmp/wklog.36.new.9711 2009-09-14 11:51:43.000000000 +0300
@@ -1 +1 @@
-Pay no attention: just check for having access
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9678 2009-09-14 11:51:28.000000000 +0300
+++ /tmp/wklog.36.new.9678 2009-09-14 11:51:28.000000000 +0300
@@ -1 +1 @@
-
+Pay no attention: just check for having access
-=-=(Knielsen - Mon, 17 Aug 2009, 12:44)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.7834 2009-08-17 12:44:17.000000000 +0300
+++ /tmp/wklog.36.new.7834 2009-08-17 12:44:17.000000000 +0300
@@ -13,7 +13,9 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
-See also MySQL BUG#42941.
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
What we could do
----------------
-=-=(Guest - Sun, 16 Aug 2009, 17:11)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.27162 2009-08-16 17:11:12.000000000 +0300
+++ /tmp/wklog.36.new.27162 2009-08-16 17:11:12.000000000 +0300
@@ -13,6 +13,8 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
+See also MySQL BUG#42941.
+
What we could do
----------------
------------------------------------------------------------
-=-=(View All Progress Notes, 15 total)=-=-
http://askmonty.org/worklog/index.pl?tid=36&nolimit=1
DESCRIPTION:
Sometimes there is a need to take a binary log and apply it to a database with
a different name than the original name of the database on binlog producer.
If one is using statement-based replication, he can achieve this by grepping
out "USE dbname" statements out of the output of mysqlbinlog(*). With
row-based replication this is no longer possible, as database name is encoded
within the the BINLOG '....' statement.
This task is about adding an option to mysqlbinlog that would allow to change
the names of used databases in both RBR and SBR events.
(*) this implies that all statements refer to tables in the current database,
doesn't catch updates made inside stored functions and so forth, but still
works for a practially-important subset of cases.
HIGH-LEVEL SPECIFICATION:
Context
-------
(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
overview)
At the moment, the server has a replication slave option
--replicate-rewrite-db="from->to"
the option affects
- Table_map_log_event (all RBR events)
- Load_log_event (LOAD DATA)
- Query_log_event (SBR-based updates, with the usual assumption that the
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
merged into MariaDB at the time of writing, but planned to be merged before
release.
What we could do
----------------
Option1: make mysqlbinlog accept --replicate-rewrite-db option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
same extent as replication slave would process --replicate-rewrite-db option.
Option2: Add database-agnostic RBR events and --strip-db option
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Right now RBR events require a databasename. It is not possible to have RBR
event stream that won't mention which database the events are for. When I
tried to use debugger and specify empty database name, attempt to apply the
binlog resulted in this error:
090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
opening tables,
We could do as follows:
- Make the server interpret empty database name in RBR event (i.e. in a
Table_map_log_event) as "use current database". Binlog slave thread
probably should not allow such events as it doesn't have a natural current
database.
- Add a mysqlbinlog --strip-db option that would
= not produce any "USE dbname" statements
= change databasename for all RBR events to be empty
That way, mysqlbinlog output will be database-agnostic and apply to the
current database.
(this will have the usual limitations that we assume that all statements in
the binlog refer to the current database).
Option3: Enhance database rewrite
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
If there is a need to support database change for statements that use
dbname.tablename notation and are replicated as statements (i.e. are DDL
statements and/or DML statements that are binlogged as statements),
then that could be supported as follows:
- Make the server's parser recognize special form of comments
/* !database-alias(oldname,newname) */
and save the mapping somewhere
- Put the hooks in table open and name resolution code to use the saved
mapping.
Once we've done the above, it will be easy to perform a complete,
no-compromise or restrictions database name change in binary log.
It will be possible to do the rewrites either on the slave (
--replicate-rewrite-db will work for all kinds of statements), or in
mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
parse the statement).
LOW-LEVEL DESIGN:
Content
-------
1. Adding rewrite-db option
2. Supporting rewrite-db option for RBR events
3. Supporting rewrite-db option for SBR events
(Limited to affecting only USE statements)
4. Current status
1. Adding rewrite-db option
---------------------------
1.1. Syntax:
--rewrite-db='db_from->db_to'
1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
1.3. In mysqlbinlog.cc:
- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
- Add Rpl_filter object to mysqlbinlog.cc
Rpl_filter* binlog_filter;
- Add corresponding switch case to get_one_option():
case OPT_REWRITE_DB:
<extract db-from and db-to strings>
binlog_filter->add_db_rewrite(db_from, db_to);
break;
.
Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
additional changes are required:
- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
uses sql_alloc() which is THD dependent. These are to be modified
as follows:
#ifdef MYSQL_CLIENT
extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
#endif
class Sql_alloc
{ ...
static void *operator new(size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
static void *operator new[](size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
...
}
- In rpl_filter.cc:
Rpl_filter::Rpl_filter() :
...
{
#ifdef MYSQL_CLIENT
init_alloc_root(&sql_list_client_mem_root, ...);
#endif
...
}
Rpl_filter::~Rpl_filter()
{ ...
#ifdef MYSQL_CLIENT
free_root(&sql_list_client_mem_root, ...);
#endif
}
2. Supporting rewrite-db for RBR events
---------------------------------------
In binlog, each row operation event is preceded by Table map event(s) which maps
table id(s) to database and table names. So, it's enough to support rewriting
database name in a Table map.
2.1. Add rewrite_db() member to Table_map_log_event:
int Table_map_log_event::rewrite_db(
const char* new_db,
size_t new_db_len,
const Format_description_log_event* desc)
{
/* 1. In temp_buf member (possibly reallocating it) rewrite
event length, db length, and db parts
2. Change m_dblen and m_dbnam members
*/
}
Comment. This function assumes that temp_buf member contains Table map
binlog representaion (temp_buf is used for creating corresponding
BINLOG statement).
2.2. In mysqlbinlog modify corresponding switch case in the
process_event() function:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
...
case TABLE_MAP_EVENT:
{
Table_map_log_event *map= ((Table_map_log_event *)ev);
if (shall_skip_database(map->get_db_name()))
{ ...
}
// WL36
size_t new_len= 0;
const char* new_db= binlog_filter->get_rewrite_db(
map->get_db_name(), &new_len);
if (new_len && map->rewrite_db(new_db, new_len,
glob_description_event))
{ error("Could not rewrite database name");
goto err;
}
}
case WRITE_ROWS_EVENT:
case DELETE_ROWS_EVENT:
case UPDATE_ROWS_EVENT:
...
}
...
}
Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
a (db_from, db_to) pair, this function returns pointer to db_to and
sets len = db_to length; otherwise, it returns db_from and does not
change len value.
3. Supporting rewrite-db for SBR events
---------------------------------------
Limited to emiting USE <db_to> instead of USE <db_from>.
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
- Query_log_event
- Load_log_event
- Execute_load_query_log_event [ :public Query_log_event ]
- Create_file_log_event [ :public Load_log_event ]
TODO. Needed to check this list carefully (not sure for Create_file_log_event)
Notes.
- In replication, only Query_log_event and Load_log_event uses
rpl_filter->get_rewrite_db();
- In mysqlbinlog (process_event), Execute_load_query_log_event
and Create_file_log_event are processed in separate switch
cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
(e.g. it is ON for 'create database' statement)
- event's db name differs from db_name in PRINT_EVENT_INFO
(PRINT_EVENT_INFO keeps db name of the last issued USE statement;
initially, this db name is empty).
3.1. In mysqlbinlog.cc
- Add the following function:
void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
{
if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
return;
/*
- For events listed above get db_from = event->db;
- If db_from is the same as pinfo->db then return;
- If there is rewrite-db rule db_from->db_to,
set db = db_to. Else set db = db_from;
- Print "use <db>" to mysqlbinlog output
- Set pinfo->db = db_from
(this suppresses emiting use-statements by corresponding
log_event's print-function)
*/
}
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
case QUERY_EVENT:
if (shall_skip_database(((Query_log_event*)ev)->db))
goto end;
if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
{
// Possibly in case of rewite-db rule for ev->db
// a warning should be emited here (see note below)
... write_event_header_and_base64(ev, ...) ...
}
else
{
print_use_stmt((Query_log_event*)ev, print_event_info);
ev->print(result_file, print_event_info);
}
break;
...
case LOAD_EVENT:
print_use_stmt((Load_log_event*)ev, print_event_info);
break;
default:
...
}
...
}
Note. write_event_header_and_base64() does not print use-statement. It
produces BINLOG statement using ev->temp_buf content (i.e. the binary
log representation of the event). We don't rewrite temp_buf here with
db_to name (as we do it for Table map event) - this implies the
limitation 3 mentioned above.
Question: Is supporting of rewite_db + --base64-output really needed
currently?
4. Current status
-----------------
The outlined design (implemented for mysql-5.1.37) is tested for
simple test-cases.
TODO. 1. Check list of events which can emit use-statement.
2. Supporting of rewite_db + --base64-output ?
ESTIMATED WORK TIME
ESTIMATED COMPLETION DATE
-----------------------------------------------------------------------
WorkLog (v3.5.9)
1
0
[Maria-developers] Updated (by Guest): Add a mysqlbinlog option to change the used database (36)
by worklog-noreply@askmonty.org 03 Oct '09
by worklog-noreply@askmonty.org 03 Oct '09
03 Oct '09
-----------------------------------------------------------------------
WORKLOG TASK
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
TASK...........: Add a mysqlbinlog option to change the used database
CREATION DATE..: Fri, 07 Aug 2009, 14:57
SUPERVISOR.....: Monty
IMPLEMENTOR....:
COPIES TO......:
CATEGORY.......: Server-RawIdeaBin
TASK ID........: 36 (http://askmonty.org/worklog/?tid=36)
VERSION........: Server-9.x
STATUS.........: Un-Assigned
PRIORITY.......: 60
WORKED HOURS...: 0
ESTIMATE.......: 0 (hours remain)
ORIG. ESTIMATE.: 0
PROGRESS NOTES:
-=-=(Guest - Sat, 03 Oct 2009, 02:27)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.23366 2009-10-03 02:27:45.000000000 +0300
+++ /tmp/wklog.36.new.23366 2009-10-03 02:27:45.000000000 +0300
@@ -1,77 +1 @@
-Context
--------
-(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
-overview)
-At the moment, the server has a replication slave option
-
- --replicate-rewrite-db="from->to"
-
-the option affects
-- Table_map_log_event (all RBR events)
-- Load_log_event (LOAD DATA)
-- Query_log_event (SBR-based updates, with the usual assumption that the
- statement refers to tables in current database, so that changing the current
- database will make the statement to work on a table in a different database).
-
-See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
-merged into MariaDB at the time of writing, but planned to be merged before
-release.
-
-What we could do
-----------------
-
-Option1: make mysqlbinlog accept --replicate-rewrite-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Make mysqlbinlog accept --replicate-rewrite-db options and process them to the
-same extent as replication slave would process --replicate-rewrite-db option.
-
-
-Option2: Add database-agnostic RBR events and --strip-db option
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-Right now RBR events require a databasename. It is not possible to have RBR
-event stream that won't mention which database the events are for. When I
-tried to use debugger and specify empty database name, attempt to apply the
-binlog resulted in this error:
-
-090809 17:38:44 [ERROR] Slave SQL: Error 'Table '.tablename' doesn't exist' on
-opening tables,
-
-We could do as follows:
-- Make the server interpret empty database name in RBR event (i.e. in a
- Table_map_log_event) as "use current database". Binlog slave thread
- probably should not allow such events as it doesn't have a natural current
- database.
-- Add a mysqlbinlog --strip-db option that would
- = not produce any "USE dbname" statements
- = change databasename for all RBR events to be empty
-
-That way, mysqlbinlog output will be database-agnostic and apply to the
-current database.
-(this will have the usual limitations that we assume that all statements in
-the binlog refer to the current database).
-
-Option3: Enhance database rewrite
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-If there is a need to support database change for statements that use
-dbname.tablename notation and are replicated as statements (i.e. are DDL
-statements and/or DML statements that are binlogged as statements),
-then that could be supported as follows:
-
-- Make the server's parser recognize special form of comments
-
- /* !database-alias(oldname,newname) */
-
- and save the mapping somewhere
-
-- Put the hooks in table open and name resolution code to use the saved
- mapping.
-
-
-Once we've done the above, it will be easy to perform a complete,
-no-compromise or restrictions database name change in binary log.
-
-It will be possible to do the rewrites either on the slave (
---replicate-rewrite-db will work for all kinds of statements), or in
-mysqlbinlog (adding a comment is easy and doesn't require mysqlbinlog to
-parse the statement).
-
+G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
-=-=(Guest - Tue, 15 Sep 2009, 18:04)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.19322 2009-09-15 18:04:49.000000000 +0300
+++ /tmp/wklog.36.new.19322 2009-09-15 18:04:49.000000000 +0300
@@ -191,7 +191,7 @@
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
- events lis above), e.g.:
+ events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
-=-=(Guest - Tue, 15 Sep 2009, 15:53)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.13421 2009-09-15 15:53:31.000000000 +0300
+++ /tmp/wklog.36.new.13421 2009-09-15 15:53:31.000000000 +0300
@@ -150,10 +150,17 @@
following events (see process_event() function):
- Query_log_event
-- Execute_load_query_log_event
-- Create_file_log_event
-
-TODO. Needed to check this list requires carefully !!!
+- Load_log_event
+- Execute_load_query_log_event [ :public Query_log_event ]
+- Create_file_log_event [ :public Load_log_event ]
+
+TODO. Needed to check this list carefully (not sure for Create_file_log_event)
+ Notes.
+ - In replication, only Query_log_event and Load_log_event uses
+ rpl_filter->get_rewrite_db();
+ - In mysqlbinlog (process_event), Execute_load_query_log_event
+ and Create_file_log_event are processed in separate switch
+ cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
@@ -182,8 +189,9 @@
*/
}
-- In process_event() function add print_use_stmt() invocations where
- needed (according to the events lis above), e.g.:
+- In process_event() function add switch case for Load_log_event and
+ add print_use_stmt() invocations where needed (according to the
+ events lis above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
@@ -207,6 +215,11 @@
}
break;
...
+ case LOAD_EVENT:
+ print_use_stmt((Load_log_event*)ev, print_event_info);
+ break;
+ default:
+ ...
}
...
}
-=-=(Guest - Tue, 15 Sep 2009, 12:12)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3961 2009-09-15 12:12:26.000000000 +0300
+++ /tmp/wklog.36.new.3961 2009-09-15 12:12:26.000000000 +0300
@@ -144,6 +144,8 @@
3. Supporting rewrite-db for SBR events
---------------------------------------
+Limited to emiting USE <db_to> instead of USE <db_from>.
+
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
-=-=(Guest - Tue, 15 Sep 2009, 12:08)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.3794 2009-09-15 12:08:54.000000000 +0300
+++ /tmp/wklog.36.new.3794 2009-09-15 12:08:54.000000000 +0300
@@ -1 +1,229 @@
+Content
+-------
+1. Adding rewrite-db option
+2. Supporting rewrite-db option for RBR events
+3. Supporting rewrite-db option for SBR events
+ (Limited to affecting only USE statements)
+4. Current status
+
+1. Adding rewrite-db option
+---------------------------
+
+1.1. Syntax:
+ --rewrite-db='db_from->db_to'
+
+1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
+
+1.3. In mysqlbinlog.cc:
+
+- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
+- Add Rpl_filter object to mysqlbinlog.cc
+
+ Rpl_filter* binlog_filter;
+
+- Add corresponding switch case to get_one_option():
+
+ case OPT_REWRITE_DB:
+ <extract db-from and db-to strings>
+ binlog_filter->add_db_rewrite(db_from, db_to);
+ break;
+ .
+Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
+additional changes are required:
+
+- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
+ uses sql_alloc() which is THD dependent. These are to be modified
+ as follows:
+
+ #ifdef MYSQL_CLIENT
+ extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
+ #endif
+
+ class Sql_alloc
+ { ...
+ static void *operator new(size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ static void *operator new[](size_t size) throw ()
+ {
+ #ifndef MYSQL_CLIENT
+ return sql_alloc(size);
+ #else
+ return alloc_root(&sql_list_client_mem_root, size);
+ #endif
+ }
+ ...
+ }
+
+- In rpl_filter.cc:
+
+ Rpl_filter::Rpl_filter() :
+ ...
+ {
+ #ifdef MYSQL_CLIENT
+ init_alloc_root(&sql_list_client_mem_root, ...);
+ #endif
+ ...
+ }
+
+ Rpl_filter::~Rpl_filter()
+ { ...
+ #ifdef MYSQL_CLIENT
+ free_root(&sql_list_client_mem_root, ...);
+ #endif
+ }
+
+2. Supporting rewrite-db for RBR events
+---------------------------------------
+
+In binlog, each row operation event is preceded by Table map event(s) which maps
+table id(s) to database and table names. So, it's enough to support rewriting
+database name in a Table map.
+
+2.1. Add rewrite_db() member to Table_map_log_event:
+
+ int Table_map_log_event::rewrite_db(
+ const char* new_db,
+ size_t new_db_len,
+ const Format_description_log_event* desc)
+ {
+ /* 1. In temp_buf member (possibly reallocating it) rewrite
+ event length, db length, and db parts
+ 2. Change m_dblen and m_dbnam members
+ */
+ }
+
+Comment. This function assumes that temp_buf member contains Table map
+binlog representaion (temp_buf is used for creating corresponding
+BINLOG statement).
+
+2.2. In mysqlbinlog modify corresponding switch case in the
+process_event() function:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ ...
+ case TABLE_MAP_EVENT:
+ {
+ Table_map_log_event *map= ((Table_map_log_event *)ev);
+ if (shall_skip_database(map->get_db_name()))
+ { ...
+ }
+ // WL36
+ size_t new_len= 0;
+ const char* new_db= binlog_filter->get_rewrite_db(
+ map->get_db_name(), &new_len);
+ if (new_len && map->rewrite_db(new_db, new_len,
+ glob_description_event))
+ { error("Could not rewrite database name");
+ goto err;
+ }
+ }
+ case WRITE_ROWS_EVENT:
+ case DELETE_ROWS_EVENT:
+ case UPDATE_ROWS_EVENT:
+ ...
+ }
+ ...
+ }
+
+Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
+a (db_from, db_to) pair, this function returns pointer to db_to and
+sets len = db_to length; otherwise, it returns db_from and does not
+change len value.
+
+3. Supporting rewrite-db for SBR events
+---------------------------------------
+
+USE statements can be emited by mysqlbinlog as a result of processing the
+following events (see process_event() function):
+
+- Query_log_event
+- Execute_load_query_log_event
+- Create_file_log_event
+
+TODO. Needed to check this list requires carefully !!!
+
+Conditions for emiting use-statement:
+- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
+ (e.g. it is ON for 'create database' statement)
+- event's db name differs from db_name in PRINT_EVENT_INFO
+ (PRINT_EVENT_INFO keeps db name of the last issued USE statement;
+ initially, this db name is empty).
+
+3.1. In mysqlbinlog.cc
+
+- Add the following function:
+
+ void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
+ {
+ if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
+ return;
+ /*
+ - For events listed above get db_from = event->db;
+ - If db_from is the same as pinfo->db then return;
+ - If there is rewrite-db rule db_from->db_to,
+ set db = db_to. Else set db = db_from;
+ - Print "use <db>" to mysqlbinlog output
+ - Set pinfo->db = db_from
+ (this suppresses emiting use-statements by corresponding
+ log_event's print-function)
+ */
+ }
+
+- In process_event() function add print_use_stmt() invocations where
+ needed (according to the events lis above), e.g.:
+
+ Exit_status process_event(
+ PRINT_EVENT_INFO *print_event_info,
+ Log_event *ev, ...)
+ {
+ ...
+ switch (ev_type) {
+ case QUERY_EVENT:
+ if (shall_skip_database(((Query_log_event*)ev)->db))
+ goto end;
+ if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
+ {
+ // Possibly in case of rewite-db rule for ev->db
+ // a warning should be emited here (see note below)
+ ... write_event_header_and_base64(ev, ...) ...
+ }
+ else
+ {
+ print_use_stmt((Query_log_event*)ev, print_event_info);
+ ev->print(result_file, print_event_info);
+ }
+ break;
+ ...
+ }
+ ...
+ }
+
+Note. write_event_header_and_base64() does not print use-statement. It
+produces BINLOG statement using ev->temp_buf content (i.e. the binary
+log representation of the event). We don't rewrite temp_buf here with
+db_to name (as we do it for Table map event) - this implies the
+limitation 3 mentioned above.
+Question: Is supporting of rewite_db + --base64-output really needed
+currently?
+
+4. Current status
+-----------------
+
+The outlined design (implemented for mysql-5.1.37) is tested for
+simple test-cases.
+
+TODO. 1. Check list of events which can emit use-statement.
+ 2. Supporting of rewite_db + --base64-output ?
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9711 2009-09-14 11:51:43.000000000 +0300
+++ /tmp/wklog.36.new.9711 2009-09-14 11:51:43.000000000 +0300
@@ -1 +1 @@
-Pay no attention: just check for having access
+
-=-=(Guest - Mon, 14 Sep 2009, 11:51)=-=-
Low Level Design modified.
--- /tmp/wklog.36.old.9678 2009-09-14 11:51:28.000000000 +0300
+++ /tmp/wklog.36.new.9678 2009-09-14 11:51:28.000000000 +0300
@@ -1 +1 @@
-
+Pay no attention: just check for having access
-=-=(Knielsen - Mon, 17 Aug 2009, 12:44)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.7834 2009-08-17 12:44:17.000000000 +0300
+++ /tmp/wklog.36.new.7834 2009-08-17 12:44:17.000000000 +0300
@@ -13,7 +13,9 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
-See also MySQL BUG#42941.
+See also MySQL BUG#42941. Note this bug is fixed in MySQL 5.1.37, which is not
+merged into MariaDB at the time of writing, but planned to be merged before
+release.
What we could do
----------------
-=-=(Guest - Sun, 16 Aug 2009, 17:11)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.27162 2009-08-16 17:11:12.000000000 +0300
+++ /tmp/wklog.36.new.27162 2009-08-16 17:11:12.000000000 +0300
@@ -13,6 +13,8 @@
statement refers to tables in current database, so that changing the current
database will make the statement to work on a table in a different database).
+See also MySQL BUG#42941.
+
What we could do
----------------
-=-=(Psergey - Mon, 10 Aug 2009, 15:41)=-=-
High-Level Specification modified.
--- /tmp/wklog.36.old.13035 2009-08-10 15:41:51.000000000 +0300
+++ /tmp/wklog.36.new.13035 2009-08-10 15:41:51.000000000 +0300
@@ -1,5 +1,7 @@
Context
-------
+(See http://askmonty.org/wiki/index.php/Scratch/ReplicationOptions for global
+overview)
At the moment, the server has a replication slave option
--replicate-rewrite-db="from->to"
------------------------------------------------------------
-=-=(View All Progress Notes, 14 total)=-=-
http://askmonty.org/worklog/index.pl?tid=36&nolimit=1
DESCRIPTION:
Sometimes there is a need to take a binary log and apply it to a database with
a different name than the original name of the database on binlog producer.
If one is using statement-based replication, he can achieve this by grepping
out "USE dbname" statements out of the output of mysqlbinlog(*). With
row-based replication this is no longer possible, as database name is encoded
within the the BINLOG '....' statement.
This task is about adding an option to mysqlbinlog that would allow to change
the names of used databases in both RBR and SBR events.
(*) this implies that all statements refer to tables in the current database,
doesn't catch updates made inside stored functions and so forth, but still
works for a practially-important subset of cases.
HIGH-LEVEL SPECIFICATION:
G9m7yq <a href="http://ijfmyyjtveuu.com/">ijfmyyjtveuu</a>, [url=http://jeczeaqoxbpt.com/]jeczeaqoxbpt[/url] [link=http://nrisgrrvcrkm.com/]nrisgrrvcrkm[/link] http://edmnozsmotmt.com/
LOW-LEVEL DESIGN:
Content
-------
1. Adding rewrite-db option
2. Supporting rewrite-db option for RBR events
3. Supporting rewrite-db option for SBR events
(Limited to affecting only USE statements)
4. Current status
1. Adding rewrite-db option
---------------------------
1.1. Syntax:
--rewrite-db='db_from->db_to'
1.2. Add 'OPT_REWRITE_DB' to 'options_client' (in client_priv.h).
1.3. In mysqlbinlog.cc:
- Add { "rewrite-db", OPT_REWRITE_DB, ...} record to my_long_options:
- Add Rpl_filter object to mysqlbinlog.cc
Rpl_filter* binlog_filter;
- Add corresponding switch case to get_one_option():
case OPT_REWRITE_DB:
<extract db-from and db-to strings>
binlog_filter->add_db_rewrite(db_from, db_to);
break;
.
Note. To make Rpl_filter usable in a MYSQL_CLIENT context, few small
additional changes are required:
- In sql_list.cc/h, Sql_alloc::new(size_t) and Sql_alloc::new[](size_t)
uses sql_alloc() which is THD dependent. These are to be modified
as follows:
#ifdef MYSQL_CLIENT
extern MEM_ROOT sql_list_client_mem_root; // defined in sql_list.cc
#endif
class Sql_alloc
{ ...
static void *operator new(size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
static void *operator new[](size_t size) throw ()
{
#ifndef MYSQL_CLIENT
return sql_alloc(size);
#else
return alloc_root(&sql_list_client_mem_root, size);
#endif
}
...
}
- In rpl_filter.cc:
Rpl_filter::Rpl_filter() :
...
{
#ifdef MYSQL_CLIENT
init_alloc_root(&sql_list_client_mem_root, ...);
#endif
...
}
Rpl_filter::~Rpl_filter()
{ ...
#ifdef MYSQL_CLIENT
free_root(&sql_list_client_mem_root, ...);
#endif
}
2. Supporting rewrite-db for RBR events
---------------------------------------
In binlog, each row operation event is preceded by Table map event(s) which maps
table id(s) to database and table names. So, it's enough to support rewriting
database name in a Table map.
2.1. Add rewrite_db() member to Table_map_log_event:
int Table_map_log_event::rewrite_db(
const char* new_db,
size_t new_db_len,
const Format_description_log_event* desc)
{
/* 1. In temp_buf member (possibly reallocating it) rewrite
event length, db length, and db parts
2. Change m_dblen and m_dbnam members
*/
}
Comment. This function assumes that temp_buf member contains Table map
binlog representaion (temp_buf is used for creating corresponding
BINLOG statement).
2.2. In mysqlbinlog modify corresponding switch case in the
process_event() function:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
...
case TABLE_MAP_EVENT:
{
Table_map_log_event *map= ((Table_map_log_event *)ev);
if (shall_skip_database(map->get_db_name()))
{ ...
}
// WL36
size_t new_len= 0;
const char* new_db= binlog_filter->get_rewrite_db(
map->get_db_name(), &new_len);
if (new_len && map->rewrite_db(new_db, new_len,
glob_description_event))
{ error("Could not rewrite database name");
goto err;
}
}
case WRITE_ROWS_EVENT:
case DELETE_ROWS_EVENT:
case UPDATE_ROWS_EVENT:
...
}
...
}
Comment. Rpl_filter::get_rewrite_db(db_from, &len): if filter contains
a (db_from, db_to) pair, this function returns pointer to db_to and
sets len = db_to length; otherwise, it returns db_from and does not
change len value.
3. Supporting rewrite-db for SBR events
---------------------------------------
Limited to emiting USE <db_to> instead of USE <db_from>.
USE statements can be emited by mysqlbinlog as a result of processing the
following events (see process_event() function):
- Query_log_event
- Load_log_event
- Execute_load_query_log_event [ :public Query_log_event ]
- Create_file_log_event [ :public Load_log_event ]
TODO. Needed to check this list carefully (not sure for Create_file_log_event)
Notes.
- In replication, only Query_log_event and Load_log_event uses
rpl_filter->get_rewrite_db();
- In mysqlbinlog (process_event), Execute_load_query_log_event
and Create_file_log_event are processed in separate switch
cases. And Load_log_event is processed in the default switch case.
Conditions for emiting use-statement:
- LOG_EVENT_SUPPRESS_USE_F is OFF for the event
(e.g. it is ON for 'create database' statement)
- event's db name differs from db_name in PRINT_EVENT_INFO
(PRINT_EVENT_INFO keeps db name of the last issued USE statement;
initially, this db name is empty).
3.1. In mysqlbinlog.cc
- Add the following function:
void print_use_stmt(Log_event* event, PRINT_EVENT_INFO* pinfo)
{
if (event->flags & LOG_EVENT_SUPPRESS_USE_F)
return;
/*
- For events listed above get db_from = event->db;
- If db_from is the same as pinfo->db then return;
- If there is rewrite-db rule db_from->db_to,
set db = db_to. Else set db = db_from;
- Print "use <db>" to mysqlbinlog output
- Set pinfo->db = db_from
(this suppresses emiting use-statements by corresponding
log_event's print-function)
*/
}
- In process_event() function add switch case for Load_log_event and
add print_use_stmt() invocations where needed (according to the
events list above), e.g.:
Exit_status process_event(
PRINT_EVENT_INFO *print_event_info,
Log_event *ev, ...)
{
...
switch (ev_type) {
case QUERY_EVENT:
if (shall_skip_database(((Query_log_event*)ev)->db))
goto end;
if (opt_base64_output_mode == BASE64_OUTPUT_ALWAYS)
{
// Possibly in case of rewite-db rule for ev->db
// a warning should be emited here (see note below)
... write_event_header_and_base64(ev, ...) ...
}
else
{
print_use_stmt((Query_log_event*)ev, print_event_info);
ev->print(result_file, print_event_info);
}
break;
...
case LOAD_EVENT:
print_use_stmt((Load_log_event*)ev, print_event_info);
break;
default:
...
}
...
}
Note. write_event_header_and_base64() does not print use-statement. It
produces BINLOG statement using ev->temp_buf content (i.e. the binary
log representation of the event). We don't rewrite temp_buf here with
db_to name (as we do it for Table map event) - this implies the
limitation 3 mentioned above.
Question: Is supporting of rewite_db + --base64-output really needed
currently?
4. Current status
-----------------
The outlined design (implemented for mysql-5.1.37) is tested for
simple test-cases.
TODO. 1. Check list of events which can emit use-statement.
2. Supporting of rewite_db + --base64-output ?
ESTIMATED WORK TIME
ESTIMATED COMPLETION DATE
-----------------------------------------------------------------------
WorkLog (v3.5.9)
1
0
[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2748)
by knielsen@knielsen-hq.org 02 Oct '09
by knielsen@knielsen-hq.org 02 Oct '09
02 Oct '09
#At lp:maria
2748 knielsen(a)knielsen-hq.org 2009-10-02 [merge]
Merge Monty's fixes from main into release branch.
- MariaDB naming.
- Error reporting with mysqld --help --verbose.
modified:
client/mysql.cc
configure.in
include/mysql.h
include/mysql.h.pp
libmysql/libmysql.c
mysql-test/r/mysqld_option_err.result
mysql-test/t/mysqld_option_err.test
sql/mysqld.cc
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2009-09-07 20:50:10 +0000
+++ b/client/mysql.cc 2009-10-02 11:56:11 +0000
@@ -43,7 +43,7 @@
#include <locale.h>
#endif
-const char *VER= "14.15";
+const char *VER= "14.16";
/* Don't try to make a nice table if the data is too big */
#define MAX_COLUMN_LENGTH 1024
@@ -1076,7 +1076,7 @@ int main(int argc,char *argv[])
delimiter_str= delimiter;
default_prompt = my_strdup(getenv("MYSQL_PS1") ?
getenv("MYSQL_PS1") :
- "mysql> ",MYF(MY_WME));
+ "\\N [\\d]> ",MYF(MY_WME));
current_prompt = my_strdup(default_prompt,MYF(MY_WME));
prompt_counter=0;
@@ -1156,10 +1156,11 @@ int main(int argc,char *argv[])
signal(SIGINT, handle_sigint); // Catch SIGINT to clean up
signal(SIGQUIT, mysql_end); // Catch SIGQUIT to clean up
- put_info("Welcome to the MySQL monitor. Commands end with ; or \\g.",
+ put_info("Welcome to the MariaDB monitor. Commands end with ; or \\g.",
INFO_INFO);
sprintf((char*) glob_buffer.ptr(),
- "Your MySQL connection id is %lu\nServer version: %s\n",
+ "Your %s connection id is %lu\nServer version: %s\n",
+ mysql_get_server_name(&mysql),
mysql_thread_id(&mysql), server_version_string(&mysql));
put_info((char*) glob_buffer.ptr(),INFO_INFO);
@@ -4369,6 +4370,7 @@ com_status(String *buffer __attribute__(
tee_fprintf(stdout, "Using outfile:\t\t'%s'\n", opt_outfile ? outfile : "");
#endif
tee_fprintf(stdout, "Using delimiter:\t%s\n", delimiter);
+ tee_fprintf(stdout, "Server:\t\t\t%s\n", mysql_get_server_name(&mysql));
tee_fprintf(stdout, "Server version:\t\t%s\n", server_version_string(&mysql));
tee_fprintf(stdout, "Protocol version:\t%d\n", mysql_get_proto_info(&mysql));
tee_fprintf(stdout, "Connection:\t\t%s\n", mysql_get_host_info(&mysql));
@@ -4700,7 +4702,7 @@ static void mysql_end_timer(ulong start_
strmov(strend(buff),")");
}
-static const char* construct_prompt()
+static const char *construct_prompt()
{
processed_prompt.free(); // Erase the old prompt
time_t lclock = time(NULL); // Get the date struct
@@ -4729,6 +4731,12 @@ static const char* construct_prompt()
case 'd':
processed_prompt.append(current_db ? current_db : "(none)");
break;
+ case 'N':
+ if (connected)
+ processed_prompt.append(mysql_get_server_name(&mysql));
+ else
+ processed_prompt.append("unknown");
+ break;
case 'h':
{
const char *prompt;
=== modified file 'configure.in'
--- a/configure.in 2009-09-29 22:50:10 +0000
+++ b/configure.in 2009-10-02 12:55:16 +0000
@@ -13,7 +13,7 @@ AC_CANONICAL_SYSTEM
#
# When merging new MySQL releases, update the version number to match the
# MySQL version number, but reset the maria subrelease (-beta1).
-AM_INIT_AUTOMAKE(mysql, 5.1.38-maria-beta1)
+AM_INIT_AUTOMAKE(mysql, 5.1.38-MariaDB-beta1)
AM_CONFIG_HEADER([include/config.h:config.h.in])
PROTOCOL_VERSION=10
=== modified file 'include/mysql.h'
--- a/include/mysql.h 2007-11-26 18:10:26 +0000
+++ b/include/mysql.h 2009-10-02 10:36:28 +0000
@@ -527,6 +527,7 @@ int STDCALL mysql_set_server_option(MYS
int STDCALL mysql_ping(MYSQL *mysql);
const char * STDCALL mysql_stat(MYSQL *mysql);
const char * STDCALL mysql_get_server_info(MYSQL *mysql);
+const char * STDCALL mysql_get_server_name(MYSQL *mysql);
const char * STDCALL mysql_get_client_info(void);
unsigned long STDCALL mysql_get_client_version(void);
const char * STDCALL mysql_get_host_info(MYSQL *mysql);
@@ -560,6 +561,7 @@ void STDCALL mysql_debug(const char *de
void STDCALL myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int STDCALL mysql_thread_safe(void);
my_bool STDCALL mysql_embedded(void);
+my_bool STDCALL mariadb_connection(MYSQL *mysql);
MYSQL_MANAGER* STDCALL mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* STDCALL mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
=== modified file 'include/mysql.h.pp'
--- a/include/mysql.h.pp 2009-03-12 22:27:35 +0000
+++ b/include/mysql.h.pp 2009-10-02 10:36:28 +0000
@@ -487,6 +487,7 @@ int mysql_set_server_option(MYSQL *mysql
int mysql_ping(MYSQL *mysql);
const char * mysql_stat(MYSQL *mysql);
const char * mysql_get_server_info(MYSQL *mysql);
+const char * mysql_get_server_name(MYSQL *mysql);
const char * mysql_get_client_info(void);
unsigned long mysql_get_client_version(void);
const char * mysql_get_host_info(MYSQL *mysql);
@@ -520,6 +521,7 @@ void mysql_debug(const char *debug);
void myodbc_remove_escape(MYSQL *mysql,char *name);
unsigned int mysql_thread_safe(void);
my_bool mysql_embedded(void);
+my_bool mariadb_connection(MYSQL *mysql);
MYSQL_MANAGER* mysql_manager_init(MYSQL_MANAGER* con);
MYSQL_MANAGER* mysql_manager_connect(MYSQL_MANAGER* con,
const char* host,
=== modified file 'libmysql/libmysql.c'
--- a/libmysql/libmysql.c 2009-04-25 10:05:32 +0000
+++ b/libmysql/libmysql.c 2009-10-02 10:36:28 +0000
@@ -1430,6 +1430,18 @@ mysql_get_server_info(MYSQL *mysql)
}
+my_bool STDCALL mariadb_connection(MYSQL *mysql)
+{
+ return strinstr(mysql->server_version, "MariaDB") != 0;
+}
+
+const char * STDCALL
+mysql_get_server_name(MYSQL *mysql)
+{
+ return mariadb_connection(mysql) ? "MariaDB" : "MySQL";
+}
+
+
const char * STDCALL
mysql_get_host_info(MYSQL *mysql)
{
=== modified file 'mysql-test/r/mysqld_option_err.result'
--- a/mysql-test/r/mysqld_option_err.result 2009-09-03 13:05:02 +0000
+++ b/mysql-test/r/mysqld_option_err.result 2009-10-02 11:09:01 +0000
@@ -3,4 +3,6 @@ Test bad binlog format.
Test bad default storage engine.
Test non-numeric value passed to number option.
Test that bad value for plugin enum option is rejected correctly.
+Test that --help --verbose works
+Test that --not-known-option --help --verbose gives error
Done.
=== modified file 'mysql-test/t/mysqld_option_err.test'
--- a/mysql-test/t/mysqld_option_err.test 2009-09-25 14:38:02 +0000
+++ b/mysql-test/t/mysqld_option_err.test 2009-10-02 11:09:01 +0000
@@ -46,5 +46,14 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_optio
--error 7
--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables $EXAMPLE_PLUGIN_OPT --plugin-load=EXAMPLE=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+#
+# Test that an wrong option with --help --verbose gives an error
+#
+
+--echo Test that --help --verbose works
+--exec $MYSQLD --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+--echo Test that --not-known-option --help --verbose gives error
+--error 2
+--exec $MYSQLD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--echo Done.
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-09-17 22:46:10 +0000
+++ b/sql/mysqld.cc 2009-10-02 11:09:01 +0000
@@ -4020,9 +4020,6 @@ server.");
plugins_are_initialized= TRUE; /* Don't separate from init function */
}
- if (opt_help)
- unireg_abort(0);
-
/* we do want to exit if there are any other unknown options */
if (defaults_argc > 1)
{
@@ -4047,13 +4044,15 @@ server.");
if (defaults_argc)
{
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n"
- "Use --verbose --help to get a list of available options\n",
+ fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n",
my_progname, *tmp_argv);
unireg_abort(1);
}
}
+ if (opt_help)
+ unireg_abort(0);
+
/* if the errmsg.sys is not loaded, terminate to maintain behaviour */
if (!errmesg[0][0])
unireg_abort(1);
1
0
[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (knielsen:2747)
by knielsen@knielsen-hq.org 02 Oct '09
by knielsen@knielsen-hq.org 02 Oct '09
02 Oct '09
#At lp:maria
2747 knielsen(a)knielsen-hq.org 2009-10-02
Add missing windows files to `make dist`.
modified:
win/Makefile.am
=== modified file 'win/Makefile.am'
--- a/win/Makefile.am 2009-06-18 08:49:44 +0000
+++ b/win/Makefile.am 2009-10-02 12:53:05 +0000
@@ -16,7 +16,8 @@
## Process this file with automake to create Makefile.in
EXTRA_DIST = build-vs71.bat build-vs8.bat build-vs8_x64.bat build-vs9.bat \
build-vs9_x64.bat configure.js README mysql_manifest.cmake \
- create_manifest.js create_def_file.js
+ create_manifest.js create_def_file.js build-nmake.bat \
+ build-nmake-x64.bat
# Don't update the files from bitkeeper
%::SCCS/s.%
1
0
[Maria-developers] [Branch ~maria-captains/maria/5.1] Rev 2740: Fixed typo
by noreply@launchpad.net 02 Oct '09
by noreply@launchpad.net 02 Oct '09
02 Oct '09
------------------------------------------------------------
revno: 2740
committer: Michael Widenius <monty(a)askmonty.org>
branch nick: mysql-maria
timestamp: Fri 2009-10-02 14:56:11 +0300
message:
Fixed typo
modified:
client/mysql.cc
--
lp:maria
https://code.launchpad.net/~maria-captains/maria/5.1
Your team Maria developers is subscribed to branch lp:maria.
To unsubscribe from this branch go to https://code.launchpad.net/~maria-captains/maria/5.1/+edit-subscription.
1
0
[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (monty:2740)
by Michael Widenius 02 Oct '09
by Michael Widenius 02 Oct '09
02 Oct '09
#At lp:maria based on revid:monty@askmonty.org-20091002110901-trnebmidd47qw6vk
2740 Michael Widenius 2009-10-02
Fixed typo
modified:
client/mysql.cc
=== modified file 'client/mysql.cc'
--- a/client/mysql.cc 2009-10-02 10:36:28 +0000
+++ b/client/mysql.cc 2009-10-02 11:56:11 +0000
@@ -4735,7 +4735,7 @@ static const char *construct_prompt()
if (connected)
processed_prompt.append(mysql_get_server_name(&mysql));
else
- processed_prompt.append("unkown");
+ processed_prompt.append("unknown");
break;
case 'h':
{
1
0
[Maria-developers] [Branch ~maria-captains/maria/5.1] Rev 2739: When using --help --verbose give error and abort if there are any unknown options
by noreply@launchpad.net 02 Oct '09
by noreply@launchpad.net 02 Oct '09
02 Oct '09
------------------------------------------------------------
revno: 2739
committer: Michael Widenius <monty(a)askmonty.org>
branch nick: mysql-maria
timestamp: Fri 2009-10-02 14:09:01 +0300
message:
When using --help --verbose give error and abort if there are any unknown options
modified:
mysql-test/r/mysqld_option_err.result
mysql-test/t/mysqld_option_err.test
sql/mysqld.cc
--
lp:maria
https://code.launchpad.net/~maria-captains/maria/5.1
Your team Maria developers is subscribed to branch lp:maria.
To unsubscribe from this branch go to https://code.launchpad.net/~maria-captains/maria/5.1/+edit-subscription.
1
0
[Maria-developers] bzr commit into MariaDB 5.1, with Maria 1.5:maria branch (monty:2739)
by Michael Widenius 02 Oct '09
by Michael Widenius 02 Oct '09
02 Oct '09
#At lp:maria based on revid:monty@askmonty.org-20091002103628-i11aqe3i16vgf514
2739 Michael Widenius 2009-10-02
When using --help --verbose give error and abort if there are any unknown options
modified:
mysql-test/r/mysqld_option_err.result
mysql-test/t/mysqld_option_err.test
sql/mysqld.cc
per-file messages:
mysql-test/r/mysqld_option_err.result
Test that mysqld --not-known-option --help --verbose gives error
mysql-test/t/mysqld_option_err.test
Test that mysqld --not-known-option --help --verbose gives error
sql/mysqld.cc
When using --help --verbose give error and abort if there are any unknown options
=== modified file 'mysql-test/r/mysqld_option_err.result'
--- a/mysql-test/r/mysqld_option_err.result 2009-09-03 13:05:02 +0000
+++ b/mysql-test/r/mysqld_option_err.result 2009-10-02 11:09:01 +0000
@@ -3,4 +3,6 @@ Test bad binlog format.
Test bad default storage engine.
Test non-numeric value passed to number option.
Test that bad value for plugin enum option is rejected correctly.
+Test that --help --verbose works
+Test that --not-known-option --help --verbose gives error
Done.
=== modified file 'mysql-test/t/mysqld_option_err.test'
--- a/mysql-test/t/mysqld_option_err.test 2009-09-25 14:38:02 +0000
+++ b/mysql-test/t/mysqld_option_err.test 2009-10-02 11:09:01 +0000
@@ -46,5 +46,14 @@ mkdir $MYSQLTEST_VARDIR/tmp/mysqld_optio
--error 7
--exec $MYSQLD --skip-networking --datadir=$MYSQLTEST_VARDIR/tmp/mysqld_option_err --skip-grant-tables $EXAMPLE_PLUGIN_OPT --plugin-load=EXAMPLE=ha_example.so --plugin-example-enum-var=noexist >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+#
+# Test that an wrong option with --help --verbose gives an error
+#
+
+--echo Test that --help --verbose works
+--exec $MYSQLD --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
+--echo Test that --not-known-option --help --verbose gives error
+--error 2
+--exec $MYSQLD --not-known-option --help --verbose >>$MYSQLTEST_VARDIR/tmp/mysqld_option_err/mysqltest.log 2>&1
--echo Done.
=== modified file 'sql/mysqld.cc'
--- a/sql/mysqld.cc 2009-09-17 22:46:10 +0000
+++ b/sql/mysqld.cc 2009-10-02 11:09:01 +0000
@@ -4020,9 +4020,6 @@ server.");
plugins_are_initialized= TRUE; /* Don't separate from init function */
}
- if (opt_help)
- unireg_abort(0);
-
/* we do want to exit if there are any other unknown options */
if (defaults_argc > 1)
{
@@ -4047,13 +4044,15 @@ server.");
if (defaults_argc)
{
- fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n"
- "Use --verbose --help to get a list of available options\n",
+ fprintf(stderr, "%s: Too many arguments (first extra is '%s').\n",
my_progname, *tmp_argv);
unireg_abort(1);
}
}
+ if (opt_help)
+ unireg_abort(0);
+
/* if the errmsg.sys is not loaded, terminate to maintain behaviour */
if (!errmesg[0][0])
unireg_abort(1);
1
0