Commit 8f18616e authored by marko's avatar marko

Reindent the code base (except for ha_innodb.{cc,h} and generated parser

and lexer files).  From now on, the following Emacs cc-mode settings apply
when indenting C function bodies in InnoDB:

(setq c-basic-offset 8)
(setq c-label-minimum-indentation 0)
(add-to-list 'c-offsets-alist '(c . 0))
(add-to-list 'c-offsets-alist '(label . [0]))

The indentation rules for function declarations still have not been
formalized, and they must be formatted manually.

Try to limit all lines to at most 79 characters (assuming TAB stops every
8 characters) by splitting lines before opening parenthesis, or at
string constants.

Fix some grammar mistakes in diagnostic output:
 match to, match with -> match
 found from -> found in
 trying rename -> trying to rename

Fix an error in page_check_dir(): it said "supremum not pointed to"
when the infimum was not pointed to.

Enclose commented-out code snippets in #if 0 ... #endif instead of /* ... */.
Add (void*) casts to some %p parameters in fprintf() calls.  Try to
split lines before a binary operator, not after one.  (These three fixes
were not made everywhere.)
parent bd338ceb
This diff is collapsed.
This diff is collapsed.
...@@ -92,9 +92,9 @@ btr_pcur_store_position( ...@@ -92,9 +92,9 @@ btr_pcur_store_position(
offs = ut_align_offset(rec, UNIV_PAGE_SIZE); offs = ut_align_offset(rec, UNIV_PAGE_SIZE);
ut_ad(mtr_memo_contains(mtr, buf_block_align(page), ut_ad(mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_S_FIX) MTR_MEMO_PAGE_S_FIX)
|| mtr_memo_contains(mtr, buf_block_align(page), || mtr_memo_contains(mtr, buf_block_align(page),
MTR_MEMO_PAGE_X_FIX)); MTR_MEMO_PAGE_X_FIX));
ut_a(cursor->latch_mode != BTR_NO_LATCHES); ut_a(cursor->latch_mode != BTR_NO_LATCHES);
if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) { if (UNIV_UNLIKELY(page_get_n_recs(page) == 0)) {
...@@ -133,14 +133,13 @@ btr_pcur_store_position( ...@@ -133,14 +133,13 @@ btr_pcur_store_position(
} }
cursor->old_stored = BTR_PCUR_OLD_STORED; cursor->old_stored = BTR_PCUR_OLD_STORED;
cursor->old_rec = dict_tree_copy_rec_order_prefix(tree, rec, cursor->old_rec = dict_tree_copy_rec_order_prefix
&cursor->old_n_fields, (tree, rec, &cursor->old_n_fields,
&cursor->old_rec_buf, &cursor->old_rec_buf, &cursor->buf_size);
&cursor->buf_size);
cursor->block_when_stored = buf_block_align(page); cursor->block_when_stored = buf_block_align(page);
cursor->modify_clock = buf_block_get_modify_clock( cursor->modify_clock = buf_block_get_modify_clock
cursor->block_when_stored); (cursor->block_when_stored);
} }
/****************************************************************** /******************************************************************
...@@ -165,7 +164,7 @@ btr_pcur_copy_stored_position( ...@@ -165,7 +164,7 @@ btr_pcur_copy_stored_position(
pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size); pcur_receive->old_rec_buf = mem_alloc(pcur_donate->buf_size);
ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf, ut_memcpy(pcur_receive->old_rec_buf, pcur_donate->old_rec_buf,
pcur_donate->buf_size); pcur_donate->buf_size);
pcur_receive->old_rec = pcur_receive->old_rec_buf pcur_receive->old_rec = pcur_receive->old_rec_buf
+ (pcur_donate->old_rec - pcur_donate->old_rec_buf); + (pcur_donate->old_rec - pcur_donate->old_rec_buf);
} }
...@@ -206,8 +205,8 @@ btr_pcur_restore_position( ...@@ -206,8 +205,8 @@ btr_pcur_restore_position(
mem_heap_t* heap; mem_heap_t* heap;
if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED) if (UNIV_UNLIKELY(cursor->old_stored != BTR_PCUR_OLD_STORED)
|| UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED || UNIV_UNLIKELY(cursor->pos_state != BTR_PCUR_WAS_POSITIONED
&& cursor->pos_state != BTR_PCUR_IS_POSITIONED)) { && cursor->pos_state != BTR_PCUR_IS_POSITIONED)) {
ut_print_buf(stderr, cursor, sizeof(btr_pcur_t)); ut_print_buf(stderr, cursor, sizeof(btr_pcur_t));
if (cursor->trx_if_known) { if (cursor->trx_if_known) {
trx_print(stderr, cursor->trx_if_known, 0); trx_print(stderr, cursor->trx_if_known, 0);
...@@ -216,19 +215,20 @@ btr_pcur_restore_position( ...@@ -216,19 +215,20 @@ btr_pcur_restore_position(
ut_error; ut_error;
} }
if (UNIV_UNLIKELY(cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE if (UNIV_UNLIKELY
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) { (cursor->rel_pos == BTR_PCUR_AFTER_LAST_IN_TREE
|| cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE)) {
/* In these cases we do not try an optimistic restoration, /* In these cases we do not try an optimistic restoration,
but always do a search */ but always do a search */
btr_cur_open_at_index_side( btr_cur_open_at_index_side
cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE, (cursor->rel_pos == BTR_PCUR_BEFORE_FIRST_IN_TREE,
btr_pcur_get_btr_cur(cursor)->index, latch_mode, btr_pcur_get_btr_cur(cursor)->index, latch_mode,
btr_pcur_get_btr_cur(cursor), mtr); btr_pcur_get_btr_cur(cursor), mtr);
cursor->block_when_stored = cursor->block_when_stored =
buf_block_align(btr_pcur_get_page(cursor)); buf_block_align(btr_pcur_get_page(cursor));
return(FALSE); return(FALSE);
} }
...@@ -239,12 +239,13 @@ btr_pcur_restore_position( ...@@ -239,12 +239,13 @@ btr_pcur_restore_position(
page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor)); page = btr_cur_get_page(btr_pcur_get_btr_cur(cursor));
if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF) if (UNIV_LIKELY(latch_mode == BTR_SEARCH_LEAF)
|| UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) { || UNIV_LIKELY(latch_mode == BTR_MODIFY_LEAF)) {
/* Try optimistic restoration */ /* Try optimistic restoration */
if (UNIV_LIKELY(buf_page_optimistic_get(latch_mode, if (UNIV_LIKELY
cursor->block_when_stored, page, (buf_page_optimistic_get(latch_mode,
cursor->modify_clock, mtr))) { cursor->block_when_stored, page,
cursor->modify_clock, mtr))) {
cursor->pos_state = BTR_PCUR_IS_POSITIONED; cursor->pos_state = BTR_PCUR_IS_POSITIONED;
#ifdef UNIV_SYNC_DEBUG #ifdef UNIV_SYNC_DEBUG
buf_page_dbg_add_level(page, SYNC_TREE_NODE); buf_page_dbg_add_level(page, SYNC_TREE_NODE);
...@@ -262,14 +263,16 @@ btr_pcur_restore_position( ...@@ -262,14 +263,16 @@ btr_pcur_restore_position(
index = btr_pcur_get_btr_cur(cursor)->index; index = btr_pcur_get_btr_cur(cursor)->index;
heap = mem_heap_create(256); heap = mem_heap_create(256);
offsets1 = rec_get_offsets(cursor->old_rec, offsets1 = rec_get_offsets
index, NULL, (cursor->old_rec, index, NULL,
cursor->old_n_fields, &heap); cursor->old_n_fields, &heap);
offsets2 = rec_get_offsets(rec, index, NULL, offsets2 = rec_get_offsets
cursor->old_n_fields, &heap); (rec, index, NULL,
cursor->old_n_fields, &heap);
ut_ad(cmp_rec_rec(cursor->old_rec,
rec, offsets1, offsets2, index) == 0); ut_ad(!cmp_rec_rec(cursor->old_rec,
rec, offsets1, offsets2,
index));
mem_heap_free(heap); mem_heap_free(heap);
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
return(TRUE); return(TRUE);
...@@ -285,7 +288,7 @@ btr_pcur_restore_position( ...@@ -285,7 +288,7 @@ btr_pcur_restore_position(
tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor)); tree = btr_cur_get_tree(btr_pcur_get_btr_cur(cursor));
tuple = dict_tree_build_data_tuple(tree, cursor->old_rec, tuple = dict_tree_build_data_tuple(tree, cursor->old_rec,
cursor->old_n_fields, heap); cursor->old_n_fields, heap);
/* Save the old search mode of the cursor */ /* Save the old search mode of the cursor */
old_mode = cursor->search_mode; old_mode = cursor->search_mode;
...@@ -300,17 +303,18 @@ btr_pcur_restore_position( ...@@ -300,17 +303,18 @@ btr_pcur_restore_position(
} }
btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple, btr_pcur_open_with_no_init(btr_pcur_get_btr_cur(cursor)->index, tuple,
mode, latch_mode, cursor, 0, mtr); mode, latch_mode, cursor, 0, mtr);
/* Restore the old search mode */ /* Restore the old search mode */
cursor->search_mode = old_mode; cursor->search_mode = old_mode;
if (cursor->rel_pos == BTR_PCUR_ON if (cursor->rel_pos == BTR_PCUR_ON
&& btr_pcur_is_on_user_rec(cursor, mtr) && btr_pcur_is_on_user_rec(cursor, mtr)
&& 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor), && 0 == cmp_dtuple_rec(tuple, btr_pcur_get_rec(cursor),
rec_get_offsets(btr_pcur_get_rec(cursor), rec_get_offsets
btr_pcur_get_btr_cur(cursor)->index, (btr_pcur_get_rec(cursor),
NULL, ULINT_UNDEFINED, &heap))) { btr_pcur_get_btr_cur(cursor)->index,
NULL, ULINT_UNDEFINED, &heap))) {
/* We have to store the NEW value for the modify clock, since /* We have to store the NEW value for the modify clock, since
the cursor can now be on a different page! But we can retain the cursor can now be on a different page! But we can retain
...@@ -467,14 +471,14 @@ btr_pcur_move_backward_from_page( ...@@ -467,14 +471,14 @@ btr_pcur_move_backward_from_page(
space = buf_frame_get_space_id(page); space = buf_frame_get_space_id(page);
if (btr_pcur_is_before_first_on_page(cursor, mtr) if (btr_pcur_is_before_first_on_page(cursor, mtr)
&& (prev_page_no != FIL_NULL)) { && (prev_page_no != FIL_NULL)) {
prev_page = btr_pcur_get_btr_cur(cursor)->left_page; prev_page = btr_pcur_get_btr_cur(cursor)->left_page;
btr_leaf_page_release(page, latch_mode, mtr); btr_leaf_page_release(page, latch_mode, mtr);
page_cur_set_after_last(prev_page, page_cur_set_after_last(prev_page,
btr_pcur_get_page_cur(cursor)); btr_pcur_get_page_cur(cursor));
} else if (prev_page_no != FIL_NULL) { } else if (prev_page_no != FIL_NULL) {
/* The repositioned cursor did not end on an infimum record on /* The repositioned cursor did not end on an infimum record on
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
...@@ -189,10 +189,10 @@ dfield_check_typed_no_assert( ...@@ -189,10 +189,10 @@ dfield_check_typed_no_assert(
dfield_t* field) /* in: data field */ dfield_t* field) /* in: data field */
{ {
if (dfield_get_type(field)->mtype > DATA_MYSQL if (dfield_get_type(field)->mtype > DATA_MYSQL
|| dfield_get_type(field)->mtype < DATA_VARCHAR) { || dfield_get_type(field)->mtype < DATA_VARCHAR) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: data field type %lu, len %lu\n", "InnoDB: Error: data field type %lu, len %lu\n",
(ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_type(field)->mtype,
(ulong) dfield_get_len(field)); (ulong) dfield_get_len(field));
return(FALSE); return(FALSE);
...@@ -215,9 +215,9 @@ dtuple_check_typed_no_assert( ...@@ -215,9 +215,9 @@ dtuple_check_typed_no_assert(
if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) { if (dtuple_get_n_fields(tuple) > REC_MAX_N_FIELDS) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: index entry has %lu fields\n", "InnoDB: Error: index entry has %lu fields\n",
(ulong) dtuple_get_n_fields(tuple)); (ulong) dtuple_get_n_fields(tuple));
dump: dump:
fputs("InnoDB: Tuple contents: ", stderr); fputs("InnoDB: Tuple contents: ", stderr);
dtuple_print(stderr, tuple); dtuple_print(stderr, tuple);
putc('\n', stderr); putc('\n', stderr);
...@@ -247,10 +247,10 @@ dfield_check_typed( ...@@ -247,10 +247,10 @@ dfield_check_typed(
dfield_t* field) /* in: data field */ dfield_t* field) /* in: data field */
{ {
if (dfield_get_type(field)->mtype > DATA_MYSQL if (dfield_get_type(field)->mtype > DATA_MYSQL
|| dfield_get_type(field)->mtype < DATA_VARCHAR) { || dfield_get_type(field)->mtype < DATA_VARCHAR) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Error: data field type %lu, len %lu\n", "InnoDB: Error: data field type %lu, len %lu\n",
(ulong) dfield_get_type(field)->mtype, (ulong) dfield_get_type(field)->mtype,
(ulong) dfield_get_len(field)); (ulong) dfield_get_len(field));
...@@ -319,8 +319,8 @@ dtuple_validate( ...@@ -319,8 +319,8 @@ dtuple_validate(
for (j = 0; j < len; j++) { for (j = 0; j < len; j++) {
data_dummy += *data; /* fool the compiler not data_dummy += *data; /* fool the compiler not
to optimize out this to optimize out this
code */ code */
data++; data++;
} }
} }
...@@ -518,14 +518,15 @@ dtuple_convert_big_rec( ...@@ -518,14 +518,15 @@ dtuple_convert_big_rec(
if (UNIV_UNLIKELY(size > 1000000000)) { if (UNIV_UNLIKELY(size > 1000000000)) {
fprintf(stderr, fprintf(stderr,
"InnoDB: Warning: tuple size very big: %lu\n", (ulong) size); "InnoDB: Warning: tuple size very big: %lu\n",
(ulong) size);
fputs("InnoDB: Tuple contents: ", stderr); fputs("InnoDB: Tuple contents: ", stderr);
dtuple_print(stderr, entry); dtuple_print(stderr, entry);
putc('\n', stderr); putc('\n', stderr);
} }
heap = mem_heap_create(size + dtuple_get_n_fields(entry) heap = mem_heap_create(size + dtuple_get_n_fields(entry)
* sizeof(big_rec_field_t) + 1000); * sizeof(big_rec_field_t) + 1000);
vector = mem_heap_alloc(heap, sizeof(big_rec_t)); vector = mem_heap_alloc(heap, sizeof(big_rec_t));
...@@ -539,13 +540,13 @@ dtuple_convert_big_rec( ...@@ -539,13 +540,13 @@ dtuple_convert_big_rec(
n_fields = 0; n_fields = 0;
while (rec_get_converted_size(index, entry) while (rec_get_converted_size(index, entry)
>= ut_min(page_get_free_space_of_empty( >= ut_min(page_get_free_space_of_empty
dict_table_is_comp(index->table)) / 2, (dict_table_is_comp(index->table)) / 2,
REC_MAX_DATA_SIZE)) { REC_MAX_DATA_SIZE)) {
longest = 0; longest = 0;
for (i = dict_index_get_n_unique_in_tree(index); for (i = dict_index_get_n_unique_in_tree(index);
i < dtuple_get_n_fields(entry); i++) { i < dtuple_get_n_fields(entry); i++) {
/* Skip over fields which already are externally /* Skip over fields which already are externally
stored */ stored */
...@@ -565,7 +566,7 @@ dtuple_convert_big_rec( ...@@ -565,7 +566,7 @@ dtuple_convert_big_rec(
dfield = dtuple_get_nth_field(entry, i); dfield = dtuple_get_nth_field(entry, i);
if (dfield->len != UNIV_SQL_NULL && if (dfield->len != UNIV_SQL_NULL &&
dfield->len > longest) { dfield->len > longest) {
longest = dfield->len; longest = dfield->len;
...@@ -582,7 +583,7 @@ dtuple_convert_big_rec( ...@@ -582,7 +583,7 @@ dtuple_convert_big_rec(
#endif #endif
if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10 if (longest < BTR_EXTERN_FIELD_REF_SIZE + 10
+ DICT_MAX_INDEX_COL_LEN) { + DICT_MAX_INDEX_COL_LEN) {
/* Cannot shorten more */ /* Cannot shorten more */
mem_heap_free(heap); mem_heap_free(heap);
...@@ -607,24 +608,24 @@ dtuple_convert_big_rec( ...@@ -607,24 +608,24 @@ dtuple_convert_big_rec(
ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN); ut_a(dfield->len > DICT_MAX_INDEX_COL_LEN);
vector->fields[n_fields].len = dfield->len vector->fields[n_fields].len = dfield->len
- DICT_MAX_INDEX_COL_LEN; - DICT_MAX_INDEX_COL_LEN;
vector->fields[n_fields].data = mem_heap_alloc(heap, vector->fields[n_fields].data = mem_heap_alloc
vector->fields[n_fields].len); (heap, vector->fields[n_fields].len);
/* Copy data (from the end of field) to big rec vector */ /* Copy data (from the end of field) to big rec vector */
ut_memcpy(vector->fields[n_fields].data, ut_memcpy(vector->fields[n_fields].data,
((byte*)dfield->data) + dfield->len ((byte*)dfield->data) + dfield->len
- vector->fields[n_fields].len, - vector->fields[n_fields].len,
vector->fields[n_fields].len); vector->fields[n_fields].len);
dfield->len = dfield->len - vector->fields[n_fields].len dfield->len = dfield->len - vector->fields[n_fields].len
+ BTR_EXTERN_FIELD_REF_SIZE; + BTR_EXTERN_FIELD_REF_SIZE;
/* Set the extern field reference in dfield to zero */ /* Set the extern field reference in dfield to zero */
memset(((byte*)dfield->data) memset(((byte*)dfield->data)
+ dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + dfield->len - BTR_EXTERN_FIELD_REF_SIZE,
0, BTR_EXTERN_FIELD_REF_SIZE); 0, BTR_EXTERN_FIELD_REF_SIZE);
n_fields++; n_fields++;
} }
...@@ -651,15 +652,15 @@ dtuple_convert_back_big_rec( ...@@ -651,15 +652,15 @@ dtuple_convert_back_big_rec(
for (i = 0; i < vector->n_fields; i++) { for (i = 0; i < vector->n_fields; i++) {
dfield = dtuple_get_nth_field(entry, dfield = dtuple_get_nth_field(entry,
vector->fields[i].field_no); vector->fields[i].field_no);
/* Copy data from big rec vector */ /* Copy data from big rec vector */
ut_memcpy(((byte*)dfield->data) ut_memcpy(((byte*)dfield->data)
+ dfield->len - BTR_EXTERN_FIELD_REF_SIZE, + dfield->len - BTR_EXTERN_FIELD_REF_SIZE,
vector->fields[i].data, vector->fields[i].data,
vector->fields[i].len); vector->fields[i].len);
dfield->len = dfield->len + vector->fields[i].len dfield->len = dfield->len + vector->fields[i].len
- BTR_EXTERN_FIELD_REF_SIZE; - BTR_EXTERN_FIELD_REF_SIZE;
} }
mem_heap_free(vector->heap); mem_heap_free(vector->heap);
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment