diff options
author | Sergei Golubchik <sergii@pisem.net> | 2014-02-22 22:51:20 +0100 |
---|---|---|
committer | Sergei Golubchik <sergii@pisem.net> | 2014-02-22 22:51:20 +0100 |
commit | ff2e82f4a175b7b023cd167b2fa6e6fcd1bd192e (patch) | |
tree | 63150adc067c1bb6cb476eef00094083e1a53865 /sql/filesort.cc | |
parent | 004642525d8c4ed02686719395faf477e94cd618 (diff) | |
parent | 3e03c9eae9089cd2cae0f378bd81ff29367f41eb (diff) | |
download | mariadb-git-ff2e82f4a175b7b023cd167b2fa6e6fcd1bd192e.tar.gz |
5.3 merge
Diffstat (limited to 'sql/filesort.cc')
-rw-r--r-- | sql/filesort.cc | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/sql/filesort.cc b/sql/filesort.cc index 0c91e42d426..4183c28f05b 100644 --- a/sql/filesort.cc +++ b/sql/filesort.cc @@ -424,6 +424,84 @@ static uchar *read_buffpek_from_file(IO_CACHE *buffpek_pointers, uint count, } #ifndef DBUG_OFF + +/* Buffer where record is returned */ +char dbug_print_row_buff[512]; + +/* Temporary buffer for printing a column */ +char dbug_print_row_buff_tmp[512]; + +/* + Print table's current row into a buffer and return a pointer to it. + + This is intended to be used from gdb: + + (gdb) p dbug_print_table_row(table) + $33 = "SUBQUERY2_t1(col_int_key,col_varchar_nokey)=(7,c)" + (gdb) + + Only columns in table->read_set are printed +*/ + +const char* dbug_print_table_row(TABLE *table) +{ + Field **pfield; + String tmp(dbug_print_row_buff_tmp, + sizeof(dbug_print_row_buff_tmp),&my_charset_bin); + + String output(dbug_print_row_buff, sizeof(dbug_print_row_buff), + &my_charset_bin); + + output.length(0); + output.append(table->alias); + output.append("("); + bool first= true; + + for (pfield= table->field; *pfield ; pfield++) + { + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + output.append((*pfield)->field_name? (*pfield)->field_name: "NULL"); + } + + output.append(")=("); + + first= true; + for (pfield= table->field; *pfield ; pfield++) + { + Field *field= *pfield; + + if (table->read_set && !bitmap_is_set(table->read_set, (*pfield)->field_index)) + continue; + + if (first) + first= false; + else + output.append(","); + + if (field->is_null()) + output.append("NULL"); + else + { + if (field->type() == MYSQL_TYPE_BIT) + (void) field->val_int_as_str(&tmp, 1); + else + field->val_str(&tmp); + output.append(tmp.ptr(), tmp.length()); + } + } + output.append(")"); + + return output.c_ptr_safe(); +} + + /* Print a text, SQL-like record representation into dbug trace. @@ -472,6 +550,7 @@ static void dbug_print_record(TABLE *table, bool print_rowid) fprintf(DBUG_FILE, "\n"); DBUG_UNLOCK_FILE; } + #endif /** |