From 4e8b49d656828fbe2f84d9970a036db644185981 Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 29 Jan 2007 10:40:26 +0100 Subject: WL#3700: Handler API change: all index search methods - that is, index_read(), index_read_idx(), index_read_last(), and records_in_range() - instead of 'uint keylen' argument take 'ulonglong keypart_map', a bitmap showing which keyparts are present in the key value. Fallback method is provided for handlers that are lagging behind. --- sql/sql_udf.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 7dec58d9b6e..b0e7831465a 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -514,8 +514,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) table->use_all_columns(); table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin); if (!table->file->index_read_idx(table->record[0], 0, - (byte*) table->field[0]->ptr, - table->key_info[0].key_length, + (byte*) table->field[0]->ptr, ~ULL(0), HA_READ_KEY_EXACT)) { int error; -- cgit v1.2.1 From 62b41b5fbcf3fe8bd680e28e0064d3194daf4157 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 16 Mar 2007 09:56:57 -0400 Subject: WL#3629 - Replication of Invocation and Invoked Features This changeset adds replication of events and user-defined functions. There are several bug reports involved in this change: BUG#16421, BUG#17857, BUG#20384: This patch modifies the mysql.events table to permit the addition of another enum value for the status column. The column now has values of ('DISABLED','SLAVESIDE_DISABLED','ENABLED'). A status of SLAVESIDE_DISABLED is set on the slave during replication of events. This enables users to determine which events werereplicated from the master and to later enable them if they promote the slave to a master. The CREATE, ALTER, and DROP statements are binlogged. A new test was added for replication of events (rpl_events). BUG#17671: This patch modifies the code to permit logging of user-defined functions. Note: this is the CREATE FUNCTION ... SONAME variety. A more friendly error message to be displayed should a replicated user-defined function not be found in the loadable library or if the library is missing from the slave.The CREATE andDROP statements are binlogged. A new test was added for replication of user-defined functions (rpl_udf). The patch also adds a new column to the mysql.event table named 'originator' that is used to store the server_id of the server that the event originated on. This enables users to promote a slave to a master and later return the promoted slave to a slave and disable the replicated events. mysql-test/lib/init_db.sql: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. mysql-test/r/events.result: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/events_grant.result: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_grant test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/events_restart_phase1.result: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_restart_phase1 test results. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/r/system_mysql_db.result: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. These changes to the result file were necessary to ensure correct test results. mysql-test/t/events.test: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events test. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. mysql-test/t/events_restart_phase1.test: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the 'originator' column to the events_restart_phase1 test. This was necessary to ensure the manual insert into mysql.event table succeeds because the originator column is set to NOT NULL. scripts/mysql_create_system_tables.sh: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. scripts/mysql_fix_privilege_tables.sql: WL#3629 - Replication of Invocation and Invoked Feature This patch adds the SLAVESIDE_DISABLED to the list of enumerated values for the mysql.event table. This patch adds the column 'originator' to the mysql.event table. sql/event_data_objects.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. This patch uses the new Event_basic:: enumerated values. sql/event_data_objects.h: WL#3629 - Replication of Invocation and Invoked Features This patch moves the duplicated enumeration values for ENABLED, SLAVESIDE_DISABLED, and DISABLED to the Event_basic class removing them from the other Event_* classes. sql/event_db_repository.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. The patch also adds a new column to the mysql.event table named 'originator' that is used to store the server_id of the server that the event originated on. This enables users to promote a slave to a master and later return the promoted slave to a slave and disable the replicated events. sql/event_db_repository.h: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add a new field named 'originator' to the enum_event_table_field and associated structure. sql/event_queue.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. sql/events.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. sql/lex.h: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add the new SLAVESIDE_DISABLE symbol to the lexical parser. sql/slave.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit the capture of the error on the slave when a UDF from a loadable library is not loaded on the server when replicated from the master. sql/sql_parse.cc: WL#3629 - Replication of Invocation and Invoked Features This patch removes the comment because drop functions commands are replicated. sql/sql_show.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to permit processing of the new enum SLAVESIDE_DISABLED which is set on the slave during replication of events. The code also adds changes the display width of the status column for the schema table for the show events command and also adds the new column 'originator' to the events_field_info structure. sql/sql_udf.cc: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to add the binlogging of the create and drop function events. sql/sql_yacc.yy: WL#3629 - Replication of Invocation and Invoked Features This patch modifies the code to change the enumeration of the status column for the events in the parser. The code uses the Event_basic:: enumerations allowing the enums to be defined in one place. mysql-test/t/rpl_events.test: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new test for testing replication of events. The test uses include files so that the test can test under both RBR and SBR. mysql-test/r/rpl_events.result: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new result file for testing replication of events. mysql-test/r/rpl_udf.result: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new result file for testing replication of UDFs. mysql-test/t/rpl_udf.test: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new test for testing replication of UDFs. The test uses include files so that the test can test under both RBR and SBR. mysql-test/include/rpl_events.inc: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new include file for testing replication of events. This file contains the core test procedures. mysql-test/include/rpl_udf.inc: WL#3629 - Replication of Invocation and Invoked Features This patch adds a new include file for testing replication of UDFs. This file contains the core test procedures. --- sql/sql_udf.cc | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index 7dec58d9b6e..3ab161bb04f 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -403,6 +403,13 @@ int mysql_create_function(THD *thd,udf_func *udf) DBUG_RETURN(1); } + /* + Turn off row binlogging of this statement and use statement-based + so that all supporting tables are updated for CREATE FUNCTION command. + */ + if (thd->current_stmt_binlog_row_based) + thd->clear_current_stmt_binlog_row_based(); + rw_wrlock(&THR_LOCK_udf); if ((hash_search(&udf_hash,(byte*) udf->name.str, udf->name.length))) { @@ -466,6 +473,15 @@ int mysql_create_function(THD *thd,udf_func *udf) goto err; } rw_unlock(&THR_LOCK_udf); + + /* Binlog the create function. */ + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, + thd->query, thd->query_length, FALSE, FALSE); + } + DBUG_RETURN(0); err: @@ -484,11 +500,20 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) char *exact_name_str; uint exact_name_len; DBUG_ENTER("mysql_drop_function"); + if (!initialized) { my_message(ER_OUT_OF_RESOURCES, ER(ER_OUT_OF_RESOURCES), MYF(0)); DBUG_RETURN(1); } + + /* + Turn off row binlogging of this statement and use statement-based + so that all supporting tables are updated for DROP FUNCTION command. + */ + if (thd->current_stmt_binlog_row_based) + thd->clear_current_stmt_binlog_row_based(); + rw_wrlock(&THR_LOCK_udf); if (!(udf=(udf_func*) hash_search(&udf_hash,(byte*) udf_name->str, (uint) udf_name->length))) @@ -525,6 +550,15 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) close_thread_tables(thd); rw_unlock(&THR_LOCK_udf); + + /* Binlog the drop function. */ + if (mysql_bin_log.is_open()) + { + thd->clear_error(); + thd->binlog_query(THD::MYSQL_QUERY_TYPE, + thd->query, thd->query_length, FALSE, FALSE); + } + DBUG_RETURN(0); err: rw_unlock(&THR_LOCK_udf); -- cgit v1.2.1 From 7d383909db64d10283c1e37a7b45026d5b3b2e3c Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 17 Mar 2007 00:13:25 +0100 Subject: wl#3700 - post-review fixes: s/ulonglong/key_part_map/, comments include/heap.h: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ include/my_base.h: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ include/myisam.h: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ include/myisammrg.h: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ sql/event_db_repository.cc: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ sql/ha_partition.cc: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ sql/ha_partition.h: wl#3700 - post-review fixes: s/ulonglong/key_part_map/ sql/sql_select.h: wl#3700 - post-review fixes: remove tab_to_keypart_map() --- sql/sql_udf.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index b0e7831465a..4c584bff72a 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -514,7 +514,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) table->use_all_columns(); table->field[0]->store(exact_name_str, exact_name_len, &my_charset_bin); if (!table->file->index_read_idx(table->record[0], 0, - (byte*) table->field[0]->ptr, ~ULL(0), + (byte*) table->field[0]->ptr, HA_WHOLE_KEY, HA_READ_KEY_EXACT)) { int error; @@ -523,7 +523,7 @@ int mysql_drop_function(THD *thd,const LEX_STRING *udf_name) } close_thread_tables(thd); - rw_unlock(&THR_LOCK_udf); + rw_unlock(&THR_LOCK_udf); DBUG_RETURN(0); err: rw_unlock(&THR_LOCK_udf); -- cgit v1.2.1 From fe074a726fae715912a94630ac5301c60e868e98 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 3 Apr 2007 16:13:27 +0500 Subject: Bug#21432 Database/Table name limited to 64 bytes, not chars, problems with multi-byte client/mysqldump.c: fixed typo include/mysql_com.h: added new constants SYSTEM_CHARSET_MBMAXLEN, NAME_CHAR_LEN, USERNAME_CHAR_LENGTH increased NAME_LEN, USERNAME_LENGTH mysql-test/r/create.result: result fix mysql-test/r/grant.result: result fix mysql-test/r/mysql.result: result fix mysql-test/r/sp.result: result fix mysql-test/t/create.test: test case mysql-test/t/grant.test: test case sql/events.cc: NAME_LEN is replaced with NAME_CHAR_LEN sql/item_strfunc.h: fixed calculation of max_length sql/mysql_priv.h: check_string_length function is replaced with check_string_byte_length added new function check_string_char_length sql/sp.cc: NAME_LEN is replaced with NAME_CHAR_LEN sql/sp_head.cc: NAME_LEN is replaced with NAME_CHAR_LEN sql/sp_head.h: changed parameter of 'check_routine_name' function sql/sql_class.cc: NAME_LEN is replaced with NAME_CHAR_LEN sql/share/errmsg.txt: increased argument lengths according to new constants sql/sql_parse.cc: removed unnecessary checks added function 'check_string_char_length' sql/sql_plugin.cc: check that name is not longer than NAME_CHAR_LEN symbols sql/sql_show.cc: NAME_LEN is replaced with NAME_CHAR_LEN sql/sql_table.cc: check that key name is not longer than NAME_LEN symbols sql/sql_udf.cc: check that udf name is not longer than NAME_CHAR_LEN symbols sql/sql_yacc.yy: check that user name is not longer than USERNAME_CHAR_LENGTH symbols sql/table.cc: check that db or table or column name is not longer than NAME_LEN symbols storage/innobase/handler/ha_innodb.cc: removed unnecessary multiplication tests/mysql_client_test.c: NAME_LEN is replaced with NAME_CHAR_LEN --- sql/sql_udf.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'sql/sql_udf.cc') diff --git a/sql/sql_udf.cc b/sql/sql_udf.cc index da5c1b0bc66..fd7ba698a93 100644 --- a/sql/sql_udf.cc +++ b/sql/sql_udf.cc @@ -169,8 +169,10 @@ void udf_init() This is done to ensure that only approved dll from the system directories are used (to make this even remotely secure). */ - if (my_strchr(files_charset_info, dl_name, dl_name + strlen(dl_name), FN_LIBCHAR) || - strlen(name.str) > NAME_LEN) + if (my_strchr(files_charset_info, dl_name, + dl_name + strlen(dl_name), FN_LIBCHAR) || + check_string_char_length(&name, "", NAME_CHAR_LEN, + system_charset_info, 1)) { sql_print_error("Invalid row in mysql.func table for function '%.64s'", name.str); @@ -397,7 +399,8 @@ int mysql_create_function(THD *thd,udf_func *udf) my_message(ER_UDF_NO_PATHS, ER(ER_UDF_NO_PATHS), MYF(0)); DBUG_RETURN(1); } - if (udf->name.length > NAME_LEN) + if (check_string_char_length(&udf->name, "", NAME_CHAR_LEN, + system_charset_info, 1)) { my_error(ER_TOO_LONG_IDENT, MYF(0), udf->name); DBUG_RETURN(1); -- cgit v1.2.1