diff options
author | unknown <mats@romeo.kindahl.net> | 2007-05-14 14:45:38 +0200 |
---|---|---|
committer | unknown <mats@romeo.kindahl.net> | 2007-05-14 14:45:38 +0200 |
commit | 499a8ecd21c2542c08e273faabfffa94ebec1cfa (patch) | |
tree | 0ac7772a8a7fdb3df1f3dc301bdeb9033cd2b0cc /sql/sql_lex.h | |
parent | f63501a2ca59d4448e7bf5b0ebe456ac3c23f771 (diff) | |
download | mariadb-git-499a8ecd21c2542c08e273faabfffa94ebec1cfa.tar.gz |
WL#3339 (Issue warnings when statement-based replication may fail):
Replacing binlog_row_based_if_mixed with variable binlog_stmt_flags
holding several flags and adding member functions to manipulate the
flags.
Added code to generate a warning when an attempt to log an unsafe
statement to the binary log was made. The warning is both pushed to the
SHOW WARNINGS table and written to the error log. The prevent flooding
the error log, the warning is just written to the error log once per
open session.
sql/item_create.cc:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
sql/sp_head.cc:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
sql/sp_head.h:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
sql/sql_base.cc:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
sql/sql_class.cc:
Adding THD::binlog_flags to store thread-specific binary log state.
Adding code to push a warning and write an entry into the error log
when an attempt is made to log an unsafe statement.
sql/sql_class.h:
Adding THD::binlog_flags to store thread-specific binary log state.
Adding BINLOG_FLAG_UNSAFE_STMT_PRINTED to denote that a warning for
an unsafe statement has already been generated for this thread.
sql/sql_insert.cc:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
sql/sql_lex.cc:
Replacing binlog_row_based_if_mixed with a variable binlog_stmt_flags
holding several flags.
sql/sql_lex.h:
Replacing binlog_row_based_if_mixed with a variable binlog_stmt_flags
holding several flags.
sql/share/errmsg.txt:
Adding error message to indicate that an attempt to log an unsafe
statement was made.
sql/sql_view.cc:
Using {is,set,clear}_stmt_unsafe() member functions instead of
binlog_row_based_if_mixed member variable.
mysql-test/r/binlog_unsafe.result:
New BitKeeper file ``mysql-test/r/binlog_unsafe.result''
mysql-test/t/binlog_unsafe.test:
New BitKeeper file ``mysql-test/t/binlog_unsafe.test''
Diffstat (limited to 'sql/sql_lex.h')
-rw-r--r-- | sql/sql_lex.h | 44 |
1 files changed, 36 insertions, 8 deletions
diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 850586c6098..7097c2de4fd 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -910,14 +910,6 @@ public: uint sroutines_list_own_elements; /* - Tells if the parsing stage detected that some items require row-based - binlogging to give a reliable binlog/replication, or if we will use - stored functions or triggers which themselves need require row-based - binlogging. - */ - bool binlog_row_based_if_mixed; - - /* These constructor and destructor serve for creation/destruction of Query_tables_list instances which are used as backup storage. */ @@ -964,6 +956,41 @@ public: query_tables_own_last= 0; } } + + /** + Has the parser/scanner detected that this statement is unsafe? + */ + inline bool is_stmt_unsafe() const { + return binlog_stmt_flags & (1U << BINLOG_STMT_FLAG_UNSAFE); + } + + /** + Flag the current (top-level) statement as unsafe. + + The flag will be reset after the statement has finished. + + */ + inline void set_stmt_unsafe() { + binlog_stmt_flags|= (1U << BINLOG_STMT_FLAG_UNSAFE); + } + + inline void clear_stmt_unsafe() { + binlog_stmt_flags&= ~(1U << BINLOG_STMT_FLAG_UNSAFE); + } + +private: + enum enum_binlog_stmt_flag { + BINLOG_STMT_FLAG_UNSAFE, + BINLOG_STMT_FLAG_COUNT + }; + + /* + Tells if the parsing stage detected properties of the statement, + for example: that some items require row-based binlogging to give + a reliable binlog/replication, or if we will use stored functions + or triggers which themselves need require row-based binlogging. + */ + uint32 binlog_stmt_flags; }; @@ -1299,6 +1326,7 @@ typedef struct st_lex : public Query_tables_list void restore_backup_query_tables_list(Query_tables_list *backup); bool table_or_sp_used(); + } LEX; struct st_lex_local: public st_lex |