mirror of
https://github.com/MariaDB/server.git
synced 2025-02-01 03:21:53 +01:00
branches/zip: Add diagnostic printout.
rec_print_comp(): New function, sliced from rec_print_new(). rec_print_old(), rec_print_comp(): Print the untruncated length of the column. row_merge_print_read, row_merge_print_write, row_merge_print_cmp: New flags, to enable debug printout in UNIV_DEBUG builds. row_merge_tuple_print(): New function for UNIV_DEBUG builds. row_merge_read_rec(): Obey row_merge_print_read. row_merge_buf_write(), row_merge_write_rec_low(), row_merge_write_eof(): Obey row_merge_print_write. row_merge_cmp(): Obey row_merge_print_cmp.
This commit is contained in:
parent
e0ce04fd89
commit
619fd43a67
3 changed files with 144 additions and 26 deletions
|
@ -698,6 +698,16 @@ rec_print_old(
|
|||
FILE* file, /* in: file where to print */
|
||||
const rec_t* rec); /* in: physical record */
|
||||
/*******************************************************************
|
||||
Prints a physical record in ROW_FORMAT=COMPACT. Ignores the
|
||||
record header. */
|
||||
|
||||
void
|
||||
rec_print_comp(
|
||||
/*===========*/
|
||||
FILE* file, /* in: file where to print */
|
||||
const rec_t* rec, /* in: physical record */
|
||||
const ulint* offsets);/* in: array returned by rec_get_offsets() */
|
||||
/*******************************************************************
|
||||
Prints a physical record. */
|
||||
|
||||
void
|
||||
|
|
|
@ -1551,7 +1551,8 @@ rec_print_old(
|
|||
} else {
|
||||
ut_print_buf(file, data, 30);
|
||||
|
||||
fputs("...(truncated)", file);
|
||||
fprintf(file, " (total %lu bytes)",
|
||||
(ulong) len);
|
||||
}
|
||||
} else {
|
||||
fprintf(file, " SQL NULL, size %lu ",
|
||||
|
@ -1566,34 +1567,21 @@ rec_print_old(
|
|||
}
|
||||
|
||||
/*******************************************************************
|
||||
Prints a physical record. */
|
||||
Prints a physical record in ROW_FORMAT=COMPACT. Ignores the
|
||||
record header. */
|
||||
|
||||
void
|
||||
rec_print_new(
|
||||
/*==========*/
|
||||
rec_print_comp(
|
||||
/*===========*/
|
||||
FILE* file, /* in: file where to print */
|
||||
const rec_t* rec, /* in: physical record */
|
||||
const ulint* offsets)/* in: array returned by rec_get_offsets() */
|
||||
{
|
||||
const byte* data;
|
||||
ulint len;
|
||||
ulint i;
|
||||
|
||||
ut_ad(rec_offs_validate(rec, NULL, offsets));
|
||||
|
||||
if (!rec_offs_comp(offsets)) {
|
||||
rec_print_old(file, rec);
|
||||
return;
|
||||
}
|
||||
|
||||
ut_ad(rec);
|
||||
|
||||
fprintf(file, "PHYSICAL RECORD: n_fields %lu;"
|
||||
" compact format; info bits %lu\n",
|
||||
(ulong) rec_offs_n_fields(offsets),
|
||||
(ulong) rec_get_info_bits(rec, TRUE));
|
||||
ulint i;
|
||||
|
||||
for (i = 0; i < rec_offs_n_fields(offsets); i++) {
|
||||
const byte* data;
|
||||
ulint len;
|
||||
|
||||
data = rec_get_nth_field(rec, offsets, i, &len);
|
||||
|
||||
|
@ -1606,7 +1594,8 @@ rec_print_new(
|
|||
} else {
|
||||
ut_print_buf(file, data, 30);
|
||||
|
||||
fputs("...(truncated)", file);
|
||||
fprintf(file, " (total %lu bytes)",
|
||||
(ulong) len);
|
||||
}
|
||||
} else {
|
||||
fputs(" SQL NULL", file);
|
||||
|
@ -1615,7 +1604,33 @@ rec_print_new(
|
|||
}
|
||||
|
||||
putc('\n', file);
|
||||
}
|
||||
|
||||
/*******************************************************************
|
||||
Prints a physical record. */
|
||||
|
||||
void
|
||||
rec_print_new(
|
||||
/*==========*/
|
||||
FILE* file, /* in: file where to print */
|
||||
const rec_t* rec, /* in: physical record */
|
||||
const ulint* offsets)/* in: array returned by rec_get_offsets() */
|
||||
{
|
||||
ut_ad(rec);
|
||||
ut_ad(offsets);
|
||||
ut_ad(rec_offs_validate(rec, NULL, offsets));
|
||||
|
||||
if (!rec_offs_comp(offsets)) {
|
||||
rec_print_old(file, rec);
|
||||
return;
|
||||
}
|
||||
|
||||
fprintf(file, "PHYSICAL RECORD: n_fields %lu;"
|
||||
" compact format; info bits %lu\n",
|
||||
(ulong) rec_offs_n_fields(offsets),
|
||||
(ulong) rec_get_info_bits(rec, TRUE));
|
||||
|
||||
rec_print_comp(file, rec, offsets);
|
||||
rec_validate(rec, offsets);
|
||||
}
|
||||
|
||||
|
|
101
row/row0merge.c
101
row/row0merge.c
|
@ -39,6 +39,13 @@ Completed by Sunny Bains and Marko Makela
|
|||
#include "log0log.h"
|
||||
#include "ut0sort.h"
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
/* Set these in order ot enable debug printout. */
|
||||
static ibool row_merge_print_cmp;
|
||||
static ibool row_merge_print_read;
|
||||
static ibool row_merge_print_write;
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
/* Block size for I/O operations in merge sort */
|
||||
|
||||
typedef byte row_merge_block_t[16384];
|
||||
|
@ -78,6 +85,42 @@ struct merge_file_struct {
|
|||
|
||||
typedef struct merge_file_struct merge_file_t;
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
/**********************************************************
|
||||
Display a merge tuple. */
|
||||
static
|
||||
void
|
||||
row_merge_tuple_print(
|
||||
/*==================*/
|
||||
FILE* f, /* in: output stream */
|
||||
const dfield_t* entry, /* in: tuple to print */
|
||||
ulint n_fields)/* in: number of fields in the tuple */
|
||||
{
|
||||
ulint j;
|
||||
|
||||
for (j = 0; j < n_fields; j++) {
|
||||
const dfield_t* field = &entry[j];
|
||||
|
||||
if (dfield_is_null(field)) {
|
||||
fputs("\n NULL;", f);
|
||||
} else {
|
||||
ulint len = ut_min(field->len, 20);
|
||||
if (dfield_is_ext(field)) {
|
||||
fputs("\nE", f);
|
||||
} else {
|
||||
fputs("\n ", f);
|
||||
}
|
||||
ut_print_buf(f, field->data, len);
|
||||
if (len != field->len) {
|
||||
fprintf(f, " (total %lu bytes)",
|
||||
(ulong) field->len);
|
||||
}
|
||||
}
|
||||
}
|
||||
putc('\n', f);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
/**********************************************************
|
||||
Allocate a sort buffer. */
|
||||
static
|
||||
|
@ -423,6 +466,12 @@ row_merge_buf_write(
|
|||
|
||||
ut_ad(b + size < block[1]);
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_write) {
|
||||
fprintf(stderr, "row_merge_buf_write %lu", (ulong) i);
|
||||
row_merge_tuple_print(stderr, entry, n_fields);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
rec_convert_dtuple_to_rec_comp(b + extra_size, 0, index,
|
||||
REC_STATUS_ORDINARY,
|
||||
entry, n_fields);
|
||||
|
@ -439,6 +488,11 @@ row_merge_buf_write(
|
|||
to avoid bogus warnings. */
|
||||
memset(b, 0xff, block[1] - b);
|
||||
#endif /* UNIV_DEBUG_VALGRIND */
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_write) {
|
||||
fputs("row_merge_buf_write EOF\n", stderr);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
}
|
||||
|
||||
/**********************************************************
|
||||
|
@ -585,6 +639,11 @@ row_merge_read_rec(
|
|||
if (UNIV_UNLIKELY(!extra_size)) {
|
||||
/* End of list */
|
||||
*mrec = NULL;
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_read) {
|
||||
fputs("row_merge_read EOF\n", stderr);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
|
@ -649,7 +708,7 @@ err_exit:
|
|||
memcpy(*buf + extra_size, b, data_size);
|
||||
b += data_size;
|
||||
|
||||
return(b);
|
||||
goto func_exit;
|
||||
}
|
||||
|
||||
*mrec = b + extra_size;
|
||||
|
@ -664,7 +723,7 @@ err_exit:
|
|||
if (UNIV_LIKELY(b < block[1])) {
|
||||
/* The record fits entirely in the block.
|
||||
This is the normal case. */
|
||||
return(b);
|
||||
goto func_exit;
|
||||
}
|
||||
|
||||
/* The record spans two blocks. Copy it to buf. */
|
||||
|
@ -687,6 +746,15 @@ err_exit:
|
|||
memcpy(*buf + avail_size, b, extra_size + data_size - avail_size);
|
||||
b += extra_size + data_size - avail_size;
|
||||
|
||||
func_exit:
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_read) {
|
||||
fputs("row_merge_read ", stderr);
|
||||
rec_print_comp(stderr, *mrec, offsets);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
return(b);
|
||||
}
|
||||
|
||||
|
@ -706,9 +774,15 @@ row_merge_write_rec_low(
|
|||
{
|
||||
#ifdef UNIV_DEBUG
|
||||
const byte* const end = b + size;
|
||||
#endif /* UNIV_DEBUG */
|
||||
ut_ad(e == rec_offs_extra_size(offsets) + 1);
|
||||
|
||||
if (row_merge_print_write) {
|
||||
fputs("row_merge_write ", stderr);
|
||||
rec_print_comp(stderr, mrec, offsets);
|
||||
putc('\n', stderr);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
if (e < 0x80) {
|
||||
*b++ = e;
|
||||
} else {
|
||||
|
@ -807,6 +881,11 @@ row_merge_write_eof(
|
|||
ut_ad(b >= block[0]);
|
||||
ut_ad(b < block[1]);
|
||||
ut_ad(foffs);
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_write) {
|
||||
fputs("row_merge_write EOF\n", stderr);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
*b++ = 0;
|
||||
UNIV_MEM_ASSERT_RW(block[0], b - block[0]);
|
||||
|
@ -842,7 +921,21 @@ row_merge_cmp(
|
|||
const ulint* offsets2, /* in: second record offsets */
|
||||
dict_index_t* index) /* in: index */
|
||||
{
|
||||
return(cmp_rec_rec_simple(mrec1, mrec2, offsets1, offsets2, index));
|
||||
int cmp;
|
||||
|
||||
cmp = cmp_rec_rec_simple(mrec1, mrec2, offsets1, offsets2, index);
|
||||
|
||||
#ifdef UNIV_DEBUG
|
||||
if (row_merge_print_cmp) {
|
||||
fputs("row_merge_cmp1 ", stderr);
|
||||
rec_print_comp(stderr, mrec1, offsets1);
|
||||
fputs("\nrow_merge_cmp2 ", stderr);
|
||||
rec_print_comp(stderr, mrec2, offsets2);
|
||||
fprintf(stderr, "\nrow_merge_cmp=%d\n", cmp);
|
||||
}
|
||||
#endif /* UNIV_DEBUG */
|
||||
|
||||
return(cmp);
|
||||
}
|
||||
|
||||
/************************************************************************
|
||||
|
|
Loading…
Add table
Reference in a new issue