| 4026 | } |
| 4027 | |
| 4028 | static void |
| 4029 | print_table_data(MYSQL_RES *result) |
| 4030 | { |
| 4031 | String separator(256); |
| 4032 | MYSQL_ROW cur; |
| 4033 | bool *num_flag; |
| 4034 | |
| 4035 | num_flag=(bool*) my_alloca(sizeof(bool)*mysql_num_fields(result)); |
| 4036 | if (column_types_flag) |
| 4037 | { |
| 4038 | print_field_types(result); |
| 4039 | if (!mysql_num_rows(result)) |
| 4040 | { |
| 4041 | my_afree((uchar*) num_flag); |
| 4042 | return; |
| 4043 | } |
| 4044 | mysql_field_seek(result,0); |
| 4045 | } |
| 4046 | separator.copy("+",1,charset_info); |
| 4047 | while (MYSQL_FIELD *field= mysql_fetch_field(result)) |
| 4048 | { |
| 4049 | uint length= column_names ? field->name_length : 0; |
| 4050 | if (quick) |
| 4051 | length= MY_MAX(length, MY_MIN(field->length, quick_max_column_width)); |
| 4052 | else |
| 4053 | length= MY_MAX(length,field->max_length); |
| 4054 | if (length < 4 && !IS_NOT_NULL(field->flags)) |
| 4055 | length=4; // Room for "NULL" |
| 4056 | if (opt_binhex && is_binary_field(field)) |
| 4057 | length= 2 + length * 2; |
| 4058 | field->max_length=length; |
| 4059 | num_flag[mysql_field_tell(result) - 1]= IS_NUM(field->type); |
| 4060 | separator.fill(separator.length()+length+2,'-'); |
| 4061 | separator.append('+'); |
| 4062 | } |
| 4063 | separator.append('\0'); // End marker for \0 |
| 4064 | tee_puts((char*) separator.ptr(), PAGER); |
| 4065 | if (column_names) |
| 4066 | { |
| 4067 | mysql_field_seek(result,0); |
| 4068 | (void) tee_fputs("|", PAGER); |
| 4069 | while (MYSQL_FIELD *field= mysql_fetch_field(result)) |
| 4070 | { |
| 4071 | size_t name_length= (uint) strlen(field->name); |
| 4072 | size_t numcells= charset_info->numcells(field->name, |
| 4073 | field->name + name_length); |
| 4074 | size_t display_length= field->max_length + name_length - numcells; |
| 4075 | tee_fprintf(PAGER, " %-*s |",(int) MY_MIN(display_length, |
| 4076 | MAX_COLUMN_LENGTH), |
| 4077 | field->name); |
| 4078 | } |
| 4079 | (void) tee_fputs("\n", PAGER); |
| 4080 | tee_puts((char*) separator.ptr(), PAGER); |
| 4081 | } |
| 4082 | |
| 4083 | while ((cur = fetch_row(result))) |
| 4084 | { |
| 4085 | if (interrupted_query) |
no test coverage detected