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

Function check_fields

sql/sql_update.cc:147–210  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

145*/
146
147static bool check_fields(THD *thd, TABLE_LIST *table, List<Item> &items,
148 bool update_view)
149{
150 Item *item;
151 if (update_view)
152 {
153 List_iterator<Item> it(items);
154 Item_field *field;
155 while ((item= it++))
156 {
157 if (!(field= item->field_for_view_update()))
158 {
159 /* item has name, because it comes from VIEW SELECT list */
160 my_error(ER_NONUPDATEABLE_COLUMN, MYF(0), item->name.str);
161 return TRUE;
162 }
163 /*
164 we make temporary copy of Item_field, to avoid influence of changing
165 result_field on Item_ref which refer on this field
166 */
167 thd->change_item_tree(it.ref(),
168 new (thd->mem_root) Item_field(thd, field));
169 }
170 }
171
172 if (thd->variables.sql_mode & MODE_SIMULTANEOUS_ASSIGNMENT)
173 {
174 // Make sure that a column is updated only once
175 List_iterator_fast<Item> it(items);
176 while ((item= it++))
177 {
178 item->field_for_view_update()->field->clear_has_explicit_value();
179 }
180 it.rewind();
181 while ((item= it++))
182 {
183 Field *f= item->field_for_view_update()->field;
184 if (f->has_explicit_value())
185 {
186 my_error(ER_UPDATED_COLUMN_ONLY_ONCE, MYF(0),
187 *(f->table_name), f->field_name.str);
188 return TRUE;
189 }
190 f->set_has_explicit_value();
191 }
192 }
193
194 if (table->has_period())
195 {
196 if (table->is_view_or_derived())
197 {
198 my_error(ER_IT_IS_A_VIEW, MYF(0), table->table_name.str);
199 return TRUE;
200 }
201 if (thd->lex->sql_command == SQLCOM_UPDATE_MULTI)
202 {
203 my_error(ER_NOT_SUPPORTED_YET, MYF(0),
204 "updating and querying the same temporal periods table");

Callers 1

handle_endMethod · 0.85

Calls 10

my_errorFunction · 0.85
change_item_treeMethod · 0.80
has_explicit_valueMethod · 0.80
has_periodMethod · 0.80
is_view_or_derivedMethod · 0.80
field_for_view_updateMethod · 0.45
refMethod · 0.45
rewindMethod · 0.45

Tested by

no test coverage detected