Item_field、Field、Table下面的record关系

    class Field下的ptr等于Table->record[0]的值

    这个比较复杂,可以从

         key_part_info->field= new Field_string(table->record[0],

                                             (uint32) key_part_info->length,

                                             (uchar*) 0,

                                             (uint) 0,

                                             Field::NONE,

                                             NullS, &my_charset_bin);

    看出来,逻辑分散太多,就不列举了

     sub_select()通过

      error= info->read_record(info);--int rr_sequential(READ_RECORD *info) 读取数据库记录,

#0  _mi_read_rnd_static_record (info=0x9205e28, buf=0x91fd920 "齮est1", ' ' <repeats 15 times>, filepos=21, skip_deleted_blocks=1 '\001') at mi_statrec.c:208

#1  0x083c2a96 in mi_scan (info=0x9205e28, buf=0x91fd920 "齮est1", ' ' <repeats 15 times>) at mi_scan.c:44

#2  0x083acbeb in ha_myisam::rnd_next (this=0x91fd7b0, buf=0x91fd920 "齮est1", ' ' <repeats 15 times>) at ha_myisam.cc:1602

#3  0x082dea16 in rr_sequential (info=0x913418c) at records.cc:390

#4  0x08261f55 in sub_select (join=0x9206110, join_tab=0x9134148, end_of_records=false) at sql_select.cc:16291

#5  0x082602fd in do_select (join=0x9206110, fields=0x90d5c78, table=0x0, procedure=0x0) at sql_select.cc:15832

#6  0x08267785 in JOIN::exec (this=0x9206110) at sql_select.cc:2886

#7  0x08268373 in mysql_select (thd=0x90d49c0, rref_pointer_array=0x90d5ce8, tables=0x91338f8, wild_num=1, fields=@0x90d5c78, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0x9133d90, unit=0x90d5950, select_lex=0x90d5be4) at sql_select.cc:3067

#8  0x0826887d in handle_select (thd=0x90d49c0, lex=0x90d58f4, result=0x9133d90, setup_tables_done_option=0) at sql_select.cc:310

#9  0x081e1af7 in execute_sqlcom_select (thd=0x90d49c0, all_tables=0x91338f8) at sql_parse.cc:4943

#10 0x081e432f in mysql_execute_command (thd=0x90d49c0) at sql_parse.cc:2157

#11 0x081ebbfa in mysql_parse (thd=0x90d49c0, inBuf=0x91337c0 "select * from test", length=18, found_semicolon=0xb54c5f14) at sql_parse.cc:5958

#12 0x081ecae6 in dispatch_command (command=COM_QUERY, thd=0x90d49c0, packet=0x912b901 "", packet_length=18) at sql_parse.cc:1049

#13 0x081eddaa in do_command (thd=0x90d49c0) at sql_parse.cc:731

#14 0x081dd5a7 in handle_one_connection (arg=0x90d49c0) at sql_connect.cc:1146

#15 0x4dfe92db in start_thread (arg=0xb54c6790) at pthread_create.c:296

#16 0x006cf14e in clone () from /lib/libc.so.6

 

       通过select_send发送到客户端  

       调用堆栈如下:

#0  select_send::send_data (this=0x9133d90, items=@0x90d5c78) at sql_class.cc:1771

#1  0x0823dee7 in end_send (join=0x9206110, join_tab=0x91342e8, end_of_records=false) at sql_select.cc:17264

#2  0x08261cef in evaluate_join_record (join=0x9206110, join_tab=0x9134148, error=<value optimized out>) at sql_select.cc:16536

#3  0x08261eeb in sub_select (join=0x9206110, join_tab=0x9134148, end_of_records=false) at sql_select.cc:16273

#4  0x082602fd in do_select (join=0x9206110, fields=0x90d5c78, table=0x0, procedure=0x0) at sql_select.cc:15832

#5  0x08267785 in JOIN::exec (this=0x9206110) at sql_select.cc:2886

#6  0x08268373 in mysql_select (thd=0x90d49c0, rref_pointer_array=0x90d5ce8, tables=0x91338f8, wild_num=1, fields=@0x90d5c78, conds=0x0, og_num=0, order=0x0, group=0x0, having=0x0, proc_param=0x0, select_options=2147764736, result=0x9133d90, unit=0x90d5950, select_lex=0x90d5be4) at sql_select.cc:3067

#7  0x0826887d in handle_select (thd=0x90d49c0, lex=0x90d58f4, result=0x9133d90, setup_tables_done_option=0) at sql_select.cc:310

#8  0x081e1af7 in execute_sqlcom_select (thd=0x90d49c0, all_tables=0x91338f8) at sql_parse.cc:4943

#9  0x081e432f in mysql_execute_command (thd=0x90d49c0) at sql_parse.cc:2157

#10 0x081ebbfa in mysql_parse (thd=0x90d49c0, inBuf=0x91337c0 "select * from test", length=18, found_semicolon=0xb54c5f14) at sql_parse.cc:5958

#11 0x081ecae6 in dispatch_command (command=COM_QUERY, thd=0x90d49c0, packet=0x912b901 "", packet_length=18) at sql_parse.cc:1049

#12 0x081eddaa in do_command (thd=0x90d49c0) at sql_parse.cc:731

#13 0x081dd5a7 in handle_one_connection (arg=0x90d49c0) at sql_connect.cc:1146

#14 0x4dfe92db in start_thread (arg=0xb54c6790) at pthread_create.c:296

#15 0x006cf14e in clone () from /lib/libc.so.6

        具体看一下下面的函数

bool select_send::send_data(List<Item> &items)

protocol->send_result_set_row(&items)

item->send(this, &str_buffer)

}

 

bool Item_field::send(Protocol *protocol, String *buffer)

{

  return protocol->store(result_field);

}

 

bool Protocol_text::store(Field *field)

{

  if (field->is_null())

    return store_null();

#ifndef DBUG_OFF

  field_pos++;

#endif

  char buff[MAX_FIELD_WIDTH];

  String str(buff,sizeof(buff), &my_charset_bin);

  CHARSET_INFO *tocs= this->thd->variables.character_set_results;

#ifndef DBUG_OFF

  TABLE *table= field->table;

  my_bitmap_map *old_map= 0;

  if (table->file)

    old_map= dbug_tmp_use_all_columns(table, table->read_set);

#endif

 

  field->val_str(&str); --获取field的值,因为上面read_record,读取了单行记录,所以这里数据随record[0]的值改变而改变

#ifndef DBUG_OFF

  if (old_map)

    dbug_tmp_restore_column_map(table->read_set, old_map);

#endif

 

  return store_string_aux(str.ptr(), str.length(), str.charset(), tocs);

}

                                           

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值