From ef8a5401f146e0aa17d9cc342c52a82e16e7c6ef Mon Sep 17 00:00:00 2001 From: unknown Date: Mon, 5 Apr 2004 19:43:37 +0400 Subject: Many files: SQL Syntax for Prepared Statements (WL#1622) ps.test, ps.result: new file sql/item.cc: SQL Syntax for Prepared Statements (WL#1622) sql/item.h: SQL Syntax for Prepared Statements (WL#1622) sql/lex.h: SQL Syntax for Prepared Statements (WL#1622) sql/mysql_priv.h: SQL Syntax for Prepared Statements (WL#1622) sql/mysqld.cc: SQL Syntax for Prepared Statements (WL#1622) sql/sql_class.cc: SQL Syntax for Prepared Statements (WL#1622) sql/sql_class.h: SQL Syntax for Prepared Statements (WL#1622) sql/sql_lex.h: SQL Syntax for Prepared Statements (WL#1622) sql/sql_parse.cc: SQL Syntax for Prepared Statements (WL#1622) sql/sql_prepare.cc: SQL Syntax for Prepared Statements (WL#1622) sql/sql_yacc.yy: SQL Syntax for Prepared Statements (WL#1622) --- sql/sql_lex.h | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index b9d85a23011..b1dd0355d62 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -76,6 +76,7 @@ enum enum_sql_command { SQLCOM_SHOW_COLUMN_TYPES, SQLCOM_SHOW_STORAGE_ENGINES, SQLCOM_SHOW_PRIVILEGES, SQLCOM_HELP, SQLCOM_DROP_USER, SQLCOM_REVOKE_ALL, SQLCOM_CHECKSUM, + SQLCOM_PREPARE, SQLCOM_EXECUTE, SQLCOM_DEALLOCATE_PREPARE, /* This should be the last !!! */ SQLCOM_END }; @@ -583,6 +584,11 @@ typedef struct st_lex bool in_comment, ignore_space, verbose, simple_alter, no_write_to_binlog; bool derived_tables; bool safe_to_cache_query; + /* Prepared statements SQL syntax:*/ + LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */ + LEX_STRING prepared_stmt_code; /* Statement query (in PREPARE )*/ + /* Names of user variables holding parameters (in EXECUTE) */ + List prepared_stmt_params; st_lex() {} inline void uncacheable(uint8 cause) { -- cgit v1.2.1 From e7710af7f4c41e77355f5599aafb04999b358292 Mon Sep 17 00:00:00 2001 From: unknown Date: Fri, 21 May 2004 04:27:50 +0400 Subject: WL#1622 "SQL Syntax for Prepared Statements": Post-review fixes (1 of 2) mysql-test/r/ps.result: Added tests for PREPARE stmt1 FROM @var syntax mysql-test/t/ps.test: Added tests for PREPARE stmt1 FROM @var syntax mysys/my_error.c: Added support for "%.*s" format sql/item.cc: Removed one redundant Item_param::set_value function sql/item.h: Removed one redundant Item_param::set_value function sql/mysqld.cc: Reformmated the code sql/share/czech/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/dutch/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/english/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/estonian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/french/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/german/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/greek/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/hungarian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/italian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/japanese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/korean/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian-ny/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/norwegian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/polish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/portuguese/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/romanian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/russian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/slovak/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/spanish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/swedish/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/share/ukrainian/errmsg.txt: Changed ER_UNKNOWN_STMT_HANDLER format string sql/sql_class.h: SQL Prepared statements now can't be used by binary protocol commands sql/sql_lex.h: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_parse.cc: Added support for PREPARE stmt1 FROM @var syntax. sql/sql_prepare.cc: Code cleanup sql/sql_yacc.yy: Added support for PREPARE stmt1 FROM @var syntax. --- sql/sql_lex.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index a525bc485c1..9bea0de7b39 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -608,7 +608,13 @@ typedef struct st_lex bool safe_to_cache_query; /* Prepared statements SQL syntax:*/ LEX_STRING prepared_stmt_name; /* Statement name (in all queries) */ - LEX_STRING prepared_stmt_code; /* Statement query (in PREPARE )*/ + /* + Prepared statement query text or name of variable that holds the + prepared statement (in PREPARE ... queries) + */ + LEX_STRING prepared_stmt_code; + /* If true, prepared_stmt_code is a name of variable that holds the query */ + bool prepared_stmt_code_is_varref; /* Names of user variables holding parameters (in EXECUTE) */ List prepared_stmt_params; st_lex() {} -- cgit v1.2.1 From 934bb37d39b7c18c8d80eccdd914dc08f988c646 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 3 Jun 2004 23:17:18 +0200 Subject: Implementation of WL#1824 "Add replication of character set variables in 4.1", by binlogging some SET ONE_SHOT CHARACTER_SETetc, which will be enough until we have it more compact and more complete in 5.0. With the present patch, replication will work ok between 4.1.3 master and slaves, as long as: - master and slave have the same GLOBAL.COLLATION_SERVER - COLLATION_DATABASE and CHARACTER_SET_DATABASE are not used - application does not use the fact that table is created with charset of the USEd db (BUG#2326). all of which are not too hard to fulfill. ONE_SHOT is reserved for internal use of mysqlbinlog|mysql and works only for charsets, so we give error if used for non-charset vars. Fix for BUG#3875 "mysqlbinlog produces wrong ouput if query uses variables containing quotes" and BUG#3943 "Queries with non-ASCII literals are not replicated properly after SET NAMES". Detecting that master and slave have different global charsets or server ids. mysql-test/r/rpl_server_id1.result: it's normal to not run as I have added a test to compare server ids of master and slave at startup and stop if equal (unless --replicate-same-server-id) mysql-test/r/rpl_user_variables.result: result update (as we now print charset of user var). mysql-test/r/user_var.result: result update mysql-test/t/rpl_server_id1.test: no need to select as slave is not running mysql-test/t/user_var.test: testing if the content of user vars is escaped when mysqlbinlog prints them, and if the name is backquoted. sql/lex.h: new keyword ONE_SHOT sql/log.cc: when writing to the binlog, before writing the actual statement, write some SET ONE_SHOT CHARACTER_SET_CLIENT etc for the slave to know the charset variables (which are important as they affect the inserted data). sql/log_event.cc: print charset and collation of user var in mysqlbinlog and SHOW BINLOG EVENTS. escape the content of the var. Backquote its name. Will ask Bar to check that using my_charset_bin for escaping is ok. sql/set_var.cc: understand SET CHARACTER_SET_CLIENT=10 (don't require a string, accept a number). Refuse changing of GLOBAL CHARACTER_SET_SERVER/COLLATION_SERVER if binlog or slave, as it will make the master or slave make wrong assumptions. A function to catch SET ONE_SHOT on non-charset variables (which is forbidden) sql/set_var.h: no_support_one_shot to know if the var supports ONE_SHOT (only charset vars do, soon timezones). Accept int arg in SET CHARACTER_SET_etc sql/slave.cc: when I/O slave thread starts, verify that master's and slave charsets match. And by the way verify that server ids are different. Don't fail if UNIX_TIMESTAMP() can't be done on master (very old master), that's not fatal. sql/sql_class.cc: one_shot sql/sql_class.h: one_shot sql/sql_lex.h: one_shot sql/sql_parse.cc: when SET ONE_SHOT is used, verify that it's only used for charset/collation vars; otherwise refuse. sql/sql_yacc.yy: ONE_SHOT keyword in SET --- sql/sql_lex.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 92ed53cf814..3884c8f2674 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -611,7 +611,7 @@ typedef struct st_lex uint fk_delete_opt, fk_update_opt, fk_match_option; uint slave_thd_opt; uint8 describe; - bool drop_if_exists, drop_temporary, local_file; + bool drop_if_exists, drop_temporary, local_file, one_shot_set; bool in_comment, ignore_space, verbose, no_write_to_binlog; bool derived_tables; bool safe_to_cache_query; -- cgit v1.2.1 From 07b5fdbcdb656b46c83d3585dc548107b5711609 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 9 Jun 2004 23:32:20 +0300 Subject: do not unlock tables early if we have subquery in HAVING clause (BUG#3984) mysql-test/r/subselect_innodb.result: test of unlocking innodb tables and subquery in HAVING clause mysql-test/t/subselect_innodb.test: test of unlocking innodb tables and subquery in HAVING clause sql/item_subselect.cc: mark SELECT with subquery in HAVING clause sql/sql_lex.cc: mark SELECT with subquery in HAVING clause sql/sql_lex.h: mark SELECT with subquery in HAVING clause sql/sql_select.cc: do not unlock tables early if we have subquery in HAVING clause --- sql/sql_lex.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 36e05b40c7d..6ecdcda46dc 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -433,6 +433,11 @@ public: bool having_fix_field; /* explicit LIMIT clause was used */ bool explicit_limit; + /* + there are subquery in HAVING clause => we can't close tables before + query processing end even if we use temporary table + */ + bool subquery_in_having; /* SELECT for SELECT command st_select_lex. Used to privent scaning -- cgit v1.2.1 From 47efa2071f946d57920e55a5a9e8ab91011b2588 Mon Sep 17 00:00:00 2001 From: unknown Date: Tue, 22 Jun 2004 00:00:36 +0300 Subject: fixed picture in comment. --- sql/sql_lex.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'sql/sql_lex.h') diff --git a/sql/sql_lex.h b/sql/sql_lex.h index 36e05b40c7d..54d9a09c1f3 100644 --- a/sql/sql_lex.h +++ b/sql/sql_lex.h @@ -175,8 +175,8 @@ enum tablespace_op_type e||+-------------------------+ || V| neighbor | V| unit1.1<+==================>unit1.2 unit2.1 - fake1.1 fake2.1 - select1.1.1 select 1.1.2 select1.2.1 select2.1.1 select2.1.2 + fake1.1 + select1.1.1 select 1.1.2 select1.2.1 select2.1.1 |^ || V| -- cgit v1.2.1