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

Function update_portion_of_time

sql/sql_delete.cc:238–287  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238static
239int update_portion_of_time(THD *thd, TABLE *table,
240 const vers_select_conds_t &period_conds,
241 bool *inside_period)
242{
243 bool lcond= period_conds.field_start->val_datetime_packed(thd)
244 < period_conds.start.item->val_datetime_packed(thd);
245 bool rcond= period_conds.field_end->val_datetime_packed(thd)
246 > period_conds.end.item->val_datetime_packed(thd);
247
248 *inside_period= !lcond && !rcond;
249 if (*inside_period)
250 return 0;
251
252 DBUG_ASSERT(!table->triggers
253 || !table->triggers->has_triggers(TRG_EVENT_INSERT,
254 TRG_ACTION_BEFORE));
255
256 int res= 0;
257 Item *src= lcond ? period_conds.start.item : period_conds.end.item;
258 uint dst_fieldno= lcond ? table->s->period.end_fieldno
259 : table->s->period.start_fieldno;
260
261 ulonglong prev_insert_id= table->file->next_insert_id;
262 store_record(table, record[1]);
263 if (likely(!res))
264 res= src->save_in_field(table->field[dst_fieldno], true);
265
266 if (likely(!res))
267 {
268 table->period_prepare_autoinc();
269 res= table->update_generated_fields();
270 }
271
272 if(likely(!res))
273 res= table->file->ha_update_row(table->record[1], table->record[0]);
274
275 if (likely(!res) && table->triggers)
276 res= table->triggers->process_triggers(thd, TRG_EVENT_INSERT,
277 TRG_ACTION_AFTER, true, nullptr);
278 restore_record(table, record[1]);
279 if (res)
280 table->file->restore_auto_increment(prev_insert_id);
281
282 if (likely(!res) && lcond && rcond)
283 res= table->period_make_insert(period_conds.end.item,
284 table->field[table->s->period.start_fieldno]);
285
286 return res;
287}
288
289/**
290 Delete a record stored in:

Callers 1

Calls 9

has_triggersMethod · 0.80
ha_update_rowMethod · 0.80
period_make_insertMethod · 0.80
val_datetime_packedMethod · 0.45
save_in_fieldMethod · 0.45
process_triggersMethod · 0.45

Tested by

no test coverage detected