diff options
Diffstat (limited to 'sql')
-rw-r--r-- | sql/sql_class.h | 7 | ||||
-rw-r--r-- | sql/sql_parse.cc | 4 | ||||
-rw-r--r-- | sql/sql_prepare.cc | 8 | ||||
-rw-r--r-- | sql/sql_view.cc | 19 | ||||
-rw-r--r-- | sql/sql_yacc.yy | 15 |
5 files changed, 41 insertions, 12 deletions
diff --git a/sql/sql_class.h b/sql/sql_class.h index dd03225b501..9fe23de6cf5 100644 --- a/sql/sql_class.h +++ b/sql/sql_class.h @@ -436,6 +436,13 @@ public: #ifndef DBUG_OFF bool is_backup_arena; /* True if this arena is used for backup. */ #endif + /* + The states relfects three diffrent life cycles for three + different types of statements: + Prepared statement: INITIALIZED -> PREPARED -> EXECUTED. + Stored procedure: INITIALIZED_FOR_SP -> EXECUTED. + Other statements: CONVENTIONAL_EXECUTION never changes. + */ enum enum_state { INITIALIZED= 0, INITIALIZED_FOR_SP= 1, PREPARED= 2, diff --git a/sql/sql_parse.cc b/sql/sql_parse.cc index 66296377100..c4426f003a2 100644 --- a/sql/sql_parse.cc +++ b/sql/sql_parse.cc @@ -4094,6 +4094,10 @@ create_sp_error: #endif // ifndef DBUG_OFF case SQLCOM_CREATE_VIEW: { + /* + Note: SQLCOM_CREATE_VIEW also handles 'ALTER VIEW' commands + as specified through the thd->lex->create_view_mode flag. + */ if (end_active_trans(thd)) goto error; diff --git a/sql/sql_prepare.cc b/sql/sql_prepare.cc index 7badccd55d9..d1d70089584 100644 --- a/sql/sql_prepare.cc +++ b/sql/sql_prepare.cc @@ -1726,6 +1726,13 @@ static bool check_prepared_statement(Prepared_statement *stmt, res= mysql_test_create_table(stmt); break; + case SQLCOM_CREATE_VIEW: + if (lex->create_view_mode == VIEW_ALTER) + { + my_message(ER_UNSUPPORTED_PS, ER(ER_UNSUPPORTED_PS), MYF(0)); + goto error; + } + break; case SQLCOM_DO: res= mysql_test_do_fields(stmt, tables, lex->insert_list); break; @@ -1779,7 +1786,6 @@ static bool check_prepared_statement(Prepared_statement *stmt, case SQLCOM_ROLLBACK: case SQLCOM_TRUNCATE: case SQLCOM_CALL: - case SQLCOM_CREATE_VIEW: case SQLCOM_DROP_VIEW: case SQLCOM_REPAIR: case SQLCOM_ANALYZE: diff --git a/sql/sql_view.cc b/sql/sql_view.cc index dd17024aee0..73cd2276e54 100644 --- a/sql/sql_view.cc +++ b/sql/sql_view.cc @@ -205,18 +205,17 @@ fill_defined_view_parts (THD *thd, TABLE_LIST *view) } -/* - Creating/altering VIEW procedure +/** + @brief Creating/altering VIEW procedure - SYNOPSIS - mysql_create_view() - thd - thread handler - views - views to create - mode - VIEW_CREATE_NEW, VIEW_ALTER, VIEW_CREATE_OR_REPLACE + @param thd thread handler + @param views views to create + @param mode VIEW_CREATE_NEW, VIEW_ALTER, VIEW_CREATE_OR_REPLACE - RETURN VALUE - FALSE OK - TRUE Error + @note This function handles both create and alter view commands. + + @retval FALSE Operation was a success. + @retval TRUE An error occured. */ bool mysql_create_view(THD *thd, TABLE_LIST *views, diff --git a/sql/sql_yacc.yy b/sql/sql_yacc.yy index 2fbb46c23fb..a5f5c8ff9d4 100644 --- a/sql/sql_yacc.yy +++ b/sql/sql_yacc.yy @@ -5169,7 +5169,14 @@ alter: } | ALTER view_algorithm definer { - Lex->create_view_mode= VIEW_ALTER; + LEX *lex= Lex; + + if (lex->sphead) + { + my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"); + MYSQL_YYABORT; + } + lex->create_view_mode= VIEW_ALTER; } view_tail {} @@ -5181,6 +5188,12 @@ alter: */ { LEX *lex= Lex; + + if (lex->sphead) + { + my_error(ER_SP_BADSTATEMENT, MYF(0), "ALTER VIEW"); + MYSQL_YYABORT; + } lex->create_view_algorithm= VIEW_ALGORITHM_UNDEFINED; lex->create_view_mode= VIEW_ALTER; } |