From 8076d23f41d689c611ad320251bb6d295f0b405f Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 10 Sep 2007 16:10:37 -0600 Subject: WL#4030 (Deprecate RENAME DATABASE: replace with ALTER DATABASE UPGRADE) Bug 17565 (RENAME DATABASE destroys events) Bug#28360 (RENAME DATABASE destroys routines) Removed the RENAME DATABASE db1 TO db2 statement. Implemented the ALTER DATABASE db UPGRADE DATA DIRECTORY NAME statement, which has the same function. client/mysqlcheck.c: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/create.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/query_cache.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/renamedb.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/sp-code.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/sp-error.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/r/upgrade.result: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/create.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/query_cache.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/renamedb.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/sp-error.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME mysql-test/t/upgrade.test: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/mysql_priv.h: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_lex.h: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_parse.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_prepare.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_yacc.yy: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME sql/sql_db.cc: ALTER DATABASE db UPGRADE DATA DIRECTORY NAME --- sql/sql_prepare.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_prepare.cc') diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 9337a2aa329..c576a9dba1d 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1799,7 +1799,7 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_UNINSTALL_PLUGIN: case SQLCOM_CREATE_DB: case SQLCOM_DROP_DB: - case SQLCOM_RENAME_DB: + case SQLCOM_ALTER_DB_UPGRADE: case SQLCOM_CHECKSUM: case SQLCOM_CREATE_USER: case SQLCOM_RENAME_USER: -- cgit v1.2.1 From fa48986a0d1b8214a118b29b95a3e8fdb0fd9eb4 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 28 Sep 2007 15:42:37 +0400 Subject: Prerequisite patch for BUG#30472: libmysql doesn't reset charset, insert_id after succ. mysql_change_user() call. Supply a correct packet length to dispatch command. sql/sp_head.cc: Fix packet length. sql/sql_parse.cc: Fix packet length. sql/sql_prepare.cc: Fix packet length. tests/mysql_client_test.c: Test case for COM_CHANGE_USER. --- sql/sql_prepare.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'sql/sql_prepare.cc') diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index c576a9dba1d..05743b6dfe3 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2107,7 +2107,7 @@ void mysql_sql_stmt_prepare(THD *thd) DBUG_VOID_RETURN; } - if (stmt->prepare(query, query_len+1)) + if (stmt->prepare(query, query_len)) { /* Statement map deletes the statement on erase */ thd->stmt_map.erase(stmt); @@ -2270,7 +2270,7 @@ void mysql_stmt_execute(THD *thd, char *packet_arg, uint packet_length) /* Query text for binary, general or slow log, if any of them is open */ String expanded_query; #ifndef EMBEDDED_LIBRARY - uchar *packet_end= packet + packet_length - 1; + uchar *packet_end= packet + packet_length; #endif Prepared_statement *stmt; bool error; @@ -2585,14 +2585,14 @@ void mysql_stmt_get_longdata(THD *thd, char *packet, ulong packet_length) Prepared_statement *stmt; Item_param *param; #ifndef EMBEDDED_LIBRARY - char *packet_end= packet + packet_length - 1; + char *packet_end= packet + packet_length; #endif DBUG_ENTER("mysql_stmt_get_longdata"); status_var_increment(thd->status_var.com_stmt_send_long_data); #ifndef EMBEDDED_LIBRARY /* Minimal size of long data packet is 6 bytes */ - if (packet_length <= MYSQL_LONG_DATA_HEADER) + if (packet_length < MYSQL_LONG_DATA_HEADER) { my_error(ER_WRONG_ARGUMENTS, MYF(0), "mysql_stmt_send_long_data"); DBUG_VOID_RETURN; @@ -2866,6 +2866,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) error= parse_sql(thd, &lip, NULL) || thd->net.report_error || init_param_array(this); + lex->set_trg_event_type_for_tables(); /* Remember the current database. */ @@ -3059,7 +3060,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) if (expanded_query->length() && alloc_query(thd, (char*) expanded_query->ptr(), - expanded_query->length()+1)) + expanded_query->length())) { my_error(ER_OUTOFMEMORY, 0, expanded_query->length()); goto error; -- cgit v1.2.1 From b9b481ec70c2475abb6303ae08c6b73592bf0c03 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 18 Oct 2007 15:45:07 -0300 Subject: Bug#21557 entries in the general query log truncated at 1000 characters. The general log write function (general_log_print) uses printf style arguments which need to be pre-processed, meaning that the all arguments are copied to a single buffer and the problem is that the buffer size is constant (1022 characters) but queries can be much larger then this. The solution is to introduce a new log write function that accepts a buffer and it's length as arguments. The function is to be used when a formatted output is not required, which is the case for almost all query write-to-log calls. This is a incompatible change with respect to the log format of prepared statements. mysql-test/r/log_tables.result: Add test case result for Bug#21557 mysql-test/t/log_tables.test: Add test case for Bug#21557 sql/log.cc: Introduce the logger function general_log_write which is similar to general_log_print but accepts a single buffer and the buffer length. The function doesn't perform any formatting and sends the buffer directly to the underlying log handlers. sql/log.h: Introduce the logger function general_log_write. sql/log_event.cc: Pass the query buffer directly to the logger function, formatting is not required on this case. sql/mysql_priv.h: Prototype for the logger function general_log_write. sql/sp_head.cc: Pass the query buffer directly to the logger function, formatting is not required on this case. sql/sql_parse.cc: Pass the buffer directly to the logger function when formatting is not required. sql/sql_prepare.cc: Don't log the statement id, it avoids making a extra copy of the query and the query is not truncated anymore if it exceeds the limit. --- sql/sql_prepare.cc | 13 ++----------- 1 file changed, 2 insertions(+), 11 deletions(-) (limited to 'sql/sql_prepare.cc') diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 05743b6dfe3..a6cdcf14881 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -2947,12 +2947,7 @@ bool Prepared_statement::prepare(const char *packet, uint packet_len) the general log. */ if (thd->spcont == NULL) - { - const char *format= "[%lu] %.*b"; - general_log_print(thd, COM_STMT_PREPARE, format, id, - query_length, query); - - } + general_log_write(thd, COM_STMT_PREPARE, query, query_length); } DBUG_RETURN(error); } @@ -3150,11 +3145,7 @@ bool Prepared_statement::execute(String *expanded_query, bool open_cursor) the general log. */ if (error == 0 && thd->spcont == NULL) - { - const char *format= "[%lu] %.*b"; - general_log_print(thd, COM_STMT_EXECUTE, format, id, - thd->query_length, thd->query); - } + general_log_write(thd, COM_STMT_EXECUTE, thd->query, thd->query_length); error: flags&= ~ (uint) IS_IN_USE; -- cgit v1.2.1