MCPcopy Create free account
hub / github.com/MariaDB/server / check_view_single_update

Function check_view_single_update

sql/sql_insert.cc:128–194  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126*/
127
128static bool check_view_single_update(List<Item> &fields, List<Item> *values,
129 TABLE_LIST *view, table_map *map,
130 bool insert)
131{
132 /* it is join view => we need to find the table for update */
133 List_iterator_fast<Item> it(fields);
134 Item *item;
135 TABLE_LIST *tbl= 0; // reset for call to check_single_table()
136 table_map tables= 0;
137
138 while ((item= it++))
139 tables|= item->used_tables();
140
141 /*
142 Check that table is only one
143 (we can not rely on check_single_table because it skips some
144 types of tables)
145 */
146 if (my_count_bits(tables) > 1)
147 goto error;
148
149 if (values)
150 {
151 it.init(*values);
152 while ((item= it++))
153 tables|= item->view_used_tables(view);
154 }
155
156 /* Convert to real table bits */
157 tables&= ~PSEUDO_TABLE_BITS;
158
159 /* Check found map against provided map */
160 if (*map)
161 {
162 if (tables != *map)
163 goto error;
164 return FALSE;
165 }
166
167 if (view->check_single_table(&tbl, tables, view) || tbl == 0)
168 goto error;
169
170 /* view->table should have been set in mysql_derived_merge_for_insert */
171 DBUG_ASSERT(view->table);
172
173 /*
174 Use buffer for the insert values that was allocated for the merged view.
175 */
176 tbl->table->insert_values= view->table->insert_values;
177 view->table= tbl->table;
178 if (!tbl->single_table_updatable())
179 {
180 if (insert)
181 my_error(ER_NON_INSERTABLE_TABLE, MYF(0), view->alias.str, "INSERT");
182 else
183 my_error(ER_NON_UPDATABLE_TABLE, MYF(0), view->alias.str, "UPDATE");
184 return TRUE;
185 }

Callers 2

check_insert_fieldsFunction · 0.85
check_update_fieldsFunction · 0.85

Calls 7

my_count_bitsFunction · 0.85
my_errorFunction · 0.85
view_used_tablesMethod · 0.80
check_single_tableMethod · 0.80
used_tablesMethod · 0.45
initMethod · 0.45

Tested by

no test coverage detected