summaryrefslogtreecommitdiff
path: root/sql/table.cc
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-06-28 10:59:01 +0300
committerMarko Mäkelä <marko.makela@mariadb.com>2022-06-28 10:59:01 +0300
commit404d4820af3fa9ea1aede5b02e0dac651598ee55 (patch)
treef9c82e85a1aee5758f859438e4253cdf95bdda8c /sql/table.cc
parentb81460f07e7f6df0fa9c25408c71d7f67ce4d3dd (diff)
parent952398629915bb7138a76b21c5a0b426ed1d83f4 (diff)
downloadmariadb-git-404d4820af3fa9ea1aede5b02e0dac651598ee55.tar.gz
Merge 10.8 into 10.9
Diffstat (limited to 'sql/table.cc')
-rw-r--r--sql/table.cc54
1 files changed, 54 insertions, 0 deletions
diff --git a/sql/table.cc b/sql/table.cc
index f0d51495953..2b41eaae129 100644
--- a/sql/table.cc
+++ b/sql/table.cc
@@ -9261,6 +9261,60 @@ bool TABLE::validate_default_values_of_unset_fields(THD *thd) const
}
+/*
+ Check assignment compatibility of a value list against an explicitly
+ specified field list, e.g.
+ INSERT INTO t1 (a,b) VALUES (1,2);
+*/
+bool TABLE::check_assignability_explicit_fields(List<Item> fields,
+ List<Item> values)
+{
+ DBUG_ENTER("TABLE::check_assignability_explicit_fields");
+ DBUG_ASSERT(fields.elements == values.elements);
+
+ List_iterator<Item> fi(fields);
+ List_iterator<Item> vi(values);
+ Item *f, *value;
+ while ((f= fi++) && (value= vi++))
+ {
+ Item_field *item_field= f->field_for_view_update();
+ if (!item_field)
+ {
+ /*
+ A non-updatable field of a view found.
+ This scenario is caught later and an error is raised.
+ We could eventually move error reporting here. For now just continue.
+ */
+ continue;
+ }
+ if (value->check_assignability_to(item_field->field))
+ DBUG_RETURN(true);
+ }
+ DBUG_RETURN(false);
+}
+
+
+/*
+ Check assignment compatibility for a value list against
+ all visible fields of the table, e.g.
+ INSERT INTO t1 VALUES (1,2);
+*/
+bool TABLE::check_assignability_all_visible_fields(List<Item> &values) const
+{
+ DBUG_ENTER("TABLE::check_assignability_all_visible_fields");
+ DBUG_ASSERT(s->visible_fields == values.elements);
+
+ List_iterator<Item> vi(values);
+ for (uint i= 0; i < s->fields; i++)
+ {
+ if (!field[i]->invisible &&
+ (vi++)->check_assignability_to(field[i]))
+ DBUG_RETURN(true);
+ }
+ DBUG_RETURN(false);
+}
+
+
bool TABLE::insert_all_rows_into_tmp_table(THD *thd,
TABLE *tmp_table,
TMP_TABLE_PARAM *tmp_table_param,