2001-02-17 14:19:19 +02:00
|
|
|
/******************************************************
|
|
|
|
Update of a row
|
|
|
|
|
|
|
|
(c) 1996 Innobase Oy
|
|
|
|
|
|
|
|
Created 12/27/1996 Heikki Tuuri
|
|
|
|
*******************************************************/
|
|
|
|
|
|
|
|
#include "mtr0log.h"
|
|
|
|
#include "trx0trx.h"
|
|
|
|
#include "trx0undo.h"
|
|
|
|
#include "row0row.h"
|
|
|
|
#include "btr0sea.h"
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Creates an update vector object. */
|
|
|
|
UNIV_INLINE
|
|
|
|
upd_t*
|
|
|
|
upd_create(
|
|
|
|
/*=======*/
|
|
|
|
/* out, own: update vector object */
|
|
|
|
ulint n, /* in: number of fields */
|
|
|
|
mem_heap_t* heap) /* in: heap from which memory allocated */
|
|
|
|
{
|
|
|
|
upd_t* update;
|
srv0srv.h Support raw disk partitions as data files
srv0start.c Support raw disk partitions as data files
srv0srv.c Support raw disk partitions as data files
row0purge.c < 4 GB rows, doublewrite, hang fixes
row0row.c < 4 GB rows, doublewrite, hang fixes
row0sel.c < 4 GB rows, doublewrite, hang fixes
row0uins.c < 4 GB rows, doublewrite, hang fixes
row0umod.c < 4 GB rows, doublewrite, hang fixes
row0undo.c < 4 GB rows, doublewrite, hang fixes
row0upd.c < 4 GB rows, doublewrite, hang fixes
srv0srv.c < 4 GB rows, doublewrite, hang fixes
srv0start.c < 4 GB rows, doublewrite, hang fixes
sync0rw.c < 4 GB rows, doublewrite, hang fixes
sync0sync.c < 4 GB rows, doublewrite, hang fixes
trx0purge.c < 4 GB rows, doublewrite, hang fixes
trx0rec.c < 4 GB rows, doublewrite, hang fixes
trx0sys.c < 4 GB rows, doublewrite, hang fixes
btr0btr.c < 4 GB rows, doublewrite, hang fixes
btr0cur.c < 4 GB rows, doublewrite, hang fixes
buf0buf.c < 4 GB rows, doublewrite, hang fixes
buf0flu.c < 4 GB rows, doublewrite, hang fixes
buf0rea.c < 4 GB rows, doublewrite, hang fixes
data0data.c < 4 GB rows, doublewrite, hang fixes
fil0fil.c < 4 GB rows, doublewrite, hang fixes
fsp0fsp.c < 4 GB rows, doublewrite, hang fixes
ibuf0ibuf.c < 4 GB rows, doublewrite, hang fixes
lock0lock.c < 4 GB rows, doublewrite, hang fixes
log0log.c < 4 GB rows, doublewrite, hang fixes
log0recv.c < 4 GB rows, doublewrite, hang fixes
os0file.c < 4 GB rows, doublewrite, hang fixes
page0cur.c < 4 GB rows, doublewrite, hang fixes
pars0pars.c < 4 GB rows, doublewrite, hang fixes
rem0cmp.c < 4 GB rows, doublewrite, hang fixes
rem0rec.c < 4 GB rows, doublewrite, hang fixes
row0ins.c < 4 GB rows, doublewrite, hang fixes
row0mysql.c < 4 GB rows, doublewrite, hang fixes
univ.i < 4 GB rows, doublewrite, hang fixes
data0data.ic < 4 GB rows, doublewrite, hang fixes
mach0data.ic < 4 GB rows, doublewrite, hang fixes
rem0rec.ic < 4 GB rows, doublewrite, hang fixes
row0upd.ic < 4 GB rows, doublewrite, hang fixes
trx0rec.ic < 4 GB rows, doublewrite, hang fixes
rem0cmp.h < 4 GB rows, doublewrite, hang fixes
rem0rec.h < 4 GB rows, doublewrite, hang fixes
row0ins.h < 4 GB rows, doublewrite, hang fixes
row0mysql.h < 4 GB rows, doublewrite, hang fixes
row0row.h < 4 GB rows, doublewrite, hang fixes
row0upd.h < 4 GB rows, doublewrite, hang fixes
srv0srv.h < 4 GB rows, doublewrite, hang fixes
sync0sync.h < 4 GB rows, doublewrite, hang fixes
trx0rec.h < 4 GB rows, doublewrite, hang fixes
trx0sys.h < 4 GB rows, doublewrite, hang fixes
trx0types.h < 4 GB rows, doublewrite, hang fixes
trx0undo.h < 4 GB rows, doublewrite, hang fixes
ut0dbg.h < 4 GB rows, doublewrite, hang fixes
ut0ut.h < 4 GB rows, doublewrite, hang fixes
btr0btr.h < 4 GB rows, doublewrite, hang fixes
btr0cur.h < 4 GB rows, doublewrite, hang fixes
buf0buf.h < 4 GB rows, doublewrite, hang fixes
buf0flu.h < 4 GB rows, doublewrite, hang fixes
data0data.h < 4 GB rows, doublewrite, hang fixes
dict0mem.h < 4 GB rows, doublewrite, hang fixes
fil0fil.h < 4 GB rows, doublewrite, hang fixes
fsp0fsp.h < 4 GB rows, doublewrite, hang fixes
os0file.h < 4 GB rows, doublewrite, hang fixes
2001-08-04 19:36:14 +03:00
|
|
|
ulint i;
|
2001-02-17 14:19:19 +02:00
|
|
|
|
|
|
|
update = mem_heap_alloc(heap, sizeof(upd_t));
|
|
|
|
|
|
|
|
update->info_bits = 0;
|
|
|
|
update->n_fields = n;
|
|
|
|
update->fields = mem_heap_alloc(heap, sizeof(upd_field_t) * n);
|
|
|
|
|
srv0srv.h Support raw disk partitions as data files
srv0start.c Support raw disk partitions as data files
srv0srv.c Support raw disk partitions as data files
row0purge.c < 4 GB rows, doublewrite, hang fixes
row0row.c < 4 GB rows, doublewrite, hang fixes
row0sel.c < 4 GB rows, doublewrite, hang fixes
row0uins.c < 4 GB rows, doublewrite, hang fixes
row0umod.c < 4 GB rows, doublewrite, hang fixes
row0undo.c < 4 GB rows, doublewrite, hang fixes
row0upd.c < 4 GB rows, doublewrite, hang fixes
srv0srv.c < 4 GB rows, doublewrite, hang fixes
srv0start.c < 4 GB rows, doublewrite, hang fixes
sync0rw.c < 4 GB rows, doublewrite, hang fixes
sync0sync.c < 4 GB rows, doublewrite, hang fixes
trx0purge.c < 4 GB rows, doublewrite, hang fixes
trx0rec.c < 4 GB rows, doublewrite, hang fixes
trx0sys.c < 4 GB rows, doublewrite, hang fixes
btr0btr.c < 4 GB rows, doublewrite, hang fixes
btr0cur.c < 4 GB rows, doublewrite, hang fixes
buf0buf.c < 4 GB rows, doublewrite, hang fixes
buf0flu.c < 4 GB rows, doublewrite, hang fixes
buf0rea.c < 4 GB rows, doublewrite, hang fixes
data0data.c < 4 GB rows, doublewrite, hang fixes
fil0fil.c < 4 GB rows, doublewrite, hang fixes
fsp0fsp.c < 4 GB rows, doublewrite, hang fixes
ibuf0ibuf.c < 4 GB rows, doublewrite, hang fixes
lock0lock.c < 4 GB rows, doublewrite, hang fixes
log0log.c < 4 GB rows, doublewrite, hang fixes
log0recv.c < 4 GB rows, doublewrite, hang fixes
os0file.c < 4 GB rows, doublewrite, hang fixes
page0cur.c < 4 GB rows, doublewrite, hang fixes
pars0pars.c < 4 GB rows, doublewrite, hang fixes
rem0cmp.c < 4 GB rows, doublewrite, hang fixes
rem0rec.c < 4 GB rows, doublewrite, hang fixes
row0ins.c < 4 GB rows, doublewrite, hang fixes
row0mysql.c < 4 GB rows, doublewrite, hang fixes
univ.i < 4 GB rows, doublewrite, hang fixes
data0data.ic < 4 GB rows, doublewrite, hang fixes
mach0data.ic < 4 GB rows, doublewrite, hang fixes
rem0rec.ic < 4 GB rows, doublewrite, hang fixes
row0upd.ic < 4 GB rows, doublewrite, hang fixes
trx0rec.ic < 4 GB rows, doublewrite, hang fixes
rem0cmp.h < 4 GB rows, doublewrite, hang fixes
rem0rec.h < 4 GB rows, doublewrite, hang fixes
row0ins.h < 4 GB rows, doublewrite, hang fixes
row0mysql.h < 4 GB rows, doublewrite, hang fixes
row0row.h < 4 GB rows, doublewrite, hang fixes
row0upd.h < 4 GB rows, doublewrite, hang fixes
srv0srv.h < 4 GB rows, doublewrite, hang fixes
sync0sync.h < 4 GB rows, doublewrite, hang fixes
trx0rec.h < 4 GB rows, doublewrite, hang fixes
trx0sys.h < 4 GB rows, doublewrite, hang fixes
trx0types.h < 4 GB rows, doublewrite, hang fixes
trx0undo.h < 4 GB rows, doublewrite, hang fixes
ut0dbg.h < 4 GB rows, doublewrite, hang fixes
ut0ut.h < 4 GB rows, doublewrite, hang fixes
btr0btr.h < 4 GB rows, doublewrite, hang fixes
btr0cur.h < 4 GB rows, doublewrite, hang fixes
buf0buf.h < 4 GB rows, doublewrite, hang fixes
buf0flu.h < 4 GB rows, doublewrite, hang fixes
data0data.h < 4 GB rows, doublewrite, hang fixes
dict0mem.h < 4 GB rows, doublewrite, hang fixes
fil0fil.h < 4 GB rows, doublewrite, hang fixes
fsp0fsp.h < 4 GB rows, doublewrite, hang fixes
os0file.h < 4 GB rows, doublewrite, hang fixes
2001-08-04 19:36:14 +03:00
|
|
|
for (i = 0; i < n; i++) {
|
|
|
|
update->fields[i].extern_storage = 0;
|
|
|
|
}
|
|
|
|
|
2001-02-17 14:19:19 +02:00
|
|
|
return(update);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Returns the number of fields in the update vector == number of columns
|
|
|
|
to be updated by an update vector. */
|
|
|
|
UNIV_INLINE
|
|
|
|
ulint
|
|
|
|
upd_get_n_fields(
|
|
|
|
/*=============*/
|
|
|
|
/* out: number of fields */
|
|
|
|
upd_t* update) /* in: update vector */
|
|
|
|
{
|
|
|
|
ut_ad(update);
|
|
|
|
|
|
|
|
return(update->n_fields);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Returns the nth field of an update vector. */
|
|
|
|
UNIV_INLINE
|
|
|
|
upd_field_t*
|
|
|
|
upd_get_nth_field(
|
|
|
|
/*==============*/
|
|
|
|
/* out: update vector field */
|
|
|
|
upd_t* update, /* in: update vector */
|
|
|
|
ulint n) /* in: field position in update vector */
|
|
|
|
{
|
|
|
|
ut_ad(update);
|
|
|
|
ut_ad(n < update->n_fields);
|
|
|
|
|
|
|
|
return(update->fields + n);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
2001-10-10 22:47:08 +03:00
|
|
|
Sets an index field number to be updated by an update vector field. */
|
2001-02-17 14:19:19 +02:00
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
upd_field_set_field_no(
|
|
|
|
/*===================*/
|
|
|
|
upd_field_t* upd_field, /* in: update vector field */
|
|
|
|
ulint field_no, /* in: field number in a clustered
|
|
|
|
index */
|
2004-10-01 11:51:59 +03:00
|
|
|
dict_index_t* index, /* in: index */
|
|
|
|
trx_t* trx) /* in: transaction */
|
2001-10-10 22:47:08 +03:00
|
|
|
{
|
2001-02-17 14:19:19 +02:00
|
|
|
upd_field->field_no = field_no;
|
|
|
|
|
2005-04-22 14:04:18 +03:00
|
|
|
if (UNIV_UNLIKELY(field_no >= dict_index_get_n_fields(index))) {
|
2001-10-10 22:47:08 +03:00
|
|
|
fprintf(stderr,
|
2004-04-06 16:14:43 +03:00
|
|
|
"InnoDB: Error: trying to access field %lu in ",
|
2004-04-26 15:53:31 +03:00
|
|
|
(ulong) field_no);
|
2004-10-01 11:51:59 +03:00
|
|
|
dict_index_name_print(stderr, trx, index);
|
2004-04-06 16:14:43 +03:00
|
|
|
fprintf(stderr, "\n"
|
|
|
|
"InnoDB: but index only has %lu fields\n",
|
2004-04-26 15:53:31 +03:00
|
|
|
(ulong) dict_index_get_n_fields(index));
|
2001-10-10 22:47:08 +03:00
|
|
|
}
|
|
|
|
|
2001-02-17 14:19:19 +02:00
|
|
|
dtype_copy(dfield_get_type(&(upd_field->new_val)),
|
|
|
|
dict_index_get_nth_type(index, field_no));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*************************************************************************
|
|
|
|
Updates the trx id and roll ptr field in a clustered index record when
|
|
|
|
a row is updated or marked deleted. */
|
|
|
|
UNIV_INLINE
|
|
|
|
void
|
|
|
|
row_upd_rec_sys_fields(
|
|
|
|
/*===================*/
|
|
|
|
rec_t* rec, /* in: record */
|
|
|
|
dict_index_t* index, /* in: clustered index */
|
2004-12-02 19:45:07 +02:00
|
|
|
const ulint* offsets,/* in: rec_get_offsets(rec, index) */
|
2001-02-17 14:19:19 +02:00
|
|
|
trx_t* trx, /* in: transaction */
|
|
|
|
dulint roll_ptr)/* in: roll ptr of the undo log record */
|
|
|
|
{
|
|
|
|
ut_ad(index->type & DICT_CLUSTERED);
|
2004-12-02 19:45:07 +02:00
|
|
|
ut_ad(rec_offs_validate(rec, index, offsets));
|
2004-03-12 17:14:51 +02:00
|
|
|
#ifdef UNIV_SYNC_DEBUG
|
2001-02-17 14:19:19 +02:00
|
|
|
ut_ad(!buf_block_align(rec)->is_hashed
|
|
|
|
|| rw_lock_own(&btr_search_latch, RW_LOCK_EX));
|
2004-03-12 17:14:51 +02:00
|
|
|
#endif /* UNIV_SYNC_DEBUG */
|
2001-02-17 14:19:19 +02:00
|
|
|
|
2004-12-02 19:45:07 +02:00
|
|
|
row_set_rec_trx_id(rec, index, offsets, trx->id);
|
|
|
|
row_set_rec_roll_ptr(rec, index, offsets, roll_ptr);
|
2001-02-17 14:19:19 +02:00
|
|
|
}
|