summaryrefslogtreecommitdiff
path: root/sql/table.h
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2018-09-06 22:45:19 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2018-09-06 22:45:19 +0200
commit31081593aabb116b6d8f86b6c7e76126edb392b4 (patch)
tree767a069f255359b5ea37e7c491dfeacf6e519fad /sql/table.h
parentb0026e33af8fc3b25a42099c096a84591fd550e2 (diff)
parent3a4242fd57b3a2235d2478ed080941b67a82ad1b (diff)
downloadmariadb-git-31081593aabb116b6d8f86b6c7e76126edb392b4.tar.gz
Merge branch '11.0' into 10.1
Diffstat (limited to 'sql/table.h')
-rw-r--r--sql/table.h59
1 files changed, 52 insertions, 7 deletions
diff --git a/sql/table.h b/sql/table.h
index bf9b55089ef..ca32234579f 100644
--- a/sql/table.h
+++ b/sql/table.h
@@ -1499,6 +1499,9 @@ enum enum_schema_table_state
PROCESSED_BY_JOIN_EXEC
};
+enum enum_fk_option { FK_OPTION_UNDEF, FK_OPTION_RESTRICT, FK_OPTION_CASCADE,
+ FK_OPTION_SET_NULL, FK_OPTION_NO_ACTION, FK_OPTION_SET_DEFAULT};
+
typedef struct st_foreign_key_info
{
LEX_STRING *foreign_id;
@@ -1506,13 +1509,16 @@ typedef struct st_foreign_key_info
LEX_STRING *foreign_table;
LEX_STRING *referenced_db;
LEX_STRING *referenced_table;
- LEX_STRING *update_method;
- LEX_STRING *delete_method;
+ enum_fk_option update_method;
+ enum_fk_option delete_method;
LEX_STRING *referenced_key_name;
List<LEX_STRING> foreign_fields;
List<LEX_STRING> referenced_fields;
} FOREIGN_KEY_INFO;
+LEX_CSTRING *fk_option_name(enum_fk_option opt);
+bool fk_modifies_child(enum_fk_option opt);
+
#define MY_I_S_MAYBE_NULL 1
#define MY_I_S_UNSIGNED 2
@@ -1760,6 +1766,14 @@ struct TABLE_LIST
const char *alias_arg,
enum thr_lock_type lock_type_arg)
{
+ enum enum_mdl_type mdl_type;
+ if (lock_type_arg >= TL_WRITE_ALLOW_WRITE)
+ mdl_type= MDL_SHARED_WRITE;
+ else if (lock_type_arg == TL_READ_NO_INSERT)
+ mdl_type= MDL_SHARED_NO_WRITE;
+ else
+ mdl_type= MDL_SHARED_READ;
+
bzero((char*) this, sizeof(*this));
db= (char*) db_name_arg;
db_length= db_length_arg;
@@ -1767,10 +1781,31 @@ struct TABLE_LIST
table_name_length= table_name_length_arg;
alias= (char*) (alias_arg ? alias_arg : table_name_arg);
lock_type= lock_type_arg;
- mdl_request.init(MDL_key::TABLE, db, table_name,
- (lock_type >= TL_WRITE_ALLOW_WRITE) ?
- MDL_SHARED_WRITE : MDL_SHARED_READ,
- MDL_TRANSACTION);
+ mdl_request.init(MDL_key::TABLE, db, table_name, mdl_type, MDL_TRANSACTION);
+ }
+
+ inline void init_one_table_for_prelocking(const char *db_name_arg,
+ size_t db_length_arg,
+ const char *table_name_arg,
+ size_t table_name_length_arg,
+ const char *alias_arg,
+ enum thr_lock_type lock_type_arg,
+ bool routine,
+ TABLE_LIST *belong_to_view_arg,
+ uint8 trg_event_map_arg,
+ TABLE_LIST ***last_ptr)
+ {
+ init_one_table(db_name_arg, db_length_arg, table_name_arg,
+ table_name_length_arg, alias_arg, lock_type_arg);
+ cacheable_table= 1;
+ prelocking_placeholder= routine ? ROUTINE : FK;
+ open_type= routine ? OT_TEMPORARY_OR_BASE : OT_BASE_ONLY;
+ belong_to_view= belong_to_view_arg;
+ trg_event_map= trg_event_map_arg;
+
+ **last_ptr= this;
+ prev_global= *last_ptr;
+ *last_ptr= &next_global;
}
/*
@@ -2049,7 +2084,7 @@ struct TABLE_LIST
This TABLE_LIST object is just placeholder for prelocking, it will be
used for implicit LOCK TABLES only and won't be used in real statement.
*/
- bool prelocking_placeholder;
+ enum { USER, ROUTINE, FK } prelocking_placeholder;
/**
Indicates that if TABLE_LIST object corresponds to the table/view
which requires special handling.
@@ -2366,6 +2401,16 @@ struct TABLE_LIST
}
void set_lock_type(THD* thd, enum thr_lock_type lock);
+ void remove_join_columns()
+ {
+ if (join_columns)
+ {
+ join_columns->empty();
+ join_columns= NULL;
+ is_join_columns_complete= FALSE;
+ }
+ }
+
private:
bool prep_check_option(THD *thd, uint8 check_opt_type);
bool prep_where(THD *thd, Item **conds, bool no_where_clause);