From ec459b583b6281f6c918e8d56d7ca9316ddfa5c8 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 12 Jan 2005 22:55:10 +0200 Subject: [PATCH 1/2] Minor clean up. mysql-test/t/analyse.test: Added a note about the bug that this test case tests. sql/sql_analyse.cc: Changed function description to standard format. --- mysql-test/t/analyse.test | 5 +++++ sql/sql_analyse.cc | 15 +++++++-------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/mysql-test/t/analyse.test b/mysql-test/t/analyse.test index 34343c2b7bf..52e367769a2 100644 --- a/mysql-test/t/analyse.test +++ b/mysql-test/t/analyse.test @@ -38,6 +38,11 @@ select * from t2; insert into t2 select * from t1 procedure analyse(); select * from t2; drop table t1,t2; + +# +# Bug#2813 - analyse does not quote string values in enums from string +# + create table t1 (v varchar(128)); insert into t1 values ('abc'),('abc\'def\\hij\"klm\0opq'),('\''),('\"'),('\\'),('a\0'),('b\''),('c\"'),('d\\'),('\'b'),('\"c'),('\\d'),('a\0\0\0b'),('a\'\'\'\'b'),('a\"\"\"\"b'),('a\\\\\\\\b'),('\'\0\\\"'),('\'\''),('\"\"'),('\\\\'),('The\ZEnd'); select * from t1 procedure analyse(); diff --git a/sql/sql_analyse.cc b/sql/sql_analyse.cc index 5265857f3b1..33ce62bc5cf 100644 --- a/sql/sql_analyse.cc +++ b/sql/sql_analyse.cc @@ -1029,20 +1029,19 @@ uint check_ulonglong(const char *str, uint length) } /* check_ulonlong */ - /* - FUNCTION: append_escaped() - + Quote special characters in a string. + + SYNOPSIS + append_escaped(to_str, from_str) + to_str (in) A pointer to a String. + from_str (to) A pointer to an allocated string + DESCRIPTION append_escaped() takes a String type variable, where it appends escaped the second argument. Only characters that require escaping will be escaped. - ARGUMENTS - A pointer to a String variable, where results will be appended - A pointer to a String variable, which is appended to the result - String, escaping those characters that require it. - RETURN VALUES 0 Success 1 Out of memory From 069d260b0ea1bd77d1f8c31f2b137dd809830858 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 13 Jan 2005 02:13:19 +0300 Subject: [PATCH 2/2] Add logging of COM_EXECUTE in the general query log. sql/sql_parse.cc: A shorter name for COM_EXECUTE command. --- sql/sql_parse.cc | 2 +- sql/sql_prepare.cc | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 2b273f4b84c..4d802ad4f34 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -64,7 +64,7 @@ const char *command_name[]={ "Drop DB", "Refresh", "Shutdown", "Statistics", "Processlist", "Connect","Kill","Debug","Ping","Time","Delayed insert","Change user", "Binlog Dump","Table Dump", "Connect Out", "Register Slave", - "Prepare", "Prepare Execute", "Long Data", "Close stmt", + "Prepare", "Execute", "Long Data", "Close stmt", "Reset stmt", "Set option", "Error" // Last command number }; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 20ebc23e240..ecf01824755 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1592,7 +1592,7 @@ int mysql_stmt_prepare(THD *thd, char *packet, uint packet_length, DBUG_RETURN(1); } - mysql_log.write(thd, COM_PREPARE, "%s", packet); + mysql_log.write(thd, COM_PREPARE, "[%lu] %s", stmt->id, packet); thd->current_arena= stmt; mysql_init_query(thd, (uchar *) thd->query, thd->query_length); @@ -1792,6 +1792,9 @@ void mysql_stmt_execute(THD *thd, char *packet, uint packet_length) if (stmt->param_count && stmt->set_params_data(stmt, &expanded_query)) goto set_params_data_err; #endif + mysql_log.write(thd, COM_EXECUTE, "[%lu] %s", stmt->id, + expanded_query.length() ? expanded_query.c_ptr() : + stmt->query); thd->protocol= &thd->protocol_prep; // Switch to binary protocol execute_stmt(thd, stmt, &expanded_query, TRUE); thd->protocol= &thd->protocol_simple; // Use normal protocol