summaryrefslogtreecommitdiff
path: root/sql/sp_head.h
diff options
context:
space:
mode:
Diffstat (limited to 'sql/sp_head.h')
-rw-r--r--sql/sp_head.h66
1 files changed, 66 insertions, 0 deletions
diff --git a/sql/sp_head.h b/sql/sp_head.h
index c0881661ad1..a253d9edcbe 100644
--- a/sql/sp_head.h
+++ b/sql/sp_head.h
@@ -28,6 +28,7 @@
// in the CREATE TABLE command.
#define TYPE_ENUM_FUNCTION 1
#define TYPE_ENUM_PROCEDURE 2
+#define TYPE_ENUM_TRIGGER 3
Item_result
sp_map_result_type(enum enum_field_types type);
@@ -377,6 +378,71 @@ private:
}; // class sp_instr_set : public sp_instr
+/*
+ Set user variable instruction.
+ Used in functions and triggers to set user variables because we don't
+ want use sp_instr_stmt + "SET @a:=..." statement in this case since
+ latter will close all tables and thus will ruin execution of statement
+ calling/invoking this function/trigger.
+*/
+class sp_instr_set_user_var : public sp_instr
+{
+ sp_instr_set_user_var(const sp_instr_set_user_var &);
+ void operator=(sp_instr_set_user_var &);
+
+public:
+
+ sp_instr_set_user_var(uint ip, LEX_STRING var, Item *val)
+ : sp_instr(ip), m_set_var_item(var, val)
+ {}
+
+ virtual ~sp_instr_set_user_var()
+ {}
+
+ virtual int execute(THD *thd, uint *nextp);
+
+ virtual void print(String *str);
+
+private:
+
+ Item_func_set_user_var m_set_var_item;
+}; // class sp_instr_set_user_var : public sp_instr
+
+
+/*
+ Set NEW/OLD row field value instruction. Used in triggers.
+*/
+class sp_instr_set_trigger_field : public sp_instr
+{
+ sp_instr_set_trigger_field(const sp_instr_set_trigger_field &);
+ void operator=(sp_instr_set_trigger_field &);
+
+public:
+
+ sp_instr_set_trigger_field(uint ip, LEX_STRING field_name, Item *val)
+ : sp_instr(ip),
+ trigger_field(Item_trigger_field::NEW_ROW, field_name.str),
+ value(val)
+ {}
+
+ virtual ~sp_instr_set_trigger_field()
+ {}
+
+ virtual int execute(THD *thd, uint *nextp);
+
+ virtual void print(String *str);
+
+ bool setup_field(THD *thd, TABLE *table, enum trg_event_type event)
+ {
+ return trigger_field.setup_field(thd, table, event);
+ }
+private:
+
+ Item_trigger_field trigger_field;
+ Item *value;
+}; // class sp_instr_trigger_field : public sp_instr
+
+
class sp_instr_jump : public sp_instr
{
sp_instr_jump(const sp_instr_jump &); /* Prevent use of these */