81
81
(grant_option && !check_grant_db(thd, file_name)))
83
83
thd->packet.length(0);
84
net_store_data(&thd->packet,file_name);
84
net_store_data(&thd->packet, thd->convert_set, file_name);
85
85
if (my_net_write(&thd->net, (char*) thd->packet.ptr(),
86
86
thd->packet.length()))
95
95
** List all open tables in a database
96
96
***************************************************************************/
98
int mysqld_show_open_tables(THD *thd,const char *db,const char *wild)
98
int mysqld_show_open_tables(THD *thd,const char *wild)
100
Item_string *field=new Item_string("",0);
101
100
List<Item> field_list;
102
char *end,*table_name;
101
OPEN_TABLE_LIST *open_list;
102
CONVERT *convert=thd->convert_set;
104
103
DBUG_ENTER("mysqld_show_open_tables");
106
field->name=(char*) thd->alloc(20+(uint) strlen(db)+(wild ? (uint) strlen(wild)+4:0));
107
end=strxmov(field->name,"Open_tables_in_",db,NullS);
109
strxmov(end," (",wild,")",NullS);
110
field->max_length=NAME_LEN;
111
field_list.push_back(field);
112
field_list.push_back(new Item_empty_string("Comment",80));
105
field_list.push_back(new Item_empty_string("Database",NAME_LEN));
106
field_list.push_back(new Item_empty_string("Table",NAME_LEN));
107
field_list.push_back(new Item_int("In_use",0, 4));
108
field_list.push_back(new Item_int("Name_locked",0, 4));
114
110
if (send_fields(thd,field_list,1))
117
if (list_open_tables(thd,&tables,db,wild))
113
if (!(open_list=list_open_tables(thd,wild)))
120
List_iterator<char> it(tables);
121
while ((table_name=it++))
116
for ( ; open_list ; open_list=open_list->next)
123
118
thd->packet.length(0);
124
net_store_data(&thd->packet,table_name);
125
net_store_data(&thd->packet,query_table_status(thd,db,table_name));
119
net_store_data(&thd->packet,convert, open_list->db);
120
net_store_data(&thd->packet,convert, open_list->table);
121
net_store_data(&thd->packet,open_list->in_use);
122
net_store_data(&thd->packet,open_list->locked);
126
123
if (my_net_write(&thd->net,(char*) thd->packet.ptr(),thd->packet.length()))
131
126
send_eof(&thd->net);
293
289
TABLE_LIST table_list;
294
290
bzero((char*) &table_list,sizeof(table_list));
295
291
packet->length(0);
296
net_store_data(packet,file_name);
292
net_store_data(packet,convert, file_name);
297
293
table_list.db=(char*) db;
298
294
table_list.real_name=table_list.name=file_name;
299
295
if (!(table = open_ltable(thd, &table_list, TL_READ)))
301
297
for (uint i=0 ; i < field_list.elements ; i++)
302
298
net_store_null(packet);
303
net_store_data(packet,thd->net.last_error);
299
net_store_data(packet,convert, thd->net.last_error);
304
300
thd->net.last_error[0]=0;
308
304
struct tm tm_tmp;
309
305
handler *file=table->file;
310
306
file->info(HA_STATUS_VARIABLE | HA_STATUS_TIME | HA_STATUS_NO_LOCK);
311
net_store_data(packet, file->table_type());
312
net_store_data(packet,
307
net_store_data(packet, convert, file->table_type());
308
net_store_data(packet, convert,
313
309
(table->db_options_in_use & HA_OPTION_PACK_RECORD) ?
315
311
(table->db_options_in_use & HA_OPTION_COMPRESS_RECORD)
390
386
my_raid_type(file->raid_type), file->raid_chunks, file->raid_chunksize/RAID_BLOCK_SIZE);
391
387
ptr=strmov(ptr,buff);
393
net_store_data(packet, option_buff+1,
389
net_store_data(packet, convert, option_buff+1,
394
390
(ptr == option_buff ? 0 : (uint) (ptr-option_buff)-1));
476
473
bool null_default_value=0;
478
475
packet->length(0);
479
net_store_data(packet,field->field_name);
476
net_store_data(packet,convert,field->field_name);
480
477
field->sql_type(type);
481
net_store_data(packet,type.ptr(),type.length());
478
net_store_data(packet,convert,type.ptr(),type.length());
483
480
pos=(byte*) ((flags & NOT_NULL_FLAG) &&
484
481
field->type() != FIELD_TYPE_TIMESTAMP ?
486
net_store_data(packet,(const char*) pos);
483
net_store_data(packet,convert,(const char*) pos);
487
484
pos=(byte*) ((field->flags & PRI_KEY_FLAG) ? "PRI" :
488
485
(field->flags & UNIQUE_KEY_FLAG) ? "UNI" :
489
486
(field->flags & MULTIPLE_KEY_FLAG) ? "MUL":"");
490
net_store_data(packet,(char*) pos);
487
net_store_data(packet,convert,(char*) pos);
492
489
if (field->type() == FIELD_TYPE_TIMESTAMP ||
493
490
field->unireg_check == Field::NEXT_NUMBER)
496
493
{ // Not null by default
497
494
type.set(tmp,sizeof(tmp));
498
495
field->val_str(&type,&type);
499
net_store_data(packet,type.ptr(),type.length());
496
net_store_data(packet,convert,type.ptr(),type.length());
501
498
else if (field->maybe_null() || null_default_value)
502
499
net_store_null(packet); // Null as default
504
net_store_data(packet,tmp,0);
501
net_store_data(packet,convert,tmp,0);
507
504
if (field->unireg_check == Field::NEXT_NUMBER)
508
505
end=strmov(tmp,"auto_increment");
509
net_store_data(packet,tmp,(uint) (end-tmp));
506
net_store_data(packet,convert,tmp,(uint) (end-tmp));
521
518
end=strmov(end,grant_types.type_names[bitnr]);
524
net_store_data(packet,tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
521
net_store_data(packet,convert, tmp+1,end == tmp ? 0 : (uint) (end-tmp-1));
526
523
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
557
555
String *packet = &thd->packet;
559
557
packet->length(0);
560
net_store_data(packet, table->table_name);
558
net_store_data(packet,convert, table->table_name);
561
559
// a hack - we need to reserve some space for the length before
562
560
// we know what it is - let's assume that the length of create table
563
561
// statement will fit into 3 bytes ( 16 MB max :-) )
655
654
for (uint j=0 ; j < key_info->key_parts ; j++,key_part++)
657
656
packet->length(0);
658
net_store_data(packet,table->table_name);
659
net_store_data(packet,((key_info->flags & HA_NOSAME) ? "0" :"1"), 1);
660
net_store_data(packet,key_info->name);
657
net_store_data(packet,convert,table->table_name);
658
net_store_data(packet,convert,((key_info->flags & HA_NOSAME) ? "0" :"1"), 1);
659
net_store_data(packet,convert,key_info->name);
661
660
end=int10_to_str((long) (j+1),(char*) buff,10);
662
net_store_data(packet,buff,(uint) (end-buff));
663
net_store_data(packet,key_part->field ? key_part->field->field_name :
661
net_store_data(packet,convert,buff,(uint) (end-buff));
662
net_store_data(packet,convert,
663
key_part->field ? key_part->field->field_name :
664
664
"?unknown field?");
665
665
if (table->file->option_flag() & HA_READ_ORDER)
666
net_store_data(packet,((key_part->key_part_flag & HA_REVERSE_SORT)
666
net_store_data(packet,convert,
667
((key_part->key_part_flag & HA_REVERSE_SORT) ?
669
670
net_store_null(packet); /* purecov: inspected */
670
671
KEY *key=table->key_info+i;
673
674
ulong records=(table->file->records / key->rec_per_key[j]);
674
675
end=int10_to_str((long) records, buff, 10);
675
net_store_data(packet,buff,(uint) (end-buff));
676
net_store_data(packet,convert,buff,(uint) (end-buff));
678
679
net_store_null(packet);
681
682
table->field[key_part->fieldnr-1]->key_length())
683
684
end=int10_to_str((long) key_part->length, buff,10); /* purecov: inspected */
684
net_store_data(packet,buff,(uint) (end-buff)); /* purecov: inspected */
685
net_store_data(packet,convert,buff,(uint) (end-buff)); /* purecov: inspected */
687
688
net_store_null(packet);
688
689
net_store_null(packet); // No pack_information yet
689
net_store_data(packet,key_info->flags & HA_FULLTEXT ? "FULLTEXT":"");
690
net_store_data(packet,convert,
691
key_info->flags & HA_FULLTEXT ? "FULLTEXT":"");
690
692
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
691
693
DBUG_RETURN(1); /* purecov: inspected */
732
734
mysqld_dump_create_info(THD *thd, TABLE *table, int fd)
736
CONVERT *convert=thd->convert_set;
734
737
DBUG_ENTER("mysqld_dump_create_info");
735
738
DBUG_PRINT("enter",("table: %s",table->real_name));
736
740
String* packet = &thd->packet;
737
741
packet->length(0);
739
if(store_create_info(thd,table,packet))
742
if (store_create_info(thd,table,packet))
746
convert->convert((char*) packet->ptr(), packet->length());
744
749
if(my_net_write(&thd->net, (char*)packet->ptr(), packet->length()))
1033
1039
char buff[20],*end;
1034
1040
packet->length(0);
1035
1041
end=int10_to_str((long) thd_info->thread_id, buff,10);
1036
net_store_data(packet,buff,(uint) (end-buff));
1037
net_store_data(packet,thd_info->user);
1038
net_store_data(packet,thd_info->host);
1042
net_store_data(packet,convert,buff,(uint) (end-buff));
1043
net_store_data(packet,convert,thd_info->user);
1044
net_store_data(packet,convert,thd_info->host);
1039
1045
if (thd_info->db)
1040
net_store_data(packet,thd_info->db);
1046
net_store_data(packet,convert,thd_info->db);
1042
1048
net_store_null(packet);
1043
1049
if (thd_info->proc_info)
1044
net_store_data(packet,thd_info->proc_info);
1050
net_store_data(packet,convert,thd_info->proc_info);
1046
net_store_data(packet,command_name[thd_info->command]);
1052
net_store_data(packet,convert,command_name[thd_info->command]);
1047
1053
if (thd_info->start_time)
1048
net_store_data(packet,(uint32)
1049
(time((time_t*) 0) - thd_info->start_time));
1054
net_store_data(packet,
1055
(uint32) (time((time_t*) 0) - thd_info->start_time));
1051
1057
net_store_null(packet);
1052
1058
if (thd_info->state_info)
1053
net_store_data(packet,thd_info->state_info);
1059
net_store_data(packet,convert,thd_info->state_info);
1055
1061
net_store_null(packet);
1056
1062
if (thd_info->query)
1057
net_store_data(packet,thd_info->query);
1063
net_store_data(packet,convert,thd_info->query);
1059
1065
net_store_null(packet);
1060
1066
if (my_net_write(&thd->net,(char*) packet->ptr(),packet->length()))
1076
1082
char buff[8192];
1077
1083
String packet2(buff,sizeof(buff));
1078
1084
List<Item> field_list;
1085
CONVERT *convert=thd->convert_set;
1079
1086
DBUG_ENTER("mysqld_show");
1080
1087
field_list.push_back(new Item_empty_string("Variable_name",30));
1081
1088
field_list.push_back(new Item_empty_string("Value",256));