diff options
author | unknown <dlenev@brandersnatch.localdomain> | 2004-09-07 16:29:46 +0400 |
---|---|---|
committer | unknown <dlenev@brandersnatch.localdomain> | 2004-09-07 16:29:46 +0400 |
commit | 960c429daa80f59b694036539b2d89b7c836cc6e (patch) | |
tree | 1da70dd5c1cc43e315c793e1a029a25723888964 /sql/parse_file.cc | |
parent | 331b30124dacedf5ea65bcc2124c56e0e00e371d (diff) | |
download | mariadb-git-960c429daa80f59b694036539b2d89b7c836cc6e.tar.gz |
WL#1218 "Triggers". Some very preliminary version of patch.
Mostly needed for Monty for him getting notion what needed for triggers
from new .FRM format.
Things to be done:
- Right placement of trigger's invocations
- Right handling of errors in triggers (including transaction rollback)
- Support for priviliges
- Right handling of DROP/RENAME table (hope that it will be handled automatically
with merging of .TRG into .FRM file)
- Saving/restoring some information critical for trigger creation and replication
with their definitions (e.g. sql_mode, creator, ...)
- Replication
Already has some known bugs so probably not for general review.
include/mysqld_error.h:
Added trigger related error codes.
sql/Makefile.am:
Added sql_trigger.* files to list of sources from which mysqld is built.
sql/item.cc:
Added Item_trigger_field class representing field of new/old version of row which is
inserted/updated/deleted and for which trigger is invoked.
sql/item.h:
Added enums for describing trigger properties. (Here because of dependencies).
Added Item_trigger_field class representing field of new/old version of row which is
inserted/updated/deleted and for which trigger is invoked.
sql/item_func.cc:
Added Item_func_set_user_var::print_as_stmt() for printing of assignment to ser variable
from stored procedures.
Added comment clarifying why we don't need set no_send_ok when calling stored functions.
sql/item_func.h:
Added Item_func_set_user_var::print_as_stmt() for printing of assignment to ser variable
from stored procedures.
sql/lex.h:
Symbols used in statements defining triggers were added.
sql/mysql_priv.h:
Exported some functions needed for triggers implementation.
sql/parse_file.cc:
Cleaned up FILE_OPTIONS_STRLIST handling (needed for triggers).
sql/parse_file.h:
Cleaned up FILE_OPTIONS_STRLIST handling (needed for triggers).
sql/share/czech/errmsg.txt:
Added trigger related error messages.
sql/share/danish/errmsg.txt:
Added trigger related error messages.
sql/share/dutch/errmsg.txt:
Added trigger related error messages.
sql/share/english/errmsg.txt:
Added trigger related error messages.
sql/share/estonian/errmsg.txt:
Added trigger related error messages.
sql/share/french/errmsg.txt:
Added trigger related error messages.
sql/share/german/errmsg.txt:
Added trigger related error messages.
sql/share/greek/errmsg.txt:
Added trigger related error messages.
sql/share/hungarian/errmsg.txt:
Added trigger related error messages.
sql/share/italian/errmsg.txt:
Added trigger related error messages.
sql/share/japanese/errmsg.txt:
Added trigger related error messages.
sql/share/korean/errmsg.txt:
Added trigger related error messages.
sql/share/norwegian-ny/errmsg.txt:
Added trigger related error messages.
sql/share/norwegian/errmsg.txt:
Added trigger related error messages.
sql/share/polish/errmsg.txt:
Added trigger related error messages.
sql/share/portuguese/errmsg.txt:
Added trigger related error messages.
sql/share/romanian/errmsg.txt:
Added trigger related error messages.
sql/share/russian/errmsg.txt:
Added trigger related error messages.
sql/share/serbian/errmsg.txt:
Added trigger related error messages.
sql/share/slovak/errmsg.txt:
Added trigger related error messages.
sql/share/spanish/errmsg.txt:
Added trigger related error messages.
sql/share/swedish/errmsg.txt:
Added trigger related error messages.
sql/share/ukrainian/errmsg.txt:
Added trigger related error messages.
sql/sp_head.cc:
sp_head::init_strings(): added support for triggers
(we don't have most of strings for them)
sp_head::execute_function(): triggers don't require RETURN
sp_head::reset_lex(): added propagation of trigger properties to LEX used for
parsing of statements composing trigger body.
Added two more SP instructions:
- sp_instr_set_user_var for setting user variables in stored functions and triggers
(we can't use sp_instr_stmt and "SET @a:=..." statement since it will close open
tables and thus break execution of calling statement.
- sp_instr_set_trigger_field for assignment to fields of row being updated/inserted in
triggers
sql/sp_head.h:
Added new type of sp_head object - TYPE_ENUM_TRIGGER
Added two more SP instructions:
- sp_instr_set_user_var for setting user variables in stored functions and triggers
(we can't use sp_instr_stmt and "SET @a:=..." statement since it will close open
tables and thus break execution of calling statement.
- sp_instr_set_trigger_field for assignment to fields of row being updated/inserted in
triggers
sql/sql_base.cc:
Now freeing memory occupied by trigger related structures when closing tables.
open_unireg_entry(): added loading of triggers for table.
find_field_in_real_table() is now public since it required by Item_trigger_field in item.cc
sql/sql_delete.cc:
Added triggers invocation for DELETE (should be fixed for sure :))
sql/sql_insert.cc:
Added triggers invocation for INSERT (should be fixed for sure :))
sql/sql_lex.cc:
Added trg_new_row_fake_var variable pointer to which is used for distinguishing between
assignment to NEW row field (when parsing trigger definition) and structured variable.
Added initialization of LEX->trg_table to lex_start(). (When triggers are parsed during
opening of table it points to table object.)
sql/sql_lex.h:
Added trigger related commands.
Added st_trg_chistics structure describing properties of trigger being created
(as struct and as LEX member).
Added trg_new_row_fake_var variable pointer to which is used for
distinguishing between assignment to NEW row field (when parsing trigger definition)
and structured variable.
Added LEX::trg_table which points to table being opened when we are parsing trigger
definition while opening table.
sql/sql_parse.cc:
Added support for CREATE/DROP TRIGGER commands.
sql/sql_table.cc:
Cleanup. close_cached_table() always returns 0 and its result is not analyzed in most
places so chenged its return type to void.
sql/sql_update.cc:
Added triggers invocation for UPDATE (should be fixed for sure :))
sql/sql_yacc.yy:
Added support for CREATE/DROP TRIGGER statements.
Added support for OLD/NEW row identifiers in trigger.
Made assignment to user variables not to break execution of stored function or trigger.
sql/table.h:
Added TABLE::triggers member representing triggers for this table.
Diffstat (limited to 'sql/parse_file.cc')
-rw-r--r-- | sql/parse_file.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/sql/parse_file.cc b/sql/parse_file.cc index 231780f437e..4bd526d7136 100644 --- a/sql/parse_file.cc +++ b/sql/parse_file.cc @@ -46,7 +46,7 @@ write_escaped_string(IO_CACHE *file, LEX_STRING *val_s) { /* Should be in sync with read_escaped_string() and - parse_quated_escaped_string() + parse_quoted_escaped_string() */ switch(*ptr) { case '\\': // escape character @@ -154,11 +154,10 @@ write_parameter(IO_CACHE *file, gptr base, File_option *parameter, LEX_STRING *str; while ((str= it++)) { - num.set((ulonglong)str->length, &my_charset_bin); - // ',' after string to detect list continuation + // We need ' ' after string to detect list continuation if ((!first && my_b_append(file, (const byte *)" ", 1)) || my_b_append(file, (const byte *)"\'", 1) || - my_b_append(file, (const byte *)str->str, str->length) || + write_escaped_string(file, str) || my_b_append(file, (const byte *)"\'", 1)) { DBUG_RETURN(TRUE); @@ -486,7 +485,7 @@ read_escaped_string(char *ptr, char *eol, LEX_STRING *str) return TRUE; /* Should be in sync with write_escaped_string() and - parse_quated_escaped_string() + parse_quoted_escaped_string() */ switch(*ptr) { case '\\': @@ -562,7 +561,7 @@ parse_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) */ static char * -parse_quated_escaped_string(char *ptr, char *end, +parse_quoted_escaped_string(char *ptr, char *end, MEM_ROOT *mem_root, LEX_STRING *str) { char *eol; @@ -684,7 +683,6 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, my_error(ER_FPARSER_ERROR_IN_PARAMETER, MYF(0), parameter->name.str, line); DBUG_RETURN(TRUE); - DBUG_RETURN(TRUE); } break; } @@ -724,6 +722,7 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, /* TODO: remove play with mem_root, when List will be able to store MEM_ROOT* pointer for list elements allocation + FIXME: we can't handle empty lists */ sql_mem= my_pthread_getspecific_ptr(MEM_ROOT*, THR_MALLOC); list= (List<LEX_STRING>*)(base + parameter->offset); @@ -741,7 +740,7 @@ File_parser::parse(gptr base, MEM_ROOT *mem_root, sizeof(LEX_STRING))) || list->push_back(str)) goto list_err; - if(!(ptr= parse_quated_escaped_string(ptr, end, mem_root, str))) + if(!(ptr= parse_quoted_escaped_string(ptr, end, mem_root, str))) goto list_err_w_message; switch (*ptr) { case '\n': |